From bbba888f3bca270b476ab2a3606f51089dac071c Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期二, 09 九月 2025 14:17:15 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs | 336 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 336 insertions(+), 0 deletions(-)
diff --git a/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs b/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs
new file mode 100644
index 0000000..debdad8
--- /dev/null
+++ b/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs
@@ -0,0 +1,336 @@
+锘縰sing DBUtility;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using SQLHelper;
+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 System.Web.Script.Serialization;
+using WebAPI.Code;
+using WebAPI.Models;
+using WebAPI.Utility;
+
+namespace WebAPI.Controllers
+{
+ public class SRM_MaterialBarCodeBillController : ApiController
+ {
+ private JsonResult objJsonResult = new JsonResult();
+ private json objjson = new json();
+ public new ClsCN oCn = new ClsCN();
+ //鑾峰彇绯荤粺鍙傛暟
+ Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+ // GET: SRM_MaterialBarCodeBill
+ #region 鏉$爜鎵归噺鐢熻景
+ [Route("GetSRMHBarCodeShowBillMain")]
+ public object GetSRMHBarCodeShowBillMain(string HInterID)
+ {
+ try
+ {
+ DataSet ds;
+ string s = "";
+ string ShowItem = " * ";//鏄剧ず鐨勫瓧娈�
+ //if (DBUtility.ClsPub.isLong(HInterID) == 0)
+ //{
+ // objjson.code = "0";
+ // objjson.count = 0;
+ // objjson.Message = "鑾峰彇澶辫触";
+ // objjson.data = null;
+ // return objjson;
+ //}
+ DAL.ClsWeb_BarCodeBill oClsWeb_BarCodeBill = new DAL.ClsWeb_BarCodeBill();
+ //string sql = string.Format(@"select * from h_v_Cg_POOrderBillMain_ForWeb2 where HInterID = " + sMsg);
+ string sql = string.Format(@"select * from h_v_SRM_BarCodeBill where HItemID in ( " + HInterID + ")");
+ ds = oCn.RunProcReturn(sql, "h_v_SRM_BarCodeBill");
+ //ds = oClsWeb_BarCodeBill.ShowBillMain1(DBUtility.ClsPub.isLong(sMsg), ShowItem, ref DBUtility.ClsPub.sExeReturnInfo);
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objjson.code = "0";
+ objjson.count = 0;
+ objjson.Message = "鑾峰彇澶辫触";
+ objjson.data = null;
+ return objjson;
+ }
+ else
+ {
+
+ objjson.code = "0";
+ objjson.count = 10000;
+ objjson.Message = "鑾峰彇鎴愬姛";
+ objjson.data = ds.Tables[0];
+ return objjson;
+ }
+ }
+ catch (Exception e)
+ {
+ objjson.code = "0";
+ objjson.count = 0;
+ objjson.Message = "鑾峰彇澶辫触" + e.ToString();
+ objjson.data = null;
+ return objjson;
+ }
+ }
+ #endregion
+
+ #region 鏉$爜淇濆瓨
+ [Route("SRM_MaterialBarCodeBillController/GetBarcodeSaveBillBoxBycg")]
+ [HttpPost]
+ /// <summary>
+ /// 鐢熸垚鏉$爜
+ /// </summary>
+ /// <param name="msg"></param>
+ /// <param name="msg2"></param>
+ /// <returns></returns>
+ public object GetBarcodeSaveBillBoxBycg([FromBody] JObject msg)
+ {
+ string FCusName = oSystemParameter.GetSingleSystemParameter("WMS_CampanyName", ref DBUtility.ClsPub.sExeReturnInfo);
+ var _value = msg["msg"].ToString();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();//
+ string msg3 = sArray[1].ToString();//
+ string UserName = "";
+ ListModels oListModels = new ListModels();
+ try
+ {
+ #region 鑾峰彇鐢ㄦ埛浠ュ強鐩稿叧鍙傛暟
+ List<Model.Cls_MaterialHandingModel> lsmain = new List<Model.Cls_MaterialHandingModel>();
+ msg2 = msg2.Replace("\\", "");
+ msg2 = msg2.Replace("\n", ""); //\n
+ lsmain = oListModels.getObjectByJson_MaterialHanding(msg2);
+ int get_BarCodecount = 0;
+ foreach (Model.Cls_MaterialHandingModel oItem in lsmain)
+ {
+ get_BarCodecount++;
+ UserName = oItem.HMaker;
+ }
+ DAL.ClsWeb_BarCodeBill oBill = new DAL.ClsWeb_BarCodeBill();
+ msg3 = msg3.Substring(1, msg3.Length - 2);
+ msg3 = msg3.Replace("\\", "");
+ msg3 = msg3.Replace("\n", ""); //\n
+ #endregion
+ List<Model.ClsGy_MaterialBarCodeBillModel> ls = new List<Model.ClsGy_MaterialBarCodeBillModel>();
+
+ ls = oListModels.getObjectByJson_BarCodeBill(msg3);//鍒楄〃鏁版嵁model
+
+
+ #region 鏁版嵁鍑嗗
+ long linterid = Pub_Class.ClsPub.CreateBillID_SRMProd("8888", ref DBUtility.ClsPub.sExeReturnInfo);
+ int LSHlen = 6; //娴佹按鍙烽暱搴�
+ int SumLen = 10; //鎬婚暱搴�
+ string TM = ""; //鏉$爜
+ double HSumQty = 0; //浜у搧鏁伴噺
+ int LSH = 0; //娴佹按鍙�
+ string LSH2 = ""; //娴佹按鍙疯浆鎹㈡垚瀛楃
+ string sDate = ""; //鏃ユ湡
+ string sYear = ""; //骞�
+ string sPeriod = ""; //鏈�
+ string sDay = ""; //鏃�
+ string WeiShu = ""; //灏炬暟
+ string HKFDQDate= ls[0].HKFDQDate;//鍒版湡鏃ユ湡
+ long HKFPeriod= (ls[0].HKFPeriod.ToString()==""?0: ls[0].HKFPeriod);//淇濊川鏈�
+ string HKFDate= ls[0].HKFDQDate==null? DateTime.Now.ToString("yyyy/MM/dd"): ls[0].HKFDQDate;//鐢熶骇鏃ユ湡
+ string HKFDate_1 = string.Join("", HKFDate.Split('/').Select(x => x.PadLeft(2, '0')));
+ double HMinQty= ls[0].HMinQty;//鏍囧噯鍖呰鏁�
+
+ double HBQty= ls[0].HBQty;//鏈�灏忓寘瑁呮暟
+ long HISKFPERIOD= ls[0].HISKFPERIOD;//鏄惁鍚敤淇濊川鏈�
+ long HBatchManager= ls[0].HBatchManager;//鏄惁鍚敤鎵瑰彿
+
+ string HSourceBillType= ls[0].HSourceBillType;//鏉$爜绫诲瀷
+
+ string HBatchNo= ls[0].HBatchNo==null?"": ls[0].HBatchNo;//鎵瑰彿
+ //鐗╂枡
+ long HMaterID=ls[0].HMaterID;
+ string HMaterNumber= ls[0].HMaterNumber;
+ string HMaterShortNumber = ls[0].HMaterShortNumber;
+ string HMaterName = ls[0].HMaterName;
+ //渚涘簲鍟�
+ long HSupID= ls[0].HSupID;
+ string HSupName= ls[0].HSupName;
+ string HMaker= ls[0].HMaker;
+ DateTime HMakeDate= ls[0].HMakeDate;
+ double HQty= ls[0].HQty; //鏈鐢熸垚鏉$爜鏁伴噺
+ double biaoqianzhangshu= ls[0].biaoqianzhangshu;
+ //娴佹按鍙�
+ DataSet Ds;
+ SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+ oCn.BeginTran();
+ Ds = oCn.RunProcReturn("exec GetLSH '" + DateTime.Today + "'", "GetLSH");
+ LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
+ #endregion
+
+ foreach (Model.ClsGy_MaterialBarCodeBillModel oItemSub in ls)
+ {
+ //鏁伴噺涓�0 璺宠繃
+ if (oItemSub.HQty == 0 || oItemSub.HMinQty == 0 )
+ continue;
+ if(oItemSub.HBatchManager!=0&&oItemSub.HBatchNo=="")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "宸插惎鐢ㄦ壒鍙凤紝鎵瑰彿涓嶈兘涓虹┖锛岃鏍稿";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oItemSub.HISKFPERIOD != 0 && oItemSub.HKFPeriod == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "宸插惎鐢ㄤ繚璐ㄦ湡锛屼繚璐ㄦ湡涓嶈兘涓�0锛岃鏍稿";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ string sql = "";
+ //鏍¢獙鎵瑰彿 鍜� 鐢熶骇鏃ユ湡
+ //string sql = $"select top 1 HKFDate from Gy_BarCodeBill where HSupID = '{oItemSub.HSupID}' and HBatchNo = '{HBatchNo.TrimStart().TrimEnd()}' and HMaterID ={oItemSub.HMaterID} and isnull(HKFDate, '') <> ''";
+ //LogService.Write($"sql:{sql}");
+ //DataTable dt = oCn.RunProcReturn(sql, "tables").Tables[0];
+ //if (dt.Rows.Count > 0)
+ //{
+ // LogService.Write($"HKFDate:{dt.Rows[0][0]}");
+ // sql = $"select DATEDIFF(D,{dt.Rows[0][0]},{HKFDate})";
+ // DataSet ds = oCn.RunProcReturn(sql, "tables2");
+ // LogService.Write($"DATEDIFF:{Convert.ToInt32(ds.Tables[0].Rows[0][0])}");
+ // if (ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 0)
+ // {
+ // objJsonResult.code = "0";
+ // objJsonResult.count = 0;
+ // objJsonResult.Message = $"鐗╂枡缂栫爜{oItemSub.HMaterNumber}锛屾壒鍙穥oItemSub.HBatchNo.TrimStart().TrimEnd()},鐢熶骇鏃ユ湡涓簕dt.Rows[0][0]},璇锋牳瀵�";
+ // objJsonResult.data = null;
+ // return objJsonResult;
+ // }
+ //}
+ if (ClsPub.isLong(oItemSub.HMaterID) != 0)
+ {
+
+ HMaterID = oItemSub.HMaterID;//鐗╂枡浠g爜
+ HQty = ClsPub.isDoule(oItemSub.HQty);//鏈鐢熸垚鏉$爜鏁伴噺
+ HBQty = ClsPub.isInt(oItemSub.HBQty);//鏈�灏忓寘瑁呮暟锛堝唴绠辨暟锛�
+ HMinQty = ClsPub.isDoule(oItemSub.HMinQty);//鏍囧噯鍖呰鏁�
+ int virtualCount = 1;//瀹為檯涓婃彃鍏ユ暟閲�
+ // HSumQty = ClsPub.isDoule(oItemSub.HQty); //浜у搧鏁伴噺
+ for (int i = 0; i < biaoqianzhangshu; i++)
+ {
+ ///渚涘簲鍟嗗悕绉�+@+鐗╂枡浠g爜+@+鐗╂枡绠�绉�+@+鏁伴噺+@+鏃ユ湡+@+娴佹按鍙�
+ LSH += 1;
+ TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{oItemSub.biaoqianzhangshu}@{HKFDate_1}@{LSH}";
+ Model.ClsGy_BarCodeBill_WMS_Model bar = new Model.ClsGy_BarCodeBill_WMS_Model();
+
+ // var HBarCode_verify = TM.Split('@'); //鏍¢獙鏉$爜淇℃伅
+ // var HMaterNumber_verify = HBarCode_verify[0]; //鏍¢獙鐗╂枡缂栫爜
+ // var HMaterName_verify = HBarCode_verify[1]; //鏍¢獙鐗╂枡鍚嶇О
+ // //var HMaterModel_verify = HBarCode_verify[2]; //鏍¢獙瑙勬牸鍨嬪彿
+ // var HSupName_verify = HBarCode_verify[7]; //鏍¢獙渚涘簲鍟�
+ //// var HSourceBillNo_verify = HBarCode_verify[8]; //鏍¢獙閲囪喘璁㈠崟鍙�
+
+ // sql = $"select * from Gy_Material where HNumber = '{HMaterNumber_verify}' and HName = '{HMaterName_verify}'";
+ // DataSet verifyMatInfo = oCn.RunProcReturn(sql, "tables");
+
+
+ // sql = $"select * from Gy_Supplier where HName = '{HSupName_verify}'";
+ // DataSet verifySupInfo = oCn.RunProcReturn(sql, "tables");
+ string HBarCodeType = "鍞竴鏉$爜";
+ //sql = "insert into Gy_BarCodeBill (HInterID,HBarCode,HBarCodeType,HMaterID,HUnitID,HQty,HKFDate,HKFPeriod,HKFDQDate" +
+ // ",HBatchNo,HBarcodeQtys,HBarcodeNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HEndQty,HSupflag" +
+ // ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HMTONO,HProduceDate,HExpiryDate,HISKFPERIOD" +
+ // ") values ("
+ // + linterid.ToString() + ",'" + TM + "','" + HBarCodeType + "'," + HMaterID + "," + "" + "," + HQty + ",'" + HKFDate + "'," + HKFPeriod + ",'" + HKFDQDate
+ // + "','" + HBatchNo + "','" + get_BarCodecount + "','" + virtualCount + "'," + HSupID + "," + "" + ",'" + ClsPub.CurUserName + "','" + DateTime.Today + "'," + "1" + ",'" + DateTime.Today + "',1"
+ // + "," + "1" + "," + "1" + ",'" + "1" + "','" + HSourceBillType + "','" + "1" + "','"
+ // + HKFDate + "','" + HKFDQDate + "'," + HISKFPERIOD + ")";
+ sql = "INSERT INTO Gy_BarCodeBill (HInterID, HBarCode, HBarCodeType, HMaterID, HUnitID, HQty, HKFDate, HKFPeriod, HKFDQDate, " +
+ "HBatchNo, HBarcodeQtys, HBarcodeNo, HSupID, HGroupID, HMaker, HMakeDate, HPrintQty, HEndQty, HSupflag, " +
+ "HSourceInterID, HSourceEntryID, HSourceBillNo, HSourceBillType, HMTONO, HProduceDate, HExpiryDate, HISKFPERIOD) " +
+ "VALUES (" +
+ linterid.ToString() + ", '" + TM + "', '" + HBarCodeType + "', " + HMaterID + ", " + "0" + ", " + HQty + ", '" + HKFDate + "', " + HKFPeriod + ", '" + HKFDQDate + "', " +
+ "'" + HBatchNo + "', " + get_BarCodecount + ", '" + virtualCount + "', " + HSupID + ", " + "0" + ", '" + ClsPub.CurUserName + "', '" + DateTime.Today.ToString("yyyy-MM-dd") + "', " + "1" + ", " + "0" + ", 1, " +
+ "1, 1, '1', '" + HSourceBillType + "', '1', '" +
+ HKFDate + "', '" + HKFDQDate + "', " + HISKFPERIOD + ")";
+ LogService.Write("鐢熸垚鏉$爜锛� " + sql);
+ oCn.RunProc(sql);
+ oCn.RunProc("exec setLSH '" + DateTime.Today + "'");
+ virtualCount++;
+ }
+
+ }
+ }
+ oCn.Commit();
+
+ }
+ catch (Exception e)
+ {
+ LogService.Write("鐢熸垚鏉$爜鍙戠敓閿欒锛� " + e);
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "" + e.Message + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鐢熸垚鏉$爜鎴愬姛锛�";
+ WebAPIController.Add_Log("鏉$爜涓嬫帹", UserName, "鐢熸垚鏉$爜");
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ #endregion
+
+ #region 鏉$爜鍒楄〃
+ [Route("showHBarCodeBillDetail")]
+ [HttpGet]
+ public object showHBarCodeBillDetail(string sMsg,string Organization)
+ {
+ try
+ {
+ DataSet ds;
+ string s = "";
+ string ShowItem = " * ";//鏄剧ず鐨勫瓧娈�
+ if (sMsg == "")
+ {
+ objjson.code = "0";
+ objjson.count = 0;
+ objjson.Message = "鑾峰彇澶辫触";
+ objjson.data = null;
+ return objjson;
+ }
+ string sql = string.Format(@"select * from h_v_Gy_UserMaterRelationPrint where HItemID in ( " + sMsg)+")";
+ ds = oCn.RunProcReturn(sql, "h_v_Gy_UserMaterRelationPrint");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objjson.code = "0";
+ objjson.count = 0;
+ objjson.Message = "鑾峰彇澶辫触" + DBUtility.ClsPub.sExeReturnInfo;
+ objjson.data = null;
+ return objjson;
+ }
+ else
+ {
+ objjson.code = "0";
+ objjson.count = 1;
+ objjson.Message = "鑾峰彇鎴愬姛锛�";
+ objjson.data = ds.Tables[0];
+ return objjson;
+
+ }
+ }
+ catch (Exception e)
+ {
+ objjson.code = "0";
+ objjson.count = 0;
+ objjson.Message = "鑾峰彇鍗曟嵁琛ㄤ綋澶辫触:" + e.Message;
+ objjson.data = null;
+ return objjson;
+ }
+ }
+ #endregion
+
+
+ }
+}
\ No newline at end of file
--
Gitblit v1.9.1