Browse Source

Merge branch 'master' of http://121.42.41.42:7070/r/epmet-cloud into dev_compare_data

 Conflicts:
	epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineDao.java
	epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml
master
yinzuomei 3 years ago
parent
commit
3fa07f5569
  1. 5
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineRelationDTO.java
  2. 7
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListResultDTO.java
  3. 7
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineController.java
  4. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineDao.java
  5. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineRelationEntity.java
  6. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineService.java
  7. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java
  8. 60
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineServiceImpl.java
  9. 5
      epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.87__alter_ic_vaccine_relation.sql
  10. 45
      epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml

5
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcVaccineRelationDTO.java

@ -50,6 +50,11 @@ public class IcVaccineRelationDTO implements Serializable {
*/
private String userType;
/**
* 是否本辖区居民10
*/
private String isLocalResiUser;
/**
* 删除标识
*/

7
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/IcVaccineListResultDTO.java

@ -85,5 +85,12 @@ public class IcVaccineListResultDTO implements Serializable {
@ExcelProperty(value = "疫苗厂家",order = 7)
private String manufacturer;
/**
* 是否本辖区居民10
*/
@ExcelIgnore
private String isLocalResiUser;
}

7
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcVaccineController.java

@ -277,5 +277,12 @@ public class IcVaccineController implements ResultDataResolver {
return new Result<>();
}
@PostMapping("initVaccineLocal")
public Result initVaccineLocal(){
icVaccineService.initVaccineLocal();
return new Result();
}
}

6
epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcVaccineDao.java

@ -8,6 +8,7 @@ import com.epmet.dto.form.MyNatListFormDTO;
import com.epmet.dto.form.VaccineListFormDTO;
import com.epmet.dto.result.IcVaccineListResultDTO;
import com.epmet.dto.result.MyNatListResultDTO;
import com.epmet.dto.result.RelationAndNatResultDTO;
import com.epmet.entity.IcVaccineEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -73,6 +74,11 @@ public interface IcVaccineDao extends BaseDao<IcVaccineEntity> {
*/
List<IcVaccineEntity> getVaccineListByIdCard(@Param("idCard") String idCard,@Param("time") String time);
List<RelationAndNatResultDTO> initVaccineLocal();
void updateRelation(List<RelationAndNatResultDTO> list);
void updateRelationOther(@Param("isLocalResiUser") String isLocalResiUser);
/**
* @Description 根据 身份证 + 疫苗接种时间 查询库里存在的
* @param list

5
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcVaccineRelationEntity.java

@ -49,4 +49,9 @@ public class IcVaccineRelationEntity extends BaseEpmetEntity {
*/
private String userType;
/**
* 是否本辖区居民10
*/
private String isLocalResiUser;
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcVaccineService.java

@ -68,4 +68,6 @@ public interface IcVaccineService extends BaseService<IcVaccineEntity> {
void edit(AddIcVaccineFormDTO formDTO);
void del(IcVaccineFormDTO formDTO);
void initVaccineLocal();
}

12
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcNatServiceImpl.java

@ -703,28 +703,28 @@ public class IcNatServiceImpl extends BaseServiceImpl<IcNatDao, IcNatEntity> imp
/**
* 创建nat关系
* @param natId
* @param currentUserAgencyId 居民所属组织
* @param currentResiAgencyId 居民所属组织
* @param staffAgencyId 工作人员所属组织
* @param agencyPids 工作人员所属组织路径
*/
private void createNatRelation(String natId, String currentUserAgencyId, String agencyPids,String staffAgencyId) {
private void createNatRelation(String natId, String currentResiAgencyId, String agencyPids,String staffAgencyId) {
// 没有关系创建关系,有关系就跳过
// 2022-10-25 修改:不管是不是本辖区居民,都创建关系,用 is_local_resi_user区分是不是本辖区居民
// 组织ID都改成工作人员所属组织ID
LambdaQueryWrapper<IcNatRelationEntity> query = new LambdaQueryWrapper<>();
query.eq(IcNatRelationEntity::getIcNatId, natId);
query.eq(IcNatRelationEntity::getAgencyId, currentUserAgencyId);
query.eq(IcNatRelationEntity::getAgencyId, currentResiAgencyId);
if (icNatRelationDao.selectCount(query) > 0) {
return;
}
IcNatRelationEntity relation = new IcNatRelationEntity();
relation.setAgencyId(currentUserAgencyId);
relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId)));
relation.setAgencyId(currentResiAgencyId);
relation.setPids(String.join(":", Arrays.asList(agencyPids, staffAgencyId)));
relation.setIcNatId(natId);
relation.setUserType("import");
relation.setIsLocalResiUser(agencyPids.contains(currentUserAgencyId) ? NumConstant.ONE_STR : NumConstant.ZERO_STR);
relation.setIsLocalResiUser(agencyPids.contains(currentResiAgencyId) ? NumConstant.ONE_STR : NumConstant.ZERO_STR);
icNatRelationDao.insert(relation);
}

