diff --git a/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/YTTripReportListDTO.java b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/YTTripReportListDTO.java new file mode 100644 index 0000000000..5d0f034489 --- /dev/null +++ b/epmet-user/epmet-user-client/src/main/java/com/epmet/dto/YTTripReportListDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2022/11/11 15:05 + */ +@Data +public class YTTripReportListDTO implements Serializable { + private static final long serialVersionUID = -5583350209850076659L; + + private String cardno; + + + +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/EpidemicConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/EpidemicConstant.java index 3b843838e4..49da3ee0b9 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/EpidemicConstant.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/EpidemicConstant.java @@ -18,9 +18,11 @@ public interface EpidemicConstant { * ic_sync_job 任务类型 * 核酸检测 * 疫苗接种 + * 行程上报 */ String JOB_TYPE_NAT = "nat"; String JOB_TYPE_VACCINE = "vaccine"; + String JOB_TYPE_TRIP_REPORT = "trip_report"; // 居民信息对比 String JOB_TYPE_COMPARISON_RESI = "comparison_resi"; diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcTripReportRecordDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcTripReportRecordDao.java index fc7a3ce96e..d22249c42f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcTripReportRecordDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcTripReportRecordDao.java @@ -63,4 +63,20 @@ public interface IcTripReportRecordDao extends BaseDao */ List emphasisTripPieDetail(EmphasisTripPieDetailFormDTO formDTO); + /** + * @Description 根据身份证查询存在的行程上报记录ID + * @param idCards + * @Author zxc + * @Date 2022/11/22 16:16 + */ + List getExistsTripReport(@Param("idCards")List idCards); + + /** + * @Description 批量更新行程上报 + * @param list + * @Author zxc + * @Date 2022/11/22 16:54 + */ + void updateTripReportList(@Param("list")List list); + } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/processor/YanTaiTripReportSyncProcessor.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/processor/YanTaiTripReportSyncProcessor.java new file mode 100644 index 0000000000..91d253ed68 --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/processor/YanTaiTripReportSyncProcessor.java @@ -0,0 +1,60 @@ +package com.epmet.processor; + +import com.epmet.constant.EpidemicConstant; +import com.epmet.entity.IcSyncJobEntity; +import com.epmet.service.DataSyncConfigService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import static com.epmet.constant.EpidemicConstant.JOB_TYPE_TRIP_REPORT; +import static com.epmet.constant.EpidemicConstant.JOB_TYPE_VACCINE; + +/** + * @Description 烟台行程上报数据同步处理器 + * @Author zxc + * @Date 2022/11/22 14:08 + */ +@Component +@Slf4j +public class YanTaiTripReportSyncProcessor extends AbstractDataSyncJobProcessor { + + @Autowired + private DataSyncConfigService dataSyncConfigService; + + /** + * @Description 定时扫描和执行同步任务【行程上报】 + * @Author zxc + * @Date 2022/11/11 10:32 + */ + @Scheduled(cron = "0/10 * * * * ? ") + public void scanJobs() { + scanAndExecWaitingJobs(); + } + + @Override + protected void execJobTask(IcSyncJobEntity jobEntity) { + dataSyncConfigService.execSyncByJobProcessor(jobEntity); + } + + @Override + protected String getDistributeLockKey() { + return "data:sync:" + JOB_TYPE_TRIP_REPORT; + } + + @Override + protected String getJobType() { + return EpidemicConstant.JOB_TYPE_TRIP_REPORT; + } + + @Override + protected long getDistributeLockLeaseTime() { + return 60; + } + + @Override + protected long getDistributeLockWaitTime() { + return 60; + } +} 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 b8b9300d2b..2cf5d3ae80 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 @@ -28,10 +28,7 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.YtHsResUtils; import com.epmet.constant.EpidemicConstant; -import com.epmet.dao.DataSyncConfigDao; -import com.epmet.dao.IcNatDao; -import com.epmet.dao.IcSyncJobDao; -import com.epmet.dao.IcVaccineDao; +import com.epmet.dao.*; import com.epmet.dto.DataSyncConfigDTO; import com.epmet.dto.DataSyncRecordDeathDTO; import com.epmet.dto.DataSyncRecordDisabilityDTO; @@ -105,6 +102,10 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl resiInfos, String customerId, String isSync){ + // 将居民信息转化为的map + Map idCardAndResiInfoMap = resiInfos.stream().collect(Collectors.toMap(resi -> resi.getIdCard(), Function.identity())); + List idCards = new ArrayList<>(idCardAndResiInfoMap.keySet()); + Map args = new HashMap<>(); + args.put("idcards", idCards); + List> tripReportList = yantaiNamedParamLantuJdbcTemplate.queryForList( + "select card_id as idCard, address as presentAddress, i_flag, i_time, i_type, i_date,i_id, travel_code_abnormal, health_code_abnormal, twon_name, county_name, city_name, province_name,\n" + + "carry_hesuan_proof, leave_the_risk_area_time, come_area_full, report_street, arrive_time, shift, come_mode, covid_flag, sex, age,\n" + + "area, card_type, invalid_time, travel_code_img, arrive_lu_time, destination_station, carry_vehicle_number_color, carry_vehicle_number,\n" + + "carry_vehicle, registered_residence_address, registered_residence_city, travel_personnel, via_county, via_city, via_province,\n" + + "nonlocal_residence_history, declaration_status, two_code_one_report_status, detection_abnormal, from t_ymjz_info where cardno in (:idcards)", args); + if (CollectionUtils.isNotEmpty(tripReportList)){ + List>> partition = ListUtils.partition(tripReportList, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + // 要更新的 + List needUpdate = new ArrayList<>(); + // 要新增的 + List entities = ConvertUtils.sourceToTarget(p, IcTripReportRecordEntity.class); + // 数据库存在的 + List existsTripReport = icTripReportRecordDao.getExistsTripReport(idCards); + if (CollectionUtils.isNotEmpty(existsTripReport)){ + // 要更新的 + existsTripReport.forEach(etr -> entities.stream().filter(e -> e.getIId().equals(etr)).forEach(e -> { + needUpdate.add(e); + })); + // 要新增的 + existsTripReport.forEach(etr -> { + Iterator iterator = entities.iterator(); + while (iterator.hasNext()){ + IcTripReportRecordEntity next = iterator.next(); + if (next.getIId().equals(etr)){ + iterator.remove(); + } + } + }); + if (CollectionUtils.isNotEmpty(entities)){ + entities.forEach(e -> { + + }); + entities.forEach(e -> resiInfos.stream().filter(r ->r.getIdCard().equals(e.getIdCard())).forEach(r -> { + e.setGridId(r.getGridId()); + e.setCustomerId(r.getCustomerId()); + e.setAgencyId(r.getAgencyId()); + e.setPids(r.getPids()); + e.setName(r.getName()); + e.setMobile(r.getMobile()); + e.setUserId(r.getUserId()); + e.setUserType("ytPull"); + + + })); + icTripReportRecordService.insertBatch(entities); + } + if (CollectionUtils.isNotEmpty(needUpdate)){ + // 因为更新字段较多,所以分批操作 + List> needs = ListUtils.partition(needUpdate, NumConstant.TWENTY); + needs.forEach(n -> { + updateTripReportList(n); + }); + } + } + }); + }else { + log.warn("未拉取到行程上报信息!"); + } + } + + @Transactional(rollbackFor = Exception.class) + public void updateTripReportList(List need){ + icTripReportRecordDao.updateTripReportList(need); + } + /** * @Description 疫苗接种信息处理 * @param resiInfos @@ -1076,38 +1162,6 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl args = new HashMap<>(); args.put("idcards", idCards); - // todo 疫苗接种视图 - String json = "[\n" + - " {\n" + - " \"id\": \"751956862490071040\",\n" + - " \"cardno\": \"370785195001012558\",\n" + - " \"name\": \"李国玺\",\n" + - " \"data\":\n" + - " {\n" + - " \"vaccineList\":\n" + - " [\n" + - " {\n" + - " \"vaccineCount\": \"1\",\n" + - " \"inoculateDate\": \"2021-04-24 16:02:46\",\n" + - " \"lastStationName\": \"烟台市只楚医院临时接种点\"\n" + - " },\n" + - " {\n" + - " \"vaccineCount\": \"2\",\n" + - " \"inoculateDate\": \"2021-06-10 16:20:30\",\n" + - " \"lastStationName\": \"烟台市芝罘岛医院临时接种点\"\n" + - " },\n" + - " {\n" + - " \"vaccineCount\": \"3\",\n" + - " \"inoculateDate\": \"2021-12-10 15:12:24\",\n" + - " \"lastStationName\": \"烟台市芝罘岛医院临时接种点\"\n" + - " }\n" + - " ],\n" + - " \"flag\": 1\n" + - " },\n" + - " \"vaccineCount\": 3\n" + - " }\n" + - "]"; -// List vaccineList = JSON.parseArray(json,Map.class); List> vaccineList = yantaiNamedParamLantuJdbcTemplate.queryForList( "select data, name, cardno, vaccineCount from t_ymjz_info where cardno in (:idcards)", args); List ytVaccineListFromApi = new ArrayList<>(); @@ -1129,15 +1183,6 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl data = (Map) v.get("data"); - //if (data.containsKey("vaccineList")){ - // List vaccineList1 = JSON.parseArray(data.get("vaccineList").toString(), YTVaccineListDTO.class); - // vaccineList1.forEach(v1 -> { - // v1.setCardno(v.get("cardno").toString()); - // }); - // ytVaccineListDTOS.addAll(vaccineList1); - //} } }); List entities = new ArrayList<>(); @@ -1157,16 +1202,6 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl + + + update ic_trip_report_record set del_flag='1',UPDATED_BY=#{userId},UPDATED_TIME=NOW() WHERE AGENCY_ID=#{agencyId} @@ -161,4 +172,193 @@ ) + + + + UPDATE ic_trip_report_record + + + + when yt_id = #{l.ytId} then #{l.travelCodeAbnormal} + + + + + when yt_id = #{l.ytId} then #{l.healthCodeAbnormal} + + + + + when yt_id = #{l.ytId} then #{l.twonName} + + + + + when yt_id = #{l.ytId} then #{l.countyName} + + + + + when yt_id = #{l.ytId} then #{l.cityName} + + + + + when yt_id = #{l.ytId} then #{l.provinceName} + + + + + when yt_id = #{l.ytId} then #{l.carryHesuanProof} + + + + + when yt_id = #{l.ytId} then #{l.leaveTheRiskAreaTime} + + + + + when yt_id = #{l.ytId} then #{l.comeAreaFull} + + + + + when yt_id = #{l.ytId} then #{l.reportStreet} + + + + + when yt_id = #{l.ytId} then #{l.arriveTime} + + + + + when yt_id = #{l.ytId} then #{l.shift} + + + + + when yt_id = #{l.ytId} then #{l.comeMode} + + + + + when yt_id = #{l.ytId} then #{l.covidFlag} + + + + + when yt_id = #{l.ytId} then #{l.sex} + + + + + when yt_id = #{l.ytId} then #{l.age} + + + + + when yt_id = #{l.ytId} then #{l.area} + + + + + when yt_id = #{l.ytId} then #{l.cardType} + + + + + when yt_id = #{l.ytId} then #{l.invalidTime} + + + + + when yt_id = #{l.ytId} then #{l.travelCodeImg} + + + + + when yt_id = #{l.ytId} then #{l.arriveLuTime} + + + + + when yt_id = #{l.ytId} then #{l.destinationStation} + + + + + when yt_id = #{l.ytId} then #{l.carryVehicleNumberColor} + + + + + when yt_id = #{l.ytId} then #{l.carryVehicleNumber} + + + + + when yt_id = #{l.ytId} then #{l.carryVehicle} + + + + + when yt_id = #{l.ytId} then #{l.registeredResidenceAddress} + + + + + when yt_id = #{l.ytId} then #{l.registeredResidenceCity} + + + + + when yt_id = #{l.ytId} then #{l.travelPersonnel} + + + + + when yt_id = #{l.ytId} then #{l.viaCounty} + + + + + when yt_id = #{l.ytId} then #{l.viaCity} + + + + + when yt_id = #{l.ytId} then #{l.viaProvince} + + + + + when yt_id = #{l.ytId} then #{l.nonlocalResidenceHistory} + + + + + when yt_id = #{l.ytId} then #{l.declarationStatus} + + + + + when yt_id = #{l.ytId} then #{l.twoCodeOneReportStatus} + + + + + when yt_id = #{l.ytId} then #{l.detectionAbnormal} + + + UPDATED_TIME = NOW() + + WHERE DEL_FLAG = '0' + AND yt_id IN ( + + #{l.ytId} + + ) + \ No newline at end of file