From 0190125daca8a74bbdceadcbf58f45ee8b0c6173 Mon Sep 17 00:00:00 2001
From: 18516761980 <4761516tqsxp>
Date: 星期二, 28 九月 2021 08:15:22 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/service/erp/ErpService.java | 254 ++++++++++++++++++++++++++++++++++----------------
1 files changed, 171 insertions(+), 83 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 623c72a..0408c57 100644
--- a/src/main/java/com/zy/common/service/erp/ErpService.java
+++ b/src/main/java/com/zy/common/service/erp/ErpService.java
@@ -40,8 +40,9 @@
return erpSqlServer.update("delete from M_item where 1=1 and Mnumber = '" + Mnumber + "'") > 0;
}
+ //////////////////////鎴愬搧銆佸師鏉愭枡鍏ュ簱閫氱煡鍗曟暟鎹彁鍙�//////////////////////////////////////////////////
/**
- * 鑾峰彇鏈鍙栬繃鐨勫師鏉愭枡鍏ュ簱鍗曟嵁
+ * 鎻愬彇涓棿琛ㄥ師鏉愭枡鍏ュ簱鍗曟嵁
*/
public List<InStockDto> getReadyInStock() {
List<InStockDto> result = new ArrayList<>();
@@ -63,11 +64,12 @@
}
/**
- * 鑾峰彇鏈鍙栬繃鐨勬垚鍝佸叆搴撳崟鎹�
+ * 鑾峰彇鍏ュ簱鐗╂祦鏄庣粏
+ * @param fInterID 鍗曟嵁鍐呯爜
*/
- public List<CPICMO> getReadyCPICMO() {
- String sql = "select * from CPICMO where 1=1 and Fflag_rw = 0";
- return erpSqlServer.select(sql, CPICMO.class);
+ private List<InStockBillEntry> getInStockBillEntry(Integer fInterID) {
+ String sql = "select * from InStockBillEntry where 1=1 and FSourceBillNo!='' and FAuxCommitQty=0 and FInterID = " + fInterID;
+ return erpSqlServer.select(sql, InStockBillEntry.class);
}
/**
@@ -80,6 +82,14 @@
}
/**
+ * 鎻愬彇涓棿琛ㄦ垚鍝佸叆搴撳崟鎹�
+ */
+ public List<CPICMO> getReadyCPICMO() {
+ String sql = "select * from CPICMO where 1=1 and FSourceBillNo!='' and FAuxCommitQty=0 and Fflag_rw = 0";
+ return erpSqlServer.select(sql, CPICMO.class);
+ }
+
+ /**
* 灏嗘湭璇荤殑鎴愬搧鍏ュ簱鍗曟嵁璁剧疆涓哄凡璇�
*/
public boolean haveReadCPICMO(String FBillNo){
@@ -87,6 +97,39 @@
sql = MessageFormat.format(sql, FBillNo);
return erpSqlServer.update(sql) > 0;
}
+ ////////////////////////////////////////////////////////////////////////////////////////
+
+ ////////////////////// 鍑哄簱閫氱煡鍗曟暟鎹彁鍙�//////////////////////////////////////////////////
+ /**
+ * 鏌ヨerp涓棿琛ㄨ〃澶碠utStockBill鏁版嵁
+ * @return
+ */
+ public List<OutStockBill> syncOutStock() {
+ return erpSqlServer.select("SELECT * FROM xtyasrs_dual.dbo.OutStockBill where Fflag_rw=0", OutStockBill.class);
+// return erpSqlServer.select("SELECT * FROM xtyasrs_dual.dbo.OutStockBill where Fflag_rw=0", OutStockBill.class);
+ }
+
+ /**
+ * 鏌ヨ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);
+ }
+
+ /**
+ * 灏嗘彁鍙栧畬鎴愮殑鎴愬搧鍑哄簱閫氱煡鍗曟嵁璁剧疆涓哄凡璇�
+ */
+ public boolean haveReadOutBill(String FBrNo, Integer FInterID){
+ String sql = "update OutStockbill set Fflag_rw = 1 where FBillNo = ''{0}'' and FInterID = {1,number,#} ";
+ sql = MessageFormat.format(sql, FBrNo, FInterID);
+ return erpSqlServer.update(sql) > 0;
+ }
+ ////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
/**
* 鎻愪氦瀹為檯鏀惰揣鏁伴噺
@@ -103,16 +146,29 @@
/**
* 鍘熸潗鏂欏閲忓叆搴�
*/
- public boolean incrementPakIn(String FBillNo, String Fnumber, Double increment) {
+ public boolean incrementPakIn(String FBillNo, String Fnumbers, Double increment) {
+ String[] arrays = Fnumbers.split("|");
+ String Fnumber="",sBillNo=""; //浜у搧浠g爜,鐢熶骇鍗曞彿
+
String sql = "update ise \n" +
"set ise.FAuxCommitQty = (ise.FAuxCommitQty + {0,number,#}) \n" +
"from InStockBillEntry ise\n" +
"left join InStockbill isb on isb.FInterID = ise.FInterID\n" +
"where 1=1 \n" +
"and ise.Fnumber = ''{1}''\n" +
- "and isb.FBillNo= ''{2}''";
- sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
+ "and isb.FBillNo= ''{2}''\n";
+
+ Fnumber = arrays[0];
+ if(arrays.length>1){
+ sBillNo = arrays[1];
+ sql = sql + "and ise.FSourceBillNo= ''{3}''";
+ sql = MessageFormat.format(sql, increment, Fnumber, FBillNo, sBillNo);
+ } else {
+ 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;
// 姣旇緝鍗曠瑪璧勬枡鐗╂枡鏄惁鍏ㄩ儴瀹屾垚
@@ -137,6 +193,7 @@
}
return true;
} else {
+ log.error("鏇存柊ERP涓棿琛ㄥけ璐�===>>[FBillNo:{},Fnumber:{},increment:{}]",FBillNo,Fnumbers,increment);
return false;
}
}
@@ -144,12 +201,29 @@
/**
* 鎴愬搧澧為噺鍏ュ簱
*/
- public boolean incrementCPakIn(String FBillNo, String Fnumber, Double increment) {
- String sql = "update CPICMO set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FBillNo = ''{2}''";
- sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
+ public boolean incrementCPakIn(String FBillNo, String Fnumbers, Double increment) {
+ String[] arrays = Fnumbers.split("|");
+ String Fnumber="",sBillNo=""; //浜у搧浠g爜,鐢熶骇鍗曞彿
+
+ String sql = "update CPICMO set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FBillNo = ''{2}'' ";
+
+ Fnumber = arrays[0];
+ if(arrays.length>1){
+ sBillNo = arrays[1];
+ sql = sql + " and FSourceBillNo= ''{3}''";
+ sql = MessageFormat.format(sql, increment, Fnumber, FBillNo, sBillNo);
+ } else {
+ sql = MessageFormat.format(sql, increment, Fnumber, FBillNo);
+ }
+
if (erpSqlServer.update(sql) > 0) {
- sql = "select * from CPICMO where 1=1 and Fnumber = ''{0}'' and FBillNo = ''{1}''";
- sql = MessageFormat.format(sql, Fnumber, FBillNo);
+ if(arrays.length>1) {
+ sql = "select * from CPICMO where 1=1 and Fnumber = ''{0}'' and FBillNo = ''{1}'' and FSourceBillNo= ''{2}''";
+ sql = MessageFormat.format(sql, Fnumber, FBillNo, sBillNo);
+ } else {
+ sql = "select * from CPICMO where 1=1 and Fnumber = ''{0}'' and FBillNo = ''{1}''";
+ sql = MessageFormat.format(sql, Fnumber, FBillNo);
+ }
List<CPICMO> select = erpSqlServer.select(sql, CPICMO.class);
CPICMO cpicmo = select.get(0);
boolean complete = false;
@@ -163,7 +237,7 @@
}
}
if (complete) {
- if (!completeCPakIn(FBillNo, Fnumber)) {
+ if (!completeCPakIn(FBillNo, Fnumber, sBillNo)) {
log.error("{}鍏ュ簱鍗曟爣璁板畬鎴愬け璐�", FBillNo);
}
}
@@ -228,29 +302,22 @@
/**
* 搴撳瓨鐩樼偣
- * @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[] arrays = FNumber.split("|");
+ FNumber = arrays[0];
+ 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;
}
// 绉佹湁鏂规硶 --------------------------------------------------------------------------------------
-
- /**
- * 鑾峰彇鍏ュ簱鐗╂祦鏄庣粏
- * @param fInterID 鍗曟嵁鍐呯爜
- */
- private List<InStockBillEntry> getInStockBillEntry(Integer fInterID) {
- String sql = "select * from InStockBillEntry where 1=1 and FInterID = " + fInterID;
- return erpSqlServer.select(sql, InStockBillEntry.class);
- }
private List<InStockBillEntry> getInStockBillEntry(String FBillNo) {
String sql = "select ise.* from InStockBillEntry ise left join InStockbill isb on isb.FInterID = ise.FInterID where 1=1 and isb.FBillNo = '" + FBillNo +"'";
@@ -269,59 +336,80 @@
/**
* 鎴愬搧鍏ュ簱鍗曟爣璁板畬鎴�
*/
- private boolean completeCPakIn(String FBillNo, String Fnumber){
- String sql = "update CPICMO set Fflag_finish = 1 where FBillNo = ''{0}'' and Fnumber = ''{1}''";
- sql = MessageFormat.format(sql, FBillNo, Fnumber);
- return erpSqlServer.update(sql) > 0;
+ private boolean completeCPakIn(String FBillNo, String Fnumber, String sBillNo){
+ if(Cools.isEmpty(sBillNo)) {
+ String sql = "update CPICMO set Fflag_finish = 1 where FBillNo = ''{0}'' and Fnumber = ''{1}''";
+ sql = MessageFormat.format(sql, FBillNo, Fnumber);
+ return erpSqlServer.update(sql) > 0;
+ } else {
+ String sql = "update CPICMO set Fflag_finish = 1 where FBillNo = ''{0}'' and Fnumber = ''{1}'' and FSourceBillNo= ''{2}'' ";
+ sql = MessageFormat.format(sql, FBillNo, Fnumber, sBillNo);
+ return erpSqlServer.update(sql) > 0;
+ }
}
- /**
- * 鍑哄簱鍗曟爣璁板畬鎴�
- */
- private boolean completePakOut(Integer fInterID){
- String sql = "update OutStockBill set Fflag_finish = 1 where FInterID = {0,number,#}";
- sql = MessageFormat.format(sql, fInterID);
- return erpSqlServer.update(sql) > 0;
- }
-
- /* 鏌ヨerp涓勾琛∣utStockBill鏁版嵁 */
- public List<OutStockBill> syncOutStock() {
- return erpSqlServer.select("SELECT * FROM xtyasrs_dual.dbo.OutStockBill", OutStockBill.class);
- }
-
- public List<OutStockBillEntry> syncOutStockDetail() {
- return erpSqlServer.select("SELECT * FROM xtyasrs_dual.dbo.OutStockBillEntry", OutStockBillEntry.class);
- }
+// /**
+// * 鍑哄簱鍗曟爣璁板畬鎴�
+// */
+// private boolean completePakOut(Integer fInterID){
+// String sql = "update OutStockBill set Fflag_finish = 1 where FInterID = {0,number,#}";
+// sql = MessageFormat.format(sql, fInterID);
+// return erpSqlServer.update(sql) > 0;
+// }
/* 鎴愬搧澧為噺鍑哄簱 */
- 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;
+ public boolean incrementCPakOut(Integer FInterID, String Fnumbers, Double increment, String FBillNo) {
+ String[] arrays = Fnumbers.split("|");
+ String Fnumber="",sBillNo=""; //浜у搧浠g爜,鐢熶骇鍗曞彿
+
+ String sql = "update OutStockbillEntry set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FInterID = {2,number,#} ";
+ Fnumber = arrays[0];
+ if(arrays.length>1){
+ sBillNo = arrays[1];
+ sql = sql + " and FSourceBillNo= ''{3}''";
+ sql = MessageFormat.format(sql, increment, Fnumber, FInterID, sBillNo);
} else {
+ sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
+ }
+
+ try {
+ if (erpSqlServer.update(sql) > 0) {
+ if(arrays.length>1) {
+ sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#} and FSourceBillNo= ''{2}''";
+ sql = MessageFormat.format(sql, Fnumber, FInterID, sBillNo);
+ } else {
+ 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;
+ }
+ }catch (Exception e){
+ e.printStackTrace();
+ log.error("incrementCPakOut----" + sql);
return false;
}
+
}
/* 鎴愬搧鍑哄簱鍗曟爣璁板畬鎴� */
@@ -332,17 +420,17 @@
}
- public boolean updateFnumber(Integer itemId, String FNumber){
- String sql = "update InStockbillEntry set Fnumber = ''{0}'' where FItemID = {1,number,#}";
- sql = MessageFormat.format(sql, FNumber, itemId);
- return erpSqlServer.update(sql) > 0;
- }
+// public boolean updateFnumber(Integer itemId, String FNumber){
+// String sql = "update InStockbillEntry set Fnumber = ''{0}'' where FItemID = {1,number,#}";
+// sql = MessageFormat.format(sql, FNumber, itemId);
+// return erpSqlServer.update(sql) > 0;
+// }
- public boolean updateCFnumber(Integer itemId, String FNumber){
- String sql = "update CPICMO set Fnumber = ''{0}'' where FItemID = {1,number,#}";
- sql = MessageFormat.format(sql, FNumber, itemId);
- return erpSqlServer.update(sql) > 0;
- }
+// public boolean updateCFnumber(Integer itemId, String FNumber){
+// String sql = "update CPICMO set Fnumber = ''{0}'' where FItemID = {1,number,#}";
+// sql = MessageFormat.format(sql, FNumber, itemId);
+// return erpSqlServer.update(sql) > 0;
+// }
public List<CPICMO> queryErpCPICMO(String fbillNo, String fsourceBillNo) {
String sql = "select * from CPICMO";
--
Gitblit v1.9.1