From ed72baa5f60f2d86cc58799ce96c658321a54d79 Mon Sep 17 00:00:00 2001
From: 王佳豪 <g675230687@126.com>
Date: 星期五, 30 四月 2021 13:53:54 +0800
Subject: [PATCH] 1.erp立库出库对接 2.erp平仓出库对接

---
 src/main/java/com/zy/common/service/erp/ErpService.java |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 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..c768af8 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;
@@ -293,6 +294,43 @@
         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;
+    }
+
 
 
 

--
Gitblit v1.9.1