Browse Source

行程上报拉取调整

dev
zxc 3 years ago
parent
commit
e02281d957
  1. 16
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ConvertUtils.java
  2. 18
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/DataSyncConfigServiceImpl.java
  3. 1
      epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml

16
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/ConvertUtils.java

@ -8,6 +8,7 @@
package com.epmet.commons.tools.utils; package com.epmet.commons.tools.utils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@ -64,6 +65,21 @@ public class ConvertUtils {
return targetList; return targetList;
} }
public static <T> List<T> batchMapToEntity(List<Map<String, Object>> maps, Class<T> entity){
if (CollectionUtils.isEmpty(maps)){
return new ArrayList<>();
}
List targetList = new ArrayList<>(maps.size());
try {
for (Map<String, Object> map : maps) {
targetList.add(mapToEntity(map, entity));
}
}catch (Exception e){
logger.error("batchMapToEntity convert error ", e);
}
return targetList;
}
public static <T> T mapToEntity(Map<String, Object> map, Class<T> entity) { public static <T> T mapToEntity(Map<String, Object> map, Class<T> entity) {
if (null == map){ if (null == map){
return null; return null;

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

@ -1088,11 +1088,13 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao
"]"; "]";
// List<Map<String,Object>> tripReportList = new ArrayList<>(); // List<Map<String,Object>> tripReportList = new ArrayList<>();
List<Map<String,Object>> tripReportList = yantaiNamedParamLantuJdbcTemplate.queryForList( List<Map<String,Object>> tripReportList = yantaiNamedParamLantuJdbcTemplate.queryForList(
"select card_id as idCard, address as detailAddress, 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" + "select id as ytId, card_id as idCard, address as detailAddress, i_flag as iFlag, i_time as iTime, i_type as iType, i_date as iDate,i_id as iId, " +
"carry_hesuan_proof, leave_the_risk_area_time, come_area_full, report_street, arrive_time, shift, come_mode, covid_flag, sex, age,\n" + "travel_code_abnormal travelCodeAbnormal, health_code_abnormal healthCodeAbnormal, twon_name twonName, county_name countyName, " +
"area, card_type, invalid_time, travel_code_img, arrive_lu_time, destination_station, carry_vehicle_number_color, carry_vehicle_number,\n" + "city_name cityName, province_name provinceName, carry_hesuan_proof carryHesuanProof, leave_the_risk_area_time leaveTheRiskAreaTime, come_area_full comeAreaFull, " +
"carry_vehicle, registered_residence_address, registered_residence_city, travel_personnel, via_county, via_city, via_province,\n" + "report_street reportStreet, arrive_time arriveTime, shift, come_mode comeMode, covid_flag covidFlag, sex, age,\n" +
"nonlocal_residence_history, declaration_status, two_code_one_report_status, detection_abnormal from t_ymjz_info where cardno in (:idcards)", args); "area, card_type cardType, invalid_time invalidTime, travel_code_img travelCodeImg, arrive_lu_time arriveLuTime, destination_station destinationStation, carry_vehicle_number_color carryVehicleNumberColor, carry_vehicle_number carryVehicleNumber,\n" +
"carry_vehicle carryVehicle, registered_residence_address registeredResidenceAddress, registered_residence_city registeredResidenceCity, travel_personnel travelPersonnel, via_county viaCounty, via_city viaCity, via_province viaProvince,\n" +
"nonlocal_residence_history nonlocalResidenceHistory, declaration_status declarationStatus, two_code_one_report_status twoCodeOneReportStatus, detection_abnormal detectionAbnormal from v_baobei where card_id in (:idcards)", args);
/*Map<String, Object> objectObjectHashMap = new HashMap<>(); /*Map<String, Object> objectObjectHashMap = new HashMap<>();
tripReportList.add(objectObjectHashMap);*/ tripReportList.add(objectObjectHashMap);*/
if (CollectionUtils.isNotEmpty(tripReportList)){ if (CollectionUtils.isNotEmpty(tripReportList)){
@ -1101,7 +1103,11 @@ public class DataSyncConfigServiceImpl extends BaseServiceImpl<DataSyncConfigDao
// 要更新的 // 要更新的
List<IcTripReportRecordEntity> needUpdate = new ArrayList<>(); List<IcTripReportRecordEntity> needUpdate = new ArrayList<>();
// 要新增的 // 要新增的
List<IcTripReportRecordEntity> entities = ConvertUtils.sourceToTarget(p, IcTripReportRecordEntity.class); List<IcTripReportRecordEntity> entities = ConvertUtils.batchMapToEntity(p, IcTripReportRecordEntity.class);
p.forEach(pp -> entities.stream().filter(ee -> ee.getIdCard().equals(pp.get("idCard"))).forEach(ee -> {
ee.setYtId(pp.get("ytId").toString());
ee.setIId(pp.get("IId").toString());
}));
// List<IcTripReportRecordEntity> entities = JSON.parseArray(json,IcTripReportRecordEntity.class); // List<IcTripReportRecordEntity> entities = JSON.parseArray(json,IcTripReportRecordEntity.class);
// 数据库存在的 // 数据库存在的
List<String> existsTripReport = icTripReportRecordDao.getExistsTripReport(idCards); List<String> existsTripReport = icTripReportRecordDao.getExistsTripReport(idCards);

1
epmet-user/epmet-user-server/src/main/resources/mapper/IcTripReportRecordDao.xml

@ -158,6 +158,7 @@
yt_id yt_id
FROM ic_trip_report_record FROM ic_trip_report_record
WHERE DEL_FLAG = '0' WHERE DEL_FLAG = '0'
AND yt_id is not null and yt_id != ''
AND ID_CARD IN ( AND ID_CARD IN (
<foreach collection="idCards" item="idCard" separator=",">#{idCard}</foreach> <foreach collection="idCards" item="idCard" separator=",">#{idCard}</foreach>
) )

Loading…
Cancel
Save