From 88cf31cb0e3559b8e60770c52bbe33d987e5bba7 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 1 Nov 2022 11:24:44 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=85=B0=E5=9B=BE=E8=A7=86=E5=9B=BE=E7=9A=84jdbcTempl?= =?UTF-8?q?ate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-user/epmet-user-server/pom.xml | 4 +- .../jdbc/config/JdbcDataSourceConfig.java | 64 +++++++++++++++++++ .../epmet/jdbc/config/JdbcTemplateConfig.java | 30 +++++++++ .../src/main/resources/bootstrap.yml | 16 +++++ 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java create mode 100644 epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java diff --git a/epmet-user/epmet-user-server/pom.xml b/epmet-user/epmet-user-server/pom.xml index ba67ff8170..831b99e408 100644 --- a/epmet-user/epmet-user-server/pom.xml +++ b/epmet-user/epmet-user-server/pom.xml @@ -28,11 +28,11 @@ epmet-commons-mybatis 2.0.0 - + org.springframework.boot spring-boot-starter-web diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcDataSourceConfig.java new file mode 100644 index 0000000000..597ff902a5 --- /dev/null +++ b/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; + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/jdbc/config/JdbcTemplateConfig.java new file mode 100644 index 0000000000..4f8be141f3 --- /dev/null +++ b/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); + } +} \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml b/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml index 11018f0592..184c73ee7b 100644 --- a/epmet-user/epmet-user-server/src/main/resources/bootstrap.yml +++ b/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@ From 6dea7ca5ae5f28208199e989d102d6e5cd0d6fd7 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Wed, 2 Nov 2022 14:25:40 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E6=9F=A5=E8=AF=A2=E6=A0=B8=E9=85=B8=E9=87=87=E6=A0=B7?= =?UTF-8?q?-=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DataSyncConfigServiceImpl.java | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java index bb72f987a6..a72a56edeb 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java +++ b/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 resiInfos, String customerId, String isSync) { + List> resiInfobatchs = ListUtils.partition(resiInfos, 50); + for (List resibatch : resiInfobatchs) { + // 50个一批,来处理他们的核酸信息,太多怕给数据库查崩了。 + yantaiHsjcByDbViewBatch(resibatch, customerId, isSync); + } + } + + /** + * 50个一批,来处理他们的核酸信息,太多怕给数据库查崩了。 + * @param resiInfos + * @param customerId + * @param isSync + */ + public void yantaiHsjcByDbViewBatch(List resiInfos, String customerId, String isSync) { + // 将居民信息转化为的map + Map idCardAndResiInfo = resiInfos.stream().collect(Collectors.toMap(resi -> resi.getIdCard(), Function.identity())); + Set 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 args = new HashMap<>(); + args.put("idCards", idCards); + // 这一批居民的核酸采样列表 + List> hscyList = yantaiJdbcTemplate.queryForList(sql, args); + if (CollectionUtils.isNotEmpty(hscyList)) { + List 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 existSampleInfo = icNatDao.getExistNatInfo(entities); + sampleAndNat(existSampleInfo,entities,NumConstant.ONE_STR,customerId,isSync); + } + } + } } From 24f1d574e39d9247a0b8388b67f6fd6a7fd140f3 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 3 Nov 2022 15:05:07 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9C=AA=E5=81=9A=E6=A0=B8=E9=85=B8?= =?UTF-8?q?=E6=AF=94=E5=AF=B9=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=A4=87=E6=B3=A8?= =?UTF-8?q?=E3=80=81=E9=87=87=E6=A0=B7=E6=97=B6=E9=97=B4=E3=80=82=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=8B=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=8C=E8=BF=98=E6=9C=89=E5=AF=BC=E5=87=BAsql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/IcNatCompareRecordDTO.java | 8 +++ .../yqfk/IcNatCompareRecordPageFormDTO.java | 4 ++ .../entity/IcNatCompareRecordEntity.java | 10 ++- ...IcNatCompareRecordExcelImportListener.java | 66 +++++++++++++------ .../mapper/IcNatCompareRecordDao.xml | 4 ++ 5 files changed, 72 insertions(+), 20 deletions(-) diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java index b422af6b61..be20e5fa68 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcNatCompareRecordDTO.java +++ b/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; + /** * 最近一次核酸时间:接口填入 */ diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java index c5f6ddd53e..ac323d4b8f 100644 --- a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/yqfk/IcNatCompareRecordPageFormDTO.java @@ -38,5 +38,9 @@ public class IcNatCompareRecordPageFormDTO extends PageFormDTO { private String customerId; private String userId; private String agencyId; + /** + * 采样日期:yyyyMMdd + */ + private String cyDate; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java index 0110312ed9..75b18618fe 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcNatCompareRecordEntity.java +++ b/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; } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java index 03c01a2f37..44ed565c6e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/IcNatCompareRecordExcelImportListener.java +++ b/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 AND (r.AGENCY_ID = #{agencyId} or r.pids like concat('%',#{agencyId},'%') ) + + and DATE_FORMAT(c.LATEST_CY_TIME,'%Y%m%d') = #{cyDate} + ORDER BY r.IMPORT_TIME DESC,r.AGENCY_ID desc From dc49dcef0051b6cb93681c8cb6d7d335ffb70ede Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 3 Nov 2022 15:06:07 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=AD=89=E4=BC=9A=E5=9B=9E=E6=9D=A5?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=84=9A=E6=9C=AC=E7=89=88=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V0.0.77__data_compare_d_c - 副本.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.77__data_compare_d_c - 副本.sql diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.77__data_compare_d_c - 副本.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.77__data_compare_d_c - 副本.sql new file mode 100644 index 0000000000..f19afc8b27 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.77__data_compare_d_c - 副本.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; \ No newline at end of file From 24320e97ebf4b36ed5473af61abcd61633bbfee5 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 3 Nov 2022 15:12:54 +0800 Subject: [PATCH 5/5] 80 --- ....77__data_compare_d_c - 副本.sql => V0.0.80__natcompare.sql} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename epmet-user/epmet-user-server/src/main/resources/db/migration/{V0.0.77__data_compare_d_c - 副本.sql => V0.0.80__natcompare.sql} (100%) diff --git a/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.77__data_compare_d_c - 副本.sql b/epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.80__natcompare.sql similarity index 100% rename from epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.77__data_compare_d_c - 副本.sql rename to epmet-user/epmet-user-server/src/main/resources/db/migration/V0.0.80__natcompare.sql