src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService11.java
@@ -27,7 +27,7 @@ @Override public String getProtocol() { return SyncProtocol.FZZY_V35_GB.getCode(); return SyncProtocol.FZZY_V40_GB.getCode(); } @Override src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java
@@ -3,6 +3,10 @@ import com.fzzy.api.data.ApiParam; import com.fzzy.api.data.SyncProtocol; import com.fzzy.api.service.SyncService13; import com.fzzy.async.fzzy40.impl.Fzzy40Sync1302; import com.fzzy.async.fzzy40.impl.Fzzy40Sync1303; import com.fzzy.async.fzzy40.impl.Fzzy40Sync1304; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; /** @@ -15,23 +19,29 @@ @Component public class Fzzy40SyncService13 implements SyncService13 { @Autowired private Fzzy40Sync1302 fzzySync1302; @Autowired private Fzzy40Sync1303 fzzySync1303; @Autowired private Fzzy40Sync1304 fzzySync1304; @Override public String getProtocol() { return SyncProtocol.FZZY_V35_GB.getCode(); return SyncProtocol.FZZY_V40_GB.getCode(); } @Override public void syncData(ApiParam param) { //æ¸©æ¹¿åº¦æ£æµæ°æ®åæ¥ TODO fzzySync1302.syncData(param.getDeptId(), param.getStart(), param.getEnd()); //è«å®³æ£æµåæ¥ TODO fzzySync1303.syncData(param.getDeptId(), param.getStart(), param.getEnd()); //æ°ä½æ£æµåæ¥ TODO fzzySync1304.syncData(param.getDeptId(), param.getStart(), param.getEnd()); //è´¨æ£åæ¥ TODO src/main/java/com/fzzy/async/fzzy40/entity/Fz40Gas.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,117 @@ package com.fzzy.async.fzzy40.entity; import com.bstek.dorado.annotation.PropertyDef; import com.fzzy.async.fzzy35.entity.Fz35GrainKey; import lombok.Data; import javax.persistence.*; import java.io.Serializable; import java.util.Date; import java.util.List; /** * æ°ä½ä¸å¡æ°æ®ä¿¡æ¯å æ¬æµåº¦ï¼æ°®æ°ï¼ååä¿¡æ¯ æ°ä½æ¨¡åï¼å æ¬æ°ä½æµåº¦ * * @author Andy * */ @Data @Entity @Table(name = "D_GAS") @IdClass(Fz40GasKey.class) public class Fz40Gas implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "BATCH_ID_", length = 40) @PropertyDef(label = "æ¹æ¬¡ID") private String batchId; @Id @Column(name = "COMPANY_ID_", length = 10) @PropertyDef(label = "ç»ç»ç¼ç ", description = "") private String companyId; @Id @Column(name = "DEPOT_ID_", length = 50) @PropertyDef(label = "ä»åºID", description = "ä»åºç¼å·") private String depotId; @Column(name = "PER_CO2_") @PropertyDef(label = "äºæ°§å碳æµåº¦", description = "å¹³åäºæ°§å碳æµåº¦(PPM)") private Double perCo2 = 0.0; @Column(name = "PER_O2_") @PropertyDef(label = "æ°§æ°æµåº¦", description = "平忰§æ°æµåº¦(%)") private Double perO2 = 0.0; @Column(name = "PER_PH3_") @PropertyDef(label = "ç£·åæ°¢æµåº¦", description = "å¹³åç£·åæ°¢æµåº¦(PPM)") private Double perPh3 = 0.0; @Column(name = "PER_N2_") @PropertyDef(label = "æ°®æ°æµåº¦", description = "æ°®æ°æµåº¦(%)") private Double perN2 = 0.0; @Column(name = "PER_CO2_MAX_") @PropertyDef(label = "äºæ°§å碳æµåº¦-æå¤§", description = "äºæ°§å碳æµåº¦(PPM)") private Double perCo2Max = 0.0; @Column(name = "PER_O2_MAX_") @PropertyDef(label = "æ°§æ°æµåº¦-æå¤§", description = "æ°§æ°æµåº¦(%)") private Double perO2Max = 0.0; @Column(name = "PER_PH3_MAX_") @PropertyDef(label = "ç£·åæ°¢æµåº¦-æå¤§", description = "ç£·åæ°¢æµåº¦(PPM)") private Double perPh3Max = 0.0; @Column(name = "PER_N2_MAX_") @PropertyDef(label = "æ°®æ°æµåº¦-æå¤§") private Double perN2Max = 0.0; @Column(name = "PER_CO2_MIN_") @PropertyDef(label = "äºæ°§å碳æµåº¦-æå°", description = "äºæ°§å碳æµåº¦(PPM)") private Double perCo2Min = 0.0; @Column(name = "PER_O2_MIN_") @PropertyDef(label = "æ°§æ°æµåº¦-æå°", description = "æ°§æ°æµåº¦(%)") private Double perO2Min = 0.0; @Column(name = "PER_PH3_MIN_") @PropertyDef(label = "ç£·åæ°¢æµåº¦-æå°", description = "ç£·åæ°¢æµåº¦(PPM)") private Double perPh3Min = 0.0; @Column(name = "PER_N2_MIN_") @PropertyDef(label = "æ°®æ°æµåº¦-æå°") private Double perN2Min = 0.0; @Column(name = "RECEIVE_DATE_") @PropertyDef(label = "æ£æµæ¶é´") private Date receiveDate; @Column(name = "GAS_START_") @PropertyDef(label = "æ°ä½ééç¹å¼å§", description = "æ°ä½é 置信æ¯") private int gasStart; @Column(name = "GAS_END_") @PropertyDef(label = "æ°ä½ééç¹æªè³", description = "æ°ä½é 置信æ¯") private int gasEnd; @Column(name = "CHECK_NUM_") @PropertyDef(label = "éééé个æ°") private int checkNum = 0; @Column(name = "POINTS_", length = 2000) @PropertyDef(label = "ééç¹ä¿¡æ¯", description = "åºå®ä¸ºï¼passCode,co2,o2,ph3,n2;passCode,co2,o2,ph3,n2;") private String points; @Column(name = "CHECK_USER_", length = 30) @PropertyDef(label = "æ£æµäºº") private String checkUser; @Column(name = "REMARK_", length = 200) @PropertyDef(label = "夿³¨ä¿¡æ¯") private String remark; } src/main/java/com/fzzy/async/fzzy40/entity/Fz40GasKey.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,17 @@ package com.fzzy.async.fzzy40.entity; import lombok.AllArgsConstructor; import lombok.Data; import java.io.Serializable; @Data @AllArgsConstructor public class Fz40GasKey implements Serializable { private String batchId; private String companyId; private String depotId; public Fz40GasKey(){ super(); } } src/main/java/com/fzzy/async/fzzy40/entity/Fz40Grain.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,107 @@ package com.fzzy.async.fzzy40.entity; import com.bstek.dorado.annotation.PropertyDef; import com.fzzy.async.fzzy35.entity.Fz35GrainKey; import lombok.Data; import javax.persistence.*; import java.io.Serializable; import java.util.Date; /** * ç²®æ æ°æ®-主表 * <p> * æ´æ°è®°å½ï¼ * 1ï¼å é¤è¡æ°æ®ç表记å½ï¼è°æ´ä¸ºæ°æ®ç´æ¥ææ¬ä¿åä¸»è¡¨ä¸ * 2ï¼ä¿çç¹ä½åæ ä¿¡æ¯ï¼ä¾¿äºä»¥åç¹ä½èµ°å¿å¾æ¥ç * * @author Andy */ @Entity @Table(name = "D_GRAIN") @Data @IdClass(Fz40GrainKey.class) public class Fz40Grain implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "BATCH_ID_", length = 30) @PropertyDef(label = "æ¹æ¬¡ç¼å·") private String batchId; @Id @Column(name = "COMPANY_ID_", length = 10) @PropertyDef(label = "ç»ç»ç¼ç ", description = "") private String companyId; @Id @Column(name = "DEPOT_ID_", length = 50) @PropertyDef(label = "æå±ä»åº", description = "ä»åºç¼å·") private String depotId; @Column(name = "TEMP_MIN_") @PropertyDef(label = "æä½æ¸©ç²®æ¸©", description = "åä½âï¼ç²®æ æä½æ¸©") private Double tempMin = 0.0; @Column(name = "TEMP_MAX_") @PropertyDef(label = "æé«ç²®æ¸©", description = "åä½âï¼ç²®æ æé«æ¸©") private Double tempMax = 0.0; @Column(name = "TEMP_AVE_") @PropertyDef(label = "å¹³å粮温", description = "åä½âï¼ç²®æ 平忏©åº¦") private Double tempAve = 0.0; @Column(name = "HUMIDITY_IN_") @PropertyDef(label = "ä»å 湿度") private Double humidityIn; @Column(name = "TEMP_IN_") @PropertyDef(label = "ä»å 温度") private Double tempIn; @Column(name = "HUMIDITY_OUT_") @PropertyDef(label = "ä»å¤æ¹¿åº¦") private Double humidityOut; @Column(name = "TEMP_OUT_") @PropertyDef(label = "ä»å¤æ¸©åº¦") private Double tempOut; @Column(name = "CABLE_", length = 20) @PropertyDef(label = "å±è¡å", description = "ç¨éå·éå¼çé 置信æ¯,å±-è¡-å") private String cable; @PropertyDef(label = "çä»å±é ç½®", description = "ç¨-éå¼çé 置信æ¯") @Column(name = "CABLE_CIR_", length = 20) private String cableCir; @PropertyDef(label = "æ²¹é¢é«åº¦", description = "ç¨-éå¼ç两个å¼ï¼æ²¹é¢é«åº¦-建çé«åº¦") @Column(name = "OIL_HEIGHT_", length = 20) private String oilHeight; @Column(name = "WEATHER_", length = 20) @PropertyDef(label = "天æ°", description = "ç´æ¥å¡«åä¸æä¿¡æ¯ï¼æ´ï¼é´é¨å¤©") private String weather = ""; @Column(name = "RECEIVE_DATE_") @PropertyDef(label = "æ¥æ¶æ¶é´") private Date receiveDate; @Column(name = "CHECK_USER_", length = 30) @PropertyDef(label = "æ£æµäºº") private String checkUser; @Column(name = "REMARK_", length = 500) @PropertyDef(label = "夿³¨", description = "夿³¨") private String remark; @Column(name = "POINTS_", length = 2000) @PropertyDef(label = "ééç¹ä¿¡æ¯", description = "ç¨éå·éå¼ç温度信æ¯ä¿¡æ¯") private String points; @Transient @PropertyDef(label = "æå±ååº", description = "ååºç¼ç ï¼éæ°æ®åºå段") private String deptId; } src/main/java/com/fzzy/async/fzzy40/entity/Fz40GrainKey.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,17 @@ package com.fzzy.async.fzzy40.entity; import lombok.AllArgsConstructor; import lombok.Data; import java.io.Serializable; @Data @AllArgsConstructor public class Fz40GrainKey implements Serializable { private String batchId; private String companyId; private String depotId; public Fz40GrainKey(){ super(); } } src/main/java/com/fzzy/async/fzzy40/entity/Fz40Pest.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,94 @@ package com.fzzy.async.fzzy40.entity; import com.bstek.dorado.annotation.PropertyDef; import lombok.Data; import javax.persistence.*; import java.io.Serializable; import java.util.Date; import java.util.List; /** * è«å®³ç»è®¡ * * @author: andy.jia * @description: * @version: * @data:2019å¹´12æ25æ¥ * */ @Data @Entity @Table(name = "D_PEST") @IdClass(Fz40PestKey.class) public class Fz40Pest implements Serializable { private static final long serialVersionUID = 1L; @Id @Column(name = "BATCH_ID_", length = 40) @PropertyDef(label = "æ¹æ¬¡ID") private String batchId; @Id @Column(name = "COMPANY_ID_", length = 10) @PropertyDef(label = "ç»ç»ç¼ç ", description = "") private String companyId; @Id @Column(name = "DEPOT_ID_", length = 50) @PropertyDef(label = "ä»åºID", description = "ä»åºç¼å·") private String depotId; @Column(name = "PEST_MAX_") @PropertyDef(label = "æå¤æ°é") private int pestMax = 0; @Column(name = "METHOD_", length = 10) @PropertyDef(label = "è«å®³æ£æµæ¹æ³", description = "0-ç²®å æ¦æ ·ï¼1-å¢é¢ç²®é¢æ£æ¥") private String method; @Column(name = "POSITION_", length =30) @PropertyDef(label = "åçé¨ä½") private String position; @Column(name = "PEST_TYPE_", length =30) @PropertyDef(label = "è«å®³ç§ç±»") private String pestType; @Column(name = "PEST_LEVEL_", length =30) @PropertyDef(label = "è«ç²®ç级å¤å®") private String pestLevel; @Column(name = "PEST_ANALYSIS_", length =60) @PropertyDef(label = "å®³è«æè¯æ§åæ") private String pestAnalysis; @Column(name = "PEST_START_") @PropertyDef(label = "è«å®³ééç¹å¼å§", description = "æ°ä½é 置信æ¯") private int pestStart; @Column(name = "PEST_END_") @PropertyDef(label = "è«å®³ééç¹æªè³", description = "æ°ä½é 置信æ¯") private int pestEnd; @Column(name = "CHECK_NUM_") @PropertyDef(label = "éééé个æ°") private int checkNum = 0; @Column(name = "RECEIVE_DATE_") @PropertyDef(label = "æ£æµæ¶é´") private Date receiveDate; @Column(name = "POINTS_", length = 2000) @PropertyDef(label = "ééç¹ä¿¡æ¯", description = "åºå®ä¸ºï¼passCode,num;passCode,num;") private String points; @Column(name = "CHECK_USER_", length = 30) @PropertyDef(label = "æ£æµäºº") private String checkUser; @Column(name = "REMARK_", length = 200) @PropertyDef(label = "夿³¨ä¿¡æ¯") private String remark; } src/main/java/com/fzzy/async/fzzy40/entity/Fz40PestKey.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,17 @@ package com.fzzy.async.fzzy40.entity; import lombok.AllArgsConstructor; import lombok.Data; import java.io.Serializable; @Data @AllArgsConstructor public class Fz40PestKey implements Serializable { private String batchId; private String companyId; private String depotId; public Fz40PestKey(){ super(); } } src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1302.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,246 @@ package com.fzzy.async.fzzy40.impl; import com.alibaba.fastjson.JSONObject; import com.bstek.dorado.util.DateUtils; import com.fzzy.api.Constant; import com.fzzy.api.entity.Api1105; import com.fzzy.api.entity.Api1302; import com.fzzy.api.entity.ApiLog; import com.fzzy.api.service.ApiCommonService; import com.fzzy.api.utils.ContextUtil; import com.fzzy.api.view.repository.Api1302Rep; import com.fzzy.api.view.repository.ApiLogRep; import com.fzzy.async.fzzy40.entity.Fz40Grain; import com.fzzy.async.fzzy40.repository.Fzzy40Sync1302Rep; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; import java.util.List; /** * æ¸©æ¹¿åº¦æ£æµæ°æ®åæ¥ * * @author chen * @date 2022-09-07 14:41 */ @Slf4j @Component public class Fzzy40Sync1302 { @Autowired private Fzzy40Sync1302Rep fzzySync1302Rep; @Autowired private ApiCommonService commonService; @Autowired private Api1302Rep api1302Rep; @Autowired private ApiLogRep apiLogRep; /** * 忥并å°è£ ä¿åæ¸©æ¹¿åº¦æ£æµæ°æ® * * @param deptId ç³»ç»å¯¹åºåºåºç¼ç * @param start èµ·å§æ¶é´ * @param end æªæ¢æ¶é´ */ public void syncData(String deptId, Date start, Date end) { log.info("-------------1302æ¥å£æ°æ®å¼å§åæ¥------------------"); //åæ¥æ°æ®ï¼åªè®°å½å¤±è´¥çä¿¡æ¯ ApiLog apiLog = new ApiLog(); apiLog.setType(ApiLog.TYPE_SYNC); apiLog.setKqdm(deptId); apiLog.setUploadTime(new Date()); apiLog.setInteId(Constant.API_CODE_1302); apiLog.setStatus(99); apiLog.setId(ContextUtil.getUUID()); try { List<Fz40Grain> list = fzzySync1302Rep.findByReceiveDate(start, end); log.info(DateUtils.format("yyyy-MM-dd HH:mm:ss",start)); log.info(DateUtils.format("yyyy-MM-dd HH:mm:ss",end)); if (null == list || list.isEmpty()) { log.info("1302---åæ¥æ°æ®ï¼æ²¡ææ¥è¯¢å°éè¦åæ¥çæ°æ®"); return; } log.info(JSONObject.toJSONString(list)); Date syncTime = new Date(); Api1302 api1302; Api1105 api1105; List<Api1302> api1302List; for (Fz40Grain fz40Grain : list) { //è·åè´§ä½ä¿¡æ¯ api1105 = commonService.getApi1105Cache(fz40Grain.getDepotId()); if (null == api1105) { continue; } //ç±è´§ä½ä»£ç +æ£æµæ¥æ ï¼yyyyMMddï¼ +4 ä½é¡ºåºå·ç»æ --2019 1128 0819 api1302 = new Api1302(); //api1302.setWsdjcdh(api1105.getHwdm() + DateFormatUtils.format(grain.getReceiveDate(), "yyyyMMdd") + String.valueOf(index).substring(1)); api1302.setWsdjcdh(api1105.getHwdm() + fz40Grain.getBatchId()); api1302.setJcsj(fz40Grain.getReceiveDate()); api1302.setHwdm(api1105.getHwdm()); api1302.setCfww(fz40Grain.getTempOut() == null ? 0.00: fz40Grain.getTempOut()); if(null == fz40Grain.getHumidityOut() || fz40Grain.getHumidityOut() < 0){ api1302.setCfws(-1); }else { api1302.setCfws(fz40Grain.getHumidityOut()); } api1302.setCfnw(fz40Grain.getTempIn() == null ? 0.00: fz40Grain.getTempIn()); if(null == fz40Grain.getHumidityIn() || fz40Grain.getHumidityIn() < 0){ api1302.setCfns(-1); }else { api1302.setCfns(fz40Grain.getHumidityIn()); } api1302.setLszgw(fz40Grain.getTempMax() == null ? 0.00: fz40Grain.getTempMax()); api1302.setLspjw(fz40Grain.getTempAve() == null ? 0.00: fz40Grain.getTempAve()); api1302.setLszdw(fz40Grain.getTempMin() == null ? 0.00: fz40Grain.getTempMin()); //温度éå if (StringUtils.isEmpty(fz40Grain.getCableCir())) { api1302.setLswdzjh(getTempPointList1(fz40Grain.getPoints(), fz40Grain.getCable())); api1302.setLssdzjh(getHumPointList1(fz40Grain.getPoints(), fz40Grain.getCable())); } else { api1302.setLswdzjh(getTempPointList2(fz40Grain.getPoints(), fz40Grain.getCable(), fz40Grain.getCableCir())); api1302.setLssdzjh(getHumPointList2(fz40Grain.getPoints(), fz40Grain.getCable(), fz40Grain.getCableCir())); } api1302.setZhgxsj(syncTime); api1302.setBizId(fz40Grain.getBatchId()); api1302.setKqdm(api1105.getKqdm()); api1302.setSyncTime(syncTime); api1302List = api1302Rep.getDataByWsdjcdh(api1302.getWsdjcdh()); if(null == api1302List || api1302List.isEmpty()){ api1302.setCzbz(Constant.CZBZ_I); }else { api1302.setCzbz(api1302List.get(0).getCzbz()); } log.info("1302---åæ¥æ°æ®ï¼" + api1302.toString()); api1302Rep.save(api1302); } } catch (Exception e) { log.error("---åæ¥å¤±è´¥----{}", e); apiLog.setResult("åæ¥å¤±è´¥ï¼" + e.getMessage()); apiLogRep.save(apiLog); } } /** * è·åå¹³æ¹ä»ç温度å¼éåï¼æ ¼å¼ï¼æ¸©åº¦å¼,屿°,è¡æ°,åæ°|温度å¼,屿°,è¡æ°,åæ°|温度å¼,屿°,è¡æ°,åæ° * * @return */ private String getTempPointList1(String point, String cable) { String[] cab = cable.split("-"); int c = Integer.valueOf(cab[0]); int h = Integer.valueOf(cab[1]); int l = Integer.valueOf(cab[2]); String[] points = point.split(","); String result = ""; for (int i = 1; i <= l; i++) { for (int j = 1; j <= h; j++) { for (int z = 1; z <= c; z++) { result += ("|" + points[(i * j - 1) * c + z - 1] + "," + z + "," + j + "," + i); } } } return result.substring(1); } /** * è·åçä»ç温度å¼éåï¼æ ¼å¼ï¼æ¸©åº¦å¼,åæ°,ç¹æ°,屿°|温度å¼,åæ°,ç¹æ°,屿°|温度å¼,åæ°,ç¹æ°,屿° * * @return */ private String getTempPointList2(String point, String cable, String cableCir) { String[] cab = cable.split("-"); String[] cabCir = cableCir.split("-"); int q = cab.length; //åæ° int c = Integer.valueOf(cabCir[0]); //屿° int g = 0; //åæ ¹æ° int g1 = 1; //åèµ·å§æ ¹æ° int g2 = 0; //åæªæ¢æ ¹æ° String[] points = point.split(","); String result = ""; for (int i = 1; i <= q; i++) { g1 += g2; g = Integer.valueOf(cab[i - 1]); g2 += g; for (int j = g1; j <= g2; j++) { for (int z = 1; z <= c; z++) { result += ("|" + points[(j - 1) * c + z - 1] + "," + i + "," + j + "," + z); } } } return result.substring(1); } /** * è·åå¹³æ¹ä»ç湿度å¼éåï¼æ ¼å¼ï¼æ¹¿åº¦,屿°,è¡æ°,åæ°|湿度,屿°,è¡æ°,åæ°|湿度,屿°,è¡æ°,åæ° * * @return */ private String getHumPointList1(String point, String cable) { String[] cab = cable.split("-"); int c = Integer.valueOf(cab[0]); int h = Integer.valueOf(cab[1]); int l = Integer.valueOf(cab[2]); // String[] points = point.split(","); String result = ""; for (int i = 1; i <= l; i++) { for (int j = 1; j <= h; j++) { for (int z = 1; z <= c; z++) { result += ("|" + "-1" + "," + z + "," + j + "," + i); } } } return result.substring(1); } /** * è·åçä»ç湿度å¼éåï¼æ ¼å¼ï¼æ¹¿åº¦,åæ°,ç¹æ°,屿°|湿度,åæ°,ç¹æ°,屿°|湿度,åæ°,ç¹æ°,屿° * * @return */ private String getHumPointList2(String point, String cable, String cableCir) { String[] cab = cable.split("-"); String[] cabCir = cableCir.split("-"); int q = cab.length; //åæ° int c = Integer.valueOf(cabCir[0]); //屿° int g = 0; //åæ ¹æ° int g1 = 1; //åèµ·å§æ ¹æ° int g2 = 0; //åæªæ¢æ ¹æ° // String[] points = point.split(","); String result = ""; for (int i = 1; i <= q; i++) { g1 += g2; g = Integer.valueOf(cab[i - 1]); g2 += g; for (int j = g1; j <= g2; j++) { for (int z = 1; z <= c; z++) { result += ("|" + "-1" + "," + i + "," + j + "," + z); } } } return result.substring(1); } } src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1303.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,152 @@ package com.fzzy.async.fzzy40.impl; import com.fzzy.api.Constant; import com.fzzy.api.entity.Api1105; import com.fzzy.api.entity.Api1303; import com.fzzy.api.entity.ApiLog; import com.fzzy.api.service.ApiCommonService; import com.fzzy.api.utils.ContextUtil; import com.fzzy.api.view.repository.Api1303Rep; import com.fzzy.api.view.repository.ApiLogRep; import com.fzzy.async.fzzy40.entity.Fz40Pest; import com.fzzy.async.fzzy40.repository.Fzzy40Sync1303Rep; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; import java.util.List; /** * è«å®³æ£æµæ°æ®åæ¥ * * @author chen * @date 2022-09-08 09:51 */ @Slf4j @Component public class Fzzy40Sync1303 { @Autowired private Fzzy40Sync1303Rep fzzy40Sync1303Rep; @Autowired private ApiCommonService commonService; @Autowired private Api1303Rep api1303Rep; @Autowired private ApiLogRep apiLogRep; /** * 忥并å°è£ ä¿åè«å®³æ£æµæ°æ® * * @param deptId ç³»ç»å¯¹åºåºåºç¼ç * @param start èµ·å§æ¶é´ * @param end æªæ¢æ¶é´ */ public void syncData(String deptId, Date start, Date end) { log.info("-------------1303æ¥å£æ°æ®å¼å§åæ¥------------------"); //åæ¥æ°æ®ï¼åªè®°å½å¤±è´¥çä¿¡æ¯ ApiLog apiLog = new ApiLog(); apiLog.setType(ApiLog.TYPE_SYNC); apiLog.setKqdm(deptId); apiLog.setUploadTime(new Date()); apiLog.setInteId(Constant.API_CODE_1303); apiLog.setStatus(99); apiLog.setId(ContextUtil.getUUID()); try { List<Fz40Pest> list = fzzy40Sync1303Rep.findPestByReceiveDate(start, end); if (null == list || list.isEmpty()) { return; } Date syncTime = new Date(); Api1303 api1303; Api1105 api1105; List<Api1303> api1303List; for (Fz40Pest fz40Pest : list) { //è·åè´§ä½ä¿¡æ¯ api1105 = commonService.getApi1105Cache(fz40Pest.getDepotId()); if (null == api1105) { continue; } api1303 = new Api1303(); api1303.setHcjcdh(api1105.getHwdm() + fz40Pest.getBatchId()); api1303.setJcsj(fz40Pest.getReceiveDate()); api1303.setHwdm(api1105.getHwdm()); //æ£æ¥å®³è«æ¹æ³ï¼0-è¿ç¨ã1-人工ã2-å ¶ä» api1303.setJchcff("0"); //åçé¨ä½ï¼åæ å¡«åï¼x,y,z api1303.setFsbw(null);//éå¿ å¡«åæ®µ //害è«ç§ç±»ãå¤ä¸ªç¨#éå¼#TODO >> å¾ ä¼åè°æ´ api1303.setHczl("21212"); //è«å£å¯åº¦å¼éå String ckmdzjh = this.geeCkmdzjh(fz40Pest.getPestMax(), fz40Pest.getPoints()); api1303.setCkmdzjh(ckmdzjh); //è«ç²®ç级å¤å®ï¼531-åºæ¬æ è«ç²®ã532-ä¸è¬è«ç²®ã533严éè«ç²®ã534å±å®³è«ç²® api1303.setCldjpd("531"); if (fz40Pest.getPestMax() > 5) { api1303.setCldjpd("532"); } if (fz40Pest.getPestMax() > 30) { api1303.setCldjpd("533"); } api1303.setZhgxsj(syncTime); api1303.setBizId(fz40Pest.getBatchId()); api1303.setKqdm(api1105.getKqdm()); api1303.setSyncTime(syncTime); api1303List = api1303Rep.getDataByHcjcdh(api1303.getHcjcdh()); if(null == api1303List || api1303List.isEmpty()){ api1303.setCzbz(Constant.CZBZ_I); }else { api1303.setCzbz(api1303List.get(0).getCzbz()); } api1303Rep.save(api1303); } } catch (Exception e) { log.error("---åæ¥å¤±è´¥----{}", e); apiLog.setResult("åæ¥å¤±è´¥ï¼" + e.getMessage()); apiLogRep.save(apiLog); } } /** * 头/kgï¼æç²®é£å®³è«å¼éåï¼ä¸ * 害è«ç§ç±»é¡ºåºå¯¹åºï¼ç¨â|âå * éï¼å¤ä¸ªåæ ·ç¹ç¨è±æåè§âï¼â * åéï¼æç §åæ ·ç¹ç¤ºæå¾æ è¯é¡º * åºæåã * * @param pestMax * @param points * @return */ private String geeCkmdzjh(int pestMax, String points) { if (StringUtils.isEmpty(points)) return "0"; String[] attr = points.split(";"); String result = ""; for (String str : attr) { result += str.split(",")[1] + ","; } return result.substring(0, result.length() - 1); } } src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1304.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,126 @@ package com.fzzy.async.fzzy40.impl; import com.fzzy.api.Constant; import com.fzzy.api.entity.Api1105; import com.fzzy.api.entity.Api1304; import com.fzzy.api.entity.ApiLog; import com.fzzy.api.service.ApiCommonService; import com.fzzy.api.utils.ContextUtil; import com.fzzy.api.view.repository.Api1304Rep; import com.fzzy.api.view.repository.ApiLogRep; import com.fzzy.async.fzzy40.entity.Fz40Gas; import com.fzzy.async.fzzy40.repository.Fzzy40Sync1304Rep; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Date; import java.util.List; /** * è«å®³æ£æµæ°æ®åæ¥ * * @author chen * @date 2022-09-08 09:51 */ @Slf4j @Component public class Fzzy40Sync1304 { @Autowired private Fzzy40Sync1304Rep fzzySync1304Rep; @Autowired private ApiCommonService commonService; @Autowired private Api1304Rep api1304Rep; @Autowired private ApiLogRep apiLogRep; /** * 忥并å°è£ ä¿åæ°ä½æ£æµæ°æ® * * @param deptId ç³»ç»å¯¹åºåºåºç¼ç * @param start èµ·å§æ¶é´ * @param end æªæ¢æ¶é´ */ public void syncData(String deptId, Date start, Date end) { log.info("-------------1304æ¥å£æ°æ®å¼å§åæ¥------------------"); //åæ¥æ°æ®ï¼åªè®°å½å¤±è´¥çä¿¡æ¯ ApiLog apiLog = new ApiLog(); apiLog.setType(ApiLog.TYPE_SYNC); apiLog.setKqdm(deptId); apiLog.setUploadTime(new Date()); apiLog.setInteId(Constant.API_CODE_1304); apiLog.setStatus(99); apiLog.setId(ContextUtil.getUUID()); try { List<Fz40Gas> list = fzzySync1304Rep.findByReceiveDate(start, end); if (null == list || list.isEmpty()) { return; } Date syncTime = new Date(); Api1304 api1304; Api1105 api1105; List<Api1304> api1304List; for (Fz40Gas fz40Gas : list) { //è·åè´§ä½ä¿¡æ¯ api1105 = commonService.getApi1105Cache(fz40Gas.getDepotId()); if (null == api1105) { continue; } api1304 = new Api1304(); // api1304.setQtndjcdh(api1105.getHwdm() + DateFormatUtils.format(gas.getReceiveDate(), "yyyyMMdd") + String.valueOf(index).substring(1)); api1304.setQtndjcdh(api1105.getHwdm() + fz40Gas.getBatchId()); api1304.setJcsj(fz40Gas.getReceiveDate()); api1304.setHwdm(api1105.getHwdm()); api1304 = updateGasInfo(api1304, fz40Gas.getPoints()); api1304.setZhgxsj(syncTime); api1304.setBizId(fz40Gas.getBatchId()); api1304.setKqdm(api1105.getKqdm()); api1304.setSyncTime(syncTime); api1304List = api1304Rep.getDataByQtndjcdh(api1304.getQtndjcdh()); if(null == api1304List || api1304List.isEmpty()){ api1304.setCzbz(Constant.CZBZ_I); }else { api1304.setCzbz(api1304List.get(0).getCzbz()); } api1304Rep.save(api1304); } } catch (Exception e) { log.error("---åæ¥å¤±è´¥----{}", e); apiLog.setResult("åæ¥å¤±è´¥ï¼" + e.getMessage()); apiLogRep.save(apiLog); } } /** * è·åå¯¹åºæ°ä½æµåº¦éåï¼passCode,co2,o2,ph3,n2;passCode,co2,o2,ph3,n2; * * @param points * @return */ private Api1304 updateGasInfo(Api1304 api1304, String points) { String[] attr = points.split(";"); String[] arrt2; String o2 = "", co2 = "", ph3 = ""; for (String temp : attr) { arrt2 = temp.split(","); o2 += arrt2[2] + ","; co2 += arrt2[1] + ","; ph3 += arrt2[3] + ","; } api1304.setYqhlzjh(o2); api1304.setEyhthlzjh(co2); api1304.setLhqndzjh(ph3); return api1304; } } src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1302Rep.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,28 @@ package com.fzzy.async.fzzy40.repository; import com.fzzy.async.fzzy35.entity.Fz35Grain; import com.fzzy.async.fzzy40.entity.Fz40Grain; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.util.Date; import java.util.List; /** * æ¥è¯¢ç²®æ æ£æµæ°æ® * * @author chen * @date 2022-09-07 14:35 */ public interface Fzzy40Sync1302Rep extends JpaRepository<Fz40Grain, String> { /** * æ ¹æ®æ¶é´æ®µæ¥è¯¢ç²®æ æ°æ® * @param start * @param end * @return */ @Query("from Fz40Grain where receiveDate >=:start and receiveDate <:end order by receiveDate ") List<Fz40Grain> findByReceiveDate(@Param("start") Date start, @Param("end") Date end); } src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1303Rep.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,28 @@ package com.fzzy.async.fzzy40.repository; import com.fzzy.async.fzzy40.entity.Fz40Pest; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.util.Date; import java.util.List; /** * æ¥è¯¢è«å®³æ£æµæ°æ® * * @author chen * @date 2022-09-08 09:51 */ public interface Fzzy40Sync1303Rep extends JpaRepository<Fz40Pest, String> { /** * æ ¹æ®æ¶é´æ®µæ¥è¯¢ç²®æ æ°æ® * * @param start * @param end * @return */ @Query("from Fz40Pest where receiveDate >=:start and receiveDate <:end order by receiveDate ") List<Fz40Pest> findPestByReceiveDate(@Param("start") Date start, @Param("end") Date end); } src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1304Rep.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,27 @@ package com.fzzy.async.fzzy40.repository; import com.fzzy.async.fzzy40.entity.Fz40Gas; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; import java.util.Date; import java.util.List; /** * æ¥è¯¢æ°ä½æ£æµæ°æ® * * @author chen * @date 2022-09-08 10:42 */ public interface Fzzy40Sync1304Rep extends JpaRepository<Fz40Gas, String> { /** * æ ¹æ®æ¶é´æ®µæ¥è¯¢ç²®æ æ°æ® * @param start * @param end * @return */ @Query("from Fz40Gas where receiveDate >=:start and receiveDate <:end order by receiveDate ") List<Fz40Gas> findByReceiveDate(@Param("start") Date start, @Param("end") Date end); }