From be8d810d8b771c0a231b4c98c21a597b0cfc9359 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期一, 02 二月 2026 10:09:58 +0800
Subject: [PATCH] 出站单增加条码拆分功能
---
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 220 ++++++++++++++++++++++++++++++++++++------------------
1 files changed, 147 insertions(+), 73 deletions(-)
diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index 6c8e5a5..efaf7e6 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -90,7 +90,7 @@
double HPeriod = DateTime.Now.Month;
string HRemark = list[0].HRemark;//澶囨敞
string HSourceName = list[0].HSourceName;//鐢熶骇璧勬簮鍚嶇О
- double HPieceQty = list[0].HPieceQty;//杩涚珯PCS鏁�
+ double HPieceQty = list[0].HPieceQty;//杩涚珯PCS鏁� 浠舵暟
double HWasterQty = list[0].HWasterQty;//鎶ュ簾鏁伴噺
double HPlanPieceQty = list[0].HPlanPieceQty;//杩涚珯PNL鏁�
double HBadPNL = list[0].HBadPNL;//鎶ュ簾PNL鏁�
@@ -644,9 +644,18 @@
//鍒ゆ柇瀹㈡埛涓哄崕鑸熷寘瑁� 鐢熸垚鏉$爜涓绘。
else if (oSystemParameter.omodel.WMS_CampanyName == "鍗庤垷")
{
- var objResult = Cj_StationOutBarCode_Save(HInterID);
+ var objResult = Cj_StationOutBarCode_Save(HInterID,1);
}
}
+ else if ("Modify".Equals(eventType))
+ {
+ //鍒ゆ柇瀹㈡埛涓哄崕鑸熷寘瑁� 鐢熸垚鏉$爜涓绘。
+ if (oSystemParameter.omodel.WMS_CampanyName == "鍗庤垷")
+ {
+ var objResult = Cj_StationOutBarCode_Save(HInterID, 2);
+ }
+
+ }
sw.Stop();//缁撴潫璁℃椂
LogService.Write($"11.鍙傛暟鏌ヨ缁撴潫,鏂板缁撴潫锛岀敤鏃�" + sw.Elapsed);
LogService.Write("END--鍑虹珯鍗曟嵁淇濆瓨缁撴潫锛屽嚭绔欏崟鍙凤細" + HBillNo);
@@ -1356,88 +1365,153 @@
#region [鍑虹珯鍗曠敓鎴愭潯鐮佷富妗
[Route("Cj_StationOutBill/Cj_StationOutBarCode_Save")]
[HttpPost]
- public object Cj_StationOutBarCode_Save(long HInterID)
+ public object Cj_StationOutBarCode_Save(long HInterID, int Type)
{
try
{
ListModels oListModels = new ListModels();
- DAL.ClsGy_BarCodeBill_ChaiMa BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa();
+ DAL.ClsGy_BarCodeBill_ChaiMa BillNew = new DAL.ClsGy_BarCodeBill_ChaiMa();
oCN.BeginTran();
- ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
-
- if (ds != null || ds.Tables[0].Rows.Count > 0)
+ // 濡傛灉Type涓�2锛屽厛鍒犻櫎鑰佺殑鏉$爜璁板綍
+ if (Type == 2)
{
+ string deleteSql = "DELETE FROM Gy_BarCodeBill WHERE HInterID = '" + HInterID + "'";
+ oCN.RunProc(deleteSql);
+ }
- string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " +
- "HPrintQty, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HinitQty, HEndQty, HBarcodeQtys, HBarcodeNo, HDeptID, HWhID, HSPID, HRemark, " +
- "HCusID, HCusType, HEndDate, HWorkLineName, HBarCodeDate, HSTOCKORGID, HOWNERID, HSeOrderBillNo, HGiveAwayFlag, HMaterName, HMaterModel, " +
- "HPinfan, HAuxPropID, HMTONo, HInnerBillNo, HCoilNO, HFurnaceNO, HFactory, HAuxQty, HheatNO, HEmpID, HCusModel, HCusMaterName, HCheckEmpName, HZZRQ,HSupMaterNumber,HSupBatchNo" +
- ") values (" +
- "'" + ds.Tables[0].Rows[0]["HInterID"].ToString() + "', " +
- "'1', " +
- "'" + ds.Tables[0].Rows[0]["HBillNO"].ToString() + "', " +
- "'鍞竴鏉$爜', " +
- "'', " +
- "'" + ds.Tables[0].Rows[0]["HMaterID"].ToString() + "', " +
- "'0', " +
- "'" + ds.Tables[0].Rows[0]["HQty"].ToString() + "', " +
- "'', " +
- "'', " +
- "'" + ds.Tables[0].Rows[0]["HGroupID"].ToString() + "', " +
- "'" + ds.Tables[0].Rows[0]["HMaker"].ToString() + "', getdate(), " +
- "'0', " +
- "'" + ds.Tables[0].Rows[0]["HICMOInterID"].ToString() + "', " +
- "'" + ds.Tables[0].Rows[0]["HICMOEntryID"].ToString() + "', " +
- "'" + ds.Tables[0].Rows[0]["HICMOBillNo"].ToString() + "', " +
- "'3710', " +
- "'0', " +
- "'0', " +
- "'1', " +
- "'1', " +
- "'" + ds.Tables[0].Rows[0]["HDeptID"].ToString() + "', " +
- "'0', " +
- "'0', " +
- "'" + ds.Tables[0].Rows[0]["HRemark"].ToString() + "', " +
- "'0', " +
- "'', " +
- "getdate(), " +
- "'', " +
- "getdate(), " +
- "'" + ds.Tables[0].Rows[0]["HPRDORGID"].ToString() + "', " +
- "'" + ds.Tables[0].Rows[0]["HPRDORGID"].ToString() + "', " +
- "'', " +
- "'0', " +
- "'', " +
- "'', " +
- "'', " +
- "'0', " +
- "'', " +
- "'', " +
- "'', " +
- "'', " +
- "'', " +
- "'0', " +
- "'', " +
- "'" + ds.Tables[0].Rows[0]["HEmpID"].ToString() + "', " +
- "'', " +
- "'', " +
- "'', " +
- "'', " +
- "'', " +
- "''" +
- ")";
- //鎻掑叆鎷嗗垎鏉$爜
- oCN.RunProc(sql);
-
- oCN.Commit();
- objJsonResult.code = "1";
- objJsonResult.count = 1;
- objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+ // 棣栧厛鏌ヨ HQty 鍜� HPieceQty
+ DataSet dsPiece = oCN.RunProcReturn("select HPieceQty, HQty from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
+
+ if (dsPiece == null || dsPiece.Tables[0].Rows.Count == 0)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佹湭鏌ヨ鍒版潯鐮佷俊鎭�";
objJsonResult.data = 1;
return objJsonResult;
+ }
+ decimal HPieceQty = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HPieceQty"]);
+ decimal HQty = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HQty"]);
+
+ if (HPieceQty <= 0)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佸崟寮犳潯鐮佹暟閲忓繀椤诲ぇ浜�0";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ // 璁$畻闇�瑕佺敓鎴愮殑鏉$爜鏁伴噺
+ int fullBarcodeCount = (int)(HQty / HPieceQty); // 瀹屾暣绠辨暟
+ decimal remainder = HQty % HPieceQty; // 浣欐暟
+
+ int barcodeCount = fullBarcodeCount;
+ if (remainder > 0)
+ {
+ barcodeCount += 1; // 鏈変綑鏁版椂澧炲姞涓�寮犳潯鐮�
+ }
+
+ // 鏌ヨ鍘熷鍗曟嵁淇℃伅
+ ds = oCN.RunProcReturn("select * from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
+
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ DataRow row = ds.Tables[0].Rows[0];
+
+ // 寰幆鐢熸垚鏉$爜
+ for (int i = 0; i < barcodeCount; i++)
+ {
+ // 璁$畻褰撳墠鏉$爜鐨勬暟閲�
+ decimal currentQty;
+ if (i < fullBarcodeCount)
+ {
+ // 鍓� fullBarcodeCount 寮犳潯鐮侊紝姣忓紶鏁伴噺涓� HPieceQty
+ currentQty = HPieceQty;
+ }
+ else
+ {
+ // 鏈�鍚庝竴寮犳潯鐮侊紝鏁伴噺涓轰綑鏁�
+ currentQty = remainder;
+ }
+
+ // 鐢熸垚鏉$爜鍙凤紙鍙互鍦ㄥ師濮嬫潯鐮佸彿鍚庨潰鍔犲簭鍙凤級
+ string barcodeNumber = row["HBillNO"].ToString() + (barcodeCount > 1 ? "-" + (i + 1).ToString() : "");
+
+ string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " +
+ "HPrintQty, HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HinitQty, HEndQty, HBarcodeQtys, HBarcodeNo, HDeptID, HWhID, HSPID, HRemark, " +
+ "HCusID, HCusType, HEndDate, HWorkLineName, HBarCodeDate, HSTOCKORGID, HOWNERID, HSeOrderBillNo, HGiveAwayFlag, HMaterName, HMaterModel, " +
+ "HPinfan, HAuxPropID, HMTONo, HInnerBillNo, HCoilNO, HFurnaceNO, HFactory, HAuxQty, HheatNO, HEmpID, HCusModel, HCusMaterName, HCheckEmpName, HZZRQ, HSupMaterNumber, HSupBatchNo" +
+ ") values (" +
+ "'" + row["HInterID"].ToString() + "', " +
+ "'" + (i + 1).ToString() + "', " + // HEntryID 鏀逛负搴忓彿
+ "'" + barcodeNumber + "', " + // 浣跨敤甯﹀簭鍙风殑鏉$爜鍙�
+ "'鍞竴鏉$爜', " +
+ "'', " +
+ "'" + row["HMaterID"].ToString() + "', " +
+ "'0', " +
+ "'" + currentQty.ToString() + "', " + // 浣跨敤褰撳墠鏉$爜鐨勬暟閲�
+ "'', " +
+ "'', " +
+ "'" + row["HGroupID"].ToString() + "', " +
+ "'" + row["HMaker"].ToString() + "', getdate(), " +
+ "'0', " +
+ "'" + row["HICMOInterID"].ToString() + "', " +
+ "'" + row["HICMOEntryID"].ToString() + "', " +
+ "'" + row["HICMOBillNo"].ToString() + "', " +
+ "'3710', " +
+ "'0', " +
+ "'0', " +
+ "'1', " +
+ "'" + (i + 1).ToString() + "', " + // HBarcodeNo 鏀逛负搴忓彿
+ "'" + row["HDeptID"].ToString() + "', " +
+ "'0', " +
+ "'0', " +
+ "'" + row["HRemark"].ToString() + "', " +
+ "'0', " +
+ "'', " +
+ "getdate(), " +
+ "'', " +
+ "'" + row["HDate"].ToString() + "', " +
+ "'" + row["HPRDORGID"].ToString() + "', " +
+ "'" + row["HPRDORGID"].ToString() + "', " +
+ "'', " +
+ "'0', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "'0', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "'0', " +
+ "'', " +
+ "'" + row["HEmpID"].ToString() + "', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "'', " +
+ "''" +
+ ")";
+
+ // 鎻掑叆鎷嗗垎鏉$爜
+ oCN.RunProc(sql);
+ }
+
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = barcodeCount;
+ objJsonResult.Message = "淇濆瓨鎴愬姛锛佸叡鐢熸垚" + barcodeCount + "寮犳潯鐮�";
+ objJsonResult.data = barcodeCount;
+ return objJsonResult;
}
else
{
@@ -1452,7 +1526,7 @@
catch (Exception e)
{
oCN.RollBack();
- oCN.RunProc("update Sc_StationOutBillMain set HInterFaceRemark =" + e.ToString() + ", HInterFaceStatus ='鏈敓鎴�' where HInterID=" + HInterID);
+ oCN.RunProc("update Sc_StationOutBillMain set HInterFaceRemark ='" + e.ToString().Replace("'", "''") + "', HInterFaceStatus ='鏈敓鎴�' where HInterID=" + HInterID);
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
--
Gitblit v1.9.1