From 00e25e4a9c9bd2fc91558c3c1a68f47db6d08b1d Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期一, 08 七月 2024 18:57:35 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API
---
WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs | 472 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 470 insertions(+), 2 deletions(-)
diff --git a/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs b/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
index 5d18f46..2676353 100644
--- a/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_ComplementGoodsController.cs
@@ -32,6 +32,7 @@
public string HDeptName { get; set; }//閮ㄩ棬
public string HJLStatus { get; set; }//鎷f枡鐘舵��
public string user { get; set; }//鍒跺崟浜�
+ public string Arbitrarily { get; set; }//浠绘剰鍙傛暟
}
[Route("Sc_ComplementGoods/ComplementGoodsList")]
@@ -60,9 +61,476 @@
//鍙嶅簭鍒楀寲浼犻�掔殑鍊�
ComplementGoods com = JsonConvert.DeserializeObject<ComplementGoods>(sWhere.ToString());
-
ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_Query '{com.MaterialNumber}','{com.MaterialName}','{com.MaterialModel}','{com.HGD}'," +
- $"'{com.HWHName}','{com.HDeptName}','{com.Organization}','{com.user}','{com.HJLStatus}','{com.HBeginDate}','{com.HEndDate}'" ,"h_p_JIT_ComplementGoodsBillList_Query");
+ $"'{com.HWHName}','{com.HDeptName}','{com.Organization}','{com.user}','{com.HJLStatus}','{com.HBeginDate}','{com.HEndDate}'", "h_p_JIT_ComplementGoodsBillList_Query");
+
+ 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;
+ }
+ }
+ #endregion
+
+ #region 鎷f枡閰嶉�佸崟 鍒犻櫎
+ [Route("Sc_ComplementGoods/DelComplementGoodsList")]
+ [HttpGet]
+ public object DelComplementGoodsList(string HInterID, string HEntryID, string HOrgID, string user)
+ {
+ try
+ {
+ //鍒犻櫎鏉冮檺
+ if (!DBUtility.ClsPub.Security_Log("Cj_ComplementGoodsBill_Drop", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn($"select HISCheck from JIT_SendGoodsBillMain where HMainSourceInterID={HInterID} ", "JIT_SendGoodsBillMain");
+
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "褰撳墠鍗曟嵁宸查厤閫�,涓嶈兘鍒犻櫎!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ oCN.RunProc($"exec Del_ComplementGoodsBillInfo {HInterID},{HEntryID},{HOrgID}");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 閰嶆枡鍗曞垪琛�
+ [Route("Sc_ComplementGoods/ComplementGoodsBill")]
+ [HttpGet]
+ public object ComplementGoodsBill(string sWhere)
+ {
+ try
+ {
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = new DataTable();
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoods_Load '{sWhere}'", "h_p_JIT_ComplementGoods_Load");
+
+ 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;
+ }
+ }
+ #endregion
+
+ #region 鍖归厤搴撳瓨
+ [Route("Sc_ComplementGoods/ComplementGoodsBill_C")]
+ [HttpGet]
+ public object ComplementGoodsBill_C(string sWhere)
+ {
+ try
+ {
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = new DataTable();
+ return objJsonResult;
+ }
+
+ oCN.RunProc($"exec h_p_JIT_ComplementGoodsBill_C_Add '{sWhere}'");
+
+ ds = oCN.RunProcReturn("exec h_p_JIT_GetComplementGoodsBill_C " + sWhere, "h_p_JIT_GetComplementGoodsBill_C");
+
+ 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;
+ }
+ }
+ #endregion
+
+ #region 浠撳簱鍙戞枡
+ //鍙傛暟
+ public class SendGoodsBill
+ {
+ public int? 鏈嫞鏂欐暟閲� = 0;
+ public int? 鏈�澶ф嫞鏂欐暟閲� = 0;
+ public int? 鏈鎷f枡鏁伴噺 = 0;
+ public int? HEntryID = 0;
+ public int? HMaterID = 0;
+ public int? HWHID = 0;
+ public int? HSPID = 0;
+ public int? HStockOutOrgID = 0;
+ public int? HStockInOrgID = 0;
+ public int? HSCWHID = 0;
+ }
+
+ [Route("Sc_ComplementGoods/JIT_SendGoodsBill")]
+ [HttpPost]
+ public object JIT_SendGoodsBill([FromBody] JObject msg)
+ {
+ var _value = msg["msg"].ToString();
+ string[] sArray = _value.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();
+ string user = sArray[1].ToString();
+ string SourceInterID = sArray[2].ToString();
+ string SourceBillNo = sArray[3].ToString();
+ try
+ {
+ msg2 = msg2.Replace("\\", "");
+ msg2 = msg2.Replace("\n", "");
+
+ List<SendGoodsBill> listCa = new List<SendGoodsBill>();
+ //鑾峰彇琛ㄦ牸鏁版嵁闆嗗悎
+ listCa = JsonConvert.DeserializeObject<List<SendGoodsBill>>(msg2.ToString());
+
+ for (int i = 0; i < listCa.Count; i++)
+ {
+ if (listCa[i].鏈鎷f枡鏁伴噺 > listCa[i].鏈�澶ф嫞鏂欐暟閲�)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏈鎷f枡鏁伴噺瓒呰繃鏈�澶ф嫞鏂欐暟閲�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (listCa[i].鏈鎷f枡鏁伴噺 > listCa[i].鏈嫞鏂欐暟閲�)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏈鎷f枡鏁伴噺瓒呰繃鏈嫞鏂欐暟閲�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+
+ objJsonResult = AddSendGoodsBill(listCa, SourceInterID, SourceBillNo, user);
+
+
+ if (objJsonResult.count==1)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "璋冩嫧鍗曠敓鎴愭垚鍔�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = objJsonResult.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ //鏂板
+ public json AddSendGoodsBill(List<SendGoodsBill> listCa, string SourceInterID, string SourceBillNo, string user)
+ {
+ try
+ {
+ oCN.BeginTran();
+
+ long InterID = 0;
+ string HBillNo = "";
+ for (int i = 0; i < listCa.Count; i++)
+ {
+
+ if (i == 0)
+ {
+ InterID = DBUtility.ClsPub.CreateBillID_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo);
+ HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("460201", ref DBUtility.ClsPub.sExeReturnInfo, true);
+
+ //娣诲姞涓昏〃鏁版嵁
+ oCN.RunProc("insert into JIT_SendGoodsBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate" +
+ ",HBillNo,HBillStatus,HMaker,HMakeDate,HISCheck, HMainSourceInterID, HMainSourceEntryID" +
+ ", HMainSourceBillNo, HMainSourceBillType)" +
+ $"values({DateTime.Now.Year},{DateTime.Now.Month},'460201','460201',{InterID}, GETDATE(), '{HBillNo}'," +
+ $" 1,'{user}', GETDATE(), 0, {SourceInterID}, {listCa[i].HEntryID}, '{SourceBillNo}', '4602')");
+ }
+
+ //娣诲姞瀛愯〃鏁版嵁
+ oCN.RunProc("insert into JIT_SendGoodsBillSub(HInterID,HBillNo_bak,HEntryID" +
+ ",HMaterID,HQty,HWHID,HSPID,HISCheck,HCheckSubMan,HCheckSubDate,HStockOutOrgID,HStockInOrgID,HSCWHID)" +
+ $"values({InterID},'{HBillNo}',{i + 1}, {listCa[i].HMaterID},{listCa[i].鏈鎷f枡鏁伴噺}," +
+ $" {listCa[i].HWHID},{listCa[i].HSPID},0,'{user}', GETDATE(),{listCa[i].HStockOutOrgID},{listCa[i].HStockInOrgID},{listCa[i].HSCWHID})");
+
+
+ DataSet dsTable = new DataSet();
+ //鏌ヨJIT_ComplementGoodsBillSub_LK
+ dsTable = oCN.RunProcReturn($"select * from JIT_ComplementGoodsBillSub_LK where HMaterID={listCa[i].HMaterID} and HInterID={SourceInterID} and HCallQTY<>HSendQTY order by HSourceInterID ", "JIT_ComplementGoodsBillSub_LK");
+
+ var HqtyCount = double.Parse(listCa[i].鏈鎷f枡鏁伴噺.ToString());
+ for (int j = 0; j < dsTable.Tables[0].Rows.Count; j++)
+ {
+ var HCallQTY = double.Parse(dsTable.Tables[0].Rows[j]["HCallQTY"].ToString()) - double.Parse(dsTable.Tables[0].Rows[j]["HSendQTY"].ToString());
+
+ //淇敼璋冩嫧鏁伴噺
+ oCN.RunProc($"update JIT_ComplementGoodsBillSub_LK set HSendQTY=HSendQTY+{(HCallQTY < HqtyCount ? HCallQTY : HqtyCount)} where HMaterID={listCa[i].HMaterID} " +
+ $" and HSourceInterID={double.Parse(dsTable.Tables[0].Rows[j]["HSourceInterID"].ToString())} and HInterID={SourceInterID} ");
+
+ HqtyCount -= HCallQTY;
+ if (HqtyCount <= 0)
+ {
+ break;
+ }
+ }
+ }
+
+ //鍚屾閲戣澏鐩存帴璋冩嫧鍗�
+ objJsonResult = AddSendGoodsBillSynChronizAtion(HBillNo);
+
+ oCN.Commit();
+
+ if (objJsonResult.count == 1)
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = null;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = objJsonResult.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = objJsonResult.Message;
+ return objJsonResult;
+ throw (e);
+ }
+ }
+
+ //鍚屾閲戣澏鐩存帴璋冩嫧鍗�
+ public json AddSendGoodsBillSynChronizAtion(string HBillNo)
+ {
+ ds = oCN.RunProcReturn("exec JIT_SendGoodsBillSynChronizAtion '" + HBillNo + "'", "JIT_SendGoodsBillSynChronizAtion");
+ if (ds.Tables[0].Rows.Count != 0)
+ {
+ foreach (DataRow dr in ds.Tables[0].Rows)
+ {
+ JObject model = new JObject();
+ model.Add("FBillTypeID", new JObject() { ["Fnumber"] = dr["FBillTypeID"].ToString() }); //鍗曟嵁绫诲瀷
+ model.Add("FDate", dr["FDate"].ToString());
+ model.Add("FBILLNO", dr["FBILLNO"].ToString());
+ model.Add("FStockOrgId", new JObject() { ["Fnumber"] = ds.Tables[1].Rows[0]["FStockOrgId"].ToString() });
+ model.Add("FOwnerTypeIdHead", dr["FOwnerTypeIdHead"].ToString());
+ model.Add("FTransferBizType", ds.Tables[1].Rows[0]["FTransferBizType"].ToString());
+ model.Add("FOwnerTypeOutIdHead", dr["FOwnerTypeOutIdHead"].ToString());
+ model.Add("FTransferDirect", dr["FTransferDirect"].ToString());
+ model.Add("FStockOutOrgId", new JObject() { ["Fnumber"] = ds.Tables[1].Rows[0]["FStockOutOrgId"].ToString() });
+
+ JArray Fentity = new JArray();
+ foreach (DataRow item in ds.Tables[1].Rows)
+ {
+ JObject FentityModel = new JObject();
+ FentityModel.Add("FMaterialId", new JObject() { ["Fnumber"] = item["FMaterialId"].ToString() });
+ FentityModel.Add("FUnitID", new JObject() { ["Fnumber"] = item["FUnitID"].ToString() });
+ FentityModel.Add("FBaseUnitId", new JObject() { ["Fnumber"] = item["FBaseUnitId"].ToString() });
+ FentityModel.Add("FOwnerTypeId", item["FOwnerTypeId"].ToString());
+ FentityModel.Add("FOwnerId", new JObject() { ["Fnumber"] = item["FOwnerId"].ToString() });
+ FentityModel.Add("FOwnerTypeOutId", item["FOwnerTypeOutId"].ToString());
+ FentityModel.Add("FOwnerOutId", new JObject() { ["Fnumber"] = item["FOwnerOutId"].ToString() });
+ FentityModel.Add("FKeeperTypeId", item["FKeeperTypeId"].ToString());
+ FentityModel.Add("FKeeperId", new JObject() { ["Fnumber"] = item["FKeeperId"].ToString() });
+ FentityModel.Add("FKeeperTypeOutId", item["FKeeperTypeOutId"].ToString());
+ FentityModel.Add("FKeeperOutId", new JObject() { ["Fnumber"] = item["FKeeperOutId"].ToString() });
+ FentityModel.Add("FDestStockId", new JObject() { ["Fnumber"] = item["FDestStockId"].ToString() });
+ FentityModel.Add("FSrcStockId", new JObject() { ["Fnumber"] = item["FSrcStockId"].ToString() });
+ FentityModel.Add("FQty", item["FQty"].ToString());
+ Fentity.Add(FentityModel);
+ }
+ model.Add("FBillEntry", Fentity);
+
+ JObject jsonRoot = new JObject()
+ {
+ ["Creator"] = "",
+ ["NeedUpDateFields"] = new JArray(),
+ ["NeedReturnFields"] = new JArray(),
+ ["IsDeleteEntry"] = "false",
+ ["SubSystemId"] = "",
+ ["IsVerifyBaseDataField"] = "false",
+ ["Model"] = model
+ };
+ var loginRet = InvokeHelper.Login();
+ var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+ if (isSuccess < 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = loginRet;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ var result = InvokeHelper.Save("STK_TransferDirect", jsonRoot.ToString());
+ if (JObject.Parse(result)["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = result;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ var json = new
+ {
+ Numbers = HBillNo,
+ };
+ //鎻愪氦
+ var _result = InvokeHelper.Submit("STK_TransferDirect", JsonConvert.SerializeObject(json));
+ var _saveObj = JObject.Parse(_result);
+ if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+ {
+ LogService.Write("鏀舵枡閫氱煡鍗曟彁浜ゅけ璐sonRoot:" + jsonRoot.ToString());
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曟彁浜ゅけ璐�" + _result;
+ objJsonResult.data = null;
+ return objJsonResult;
+
+ }
+ //瀹℃牳
+ _result = InvokeHelper.Audit("STK_TransferDirect", JsonConvert.SerializeObject(json));
+ _saveObj = JObject.Parse(_result);
+ if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+ {
+ LogService.Write("鏀舵枡閫氱煡鍗曞鏍稿け璐sonRoot:" + jsonRoot.ToString());
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "閲戣澏鏀舵枡閫氱煡鍗曞鏍稿け璐sonRoot" + _result;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎿嶄綔鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "璋冩嫧鍗曞凡缁忓瓨鍦�,鏃犳硶鐢熸垚!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = null;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ #endregion
+
+ #region 涓婃煡
+ [Route("Sc_ComplementGoods/ComplementGoodsList_Sc")]
+ [HttpGet]
+ public object ComplementGoodsList_Sc(string HInterID, string HMaterID)
+ {
+ try
+ {
+
+ ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_UpQuery '{HInterID}',{HMaterID}", "h_p_JIT_ComplementGoodsBillList_UpQuery");
+
+ 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;
+ }
+ }
+ #endregion
+
+ #region 涓嬫煡
+ [Route("Sc_ComplementGoods/JIT_SendGoodsBillList_Xc")]
+ [HttpGet]
+ public object JIT_SendGoodsBillList_Xc(string HInterID, string HMaterID)
+ {
+ try
+ {
+
+ ds = oCN.RunProcReturn($"exec h_p_JIT_ComplementGoodsBillList_DownQuery '{HInterID}',{HMaterID}", "h_p_JIT_ComplementGoodsBillList_DownQuery");
objJsonResult.code = "1";
objJsonResult.count = 1;
--
Gitblit v1.9.1