|
|
@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil; |
|
|
|
import cn.afterturn.easypoi.excel.entity.ImportParams; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.FileUtils; |
|
|
|
import com.elink.esua.epdc.commons.tools.utils.Result; |
|
|
@ -159,11 +160,11 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
public Result importManualScoreExcel(MultipartFile file) { |
|
|
|
log.info("进入Excel数据导入"); |
|
|
|
File f = StreamUtils.conversionFile(file); |
|
|
|
String checkInfo = ""; |
|
|
|
StringBuilder checkInfo = new StringBuilder(); |
|
|
|
try { |
|
|
|
//判断上传文件类型
|
|
|
|
String originalFilename = file.getOriginalFilename(); |
|
|
|
if (!originalFilename.endsWith(StrConstant.EXCEL_SUFFIX_2003) && !originalFilename.endsWith(StrConstant.EXCEL_SUFFIX_2007)) { |
|
|
|
if (originalFilename != null && !originalFilename.endsWith(StrConstant.EXCEL_SUFFIX_2003) && !originalFilename.endsWith(StrConstant.EXCEL_SUFFIX_2007)) { |
|
|
|
return new Result().error("请选择.xls或者.xlsx格式文件"); |
|
|
|
} |
|
|
|
// 判断导入文件是否为空
|
|
|
@ -182,7 +183,6 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
Map<String, EpidemicUserInfoDTO> maxDoseMap = new HashMap<>(); |
|
|
|
log.info("准备进入Excel数据导入循环"); |
|
|
|
|
|
|
|
// List<VaccineDto> vaccineList = vaccineTypeService.vaccineList();
|
|
|
|
List<VaccineDto> companyList = vaccineCompanyService.compantyList(); |
|
|
|
List<VaccineDto> siteList = vaccinationSiteService.getSiteList(); |
|
|
|
List<EpidemicUserInfoEntity> allUserList = epidemicUserInfoDao.selectAllUserInfo(); |
|
|
@ -197,7 +197,7 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
vaccinationInfoDTO = ConvertUtils.sourceToTarget(epidemicReportUserInfoAllExcel, VaccinationInfoDTO.class); |
|
|
|
// 校验是否存在空单元格(校验必填)
|
|
|
|
if (checkNullCell(epidemicReportUserInfoAllExcel)) { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("存在空单元格"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
@ -207,7 +207,7 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
|
|
|
|
// 人员校验
|
|
|
|
if (!allUserIdCards.contains(idCard)) { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("查无此人"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
@ -215,31 +215,12 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
|
|
|
|
// 校验身份证号是否合法
|
|
|
|
if (StringUtils.isBlank(idCard) || idCard.length() != 18) { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("身份证号不合法"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// // 校验疫苗类型
|
|
|
|
// String vaccineName = epidemicReportUserInfoAllExcel.getVaccineName();
|
|
|
|
// if (StringUtils.isNotBlank(vaccineName)) {
|
|
|
|
// List<VaccineDto> vaccine = vaccineList.stream().filter(item -> vaccineName.equals(item.getLabel())).collect(Collectors.toList());
|
|
|
|
// if (!vaccine.isEmpty()) {
|
|
|
|
// epidemicReportUserInfoAllExcel.setVaccineId(vaccine.get(0).getValue());
|
|
|
|
// } else {
|
|
|
|
// checkInfo += "第" + (i + 1) + "条、";
|
|
|
|
// epidemicReportUserInfoAllExcel.setErrorInfo("不存在的疫苗类型");
|
|
|
|
// addErrorList.add(epidemicReportUserInfoAllExcel);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
// checkInfo += "第" + (i + 1) + "条、";
|
|
|
|
// epidemicReportUserInfoAllExcel.setErrorInfo("未填写疫苗类型");
|
|
|
|
// addErrorList.add(epidemicReportUserInfoAllExcel);
|
|
|
|
// continue;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// 校验疫苗生产商
|
|
|
|
String companyName = epidemicReportUserInfoAllExcel.getCompanyName(); |
|
|
|
if (StringUtils.isNotBlank(companyName)) { |
|
|
@ -248,13 +229,13 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
epidemicReportUserInfoAllExcel.setCompanyId(company.get(0).getValue()); |
|
|
|
maxDose = company.get(0).getMaxDose(); |
|
|
|
} else { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("不存在的疫苗生产商"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("未填写疫苗生产商"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
@ -267,13 +248,13 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
if (!site.isEmpty()) { |
|
|
|
epidemicReportUserInfoAllExcel.setSiteId(site.get(0).getValue()); |
|
|
|
} else { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("不存在的疫苗接种点"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else { |
|
|
|
checkInfo += "第" + (i + 1) + "条、"; |
|
|
|
checkInfo.append("第").append(i + 1).append("条、"); |
|
|
|
epidemicReportUserInfoAllExcel.setErrorInfo("未填写疫苗接种点"); |
|
|
|
addErrorList.add(epidemicReportUserInfoAllExcel); |
|
|
|
continue; |
|
|
@ -314,12 +295,9 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
|
|
|
|
existUserList.forEach(item -> { |
|
|
|
EpidemicUserInfoDTO updateDto = new EpidemicUserInfoDTO(); |
|
|
|
if (item.getVaccinationState() == 2) { |
|
|
|
// 已经接种完的不需要处理
|
|
|
|
} else { |
|
|
|
if (item.getVaccinationNum() > maxDoseMap.get(item.getIdCard()).getVaccinationNum()) { |
|
|
|
// excel的剂次数据小于数据库时不需要处理
|
|
|
|
} else { |
|
|
|
|
|
|
|
// 已经接种完的不需要处理,excel的剂次数据小于数据库时不需要处理,已经接种完的不需要处理
|
|
|
|
if (item.getVaccinationState() != NumConstant.TWO && item.getVaccinationNum() <= maxDoseMap.get(item.getIdCard()).getVaccinationNum()) { |
|
|
|
updateDto.setIdCard(item.getIdCard()); |
|
|
|
updateDto.setVaccinationNum(maxDoseMap.get(item.getIdCard()).getVaccinationNum()); |
|
|
|
if (maxDoseMap.get(item.getIdCard()).getVaccinationNum().equals(maxDoseMap.get(item.getIdCard()).getMaxDose())) { |
|
|
@ -330,25 +308,18 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
} |
|
|
|
updateList.add(updateDto); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
log.info("需要更新的人员信息数量为:" + updateList.size()); |
|
|
|
|
|
|
|
// 对规范数据,根据身份证号进行逻辑删除
|
|
|
|
// 对历史数据根据身份证号进行逻辑删除
|
|
|
|
if (!deleteIdCardArr.isEmpty()) { |
|
|
|
baseDao.deleteDistinctDose(deleteIdCardArr); |
|
|
|
} |
|
|
|
|
|
|
|
// 插入数据----需改为批量插入
|
|
|
|
List<VaccinationInfoEntity> insertUserList = new ArrayList<>(); |
|
|
|
|
|
|
|
VaccinationInfoEntity userEntity; |
|
|
|
for (VaccinationInfoAllExcel vaccinationInfoAllExcel : addList) { |
|
|
|
userEntity = ConvertUtils.sourceToTarget(vaccinationInfoAllExcel, VaccinationInfoEntity.class); |
|
|
|
insertUserList.add(userEntity); |
|
|
|
} |
|
|
|
// 插入接种数据
|
|
|
|
List<VaccinationInfoEntity> insertUserList = ConvertUtils.sourceToTarget(addList, VaccinationInfoEntity.class); |
|
|
|
insertBatch(insertUserList); |
|
|
|
|
|
|
|
// 更新人员的接种信息
|
|
|
@ -380,12 +351,14 @@ public class VaccinationInfoServiceImpl extends BaseVimCurdServiceImpl<Vaccinati |
|
|
|
|
|
|
|
/** |
|
|
|
* 校验是否存在空单元格 |
|
|
|
* 校验必填项 (用户名、身份证号、接种剂次) |
|
|
|
* |
|
|
|
* @param infoAllExcel |
|
|
|
* @return |
|
|
|
* @return boolean |
|
|
|
* @author zhy |
|
|
|
* @date 2021/5/10 11:18 |
|
|
|
*/ |
|
|
|
private boolean checkNullCell(VaccinationInfoAllExcel infoAllExcel) { |
|
|
|
// 校验必填项 (用户名、身份证号)
|
|
|
|
return StringUtils.isBlank(infoAllExcel.getRealName()) || StringUtils.isBlank(infoAllExcel.getIdentityNo()) || infoAllExcel.getDose() == null; |
|
|
|
} |
|
|
|
|
|
|
|