60
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcVaccineServiceImpl.java

@ -18,15 +18,13 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
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.IcResiUserDao;
import com.epmet.dao.IcVaccineDao;
import com.epmet.dao.IcVaccineRelationDao;
import com.epmet.dto.IcVaccineDTO;
import com.epmet.dto.form.*;
import com.epmet.dto.result.IcVaccineListResultDTO;
import com.epmet.dto.result.LoginUserDetailsResultDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.dto.result.VaccineListDTO;
import com.epmet.dto.result.*;
import com.epmet.entity.IcResiUserEntity;
import com.epmet.entity.IcVaccineEntity;
import com.epmet.entity.IcVaccineRelationEntity;
@ -82,6 +80,8 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
private UserService userService;
@Autowired
private IcNoticeService icNoticeService;
@Autowired
private IcNatDao icNatDao;
/**
* @Author sun
@ -369,7 +369,7 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
// 建立关系
if (resi != null) {
createVaccineRelation(resiVaccine.getId(), resi.getAgencyId(), resi.getPids());
createVaccineRelation(resiVaccine.getId(), resi.getAgencyId(), resi.getPids(), agencyPids);
}
return;
@ -383,7 +383,7 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
// 只要是居民,就创建上关系
if (resi != null) {
createVaccineRelation(e.getId(), resi.getAgencyId(), resi.getPids());
createVaccineRelation(e.getId(), resi.getAgencyId(), resi.getPids(), agencyPids);
}
}
@ -425,7 +425,7 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
* @param vaccineId
* @param currentUserAgencyId
*/
private void createVaccineRelation(String vaccineId, String currentUserAgencyId, String agencyPids) {
private void createVaccineRelation(String vaccineId, String currentUserAgencyId, String agencyPids, String tokenAgencyPids) {
// 没有关系创建关系,有关系就跳过
LambdaQueryWrapper<IcVaccineRelationEntity> query = new LambdaQueryWrapper<>();
@ -440,6 +440,7 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
relation.setPids(String.join(":", Arrays.asList(agencyPids, currentUserAgencyId)));
relation.setIcVaccineId(vaccineId);
relation.setUserType("import");
relation.setIsLocalResiUser(tokenAgencyPids.contains(currentUserAgencyId) ? NumConstant.ONE_STR : NumConstant.ZERO_STR);
icVaccineRelationDao.insert(relation);
}
@ -508,6 +509,9 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
IcVaccineRelationEntity relationEntity = ConvertUtils.sourceToTarget(formDTO, IcVaccineRelationEntity.class);
relationEntity.setIcVaccineId(entity.getId());
relationEntity.setPids(StringUtils.isNotBlank(agencyInfo.getPids()) ? agencyInfo.getPids() + ":" + formDTO.getAgencyId() : formDTO.getAgencyId());
//判断当前身份证号是否本辖区下居民
ResiAndLocalResiResultDTO resiCount = icResiUserDao.getResiCount(formDTO.getAgencyId(), formDTO.getIdCard(), formDTO.getCustomerId());
relationEntity.setIsLocalResiUser(resiCount.getIsLocal() == NumConstant.ZERO ? NumConstant.ZERO_STR : NumConstant.ONE_STR);
icVaccineRelationDao.insert(relationEntity);
//3.新增通知表信息
@ -567,4 +571,46 @@ public class IcVaccineServiceImpl extends BaseServiceImpl<IcVaccineDao, IcVaccin
icVaccineRelationDao.delRelation(formDTO.getVaccineId(), null);
}
@Override
public void initVaccineLocal() {
Integer no = NumConstant.ONE;
Integer size;
// 查询关系表
do {
PageInfo<RelationAndNatResultDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_THOUSAND).doSelectPageInfo(() -> baseDao.initVaccineLocal());
List<RelationAndNatResultDTO> list = pageInfo.getList();
size = list.size();
if (CollectionUtils.isNotEmpty(list)){
List<IcResiUserEntity> users = icNatDao.getResiByIdCards(list.stream().map(m -> m.getIdCard()).distinct().collect(Collectors.toList()));
if (CollectionUtils.isNotEmpty(users)){
for (RelationAndNatResultDTO l : list) {
for (IcResiUserEntity u : users) {
if (l.getStaffAgencyIdPath().contains(u.getAgencyId())){
l.setIsLocalResiUser(NumConstant.ONE_STR);
break;
}
}
}
updateRelation(list,NumConstant.ONE_STR);
}
}
no++;
}while (size == NumConstant.ONE_THOUSAND);
// 其他类型的userType直接是居民的组织信息,所以直接赋值 is_local_resi_user = '1'
updateRelation(null,NumConstant.TWO_STR);
log.error("/epmetuser/icNat/initNatLocal更新核酸检测记录关系表,是否是本辖区居民标志 end");
}
@Transactional(rollbackFor = Exception.class)
public void updateRelation(List<RelationAndNatResultDTO> list,String type){
if (NumConstant.ONE_STR.equals(type)){
if (CollectionUtils.isNotEmpty(list)){
baseDao.updateRelation(list);
}
}else {
baseDao.updateRelationOther("1");
baseDao.updateRelationOther("0");
}
}
}

