From 8eae44e262f427fec2f82db0aca819b0494ae3ef Mon Sep 17 00:00:00 2001
From: WS <1143478319@qq.com>
Date: 星期四, 17 八月 2023 10:06:56 +0800
Subject: [PATCH] 提交质检信息同步

---
 src/main/java/com/fzzy/async/fzzy40/entity/Fz40Quality.java           |  149 ++++++++++++++++++++++++
 src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java          |   12 +
 src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1310Rep.java |   27 ++++
 src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java          |  153 +++++++++++++++++++++++++
 4 files changed, 337 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java
index 14f97a4..bb1a3c3 100644
--- a/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java
+++ b/src/main/java/com/fzzy/async/fzzy40/Fzzy40SyncService13.java
@@ -6,6 +6,7 @@
 import com.fzzy.async.fzzy40.impl.Fzzy40Sync1302;
 import com.fzzy.async.fzzy40.impl.Fzzy40Sync1303;
 import com.fzzy.async.fzzy40.impl.Fzzy40Sync1304;
+import com.fzzy.async.fzzy40.impl.Fzzy40Sync1310;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -25,6 +26,8 @@
     private Fzzy40Sync1303 fzzySync1303;
     @Autowired
     private Fzzy40Sync1304 fzzySync1304;
+    @Autowired
+    private Fzzy40Sync1310 fzzySync1310;
 
     @Override
     public String getProtocol() {
@@ -34,16 +37,17 @@
     @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
+        //璐ㄦ鍚屾
+        fzzySync1310.syncData(param.getKqdm(), param.getDeptId(), param.getStart(), param.getEnd());
 
         //閫氶浣滀笟淇℃伅鍚屾  TODO
 
diff --git a/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Quality.java b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Quality.java
new file mode 100644
index 0000000..679f70b
--- /dev/null
+++ b/src/main/java/com/fzzy/async/fzzy40/entity/Fz40Quality.java
@@ -0,0 +1,149 @@
+package com.fzzy.async.fzzy40.entity;
+
+import com.alibaba.fastjson.annotation.JSONField;
+import com.bstek.dorado.annotation.PropertyDef;
+import lombok.Data;
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * 璐ㄩ噺绠$悊锛�2023骞�5鏈�26鏃� 鏍规嵁鏂板浗绮浼樺寲璋冩暣
+ *
+ * @author chen
+ */
+@Data
+@Entity
+@Table(name = "D_M_QUALITY")
+public class Fz40Quality implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @Id
+    @Column(name = "ID_", length = 40)
+    @PropertyDef(label = "涓婚敭ID", description = "ZJ+妫�楠岀被鍒�+骞存湀鏃ユ椂鍒嗙")
+    private String id;
+
+    @Column(name = "COMPANY_ID_", length = 10)
+    @PropertyDef(label = "缁勭粐缂栫爜")
+    private String companyId;
+
+    @Column(name = "DEPT_ID_", length = 40)
+    @PropertyDef(label = "搴撳尯缂栫爜")
+    private String deptId;
+
+    @Column(name = "DEPOT_ID_", length = 50)
+    @PropertyDef(label = "浠撳簱缂栫爜")
+    private String depotId;
+
+    @Column(name = "FOOD_VARIETY_", length = 10)
+    @PropertyDef(label = "绮鍝佺")
+    private String foodVariety;
+
+    @Column(name = "FOOD_LEVEL_", length = 10)
+    @PropertyDef(label = "绮绛夌骇")
+    private String foodLevel;
+
+    @PropertyDef(label = "鍏ュ簱鏃ユ湡")
+    @Column(name = "STORE_DATE_")
+    private Date storeDate;
+
+    @Column(name = "TYPE_", length = 10)
+    @PropertyDef(label = "妫�楠岀被鍒�", description = "01锛氬叆浠撻獙鏀� 02锛氬嚭浠撴楠� 03锛�3 鏈堟湯鏅04锛�9 鏈堟湯鏅 05锛氬叆浠撳垵妫� 06锛氭湀搴︽鏌� 07锛�3 鏈堟湯搴撳唴鏅煡 08锛�9 鏈堟湯搴撳唴鏅煡")
+    private String type;
+
+    @Column(name = "TIME_")
+    @PropertyDef(label = "妫�楠屾椂闂�")
+    private Date time;
+
+    @Column(name = "USER_", length = 50)
+    @PropertyDef(label = "妫�楠屼汉", description = "妫�楠屼汉鍛樺鍚嶏紝鑻ユ湁澶氫釜淇濈鍛�")
+    private String user;
+
+    @Column(name = "UNIT_", length = 50)
+    @PropertyDef(label = "妫�楠屽崟浣�")
+    private String unit;
+
+    @Column(name = "STANDARD_", length = 4)
+    @PropertyDef(label = "妫�楠屼緷鎹�", description = "1-鍥芥爣锛�0-鍏朵粬")
+    private String standard;
+
+
+    @PropertyDef(label = "鎸囨爣绫诲埆", description = "1: 璐ㄩ噺鎸囨爣妫�楠�2锛氬偍瀛樺搧璐ㄦ楠�3锛氶鍝佸畨鍏ㄦ楠� 濡傛灉鍚屾椂妫�楠屼簡澶氫釜锛岀敤#闅斿紑锛屼緥濡傦細1#2#3")
+    @Column(name = "zblb", length = 8)
+    private String zblb;
+
+    @Column(name = "RESULT_", length = 40)
+    @PropertyDef(label = "妫�楠岀粨璁�", description = "1銆佽川閲忔寚鏍囧~鍐�/杈炬爣/涓嶈揪鏍� 2銆佸偍瀛樺搧璐ㄦ寚鏍囧~鍐欌�滃疁瀛樷�濄�佽交搴︿笉瀹滃瓨鈥濄�佲�滈噸搴︿笉瀹滃瓨鈥�3銆侀鍝佸畨鍏ㄦ寚鏍囧~鍐欌�滃悎鏍尖�濄�佷笉鍚堟牸鈥� 澶氶」鎸囨爣鏃朵互#鍒嗛殧锛屼緥濡傦細杈炬爣|缁煎悎鍒ゅ畾#瀹滃瓨#鍚堟牸 ")
+    private String result;
+
+    @JSONField(format = "yyyy-MM-dd")
+    @PropertyDef(label = "绛惧彂鏃ユ湡")
+    @Column(name = "qfrq")
+    private Date qfrq;
+
+    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
+    @PropertyDef(label = "鎶ュ憡鍑哄叿鏃堕棿")
+    @Column(name = "bgcjsj")
+    private Date bgcjsj;
+
+    @PropertyDef(label = "瀹℃牳浜哄鍚�")
+    @Column(name = "shrxm", length = 64)
+    private String shrxm;
+
+    @PropertyDef(label = "鎵︽牱鍗曠紪鍙�")
+    @Column(name = "qydbh", length = 64)
+    private String qydbh;
+
+    @Column(name = "CHECK_TIME_")
+    @PropertyDef(label = "鎵︽牱鏃堕棿", required = true)
+    private Date checkTime;
+
+    @Column(name = "CHECK_AREA_", length = 50)
+    @PropertyDef(label = "鎵︽牱鍖哄煙")
+    private String checkArea;
+
+    @Column(name = "CHECK_USER_", length = 50)
+    @PropertyDef(label = "鎵︽牱浜�", required = true)
+    private String checkUser;
+
+    @PropertyDef(label = "鐩戠潱浜哄鍚�")
+    @Column(name = "jdrxm", length = 64)
+    private String jdrxm;
+
+    @PropertyDef(label = "鏍峰搧缂栧彿")
+    @Column(name = "ypbh", length = 64)
+    private String ypbh;
+
+    @PropertyDef(label = "鏍峰搧鏁伴噺", required = true)
+    @Column(name = "ypsl", precision = 20, scale = 6)
+    private double ypsl;
+
+    @PropertyDef(label = "浠h〃鏁伴噺")
+    @Column(name = "dbsl", precision = 20, scale = 6)
+    private double dbsl;
+
+    @PropertyDef(label = "鏍峰搧绛夌骇")
+    @Column(name = "ypdj", length = 2)
+    private String ypdj;
+
+    @Column(name = "NORMAL_YEAR_", length = 10)
+    @PropertyDef(label = "鏄惁姝e父瀛樺偍骞撮檺")
+    private String normalYear;
+
+    @Column(name = "REMARK_", length = 200)
+    @PropertyDef(label = "澶囨敞", description = "澶囨敞淇℃伅")
+    private String remark;
+
+    @Column(name = "UPDATE_TIME_")
+    @PropertyDef(label = "鏁版嵁鏇存柊鏃堕棿")
+    private Date updateTime;
+//
+//    /**
+//     * 鍖栭獙椤圭洰鏄庣粏
+//     */
+//    @Transient
+//    private List<CheckItemData> checkItems;
+
+}
diff --git a/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java
new file mode 100644
index 0000000..0478e46
--- /dev/null
+++ b/src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1310.java
@@ -0,0 +1,153 @@
+package com.fzzy.async.fzzy40.impl;
+
+import com.fzzy.api.Constant;
+import com.fzzy.api.entity.Api1105;
+import com.fzzy.api.entity.Api1310;
+import com.fzzy.api.entity.ApiLog;
+import com.fzzy.api.entity.GbCheckItem;
+import com.fzzy.api.service.ApiCommonService;
+import com.fzzy.api.utils.ContextUtil;
+import com.fzzy.api.view.repository.Api1310Rep;
+import com.fzzy.api.view.repository.ApiLogRep;
+import com.fzzy.api.view.repository.GbCheckItemRep;
+import com.fzzy.async.fzzy40.entity.Fz40CheckItem;
+import com.fzzy.async.fzzy40.entity.Fz40Quality;
+import com.fzzy.async.fzzy40.repository.Fzzy40Sync1203Rep;
+import com.fzzy.async.fzzy40.repository.Fzzy40Sync1310Rep;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.time.DateFormatUtils;
+import org.apache.commons.lang.time.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 璐ㄦ鍚屾
+ *
+ * @author czt
+ * @date 2023-05-14 19:51
+ */
+@Slf4j
+@Component
+public class Fzzy40Sync1310 {
+
+    @Autowired
+    private Fzzy40Sync1310Rep fzzySync1310Rep;
+    @Autowired
+    private Fzzy40Sync1203Rep fzzySync1203Rep;
+    @Autowired
+    private GbCheckItemRep gbCheckItemRep;
+    @Autowired
+    private ApiCommonService commonService;
+    @Autowired
+    private Api1310Rep api1310Rep;
+    @Autowired
+    private ApiLogRep apiLogRep;
+
+    /**
+     * 鍚屾骞跺皝瑁呬繚瀛樿川妫�鏁版嵁
+     *
+     * @param deptId 绯荤粺瀵瑰簲搴撳尯缂栫爜
+     * @param start  璧峰鏃堕棿
+     * @param end    鎴鏃堕棿
+     */
+    public void syncData(String kqdm, String deptId, Date start, Date end) {
+        log.info("-------------1310鎺ュ彛鏁版嵁寮�濮嬪悓姝�------------------");
+        //鍚屾鏁版嵁锛屽彧璁板綍澶辫触鐨勪俊鎭�
+        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<Fz40Quality> list = fzzySync1310Rep.findDateByTime(start, end);
+            if (null == list || list.isEmpty()) {
+                return;
+            }
+
+            Api1310 api1310;
+            Api1105 api1105;
+            List<Fz40CheckItem> fz40CheckItems;
+            List<GbCheckItem> gbCheckList;
+            StringBuilder jyxm;
+            StringBuilder jyxmz;
+            List<Api1310> api1310List;
+            int index = 10001;
+            for (Fz40Quality fz40Quality : list) {
+                api1105 = commonService.getApi1105Cache(fz40Quality.getDepotId());
+                if (null == api1105) {
+                    continue;
+                }
+                api1310 = new Api1310();
+                api1310.setZjbgdh(fz40Quality.getType() + DateFormatUtils.format(fz40Quality.getTime(), "yyyyMMdd") + String.valueOf(index).substring(1));
+                api1310.setHwdm(api1105.getHwdm());
+                api1310.setKqdm(kqdm);
+                api1310.setLspzdm(fz40Quality.getFoodVariety());
+                api1310.setLsdjdm(fz40Quality.getFoodLevel());
+                api1310.setRkrq(DateUtils.addDays(fz40Quality.getTime(), -30));
+                api1310.setJylb(fz40Quality.getType());
+                api1310.setJysj(fz40Quality.getTime());
+                api1310.setJydw(fz40Quality.getUser());
+                api1310.setJyr(fz40Quality.getUser());
+                api1310.setJyyj(fz40Quality.getStandard());
+                api1310.setZblb("2");
+                //妫�娴嬮」锛屾娴嬪��
+                jyxm = new StringBuilder();
+                jyxmz = new StringBuilder();
+                fz40CheckItems = fzzySync1203Rep.listInoutCheckItem(fz40Quality.getId(), deptId.substring(0, 4));
+                if (null != fz40CheckItems && fz40CheckItems.size() > 0) {
+
+                    for (Fz40CheckItem fz40CheckItem : fz40CheckItems) {
+                        if(StringUtils.isEmpty(fz40CheckItem.getValue())){
+                            continue;
+                        }
+                        gbCheckList = gbCheckItemRep.findByBizCode(fz40CheckItem.getStandardId());
+                        if (gbCheckList == null || gbCheckList.isEmpty()) {
+                            continue;
+                        }
+                        jyxm.append(",").append(gbCheckList.get(0).getCode());
+                        jyxmz.append(",").append(fz40CheckItem.getValue());
+                    }
+                }
+                api1310.setJyxm(jyxm.toString().substring(1));
+                api1310.setJyxmz(jyxmz.toString().substring(1));
+
+                api1310.setZbjgpd(fz40Quality.getResult());
+                api1310.setQfrq(fz40Quality.getTime());
+                api1310.setBgcjsj(fz40Quality.getTime());
+                api1310.setShrxm(fz40Quality.getCheckUser());
+                api1310.setQysj(fz40Quality.getCheckTime());
+                api1310.setQyqy(fz40Quality.getCheckArea());
+                api1310.setQyrxm(fz40Quality.getCheckUser());
+                api1310.setJdrxm(fz40Quality.getCheckUser());
+
+                api1310.setYpsl(fz40Quality.getYpsl());
+                api1310.setDbsl(fz40Quality.getDbsl());
+                api1310.setYpdj(StringUtils.isEmpty(fz40Quality.getYpdj())?"0": fz40Quality.getYpdj());
+                api1310.setSfzcccnx(StringUtils.isEmpty(fz40Quality.getNormalYear())?"0": fz40Quality.getNormalYear());
+                api1310.setBz(fz40Quality.getRemark());
+                api1310.setZhgxsj(new Date());
+
+                api1310List = api1310Rep.getDataByZjbgdh(api1310.getZjbgdh());
+                if(null == api1310List || api1310List.isEmpty()){
+                    api1310.setCzbz(Constant.CZBZ_I);
+                }else {
+                    api1310.setCzbz(api1310List.get(0).getCzbz());
+                }
+
+                api1310Rep.save(api1310);
+                index ++;
+            }
+        } catch (Exception e) {
+            log.error("---鍚屾澶辫触----{}", e);
+            apiLog.setResult("鍚屾澶辫触锛�" + e.getMessage());
+            apiLogRep.save(apiLog);
+        }
+    }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1310Rep.java b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1310Rep.java
new file mode 100644
index 0000000..b18067c
--- /dev/null
+++ b/src/main/java/com/fzzy/async/fzzy40/repository/Fzzy40Sync1310Rep.java
@@ -0,0 +1,27 @@
+package com.fzzy.async.fzzy40.repository;
+
+import com.fzzy.async.fzzy40.entity.Fz40Quality;
+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 2023-05-14 19:55
+ */
+public interface Fzzy40Sync1310Rep extends JpaRepository<Fz40Quality, String> {
+
+    /**
+     * 鏍规嵁鏃堕棿娈垫煡璇㈢伯鎯呮暟鎹�
+     * @param start
+     * @param end
+     * @return
+     */
+    @Query("from Fz40Quality where time >=:start and time <:end order by time ")
+    List<Fz40Quality> findDateByTime(@Param("start") Date start, @Param("end") Date end);
+}

--
Gitblit v1.9.3