From 2eb6dfc871766780831a91ccff95d9d4afffef9e Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期三, 04 二月 2026 16:40:58 +0800
Subject: [PATCH] app小卫装箱
---
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 252 +++++++++++++++++++++++++++++++++++--------------
1 files changed, 179 insertions(+), 73 deletions(-)
diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index 6c8e5a5..ea45580 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,169 @@
#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銆丠PieceQty 鍜� 閲嶉噺瀛楁
+ DataSet dsPiece = oCN.RunProcReturn("select HPieceQty, HQty, HWeight 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"]);
+ decimal totalWeight = Convert.ToDecimal(dsPiece.Tables[0].Rows[0]["HWeight"]);
+
+ if (HPieceQty <= 0)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷欢鏁板繀椤诲ぇ浜�0";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ if (totalWeight <= 0)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛侀噸閲忓繀椤诲ぇ浜�0";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ // 鍥哄畾鐢熸垚鎸囧畾浠舵暟鐨勬潯鐮�
+ int barcodeCount = (int)HPieceQty; // HPieceQty 浣滀负鏉$爜浠舵暟
+
+ // 璁$畻姣忓紶鏉$爜鐨勫熀纭�鏁伴噺鍜屽熀纭�閲嶉噺
+ decimal baseQtyPerPiece = Math.Floor(HQty / HPieceQty);
+ decimal remainderQty = HQty % HPieceQty;
+
+ // 璁$畻姣忓紶鏉$爜鐨勫熀纭�閲嶉噺锛堝噣閲嶅拰姣涢噸鐩稿悓锛�
+ decimal baseWeightPerPiece = Math.Floor(totalWeight / HPieceQty * 10000) / 10000; // 淇濈暀4浣嶅皬鏁�
+ decimal remainderWeight = totalWeight - (baseWeightPerPiece * HPieceQty);
+
+ // 鏌ヨ鍘熷鍗曟嵁淇℃伅
+ 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 = baseQtyPerPiece;
+ if (i < remainderQty) // 濡傛灉鏈変綑鏁帮紝鍓峃寮犳潯鐮佸悇鍔�1
+ {
+ currentQty += 1;
+ }
+
+ // 璁$畻褰撳墠鏉$爜鐨勯噸閲忥紙鍑�閲嶅拰姣涢噸鐩稿悓锛�
+ decimal currentWeight = baseWeightPerPiece;
+ if (i < Math.Ceiling(remainderWeight / baseWeightPerPiece) && remainderWeight > 0)
+ {
+ currentWeight += baseWeightPerPiece; // 閲嶉噺浣欐暟涔熷垎鎽婂埌鍓嶅嚑寮犳潯鐮�
+ }
+
+ // 鐢熸垚鏉$爜鍙�
+ string barcodeNumber = row["HBillNO"].ToString() + (barcodeCount > 1 ? "-" + (i + 1).ToString() : "");
+
+ // 淇敼鎻掑叆璇彞锛屾坊鍔燞MaterialJQty鍜孒MaterialMQty瀛楁
+ string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HMaterialJQty, HMaterialMQty, 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() + "', " + // 浣跨敤褰撳墠鏉$爜鐨勬暟閲�
+ "'" + currentWeight.ToString() + "', " + // 鍑�閲�
+ "'" + currentWeight.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 +1542,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();
@@ -3961,6 +4051,7 @@
objJsonResult.data = ds.Tables[0];
return objJsonResult;
}
+
objJsonResult.code = "1";
objJsonResult.count = 1;
objJsonResult.Message = "";
@@ -3982,6 +4073,8 @@
objJsonResult.data = ds.Tables[0];
return objJsonResult;
}
+
+
objJsonResult.code = "1";
objJsonResult.count = 1;
@@ -4027,14 +4120,27 @@
return objJsonResult;
}
+
+ List<object> columnNameList = new List<object>();
+
string sql1 = "select * from h_v_MES_StationOutBillList_SN where 1 = 1 ";
string sql = sql1 + sWhere + " order by 鍒跺崟鏃ユ湡 desc";
ds = oCN.RunProcReturn(sql, "h_v_MES_StationOutBillList_SN");
+
+ //娣诲姞鍒楀悕
+ foreach (DataColumn col in ds.Tables[0].Columns)
+ {
+ LogService.Write(21231321);
+ Type dataType = col.DataType;
+ string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+ columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+ }
objJsonResult.code = "1";
objJsonResult.count = 1;
objJsonResult.Message = "Sucess锛�";
objJsonResult.data = ds.Tables[0];
+ objJsonResult.list = columnNameList;
return objJsonResult;
}
catch (Exception e)
--
Gitblit v1.9.1