|
|
@ -22,16 +22,15 @@ import com.epmet.commons.tools.utils.ExcelPoiUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constants.ImportTaskConstants; |
|
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
import com.epmet.dao.IcVaccineDao; |
|
|
|
import com.epmet.dao.IcVaccinePrarmeterDao; |
|
|
|
import com.epmet.dao.IcVaccineRelationDao; |
|
|
|
import com.epmet.dto.IcVaccinePrarmeterDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.GridInfoByNameResultDTO; |
|
|
|
import com.epmet.dto.result.IcHouseInfoCollectResultDTO; |
|
|
|
import com.epmet.dto.result.UploadImgResultDTO; |
|
|
|
import com.epmet.entity.IcResiCollectEntity; |
|
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
|
import com.epmet.entity.IcUserChangeRecordEntity; |
|
|
|
import com.epmet.entity.IcVaccinePrarmeterEntity; |
|
|
|
import com.epmet.entity.*; |
|
|
|
import com.epmet.excel.IcVaccinePrarmeterImportExcel; |
|
|
|
import com.epmet.excel.error.IcVaccinePrarmeterImportErrorModel; |
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
@ -40,6 +39,7 @@ import com.epmet.feign.OssFeignClient; |
|
|
|
import com.epmet.redis.IcVaccinePrarmeterRedis; |
|
|
|
import com.epmet.service.IcUserChangeRecordService; |
|
|
|
import com.epmet.service.IcVaccinePrarmeterService; |
|
|
|
import lombok.SneakyThrows; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.fileupload.FileItem; |
|
|
@ -57,6 +57,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.OutputStream; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
@ -89,6 +90,12 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl<IcVaccinePrar |
|
|
|
@Autowired |
|
|
|
private IcUserChangeRecordService icUserChangeRecordService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcVaccineDao icVaccineDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcVaccineRelationDao icVaccineRelationDao; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcVaccinePrarmeterDTO> page(Map<String, Object> params) { |
|
|
|
IPage<IcVaccinePrarmeterEntity> page = baseDao.selectPage( |
|
|
@ -447,31 +454,31 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl<IcVaccinePrar |
|
|
|
// 审核状态:0待审核 1未通过 2已通过
|
|
|
|
if("2".equals(formDTO.getCheckState())){ |
|
|
|
|
|
|
|
// 同步接种记录
|
|
|
|
String icResiUserId = ""; |
|
|
|
|
|
|
|
// 根据身份证号和房屋ID获取人员信息
|
|
|
|
IcResiUserEntity userIdCardEntity = queryOriginUserByIdCard(icResiCollectEntity.getIdCard(),icResiCollectEntity.getCustomerId()); |
|
|
|
|
|
|
|
if(StringUtils.isBlank(icResiCollectEntity.getHomeId())){ |
|
|
|
// 新增房屋(新增房屋操作已在审核接口之前,前端调用新增接口实现)
|
|
|
|
// 更新登记表房屋ID
|
|
|
|
icResiCollectEntity = updateHomeId(icResiCollectEntity,formDTO); |
|
|
|
|
|
|
|
// 根据身份证号和房屋ID获取人员信息
|
|
|
|
IcResiUserEntity userIdCardEntity = queryOriginUserByIdCard(icResiCollectEntity.getIdCard(),icResiCollectEntity.getCustomerId()); |
|
|
|
if(userIdCardEntity != null){ |
|
|
|
icResiUserId = userIdCardEntity.getId(); |
|
|
|
// 已存在人员 人员房屋不一致(更新人员信息和变更记录)
|
|
|
|
updateUserInfo(icResiCollectEntity,true,formDTO,userIdCardEntity); |
|
|
|
}else{ |
|
|
|
// 不存在人员
|
|
|
|
insertUserInfo(icResiCollectEntity,formDTO); |
|
|
|
icResiUserId = insertUserInfo(icResiCollectEntity,formDTO); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
// 更新房屋
|
|
|
|
updateHouseInfo(icResiCollectEntity); |
|
|
|
|
|
|
|
// 根据身份证号和房屋ID获取人员信息
|
|
|
|
IcResiUserEntity userIdCardEntity = queryOriginUserByIdCard(icResiCollectEntity.getIdCard(),icResiCollectEntity.getCustomerId()); |
|
|
|
Map<String, IcResiUserEntity> userMap = queryOriginUserByHomeId(icResiCollectEntity.getHomeId(),icResiCollectEntity.getCustomerId()); |
|
|
|
if(userIdCardEntity != null){ |
|
|
|
icResiUserId = userIdCardEntity.getId(); |
|
|
|
// 已存在人员
|
|
|
|
if(userMap.containsKey(icResiCollectEntity.getIdCard())){ |
|
|
|
// 人员房屋一致(只更新人员信息)
|
|
|
@ -482,12 +489,135 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl<IcVaccinePrar |
|
|
|
} |
|
|
|
}else{ |
|
|
|
// 不存在人员
|
|
|
|
insertUserInfo(icResiCollectEntity,formDTO); |
|
|
|
icResiUserId = insertUserInfo(icResiCollectEntity,formDTO); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 同步接种记录 and 疫苗接种记录关系
|
|
|
|
synchronizationVaccineInfo(icResiCollectEntity,icResiUserId); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 同步接种记录 and 疫苗接种记录关系 |
|
|
|
* @param icResiCollectEntity |
|
|
|
* @param icResiUserId |
|
|
|
*/ |
|
|
|
@SneakyThrows |
|
|
|
private void synchronizationVaccineInfo(IcVaccinePrarmeterEntity icResiCollectEntity,String icResiUserId){ |
|
|
|
// 同步接种记录
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
// 处理第一次接种时间格式
|
|
|
|
String firstTime = icResiCollectEntity.getFirstVacTime(); |
|
|
|
Date firstDate = sdf.parse(firstTime); |
|
|
|
icResiCollectEntity.setFirstVacTime(sdf.format(firstDate)); |
|
|
|
// 处理第二次接种时间格式
|
|
|
|
String secondTime = icResiCollectEntity.getSecondVacTime(); |
|
|
|
Date secondDate = sdf.parse(secondTime); |
|
|
|
icResiCollectEntity.setSecondVacTime(sdf.format(secondDate)); |
|
|
|
// 处理第三次接种时间格式
|
|
|
|
String thirdTime = icResiCollectEntity.getThirdVacTime(); |
|
|
|
Date thirdDate = sdf.parse(thirdTime); |
|
|
|
icResiCollectEntity.setThirdVacTime(sdf.format(thirdDate)); |
|
|
|
|
|
|
|
// 查询第一次接种信息
|
|
|
|
List<IcVaccineEntity> icVaccineEntityFirstList = icVaccineDao.getVaccineListByIdCard(icResiCollectEntity.getIdCard(),sdf.format(firstDate)); |
|
|
|
if(icVaccineEntityFirstList.size() > 0){ |
|
|
|
// 更新疫苗接种记录 and 疫苗接种记录关系
|
|
|
|
for(IcVaccineEntity entity : icVaccineEntityFirstList){ |
|
|
|
updateVaccineInfo(entity,icResiCollectEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
// 新增疫苗接种记录 and 疫苗接种记录关系
|
|
|
|
insertVaccineInfo(icResiCollectEntity,icResiUserId,firstDate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询第二次接种信息
|
|
|
|
List<IcVaccineEntity> icVaccineEntitySecondList = icVaccineDao.getVaccineListByIdCard(icResiCollectEntity.getIdCard(),sdf.format(secondDate)); |
|
|
|
if(icVaccineEntitySecondList.size() > 0){ |
|
|
|
// 更新疫苗接种记录 and 疫苗接种记录关系
|
|
|
|
for(IcVaccineEntity entity : icVaccineEntitySecondList){ |
|
|
|
updateVaccineInfo(entity,icResiCollectEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
// 新增疫苗接种记录 and 疫苗接种记录关系
|
|
|
|
insertVaccineInfo(icResiCollectEntity,icResiUserId,firstDate); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 查询第三次接种信息
|
|
|
|
List<IcVaccineEntity> icVaccineEntityThirdList = icVaccineDao.getVaccineListByIdCard(icResiCollectEntity.getIdCard(),sdf.format(thirdDate)); |
|
|
|
if(icVaccineEntityThirdList.size() > 0){ |
|
|
|
// 更新疫苗接种记录 and 疫苗接种记录关系
|
|
|
|
for(IcVaccineEntity entity : icVaccineEntityThirdList){ |
|
|
|
updateVaccineInfo(entity,icResiCollectEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
// 新增疫苗接种记录 and 疫苗接种记录关系
|
|
|
|
insertVaccineInfo(icResiCollectEntity,icResiUserId,firstDate); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新疫苗接种记录 and 疫苗接种记录关系 |
|
|
|
* @param entity |
|
|
|
* @param icResiCollectEntity |
|
|
|
*/ |
|
|
|
private void updateVaccineInfo(IcVaccineEntity entity,IcVaccinePrarmeterEntity icResiCollectEntity){ |
|
|
|
// 更新疫苗接种记录
|
|
|
|
entity.setInoculateAddress(icResiCollectEntity.getFirstVacSite()); |
|
|
|
entity.setUserType("prarmeter"); |
|
|
|
entity.setCustomerId(icResiCollectEntity.getCustomerId()); |
|
|
|
icVaccineDao.updateById(entity); |
|
|
|
|
|
|
|
// 更新疫苗接种记录关系
|
|
|
|
IcVaccineRelationEntity icVaccineRelationEntity = new IcVaccineRelationEntity(); |
|
|
|
icVaccineRelationEntity.setIcVaccineId(entity.getId()); |
|
|
|
icVaccineRelationEntity.setUserType("prarmeter"); |
|
|
|
icVaccineRelationEntity.setCustomerId(icResiCollectEntity.getCustomerId()); |
|
|
|
icVaccineRelationDao.updateRelationInfoByVaccineId(icVaccineRelationEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增疫苗接种记录 and 疫苗接种记录关系 |
|
|
|
* @param icResiCollectEntity |
|
|
|
* @param icResiUserId |
|
|
|
* @param time |
|
|
|
*/ |
|
|
|
private void insertVaccineInfo(IcVaccinePrarmeterEntity icResiCollectEntity,String icResiUserId,Date time){ |
|
|
|
IcVaccineEntity icVaccineEntity = new IcVaccineEntity(); |
|
|
|
icVaccineEntity.setCustomerId(icResiCollectEntity.getCustomerId()); |
|
|
|
icVaccineEntity.setName(icResiCollectEntity.getName()); |
|
|
|
icVaccineEntity.setMobile(icResiCollectEntity.getMobile()); |
|
|
|
icVaccineEntity.setIdCard(icResiCollectEntity.getIdCard()); |
|
|
|
icVaccineEntity.setIsResiUser("1"); |
|
|
|
icVaccineEntity.setUserType("prarmeter"); |
|
|
|
icVaccineEntity.setUserId(icResiUserId); |
|
|
|
icVaccineEntity.setInoculateTime(time); |
|
|
|
icVaccineEntity.setInoculateAddress(icResiCollectEntity.getFirstVacSite()); |
|
|
|
icVaccineDao.insert(icVaccineEntity); |
|
|
|
|
|
|
|
// 新增关系
|
|
|
|
IcVaccineRelationEntity icVaccineRelationEntity = new IcVaccineRelationEntity(); |
|
|
|
icVaccineRelationEntity.setCustomerId(icResiCollectEntity.getCustomerId()); |
|
|
|
icVaccineRelationEntity.setAgencyId(icResiCollectEntity.getAgencyId()); |
|
|
|
icVaccineRelationEntity.setPids(icResiCollectEntity.getPids()); |
|
|
|
icVaccineRelationEntity.setIcVaccineId(icVaccineEntity.getId()); |
|
|
|
icVaccineRelationEntity.setUserType("prarmeter"); |
|
|
|
icVaccineRelationDao.insert(icVaccineRelationEntity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新新冠病毒疫苗接种人员信息台账表房屋ID |
|
|
|
* @param icResiCollectEntity |
|
|
@ -601,7 +731,7 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl<IcVaccinePrar |
|
|
|
* @param icResiCollectEntity |
|
|
|
* @param formDTO |
|
|
|
*/ |
|
|
|
private void insertUserInfo(IcVaccinePrarmeterEntity icResiCollectEntity,IcVaccineCheckFormDTO formDTO){ |
|
|
|
private String insertUserInfo(IcVaccinePrarmeterEntity icResiCollectEntity,IcVaccineCheckFormDTO formDTO){ |
|
|
|
|
|
|
|
// 新增人员
|
|
|
|
IcResiUserEntity userEntity = new IcResiUserEntity(); |
|
|
@ -632,6 +762,8 @@ public class IcVaccinePrarmeterServiceImpl extends BaseServiceImpl<IcVaccinePrar |
|
|
|
changeRecordEntity.setChangeTime(new java.util.Date()); |
|
|
|
icUserChangeRecordService.insert(changeRecordEntity); |
|
|
|
|
|
|
|
return userEntity.getId(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|