Browse Source

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

master
yinzuomei 3 years ago
parent
commit
599cc52226
  1. 8
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java
  2. 4
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java
  3. 4
      epmet-user/epmet-user-server/pom.xml
  4. 10
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java
  5. 66
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java
  6. 64
      epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java
  7. 30
      epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java
  8. 72
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java
  9. 16
      epmet-user/epmet-user-server/src/main/resources/bootstrap.yml
  10. 2
      epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.80__natcompare.sql
  11. 4
      epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml

8
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java

@ -82,6 +82,14 @@ public class IcNatCompareRecordDTO implements Serializable {
@ExcelIgnore
private String icResiUserId;
/***
* 采样时间
*/
@ColumnWidth(30)
@ExcelProperty("最近一次采样时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date latestCyTime;
/**
* 最近一次核酸时间:接口填入
*/

4
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java

@ -38,6 +38,10 @@ public class IcNatCompareRecordPageFormDTO extends PageFormDTO {
private String customerId;
private String userId;
private String agencyId;
/**
* 采样日期yyyyMMdd
*/
private String cyDate;
/**
* 检测时间

4
epmet-user/epmet-user-server/pom.xml

@ -28,11 +28,11 @@
<artifactId>epmet-commons-mybatis</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<!--<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-commons-dynamic-datasource</artifactId>
<version>2.0.0</version>
</dependency>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

10
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java

@ -45,7 +45,10 @@ public class IcNatCompareRecordEntity extends BaseEpmetEntity {
* 是否客户下居民ic_resi_user.id
*/
private String icResiUserId;
/**
* 最近一次采样时间:接口填入
*/
private Date latestCyTime;
/**
* 最近一次核酸时间:接口填入
*/
@ -68,4 +71,9 @@ public class IcNatCompareRecordEntity extends BaseEpmetEntity {
* 最新一次导入时间对应ic_nat_compare_rec_relation.IMPORT_TIME
*/
private Date latestImportTime;
/**
* 备注系统内部使用方便看看错误
*/
private String internalRemark;
}

66
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java

@ -5,6 +5,7 @@ import com.alibaba.excel.read.listener.ReadListener;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.dto.result.YtHscyResDTO;
import com.epmet.commons.tools.dto.result.YtHsjcResDTO;
import com.epmet.commons.tools.dto.result.YtHsjcResDetailDTO;
import com.epmet.commons.tools.enums.EnvEnum;
@ -84,27 +85,54 @@ public class IcNatCompareRecordExcelImportListener implements ReadListener<IcNat
// 开发和测试没法测试,只能写死只有生产才去调用了 烟台客户id:1535072605621841922
EnvEnum currentEnv = EnvEnum.getCurrentEnv();
if (EnvEnum.PROD.getCode().equals(currentEnv.getCode()) && "1535072605621841922".equals(customerId)) {
// 调用烟台api获取核酸检测结果
YtHsjcResDTO hsjcResDTO = YtHsResUtils.hsjc(data.getIdCard(), 1, 1);
if (null != hsjcResDTO && CollectionUtils.isNotEmpty(hsjcResDTO.getData()) && null != hsjcResDTO.getData().get(0)) {
YtHsjcResDetailDTO ytHsjcResDetailDTO = hsjcResDTO.getData().get(0);
String testTime = ytHsjcResDetailDTO.getTest_time();
if (StringUtils.isNotBlank(testTime)) {
// 赋值最近一次核酸时间
compareRecordEntity.setLatestNatTime(DateUtils.parse(testTime, DateUtils.DATE_TIME_PATTERN));
}
// 赋值检测地点
compareRecordEntity.setNatAddress(StringUtils.isNotBlank(ytHsjcResDetailDTO.getSampling_org_pcr()) ? ytHsjcResDetailDTO.getSampling_org_pcr() : StrConstant.EPMETY_STR);
//先查询最后一次采样记录
YtHscyResDTO hscyResDTO=YtHsResUtils.hscy(data.getIdCard(),1,1);
if(CollectionUtils.isNotEmpty(hscyResDTO.getData())){
//存在 最近一条采样记录
YtHscyResDTO.YtHscyResDetail cyDetail=hscyResDTO.getData().get(0);
if (null != cyDetail) {
if(StringUtils.isBlank(cyDetail.getCreate_time())){
compareRecordEntity.setInternalRemark("create_time is null");
}else{
//赋值采样时间
compareRecordEntity.setLatestCyTime(DateUtils.parse(cyDetail.getCreate_time(),DateUtils.DATE_TIME_PATTERN));
// 调用烟台api获取核酸检测结果
YtHsjcResDTO hsjcResDTO = YtHsResUtils.hsjc(data.getIdCard(), 1, 1);
if (null != hsjcResDTO && CollectionUtils.isNotEmpty(hsjcResDTO.getData()) && null != hsjcResDTO.getData().get(0)) {
YtHsjcResDetailDTO ytHsjcResDetailDTO = hsjcResDTO.getData().get(0);
//最近一次采样时间,与最近一次检测结果的采样时间相比较
if(compareRecordEntity.getLatestCyTime().equals(ytHsjcResDetailDTO.getSample_time())){
// 一致说明出结果了
String testTime = ytHsjcResDetailDTO.getTest_time();
if (StringUtils.isNotBlank(testTime)) {
// 赋值最近一次核酸时间
compareRecordEntity.setLatestNatTime(DateUtils.parse(testTime, DateUtils.DATE_TIME_PATTERN));
}
// 赋值检测地点
compareRecordEntity.setNatAddress(StringUtils.isNotBlank(ytHsjcResDetailDTO.getSampling_org_pcr()) ? ytHsjcResDetailDTO.getSampling_org_pcr() : StrConstant.EPMETY_STR);
// "sample_result_pcr":"2",// 核酸检测结果 1:阳性,2:阴性
String sample_result_pcr = ytHsjcResDetailDTO.getSample_result_pcr();
if (NumConstant.ONE_STR.equals(sample_result_pcr)) {
// 检测结果(0:阴性 1:阳性):接口填入
compareRecordEntity.setNatResult(NumConstant.ONE_STR);
} else if (NumConstant.TWO_STR.equals(sample_result_pcr)) {
compareRecordEntity.setNatResult(NumConstant.ZERO_STR);
// "sample_result_pcr":"2",// 核酸检测结果 1:阳性,2:阴性
String sample_result_pcr = ytHsjcResDetailDTO.getSample_result_pcr();
if (NumConstant.ONE_STR.equals(sample_result_pcr)) {
// 检测结果(0:阴性 1:阳性):接口填入
compareRecordEntity.setNatResult(NumConstant.ONE_STR);
} else if (NumConstant.TWO_STR.equals(sample_result_pcr)) {
compareRecordEntity.setNatResult(NumConstant.ZERO_STR);
}
compareRecordEntity.setContactAddress(StringUtils.isNotBlank(ytHsjcResDetailDTO.getAddress()) ? ytHsjcResDetailDTO.getAddress() : StrConstant.EPMETY_STR);
}else{
//采样时间不一致,说明未出结果
compareRecordEntity.setInternalRemark(String.format("采样时间不一致,采样接口返回的采样时间:%s,检测结果接口返回的采样时间:%s",compareRecordEntity.getLatestCyTime(),ytHsjcResDetailDTO.getSample_time()));
}
}else{
compareRecordEntity.setInternalRemark("检测结果查询接口为空");
}
}
}else{
compareRecordEntity.setInternalRemark("采样信息查询接口返回成功,data is null");
}
compareRecordEntity.setContactAddress(StringUtils.isNotBlank(ytHsjcResDetailDTO.getAddress()) ? ytHsjcResDetailDTO.getAddress() : StrConstant.EPMETY_STR);
}else{
compareRecordEntity.setInternalRemark("采样信息查询接口返回失败,data is empty");
}
}
datas.add(compareRecordEntity);

64
epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java

@ -0,0 +1,64 @@
package com.epmet.jdbc.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
/**
* jdbc连接外部数据源配置
*/
@Configuration
public class JdbcDataSourceConfig {
// ----------------对接兰图的数据源-------------------
@Value("${spring.datasource.yantai.lantu.driver-class-name}")
private String yantaiLantuDriverClassName;
@Value("${spring.datasource.yantai.lantu.url}")
private String yantaiLantuUrl;
@Value("${spring.datasource.yantai.lantu.username}")
private String yantaiLantuUsername;
@Value("${spring.datasource.yantai.lantu.password}")
private String yantaiLantuPassword;
@Value("${spring.datasource.yantai.lantu.initial-size}")
private Integer yantaiLantuInitialSize;
@Value("${spring.datasource.yantai.lantu.max-active}")
private Integer yantaiLantuMacActive;
@Value("${spring.datasource.yantai.lantu.min-idle}")
private Integer yantaiLantuMinIdle;
@Value("${spring.datasource.yantai.lantu.max-wait}")
private Long yantaiLantuMaxWait;
@Value("${spring.datasource.yantai.lantu.pool-prepared-statements}")
private Boolean yantaiLantuPreparedStatements;
@Value("${spring.datasource.yantai.lantu.max-pool-prepared-statement-per-connection-size}")
private Integer yantaiLantuPspcs;
@Value("${spring.datasource.yantai.lantu.time-between-eviction-runs-millis}")
private Long yantaiLantuTberm;
@Value("${spring.datasource.yantai.lantu.min-evictable-idle-time-millis}")
private Long yantaiLantuMeitm;
// ----------------对接兰图的数据源-------------------
/**
* 烟台-连接兰图的数据源
* @return
*/
DataSource createYantaiLantuDataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(yantaiLantuDriverClassName);
druidDataSource.setUrl(yantaiLantuUrl);
druidDataSource.setUsername(yantaiLantuUsername);
druidDataSource.setPassword(yantaiLantuPassword);
druidDataSource.setInitialSize(yantaiLantuInitialSize);
druidDataSource.setMaxActive(yantaiLantuMacActive);
druidDataSource.setMinIdle(yantaiLantuMinIdle);
druidDataSource.setMaxWait(yantaiLantuMaxWait);
druidDataSource.setPoolPreparedStatements(yantaiLantuPreparedStatements);
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(yantaiLantuPspcs);
druidDataSource.setTimeBetweenEvictionRunsMillis(yantaiLantuTberm);
druidDataSource.setMinEvictableIdleTimeMillis(yantaiLantuMeitm);
return druidDataSource;
}
}

30
epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java

@ -0,0 +1,30 @@
package com.epmet.jdbc.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.AutoConfigurationPackage;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource;
/**
* jdbcTemplate配置类
*/
@Configuration
public class JdbcTemplateConfig {
@Autowired
private JdbcDataSourceConfig jdbcDataSourceConfig;
/**
* 烟台-兰图-jdbcTempalte对象
* @return
*/
@Bean
JdbcTemplate yantaiLantuJdbcTemplate() {
DataSource yantaiLantuDataSource = jdbcDataSourceConfig.createYantaiLantuDataSource();
return new JdbcTemplate(yantaiLantuDataSource);
}
}

72
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java

@ -12,6 +12,7 @@ import com.epmet.commons.tools.dto.result.YtHscyResDTO;
import com.epmet.commons.tools.dto.result.YtHsjcResDTO;
import com.epmet.commons.tools.enums.GenderEnum;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerOrgRedis;
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache;
@ -39,12 +40,15 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -72,6 +76,9 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao
@Autowired
private ExecutorService executorService;
@Resource(name = "yantaiLantuJdbcTemplate")
private JdbcTemplate yantaiJdbcTemplate;
@Override
public DataSyncConfigDTO get(String id) {
DataSyncConfigEntity entity = baseDao.selectById(id);
@ -769,4 +776,69 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao
return this;
}
}
/**
* 烟台核酸检测(视图方式获取数据)
* @param resiInfos
* @param customerId
* @param isSync
*/
public void yantaiHsjcByDbView(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) {
List<List<NatUserInfoResultDTO>> resiInfobatchs = ListUtils.partition(resiInfos, 50);
for (List<NatUserInfoResultDTO> resibatch : resiInfobatchs) {
// 50个一批,来处理他们的核酸信息,太多怕给数据库查崩了。
yantaiHsjcByDbViewBatch(resibatch, customerId, isSync);
}
}
/**
* 50个一批来处理他们的核酸信息太多怕给数据库查崩了
* @param resiInfos
* @param customerId
* @param isSync
*/
public void yantaiHsjcByDbViewBatch(List<NatUserInfoResultDTO> resiInfos, String customerId, String isSync) {
// 将居民信息转化为<idCard,resiInfo>的map
Map<String, NatUserInfoResultDTO> idCardAndResiInfo = resiInfos.stream().collect(Collectors.toMap(resi -> resi.getIdCard(), Function.identity()));
Set<String> idCards = idCardAndResiInfo.keySet();//resiInfos.stream().map(resi -> resi.getIdCard()).collect(Collectors.toList());
// String idCardsStr = "''" + String.join("','", idCards) + "''";
// 1.获取核酸采样信息
String sql = "select id, name,card_no, create_time, realname from hscyxxb where card_no in (:idCards) order by create_time desc";
HashMap<String, Object> args = new HashMap<>();
args.put("idCards", idCards);
// 这一批居民的核酸采样列表
List<Map<String, Object>> hscyList = yantaiJdbcTemplate.queryForList(sql, args);
if (CollectionUtils.isNotEmpty(hscyList)) {
List<IcNatEntity> entities = new ArrayList<>();
hscyList.forEach(sampleInfo -> {
// 从视图中获取到的核酸采样相关信息
String name = (String) sampleInfo.get("name");
String cardNo = (String) sampleInfo.get("card_no");
Date createTime = (Date) sampleInfo.get("create_time");
// 本地数据库中,居民信息
NatUserInfoResultDTO currentResiInfo = idCardAndResiInfo.get(cardNo);
IcNatEntity e = new IcNatEntity();
e.setCustomerId(customerId);
e.setIsResiUser(StringUtils.isBlank(currentResiInfo.getUserId()) ? NumConstant.ZERO_STR : NumConstant.ONE_STR);
e.setUserId(currentResiInfo.getUserId());
e.setMobile("");
e.setUserType(isSync.equals(NumConstant.ONE_STR) ? "manualSync" : "sync");
e.setName(StringUtils.isNotBlank(name) ? name : "");
e.setIdCard(StringUtils.isNotBlank(cardNo) ? cardNo : "");
e.setSampleTime(createTime);
// e.setSampleTime(DateUtils.parseDate(createTime, DateUtils.DATE_TIME_PATTERN));
e.setAgencyId(currentResiInfo.getAgencyId());
e.setPids(currentResiInfo.getPids());
e.setAttachmentType("");
e.setAttachmentUrl("");
entities.add(e);
});
if (CollectionUtils.isNotEmpty(entities)){
List<NatUserInfoResultDTO> existSampleInfo = icNatDao.getExistNatInfo(entities);
sampleAndNat(existSampleInfo,entities,NumConstant.ONE_STR,customerId,isSync);
}
}
}
}

16
epmet-user/epmet-user-server/src/main/resources/bootstrap.yml

@ -52,6 +52,22 @@ spring:
wall:
config:
multi-statement-allow: true
# 对接兰图数据源
yantai:
lantu:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/epmet_gov_voice?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
initial-size: 10
max-active: 100
min-idle: 10
max-wait: 60000
pool-prepared-statements: true
max-pool-prepared-statement-per-connection-size: 20
time-between-eviction-runs-millis: 60000
min-evictable-idle-time-millis: 300000
# 数据迁移工具flyway
flyway:
enabled: @spring.flyway.enabled@

2
epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.80__natcompare.sql

@ -0,0 +1,2 @@
alter table ic_nat_compare_record add COLUMN `LATEST_CY_TIME` datetime DEFAULT NULL COMMENT '最近一次采样时间:接口填入' after IC_RESI_USER_ID;
ALTER TABLE ic_nat_compare_record ADD COLUMN INTERNAL_REMARK VARCHAR ( 128 ) DEFAULT '' COMMENT '备注;系统内部使用,方便看看错误' AFTER LATEST_IMPORT_TIME;

4
epmet-user/epmet-user-server/src/main/resources/mapper/IcNatCompareRecordDao.xml

@ -11,6 +11,7 @@
c.MOBILE,
c.ID_CARD,
c.`NAME`,
c.LATEST_CY_TIME,
c.LATEST_NAT_TIME,
c.NAT_ADDRESS,
c.NAT_RESULT,
@ -55,6 +56,9 @@
<if test='null != agencyId and "" != agencyId'>
AND (r.AGENCY_ID = #{agencyId} or r.pids like concat('%',#{agencyId},'%') )
</if>
<if test='null != cyDate and "" != cyDate'>
and DATE_FORMAT(c.LATEST_CY_TIME,'%Y%m%d') = #{cyDate}
</if>
<if test='null != natDate and "" != natDate'>
<if test='null != natStatus and "1" == natStatus'>

Loading…
Cancel
Save