|
@ -18,10 +18,7 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
import com.epmet.commons.tools.utils.*; |
|
|
import com.epmet.commons.tools.utils.*; |
|
|
import com.epmet.constants.ImportTaskConstants; |
|
|
import com.epmet.constants.ImportTaskConstants; |
|
|
import com.epmet.dao.IcNatRelationDao; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dao.IcResiUserDao; |
|
|
|
|
|
import com.epmet.dao.IcVaccineDao; |
|
|
|
|
|
import com.epmet.dao.UserBaseInfoDao; |
|
|
|
|
|
import com.epmet.dto.IcNatDTO; |
|
|
import com.epmet.dto.IcNatDTO; |
|
|
import com.epmet.dto.IcNoticeDTO; |
|
|
import com.epmet.dto.IcNoticeDTO; |
|
|
import com.epmet.dto.form.AddIcNatFormDTO; |
|
|
import com.epmet.dto.form.AddIcNatFormDTO; |
|
@ -32,8 +29,9 @@ import com.epmet.dto.result.*; |
|
|
import com.epmet.entity.IcNatRelationEntity; |
|
|
import com.epmet.entity.IcNatRelationEntity; |
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
import com.epmet.entity.IcResiUserEntity; |
|
|
import com.epmet.entity.IcVaccineEntity; |
|
|
import com.epmet.entity.IcVaccineEntity; |
|
|
|
|
|
import com.epmet.entity.IcVaccineRelationEntity; |
|
|
import com.epmet.excel.data.IcNatImportExcelData; |
|
|
import com.epmet.excel.data.IcNatImportExcelData; |
|
|
import com.epmet.excel.handler.IcNatExcelImportListener; |
|
|
import com.epmet.excel.data.IcVaccineImportExcelData; |
|
|
import com.epmet.excel.handler.IcVaccineExcelImportListener; |
|
|
import com.epmet.excel.handler.IcVaccineExcelImportListener; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
@ -85,6 +83,10 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
@Autowired |
|
|
@Autowired |
|
|
private IcNatRelationDao icNatRelationDao; |
|
|
private IcNatRelationDao icNatRelationDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
|
|
|
private IcVaccineDao icVaccineDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private IcVaccineRelationDao icVaccineRelationDao; |
|
|
|
|
|
@Autowired |
|
|
private IcResiUserDao icResiUserDao; |
|
|
private IcResiUserDao icResiUserDao; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private UserService userService; |
|
|
private UserService userService; |
|
@ -322,7 +324,7 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
|
|
|
|
|
|
String agencyId = loginUserDetails.getAgencyId(); |
|
|
String agencyId = loginUserDetails.getAgencyId(); |
|
|
|
|
|
|
|
|
IcNatExcelImportListener listener = new IcNatExcelImportListener(userId, agencyId, loginUserDetails.getOrgIdPath().replace(":".concat(agencyId), ""), this); |
|
|
IcVaccineExcelImportListener listener = new IcVaccineExcelImportListener(userId, agencyId, loginUserDetails.getOrgIdPath().replace(":".concat(agencyId), ""), this); |
|
|
|
|
|
|
|
|
EasyExcel.read(filePath.toFile(), IcNatImportExcelData.class, listener).headRowNumber(2).sheet(0).doRead(); |
|
|
EasyExcel.read(filePath.toFile(), IcNatImportExcelData.class, listener).headRowNumber(2).sheet(0).doRead(); |
|
|
|
|
|
|
|
@ -459,7 +461,7 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(exception); |
|
|
String errorMsg = ExceptionUtils.getErrorStackTrace(exception); |
|
|
log.error(errorMsg); |
|
|
log.error(errorMsg); |
|
|
|
|
|
|
|
|
IcNatImportExcelData.RowRemarkMessage errorRow = new IcNatImportExcelData.RowRemarkMessage(); |
|
|
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|
|
errorRow.setName(e.getName()); |
|
|
errorRow.setName(e.getName()); |
|
|
errorRow.setMobile(e.getMobile()); |
|
|
errorRow.setMobile(e.getMobile()); |
|
|
errorRow.setIdCard(e.getIdCard()); |
|
|
errorRow.setIdCard(e.getIdCard()); |
|
@ -477,25 +479,25 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
* @param listener |
|
|
* @param listener |
|
|
*/ |
|
|
*/ |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void persisVaccine(IcVaccineEntity e, String customerId, String currentUserId, IcNatExcelImportListener listener) { |
|
|
public void persisVaccine(IcVaccineEntity e, String customerId, String currentUserId, IcVaccineExcelImportListener listener) { |
|
|
List<IcNatImportExcelData.RowRemarkMessage> otherRows = listener.getOtherRows(); |
|
|
List<IcVaccineImportExcelData.RowRemarkMessage> otherRows = listener.getOtherRows(); |
|
|
String agencyPids = listener.getCurrentAgencyPids(); |
|
|
String agencyPids = listener.getCurrentAgencyPids(); |
|
|
String agencyId = listener.getCurrentAgencyId(); |
|
|
String agencyId = listener.getCurrentAgencyId(); |
|
|
|
|
|
|
|
|
Date natTime = e.getNatTime(); |
|
|
|
|
|
String idCard = e.getIdCard(); |
|
|
String idCard = e.getIdCard(); |
|
|
String name = e.getName(); |
|
|
String name = e.getName(); |
|
|
String mobile = e.getMobile(); |
|
|
String mobile = e.getMobile(); |
|
|
String natResult = e.getNatResult(); |
|
|
String manufacturer = e.getManufacturer(); |
|
|
String natAddress = e.getNatAddress(); |
|
|
Date inoculateTime = e.getInoculateTime(); |
|
|
|
|
|
String inoculateAddress = e.getInoculateAddress(); |
|
|
|
|
|
|
|
|
//1.先看客户下有没有这个人
|
|
|
//1.先看客户下有没有这个人
|
|
|
IcVaccineEntity resiNat = getResiNat(customerId, idCard, natTime); |
|
|
IcVaccineEntity resiVaccine = getResiVaccine(customerId, idCard, inoculateTime); |
|
|
if (resiNat != null && !"import".equals(resiNat.getUserType())) { |
|
|
if (resiVaccine != null && !"import".equals(resiVaccine.getUserType())) { |
|
|
// 有这个人,并且不是导入的
|
|
|
// 有这个人,并且不是导入的
|
|
|
String message = "已存在该次核酸检测录入记录,请到系统中修改"; |
|
|
String message = "已存在该次疫苗接种录入记录,请到系统中修改"; |
|
|
|
|
|
|
|
|
IcNatImportExcelData.RowRemarkMessage errorRow = new IcNatImportExcelData.RowRemarkMessage(); |
|
|
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|
|
errorRow.setName(name); |
|
|
errorRow.setName(name); |
|
|
errorRow.setMobile(mobile); |
|
|
errorRow.setMobile(mobile); |
|
|
errorRow.setIdCard(idCard); |
|
|
errorRow.setIdCard(idCard); |
|
@ -504,39 +506,35 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (resiNat != null) { |
|
|
if (resiVaccine != null) { |
|
|
boolean needUpdate = false; |
|
|
boolean needUpdate = false; |
|
|
|
|
|
|
|
|
// 有这个人,也是导入的,那就要更新le
|
|
|
// 有这个人,也是导入的,那就要更新le
|
|
|
ArrayList<String> changedFieldNames = new ArrayList<>(); |
|
|
Boolean isNameChanged = false; |
|
|
if (!name.equals(resiNat.getName())) { |
|
|
if (!name.equals(resiVaccine.getName())) { |
|
|
changedFieldNames.add("姓名"); |
|
|
isNameChanged = true; |
|
|
resiNat.setName(name); |
|
|
resiVaccine.setName(name); |
|
|
needUpdate = true; |
|
|
needUpdate = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!natResult.equals(resiNat.getNatResult())) { |
|
|
if (!inoculateAddress.equals(resiVaccine.getInoculateAddress())) { |
|
|
changedFieldNames.add("检测结果"); |
|
|
resiVaccine.setInoculateAddress(inoculateAddress); |
|
|
resiNat.setNatResult(natResult); |
|
|
|
|
|
needUpdate = true; |
|
|
needUpdate = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 检测地点和手机号先不提示,说需要提示再提示。需要考虑两个都不为空&&不相等 || 两个中一个为空一个不为空
|
|
|
if (!manufacturer.equals(resiVaccine.getManufacturer())) { |
|
|
if ((com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(natAddress) && com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(resiNat.getNatAddress())) |
|
|
resiVaccine.setManufacturer(manufacturer); |
|
|
|| (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(natAddress) && com.baomidou.mybatisplus.core.toolkit.StringUtils.isBlank(resiNat.getNatAddress())) |
|
|
|
|
|
|| (com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(natAddress) && com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotBlank(resiNat.getNatAddress()) && !natAddress.equals(resiNat.getNatAddress()))) { |
|
|
|
|
|
resiNat.setNatAddress(natAddress); |
|
|
|
|
|
needUpdate = true; |
|
|
needUpdate = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!mobile.equals(resiNat.getMobile())) { |
|
|
if (!mobile.equals(resiVaccine.getMobile())) { |
|
|
resiNat.setMobile(mobile); |
|
|
resiVaccine.setMobile(mobile); |
|
|
needUpdate = true; |
|
|
needUpdate = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (changedFieldNames.size() > 0) { |
|
|
if (isNameChanged) { |
|
|
String fieldsStr = String.join(",", changedFieldNames); |
|
|
String message = "平台存在相同记录身份证号与姓名不一致,已更新最新姓名"; |
|
|
String message = "该次核酸检测记录已存在,执行更新动作," + fieldsStr + "已成功更新"; |
|
|
IcVaccineImportExcelData.RowRemarkMessage errorRow = new IcVaccineImportExcelData.RowRemarkMessage(); |
|
|
IcNatImportExcelData.RowRemarkMessage errorRow = new IcNatImportExcelData.RowRemarkMessage(); |
|
|
|
|
|
errorRow.setName(name); |
|
|
errorRow.setName(name); |
|
|
errorRow.setMobile(mobile); |
|
|
errorRow.setMobile(mobile); |
|
|
errorRow.setIdCard(idCard); |
|
|
errorRow.setIdCard(idCard); |
|
@ -545,19 +543,18 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (needUpdate) { |
|
|
if (needUpdate) { |
|
|
resiNat.setUpdatedBy(currentUserId); |
|
|
resiVaccine.setUpdatedBy(currentUserId); |
|
|
resiNat.setUpdatedTime(new Date()); |
|
|
resiVaccine.setUpdatedTime(new Date()); |
|
|
|
|
|
|
|
|
IcResiUserEntity resi = getResi(customerId, idCard, null); |
|
|
IcResiUserEntity resi = getResi(customerId, idCard, null); |
|
|
resiNat.setIsResiUser(resi != null ? "1" : "0"); |
|
|
resiVaccine.setIsResiUser(resi != null ? "1" : "0"); |
|
|
resiNat.setUserId(resi != null ? resi.getId() : ""); |
|
|
|
|
|
|
|
|
|
|
|
baseDao.updateById(resiNat); |
|
|
baseDao.updateById(resiVaccine); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|
|
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|
|
if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { |
|
|
if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { |
|
|
createNatRelation(resiNat.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); |
|
|
createVaccineRelation(resiVaccine.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return; |
|
|
return; |
|
@ -566,14 +563,13 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
// 执行新增操作
|
|
|
// 执行新增操作
|
|
|
IcResiUserEntity resi = getResi(customerId, idCard, null); |
|
|
IcResiUserEntity resi = getResi(customerId, idCard, null); |
|
|
e.setIsResiUser(resi != null ? "1" : "0"); |
|
|
e.setIsResiUser(resi != null ? "1" : "0"); |
|
|
e.setUserId(resi != null ? resi.getId() : ""); |
|
|
|
|
|
e.setUserType("import"); |
|
|
e.setUserType("import"); |
|
|
|
|
|
|
|
|
baseDao.insert(e); |
|
|
baseDao.insert(e); |
|
|
|
|
|
|
|
|
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|
|
// 还要创建关系。只有本辖区及下级居民,才建立关系
|
|
|
if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { |
|
|
if (getResi(customerId, idCard, String.join(":", Arrays.asList(agencyPids, agencyId))) != null) { |
|
|
createNatRelation(e.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); |
|
|
createVaccineRelation(e.getId(), listener.getCurrentAgencyId(), listener.getCurrentAgencyPids()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -601,35 +597,35 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin |
|
|
* @param idCard |
|
|
* @param idCard |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
|
public IcVaccineEntity getResiNat(String customerId, String idCard, Date natTime) { |
|
|
public IcVaccineEntity getResiVaccine(String customerId, String idCard, Date natTime) { |
|
|
LambdaQueryWrapper<IcVaccineEntity> query = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<IcVaccineEntity> query = new LambdaQueryWrapper<>(); |
|
|
query.eq(IcVaccineEntity::getCustomerId, customerId); |
|
|
query.eq(IcVaccineEntity::getCustomerId, customerId); |
|
|
query.eq(IcVaccineEntity::getIdCard, idCard); |
|
|
query.eq(IcVaccineEntity::getIdCard, idCard); |
|
|
query.eq(IcVaccineEntity::getNatTime, natTime); |
|
|
query.eq(IcVaccineEntity::getInoculateTime, natTime); |
|
|
return baseDao.selectOne(query); |
|
|
return baseDao.selectOne(query); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 创建nat关系 |
|
|
* 创建关系 |
|
|
* @param natId |
|
|
* @param vaccineId |
|
|
* @param currentUserAgencyId |
|
|
* @param currentUserAgencyId |
|
|
*/ |
|
|
*/ |
|
|
private void createNatRelation(String natId, String currentUserAgencyId, String agencyPids) { |
|
|
private void createVaccineRelation(String vaccineId, String currentUserAgencyId, String agencyPids) { |
|
|
|
|
|
|
|
|
// 没有关系创建关系,有关系就跳过
|
|
|
// 没有关系创建关系,有关系就跳过
|
|
|
LambdaQueryWrapper<IcNatRelationEntity> query = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<IcVaccineRelationEntity> query = new LambdaQueryWrapper<>(); |
|
|
query.eq(IcNatRelationEntity::getIcNatId, natId); |
|
|
query.eq(IcVaccineRelationEntity::getIcVaccineId, vaccineId); |
|
|
query.eq(IcNatRelationEntity::getAgencyId, currentUserAgencyId); |
|
|
query.eq(IcVaccineRelationEntity::getAgencyId, currentUserAgencyId); |
|
|
if (icNatRelationDao.selectCount(query) > 0) { |
|
|
if (icVaccineRelationDao.selectCount(query) > 0) { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
IcNatRelationEntity relation = new IcNatRelationEntity(); |
|
|
IcVaccineRelationEntity relation = new IcVaccineRelationEntity(); |
|
|
relation.setAgencyId(currentUserAgencyId); |
|
|
relation.setAgencyId(currentUserAgencyId); |
|
|
relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId))); |
|
|
relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId))); |
|
|
relation.setIcNatId(natId); |
|
|
relation.setIcVaccineId(vaccineId); |
|
|
relation.setUserType("import"); |
|
|
relation.setUserType("import"); |
|
|
icNatRelationDao.insert(relation); |
|
|
icVaccineRelationDao.insert(relation); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|