Browse Source

Merge branch 'dev_compare_data' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_compare_data

master
wangxianzhang 3 years ago
parent
commit
a16eaffdea
  1. 1
      epmet-user/epmet-user-server/src/main/java/com/epmet/constant/EpidemicConstant.java
  2. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiComparisonRecordDao.java
  3. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcResiComparisonRecordExcel.java
  4. 118
      epmet-user/epmet-user-server/src/main/java/com/epmet/processor/YanTaiComparisonSyncProcessor.java
  5. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiComparisonRecordService.java
  6. 160
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiComparisonRecordServiceImpl.java
  7. 21
      epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.88__ic_resi_comparison_record.sql
  8. 91
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiComparisonRecordDao.xml
  9. 20
      epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

1
epmet-user/epmet-user-server/src/main/java/com/epmet/constant/EpidemicConstant.java

@ -21,6 +21,7 @@ public interface EpidemicConstant {
*/
String JOB_TYPE_NAT = "nat";
String JOB_TYPE_VACCINE = "vaccine";
String JOB_TYPE_COMPARISON = "comparison";
String OPERATION_STATUS_WAITING = "waiting";
String OPERATION_STATUS_PROCESSING = "processing";

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

@ -18,10 +18,12 @@
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.form.ComparisonFormDTO;
import com.epmet.dto.form.ResiComparisonListFormDTO;
import com.epmet.dto.result.ResiComparisonListResultDTO;
import com.epmet.entity.IcResiComparisonRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -36,5 +38,7 @@ public interface IcResiComparisonRecordDao extends BaseDao<IcResiComparisonRecor
List<ResiComparisonListResultDTO> getResiComparisonList(ResiComparisonListFormDTO formDTO);
void saveInsert(IcResiComparisonRecordEntity recordEntity);
void saveInsert(@Param("list") List<IcResiComparisonRecordEntity> recordEntity);
List<IcResiComparisonRecordEntity> getComparisonList(ComparisonFormDTO formDTO);
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/IcResiComparisonRecordExcel.java

@ -29,7 +29,7 @@ public class IcResiComparisonRecordExcel implements Serializable {
/**
* 居民库证件号
*/
@ExcelProperty(value = "居民库=证件号")
@ExcelProperty(value = "居民库-证件号")
@ColumnWidth(20)
private String resiIdCard;

118
epmet-user/epmet-user-server/src/main/java/com/epmet/processor/YanTaiComparisonSyncProcessor.java

@ -0,0 +1,118 @@
package com.epmet.processor;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.tools.distributedlock.DistributedLock;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.constant.EpidemicConstant;
import com.epmet.dao.IcSyncJobDao;
import com.epmet.entity.IcSyncJobEntity;
import com.epmet.service.DataSyncConfigService;
import com.epmet.service.IcResiComparisonRecordService;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import static com.epmet.constant.EpidemicConstant.JOB_TYPE_NAT;
// 烟台数据比对
@Component
@Slf4j
public class YanTaiComparisonSyncProcessor {
public static final int MAX_EXECUTING_COUNT = 3;
@Autowired
private ExecutorService executorService;
@Autowired
private IcSyncJobDao icSyncJobDao;
@Autowired
private IcResiComparisonRecordService icResiComparisonRecordService;
@Autowired
private DistributedLock distributedLock;
@Autowired
RedisUtils redisUtils;
/**
* 定时扫描和执行同步任务
* 10s扫一次库
*/
@Scheduled(cron = "0/10 * * * * ? ")
public void scanJobs() {
//log.info("【异步数据更新】开始同步任务");
LambdaQueryWrapper<IcSyncJobEntity> executingListQuery = new LambdaQueryWrapper<>();
executingListQuery.eq(IcSyncJobEntity::getOperationStatus, EpidemicConstant.OPERATION_STATUS_PROCESSING);
List<IcSyncJobEntity> executingJobList = icSyncJobDao.selectList(executingListQuery);
if (!CollectionUtils.isEmpty(executingJobList) && executingJobList.size() >= MAX_EXECUTING_COUNT) {
// 最多只允许同时3条线程运行
return;
}
int executingCount = executingJobList.size();
// 还可以运行几条线程
int leftCount = MAX_EXECUTING_COUNT - executingCount;
RLock lock = null;
try {
lock = distributedLock.getLock("data:sync:" + "comparison", 60L, 60L, TimeUnit.SECONDS);
// 查询可执行的任务列表,并且异步执行
List<IcSyncJobEntity> icSyncJobToExec = icSyncJobDao.selectExecutableJobList(
EpidemicConstant.JOB_TYPE_COMPARISON,
leftCount);
if (!CollectionUtils.isEmpty(icSyncJobToExec)) {
// 异步提交任务
for (IcSyncJobEntity jobEntity : icSyncJobToExec) {
updateJobStatus(jobEntity.getId(), EpidemicConstant.OPERATION_STATUS_PROCESSING);
executorService.submit(() -> {
// 将此任务状态修改为执行中
try {
icResiComparisonRecordService.comparisonUserData(jobEntity);
} finally {
// 更新任务状态为结束
updateJobStatus(jobEntity.getId(), EpidemicConstant.OPERATION_STATUS_FINISH);
}
});
}
}
} catch (Exception e) {
log.error("【异步数据更新】出错:{}", ExceptionUtils.getErrorStackTrace(e));
} finally {
if (lock != null) {
lock.unlock();
}
}
}
/**
* 更新任务状态
* @param id
* @param status
*/
private void updateJobStatus(String id, String status) {
LambdaQueryWrapper<IcSyncJobEntity> query = new LambdaQueryWrapper<>();
query.eq(IcSyncJobEntity::getId, id);
IcSyncJobEntity updateEntity = new IcSyncJobEntity();
updateEntity.setOperationStatus(status);
icSyncJobDao.update(updateEntity, query);
}
}

3
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiComparisonRecordService.java

@ -7,6 +7,7 @@ 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.IcSyncJobEntity;
/**
* 居民信息与公安部信息比对记录表
@ -20,5 +21,7 @@ public interface IcResiComparisonRecordService extends BaseService<IcResiCompari
ComparisonResultDTO comparison(ComparisonFormDTO formDTO);
void comparisonUserData(IcSyncJobEntity jobEntity);
void comparisonUpdate(ComparisonFormDTO formDTO);
}

160
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiComparisonRecordServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
@ -8,10 +9,14 @@ 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.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
import com.epmet.commons.tools.utils.YtHsResUtils;
import com.epmet.constant.EpidemicConstant;
import com.epmet.dao.IcResiComparisonRecordDao;
import com.epmet.dao.IcResiUserDao;
import com.epmet.dao.IcSyncJobDao;
import com.epmet.dto.IcResiUserDTO;
import com.epmet.dto.form.ComparisonFormDTO;
import com.epmet.dto.form.ResiComparisonListFormDTO;
@ -19,15 +24,23 @@ 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.entity.IcSyncJobEntity;
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.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import static com.epmet.constant.EpidemicConstant.OPERATION_STATUS_PROCESSING;
import static com.epmet.constant.EpidemicConstant.OPERATION_STATUS_WAITING;
/**
* 居民信息与公安部信息比对记录表
*
@ -39,6 +52,8 @@ import org.springframework.stereotype.Service;
public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiComparisonRecordDao, IcResiComparisonRecordEntity> implements IcResiComparisonRecordService, ResultDataResolver {
@Autowired
private IcResiUserDao icResiUserDao;
@Autowired
private IcSyncJobDao icSyncJobDao;
@Override
@ -77,6 +92,7 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
resultDTO.setResultExplain("未查询到居民信息");
return resultDTO;
}
List<IcResiComparisonRecordEntity> list = new ArrayList<>();
IcResiComparisonRecordEntity recordEntity = new IcResiComparisonRecordEntity();
recordEntity.setCustomerId(entity.getCustomerId());
recordEntity.setResiId(entity.getId());
@ -99,11 +115,11 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
resultDTO.setResultExplain("公安部接口调用失败");
return resultDTO;
} else {
//数据已处理
recordEntity.setType("1");
//公安部不存在的数据
if (CollectionUtils.isEmpty(sfhyxxcxdsjjResult.getData().getResult())) {
recordEntity.setComparisonResult("公安部身份证号对应数据不存在");
//数据不一致的赋值为未处理信息不一致(空)
recordEntity.setType("0");
//代表程序干活了
recordEntity.setIdentical("2");
resultDTO.setResult(true);
@ -113,23 +129,29 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
recordEntity.setPoliceIdCard(sfhyxxcxdsjjResult.getData().getResult().get(0).getGMSFHM());
//公安部跟居民库姓名不一致
if (!entity.getName().equals(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM())) {
//姓名不一致的赋值为未处理信息不一致(否)
recordEntity.setType("0");
recordEntity.setIdentical("0");
recordEntity.setComparisonResult("公安部与居民库姓名不相同");
resultDTO.setResult(true);
resultDTO.setResultExplain("公安部与居民库姓名不相同");
} else {
recordEntity.setType("1");
recordEntity.setIdentical("1");
}
}
}
recordEntity.setCreatedBy(formDTO.getUserId());
recordEntity.setUpdatedBy(formDTO.getUserId());
baseDao.saveInsert(recordEntity);
list.add(recordEntity);
baseDao.saveInsert(list);
return resultDTO;
}
//3.判断多条比对则开启子线程执行
if (CollectionUtils.isEmpty(formDTO.getUserIdList()) || formDTO.getUserIdList().size() > NumConstant.ONE) {
asyncComparison(formDTO);
//asyncComparison(formDTO);
saveComparison(formDTO);
saveJob(formDTO);
resultDTO.setResult(true);
resultDTO.setResultExplain("数据比对中请稍后");
return resultDTO;
@ -149,6 +171,7 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
int pageNo = formDTO.getPageNo();
do {
data = getResiUserList(formDTO);
List<IcResiComparisonRecordEntity> list = new ArrayList<>();
data.getList().forEach(o -> {
IcResiComparisonRecordEntity recordEntity = new IcResiComparisonRecordEntity();
recordEntity.setCustomerId(o.getCustomerId());
@ -160,11 +183,11 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
if (null == sfhyxxcxdsjjResult || sfhyxxcxdsjjResult.getCode() != 200) {
recordEntity.setComparisonResult("接口调用失败");
} else {
//数据已处理
recordEntity.setType("1");
//公安部不存在的数据
if (CollectionUtils.isEmpty(sfhyxxcxdsjjResult.getData().getResult())) {
recordEntity.setComparisonResult("公安部身份证号对应数据不存在");
//数据不一致的赋值为未处理信息不一致(空)
recordEntity.setType("0");
//代表程序干活了
recordEntity.setIdentical("2");
} else {//在公安部查询到了数据
@ -172,21 +195,140 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
recordEntity.setPoliceIdCard(sfhyxxcxdsjjResult.getData().getResult().get(0).getGMSFHM());
//公安部跟居民库姓名不一致
if (!o.getName().equals(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM())) {
//姓名不一致的赋值为未处理信息不一致(否)
recordEntity.setType("0");
recordEntity.setIdentical("0");
recordEntity.setComparisonResult("公安部与居民库姓名不相同");
} else {
recordEntity.setType("1");
recordEntity.setIdentical("1");
}
}
}
recordEntity.setCreatedBy(formDTO.getUserId());
recordEntity.setUpdatedBy(formDTO.getUserId());
baseDao.saveInsert(recordEntity);
list.add(recordEntity);
});
baseDao.saveInsert(list);
formDTO.setPageNo(++pageNo);
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize());
}
/**
* 批量将需要比对的人员数据存入比对记录表中
* @param formDTO
*/
public void saveComparison(ComparisonFormDTO formDTO) {
PageData<IcResiUserDTO> data = null;
formDTO.setIsPage(false);
formDTO.setPageSize(NumConstant.ONE_THOUSAND);
int pageNo = formDTO.getPageNo();
do {
data = getResiUserList(formDTO);
List<IcResiComparisonRecordEntity> list = new ArrayList<>();
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.setType("0");
recordEntity.setIdentical("0");
recordEntity.setIsComparison("0");
list.add(recordEntity);
});
insertBatch(list);
formDTO.setPageNo(++pageNo);
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize());
}
public void saveJob(ComparisonFormDTO formDTO) {
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(formDTO.getAgencyId());
if (null == agencyInfo) {
throw new EpmetException("未查询到组织信息:" + formDTO.getAgencyId());
}
// 查询该组织是否存在等待中或者进行中的任务
LambdaQueryWrapper<IcSyncJobEntity> qw = new LambdaQueryWrapper<>();
qw.eq(IcSyncJobEntity::getOrgId, formDTO.getAgencyId())
.eq(IcSyncJobEntity::getJobType, EpidemicConstant.JOB_TYPE_COMPARISON)
.in(IcSyncJobEntity::getOperationStatus, OPERATION_STATUS_WAITING, OPERATION_STATUS_PROCESSING);
List<IcSyncJobEntity> icSyncJobEntities = icSyncJobDao.selectList(qw);
// 当前组织下存在同步任务
if (CollectionUtils.isNotEmpty(icSyncJobEntities)) {
throw new EpmetException(EpmetErrorCode.EXIST_SYNC_JOB_ERROR.getCode());
}
// 不存在新增一条记录
IcSyncJobEntity e = new IcSyncJobEntity();
e.setCustomerId(formDTO.getCustomerId());
e.setOrgId(formDTO.getAgencyId());
e.setPid(agencyInfo.getPid());
e.setOrgIdPath(StringUtils.isBlank(agencyInfo.getPids()) ? agencyInfo.getId() : agencyInfo.getPids() + ":" + agencyInfo.getId());
e.setJobType(EpidemicConstant.JOB_TYPE_COMPARISON);
e.setOperatorId(formDTO.getUserId());
e.setOperationStatus(OPERATION_STATUS_WAITING);
icSyncJobDao.insert(e);
}
@Override
public void comparisonUserData(IcSyncJobEntity jobEntity) {
ComparisonFormDTO formDTO = new ComparisonFormDTO();
PageData<IcResiComparisonRecordEntity> data = null;
formDTO.setIsPage(false);
formDTO.setPageSize(NumConstant.ONE_THOUSAND);
int pageNo = NumConstant.ONE;
do {
data = getComparisonList(formDTO);
data.getList().forEach(o -> {
o.setIsComparison("1");
YtSfhyxxcxdsjjResDTO sfhyxxcxdsjjResult = YtHsResUtils.sfhyxxcxdsjj(o.getResiIdCard(), o.getResiName());
/*YtSfhyxxcxdsjjResDTO sfhyxxcxdsjjResult = new YtSfhyxxcxdsjjResDTO();
YtSfhyxxcxdsjjResDTO.YtSfhyxxcxdsjjDetail f = new YtSfhyxxcxdsjjResDTO.YtSfhyxxcxdsjjDetail();
List<YtSfhyxxcxdsjjResDTO.Result> l = new ArrayList<>();
YtSfhyxxcxdsjjResDTO.Result d = new YtSfhyxxcxdsjjResDTO.Result();
d.setGMSFHM("371424188808087654");
d.setXM("小二");
l.add(d);
f.setResult(l);
sfhyxxcxdsjjResult.setData(f);*/
if (null == sfhyxxcxdsjjResult || sfhyxxcxdsjjResult.getCode() != 200) {
o.setComparisonResult("接口调用失败");
} else {
//公安部不存在的数据
if (CollectionUtils.isEmpty(sfhyxxcxdsjjResult.getData().getResult())) {
o.setComparisonResult("公安部身份证号对应数据不存在");
//数据不一致的赋值为未处理信息不一致(空)
o.setType("0");
//代表程序干活了
o.setIdentical("2");
} else {//在公安部查询到了数据
o.setPoliceName(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM());
o.setPoliceIdCard(sfhyxxcxdsjjResult.getData().getResult().get(0).getGMSFHM());
//公安部跟居民库姓名不一致
if (!o.getResiName().equals(sfhyxxcxdsjjResult.getData().getResult().get(0).getXM())) {
//姓名不一致的赋值为未处理信息不一致(否)
o.setType("0");
o.setIdentical("0");
o.setComparisonResult("公安部与居民库姓名不相同");
} else {
o.setType("1");
o.setIdentical("1");
}
}
}
o.setCreatedBy(formDTO.getUserId());
o.setUpdatedBy(formDTO.getUserId());
});
baseDao.saveInsert(data.getList());
formDTO.setPageNo(++pageNo);
} while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize());
}
private PageData<IcResiComparisonRecordEntity> getComparisonList(ComparisonFormDTO formDTO) {
PageInfo<IcResiComparisonRecordEntity> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage())
.doSelectPageInfo(() -> baseDao.getComparisonList(formDTO));
return new PageData(data.getList(), data.getTotal());
}
private PageData<IcResiUserDTO> getResiUserList(ComparisonFormDTO formDTO) {
PageInfo<IcResiUserDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage())
.doSelectPageInfo(() -> icResiUserDao.getResiUserList(formDTO));
@ -209,6 +351,10 @@ public class IcResiComparisonRecordServiceImpl extends BaseServiceImpl<IcResiCom
resiUserEntity.setId(entity.getResiId());
resiUserEntity.setName(entity.getPoliceName());
icResiUserDao.updateById(resiUserEntity);
//3.更新比对表数据状态
entity.setType("1");
entity.setIdentical("1");
updateById(entity);
}

