From 9fc253e4b7c5d77082ca8d71213e6cf351ca28e9 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期五, 05 九月 2025 16:23:17 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/仓存管理/条码生成/Sc_BarCodeController.cs | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 305 insertions(+), 1 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 7a75ca8..6cbbd57 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"
@@ -6,9 +6,11 @@
using System;
using System.Collections.Generic;
using System.Data;
+using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
+using System.Web;
using System.Web.Http;
using WebAPI.Models;
@@ -526,6 +528,8 @@
return ordrlist;
}
+
+
public object HSourceOrderList1(DataTable dt, HSouceOrderList ordrlist, string HBarCodeType,string HSourceBillType)
{
oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo);
@@ -902,6 +906,9 @@
string HCusMaterName = ""; //瀹㈡埛鐗╂枡鍚嶇О
string HCheckEmpName = ""; //妫�楠屽憳鍚嶇О
+ string HSupNumber = ""; // 渚涘簲鍟嗙紪鐮�
+ string HPOInStockBillNo = ""; // 鏀舵枡閫氱煡鍗曞彿
+
DataSet Ds;
msg2 = msg2.Replace("\\", "");
msg2 = msg2.Replace("\n", ""); //\n
@@ -949,6 +956,9 @@
HICMOBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HSourceBillNo); //鐢熶骇璁㈠崟鍙凤紙澶忓疂鐢靛櫒锛�
HBarCodeBatchNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HPinfanBarCode); //鏉$爜鎵规鍙凤紙澶忓疂鐢靛櫒锛�
HBarCodeDate = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber); //鏉$爜鏃ユ湡锛堝瀹濈數鍣級
+
+ HPOInStockBillNo = DBUtility.ClsPub.isStrNull(ordrlist[j].HBillNo); // 鏀舵枡閫氱煡鍗曞彿 鍏磋揪鏉$爜
+ HSupNumber = DBUtility.ClsPub.isStrNull(ordrlist[j].HSupNumber);// 渚涘簲鍟嗙紪鍙� 鍏磋揪鏉$爜
//
sYear = ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
sPeriod = "0" + ClsPub.isDate(sDate).Month.ToString();
@@ -1048,6 +1058,17 @@
Ds = oCN.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo"); //鑾峰彇鏈�澶ф祦姘村彿
LSH = ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
}
+ }
+ else if (CampanyName.Contains("鍏磋揪"))
+ {
+
+ // 鍏磋揪鏉$爜
+ //鏉$爜鍓嶇紑 = 鏀舵枡閫氱煡鍗曞彿 + 渚涘簲鍟嗙紪鐮� + 骞� + 鏈� + 鏃� + 3浣嶆祦姘村彿
+
+ sTMNumber = HPOInStockBillNo + "@" + HSupNumber + "@" + sYear + sPeriod + sDay;
+ 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 //閫氱敤鏂规硶
{
@@ -1647,7 +1668,10 @@
",@HFactory = N'" + HFactory + "'" +
",@HCoilNO = N'" + HCoilNO + "'" +
",@HFurnaceNO = N'" + HFurnaceNO + "'" +
- ",@HInnerBillNo = N'" + ordrlist[0].HInnerBillNo + "'"
+ ",@HInnerBillNo = N'" + ordrlist[0].HInnerBillNo + "'" +
+ ",@HSourceBillType = N'" + ordrlist[0].HBillType + "'" +
+ ",@HStockOrg = N'" + HOrgType + "'" +
+ ",@HInterID = N'" + ordrlist[0].HInterID + "'"
, "h_p_SC_BarCode_Transfer");
if((bool)ds1.Tables[0].Rows[0]["returntype"] == true)
{
@@ -1670,6 +1694,283 @@
return objJsonResult;
}
return objJsonResult;
+ }
+ #endregion
+
+ #region 鏉$爜杞瓨鏉$爜涓绘。(鎵归噺)
+ /// <summary>
+ /// 鏉$爜杞瓨鏉$爜涓绘。(鎵归噺)
+ /// </summary>
+ /// <param name="msg"></param>
+ /// <returns></returns>
+ [Route("Sc_BarCode/SaveBarCode_NoGenerate_Batch")]
+ [HttpPost]
+ public object SaveBarCode_NoGenerate_Batch([FromBody] JObject msg)
+ {
+ try
+ {
+ var _value = msg["msg"].ToString();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.None);
+ string msg2 = sArray[0].ToString();
+ string HOrgType = sArray[1].ToString();
+ string HSourceBillTypeName = sArray[2].ToString();
+ string HSelectBarCodeType = sArray[3].ToString();
+ string CampanyName = sArray[4].ToString() == "xxx" ? "" : sArray[4].ToString();
+ string UserName = sArray[5].ToString();
+ string barCodeNoStrs = sArray[6].ToString(); // 杩欓噷鐨勬潯鐮佹槸涓庢彁浜ょ殑鍗曟嵁搴忓垪瀵瑰簲鐨勬潯鐮佹暟缁�
+ string HFactory = sArray[7].ToString();
+ string HCoilNO = sArray[8].ToString();
+ string HFurnaceNO = sArray[9].ToString();
+ ClsPub.CurUserName = UserName;
+
+ //鑾峰彇鍐呯爜
+ HInterID = DBUtility.ClsPub.CreateBillID_Prod(ModName, ref DBUtility.ClsPub.sExeReturnInfo);
+ DAL.ClsGy_ORGANIZATIONS_View oClsGy_ORGANIZATIONS_View = new DAL.ClsGy_ORGANIZATIONS_View();
+ HOrgNumber = "";
+ if (oClsGy_ORGANIZATIONS_View.GetInfoByName(HOrgType))
+ {
+ HOrgID = oClsGy_ORGANIZATIONS_View.omodel.HItemID;
+ HOrgNumber = DBUtility.ClsPub.isStrNull(oClsGy_ORGANIZATIONS_View.omodel.HNumber);
+ }
+ if (HOrgID == -1)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "[0000-2-055]閫夋嫨缁勭粐鏈夐敊璇�!";
+ return objJsonResult;
+ }
+ if (!Sub_AllowSave(msg2, HSelectBarCodeType))//鍗曟嵁瀹屾暣鎬у垽鏂�
+ {
+ return objJsonResult;
+ }
+ if (HSelectBarCodeType == "浠櫒鎴愬搧鏉$爜瑙勫垯")
+ {
+ //瀹㈡埛瀹氬埗
+ }
+ else
+ {
+ string HBarCodeType = ClsPub.isStrNull(HSelectBarCodeType);
+ // 鏉$爜杞瓨
+ msg2 = msg2.Replace("\\", "");
+ msg2 = msg2.Replace("\n", ""); //\n
+ List<HSouceOrderList> ordrlist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HSouceOrderList>>(msg2);
+ List<string> barcodeList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(barCodeNoStrs);
+ // TODO 閫氳繃InterID 鍜� EntryID 浠庢潯鐮佹。妗堜腑鏌ヨ鏄惁鏈夊凡鐢熸垚鐨勫崟鎹� 閲嶆柊鍐欎竴涓瓨鍌ㄨ繃绋嬶紝褰撳凡瀛樺湪瀵瑰簲鐨勬潯鐮佸崟鎹椂锛岃繑鍥炴潯鐮佷富妗d腑鐨勬潯鐮佹。妗�
+ DataSet dsCache = oCN.RunProcReturn($@"select * from h_v_IF_BarCodeBillList a
+ Inner Join Gy_BarCodeBill b on a.HItemID = b.HItemID
+ where b.HSourceINterID = { ordrlist[0].HMainID } and b.HSourceEntryID = {ordrlist[0].HSubID}"
+ , "h_v_IF_BarCodeBillList");
+ if(dsCache.Tables[0].Rows.Count > 0)
+ {
+ objJsonResult.code = "2";
+ objJsonResult.count = 1;
+ objJsonResult.data = dsCache.Tables[0];
+ objJsonResult.Message = "鏉$爜宸插瓨鍦�!";
+ return objJsonResult;
+ }
+ DataSet ds1 = new DataSet();
+ for(int i=0; i<ordrlist.Count; i++)
+ {
+
+ long HSourceInterID = string.IsNullOrEmpty(ordrlist[i].HMainID) == true ? 0 : ClsPub.isLong(ordrlist[0].HMainID);
+ long HSourceEntryID = string.IsNullOrEmpty(ordrlist[i].HSubID) == true ? 0 : ClsPub.isLong(ordrlist[0].HSubID);
+
+ ds1 = oCN.RunProcReturn("exec h_p_SC_BarCode_Transfer " +
+ "@HBarCodeNo = N'" + barcodeList[i] + "'" +
+ ",@HSubID = " + ordrlist[i].HSubID +
+ ",@HMaterID = " + ordrlist[i].HMaterID +
+ ",@HGiveAwayFlag = " + ordrlist[i].HGiveAwayFlag +
+ ",@HQty = " + ordrlist[i].HQty +
+ ",@HUnitID = " + ordrlist[i].HUnitID +
+ ",@HMinQty = " + ordrlist[i].HMinQty +
+ ",@HSupID = " + ordrlist[i].HSupID +
+ ",@HBatchNo = N'" + ordrlist[i].HBatchNo + "'" +
+ ",@HMTONO = N'" + ordrlist[i].HMTONo + "'" +
+ ",@HBarCodeDate = N'" + ordrlist[i].HDate + "'" +
+ ",@HEmpID = " + ordrlist[i].HEmpID +
+ ",@HSourceInterID = " + HSourceInterID +
+ ",@HSourceEntryID = " + HSourceEntryID +
+ ",@HBarCodeType = N'" + HBarCodeType + "'" +
+ ",@HSourceBillNo = N'" + ordrlist[i].HSourceBillNo + "'" +
+ ",@HMaker = N'" + ordrlist[i].HMaker + "'" +
+ ",@HFactory = N'" + HFactory + "'" +
+ ",@HCoilNO = N'" + HCoilNO + "'" +
+ ",@HFurnaceNO = N'" + HFurnaceNO + "'" +
+ ",@HInnerBillNo = N'" + ordrlist[i].HInnerBillNo + "'" +
+ ",@HSourceBillType = N'" + ordrlist[i].HBillType + "'" +
+ ",@HStockOrg = N'" + HOrgType + "'" +
+ ",@HInterID = " + ordrlist[i].HInterID
+ , "h_p_SC_BarCode_Transfer");
+ if ((bool)ds1.Tables[0].Rows[0]["returntype"] == false)
+ {
+ throw new Exception(ds1.Tables[0].Rows[0]["mesg"].ToString());
+ }
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = ds1.Tables[0].Rows[0]["mesg"].ToString();
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "[3899-2-006]鏉$爜鐢熸垚澶辫触!" + e.Message;
+ return objJsonResult;
+ }
+ return objJsonResult;
+ }
+ #endregion
+
+ #region 鏇存柊鏉$爜 瀵瑰簲鍗曟嵁 鍗曞彿 娆℃暟 鏃堕棿
+ public class BarCodeMeta
+ {
+ public string HBarCode { get; set; }
+ public string HBatchNo { get; set; }
+ public string HMaterModel { get; set; }
+ public string HMaterName { get; set; }
+ public float HQty { get; set; }
+ public string HSCSPName { get; set; }
+ public string HSCWHName { get; set; }
+ public string HSPName { get; set; }
+ public float HTMQty { get; set; }
+ public string HUnitName { get; set; }
+ public string HWHName { get; set; }
+ }
+
+ [Route("Sc_BarCode/Set_BarCodeBill")]
+ [HttpPost]
+ public object Set_BarCodeBill([FromBody] JObject msg)
+ {
+
+ var _value = msg["msg"].ToString();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.None);
+ string msg2 = sArray[0].ToString();
+ string HBillType = sArray[1].ToString();
+ string HBillNo = sArray[2].ToString();
+
+ List<BarCodeMeta> BarCodeMetaList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BarCodeMeta>>(msg2);
+ 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");
+ }
+ }
+
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "";
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇敼澶辫触!" + e.Message;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region [鑾峰彇鏍囩鎵撳嵃鎸囦护 CPCL鎸囦护]
+ [Route("Sc_BarCode/Get_BarCodePrintCode_CPCL")]
+ [HttpGet]
+ public object Get_BarCodePrintCode_CPCL(string HOrginationName, string HViewName, 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");
+ if((int)ds.Tables[0].Rows[0]["resultType"] == 1)
+ {
+ string resultMesg = ds.Tables[0].Rows[0]["payload"].ToString().Replace("\\r\\n", "\r\n");
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = resultMesg;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎵撳嵃鎸囦护鑾峰彇澶辫触!" + ds.Tables[0].Rows[0]["payload"];
+ return objJsonResult;
+ }
+ }
+ catch(Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎵撳嵃鎸囦护鑾峰彇澶辫触!" + e.Message;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region [APP 鑾峰彇鎵撳嵃妯℃澘]
+ public class PrintTemplate
+ {
+ public int Id { get; set; }
+ public string OrgShort { get; set; }
+ public string HBillSubtype { get; set; }
+ public string Format { get; set; }
+ public string Description { get; set; }
+ public string[] Placeholder { get; set; }
+ }
+
+ [Route("Sc_BarCode/Get_BarCodeGenTemplate")]
+ [HttpGet]
+ public object Get_BarCodeGenTemplate(string HOrginationName, string HBillSubType)
+ {
+ try
+ {
+
+ string filePath = HttpContext.Current.Server.MapPath("~/Template");
+ string fileFullPath = Path.Combine(filePath, "barCodeTemplateStorage.json");
+
+ if (!File.Exists(fileFullPath))
+ {
+
+ throw new Exception($"妯℃澘鏂囦欢涓嶅瓨鍦細{fileFullPath}");
+ }
+
+ string jsonContent = File.ReadAllText(fileFullPath);
+ PrintTemplate[] templates = JsonConvert.DeserializeObject<PrintTemplate[]>(jsonContent);
+ PrintTemplate targetTemplate = templates.FirstOrDefault<PrintTemplate>(t => HOrginationName.Contains(t.OrgShort) && string.Equals(t.HBillSubtype, HBillSubType));
+ if (targetTemplate != null)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.data = JsonConvert.SerializeObject(targetTemplate);
+ return objJsonResult;
+ }
+ else
+ {
+ throw new Exception($"娌℃湁鎵惧埌瀵瑰簲鐨勬ā鏉�");
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎵撳嵃妯℃澘鑾峰彇澶辫触!" + e.Message;
+ return objJsonResult;
+ }
}
#endregion
@@ -2175,6 +2476,9 @@
//澧炲姞 鏉$爜瓒呰繃鏈敓鎴愬姛鑳芥帶鍒�
//
+ //鑷姩瑁呯
+ string sql_autoForBoxBill = "exec h_v_Gy_BarCode_AutoProductBarCodeBox " + HInterID.ToString();
+ oCN.RunProc(sql_autoForBoxBill);
oCN.Commit();
List<Object> listobj = ListRows.ConvertAll(s => (object)s);//List瀹炰綋绫昏浆鎹负object
--
Gitblit v1.9.1