|
|
|
@ -3,6 +3,7 @@ package com.epmet.service.impl; |
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
@ -20,12 +21,14 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.constants.ImportTaskConstants; |
|
|
|
import com.epmet.dao.IcNatDao; |
|
|
|
import com.epmet.dao.IcNatRelationDao; |
|
|
|
import com.epmet.dao.UserBaseInfoDao; |
|
|
|
import com.epmet.dto.IcNatDTO; |
|
|
|
import com.epmet.dto.IcNoticeDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.*; |
|
|
|
import com.epmet.entity.IcNatEntity; |
|
|
|
import com.epmet.entity.IcNatRelationEntity; |
|
|
|
import com.epmet.excel.data.IcNatImportExcelData; |
|
|
|
import com.epmet.excel.handler.IcNatExcelImportListener; |
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
|
@ -69,18 +72,16 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IcNoticeService icNoticeService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OssFeignClient ossFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserBaseInfoDao userBaseInfoDao; |
|
|
|
@Autowired |
|
|
|
private IcNatRelationDao icNatRelationDao; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
@ -89,8 +90,8 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void add(AddIcNatFormDTO formDTO) { |
|
|
|
//0.先根据身份证号和检查时间校验数据是否存在
|
|
|
|
IcNatDTO icNatDTO = baseDao.getNatDTO(formDTO.getCustomerId(), null, formDTO.getIdCard(), DateUtils.format(formDTO.getNatTime(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); |
|
|
|
//0.先根据身份证号和检查时间以及检测结果校验数据是否存在
|
|
|
|
IcNatDTO icNatDTO = baseDao.getNatDTO(formDTO.getCustomerId(), null, formDTO.getIdCard(), DateUtils.format(formDTO.getNatTime(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE), formDTO.getNatResult()); |
|
|
|
if (null != icNatDTO) { |
|
|
|
throw new RenException(EpmetErrorCode.IC_NAT_IDCARD_NATTIME.getCode(), EpmetErrorCode.IC_NAT_IDCARD_NATTIME.getMsg()); |
|
|
|
} |
|
|
|
@ -99,10 +100,17 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
if (null == agencyInfo) { |
|
|
|
throw new RenException(String.format("获取组织缓存信息失败%s", formDTO.getAgencyId())); |
|
|
|
} |
|
|
|
//2.新增核酸记录表数据
|
|
|
|
//2.新增核酸基础信息数据
|
|
|
|
IcNatEntity entity = ConvertUtils.sourceToTarget(formDTO, IcNatEntity.class); |
|
|
|
entity.setPids(agencyInfo.getPids()); |
|
|
|
if (StringUtils.isNotBlank(formDTO.getUserId())) { |
|
|
|
entity.setIsResiUser("1"); |
|
|
|
} |
|
|
|
insert(entity); |
|
|
|
//3.核酸记录关系表新增与组织的关系数据
|
|
|
|
IcNatRelationEntity relationEntity = ConvertUtils.sourceToTarget(formDTO, IcNatRelationEntity.class); |
|
|
|
relationEntity.setIcNatId(entity.getId()); |
|
|
|
relationEntity.setPids(StringUtils.isNotBlank(agencyInfo.getPids()) ? agencyInfo.getPids() + ":" + formDTO.getAgencyId() : formDTO.getAgencyId()); |
|
|
|
icNatRelationDao.insert(relationEntity); |
|
|
|
|
|
|
|
//3.新增通知表信息
|
|
|
|
if (formDTO.getChannel().size() > NumConstant.ZERO) { |
|
|
|
@ -129,32 +137,39 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
//1.根据token信息查询居民身份证号
|
|
|
|
UserBaseInfoResultDTO dto = userBaseInfoDao.selectListByUserIdList(formDTO.getUserId()); |
|
|
|
formDTO.setIdCard(dto.getIdNum()); |
|
|
|
//2.查询当前人员创建的或该身份证号录入的核算检测数据(居民端录入、数字平台录入、数字平台导入)
|
|
|
|
//2.查询当前人员创建的或该身份证号录入的核算检测数据(居民端录入、数字平台录入、数字平台导入、数字平台同步的)
|
|
|
|
List<MyNatListResultDTO> resultList = baseDao.getMyNatList(formDTO); |
|
|
|
return resultList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 【核酸】核酸检测信息列表 |
|
|
|
* @Description 【核酸】本组织及下级核酸检测信息列表 |
|
|
|
* |
|
|
|
* @return*/ |
|
|
|
@Override |
|
|
|
public PageData<NatListResultDTO> natList(MyNatListFormDTO formDTO) { |
|
|
|
//1.根据orgType值判断是查询当前组织下还是整个客户下数据
|
|
|
|
//1.根据是查询客户数据还是本辖区数据走不同逻辑
|
|
|
|
if ("current".equals(formDTO.getOrgType())) { |
|
|
|
//获取工作人员缓存信息
|
|
|
|
//本辖区数据
|
|
|
|
//2.获取工作人员缓存信息
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|
|
|
if (null == staffInfo) { |
|
|
|
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |
|
|
|
} |
|
|
|
formDTO.setAgencyId(staffInfo.getAgencyId()); |
|
|
|
//3.按条件查询业务数据
|
|
|
|
PageInfo<NatListResultDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.isPage()) |
|
|
|
.doSelectPageInfo(() -> baseDao.getNatList(formDTO)); |
|
|
|
return new PageData(data.getList(), data.getTotal()); |
|
|
|
} else if ("current".equals(formDTO.getOrgType())) { |
|
|
|
//客户下数据
|
|
|
|
PageInfo<NatListResultDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.isPage()) |
|
|
|
.doSelectPageInfo(() -> baseDao.getCustomerNatList(formDTO)); |
|
|
|
return new PageData(data.getList(), data.getTotal()); |
|
|
|
} |
|
|
|
|
|
|
|
//2.按条件查询业务数据
|
|
|
|
PageInfo<NatListResultDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.isPage()) |
|
|
|
.doSelectPageInfo(() -> baseDao.getNatList(formDTO)); |
|
|
|
return new PageData(data.getList(),data.getTotal()); |
|
|
|
return new PageData(new ArrayList(), 0); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -188,18 +203,19 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void edit(AddIcNatFormDTO formDTO) { |
|
|
|
//0.先根据身份证号和检测时间校验除当前数据是否还存在相同数据
|
|
|
|
IcNatDTO icNatDTO = baseDao.getNatDTO(formDTO.getCustomerId(), formDTO.getIcNatId(), formDTO.getIdCard(), DateUtils.format(formDTO.getNatTime(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE)); |
|
|
|
//0.先根据身份证号和检测时间以及检测结果校验除当前数据是否还存在相同数据
|
|
|
|
IcNatDTO icNatDTO = baseDao.getNatDTO(formDTO.getCustomerId(), formDTO.getIcNatId(), formDTO.getIdCard(), DateUtils.format(formDTO.getNatTime(), DateUtils.DATE_TIME_PATTERN_END_WITH_MINUTE), formDTO.getNatResult()); |
|
|
|
if (null != icNatDTO) { |
|
|
|
throw new RenException(EpmetErrorCode.IC_NAT_IDCARD_NATTIME.getCode(), EpmetErrorCode.IC_NAT_IDCARD_NATTIME.getMsg()); |
|
|
|
} |
|
|
|
//1.更新核酸记录表数据
|
|
|
|
//1.更新核酸记录基础信息表数据
|
|
|
|
IcNatEntity entity = ConvertUtils.sourceToTarget(formDTO, IcNatEntity.class); |
|
|
|
entity.setId(formDTO.getIcNatId()); |
|
|
|
if (!updateById(entity)) { |
|
|
|
log.error(String.format("数据修改失败,核酸记录Id->%s", formDTO.getIcNatId())); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "核酸记录修改失败"); |
|
|
|
} |
|
|
|
//修改只涉及到基础信息的修改 不会修改关系数据 关系表不涉及更新
|
|
|
|
|
|
|
|
//3.新增通知表信息
|
|
|
|
if (CollectionUtils.isNotEmpty(formDTO.getChannel())) { |
|
|
|
@ -223,11 +239,13 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void del(MyNatListFormDTO formDTO) { |
|
|
|
//1.物理删除业务数据
|
|
|
|
//1.确定删除则需要删除基础数据以及所有可能存在的关系数据,物理删除业务数据
|
|
|
|
if (baseDao.delById(formDTO.getIcNatId()) < NumConstant.ONE) { |
|
|
|
log.error(String.format("数据删除/取消同步失败,核酸记录Id->%s", formDTO.getIcNatId())); |
|
|
|
log.error(String.format("数据删除失败,核酸记录Id->%s", formDTO.getIcNatId())); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据操作失败"); |
|
|
|
} |
|
|
|
//关系数据删除
|
|
|
|
icNatRelationDao.delRelation(formDTO.getIcNatId(), null); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -237,25 +255,46 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void synchro(MyNatListFormDTO formDTO) { |
|
|
|
//1.检验核酸基础信息是否存在
|
|
|
|
IcNatEntity entity = baseDao.selectById(formDTO.getIcNatId()); |
|
|
|
if (null == entity) { |
|
|
|
log.error(String.format("核酸记录数据不存在同步失败,核酸记录Id->%s", formDTO.getIcNatId())); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据同步失败,核酸记录数据不存在"); |
|
|
|
} |
|
|
|
//获取工作人员缓存数据
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|
|
|
if (null == staffInfo) { |
|
|
|
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |
|
|
|
} |
|
|
|
//2.不管是否已存在关系数据都是先删后增
|
|
|
|
icNatRelationDao.delRelation(formDTO.getIcNatId(), null); |
|
|
|
//3.新增关系数据
|
|
|
|
IcNatRelationEntity relationEntity = new IcNatRelationEntity(); |
|
|
|
relationEntity.setCustomerId(formDTO.getCustomerId()); |
|
|
|
relationEntity.setIcNatId(formDTO.getIcNatId()); |
|
|
|
relationEntity.setAgencyId(staffInfo.getAgencyId()); |
|
|
|
relationEntity.setPids(StringUtils.isNotBlank(staffInfo.getAgencyPIds())?staffInfo.getAgencyPIds()+":"+formDTO.getAgencyId():staffInfo.getAgencyId()); |
|
|
|
relationEntity.setUserType("synchro"); |
|
|
|
icNatRelationDao.insert(relationEntity); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author sun |
|
|
|
* @Description 【核酸】核酸检测信息取消同步 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void cancelSynchro(MyNatListFormDTO formDTO) { |
|
|
|
//1.获取工作人员缓存数据
|
|
|
|
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); |
|
|
|
if (null == staffInfo) { |
|
|
|
throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); |
|
|
|
} |
|
|
|
//1.根据核酸记录Id查询业务数据并进行必要校验
|
|
|
|
IcNatEntity entity = baseDao.selectById(formDTO.getIcNatId()); |
|
|
|
if (null == entity || staffInfo.getAgencyId().equals(entity.getAgencyId()) |
|
|
|
|| (!"import".equals(entity.getUserType()) && !"synchro".equals(entity.getUserType()))) { |
|
|
|
log.error(String.format("数据同步失败,核酸记录Id->%s", formDTO.getIcNatId())); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "数据同步失败,不是导入数据或非本组织数据"); |
|
|
|
//1.物理删除关系数据
|
|
|
|
if (icNatRelationDao.delRelation(formDTO.getIcNatId(), staffInfo.getAgencyId()) < NumConstant.ONE) { |
|
|
|
log.error(String.format("数据取消同步失败,核酸记录Id->%s", formDTO.getIcNatId())); |
|
|
|
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "取消同步操作失败"); |
|
|
|
} |
|
|
|
|
|
|
|
//3.待同步组织新增业务数据
|
|
|
|
entity.setId(""); |
|
|
|
entity.setAgencyId(staffInfo.getAgencyId()); |
|
|
|
entity.setPids(staffInfo.getAgencyPIds()); |
|
|
|
entity.setUserType("synchro"); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Async |
|
|
|
|