diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtSfhyxxcxdsjjResDTO.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtSfhyxxcxdsjjResDTO.java new file mode 100644 index 0000000000..8863619d26 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/dto/result/YtSfhyxxcxdsjjResDTO.java @@ -0,0 +1,39 @@ +package com.epmet.commons.tools.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +/** + * @Description 根据身份证号和姓名查询公安部备案信息 + */ +@NoArgsConstructor +@Data +public class YtSfhyxxcxdsjjResDTO { + private int code = 200; + private String msg = "请求成功"; + /** + * 响应数据 + */ + private YtSfhyxxcxdsjjDetail data; + private int total; + + @Data + public static class YtSfhyxxcxdsjjDetail { + private String status = "000"; + private String statusMsg = "正常返回"; + private String count = "1"; + //结果数量 + private String total; + private List result; + } + @Data + public static class Result { + //身份证号 + private String GMSFHM; + //姓名 + private String XM; + } +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java index 9010c9b84a..371aa8b95b 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/YtHsResUtils.java @@ -6,6 +6,7 @@ import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.YtDataSyncResDTO; import com.epmet.commons.tools.dto.result.YtHscyResDTO; import com.epmet.commons.tools.dto.result.YtHsjcResDTO; +import com.epmet.commons.tools.dto.result.YtSfhyxxcxdsjjResDTO; import com.google.common.util.concurrent.RateLimiter; import lombok.extern.slf4j.Slf4j; @@ -226,6 +227,40 @@ public class YtHsResUtils { return failResult; } + /** + * desc:根据身份证号和姓名查询公安部备案信息 + * + * @return + */ + public static YtSfhyxxcxdsjjResDTO sfhyxxcxdsjj(String gmsfhm, String xm) { + try { + tryAcquire("sfhyxxcxdsjj"); + + Map param = new HashMap<>(); + param.put(APP_KEY, "RhOHlu7Bmkrj8Vk7uGTNNxHqI"); + param.put("gmsfhm", gmsfhm); + param.put("xm", xm); + log.info("sfhyxxcxdsjj api param:{}", param); + + Result result = HttpClientManager.getInstance().sendGet(SERVER_URL + "sfhyxxcxdsjj", param); + log.info("sfhyxxcxdsjj api result:{}", JSON.toJSONString(result)); + if (result.success()) { + String data = result.getData(); + JSONObject jsonObject = JSON.parseObject(data); + if (jsonObject != null && StrConstant.HTTP_STATUS_OK.equals(jsonObject.getString(StrConstant.HTTP_RESP_CODE))) { + return JSON.parseObject(result.getData(), YtSfhyxxcxdsjjResDTO.class); + } else { + log.warn("sfhyxxcxdsjj 烟台公安部居民基础信息调用失败"); + } + } + } catch (Exception e) { + log.error(String.format("烟台公民基本信息查询异常gmsfhm:%s", gmsfhm), e); + } + YtSfhyxxcxdsjjResDTO resultResult = new YtSfhyxxcxdsjjResDTO(); + resultResult.setData(new YtSfhyxxcxdsjjResDTO.YtSfhyxxcxdsjjDetail()); + return resultResult; + } + public static void main(String[] args) { //YtDataSyncResDTO canji = canji("123", "123"); diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiComparisonRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiComparisonRecordDTO.java new file mode 100644 index 0000000000..b8f092cc4c --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcResiComparisonRecordDTO.java @@ -0,0 +1,105 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 居民信息与公安部信息比对记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-11-14 + */ +@Data +public class IcResiComparisonRecordDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * ic_resi_user.id【比对时的数据值】 + */ + private String resiId; + + /** + * 数字社区人员姓名【比对时的数据值】 + */ + private String resiName; + + /** + * 数据社区身份证号【比对时的数据值】 + */ + private String resiIdCard; + + /** + * 公安部人员姓名 + */ + private String policeName; + + /** + * 公安部人员证件号 + */ + private String policeIdCard; + + /** + * 数据状态(0:未处理 1:已处理) + */ + private String type; + + /** + * 信息一致性(0:否 1:是 2:-)2代表程序比对了没有匹配上 + */ + private String identical; + + /** + * 是否比对过(0:否 1:是) + */ + private String isComparison; + + /** + * 比对结果说明 + */ + private String comparisonResult; + + /** + * + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ComparisonFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ComparisonFormDTO.java new file mode 100644 index 0000000000..53688b39da --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ComparisonFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +@Data +public class ComparisonFormDTO extends PageFormDTO { + private static final long serialVersionUID = 9156247659994638103L; + public interface Update extends CustomerClientShowGroup { + } + + /** + * 居民Id集合 + */ + private List userIdList; + /** + * 比对记录Id + */ + @NotBlank(message = "比对记录Id不能为空", groups = {Update.class}) + private String comparisonRecordId; + + /** + * token里设置 + */ + private String customerId; + private String userId; + private String agencyId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ResiComparisonListFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ResiComparisonListFormDTO.java new file mode 100644 index 0000000000..e16be96134 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/ResiComparisonListFormDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.Data; + +/** + * @Description 数据比对列表-接口入参 + * @Author sun + */ +@Data +public class ResiComparisonListFormDTO extends PageFormDTO { + private static final long serialVersionUID = 9156247659994638103L; + + /** + * 信息一致性(0:否 1:是 2:-)2代表程序比对了没有匹配上 + */ + private String identical; + /** + * 数据状态(0:未处理 1:已处理) + */ + private String type; + /** + * 身份证号 + */ + private String idCard; + + private Integer pageNo = 1; + private Integer pageSize = 20; + private Boolean isPage = true; + + + /** + * token里设置 + */ + private String customerId; + private String userId; + private String agencyId; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/ComparisonResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/ComparisonResultDTO.java new file mode 100644 index 0000000000..9310c125e1 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/ComparisonResultDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class ComparisonResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 是否存在异常 + */ + private Boolean result = false; + /** + * 接口反馈说明 + */ + private String resultExplain; + +} diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/ResiComparisonListResultDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/ResiComparisonListResultDTO.java new file mode 100644 index 0000000000..a25b565b80 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/result/ResiComparisonListResultDTO.java @@ -0,0 +1,70 @@ +package com.epmet.dto.result; + +import com.alibaba.excel.annotation.write.style.HeadStyle; +import com.alibaba.excel.enums.poi.FillPatternTypeEnum; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Description 数据比对列表-接口返参 + * @Author sun + */ +@Data +public class ResiComparisonListResultDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 比对记录表Id + */ + private String comparisonRecordId; + + /** + * ic_resi_user.id【比对时的数据值】 + */ + private String resiId; + + /** + * 居民库姓名 + */ + private String resiName; + + /** + * 居民库证件号 + */ + private String resiIdCard; + + /** + * 公安部人员姓名 + */ + private String policeName; + + /** + * 公安部人员证件号 + */ + private String policeIdCard; + + /** + * 数据状态(0:未处理 1:已处理) + */ + private String type; + private String typeName; + + /** + * 信息一致性(0:否 1:是 2:-)2代表程序比对了没有匹配上 + */ + private String identical; + private String identicalName; + + /** + * 是否比对过(0:否 1:是) + */ + private String isComparison; + private String isComparisonName; + + /** + * 比对结果说明 + */ + private String comparisonResult; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiComparisonRecordController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiComparisonRecordController.java new file mode 100644 index 0000000000..10b14afe76 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiComparisonRecordController.java @@ -0,0 +1,136 @@ +package com.epmet.controller; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.annotation.MaskResponse; +import com.epmet.commons.tools.aop.NoRepeatSubmit; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dto.form.ComparisonFormDTO; +import com.epmet.dto.form.ResiComparisonListFormDTO; +import com.epmet.dto.result.ComparisonResultDTO; +import com.epmet.dto.result.ResiComparisonListResultDTO; +import com.epmet.excel.IcResiComparisonRecordExcel; +import com.epmet.service.IcResiComparisonRecordService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Date; +import java.util.List; + + +/** + * 居民信息与公安部信息比对记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-11-14 + */ +@Slf4j +@RestController +@RequestMapping("icResiComparisonRecord") +public class IcResiComparisonRecordController implements ResultDataResolver { + + @Autowired + private IcResiComparisonRecordService icResiComparisonRecordService; + + + /** + * @Author sun + * @Description 数据比对列表 + **/ + @PostMapping("resiComparisonList") + @MaskResponse(fieldNames = {"resiIdCard", "policeIdCard"}, fieldsMaskType = {MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD}) + public Result> resiComparisonList(@LoginUser TokenDto tokenDto, @RequestBody ResiComparisonListFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + return new Result>().ok(icResiComparisonRecordService.resiComparisonList(formDTO)); + } + + /** + * @Author sun + * @Description 比对、批量比对、组织及下级比对 + **/ + @PostMapping("comparison") + public Result comparison(@LoginUser TokenDto tokenDto, @RequestBody ComparisonFormDTO formDTO) { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + return new Result().ok(icResiComparisonRecordService.comparison(formDTO)); + } + + /** + * @Author sun + * @Description 比对后的更新 + **/ + @PostMapping("comparisonUpdate") + public Result comparisonUpdate(@LoginUser TokenDto tokenDto, @RequestBody ComparisonFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, ComparisonFormDTO.Update.class); + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + icResiComparisonRecordService.comparisonUpdate(formDTO); + return new Result(); + } + + /** + * @Author sun + * @Description 比对记录数据导出 + **/ + @NoRepeatSubmit + @PostMapping("export") + public void export(@LoginUser TokenDto tokenDto, @RequestBody ResiComparisonListFormDTO formDTO, HttpServletResponse response) throws IOException { + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setUserId(tokenDto.getUserId()); + formDTO.setIsPage(false); + ExcelWriter excelWriter = null; + formDTO.setPageNo(NumConstant.ONE); + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + try { + String fileName = "比对记录" + DateUtils.format(new Date()) + ".xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcResiComparisonRecordExcel.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + PageData data = null; + List list = null; + do { + data = icResiComparisonRecordService.resiComparisonList(formDTO); + list = ConvertUtils.sourceToTarget(data.getList(), IcResiComparisonRecordExcel.class); + formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); + excelWriter.write(list, writeSheet); + } while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiComparisonRecordDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiComparisonRecordDao.java new file mode 100644 index 0000000000..848067199c --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiComparisonRecordDao.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.ResiComparisonListFormDTO; +import com.epmet.dto.result.ResiComparisonListResultDTO; +import com.epmet.entity.IcResiComparisonRecordEntity; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 居民信息与公安部信息比对记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-11-14 + */ +@Mapper +public interface IcResiComparisonRecordDao extends BaseDao { + + List getResiComparisonList(ResiComparisonListFormDTO formDTO); + + void saveInsert(IcResiComparisonRecordEntity recordEntity); +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 8caa220af2..762baa4ed5 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.tools.dto.result.OptionDataResultDTO; +import com.epmet.commons.tools.page.PageData; import com.epmet.dto.IcResiUserConfirmDTO; import com.epmet.dto.IcResiUserDTO; import com.epmet.dto.IcVolunteerPolyDTO; @@ -439,4 +440,6 @@ public interface IcResiUserDao extends BaseDao { * @Date 2022/10/24 15:47 */ ResiAndLocalResiResultDTO getResiCount(@Param("agencyId")String agencyId,@Param("idCard")String idCard,@Param("customerId")String customerId); + + List getResiUserList(ComparisonFormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiComparisonRecordEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiComparisonRecordEntity.java new file mode 100644 index 0000000000..ad290f5755 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcResiComparisonRecordEntity.java @@ -0,0 +1,71 @@ +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 出生管理 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-05-10 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("ic_resi_comparison_record") +public class IcResiComparisonRecordEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * ic_resi_user.id【比对时的数据值】 + */ + private String resiId; + + /** + * 数字社区人员姓名【比对时的数据值】 + */ + private String resiName; + + /** + * 数据社区身份证号【比对时的数据值】 + */ + private String resiIdCard; + + /** + * 公安部人员姓名 + */ + private String policeName; + + /** + * 公安部人员证件号 + */ + private String policeIdCard; + + /** + * 数据状态(0:未处理 1:已处理) + */ + private String type; + + /** + * 信息一致性(0:否 1:是 2:-)2代表程序比对了没有匹配上 + */ + private String identical; + + /** + * 是否比对过(0:否 1:是) + */ + private String isComparison; + + /** + * 比对结果说明 + */ + private String comparisonResult; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcResiComparisonRecordExcel.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcResiComparisonRecordExcel.java new file mode 100644 index 0000000000..2442b95a31 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcResiComparisonRecordExcel.java @@ -0,0 +1,64 @@ +package com.epmet.excel; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.HeadStyle; +import com.alibaba.excel.enums.poi.FillPatternTypeEnum; +import lombok.Data; + +import java.io.Serializable; + +/** + * 比对记录 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-11-14 + */ +@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 44) +@Data +public class IcResiComparisonRecordExcel implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 居民库姓名 + */ + @ExcelProperty(value = "居民库-姓名") + @ColumnWidth(15) + private String resiName; + + /** + * 居民库证件号 + */ + @ExcelProperty(value = "居民库=证件号") + @ColumnWidth(20) + private String resiIdCard; + + /** + * 公安部人员姓名 + */ + @ExcelProperty(value = "公安-姓名") + @ColumnWidth(15) + private String policeName; + + /** + * 公安部人员证件号 + */ + @ExcelProperty(value = "公安-证件号") + @ColumnWidth(20) + private String policeIdCard; + + /** + * 数据状态(0:未处理 1:已处理) + */ + @ExcelProperty(value = "状态") + @ColumnWidth(12) + private String typeName; + + /** + * 信息一致性(0:否 1:是 2:-)2代表程序比对了没有匹配上 + */ + @ExcelProperty(value = "信息一致") + @ColumnWidth(12) + private String identicalName; + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiComparisonRecordService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiComparisonRecordService.java new file mode 100644 index 0000000000..5d846db7d7 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiComparisonRecordService.java @@ -0,0 +1,24 @@ +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.ComparisonFormDTO; +import com.epmet.dto.form.ResiComparisonListFormDTO; +import com.epmet.dto.result.ComparisonResultDTO; +import com.epmet.dto.result.ResiComparisonListResultDTO; +import com.epmet.entity.IcResiComparisonRecordEntity; + +/** + * 居民信息与公安部信息比对记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-11-14 + */ +public interface IcResiComparisonRecordService extends BaseService { + + PageData resiComparisonList(ResiComparisonListFormDTO formDTO); + + ComparisonResultDTO comparison(ComparisonFormDTO formDTO); + + void comparisonUpdate(ComparisonFormDTO formDTO); +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiComparisonRecordServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiComparisonRecordServiceImpl.java new file mode 100644 index 0000000000..37f3427ac3 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiComparisonRecordServiceImpl.java @@ -0,0 +1,215 @@ +package com.epmet.service.impl; + +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.dto.result.YtSfhyxxcxdsjjResDTO; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerStaffRedis; +import com.epmet.commons.tools.utils.YtHsResUtils; +import com.epmet.dao.IcResiComparisonRecordDao; +import com.epmet.dao.IcResiUserDao; +import com.epmet.dto.IcResiUserDTO; +import com.epmet.dto.form.ComparisonFormDTO; +import com.epmet.dto.form.ResiComparisonListFormDTO; +import com.epmet.dto.result.ComparisonResultDTO; +import com.epmet.dto.result.ResiComparisonListResultDTO; +import com.epmet.entity.IcResiComparisonRecordEntity; +import com.epmet.entity.IcResiUserEntity; +import com.epmet.service.IcResiComparisonRecordService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Service; + +/** + * 居民信息与公安部信息比对记录表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2022-11-14 + */ +@Service +@Slf4j +public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl implements IcResiComparisonRecordService, ResultDataResolver { + @Autowired + private IcResiUserDao icResiUserDao; + + + @Override + public PageData resiComparisonList(ResiComparisonListFormDTO formDTO) { + //1.获取工作人员信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + formDTO.setAgencyId(staffInfo.getAgencyId()); + //2.按条件分页查询数据s + PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) + .doSelectPageInfo(() -> baseDao.getResiComparisonList(formDTO)); + + return new PageData(data.getList(), data.getTotal()); + } + + /** + * @Author sun + * @Description 比对、批量比对、组织及下级比对 + **/ + @Override + public ComparisonResultDTO comparison(ComparisonFormDTO formDTO) { + ComparisonResultDTO resultDTO = new ComparisonResultDTO(); + //1.获取工作人员信息 + CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getUserId()); + if (null == staffInfo) { + throw new EpmetException(String.format("查询工作人员%s缓存信息失败...", formDTO.getUserId())); + } + formDTO.setAgencyId(staffInfo.getAgencyId()); + //2.判断是单条比对的则直接处理 + if (formDTO.getUserIdList().size() == 1) { + IcResiUserEntity entity = icResiUserDao.selectById(formDTO.getUserIdList().get(NumConstant.ZERO)); + if (null == entity) { + resultDTO.setResult(true); + resultDTO.setResultExplain("未查询到居民信息"); + return resultDTO; + } + IcResiComparisonRecordEntity recordEntity = new IcResiComparisonRecordEntity(); + recordEntity.setCustomerId(entity.getCustomerId()); + recordEntity.setResiId(entity.getId()); + recordEntity.setResiName(entity.getName()); + recordEntity.setResiIdCard(entity.getIdCard()); + recordEntity.setIsComparison("1"); + YtSfhyxxcxdsjjResDTO sfhyxxcxdsjjResult = YtHsResUtils.sfhyxxcxdsjj(entity.getIdCard(), entity.getName()); + /*YtSfhyxxcxdsjjResDTO sfhyxxcxdsjjResult = new YtSfhyxxcxdsjjResDTO(); + YtSfhyxxcxdsjjResDTO.YtSfhyxxcxdsjjDetail f = new YtSfhyxxcxdsjjResDTO.YtSfhyxxcxdsjjDetail(); + List l = new ArrayList<>(); + YtSfhyxxcxdsjjResDTO.Result d = new YtSfhyxxcxdsjjResDTO.Result(); + d.setGMSFHM("371424188808087654"); + d.setXM("小二"); + l.add(d); + f.setResult(l); + sfhyxxcxdsjjResult.setData(f);*/ + if (sfhyxxcxdsjjResult.getCode() != 200) { + recordEntity.setComparisonResult("公安部接口调用失败"); + resultDTO.setResult(true); + resultDTO.setResultExplain("公安部接口调用失败"); + return resultDTO; + } else { + //数据已处理 + recordEntity.setType("1"); + //公安部不存在的数据 + if (CollectionUtils.isEmpty(sfhyxxcxdsjjResult.getData().getResult())) { + recordEntity.setComparisonResult("公安部身份证号对应数据不存在"); + //代表程序干活了 + recordEntity.setIdentical("2"); + resultDTO.setResult(true); + resultDTO.setResultExplain("公安部身份证号对应数据不存在"); + } else {//在公安部查询到了数据 + recordEntity.setPoliceName(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM()); + recordEntity.setPoliceIdCard(sfhyxxcxdsjjResult.getData().getResult().get(0).getGMSFHM()); + //公安部跟居民库姓名不一致 + if (!entity.getName().equals(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM())) { + recordEntity.setIdentical("0"); + recordEntity.setComparisonResult("公安部与居民库姓名不相同"); + resultDTO.setResult(true); + resultDTO.setResultExplain("公安部与居民库姓名不相同"); + } else { + recordEntity.setIdentical("1"); + } + } + } + recordEntity.setCreatedBy(formDTO.getUserId()); + recordEntity.setUpdatedBy(formDTO.getUserId()); + baseDao.saveInsert(recordEntity); + return resultDTO; + } + //3.判断多条比对则开启子线程执行 + if (CollectionUtils.isEmpty(formDTO.getUserIdList()) || formDTO.getUserIdList().size() > NumConstant.ONE) { + asyncComparison(formDTO); + resultDTO.setResult(true); + resultDTO.setResultExplain("数据比对中请稍后"); + return resultDTO; + } + return resultDTO; + } + + /** + * @Author sun + * @Description 线程逐条比对居民信息 + **/ + @Async + public void asyncComparison(ComparisonFormDTO formDTO) { + PageData data = null; + formDTO.setIsPage(false); + formDTO.setPageSize(NumConstant.ONE_THOUSAND); + int pageNo = formDTO.getPageNo(); + do { + data = getResiUserList(formDTO); + data.getList().forEach(o -> { + IcResiComparisonRecordEntity recordEntity = new IcResiComparisonRecordEntity(); + recordEntity.setCustomerId(o.getCustomerId()); + recordEntity.setResiId(o.getId()); + recordEntity.setResiName(o.getName()); + recordEntity.setResiIdCard(o.getIdCard()); + recordEntity.setIsComparison("1"); + YtSfhyxxcxdsjjResDTO sfhyxxcxdsjjResult = YtHsResUtils.sfhyxxcxdsjj(o.getIdCard(), o.getName()); + if (sfhyxxcxdsjjResult.getCode() != 200) { + recordEntity.setComparisonResult("接口调用失败"); + } else { + //数据已处理 + recordEntity.setType("1"); + //公安部不存在的数据 + if (CollectionUtils.isEmpty(sfhyxxcxdsjjResult.getData().getResult())) { + recordEntity.setComparisonResult("公安部身份证号对应数据不存在"); + //代表程序干活了 + recordEntity.setIdentical("2"); + } else {//在公安部查询到了数据 + recordEntity.setPoliceName(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM()); + recordEntity.setPoliceIdCard(sfhyxxcxdsjjResult.getData().getResult().get(0).getGMSFHM()); + //公安部跟居民库姓名不一致 + if (!o.getName().equals(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM())) { + recordEntity.setIdentical("0"); + recordEntity.setComparisonResult("公安部与居民库姓名不相同"); + } else { + recordEntity.setIdentical("1"); + } + } + } + recordEntity.setCreatedBy(formDTO.getUserId()); + recordEntity.setUpdatedBy(formDTO.getUserId()); + baseDao.saveInsert(recordEntity); + }); + formDTO.setPageNo(++pageNo); + } while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); + } + + private PageData getResiUserList(ComparisonFormDTO formDTO) { + PageInfo data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()) + .doSelectPageInfo(() -> icResiUserDao.getResiUserList(formDTO)); + return new PageData(data.getList(), data.getTotal()); + } + + /** + * @Author sun + * @Description 比对后的更新 + **/ + @Override + public void comparisonUpdate(ComparisonFormDTO formDTO) { + //1.查询比对记录表数据 + IcResiComparisonRecordEntity entity = baseDao.selectById(formDTO.getComparisonRecordId()); + if (null == entity) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "未查询到对应比对记录数据", "未查询到对应比对记录数据"); + } + //2.根据居民信息表数据 + IcResiUserEntity resiUserEntity = new IcResiUserEntity(); + resiUserEntity.setId(entity.getResiId()); + resiUserEntity.setName(entity.getPoliceName()); + icResiUserDao.updateById(resiUserEntity); + } + + +} diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiComparisonRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiComparisonRecordDao.xml new file mode 100644 index 0000000000..584f234505 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiComparisonRecordDao.xml @@ -0,0 +1,108 @@ + + + + + + + + SELECT replace(uuid(),'-','') AS ID + + INSERT INTO ic_resi_comparison_record + ( + id, + customer_id, + resi_id, + resi_name, + resi_id_card, + police_name, + police_id_card, + `type`, + identical, + is_comparison, + comparison_result, + del_flag, + revision, + created_by, + created_time, + updated_by, + updated_time + ) VALUE ( + #{id}, + #{customerId}, + #{resiId}, + #{resiName}, + #{resiIdCard}, + #{policeName}, + #{policeIdCard}, + #{type}, + #{identical}, + #{isComparison}, + #{comparisonResult}, + 0, + 0, + #{createdBy}, + now(), + #{createdBy}, + now() + ) ON DUPLICATE KEY UPDATE + resi_name = values(resi_name), + resi_id_card = values(resi_id_card), + police_name = values(police_name), + police_id_card = values(police_id_card), + `type` = values(`type`), + identical = values(identical), + is_comparison = values(is_comparison), + comparison_result = values(comparison_result), + updated_time = NOW(), + updated_by = #{updatedBy} + + + + + + \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 9c48f39c2f..a86af22468 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -1402,4 +1402,18 @@ AND ID_CARD = #{idCard} + +