|
@ -9,6 +9,9 @@ import com.elink.esua.epdc.commons.tools.utils.FileUtils; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
import com.elink.esua.epdc.vaccine.common.base.BaseVimCurdServiceImpl; |
|
|
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.constant.StrConstant; |
|
|
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dao.EpidemicUserInfoDao; |
|
|
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.dto.EpidemicUserInfoDTO; |
|
|
|
|
|
import com.elink.esua.epdc.vaccine.epidemic.entity.EpidemicUserInfoEntity; |
|
|
import com.elink.esua.epdc.vaccine.epidemic.service.EpidemicUserInfoService; |
|
|
import com.elink.esua.epdc.vaccine.epidemic.service.EpidemicUserInfoService; |
|
|
import com.elink.esua.epdc.vaccine.epidemic.utils.StreamUtils; |
|
|
import com.elink.esua.epdc.vaccine.epidemic.utils.StreamUtils; |
|
|
import com.elink.esua.epdc.vaccine.vim.dao.VaccinationErrorDao; |
|
|
import com.elink.esua.epdc.vaccine.vim.dao.VaccinationErrorDao; |
|
@ -29,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile; |
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import java.io.File; |
|
|
import java.io.File; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
@ -55,6 +59,8 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
private VaccinationErrorService vaccinationErrorService; |
|
|
private VaccinationErrorService vaccinationErrorService; |
|
|
@Resource |
|
|
@Resource |
|
|
private VaccinationErrorDao vaccinationErrorDao; |
|
|
private VaccinationErrorDao vaccinationErrorDao; |
|
|
|
|
|
@Resource |
|
|
|
|
|
private EpidemicUserInfoDao epidemicUserInfoDao; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public QueryWrapper<VaccinationInfoEntity> getWrapper(Map<String, Object> params) { |
|
|
public QueryWrapper<VaccinationInfoEntity> getWrapper(Map<String, Object> params) { |
|
@ -85,10 +91,13 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public boolean beforeDelete(VaccinationInfoDTO dto) { |
|
|
public boolean beforeDelete(VaccinationInfoDTO dto) { |
|
|
int dose = dto.getDose(); |
|
|
VaccinationInfoDTO checkDto = new VaccinationInfoDTO(); |
|
|
|
|
|
checkDto.setIdentityNo(dto.getIdentityNo()); |
|
|
|
|
|
|
|
|
// 根据身份证查询处该人员的所有接种记录
|
|
|
// 根据身份证查询处该人员的所有接种记录
|
|
|
dto.setDose(null); |
|
|
List<VaccinationInfoEntity> checkInfoList = checkVaccination(checkDto); |
|
|
List<VaccinationInfoEntity> checkInfoList = checkVaccination(dto); |
|
|
|
|
|
|
|
|
int dose = dto.getDose(); |
|
|
int maxDose = checkInfoList.stream().collect(Collectors.summarizingInt(VaccinationInfoEntity::getDose)).getMax(); |
|
|
int maxDose = checkInfoList.stream().collect(Collectors.summarizingInt(VaccinationInfoEntity::getDose)).getMax(); |
|
|
return maxDose <= dose; |
|
|
return maxDose <= dose; |
|
|
} |
|
|
} |
|
@ -166,15 +175,20 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
List<VaccinationInfoAllExcel> addList = new ArrayList<>(); |
|
|
List<VaccinationInfoAllExcel> addList = new ArrayList<>(); |
|
|
// 存储错误数据批量插入实体
|
|
|
// 存储错误数据批量插入实体
|
|
|
List<VaccinationInfoAllExcel> addErrorList = new ArrayList<>(); |
|
|
List<VaccinationInfoAllExcel> addErrorList = new ArrayList<>(); |
|
|
|
|
|
// 记录单人最高剂次
|
|
|
|
|
|
Map<String, EpidemicUserInfoDTO> maxDoseMap = new HashMap<>(); |
|
|
log.info("准备进入Excel数据导入循环"); |
|
|
log.info("准备进入Excel数据导入循环"); |
|
|
|
|
|
|
|
|
List<VaccineDto> vaccineList = vaccineTypeService.vaccineList(); |
|
|
List<VaccineDto> vaccineList = vaccineTypeService.vaccineList(); |
|
|
List<VaccineDto> companyList = vaccineCompanyService.compantyList(); |
|
|
List<VaccineDto> companyList = vaccineCompanyService.compantyList(); |
|
|
List<VaccineDto> siteList = vaccinationSiteService.getSiteList(); |
|
|
List<VaccineDto> siteList = vaccinationSiteService.getSiteList(); |
|
|
|
|
|
List<EpidemicUserInfoEntity> allUserList = epidemicUserInfoDao.selectAllUserInfo(); |
|
|
|
|
|
List<String> allUserIdCards = allUserList.stream().map(EpidemicUserInfoEntity::getIdCard).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
VaccinationInfoAllExcel epidemicReportUserInfoAllExcel; |
|
|
VaccinationInfoAllExcel epidemicReportUserInfoAllExcel; |
|
|
VaccinationInfoDTO vaccinationInfoDTO; |
|
|
VaccinationInfoDTO vaccinationInfoDTO; |
|
|
String idCard; |
|
|
String idCard; |
|
|
|
|
|
Integer maxDose; |
|
|
for (int i = 0; i < recordList.size(); i++) { |
|
|
for (int i = 0; i < recordList.size(); i++) { |
|
|
epidemicReportUserInfoAllExcel = recordList.get(i); |
|
|
epidemicReportUserInfoAllExcel = recordList.get(i); |
|
|
vaccinationInfoDTO = ConvertUtils.sourceToTarget(epidemicReportUserInfoAllExcel, VaccinationInfoDTO.class); |
|
|
vaccinationInfoDTO = ConvertUtils.sourceToTarget(epidemicReportUserInfoAllExcel, VaccinationInfoDTO.class); |
|
@ -187,16 +201,14 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
idCard = epidemicReportUserInfoAllExcel.getIdentityNo(); |
|
|
idCard = epidemicReportUserInfoAllExcel.getIdentityNo(); |
|
|
// 校验excel中身份证号是否存在重复
|
|
|
|
|
|
if (checkIdCardList.contains(idCard)) { |
|
|
// 人员校验
|
|
|
|
|
|
if (!allUserIdCards.contains(idCard)) { |
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("身份证号存在重复"); |
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("查无此人"); |
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
if (!StringUtils.isBlank(idCard)) { |
|
|
|
|
|
checkIdCardList.add(idCard); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 校验身份证号是否合法
|
|
|
// 校验身份证号是否合法
|
|
|
if (StringUtils.isBlank(idCard) || idCard.length() != 18) { |
|
|
if (StringUtils.isBlank(idCard) || idCard.length() != 18) { |
|
@ -231,6 +243,7 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
List<VaccineDto> company = companyList.stream().filter(item -> companyName.equals(item.getLabel())).collect(Collectors.toList()); |
|
|
List<VaccineDto> company = companyList.stream().filter(item -> companyName.equals(item.getLabel())).collect(Collectors.toList()); |
|
|
if (company.size() > 0) { |
|
|
if (company.size() > 0) { |
|
|
epidemicReportUserInfoAllExcel.setVaccineId(company.get(0).getValue()); |
|
|
epidemicReportUserInfoAllExcel.setVaccineId(company.get(0).getValue()); |
|
|
|
|
|
maxDose = company.get(0).getMaxDose(); |
|
|
} else { |
|
|
} else { |
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("不存在的疫苗生产商"); |
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("不存在的疫苗生产商"); |
|
@ -263,6 +276,20 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// map用来记录身份证号的最大剂次
|
|
|
|
|
|
if (maxDoseMap.containsKey(epidemicReportUserInfoAllExcel.getIdentityNo())) { |
|
|
|
|
|
if (maxDoseMap.get(epidemicReportUserInfoAllExcel.getIdentityNo()).getVaccinationNum() < epidemicReportUserInfoAllExcel.getDose()) { |
|
|
|
|
|
EpidemicUserInfoDTO dto = new EpidemicUserInfoDTO(); |
|
|
|
|
|
dto.setVaccinationNum(epidemicReportUserInfoAllExcel.getDose()); |
|
|
|
|
|
dto.setMaxDose(maxDose); |
|
|
|
|
|
maxDoseMap.put(epidemicReportUserInfoAllExcel.getIdentityNo(), dto); |
|
|
|
|
|
} |
|
|
|
|
|
} else { |
|
|
|
|
|
EpidemicUserInfoDTO dto = new EpidemicUserInfoDTO(); |
|
|
|
|
|
dto.setVaccinationNum(epidemicReportUserInfoAllExcel.getDose()); |
|
|
|
|
|
dto.setMaxDose(maxDose); |
|
|
|
|
|
maxDoseMap.put(epidemicReportUserInfoAllExcel.getIdentityNo(), dto); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
addList.add(epidemicReportUserInfoAllExcel); |
|
|
addList.add(epidemicReportUserInfoAllExcel); |
|
|
|
|
|
|
|
@ -272,20 +299,55 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
log.info("循环结束,进入人员数据处理"); |
|
|
// 对规范数据,根据身份证号进行逻辑删除
|
|
|
// 对规范数据,根据身份证号进行逻辑删除
|
|
|
if (deleteIdCardArr.size() > 0) { |
|
|
if (deleteIdCardArr.size() > 0) { |
|
|
baseDao.deleteDistinctDose(deleteIdCardArr); |
|
|
baseDao.deleteDistinctDose(deleteIdCardArr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
List<String> idCards = new ArrayList<>(maxDoseMap.keySet()); |
|
|
|
|
|
|
|
|
|
|
|
List<EpidemicUserInfoDTO> updateList = new ArrayList<>(); |
|
|
|
|
|
if (!idCards.isEmpty()) { |
|
|
|
|
|
|
|
|
|
|
|
List<EpidemicUserInfoDTO> existUserList = epidemicUserInfoDao.selectByIdCards(idCards); |
|
|
|
|
|
existUserList.forEach(item -> { |
|
|
|
|
|
EpidemicUserInfoDTO updateDto = new EpidemicUserInfoDTO(); |
|
|
|
|
|
if (item.getVaccinationState() == 2) { |
|
|
|
|
|
// 已经接种完的不需要处理
|
|
|
|
|
|
} else { |
|
|
|
|
|
if (item.getVaccinationNum() > maxDoseMap.get(item.getIdCard()).getVaccinationNum()) { |
|
|
|
|
|
// excel的剂次数据小于数据库时不需要处理
|
|
|
|
|
|
} else { |
|
|
|
|
|
updateDto.setIdCard(item.getIdCard()); |
|
|
|
|
|
updateDto.setVaccinationNum(maxDoseMap.get(item.getIdCard()).getVaccinationNum()); |
|
|
|
|
|
if (maxDoseMap.get(item.getIdCard()).getVaccinationNum().equals(maxDoseMap.get(item.getIdCard()).getMaxDose())) { |
|
|
|
|
|
// 如果最大剂次同于excel的剂次就是接种完成,否则是接种中
|
|
|
|
|
|
updateDto.setVaccinationState(2); |
|
|
|
|
|
} else { |
|
|
|
|
|
updateDto.setVaccinationState(1); |
|
|
|
|
|
} |
|
|
|
|
|
updateList.add(updateDto); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
log.info("需要更新的人员信息数量为:" + updateList.size()); |
|
|
// 插入数据----需改为批量插入
|
|
|
// 插入数据----需改为批量插入
|
|
|
List<VaccinationInfoEntity> insertUserList = new ArrayList<>(); |
|
|
List<VaccinationInfoEntity> insertUserList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
VaccinationInfoEntity userEntity; |
|
|
VaccinationInfoEntity userEntity; |
|
|
for (int k = 0; k < addList.size(); k++) { |
|
|
for (VaccinationInfoAllExcel vaccinationInfoAllExcel : addList) { |
|
|
userEntity = ConvertUtils.sourceToTarget(addList.get(k), VaccinationInfoEntity.class); |
|
|
userEntity = ConvertUtils.sourceToTarget(vaccinationInfoAllExcel, VaccinationInfoEntity.class); |
|
|
insertUserList.add(userEntity); |
|
|
insertUserList.add(userEntity); |
|
|
} |
|
|
} |
|
|
|
|
|
// 更新人员的接种信息
|
|
|
|
|
|
for (EpidemicUserInfoDTO dto : updateList) { |
|
|
|
|
|
epidemicUserInfoDao.updateVaccinationInfo(dto); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
insertBatch(insertUserList); |
|
|
insertBatch(insertUserList); |
|
|
// 批量插入错误数据
|
|
|
// 批量插入错误数据
|
|
|
List<VaccinationErrorEntity> insertErrorList = ConvertUtils.sourceToTarget(addErrorList, VaccinationErrorEntity.class); |
|
|
List<VaccinationErrorEntity> insertErrorList = ConvertUtils.sourceToTarget(addErrorList, VaccinationErrorEntity.class); |
|
|