From da4b0a4e9a171b46d08beb45aa2b2ac7f7e3b12e Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期四, 05 三月 2026 10:51:10 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs | 74 ++++++++++++++++++++++++++----------
1 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
index efaf7e6..ea45580 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationOutBillController.cs
@@ -1381,8 +1381,8 @@
oCN.RunProc(deleteSql);
}
- // 棣栧厛鏌ヨ HQty 鍜� HPieceQty
- DataSet dsPiece = oCN.RunProcReturn("select HPieceQty, HQty from Sc_StationOutBillMain where HInterID='" + HInterID + "'", "Sc_StationOutBillMain");
+ // 鏌ヨ 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)
{
@@ -1396,26 +1396,38 @@
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.Message = "淇濆瓨澶辫触锛佷欢鏁板繀椤诲ぇ浜�0";
objJsonResult.data = 1;
return objJsonResult;
}
- // 璁$畻闇�瑕佺敓鎴愮殑鏉$爜鏁伴噺
- int fullBarcodeCount = (int)(HQty / HPieceQty); // 瀹屾暣绠辨暟
- decimal remainder = HQty % HPieceQty; // 浣欐暟
-
- int barcodeCount = fullBarcodeCount;
- if (remainder > 0)
+ if (totalWeight <= 0)
{
- barcodeCount += 1; // 鏈変綑鏁版椂澧炲姞涓�寮犳潯鐮�
+ 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");
@@ -1428,22 +1440,24 @@
for (int i = 0; i < barcodeCount; i++)
{
// 璁$畻褰撳墠鏉$爜鐨勬暟閲�
- decimal currentQty;
- if (i < fullBarcodeCount)
+ decimal currentQty = baseQtyPerPiece;
+ if (i < remainderQty) // 濡傛灉鏈変綑鏁帮紝鍓峃寮犳潯鐮佸悇鍔�1
{
- // 鍓� fullBarcodeCount 寮犳潯鐮侊紝姣忓紶鏁伴噺涓� HPieceQty
- currentQty = HPieceQty;
- }
- else
- {
- // 鏈�鍚庝竴寮犳潯鐮侊紝鏁伴噺涓轰綑鏁�
- currentQty = remainder;
+ 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() : "");
- string sql = "insert into Gy_BarCodeBill (HInterID, HEntryID, HBarCode, HBarCodeType, HBarCodeSubType, HMaterID, HUnitID, HQty, HBatchNo, HSupID, HGroupID, HMaker, HMakeDate, " +
+ // 淇敼鎻掑叆璇彞锛屾坊鍔燞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" +
@@ -1456,6 +1470,8 @@
"'" + row["HMaterID"].ToString() + "', " +
"'0', " +
"'" + currentQty.ToString() + "', " + // 浣跨敤褰撳墠鏉$爜鐨勬暟閲�
+ "'" + currentWeight.ToString() + "', " + // 鍑�閲�
+ "'" + currentWeight.ToString() + "', " + // 姣涢噸锛堜笌鍑�閲嶇浉鍚岋級
"'', " +
"'', " +
"'" + row["HGroupID"].ToString() + "', " +
@@ -4035,6 +4051,7 @@
objJsonResult.data = ds.Tables[0];
return objJsonResult;
}
+
objJsonResult.code = "1";
objJsonResult.count = 1;
objJsonResult.Message = "";
@@ -4056,6 +4073,8 @@
objJsonResult.data = ds.Tables[0];
return objJsonResult;
}
+
+
objJsonResult.code = "1";
objJsonResult.count = 1;
@@ -4101,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