From 78ff1efa3f21c9cb330338d00c378b79c9df2b7f Mon Sep 17 00:00:00 2001
From: YL <YL@LAPTOP-SE03PLUR>
Date: 星期五, 03 九月 2021 18:04:18 +0800
Subject: [PATCH] 进站单上道工序转序检验,出站单当前工序首件检验
---
WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs | 393 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 391 insertions(+), 2 deletions(-)
diff --git a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
index 8bc1ceb..52b44e2 100644
--- a/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_StationEntrustInBillController.cs
@@ -33,11 +33,11 @@
{
if (sWhere == null || sWhere.Equals(""))
{
- ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustInBillList " + sWhere, "h_v_MES_StationEntrustInBillList");
+ ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustInBillList " + sWhere+ " order by 鍙戝嚭鏃堕棿 desc", "h_v_MES_StationEntrustInBillList");
}
else
{
- string sql1 = "select * from h_v_MES_StationEntrustInBillList where 1 = 1 ";
+ string sql1 = "select * from h_v_MES_StationEntrustInBillList where 1 = 1 order by 鍙戝嚭鏃堕棿 desc";
string sql = sql1 + sWhere;
ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustInBillList");
}
@@ -68,6 +68,395 @@
}
}
+ /// <summary>
+ /// 濮斿宸ュ簭鍙戝嚭鍗曟祦姘村彿鍥炶溅鑾峰彇娴佽浆鍗′俊鎭紙濮斿宸ュ簭鎺ユ敹銆佸伐搴忚繘绔欐帴鏀堕�氱敤锛�
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Cj_StationEntrustInBill/txtHBarCode_KeyDown")]
+ [HttpGet]
+ public object txtHBarCode_KeyDown(string HBarCode)
+ {
+ try
+ {
+ if (HBarCode == null || HBarCode.Equals(""))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏉″舰鐮佷笉鑳戒负绌猴紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //鎷嗗垎鏉″舰鐮�
+ string sBillBarCode = HBarCode.Trim();
+ string[] NewBarCode;
+ if (sBillBarCode.CompareTo("#") > 0)
+ {
+ NewBarCode = sBillBarCode.Split(Convert.ToChar("#"));
+ sBillBarCode = NewBarCode[0];
+ }
+ string sBillNo = sBillBarCode;
+ //寰楀埌淇℃伅
+ ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 鍗曟嵁鍙�= '" + sBillNo + "'", "h_v_Sc_ProcessExchangeBillList");
+ //鍐欏叆淇℃伅
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏈煡璇㈠埌娴佽浆鍗′俊鎭紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Cj_StationEntrustInBill/AddBill")]
+ [HttpPost]
+ public object AddBill([FromBody] JObject oMain)
+ {
+ var _value = oMain["oMain"].ToString();
+ string msg1 = _value.ToString();
+ try
+ {
+ //濮斿宸ュ簭鍙戝嚭鍙嶅簭鍒楀寲
+ msg1 = "[" + msg1.ToString() + "]";
+ List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1);
+ string eventType = list[0].eventType;
+ long HInterID = list[0].HInterID;//閫掑叆type寰楀埌鐨勫崟鎹甀D
+ int HYear = 2021;
+ double HPeriod = list[0].HPeriod;//鍗曚环
+ string HBillNo = list[0].HBillNo;//閫掑叆type寰楀埌鐨勫崟鎹彿
+ int HBillStatus = 0;
+ string HInnerBillNo = list[0].HInnerBillNo;//閫佽揣鍗曞彿
+ string HICMOBillNo = list[0].HICMOBillNo;//鐢熶骇璁㈠崟鍙�
+ long HICMOInterID = list[0].HICMOInterID;//鐢熶骇璁㈠崟鍙稩D
+ long HProcExchInterID = list[0].lngBillKey;
+ long HProcExchEntryID = list[0].lngBillSubKey;
+ string HProcExchBillNo = list[0].HProcExchBillNo;//娴佽浆鍗�
+ long HProcID = list[0].HProcID;//褰撳墠宸ュ簭
+ long HMaterID = list[0].HMaterID;//浜у搧ID
+ DateTime HStationInTime = list[0].HStationInTime;//
+ long HEmpID = list[0].HEmpID;//鎿嶄綔鍛業D
+ long HSourceID = list[0].HSourceID;//鐢熶骇璧勬簮ID
+ long HGroupID = list[0].HGroupID;//鐝粍ID
+ double HICMOQty = list[0].HICMOQty;//浠诲姟鍗曟暟閲�
+ double HPlanQty = list[0].HPlanQty;//娴佽浆鍗℃暟閲�
+ double HQty = list[0].HQty;//鍙戝嚭鏁伴噺
+ long HSupID = list[0].HSupID;//渚涘簲鍟咺D
+ double HPieceQty = list[0].HPieceQty;//鍙戝嚭浠舵暟
+ string HSourceName = list[0].HSourceName;//
+ double HPrice = list[0].HPrice;//鍗曚环
+ double HMoney = list[0].HMoney;//閲戦
+ string HRemark = list[0].HRemark;//澶囨敞
+ double HTaxRate = list[0].HTaxRate;//绋庣巼
+ long HProcNo = list[0].HProcNo;//娴佹按鍙�
+ string HOrderProcNO = list[0].HOrderProcNO;//璁㈠崟璺熻釜鍙�
+ int HWWWorkOrderInterID = 0;//濮斿宸ュ崟鍙峰瓙鍐呯爜
+ int HWWWorkOrderEntryID = 0;//濮斿宸ュ崟鍙蜂富鍐呭悧
+ string HWWWorkOrderBillNo = list[0].HWWWorkOrderBillNo;//濮斿宸ュ崟鍙�
+ string HMaker = list[0].HMaker;//鍒跺崟浜�
+ int HProcPlanInterID = 0;
+ int HProcPlanEntryID = 0;
+ string HProcPlanBillNo = "";
+ long HDeptID = list[0].HDeptID;//閮ㄩ棬ID
+ string HBarCode = list[0].HBarCode;//鏉″舰鐮�
+ string HAddr = "";
+ string HBarCodeMaker = "";
+ if (HProcExchInterID <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娴佽浆鍗℃病鏈夐�夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HProcExchEntryID <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娴佹按鍙�2娌℃湁閫夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HProcNo <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娴佹按鍙锋病鏈夐�夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HProcExchBillNo == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娴佽浆鍗″彿娌℃湁閫夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HMaterID <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "浜у搧娌℃湁閫夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HSupID <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "渚涘簲鍟嗘病鏈夐�夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HProcID <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "褰撳墠宸ュ簭娌℃湁閫夋嫨锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (HQty <= 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍙戝嚭鏁伴噺涓嶈兘涓�0锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+ oCN.BeginTran();
+ if ("Add".Equals(eventType))
+ {
+ if (!AllowbillNo(HBillNo))
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //涓昏〃
+ oCN.RunProc("Insert Into Sc_StationInBillMain " +
+ "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
+ ",HYear,HPeriod,HRemark,HInnerBillNo" +
+ ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" +
+ ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" +
+ ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" +
+ ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPieceQty" +
+ ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID" +
+ ") " +
+ " values('3792','3792'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillStatus.ToString() + "',getdate(),'" + HMaker + "',getdate()" +
+ ",'" + HYear.ToString() + "','" + HPeriod.ToString() + "','" + HRemark + "','" + HInnerBillNo + "'" +
+ "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID +
+ ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID +
+ "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" +
+ "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPieceQty +
+ ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "" +
+ ") ");
+ }
+ else if ("Modify".Equals(eventType))
+ {
+
+ //鍒犻櫎鍏宠仈
+ oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_In " + HInterID + ",-1");
+ oCN.RunProc("exec h_p_WW_EntrustWorkOrderRelationQty_In " + HInterID + ",-1");
+
+ //鏇存柊涓昏〃
+ oCN.RunProc("UpDate Sc_StationInBillMain set " +
+ "HBillNo='" + HBillNo + "'" +
+ ",HRemark='" + HRemark + "'" +
+ ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" +
+ ",HUpDateDate=getdate()" +
+ ",HInnerBillNo='" + HInnerBillNo + "'" +
+ ",HSupID=" + HSupID +
+ ",HQty=" + HQty +
+ ",HPieceQty=" + HPieceQty +
+ ",HPrice=" + HPrice +
+ ",HMoney=" + HMoney +
+ ",HTaxRate=" + HTaxRate +
+ ",HMaterID=" + HMaterID +
+ ",HProcID=" + HProcID +
+ ",HProcNo=" + HProcNo +
+ ",HOrderProcNO='" + HOrderProcNO + "'" +
+ " where HInterID=" + HInterID);
+ }
+ else
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎿嶄綔绫诲瀷鏃犳晥锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_QtyCtrl " + HInterID + "", "h_p_MES_StationInBill_QtyCtrl");
+ if (ds == null)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍒ゆ柇鏁伴噺澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍒ゆ柇鏁伴噺澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2")
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_In " + HInterID.ToString() + ",1");
+ oCN.RunProc("exec h_p_WW_EntrustWorkOrderRelationQty_In " + HInterID.ToString() + ",1");
+ oCN.Commit();
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鏂板鍗曟嵁鎴愬姛锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ private bool AllowbillNo(string HBillNo)
+ {
+ ds = oCN.RunProcReturn("select HBillNo from Sc_StationInBillMain where HBillNo = '" + HBillNo + "'", "Sc_StationInBillMain");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /// <summary>
+ /// 缂栬緫椤甸潰鏍规嵁id鑾峰彇濮斿宸ュ簭鎺ユ敹鍗曚俊鎭�
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Cj_StationEntrustInBill/GetStationEntrustInBill")]
+ [HttpGet]
+ public object GetStationEntrustInBill(int HInterID)
+ {
+ try
+ {
+ ds = oCN.RunProcReturn("select * from h_v_GetStationInBill where HInterID = " + HInterID, "h_v_GetStationOutBill");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "濮斿宸ュ簭鎺ユ敹鍗曚俊鎭幏鍙栧け璐ワ紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+
+ /// <summary>
+ /// 濮斿宸ュ簭鍙戝嚭鍗曟祦姘村彿鍥炶溅鑾峰彇宸ュ簭淇℃伅
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Cj_StationEntrustInBill/txtHProcNo_KeyDown")]
+ [HttpGet]
+ public object txtHProcNo_KeyDown(string sBillNo, string sProcNo)
+ {
+ try
+ {
+ if (sBillNo.Equals("") || sProcNo.Equals(""))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏉″舰鐮佷笉鑳戒负绌猴紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //寰楀埌淇℃伅锛堝澶栨爣璁颁负0鏃讹紝娴佽浆鏍囪涓�1鏃讹級
+ ds = oCN.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 鍗曟嵁鍙�= '" + sBillNo + "' and 涓嬮亾娴佽浆宸ュ簭<>'杞�' and 濮斿鏍囪=1 and 娴佽浆鏍囪=1 and 宸ュ簭鍙�='" + sProcNo + "'", "h_v_Sc_ProcessExchangeBillList");
+ //Ds = oCn.RunProcReturn("select top 1 * from h_v_Sc_ProcessExchangeBillList where 鍗曟嵁鍙�= '" + sBillNo + "' and 宸ュ簭鍙�='" + sProcNo + "' and 濮斿鏍囪=0 and 娴佽浆鏍囪=1 ", "h_v_Sc_ProcessExchangeBillList");
+ //鍐欏叆淇℃伅
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "宸ュ簭鍙烽敊璇垨鑰呭綋鍓嶅伐搴忓彿涓嶅厑璁歌繘绔欙紝璇烽噸鏂拌緭鍏ワ紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+
//
--
Gitblit v1.9.1