From f0eeec1f6db4cfc0f9e3f2de5c765d06d5831201 Mon Sep 17 00:00:00 2001
From: 18516761980 <tqsxp@163.com>
Date: 星期六, 04 二月 2023 11:41:50 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/ints/task/scheduler/ErpDetTbScheduler.java |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/main/java/com/zy/ints/task/scheduler/ErpDetTbScheduler.java b/src/main/java/com/zy/ints/task/scheduler/ErpDetTbScheduler.java
index 7fca83c..735cad3 100644
--- a/src/main/java/com/zy/ints/task/scheduler/ErpDetTbScheduler.java
+++ b/src/main/java/com/zy/ints/task/scheduler/ErpDetTbScheduler.java
@@ -59,7 +59,7 @@
     @Scheduled(cron = "${erp.refreshtime}")
     public void InOrOutOrder() {
         if (!erpEnabledErpDetTb) return;
-        String sqlSelectErpDetTb = "select BIL_NO as billNo,prd_no as prdNo,ITM as itm,ADD_ID as addId2,QTY as qty,PRD_MARK as prdMark,WH as wh,BIL_DATE as billdate,STATUS as status,Temp1 as temp1,Temp2 as temp2,Temp3 as temp3 from ERP_DETTB where 1=1";
+        String sqlSelectErpDetTb = "select BIL_NO as billNo,prd_no as prdNo,ITM as itm,ADD_ID as addId2,QTY as qty,PRD_MARK as prdMark,WH as wh,STATUS as status,Temp1 as temp1,Temp2 as temp2,Temp3 as temp3 from ERP_DETTB where 1=1";
         String sqlUpDateErpDetTbOne = "update ERP_DETTB set STATUS=1 where 1=1 and PRD_NO=";
         String sqlUpDateErpDetTbTwo = "update ERP_DETTB set STATUS=2 ";
 
@@ -72,8 +72,13 @@
                     if (status == 0) {
                         Mat mat = matService.selectByMatnr(erpDetTb.getPrdNo());
                         if (Cools.isEmpty(mat)) {
-                            erpSqlServer.update(sqlUpDateErpDetTbTwo + ",Temp1='鍝佸彿淇℃伅鍦ㄧ珛搴撲笉瀛樺湪锛岃鍏堟坊鍔犲晢鍝侊紒锛侊紒'" + "where 1=1 and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'");
-                            callApiLogSave(erpDetTb, "ERP_DETTB", "鍝佸彿淇℃伅鍦ㄧ珛搴撲笉瀛樺湪锛岃鍏堟坊鍔犲晢鍝侊紒锛侊紒", false);
+                            if(Cools.isEmpty(erpDetTb.getTemp1())){
+                                erpSqlServer.update(sqlUpDateErpDetTbTwo + ",Temp1='鍝佸彿淇℃伅鍦ㄧ珛搴撲笉瀛樺湪锛岃鍏堟坊鍔犲晢鍝侊紒锛侊紒'" + "where 1=1 "
+                                        +" and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'"
+                                        +" and ITM=" + "'" + erpDetTb.getItm() + "'"
+                                        +" and BIL_NO=" + "'" + erpDetTb.getBillNo() + "'");
+                                callApiLogSave(erpDetTb, "ERP_DETTB", "鍝佸彿淇℃伅鍦ㄧ珛搴撲笉瀛樺湪锛岃鍏堟坊鍔犲晢鍝侊紒锛侊紒", false);
+                            }
                         } else {
                             Order order = orderService.selectByNo(erpDetTb.getBillNo());
                             if (Cools.isEmpty(order)) {
@@ -113,8 +118,8 @@
                                         now,    // 淇敼鏃堕棿
                                         null    // 澶囨敞
                                 );
-                                String InAndOut = erpDetTb.getAddId2()==2 ? "锛堝嚭搴擄級" : "锛堝叆搴擄級";
-                                DocType docType = docTypeService.selectOrAdd("ERP璁㈠崟"+InAndOut, erpDetTb.getAddId2()==1);
+                                String InAndOut = erpDetTb.getAddId2().equals(2) ? "锛堝嚭搴擄級" : "锛堝叆搴擄級";
+                                DocType docType = docTypeService.selectOrAdd("ERP璁㈠崟"+InAndOut, erpDetTb.getAddId2().equals(1));
                                 if (!Cools.isEmpty(docType)) {
                                     order.setDocType(docType.getDocId());
                                     if (!orderService.insert(order)) {
@@ -150,8 +155,13 @@
                                         erpSqlServer.update(sqlUpDateErpDetTbOne + "'" + erpDetTb.getPrdNo() + "'");
                                         callApiLogSave(erpDetTb, "ERP_DETTB", "鎺ユ敹ERP涓嬪彂璁㈠崟鎺ユ敹鎴愬姛锛侊紒", true);
                                     } else {
-                                        erpSqlServer.update(sqlUpDateErpDetTbTwo + ",temp1='娣诲姞璁㈠崟鏄庣粏妗eけ璐ワ紒锛侊紒'" + "where 1=1 and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'");
-                                        callApiLogSave(erpDetTb, "ERP_DETTB", "ERP涓嬪彂璁㈠崟鎺ユ敹澶辫触锛侊紒", false);
+                                        if (Cools.isEmpty(erpDetTb.getTemp2())){
+                                            erpSqlServer.update(sqlUpDateErpDetTbTwo + ",temp2='娣诲姞璁㈠崟鏄庣粏妗eけ璐ワ紒锛侊紒'" + "where 1=1 "
+                                                    +" and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'"
+                                                    +" and ITM=" + "'" + erpDetTb.getItm() + "'"
+                                                    +" and BIL_NO=" + "'" + erpDetTb.getBillNo() + "'");
+                                            callApiLogSave(erpDetTb, "ERP_DETTB", "ERP涓嬪彂璁㈠崟鎺ユ敹澶辫触锛侊紒", false);
+                                        }
                                     }
                                 }
                             }
@@ -185,7 +195,13 @@
 //                        callApiLogSave(erpDetTb, "ERP_DETTB", "ERP涓嬪彂璁㈠崟澶囦唤鍚庡垹闄ゆ垚鍔燂紒锛�", true);
 
                     } else {
-                        callApiLogSave(erpDetTb, "ERP_DETTB", "鎺ユ敹ERP涓嬪彂璁㈠崟澶辫触锛侊紒锛佺姸鎬佸紓甯革紒锛侊紒", false);
+                        if (Cools.isEmpty(erpDetTb.getTemp1()) && Cools.isEmpty(erpDetTb.getTemp2()) && Cools.isEmpty(erpDetTb.getTemp3())){
+                            erpSqlServer.update(sqlUpDateErpDetTbTwo + ",Temp1='鎺ユ敹ERP涓嬪彂璁㈠崟澶辫触锛侊紒锛佺姸鎬佸紓甯革紒锛侊紒璇稥RP銆佺珛搴撳弻鏂瑰崗鍔╄В鍐炽��'" + "where 1=1 "
+                                    +" and PRD_NO=" + "'" + erpDetTb.getPrdNo() + "'"
+                                    +" and ITM=" + "'" + erpDetTb.getItm() + "'"
+                                    +" and BIL_NO=" + "'" + erpDetTb.getBillNo() + "'");
+                            callApiLogSave(erpDetTb, "ERP_DETTB", "鎺ユ敹ERP涓嬪彂璁㈠崟澶辫触锛侊紒锛佺姸鎬佸紓甯革紒锛侊紒", false);
+                        }
                     }
                 }
             }

--
Gitblit v1.9.1