diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/PersonSpecialTypeBean.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/PersonSpecialTypeBean.java new file mode 100644 index 0000000000..df260b524f --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/bean/PersonSpecialTypeBean.java @@ -0,0 +1,15 @@ +package com.epmet.bean; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PersonSpecialTypeBean { + private String resiId; + private String idCard; + + private String specialType; +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java index 97eb46b233..19862d22d5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java @@ -70,7 +70,8 @@ public class LingShanSpecialCrowdController { is = this.getClass().getClassLoader().getResourceAsStream("excel/lingshan/special_crowd_" + specialType + "_import.xlsx"); response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); - response.setHeader("content-Type", "application/vnd.ms-excel"); + response.setHeader("content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + // response.setHeader("content-Type", "application/vnd.ms-excel"); response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(st.getName(), "UTF-8")); IOUtils.copy(is, os); @@ -249,7 +250,7 @@ public class LingShanSpecialCrowdController { * @author: WangXianZhang * @date: 2023/4/21 9:40 AM */ - @PostMapping("deleteByType") + @PostMapping("deleteByResi") public Result deleteByType(@RequestBody Map params) { String resiId = params.get("resiId"); @@ -257,7 +258,7 @@ public class LingShanSpecialCrowdController { throw new ValidateException("特殊人群类型或身份证不能为空"); } - lingShanSpecialCrowdService.deleteByType(resiId); + lingShanSpecialCrowdService.deleteByResi(resiId); return new Result(); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcSpecialDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcSpecialDao.java new file mode 100644 index 0000000000..c1b47971f2 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcSpecialDao.java @@ -0,0 +1,22 @@ +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.LingShanSpecialCrowdListResultDTO; +import com.epmet.entity.IcSpecialEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface IcSpecialDao extends BaseDao { + + public IcSpecialEntity selectByResiId(@Param("resiId") String resiId); + + List listSpecialCrowd(@Param("orgIdPath") String orgIdPath, + @Param("agencyId") String agencyId, + @Param("specialType") String specialType, + @Param("name") String name, + @Param("mobile") String mobile, + @Param("idCard") String idCard); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/LingshanSpecialCrowdPersonTypeDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/LingshanSpecialCrowdPersonTypeDao.java deleted file mode 100644 index 8be11fb77d..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/LingshanSpecialCrowdPersonTypeDao.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.epmet.dao; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.result.LingShanSpecialCrowdListResultDTO; -import com.epmet.entity.LingshanSpecialCrowdPersonTypeEntity; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 灵山-特殊人群-人员具有的特殊人群类型信息 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2023-04-18 - */ -@Mapper -public interface LingshanSpecialCrowdPersonTypeDao extends BaseDao { - - void saveOrUpdateManually(@Param("types") List types); - - List listSpecialCrowds(@Param("orgIdPath") String orgIdPath, - @Param("orgType") String orgType, - @Param("specialType") String specialType, - @Param("name") String name, - @Param("mobile") String mobile, - @Param("idCard") String idCard); - - void deletePhysical(@Param("resiId") String resiId); -} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcSpecialEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcSpecialEntity.java index 114ad7e2e5..693cd2499e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcSpecialEntity.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcSpecialEntity.java @@ -17,7 +17,7 @@ package com.epmet.entity; -import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.*; import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -38,6 +38,7 @@ public class IcSpecialEntity extends BaseEpmetEntity { /** * 客户Id customer.id */ + @TableField(fill = FieldFill.INSERT) private String customerId; /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/LingshanSpecialCrowdPersonTypeEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/LingshanSpecialCrowdPersonTypeEntity.java deleted file mode 100644 index 0936dfde6b..0000000000 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/LingshanSpecialCrowdPersonTypeEntity.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.epmet.entity; - -import com.baomidou.mybatisplus.annotation.TableName; - -import com.epmet.commons.mybatis.entity.BaseEpmetEntity; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.Date; - -/** - * 灵山-特殊人群-人员具有的特殊人群类型信息 - * - * @author generator generator@elink-cn.com - * @since v1.0.0 2023-04-18 - */ -@Data -@EqualsAndHashCode(callSuper=false) -@TableName("lingshan_special_crowd_person_type") -public class LingshanSpecialCrowdPersonTypeEntity extends BaseEpmetEntity { - - private static final long serialVersionUID = 1L; - - /** - * 客户Id - */ - private String customerId; - - /** - * org id路径,:分割 - */ - private String orgIdPath; - - /** - * @description: 居民ID - * @param null: - * @return - * @author: WangXianZhang - * @date: 2023/4/23 10:26 AM - */ - private String resiId; - - /** - * 证件号 - */ - private String idCard; - - /** - * 特殊人群类别 - */ - private String specialType; - - public LingshanSpecialCrowdPersonTypeEntity(String id, String customerId, String orgIdPath, String resiId, String idCard, String specialType, String delFlag, - Integer revision, Date createdTime, String createdBy, Date updatedTime, String updatedBy) { - this.resiId = resiId; - this.customerId = customerId; - this.orgIdPath = orgIdPath; - this.idCard = idCard; - this.specialType = specialType; - this.setDelFlag(delFlag); - this.setCreatedBy(createdBy); - this.setCreatedTime(createdTime); - this.setUpdatedBy(updatedBy); - this.setUpdatedTime(updatedTime); - this.setRevision(revision); - this.setId(id); - } -} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/AbstractLingShanSpecialCrowdExcelImportListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/AbstractLingShanSpecialCrowdExcelImportListener.java index 20cd011cdc..2edf65c4eb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/AbstractLingShanSpecialCrowdExcelImportListener.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/AbstractLingShanSpecialCrowdExcelImportListener.java @@ -3,6 +3,7 @@ package com.epmet.excel.handler; import com.alibaba.excel.context.AnalysisContext; import com.alibaba.excel.event.AnalysisEventListener; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.epmet.bean.PersonSpecialTypeBean; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -15,7 +16,6 @@ import com.epmet.commons.tools.utils.PidUtils; import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.entity.LingshanSpecialCrowdDetailBaseEntity; -import com.epmet.entity.LingshanSpecialCrowdPersonTypeEntity; import com.epmet.enums.LingShanSpecialCrowdTypeEnums; import com.epmet.excel.data.LingShanSpecialCrowdDetailBaseExcelData; import com.epmet.exceptions.ReadExcelHeaderOnlyException; @@ -96,7 +96,8 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener persons = new ArrayList<>(); - private List personTypes = new ArrayList<>(); + // private List personTypes = new ArrayList<>(); + private List specialTypes = new ArrayList<>(); protected LingShanSpecialCrowdService lingShanSpecialCrowdService; @@ -255,10 +256,7 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener personTypes) { + private void savePersonAndTypes(List personTypes) { lingShanSpecialCrowdService.savePersonAndTypes(personTypes); } @@ -404,4 +400,8 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener personTypes); + void savePersonAndTypes(List personTypes); /** * @description: 安置帮教-导入 @@ -82,7 +84,7 @@ public interface LingShanSpecialCrowdService { PageData listSpecialCrowds(String orgId, String orgType, String specialType, String name, String mobile, String idCard, Integer pageNo, Integer pageSize); - void deleteByType(String resiId); + void deleteByResi(String resiId); /** * @description: 保存或修改 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java index b859446a93..c907a727c3 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java @@ -5,6 +5,7 @@ import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.epmet.bean.PersonSpecialTypeBean; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionResultDTO; @@ -65,6 +66,7 @@ import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; /** * 灵山特殊人群service @@ -73,9 +75,6 @@ import java.util.concurrent.atomic.AtomicReference; @Service public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdService, ResultDataResolver { - @Autowired - private LingshanSpecialCrowdPersonTypeDao specialCrowdPersonTypeDao; - @Autowired private LingshanSpecialCrowdDetailAzbjDao specialCrowdDetailAzbjDao; @@ -94,6 +93,9 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ @Autowired private IcResiUserDao icResiUserDao; + @Autowired + private IcSpecialDao icSpecialDao; + @Autowired private ExecutorService executorService; @@ -257,17 +259,44 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ } @Override - public void savePersonAndTypes(List personTypes) { - // List> personParts = ListUtils.partition(persons, 50); - List> personTypeParts = ListUtils.partition(personTypes, 50); - - // for (List p : personParts) { - // specialCrowdPersonDao.saveOrUpdateManually(p); - // } - for (List p : personTypeParts) { - if (CollectionUtils.isNotEmpty(p)) { - specialCrowdPersonTypeDao.saveOrUpdateManually(p); + public void savePersonAndTypes(List personTypes) { + HashMap> resiIdAndTypes = new HashMap<>(); + + // 将所有的人群类别信息,按照居民id归类为map + for (PersonSpecialTypeBean type : personTypes) { + String resiId = type.getResiId(); + Set types = resiIdAndTypes.get(resiId); + if (CollectionUtils.isEmpty(types)) { + types = new HashSet<>(); + resiIdAndTypes.put(resiId, types); } + types.add(type.getSpecialType()); + } + + // 取出已有的人群类别,合并,转化为字符串,存入 + for (Map.Entry> entry : resiIdAndTypes.entrySet()) { + String resiId = entry.getKey(); + Set typeSet = entry.getValue(); + IcSpecialEntity specialTypeInDb = icSpecialDao.selectByResiId(resiId); + if (specialTypeInDb == null) { + //目前还不是特殊人群 + specialTypeInDb = new IcSpecialEntity(); + specialTypeInDb.setIcResiUser(resiId); + specialTypeInDb.setSpecialRqlb(String.join(",", typeSet)); + icSpecialDao.insert(specialTypeInDb); + } else { + // 已经是特殊人群了,那么追加新类别 + typeSet.addAll(new HashSet<>(Arrays.asList(specialTypeInDb.getSpecialRqlb().split(",")))); + IcSpecialEntity icSpecialUpdate = new IcSpecialEntity(); + icSpecialUpdate.setSpecialRqlb(String.join(",", typeSet)); + icSpecialUpdate.setId(specialTypeInDb.getId()); + icSpecialDao.updateById(icSpecialUpdate); + } + + // 设置居民的IS_SPECIAL字段为1 + HashMap updateMap = new HashMap<>(); + updateMap.put("IS_SPECIAL", "1"); + icResiUserDao.upTable("ic_resi_user", resiId, updateMap); } } @@ -396,7 +425,7 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ Date now = new Date(); - ArrayList types2Save = new ArrayList<>(); + ArrayList types2Save = new ArrayList<>(); // 保存人群详情 if (input.getSpecialCrowdDetails().getAnzhibangjiao() != null) { @@ -405,8 +434,7 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ azbj.setIdCard(input.getIdCard()); saveBatch(Arrays.asList(azbj), azbj); - LingshanSpecialCrowdPersonTypeEntity azbjE = new LingshanSpecialCrowdPersonTypeEntity(IdWorker.getIdStr(), customerId, orgIdPath, vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.AZBJ.getType(), - "0", 0, now, staffId, now, staffId); + PersonSpecialTypeBean azbjE = new PersonSpecialTypeBean(vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.AZBJ.getType()); types2Save.add(azbjE); } @@ -416,9 +444,8 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ jdry.setIdCard(input.getIdCard()); saveBatch(Arrays.asList(jdry), jdry); - LingshanSpecialCrowdPersonTypeEntity JdryE = new LingshanSpecialCrowdPersonTypeEntity(IdWorker.getIdStr(), customerId, orgIdPath, vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.JDRY.getType(), - "0", 0, now, staffId, now, staffId); - types2Save.add(JdryE); + PersonSpecialTypeBean jdryE = new PersonSpecialTypeBean(vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.JDRY.getType()); + types2Save.add(jdryE); } if (input.getSpecialCrowdDetails().getJingzhanghuanzhe() != null) { @@ -427,8 +454,7 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ jzhz.setIdCard(input.getIdCard()); saveBatch(Arrays.asList(jzhz), jzhz); - LingshanSpecialCrowdPersonTypeEntity jzhzE = new LingshanSpecialCrowdPersonTypeEntity(IdWorker.getIdStr(), customerId, orgIdPath, vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.JZHZ.getType(), - "0", 0, now, staffId, now, staffId); + PersonSpecialTypeBean jzhzE = new PersonSpecialTypeBean(vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.JZHZ.getType()); types2Save.add(jzhzE); } @@ -438,8 +464,7 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ xfry.setIdCard(input.getIdCard()); saveBatch(Arrays.asList(xfry), xfry); - LingshanSpecialCrowdPersonTypeEntity xfryE = new LingshanSpecialCrowdPersonTypeEntity(IdWorker.getIdStr(), customerId, orgIdPath, vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.XFRY.getType(), - "0", 0, now, staffId, now, staffId); + PersonSpecialTypeBean xfryE = new PersonSpecialTypeBean(vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.XFRY.getType()); types2Save.add(xfryE); } @@ -449,8 +474,7 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ sqjz.setIdCard(input.getIdCard()); saveBatch(Arrays.asList(sqjz), sqjz); - LingshanSpecialCrowdPersonTypeEntity sqjzE = new LingshanSpecialCrowdPersonTypeEntity(IdWorker.getIdStr(), customerId, orgIdPath, vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.SQJZ.getType(), - "0", 0, now, staffId, now, staffId); + PersonSpecialTypeBean sqjzE = new PersonSpecialTypeBean(vt.getResiId(), input.getIdCard(), LingShanSpecialCrowdTypeEnums.SQJZ.getType()); types2Save.add(sqjzE); } @@ -585,7 +609,8 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ orgIdPath = CustomerOrgRedis.getOrgIdPath(orgId, orgType); } PageHelper.startPage(pageNo, pageSize); - List l = specialCrowdPersonTypeDao.listSpecialCrowds(orgIdPath, orgType, specialType, name, mobile, idCard); + List l = icSpecialDao.listSpecialCrowd(orgIdPath, orgType, specialType, name, mobile, idCard); + // List l = specialCrowdPersonTypeDao.listSpecialCrowds(orgIdPath, orgType, specialType, name, mobile, idCard); l.forEach(i -> { IcResiUserDTO resi = icResiUserDao.getResiUserByIdCard(i.getIdCard(), customerId); GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(resi.getGridId()); @@ -608,13 +633,20 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ @Transactional @Override - public void deleteByType(String resiId) { - // 先删除type - specialCrowdPersonTypeDao.deletePhysical(resiId); + public void deleteByResi(String resiId) { + // 1.先删除type + LambdaQueryWrapper q = new LambdaQueryWrapper<>(); + q.eq(IcSpecialEntity::getIcResiUser, resiId); + icSpecialDao.delete(q); + // 2.更新居民信息主表中的标记 IcResiUserEntity resiInfo = icResiUserDao.selectById(resiId); - // 再删除detail + HashMap updateData = new HashMap<>(); + updateData.put("IS_SPECIAL", null); + icResiUserDao.upTable("ic_resi_user", resiId, updateData); + + // 3.再删除detail specialCrowdDetailAzbjDao.deletePhysical(resiInfo.getIdCard()); specialCrowdDetailXfryDao.deletePhysical(resiInfo.getIdCard()); specialCrowdDetailJdryDao.deletePhysical(resiInfo.getIdCard()); diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcSpecialDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcSpecialDao.xml new file mode 100644 index 0000000000..7fe616b679 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcSpecialDao.xml @@ -0,0 +1,40 @@ + + + + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdPersonTypeDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdPersonTypeDao.xml deleted file mode 100644 index 93ad9b6242..0000000000 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdPersonTypeDao.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - insert into lingshan_special_crowd_person_type ( ID, CUSTOMER_ID, ORG_ID_PATH, RESI_ID, ID_CARD, SPECIAL_TYPE, - DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME) - values - - (#{type.id}, #{type.customerId}, #{type.orgIdPath}, #{type.resiId}, #{type.idCard}, #{type.specialType}, - #{type.delFlag}, #{type.revision}, #{type.createdBy}, #{type.createdTime}, #{type.updatedBy}, #{type.updatedTime}) - - on duplicate key update - ORG_ID_PATH=values(ORG_ID_PATH) - , SPECIAL_TYPE =values(SPECIAL_TYPE) - , UPDATED_BY =values(UPDATED_BY) - , UPDATED_TIME = values(UPDATED_TIME) - - - delete from lingshan_special_crowd_person_type where RESI_ID = #{resiId} - - - - - - \ No newline at end of file