21
epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.88__ic_resi_comparison_record.sql

@ -0,0 +1,21 @@
CREATE TABLE `ic_resi_comparison_record` (
`ID` varchar(64) NOT NULL COMMENT 'ID',
`CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户Id',
`RESI_ID` varchar(64) NOT NULL COMMENT 'ic_resi_user.id【比对时的数据值】',
`RESI_NAME` varchar(64) NOT NULL COMMENT '数字社区人员姓名【比对时的数据值】',
`RESI_ID_CARD` varchar(18) NOT NULL COMMENT '数据社区身份证号【比对时的数据值】',
`POLICE_NAME` varchar(64) DEFAULT NULL COMMENT '公安部人员姓名',
`POLICE_ID_CARD` varchar(18) DEFAULT NULL COMMENT '公安部人员证件号',
`TYPE` varchar(1) NOT NULL DEFAULT '0' COMMENT '数据状态(0:未处理 1:已处理)',
`IDENTICAL` varchar(1) NOT NULL DEFAULT '0' COMMENT '信息一致性(0:否 1:是 2:-)2代表程序比对了没有匹配上',
`IS_COMPARISON` varchar(1) DEFAULT '0' COMMENT '是否比对过(0:否 1:是)',
`COMPARISON_RESULT` varchar(255) DEFAULT NULL COMMENT '比对结果说明',
`DEL_FLAG` int(11) NOT NULL COMMENT '删除标识',
`REVISION` int(11) NOT NULL COMMENT '乐观锁',
`CREATED_BY` varchar(32) NOT NULL COMMENT '创建人',
`CREATED_TIME` datetime NOT NULL COMMENT '创建时间',
`UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人',
`UPDATED_TIME` datetime NOT NULL COMMENT '更新时间',
PRIMARY KEY (`ID`),
UNIQUE KEY `resi_id` (`RESI_ID`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT COMMENT='居民信息与公安部信息比对记录表';

91
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiComparisonRecordDao.xml

@ -3,10 +3,7 @@
<mapper namespace="com.epmet.dao.IcResiComparisonRecordDao">
<insert id="saveInsert" useGeneratedKeys="true" keyColumn="id" keyProperty="id" parameterType="com.epmet.entity.IcResiComparisonRecordEntity">
<selectKey keyProperty="id" resultType="java.lang.String" order="BEFORE">
SELECT replace(uuid(),'-','') AS ID
</selectKey>
<insert id="saveInsert">
INSERT INTO ic_resi_comparison_record
(
id,
@ -26,25 +23,30 @@
created_time,
updated_by,
updated_time
) VALUE (
#{id},
#{customerId},
#{resiId},
#{resiName},
#{resiIdCard},
#{policeName},
#{policeIdCard},
#{type},
#{identical},
#{isComparison},
#{comparisonResult},
) VALUE
<foreach collection="list" item="i" separator=",">
(
REPLACE(UUID(), '-', ''),
#{i.customerId},
#{i.resiId},
#{i.resiName},
#{i.resiIdCard},
#{i.policeName},
#{i.policeIdCard},
#{i.type},
#{i.identical},
#{i.isComparison},
#{i.comparisonResult},
0,
0,
#{createdBy},
#{i.createdBy},
now(),
#{createdBy},
#{i.createdBy},
now()
) ON DUPLICATE KEY UPDATE
)
</foreach>
ON DUPLICATE KEY
UPDATE
resi_name = values(resi_name),
resi_id_card = values(resi_id_card),
police_name = values(police_name),
@ -54,33 +56,27 @@
is_comparison = values(is_comparison),
comparison_result = values(comparison_result),
updated_time = NOW(),
updated_by = #{updatedBy}
updated_by = values(updated_by)
</insert>
<select id="getResiComparisonList" resultType="com.epmet.dto.result.ResiComparisonListResultDTO">
SELECT
a.id resiId,
a.`name` resiName,
a.id_card resiIdCard,
b.id comparisonRecordId,
b.police_name policeName,
b.police_id_card policeIdCard,
IFNULL(b.type, '0') type,
IF (b.type = '1', '已处理', '未处理') typeName,
IFNULL(b.identical, '0') identical,
(case b.identical when '0' then '否' when '1' then '是' WHEN '2' THEN '-' else '否' end ) identicalName,
IFNULL(b.is_comparison, '0') isComparison,
IF (b.is_comparison = '1', '是', '否') isComparisonName,
b.comparison_result comparisonResult
a.`name` resiName,
a.id_card resiIdCard,
b.id comparisonRecordId,
b.police_name policeName,
b.police_id_card policeIdCard,
IFNULL(b.type, '0') type,
IF (b.type = '1', '已处理', '未处理') typeName,
IFNULL(b.identical, '0') identical,
(case b.identical when '0' then '否' when '1' then '是' WHEN '2' THEN '-' else '否' end ) identicalName,
IFNULL(b.is_comparison, '0') isComparison,
IF (b.is_comparison = '1', '是', '否') isComparisonName,
b.comparison_result comparisonResult
FROM
ic_resi_user a
LEFT JOIN ic_resi_comparison_record b ON a.id = b.resi_id AND b.del_flag = '0'
<if test='identical != null and identical != "" and identical == "0" '>
AND b.identical =#{identical}
</if>
<if test='type != null and type != "" and type == "0" '>
AND b.type =#{type}
</if>
WHERE
a.del_flag = '0'
AND a.customer_id = #{customerId}
@ -88,13 +84,30 @@
<if test="idCard != null and idCard != ''">
AND a.id_card =#{idCard}
</if>
<if test='identical != null and identical != "" and identical == "0" '>
AND (b.id is null or b.identical =#{identical})
</if>
<if test='identical != null and identical != "" and identical != "0" '>
AND b.identical =#{identical}
</if>
<if test='type != null and type != "" and type == "0" '>
AND (b.id is null or b.type =#{type})
</if>
<if test='type != null and type != "" and type != "0" '>
AND b.type =#{type}
</if>
ORDER BY a.pids ASC, b.created_time DESC
ORDER BY a.pids ASC, b.created_time DESC, a.`NAME` ASC
</select>
<select id="getComparisonList" resultType="com.epmet.entity.IcResiComparisonRecordEntity">
SELECT
*
FROM
ic_resi_comparison_record
WHERE
del_flag = '0'
AND is_comparison = '0'
ORDER BY created_time DESC
</select>

20
epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml

@ -1404,21 +1404,23 @@
<select id="getResiUserList" resultType="com.epmet.dto.IcResiUserDTO">
SELECT
id,
customer_id,
`name`,
id_card
a.id,
a.customer_id,
a.`name`,
a.id_card
FROM
ic_resi_user
ic_resi_user a
LEFT JOIN ic_resi_comparison_record b on a.id = b.RESI_ID
WHERE
del_flag = '0'
AND pids LIKE CONCAT('%',#{agencyId},'%')
a.del_flag = '0'
AND a.pids LIKE CONCAT('%',#{agencyId},'%')
<if test='null != userIdList and userIdList.size() > 0'>
<foreach collection="userIdList" item="id" open="AND id IN (" separator="," close=")">
<foreach collection="userIdList" item="id" open="AND a.id IN (" separator="," close=")">
#{id}
</foreach>
</if>
order by pids ASC, created_time DESC
AND b.id is null
order by a.pids ASC, a.created_time DESC
</select>
</mapper>

Loading…
Cancel
Save