From b8d7145eadce706aef50ef95be75cff9ef79b518 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期五, 31 十月 2025 09:01:20 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
---
WebAPI/Controllers/仓存管理/条码生成/Sc_BarCodeController.cs | 192 +++++++++++++++++++++++++++++++++++------------
1 files changed, 143 insertions(+), 49 deletions(-)
diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs"
index 6cbbd57..10103a7 100644
--- "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs"
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\346\235\241\347\240\201\347\224\237\346\210\220/Sc_BarCodeController.cs"
@@ -25,6 +25,7 @@
public WebServer webserver = new WebServer();
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
private WebS.WebService1 oWebs = new WebS.WebService1();
+ public WebS.ClsKf_ICStockBill_WMS WebSoBar = new WebS.ClsKf_ICStockBill_WMS();
//鑾峰彇绯荤粺鍙傛暟
Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
public Int64 HInterID = 0; //鍐呯爜
@@ -909,6 +910,8 @@
string HSupNumber = ""; // 渚涘簲鍟嗙紪鐮�
string HPOInStockBillNo = ""; // 鏀舵枡閫氱煡鍗曞彿
+ string HPOOrderBillNo = ""; // 閲囪喘璁㈠崟鍙�
+
DataSet Ds;
msg2 = msg2.Replace("\\", "");
msg2 = msg2.Replace("\n", ""); //\n
@@ -959,6 +962,8 @@
HPOInStockBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo); // 鏀舵枡閫氱煡鍗曞彿 鍏磋揪鏉$爜
HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber);// 渚涘簲鍟嗙紪鍙� 鍏磋揪鏉$爜
+
+ HPOOrderBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo); // 閲囪喘璁㈠崟鍙� 灏忓崼鐢靛櫒
//
sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
@@ -1069,6 +1074,14 @@
Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //鑾峰彇鏈�澶ф祦姘村彿
LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
LSHlen = 3; // 涓変綅娴佹按鍙�
+ }
+ else if (CampanyName.Contains("灏忓崼"))
+ {
+ // 灏忓崼鐢靛櫒
+ // 鏉$爜鍓嶇紑 = 鍗曟嵁鍙� + 鐗╂枡缂栫爜 + 鎵规鍙�
+ sTMNumber = HPOOrderBillNo + "@" + HMaterNumber + "@" + HBatchNo;
+ Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //鑾峰彇鏈�澶ф祦姘村彿
+ LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
}
else //閫氱敤鏂规硶
{
@@ -1824,7 +1837,7 @@
}
#endregion
- #region 鏇存柊鏉$爜 瀵瑰簲鍗曟嵁 鍗曞彿 娆℃暟 鏃堕棿
+ #region 鏇存柊鏉$爜瀵瑰簲鍑哄簱鐢宠鍗曞彿 鍏磋揪
public class BarCodeMeta
{
public string HBarCode { get; set; }
@@ -1851,23 +1864,24 @@
string msg2 = sArray[0].ToString();
string HBillType = sArray[1].ToString();
string HBillNo = sArray[2].ToString();
+ string HOrgName = sArray[3].ToString();
List<BarCodeMeta> BarCodeMetaList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BarCodeMeta>>(msg2);
+ oCN.BeginTran();
try
{
- oCN.BeginTran();
-
for(int i = 0; i < BarCodeMetaList.Count; i++)
{
if (HBillType == "1205") // 閿�鍞嚭搴�
{
- oCN.RunProcReturn("Update Gy_BarCodeBill set HOutStockDate = getdate(), HOutStockCounts=isnull(HOutStockCounts,0)+1," +
- "HOutStockBillNo='" + HBillNo + " 'where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill");
- }
- if (HBillType == "1201") // 閲囪喘鍏ュ簱
- {
- oCN.RunProcReturn("Update Gy_BarCodeBill set HInStockDate = getdate(), HInStockCounts=isnull(HOutStockCounts,0)+1," +
- "HInStockBillNo='" + HBillNo + " 'where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill");
+
+ if (HOrgName.Contains("鍏磋揪") && !string.IsNullOrEmpty(HBillNo))
+ {
+ // 鍏磋揪 閿�鍞嚭搴撴洿鏂� 鍙戣揣閫氱煡鍗�
+ oCN.RunProcReturn("Update Gy_BarCodeBill set " +
+ "HSeOutStockBillNo='" + HBillNo + "' where HBarCode = '" + BarCodeMetaList[i].HBarCode + "'", "Gy_BarCodeBill");
+ }
+
}
}
@@ -1879,6 +1893,7 @@
}
catch (Exception e)
{
+ oCN.RollBack();
objJsonResult.code = "0";
objJsonResult.count = 0;
objJsonResult.Message = "淇敼澶辫触!" + e.Message;
@@ -1890,12 +1905,12 @@
#region [鑾峰彇鏍囩鎵撳嵃鎸囦护 CPCL鎸囦护]
[Route("Sc_BarCode/Get_BarCodePrintCode_CPCL")]
[HttpGet]
- public object Get_BarCodePrintCode_CPCL(string HOrginationName, string HViewName, string HBillSubType, int HInterID, int HItemID)
+ public object Get_BarCodePrintCode_CPCL(string HOrginationName, string HBillSubType, int HInterID, int HItemID)
{
try
{
ds = oCN.RunProcReturn("exec h_p_getHBarCodePrintCode_CPCL N'" + HOrginationName + "'" +
- ",N'" + HViewName + "',N'" + HBillSubType + "'," + HInterID + "," + HItemID, "h_p_getHBarCodePrintCode_CPCL");
+ ",N'" + HBillSubType + "'," + HInterID + "," + HItemID, "h_p_getHBarCodePrintCode_CPCL");
if((int)ds.Tables[0].Rows[0]["resultType"] == 1)
{
string resultMesg = ds.Tables[0].Rows[0]["payload"].ToString().Replace("\\r\\n", "\r\n");
@@ -2523,64 +2538,86 @@
{
try
{
- SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
- //鏌ヨ鏉$爜淇℃伅
- if (HBarCodeNo != null)
+ if (string.IsNullOrWhiteSpace(HBarCodeNo))
{
- string prefix = HBarCodeNo.Trim() + "-";
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "璇疯緭鍏ユ潯鐮佺紪鍙�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
- ds = oCn.RunProcReturn("SELECT * FROM h_v_Gy_SplitBarCode WITH(NOLOCK) WHERE HBarCode LIKE '" + prefix + "' + '%' AND HBarCode NOT LIKE '" + prefix + "' + '%-%' AND ISNUMERIC(RIGHT(HBarCode, LEN(HBarCode) - LEN( '" + prefix + "' ))) = 1 AND TRY_CAST(RIGHT(HBarCode, LEN(HBarCode) - LEN( '" + prefix + "' )) AS INT) IS NOT NULL ", "Gy_BarCodeBill");
- if (ds != null || ds.Tables[0].Rows.Count >= 0)
+ // 鍘荤┖鏍�
+ string cleanBarCode = HBarCodeNo.Trim();
+ string prefix = cleanBarCode + "-"; // 鐢ㄤ簬鏌ュ瓙鐮�
+
+ SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+
+ // 1. 鍏堟煡鐩存帴瀛愮爜锛堜竴绾у瓙鐮侊細xxx-1, xxx-2, ...锛�
+ string sqlSub = @"SELECT * FROM h_v_Gy_SplitBarCode WITH(NOLOCK) WHERE HBarCode LIKE '" + prefix + @"%'
+ AND HBarCode NOT LIKE '" + prefix + @"%-%'
+ AND ISNUMERIC(RIGHT(HBarCode, LEN(HBarCode) - LEN('" + prefix + @"'))) = 1
+ AND TRY_CAST(RIGHT(HBarCode, LEN(HBarCode) - LEN('" + prefix + @"')) AS INT) IS NOT NULL";
+
+ DataSet ds = oCn.RunProcReturn(sqlSub, "Gy_BarCodeBill");
+
+ // 2. 濡傛灉鏈夊瓙鐮� 鈫� 杩斿洖瀛愮爜 + 涓嬩竴涓紪鍙�
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ int maxSuffix = 0;
+ foreach (DataRow row in ds.Tables[0].Rows)
{
- // 鎵惧嚭鏈�澶у悗缂�鏁板瓧锛岀敤浜庣敓鎴愪笅涓�涓紪鍙�
- int maxSuffix = 0;
- foreach (DataRow row in ds.Tables[0].Rows)
- {
- string barCode = row["HBarCode"].ToString();
- string suffixPart = barCode.Substring(prefix.Length); // 鍙� - 鍚庣殑閮ㄥ垎
- if (int.TryParse(suffixPart, out int num))
- {
- if (num > maxSuffix) maxSuffix = num;
- }
- }
+ string barCode = row["HBarCode"].ToString();
+ string suffix = barCode.Substring(prefix.Length);
+ if (int.TryParse(suffix, out int num) && num > maxSuffix)
+ maxSuffix = num;
+ }
- // 鐢熸垚涓嬩竴涓瓙鐮佺紪鍙�
- string nextBarCode = $"{HBarCodeNo}-{maxSuffix + 1}";
+ string nextBarCode = $"{cleanBarCode}-{maxSuffix + 1}";
+ objJsonResult.code = "1";
+ objJsonResult.count = ds.Tables[0].Rows.Count;
+ objJsonResult.Message = "鏌ヨ鎴愬姛锛岃繑鍥炵洿鎺ュ瓙鐮�";
+ objJsonResult.data = new
+ {
+ SubBarCodes = ds.Tables[0],
+ NextBarCode = nextBarCode
+ };
+ }
+ else
+ {
+ // 3. 娌℃湁瀛愮爜 鈫� 鏌ヨ嚜宸�
+ string sqlSelf = @"SELECT * FROM h_v_Gy_SplitBarCode WITH(NOLOCK) WHERE HBarCode = '" + cleanBarCode.Replace("'", "''") + "'";
+
+ DataSet dsSelf = oCn.RunProcReturn(sqlSelf, "Gy_BarCodeBill");
+
+ if (dsSelf != null && dsSelf.Tables[0].Rows.Count > 0)
+ {
objJsonResult.code = "1";
objJsonResult.count = 1;
- objJsonResult.Message = "Sucess锛�";
+ objJsonResult.Message = "璇ユ潯鐮佹棤瀛愮爜锛岃繑鍥炶嚜韬�";
objJsonResult.data = new
{
- SubBarCodes = ds.Tables[0], // 鏉$爜鍩虹淇℃伅
- NextBarCode = nextBarCode // 涓嬩竴涓敓鎴愮殑鏉$爜
+ SubBarCodes = dsSelf.Tables[0],
+ NextBarCode = $"{cleanBarCode}-1" // 寤鸿浠� -1 寮�濮�
};
- return objJsonResult;
}
else
{
objJsonResult.code = "0";
objJsonResult.count = 0;
- objJsonResult.Message = "鏉$爜缂栧彿涓嶅瓨鍦�, 鎻愮ず";
+ objJsonResult.Message = "鏉$爜涓嶅瓨鍦紝璇锋鏌�";
objJsonResult.data = null;
- return objJsonResult;
- }
+ }
}
- else
- {
- objJsonResult.code = "0";
- objJsonResult.count = 0;
- objJsonResult.Message = "璇疯緭鍏ユ潯鐮佺紪鍙锋垨鎷嗗垎鏉$爜鏁�";
- objJsonResult.data = null;
- return objJsonResult;
- }
-
+
+ return objJsonResult;
}
- catch (Exception e) //鎶涘嚭寮傚父
+ catch (Exception ex)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
- objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.Message = "寮傚父锛�" + ex.Message;
objJsonResult.data = null;
return objJsonResult;
}
@@ -2713,6 +2750,63 @@
}
#endregion
+ #region [鏉$爜鐢熸垚鎺ュ彛_灏忓崼闀洉鐮乚
+ [Route("Sc_BarCode/SaveSNByICMO_XW")]
+ [HttpGet]
+ public object SaveSNByICMO_XW(String HBillNo,string HSN, int HBeginNo, int HEndNo, int HCount,string HMachineCode)
+ {
+ try
+ {
+ if(oWebs.GetWebAPIToLocal_ICMO(HBillNo, "3710", "admin", ref DBUtility.ClsPub.sErrInfo)==false)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "[0000-2-020]鍗曟嵁鍚屾澶辫触璇疯仈绯荤鐞嗗憳,"+ DBUtility.ClsPub.sErrInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ ds = oCN.RunProcReturn("exec h_p_WMS_SaveSNByICMO_XW '" + @HBillNo + "', " + HSN +","+HBeginNo+","+HEndNo+","+HCount+",'"+HMachineCode+"'", "h_p_WMS_SaveSNByICMO_XW");
+
+ if (ds == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "[0000-2-020]娌℃湁杩斿洖浠讳綍缁撴灉,鏉$爜淇濆瓨澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "[0000-2-020]鏉$爜缁戝畾澶辫触锛�"+ ds.Tables[0].Rows[0]["HRemark"].ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "[0000-1-037]鏉$爜鐢熸垚鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+
+
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "[3899-2-006]鏉$爜鐢熸垚澶辫触!" + e.Message;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
#endregion
}
}
\ No newline at end of file
--
Gitblit v1.9.1