5
epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.87__alter_ic_vaccine_relation.sql

@ -0,0 +1,5 @@
ALTER TABLE `ic_vaccine_relation`
ADD COLUMN `IS_LOCAL_RESI_USER` varchar(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '是否本辖区居民,1:是;0:否' AFTER `USER_TYPE`;

45
epmet-user/epmet-user-server/src/main/resources/mapper/IcVaccineDao.xml

@ -35,6 +35,7 @@
a.IC_VACCINE_ID AS vaccineId,
a.agency_id,
a.user_type,
a.is_local_resi_user isLocalResiUser,
b.`name`,
b.mobile,
b.id_card,
@ -63,7 +64,7 @@
AND b.INOCULATE_TIME <![CDATA[ <= ]]> #{endTime}
</if>
<if test='isResiUser != null and isResiUser != ""'>
AND b.IS_RESI_USER = #{isResiUser}
AND a.is_local_resi_user = #{isResiUser}
</if>
ORDER BY b.INOCULATE_TIME DESC, b.id ASC
</select>
@ -184,6 +185,48 @@
and DATE_FORMAT( INOCULATE_TIME, '%Y-%m-%d' ) = #{time}
</select>
<select id="initVaccineLocal" resultType="com.epmet.dto.result.RelationAndNatResultDTO">
SELECT
r.id AS relationId,
i.id AS natId,
i.id_card,
r.pids AS staffAgencyIdPath
FROM ic_vaccine_relation r
INNER JOIN ic_vaccine i ON i.ID = r.ic_vaccine_id AND i.del_flag = 0
WHERE r.del_flag = 0
AND r.user_type = 'import'
</select>
<update id="updateRelation">
UPDATE ic_vaccine_relation
<trim prefix="set" suffixOverrides=",">
<trim prefix="is_local_resi_user =(case" suffix="end),">
<foreach collection="list" item="l">
when ID = #{l.relationId} then #{l.isLocalResiUser}
</foreach>
</trim>
updated_time = NOW()
</trim>
WHERE ID IN(
<foreach collection="list" item="l" separator=",">
#{l.relationId}
</foreach>)
</update>
<update id="updateRelationOther">
UPDATE ic_vaccine_relation a
INNER JOIN ic_vaccine b ON a.ic_vaccine_id = b.id
set a.is_local_resi_user = #{isLocalResiUser},
a.updated_time = NOW()
where a.user_type != 'import'
<if test="isLocalResiUser == '1'">
and b.USER_ID is not null
and b.USER_ID != ''
</if>
<if test="isLocalResiUser == '0'">
and (b.USER_ID is null or b.USER_ID ='')
</if>
</update>
<!-- 根据 身份证 + 疫苗接种时间 查询库里存在的 -->
<select id="getExistVaccine" resultType="com.epmet.dto.YTVaccineListDTO">
SELECT

Loading…
Cancel
Save