From 581e0f8eda86f5ad19a5ce03253faf14928c90fa Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 18 九月 2024 18:59:10 +0800
Subject: [PATCH] 关键件绑定
---
WebAPI/ListModels.cs | 24 +++
DAL/车间管理/ClsSc_AssemblyBill.cs | 14 +
WebAPI/WebAPI.csproj | 1
WebAPI/Controllers/CJGL/Sc_KeyElementBindingController.cs | 341 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 375 insertions(+), 5 deletions(-)
diff --git "a/DAL/\350\275\246\351\227\264\347\256\241\347\220\206/ClsSc_AssemblyBill.cs" "b/DAL/\350\275\246\351\227\264\347\256\241\347\220\206/ClsSc_AssemblyBill.cs"
index bd6f57e..dc410b9 100644
--- "a/DAL/\350\275\246\351\227\264\347\256\241\347\220\206/ClsSc_AssemblyBill.cs"
+++ "b/DAL/\350\275\246\351\227\264\347\256\241\347\220\206/ClsSc_AssemblyBill.cs"
@@ -86,7 +86,11 @@
try
{
//寰楀埌mainid
- omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ if (omodel.HInterID == 0 || omodel.HInterID.ToString() == null || omodel.HInterID.ToString() == "undefined")
+ {
+ omodel.HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ }
+
//鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
oCn.BeginTran();
//涓昏〃
@@ -94,12 +98,12 @@
"(HYear,HPeriod,HBillType,HInterID" +
",HDate,HBillNo,HBillStatus,HRemark,HICMOInterID" +
",HICMOBillNo,HBarCode_P,HMaterID,HUnitID" +
- ",HMaker,HMakeDate" +
+ ",HMaker,HMakeDate,HBillSubType" +
") " +
" values(" + omodel.HYear + "," + omodel.HPeriod + ",'" + this.BillType + "'," + omodel.HInterID + "" +
",'" + omodel.HDate + "','" + omodel.HBillNo.ToString() + "'," + omodel.HBillStatus + ",'" + omodel.HRemark + "'," + omodel.HICMOInterID + "" +
",'" + omodel.HICMOBillNo.ToString() + "','" + omodel.HBarCode_P.ToString() + "'," + omodel.HMaterID + "," + omodel.HUnitID + "" +
- ",'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.GetServerDate(-1) + "'" +
+ ",'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.GetServerDate(-1) + "','" + this.BillType + "'" +
") ");
////鎻掑叆瀛愯〃
foreach (Model.ClsSc_AssemblyBillSub oSub in DetailColl)
@@ -108,12 +112,12 @@
" (HInterID,HEntryID,HMaterID,HUnitID,HQty,HSourceID" +
",HEquipID,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P" +
",HCloseMan,HCloseType,HRemark" +
- ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)" +
+ ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HBillNo_bak)" +
" values("
+ omodel.HInterID.ToString() + "," + oSub.HEntryID.ToString() + "," + oSub.HMaterID.ToString() + "," + oSub.HUnitID.ToString() + "," + oSub.HQty.ToString() + "," + oSub.HSourceID.ToString() + "" +
"," + oSub.HEquipID.ToString() + "," + oSub.HGroupID.ToString() + "," + oSub.HWorkerID.ToString() + ",'" + oSub.HScanDate.ToShortDateString() + "','" + oSub.HBarCode + "','" + oSub.HBarCode_P + "'" +
",'" + oSub.HCloseMan + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" +
- "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() +
+ "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + ",'" + omodel.HBillNo + "'" +
") ");
}
sReturn = "鏂板鍗曟嵁鎴愬姛锛�";
diff --git a/WebAPI/Controllers/CJGL/Sc_KeyElementBindingController.cs b/WebAPI/Controllers/CJGL/Sc_KeyElementBindingController.cs
new file mode 100644
index 0000000..0c2d8d3
--- /dev/null
+++ b/WebAPI/Controllers/CJGL/Sc_KeyElementBindingController.cs
@@ -0,0 +1,341 @@
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Pub_Class;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Web.Http;
+using WebAPI.Models;
+
+namespace WebAPI.Controllers
+{
+ public class Sc_KeyElementBindingController : ApiController
+ {
+ Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+ private json objJsonResult = new json();
+ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+ DataSet ds;
+
+ #region 宸ュ簭娴佽浆鍗$淮鎶�-鏌ヨ
+ /// <summary>
+ /// 杩斿洖宸ュ簭娴佽浆鍗$淮鎶ゅ垪琛ㄤ富琛�
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Sc_KeyElementBinding/GetProcessExchangeList")]
+ [HttpGet]
+ public object GetProcessExchangeList(string HBillNo, string user)
+ {
+ try
+ {
+ ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeInfo_ForKeyBind where 娴佽浆鍗″彿 = '" + HBillNo + "'", "h_v_Sc_ProcessExchangeInfo_ForKeyBind");
+
+ if (ds.Tables[0].Rows.Count > 0 && ds != null)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏌ユ棤姝ゆ祦杞崱淇℃伅锛岃鏍稿鏀规祦杞崱鏄惁宸茶鍒犻櫎";
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "寮傚父锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鍏抽敭浠剁粦瀹� 浜у搧鏉$爜瑙f瀽
+ [Route("Sc_KeyElementBinding/ProductBardCode_JX")]
+ [HttpGet]
+ public object ProductBardCode_JX(string HBarCode, string HProcExchBillNo, string HBillNo, string user, int HOrgID)
+ {
+ try
+ {
+ //鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀瓨鍦ㄦ潯鐮佹。妗堝綋涓�
+ ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ //鏉$爜妗f涓病鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽垯鏍规嵁瑙勫垯瑙f瀽鐢熸垚鏉$爜
+ ds = oCN.RunProcReturn(@"exec h_p_Sc_BarCode_JX '" + HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'", "h_p_Sc_BarCode_JX");
+
+ if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "瑙f瀽鏉$爜澶辫触锛岃涓庣鐞嗚仈绯伙紒" + ds.Tables[0].Rows[0]["HBackRemark"] + "==exec h_p_Sc_BarCode_JX '" +HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'";
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ }
+
+ //鏉$爜妗f涓凡鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽尮閰嶇敤鏂欐竻鍗曪紙鎵爜鏁版嵁鍐欏叆涓存椂琛級
+ ds = oCN.RunProcReturn(@"exec h_p_Sc_PPBomBill_Matching '" + HBarCode + "','" + HProcExchBillNo + "','" + HBillNo + "','" + HOrgID + "'", "h_p_Sc_PPBomBill_Matching");
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "";
+ objJsonResult.data = "娌℃湁鏌ヨ鍒版暟鎹�";
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "ERROR锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鍏抽敭浠剁粦瀹� 閰嶄欢鏉$爜瑙f瀽
+ [Route("Sc_KeyElementBinding/PartsBardCode_JX")]
+ [HttpGet]
+ public object PartsBardCode_JX(string HBarCode, string HProcExchBillNo, string HBillNo, string user, int HOrgID)
+ {
+ try
+ {
+ //鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀瓨鍦ㄦ潯鐮佹。妗堝綋涓�
+ ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ //鏉$爜妗f涓病鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽垯鏍规嵁瑙勫垯瑙f瀽鐢熸垚鏉$爜
+ ds = oCN.RunProcReturn(@"exec h_p_Sc_BarCode_JX '" + HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'", "h_p_Sc_BarCode_JX");
+ if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "瑙f瀽鏉$爜澶辫触锛岃涓庣鐞嗚仈绯伙紒" + ds.Tables[0].Rows[0]["HBackRemark"] + "==exec h_p_Sc_BarCode_JX '" + HBarCode + "','" + HProcExchBillNo + "','" + HOrgID + "'";
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ }
+
+ //鏉$爜妗f涓凡鏈夋湰娆℃壂鎻忕殑鏉$爜锛屾煡璇㈤厤浠朵俊鎭紙鎵弿鏉$爜淇℃伅鍐欏叆涓存椂琛級
+ ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBill_Bind '" + HBarCode + "','" + HProcExchBillNo + "','" + HBillNo + "','" + HOrgID + "'", "h_p_Gy_BarCodeBill_Bind");
+
+ if (ds != null && ds.Tables[0].Rows.Count > 0)
+ {
+ if (ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+ objJsonResult.data = "";
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "";
+ objJsonResult.data = "娌℃湁鏌ヨ鍒版暟鎹�";
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "ERROR锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鍏抽敭浠剁粦瀹氫繚瀛� 鏂板/缂栬緫
+ [Route("Sc_KeyElementBinding/Save")]
+ [HttpPost]
+ public object Save([FromBody] JObject msg)
+ {
+ 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 msg4 = sArray[2].ToString(); //鐢ㄦ埛
+
+ DBUtility.ClsPub.CurUserName = msg4;
+
+ string UserName = "";
+ ListModels oListModels = new ListModels();
+ try
+ {
+
+
+ DAL.ClsSc_AssemblyBill oBill = new DAL.ClsSc_AssemblyBill();
+ List<Model.ClsSc_AssemblyBillMain> lsmain = new List<Model.ClsSc_AssemblyBillMain>();
+ msg2 = msg2.Replace("\\", "");
+ msg2 = msg2.Replace("\n", ""); //\n
+ lsmain = oListModels.getObjectByJson_Sc_AssemblyBillMain2(msg2);
+ foreach (Model.ClsSc_AssemblyBillMain oItem in lsmain)
+ {
+ UserName = oItem.HMaker; //鍒跺崟浜�
+ oItem.HBillType = "3727";
+ oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+ oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+ oItem.HBillStatus = 1;
+ oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
+
+ if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ oBill.omodel = oItem;
+ }
+ //琛ㄤ綋鏁版嵁
+ //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+ msg3 = msg3.Substring(1, msg3.Length - 2);
+ msg3 = msg3.Replace("\\", "");
+ msg3 = msg3.Replace("\n", ""); //\n
+ //msg2 = msg2.Replace("'", "鈥�");
+ List<Model.ClsSc_AssemblyBillSub> ls = new List<Model.ClsSc_AssemblyBillSub>();
+ ls = oListModels.getObjectByJson_Sc_AssemblyBillSub2(msg3);
+ int i = 0;
+ foreach (Model.ClsSc_AssemblyBillSub oItemSub in ls)
+ {
+ i++;
+ oItemSub.HEntryID = i;
+
+ oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+ oItemSub.HCloseType = false; //鍏抽棴绫诲瀷
+ oItemSub.HUnitID = 0;
+ oItemSub.HQty = 1;
+
+ oBill.DetailColl.Add(oItemSub);
+ }
+
+ //淇濆瓨
+ //淇濆瓨瀹屾瘯鍚庡鐞�
+ bool bResult;
+ bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+
+
+ if (bResult)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = 0;
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region [鍒犻櫎涓存椂琛ㄦ暟鎹甝
+ [Route("Deltet_Sc_AssemblyBill_BindBarCodeTemp")]
+ [HttpGet]
+ public object Deltet_Sc_AssemblyBill_BindBarCodeTemp(string HBillNo, string HBarCode, string user)
+ {
+ DataSet ds;
+ try
+ {
+ if (string.IsNullOrWhiteSpace(HBillNo) || string.IsNullOrWhiteSpace(HBarCode))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "杩芥函鍗曞彿鎴栭厤浠舵潯鐮佷负绌猴紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ oCN.BeginTran();//寮�濮嬩簨鍔�
+ ds = oCN.RunProcReturn("select * from Sc_AssemblyBill_BindBarCodeTemp where HBillNo_bak = '" + HBillNo + "' and HBarCode = '" + HBarCode + "'", "Sc_AssemblyBill_BindBarCodeTemp");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+ objJsonResult.data = null;
+ return objJsonResult; ;
+ }
+
+
+ oCN.RunProc("delete from Sc_AssemblyBill_BindBarCodeTemp where HBillNo_bak = '" + HBillNo + "' and HBarCode = '" + HBarCode + "'");
+ oCN.Commit();//鎻愪氦浜嬪姟
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "* 鏁版嵁鍒犻櫎鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult; ;
+
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/WebAPI/ListModels.cs b/WebAPI/ListModels.cs
index 3511795..a1b3896 100644
--- a/WebAPI/ListModels.cs
+++ b/WebAPI/ListModels.cs
@@ -4313,6 +4313,30 @@
return list;
}
+ /// <summary>
+ /// 缁勮杩芥函-涓�2
+ /// </summary>
+ /// <param name="jsonString"></param>
+ /// <returns></returns>
+ public List<Model.ClsSc_AssemblyBillMain> getObjectByJson_Sc_AssemblyBillMain2(string jsonString)
+ {
+ jsonString = "[" + jsonString.ToString() + "]";
+ List<Model.ClsSc_AssemblyBillMain> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillMain>>(jsonString);
+ return list;
+ }
+
+ /// <summary>
+ /// 缁勮杩芥函-瀛�2
+ /// </summary>
+ /// <param name="jsonString"></param>
+ /// <returns></returns>
+ public List<Model.ClsSc_AssemblyBillSub> getObjectByJson_Sc_AssemblyBillSub2(string jsonString)
+ {
+ jsonString = "[" + jsonString.ToString() + "]";
+ List<Model.ClsSc_AssemblyBillSub> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSc_AssemblyBillSub>>(jsonString);
+ return list;
+ }
+
///棣栦欢妫�楠屽崟 瀛欒〃
///ClsQC_FirstPieceCheckBillSub_ValueGrid
public List<Model.ClsQC_FirstPieceCheckBillSub_ValueGrid> getObjectByJson_ClsQC_FirstPieceCheckBillSub_ValueGrid(string jsonString)
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index 8d4d4d5..183c549 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -436,6 +436,7 @@
<Compile Include="Controllers\CJGL\Cj_SendGoodsBillController.cs" />
<Compile Include="Controllers\CJGL\Mes_OrderProcFlowAllReportController.cs" />
<Compile Include="Controllers\CJGL\Gy_MaterPreventErrMouldBillController.cs" />
+ <Compile Include="Controllers\CJGL\Sc_KeyElementBindingController.cs" />
<Compile Include="Controllers\SBGL\SBBB\Sb_EquipMentCollectionTechParamController.cs" />
<Compile Include="Controllers\SBGL\SBBB\Sb_EquipMentCollectionTechParam_TempController.cs" />
<Compile Include="Controllers\SCGL\Sc_ProductionReportsController.cs" />
--
Gitblit v1.9.1