From 23d7909b52e22eb42900a506c7d8b72f58f28944 Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期一, 03 七月 2023 17:36:21 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/common/service/erp/ErpService.java |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 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 18e85d3..4a27748 100644
--- a/src/main/java/com/zy/common/service/erp/ErpService.java
+++ b/src/main/java/com/zy/common/service/erp/ErpService.java
@@ -1,5 +1,6 @@
 package com.zy.common.service.erp;
 
+import com.baomidou.mybatisplus.MybatisSqlSessionTemplate;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
 import com.core.common.Cools;
 import com.core.common.DateUtils;
@@ -86,7 +87,8 @@
      * @param fInterID 鍗曟嵁鍐呯爜
      */
     private List<InStockBillEntry> getInStockBillEntry(Integer fInterID) {
-        String sql = "select * from InStockBillEntry where 1=1 and FSourceBillNo!='' and FAuxCommitQty=0 and FInterID = " + fInterID;
+//        String sql = "select * from InStockBillEntry where 1=1 and FSourceBillNo!='' and FAuxCommitQty=0 and FInterID = " + fInterID;
+        String sql = "select * from InStockBillEntry where 1=1 and FAuxCommitQty=0 and FInterID = " + fInterID;
         return erpSqlServer.select(sql, InStockBillEntry.class);
     }
 
@@ -103,7 +105,8 @@
      * 鎻愬彇涓棿琛ㄦ垚鍝佸叆搴撳崟鎹�
      */
     public List<CPICMO> getReadyCPICMO() {
-        String sql = "select * from CPICMO where 1=1 and FSourceBillNo!='' and FAuxCommitQty=0 and Fflag_rw = 0";
+//        String sql = "select * from CPICMO where 1=1 and FSourceBillNo!='' and FAuxCommitQty=0 and Fflag_rw = 0";
+        String sql = "select * from CPICMO where 1=1 and FAuxCommitQty=0 and Fflag_rw = 0";
         return erpSqlServer.select(sql, CPICMO.class);
     }
 
@@ -155,13 +158,16 @@
         return erpSqlServer.executeQueryCount(sql,"qty");
     }
 
+
     /**
      * 鏌ヨerp涓棿琛ㄨ〃浣揙utStockbillEntry鏁版嵁
      * @param FInterID
      * @return
      */
     public List<OutStockBillEntry> syncOutStockDetail(Integer FInterID) {
-        return erpSqlServer.select("SELECT * FROM  xtyasrs_dual.dbo.OutStockBillEntry where FSourceBillNo!='' and FAuxCommitQty=0 and FInterID=" + FInterID, OutStockBillEntry.class);
+//        String sql = "SELECT * FROM  xtyasrs_dual.dbo.OutStockBillEntry where FSourceBillNo!='' and FAuxCommitQty=0 and FInterID=" + FInterID;
+        String sql = "SELECT * FROM  xtyasrs_dual.dbo.OutStockBillEntry where FAuxCommitQty=0 and FInterID=" + FInterID;
+        return erpSqlServer.select(sql, OutStockBillEntry.class);
     }
 
     /**
@@ -446,12 +452,25 @@
                     }
                 }
                 if (complete) {
-                    if (!completeCPakOut(FBillNo)) {
-                        log.error("{}鍑哄簱鍗曟爣璁板畬鎴愬け璐�", FBillNo);
+                    sql = "select * from OutStockbillEntry where 1=1 and FInterID = {1,number,#}";
+                    sql = MessageFormat.format(sql, Fnumber, FInterID);
+                    List<OutStockBillEntry> select1 = erpSqlServer.select(sql, OutStockBillEntry.class);
+
+                    boolean flag = true;
+                    for(OutStockBillEntry outStockBillEntry1 : select1){
+                        if (outStockBillEntry1.getFAuxCommitQty().compareTo(outStockBillEntry1.getFQty()) == -1) {
+                            flag = false;
+                        }
                     }
-                    int updateCount = jdbcTemplate.update("update OutStockbill set Fflag_finish=1 where FBillNo='" + FBillNo + "'");
-                    if(updateCount<=0){
-                        throw new CoolException("鏇存柊鍑哄簱閫氱煡妗e畬鎴愭爣璁板け璐FBillNo="+FBillNo+"]");
+
+                    if(flag){
+                        if (!completeCPakOut(FBillNo) ) {
+                            log.error("{}鍑哄簱鍗曟爣璁板畬鎴愬け璐�", FBillNo);
+                        }
+                        int updateCount = jdbcTemplate.update("update OutStockbill set Fflag_finish=1 where FBillNo='" + FBillNo + "'");
+                        if(updateCount<=0){
+                            throw new CoolException("鏇存柊鍑哄簱閫氱煡妗e畬鎴愭爣璁板け璐FBillNo="+FBillNo+"]");
+                        }
                     }
                 }
                 return true;

--
Gitblit v1.9.1