|
|
@ -18,6 +18,7 @@ import com.elink.esua.epdc.vaccine.common.base.BaseVimCurdServiceImpl; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.constant.StrConstant; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dao.EpidemicUserInfoDao; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dao.EpidemicUserInoutRecordDao; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dto.EpidemicUserDeptInfoDTO; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dto.EpidemicUserInfoDTO; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dto.EpidemicUserInfoDTOV2; |
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserInfoEntity; |
|
|
@ -50,6 +51,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.io.File; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -110,6 +112,11 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
Map<String, Object> authParams = vaccinationUserRoleService.getVaccinationAuthParams(user.getId()); |
|
|
|
params.putAll(authParams); |
|
|
|
|
|
|
|
// 街道和超管有权查看所有数据
|
|
|
|
if (NumConstant.ZERO == user.getSuperAdmin() && user.getDeptId() != 1258587398679126017L) { |
|
|
|
params.put("deptIdList", user.getDeptIdList()); |
|
|
|
} |
|
|
|
|
|
|
|
List<VaccinationInfoDTO> list = getVaccinationInfoList(params); |
|
|
|
return new PageData<>(list, page.getTotal()); |
|
|
|
} |
|
|
@ -157,6 +164,14 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
if (checkVaccination(dto).isEmpty()) { |
|
|
|
dto.setId(null); |
|
|
|
VaccinationInfoEntity entity = ConvertUtils.sourceToTarget(dto, VaccinationInfoEntity.class); |
|
|
|
EpidemicUserDeptInfoDTO dept= epidemicUserInfoDao.selectDeptInfoByIdCard(dto.getIdentityNo()); |
|
|
|
if(dept!=null){ |
|
|
|
entity.setGridId(dept.getGridId()); |
|
|
|
entity.setParentDeptIds(dept.getParentDeptIds()); |
|
|
|
entity.setParentDeptNames(dept.getParentDeptNames()); |
|
|
|
entity.setAllDeptIds(dept.getAllDeptIds()); |
|
|
|
entity.setAllDeptNames(dept.getAllDeptNames()); |
|
|
|
} |
|
|
|
baseDao.insert(entity); |
|
|
|
epidemicUserInfoService.updateVaccinationInfo(dto, true); |
|
|
|
} else { |
|
|
@ -230,6 +245,59 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新人员接种信息第一版 |
|
|
|
* |
|
|
|
* @param addressList |
|
|
|
* @param maxDoseMap |
|
|
|
* @return boolean |
|
|
|
* @author zhy |
|
|
|
* @date 2021/9/13 15:17 |
|
|
|
*/ |
|
|
|
private boolean updateEpidemicUserInfoV1(List<EpidemicUserInoutRecordEntity> addressList, Map<String, EpidemicUserInfoDTO> maxDoseMap) { |
|
|
|
List<String> idCards = new ArrayList<>(maxDoseMap.keySet()); |
|
|
|
List<EpidemicUserInfoDTO> updateList = new ArrayList<>(); |
|
|
|
EpidemicUserInfoDTO epidemicUserInfo; |
|
|
|
String idCard; |
|
|
|
|
|
|
|
if (!idCards.isEmpty()) { |
|
|
|
List<EpidemicUserInfoDTO> existUserList = epidemicUserInfoDao.selectByIdCards(idCards); |
|
|
|
addressList = epidemicUserInoutRecordDao.getAddressInfo(idCards); |
|
|
|
|
|
|
|
EpidemicUserInfoDTO updateDto; |
|
|
|
for (EpidemicUserInfoDTO item : existUserList) { |
|
|
|
if (null == item) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
idCard = item.getIdCard(); |
|
|
|
epidemicUserInfo = maxDoseMap.get(idCard.toUpperCase()); |
|
|
|
if (null == epidemicUserInfo) { |
|
|
|
log.error(idCard); |
|
|
|
continue; |
|
|
|
} |
|
|
|
updateDto = new EpidemicUserInfoDTO(); |
|
|
|
epidemicUserInfo = maxDoseMap.get(idCard.toUpperCase()); |
|
|
|
// 已经接种完的不需要处理,excel的剂次数据小于数据库时不需要处理,已经接种完的不需要处理
|
|
|
|
if (item.getVaccinationState() != NumConstant.TWO && item.getVaccinationNum() <= epidemicUserInfo.getVaccinationNum()) { |
|
|
|
updateDto.setIdCard(idCard); |
|
|
|
updateDto.setVaccinationNum(epidemicUserInfo.getVaccinationNum()); |
|
|
|
if (epidemicUserInfo.getVaccinationNum().equals(epidemicUserInfo.getMaxDose())) { |
|
|
|
// 如果最大剂次同于excel的剂次就是接种完成,否则是接种中
|
|
|
|
updateDto.setVaccinationState(2); |
|
|
|
} else { |
|
|
|
updateDto.setVaccinationState(1); |
|
|
|
} |
|
|
|
updateList.add(updateDto); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 更新人员的接种信息
|
|
|
|
for (EpidemicUserInfoDTO dto : updateList) { |
|
|
|
epidemicUserInfoDao.updateVaccinationInfo(dto); |
|
|
|
} |
|
|
|
log.info("待处理人员数量为:" + idCards.size() + "||可用地址数量为" + addressList.size() + "||实际需要更新的人员信息数量为:" + updateList.size()); |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @return boolean |
|
|
@ -239,7 +307,7 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
* @params addressList |
|
|
|
* @params maxDoseMap |
|
|
|
*/ |
|
|
|
private boolean updateEpidemicUserInfo(List<EpidemicUserInoutRecordEntity> addressList, Map<String, EpidemicUserInfoDTO> maxDoseMap) { |
|
|
|
private boolean updateEpidemicUserInfoV2(List<EpidemicUserInoutRecordEntity> addressList, Map<String, EpidemicUserInfoDTO> maxDoseMap) { |
|
|
|
List<String> idCards = new ArrayList<>(maxDoseMap.keySet()); |
|
|
|
if (!idCards.isEmpty()) { |
|
|
|
addressList = epidemicUserInoutRecordDao.getAddressInfo(idCards); |
|
|
@ -309,12 +377,19 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
* @params addList |
|
|
|
* addressList |
|
|
|
*/ |
|
|
|
private boolean insertBatchVaccination(List<VaccinationInfoAllExcel> addList, List<EpidemicUserInoutRecordEntity> addressList, List<Long> deleteIdCardArr) { |
|
|
|
private boolean insertBatchVaccination(List<VaccinationInfoAllExcel> addList, List<EpidemicUserInoutRecordEntity> addressList, List<Long> deleteIdCardArr,Map<String, EpidemicUserInfoDTO> maxDoseMap) { |
|
|
|
// 对历史数据根据身份证号进行逻辑删除// 对历史数据根据身份证号进行逻辑删除
|
|
|
|
if (!deleteIdCardArr.isEmpty()) { |
|
|
|
baseDao.deleteDistinctDose(deleteIdCardArr); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("已删除用户数量:" + deleteIdCardArr.size()); |
|
|
|
|
|
|
|
// 网格信息
|
|
|
|
List<String> idCards = new ArrayList<>(maxDoseMap.keySet()); |
|
|
|
List<EpidemicUserDeptInfoDTO> userDeptInfoList = epidemicUserInfoDao.selectDeptInfoByIdCards(idCards); |
|
|
|
Map<String, EpidemicUserDeptInfoDTO> deptMaps = userDeptInfoList.stream().collect(Collectors.toMap(EpidemicUserDeptInfoDTO::getIdCard, Function.identity())); |
|
|
|
|
|
|
|
// 插入接种数据
|
|
|
|
if (!addList.isEmpty()) { |
|
|
|
List<VaccinationInfoEntity> insertUserList = ConvertUtils.sourceToTarget(addList, VaccinationInfoEntity.class); |
|
|
@ -329,6 +404,14 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
entity.setGrid(addressOptional.get().getGridName()); |
|
|
|
entity.setVillageName(addressOptional.get().getPlot()); |
|
|
|
} |
|
|
|
EpidemicUserDeptInfoDTO dept = deptMaps.get(entity.getIdentityNo().toUpperCase()); |
|
|
|
if (dept != null) { |
|
|
|
entity.setGridId(dept.getGridId()); |
|
|
|
entity.setParentDeptIds(dept.getParentDeptIds()); |
|
|
|
entity.setParentDeptNames(dept.getParentDeptNames()); |
|
|
|
entity.setAllDeptIds(dept.getAllDeptIds()); |
|
|
|
entity.setAllDeptNames(dept.getAllDeptNames()); |
|
|
|
} |
|
|
|
}); |
|
|
|
boolean is = insertBatch(insertUserList); |
|
|
|
log.info("已插入接种记录" + insertUserList.size()); |
|
|
@ -498,12 +581,12 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
List<EpidemicUserInoutRecordEntity> addressList = Lists.newArrayList(); |
|
|
|
|
|
|
|
// 更新人员的接种信息
|
|
|
|
if (!updateEpidemicUserInfo(addressList, maxDoseMap)) { |
|
|
|
if (!updateEpidemicUserInfoV1(addressList, maxDoseMap)) { |
|
|
|
throw new RenException("更新人员的接种信息失败"); |
|
|
|
} |
|
|
|
|
|
|
|
// 插入接种数据
|
|
|
|
if (!insertBatchVaccination(addList, addressList, deleteIdCardArr)) { |
|
|
|
if (!insertBatchVaccination(addList, addressList, deleteIdCardArr,maxDoseMap)) { |
|
|
|
throw new RenException("插入接种数据失败"); |
|
|
|
} |
|
|
|
|
|
|
|