From c110b50500f6446c7471fd4e413c563067381de9 Mon Sep 17 00:00:00 2001 From: WS <1143478319@qq.com> Date: 星期一, 14 八月 2023 19:49:15 +0800 Subject: [PATCH] V4.0版本温湿度 虫情 气体数据同步 --- src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService11.java | 2 src/main/java/com/fzzy/async/fzzy40/entity/Fz40Grain.java | 107 ++++++ src/main/java/com/fzzy/async/fzzy40/entity/Fz40GasKey.java | 17 + src/main/java/com/fzzy/async/fzzy40/entity/Fz40GrainKey.java | 17 + src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1303.java | 152 ++++++++ src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1302.java | 246 ++++++++++++++ src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1303Rep.java | 28 + src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1302Rep.java | 28 + src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java | 18 src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1304Rep.java | 27 + src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1304.java | 126 +++++++ src/main/java/com/fzzy/async/fzzy40/entity/Fz40PestKey.java | 17 + src/main/java/com/fzzy/async/fzzy40/entity/Fz40Gas.java | 117 ++++++ src/main/java/com/fzzy/async/fzzy40/entity/Fz40Pest.java | 94 +++++ 14 files changed, 991 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService11.java b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService11.java index e82fd5f..dc127ad 100644 --- a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService11.java +++ b/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 diff --git a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java index 09f259f..14f97a4 100644 --- a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java +++ b/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 diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Gas.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Gas.java new file mode 100644 index 0000000..18b0740 --- /dev/null +++ b/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; + +} diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40GasKey.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40GasKey.java new file mode 100644 index 0000000..5ab0998 --- /dev/null +++ b/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(); + } + } \ No newline at end of file diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Grain.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Grain.java new file mode 100644 index 0000000..9a366f3 --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40GrainKey.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40GrainKey.java new file mode 100644 index 0000000..b6e9f7d --- /dev/null +++ b/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(); + } + } \ No newline at end of file diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Pest.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Pest.java new file mode 100644 index 0000000..a49819d --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40PestKey.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40PestKey.java new file mode 100644 index 0000000..33337f9 --- /dev/null +++ b/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(); + } + } \ No newline at end of file diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1302.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1302.java new file mode 100644 index 0000000..b2ddf0b --- /dev/null +++ b/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; + } + + //鐢辫揣浣嶄唬鐮�+妫�娴嬫棩鏈� 锛坹yyyMMdd锛� +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); + } +} diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1303.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1303.java new file mode 100644 index 0000000..aa87fd4 --- /dev/null +++ b/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); + } + + +} diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1304.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1304.java new file mode 100644 index 0000000..d947cf5 --- /dev/null +++ b/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); + } + } + + /** + * 鑾峰彇瀵瑰簲姘斾綋娴撳害闆嗗悎锛歱assCode,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; + } + +} diff --git a/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1302Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1302Rep.java new file mode 100644 index 0000000..7508ff8 --- /dev/null +++ b/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); +} diff --git a/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1303Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1303Rep.java new file mode 100644 index 0000000..3d33ba0 --- /dev/null +++ b/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); +} diff --git a/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1304Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1304Rep.java new file mode 100644 index 0000000..805968c --- /dev/null +++ b/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); +} -- Gitblit v1.9.3