From 98610c8e9101b11678e6bc06bef2abfc45f5dc4c Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期五, 24 九月 2021 10:36:21 +0800
Subject: [PATCH] 1

---
 src/main/java/com/zy/common/service/erp/ErpService.java |   77 +++++++++++++++++++++++++++++---------
 1 files changed, 59 insertions(+), 18 deletions(-)

diff --git a/src/main/java/com/zy/common/service/erp/ErpService.java b/src/main/java/com/zy/common/service/erp/ErpService.java
index c55382d..142d9d0 100644
--- a/src/main/java/com/zy/common/service/erp/ErpService.java
+++ b/src/main/java/com/zy/common/service/erp/ErpService.java
@@ -12,6 +12,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -112,6 +113,7 @@
                 "and isb.FBillNo= ''{2}''";
         sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
         if (erpSqlServer.update(sql) > 0) {
+//            log.error("鏇存柊ERP涓棿琛ㄦ垚鍔�===>>[FBillNo:{},Fnumber:{},increment:{}]",FBillNo,Fnumber,increment);
             List<InStockBillEntry> inStockBillEntries = getInStockBillEntry(FBillNo);
             boolean complete = true;
             // 姣旇緝鍗曠瑪璧勬枡鐗╂枡鏄惁鍏ㄩ儴瀹屾垚
@@ -136,6 +138,7 @@
             }
             return true;
         } else {
+            log.error("鏇存柊ERP涓棿琛ㄥけ璐�===>>[FBillNo:{},Fnumber:{},increment:{}]",FBillNo,Fnumber,increment);
             return false;
         }
     }
@@ -153,11 +156,11 @@
             CPICMO cpicmo = select.get(0);
             boolean complete = false;
             if (cpicmo.getFQty() > 0) {
-                if (cpicmo.getFAuxCommitQty() >= cpicmo.getFQty()) {
+                if (Double.doubleToLongBits(cpicmo.getFAuxCommitQty()) == Double.doubleToLongBits(cpicmo.getFQty())) {
                     complete = true;
                 }
             } else {
-                if (cpicmo.getFAuxCommitQty() >= cpicmo.getFAuxQty()) {
+                if (Double.doubleToLongBits(cpicmo.getFAuxCommitQty()) == Double.doubleToLongBits(cpicmo.getFAuxQty())) {
                     complete = true;
                 }
             }
@@ -227,14 +230,14 @@
 
     /**
      * 搴撳瓨鐩樼偣
-     * @param FItemID 鐗╂枡鍐呯爜
+     * @param FNumber 鐗╂枡鍐呯爜
      * @param qty 鏁伴噺锛堟琛ㄧず鐩樼泩銆佽礋琛ㄧず鐩樹簭锛�
      */
-    public boolean checkStockEntity(Integer FItemID, Integer FEntryID, Double qty){
-        String sql = "insert [dbo].[StockCheckRecord] ([FItemID],[FEntryID], [CheckQty],[Fflag_rw],[Fflag_finish]) values ({0,number,#}, {1,number,#}, {2,number,#}, 0, 0);";
-        sql = MessageFormat.format(sql, FItemID, FEntryID, qty);
+    public boolean checkStockEntity(String FNumber, Double qty){
+        String sql = "insert [dbo].[StockCheckRecord] ([FNumber],[CheckQty],[Fflag_rw],[Fflag_finish],[sync_id]) values (''{0}'', {1,number,#}, 0, 0, -1);";
+        sql = MessageFormat.format(sql, FNumber, qty);
         if (erpSqlServer.update(sql) == 0) {
-            log.error("{}鏂板鐩樼偣璁板綍澶辫触", FItemID);
+            log.error("{}鏂板鐩樼偣璁板綍澶辫触", FNumber);
             return false;
         }
         return true;
@@ -293,18 +296,42 @@
         return erpSqlServer.select("SELECT * FROM  xtyasrs_dual.dbo.OutStockBillEntry", OutStockBillEntry.class);
     }
 
+    /* 鎴愬搧澧為噺鍑哄簱 */
+    public boolean incrementCPakOut(Integer FInterID, String Fnumber, Double increment, String FBillNo) {
+        String sql = "update OutStockbillEntry set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FInterID = {2,number,#}";
+        sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
+        if (erpSqlServer.update(sql) > 0) {
+            sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#}";
+            sql = MessageFormat.format(sql, Fnumber, FInterID);
+            List<OutStockBillEntry> select = erpSqlServer.select(sql, OutStockBillEntry.class);
+            OutStockBillEntry outStockBillEntry = select.get(0);
+            boolean complete = false;
+            if (outStockBillEntry.getFQty().compareTo(BigDecimal.ZERO) == 1) {
+                if (outStockBillEntry.getFAuxCommitQty().compareTo(outStockBillEntry.getFQty()) > -1) {
+                    complete = true;
+                }
+            } else {
+                if (outStockBillEntry.getFAuxCommitQty().compareTo(outStockBillEntry.getFAuxQty()) > -1) {
+                    complete = true;
+                }
+            }
+            if (complete) {
+                if (!completeCPakOut(FBillNo)) {
+                    log.error("{}鍑哄簱鍗曟爣璁板畬鎴愬け璐�", FBillNo);
+                }
+            }
+            return true;
+        } else {
+            return false;
+        }
+    }
 
-
-
-
-
-
-
-
-
-
-
-
+    /* 鎴愬搧鍑哄簱鍗曟爣璁板畬鎴� */
+    private boolean completeCPakOut(String FBillNo){
+        String sql = "update OutStockbill set Fflag_finish = 1 where FBillNo = ''{0}''";
+        sql = MessageFormat.format(sql, FBillNo);
+        return erpSqlServer.update(sql) > 0;
+    }
 
 
     public boolean updateFnumber(Integer itemId, String FNumber){
@@ -319,4 +346,18 @@
         return erpSqlServer.update(sql) > 0;
     }
 
+    public List<CPICMO> queryErpCPICMO(String fbillNo, String fsourceBillNo) {
+        String sql = "select * from CPICMO";
+        if (!Cools.isEmpty(fbillNo) && Cools.isEmpty(fsourceBillNo)) {
+            sql = "select * from CPICMO where FBillNo = ''{0}''";
+            sql = MessageFormat.format(sql, fbillNo);
+        } else if (Cools.isEmpty(fbillNo) && !Cools.isEmpty(fsourceBillNo)) {
+            sql = "select * from CPICMO where FSourceBillNo = ''{0}''";
+            sql = MessageFormat.format(sql, fsourceBillNo);
+        } else if (!Cools.isEmpty(fbillNo) && !Cools.isEmpty(fsourceBillNo)) {
+            sql = "select * from CPICMO where FBillNo = ''{0}'' and FSourceBillNo = ''{1}''";
+            sql = MessageFormat.format(sql, fbillNo, fsourceBillNo);
+        }
+        return erpSqlServer.select(sql, CPICMO.class);
+    }
 }

--
Gitblit v1.9.1