From 898a695edb40a65c3ab2bfa23ced763bd084e28d Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期五, 28 六月 2024 18:06:46 +0800
Subject: [PATCH] 异常反馈单,保存时,如果抄送为空,就不追加值,增加异常反馈单列表查询
---
WebAPI/Controllers/SCGL/日计划管理/Sc_JIT_ComplementGoodBillController.cs | 620 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 593 insertions(+), 27 deletions(-)
diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs"
index 3a9d87e..b2321bb 100644
--- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs"
+++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs"
@@ -3,9 +3,11 @@
using System;
using System.Collections.Generic;
using System.Data;
+using System.IO;
using System.Linq;
using System.Web;
using System.Web.Http;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
using WebAPI.Models;
namespace WebAPI.Controllers.SCGL
@@ -19,6 +21,7 @@
private json objJsonResult = new json();
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
DataSet ds;
+ Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
#region 鏃ヨ鍒掑钩鍙板熀纭�璧勬枡 杞﹂棿浠撳簱瀵圭収
@@ -91,9 +94,8 @@
string msg2 = sArray[0].ToString();
string msg3 = sArray[1].ToString();
- int hentryid = int.Parse(sArray[2].ToString());//瀛愯〃鐨勯『搴廼d
- int OperationType = int.Parse(sArray[3].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
- string user = sArray[4].ToString();
+ int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+ string user = sArray[3].ToString();
try
{
if (!DBUtility.ClsPub.Security_Log("JIT_ComplementGoodBill_Edit", 1, false, user))
@@ -106,8 +108,23 @@
}
omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2);
+
+ if (omdelMian.HPRDORGID.ToString() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "缁勭粐涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
string BillType = "4612";
+ ds = ds = oCN.RunProcReturn($"select * from h_v_JIT_Gy_WorkWarehouseBillList where hmainid={omdelMian.HInterID} and 鍗曟嵁鍙�='{omdelMian.HBillNo}'", "h_v_JIT_Gy_WorkWarehouseBillList");
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ OperationType = 3;
+ }
if (OperationType == 1)//鏂板
{
@@ -123,12 +140,9 @@
",HUpDater='" + omdelMian.HMaker + "'" +
",HUpDateDate='" + DateTime.Now+ "'" +
" where HInterID=" + omdelMian.HInterID.ToString());
-
- //鍒犻櫎瀛愯〃
- oCN.RunProc("delete from Gy_WorkWarehouseBillMainSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
}
//淇濆瓨瀛愯〃
- objJsonResult = AddBillSub(msg3, hentryid);
+ objJsonResult = AddBillSub(msg3);
if (objJsonResult.code == "0")
{
objJsonResult.code = "0";
@@ -154,9 +168,33 @@
}
}
- public json AddBillSub(string msg3, int hentryid)
+ public json AddBillSub(string msg3)
{
omodelsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_WorkWarehouseBillMainSub>>(msg3);
+
+ foreach (Models.Gy_WorkWarehouseBillMainSub oSub in omodelsub)
+ {
+ if (oSub.HWorkShopID == 0 || oSub.HWorkShopID ==null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鐢熶骇杞﹂棿涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HWHID == 0|| oSub.HWHID == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "浠撳簱涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ //鍒犻櫎瀛愯〃
+ oCN.RunProc("delete from Gy_WorkWarehouseBillMainSub where HInterID='" + omdelMian.HInterID.ToString() + "'");
+
int i = 1;
//鎻掑叆瀛愯〃
foreach (Models.Gy_WorkWarehouseBillMainSub oSub in omodelsub)
@@ -164,7 +202,7 @@
oCN.RunProc("insert into Gy_WorkWarehouseBillMainSub(HInterID,HEntryID,HRemark,HWorkShopID," +
"HWorkShopName,HWHID,HWHName) " +
"values("
- + omdelMian.HInterID.ToString() + "," + (hentryid == -1 ? i : hentryid) + ",'" + oSub.HRemark + "'," + (oSub.HWorkShopID==null?0:oSub.HWorkShopID)
+ + omdelMian.HInterID.ToString() + "," + i + ",'" + oSub.HRemark + "'," + (oSub.HWorkShopID==null?0:oSub.HWorkShopID)
+ ",'" +oSub.HWorkShopName + "'," + (oSub.HWHID==null?0: oSub.HWHID) + ",'" + oSub.HWHName.ToString()+ "') ");
i++;
}
@@ -316,9 +354,8 @@
string msg2 = sArray[0].ToString();//涓昏〃鏁版嵁
string msg3 = sArray[1].ToString();//瀛愯〃鏁版嵁
- int hentryid = int.Parse(sArray[2].ToString());//瀛愯〃鐨勯『搴廼d
- int OperationType = int.Parse(sArray[3].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
- string user = sArray[4].ToString();
+ int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+ string user = sArray[3].ToString();
try
{
if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanConfigBill_Edit", 1, false, user))
@@ -333,6 +370,11 @@
omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2);
string BillType = "4611";
+ ds = ds = oCN.RunProcReturn($"select * from h_v_JIT_Cg_PODemandPlanConfigBillList where hmainid={omdelMian.HInterID} and 鍗曟嵁鍙�='{omdelMian.HBillNo}'", "h_v_JIT_Cg_PODemandPlanConfigBillList");
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ OperationType = 3;
+ }
if (OperationType == 1)//鏂板
{
@@ -348,12 +390,9 @@
",HUpDater='" + omdelMian.HMaker + "'" +
",HUpDateDate='" + DateTime.Now + "'" +
" where HInterID=" + omdelMian.HInterID.ToString());
-
- //鍒犻櫎瀛愯〃
- oCN.RunProc("delete from Cg_PODemandPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
}
//淇濆瓨瀛愯〃
- objJsonResult = AddPODBillSub(msg3, hentryid);
+ objJsonResult = AddPODBillSub(msg3);
if (objJsonResult.code == "0")
{
objJsonResult.code = "0";
@@ -379,9 +418,64 @@
}
}
- public json AddPODBillSub(string msg3, int hentryid)
+ public json AddPODBillSub(string msg3)
{
+ string Ret = "";
+ oSystemParameter.ShowBill(ref Ret);
omodelPODsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanConfigBillSub>>(msg3);
+
+ foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub)
+ {
+ if (oSub.HSupplierID == 0 || oSub.HSupplierID == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "渚涘簲鍟嗕笉鑳戒负绌�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HMaterID == 0 || oSub.HMaterID == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鐗╂枡涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HLeadTime == 0 || oSub.HLeadTime == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = " JIT渚涜揣鎻愬墠鏈熶笉鑳戒负绌�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ if (oSystemParameter.omodel.WMS_CampanyName != "甯呭▉")
+ {
+ if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = " JIT鍒拌揣鍓嶇疆鏈熶笉鑳戒负绌�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = " JIT閫佽揣鎺у埗澶╂暟涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ }
+
+
+ //鍒犻櫎瀛愯〃
+ oCN.RunProc("delete from Cg_PODemandPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "'");
+
int i = 1;
//鎻掑叆瀛愯〃
foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub)
@@ -389,7 +483,7 @@
oCN.RunProc("insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," +
"HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
"HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" +
- $"({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid) }, '{oSub.HRemark}', {(oSub.HSupplierID==null?0: oSub.HSupplierID)}, '{oSub.HSupplierName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
+ $"({omdelMian.HInterID}, {i}, '{oSub.HRemark}', {(oSub.HSupplierID==null?0: oSub.HSupplierID)}, '{oSub.HSupplierName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
$" '{oSub.HMaterName}', '{oSub.HMaterModel}', '{oSub.HJITMaterGroup}', {(oSub.HJITSafeStock == null ? 0 : oSub.HJITSafeStock)}, {(oSub.HJITMaterDemand == null ? 0 : oSub.HJITMaterDemand)},{(oSub.HJITBatchQty == null ? 0 : oSub.HJITBatchQty)},{(oSub.HDeliveryPeriod == null ? 0 : oSub.HDeliveryPeriod)}," +
$" {(oSub.HLeadTime == null ? 0 : oSub.HLeadTime)}, {(oSub.HLeadTime_Sec == null ? 0 : oSub.HLeadTime_Sec)}, '{oSub.HDeliveryMode}', {(oSub.HDeliveryDaysCtrl == null ? 0 : oSub.HDeliveryDaysCtrl)}) ");
i++;
@@ -469,6 +563,428 @@
}
#endregion
+ #region 鎻愭枡璁″垝淇℃伅 鏂囦欢涓婁紶
+ [Route("Cg_PODemandPlanConfigBill/Cg_PODemandPlanConfigBill_Excel")]
+ [HttpPost]
+ public object Cg_PODemandPlanConfigBill_Excel()
+ {
+ try
+ {
+ //var WorkBookName = HttpContext.Current.Request["WorkBookName"];
+ //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]);
+ //鑾峰彇鏂囦欢鍚嶇О
+ var file = HttpContext.Current.Request.Files[0];
+ //鑾峰彇鏂囦欢鐗╃悊璺緞
+ string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+ //淇濆瓨鏂囦欢
+ file.SaveAs(ExcelPath);
+
+ NpoiHelper np = new NpoiHelper();
+ DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+ //鍒犻櫎鏂囦欢
+ File.Delete(ExcelPath);
+
+ //鍒涘缓涓存椂琛�
+ DataTable tb2 = new DataTable("dt2");
+
+ //娣诲姞鍒楀悕
+ for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+ {
+ tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+ }
+
+ //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+ tb2.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID
+ tb2.Columns.Add("HSupID", typeof(Int32));//渚涘簲鍟�
+ tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID
+ tb2.Columns.Add("HUnitID", typeof(Int32));//璁¢噺鍗曚綅
+
+ //娣诲姞鏁版嵁
+ for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+ {
+ DataRow row = tb2.NewRow();
+ for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+ {
+ row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+ }
+ //濡傛灉琛ㄦ牸绗琲琛岀殑绗竴鍒椾负绌猴紝鍒欏垽鏂负杩欎竴琛岀殑鏁版嵁涓虹┖锛岃烦鍑哄惊鐜苟涓斾笉鎶婃暟鎹啓鍏� tb2
+ if (ExcelDs.Tables[0].Rows[i][0].ToString() == "")
+ {
+ continue;
+ }
+ else
+ {
+ tb2.Rows.Add(row);
+ }
+ }
+
+
+ var error = "";
+
+ //鏌ヨ宸ヨ壓璺嚎娌℃湁鐨勫垪
+ if (!tb2.Columns.Contains("缁勭粐缂栫爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囩紪鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囥�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("渚涘簲鍟嗕唬鐮�"))
+ error += "娌℃湁鎵惧埌銆愪緵搴斿晢浠g爜銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("渚涘簲鍟�"))
+ error += "娌℃湁鎵惧埌銆愪緵搴斿晢銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗╂枡浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欎唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗╂枡鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欏悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瑙勬牸鍨嬪彿"))
+ error += "娌℃湁鎵惧埌銆愯鏍煎瀷鍙枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁¢噺鍗曚綅"))
+ error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶃�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鐗╂枡鍒嗙被"))
+ error += "娌℃湁鎵惧埌銆怞IT鐗╂枡鍒嗙被銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鎷夊姩瀹夊叏搴撳瓨閲�"))
+ error += "娌℃湁鎵惧埌銆怞IT鎷夊姩瀹夊叏搴撳瓨閲忋�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鐗╂枡闇�姹備緵璐у懆鏈�"))
+ error += "娌℃湁鎵惧埌銆怞IT鐗╂枡闇�姹備緵璐у懆鏈熴�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鎻愯揣缁忔祹鎵归噺"))
+ error += "娌℃湁鎵惧埌銆怞IT鎻愯揣缁忔祹鎵归噺銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鎻愯揣鎵归噺瀵瑰簲鍛ㄦ湡锛堝ぉ锛�"))
+ error += "娌℃湁鎵惧埌銆怞IT鎻愯揣鎵归噺瀵瑰簲鍛ㄦ湡锛堝ぉ锛夈�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT渚涜揣鎻愬墠鏈燂紙澶╋級"))
+ error += "娌℃湁鎵惧埌銆怞IT渚涜揣鎻愬墠鏈燂紙澶╋級銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級"))
+ error += "娌℃湁鎵惧埌銆怞IT鍒拌揣鍓嶇疆鏈燂紙澶╋級銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT閫佽揣鎺у埗澶╂暟"))
+ error += "娌℃湁鎵惧埌銆怞IT閫佽揣鎺у埗澶╂暟銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("JIT鏈�灏忚捣閫侀噺"))
+ error += "娌℃湁鎵惧埌銆怞IT鏈�灏忚捣閫侀噺銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HORGNumber = "";
+ string HORGName = "";
+ string HSupNumer = "";
+ string HSupName = "";
+ string HMaterNumer = "";
+ string HMaterName = "";
+ string HMaterModel = "";
+ string HUntilName = "";
+
+ string JITType = "";//JIT鐗╂枡鍒嗙被
+ string JIPEB = ""; //JIT鎻愯揣缁忔祹鎵归噺
+ string JISLT = ""; //JIT渚涜揣鎻愬墠鏈燂紙澶╋級
+ string JIDLT = ""; //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級
+ string JIMLC = ""; //JIT鏈�灏忚捣閫侀噺
+
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString());
+ HSupNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString());
+ HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString());
+ HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString());
+ HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString());
+ HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勬牸鍨嬪彿"].ToString());
+ HUntilName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString());
+
+ JITType = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鐗╂枡鍒嗙被"].ToString());
+ JIPEB = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鎻愯揣缁忔祹鎵归噺"].ToString());
+ JISLT = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT渚涜揣鎻愬墠鏈燂紙澶╋級"].ToString());
+ JIDLT = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級"].ToString());
+ JIMLC = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鏈�灏忚捣閫侀噺"].ToString());
+
+ //妫�鏌ョ墿鏂�
+ int index = i + 1;
+
+ if (HORGNumber != "")
+ {
+
+
+ //鏌ヨ缁勭粐
+ ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
+
+
+ //鏌ヨ渚涘簲鍟�
+ ds = oCN.RunProcReturn("select * from Gy_Supplier where HNumber='" + HSupNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Supplier");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,渚涘簲鍟�:"+ HSupName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+ //鏌ヨ鐗╂枡
+ ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Material");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鐗╂枡:"+ HMaterName + ",鐗╂枡浠g爜:"+ HMaterNumer + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+ //鏌ヨ璁¢噺鍗曚綅
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HUntilName + "' ", "Gy_Unit"); //and HUSEORGID=" + HORGid + "
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,璁¢噺鍗曚綅:"+ HUntilName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+ //JIT鐗╂枡鍒嗙被
+ if (JITType == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,JIT鐗╂枡鍒嗙被涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //JIT鎻愯揣缁忔祹鎵归噺
+ if (JIPEB == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,JIT鎻愯揣缁忔祹鎵归噺涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //JIT渚涜揣鎻愬墠鏈燂紙澶╋級
+ if (JISLT == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,JIT渚涜揣鎻愬墠鏈燂紙澶╋級涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級
+ if (JIDLT == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //JIT鏈�灏忚捣閫侀噺
+ if (JIMLC == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,JIT鏈�灏忚捣閫侀噺涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //瀹℃牳浠g爜鏄惁鍚堢悊
+ if (!DBUtility.ClsPub.AllowNumber(HMaterNumer))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鎻愭枡璁″垝淇℃伅 瀵煎叆(淇濆瓨)
+ [Route("Cg_PODemandPlanConfigBill/Cg_PODemandPlanConfigBill_btnSave")]
+ [HttpPost]
+ public object Cg_PODemandPlanConfigBill_btnSave([FromBody] JObject sMainSub)
+ {
+ var _value = sMainSub["sMainSub"].ToString();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();
+ string user = sArray[1].ToString();
+ try
+ {
+ if (!DBUtility.ClsPub.Security_Log("Cg_PODemandPlanConfigBill_Edit", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+ List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+ foreach (JObject item in Excel)
+ {
+ Dictionary<string, string> dic = new Dictionary<string, string>();
+ foreach (var itm in item.Properties())
+ {
+ dic.Add(itm.Name, itm.Value.ToString());
+ }
+ list.Add(dic);
+ }
+
+ oCN.BeginTran();
+ int i = 1;
+ foreach (Dictionary<string, string> item in list)
+ {
+ string HSupID = item["HSupID"].ToString();//渚涘簲鍟�
+ string HMaterID = item["HMaterID"].ToString();//鐗╂枡ID
+ string HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HSupplierName = item["渚涘簲鍟�"].ToString();
+ string HMaterName = item["鐗╂枡鍚嶇О"].ToString();
+ string HMaterModel = item["瑙勬牸鍨嬪彿"].ToString();
+ string HUnitID = item["HUnitID"].ToString();//璁¢噺鍗曚綅
+ string JITType = item["JIT鐗╂枡鍒嗙被"].ToString();
+ string JITPSL = item["JIT鎷夊姩瀹夊叏搴撳瓨閲�"].ToString();
+ string JITMDSC = item["JIT鐗╂枡闇�姹備緵璐у懆鏈�"].ToString();
+ string JIPEB = item["JIT鎻愯揣缁忔祹鎵归噺"].ToString();
+ string JITPBCC = item["JIT鎻愯揣鎵归噺瀵瑰簲鍛ㄦ湡锛堝ぉ锛�"].ToString();
+ string JISLT = item["JIT渚涜揣鎻愬墠鏈燂紙澶╋級"].ToString();
+ string JIDLT = item["JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級"].ToString();
+ string JITDCD = item["JIT閫佽揣鎺у埗澶╂暟"].ToString();
+ string JIMLC = item["JIT鏈�灏忚捣閫侀噺"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+
+ ds = oCN.RunProcReturn("select * from Cg_PODemandPlanConfigBillSub where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID, "Cg_PODemandPlanConfigBillSub");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+
+ long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d
+ string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿
+
+
+ string sql = "insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" +
+ $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4611', '4611', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})";
+ string sql1 = "insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," +
+ "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
+ "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl,HUnitID,HJITMinDeliveryQty)values" +
+ $"({HInterID}, 1, '{HRemark}', {(HSupID == "" ? "0" : HSupID)}, '{HSupplierName}', {(HMaterID == "" ? "0" : HMaterID)}," +
+ $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," +
+ $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)} ,{HUnitID},{JIMLC})";
+ //涓昏〃
+ oCN.RunProc(sql);
+ //瀛愯〃
+ oCN.RunProc(sql1);
+ }
+ else
+ {
+ oCN.RunProc(" update Cg_PODemandPlanConfigBillSub set HLeadTime=" + JISLT + " where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID);
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
#endregion
#region 鏃ヨ鍒掑钩鍙板熀纭�璧勬枡 瑕佹枡璁″垝淇℃伅
@@ -542,9 +1058,8 @@
string msg2 = sArray[0].ToString();//涓昏〃鏁版嵁
string msg3 = sArray[1].ToString();//瀛愯〃鏁版嵁
- int hentryid = int.Parse(sArray[2].ToString());//瀛愯〃鐨勯『搴廼d
- int OperationType = int.Parse(sArray[3].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
- string user = sArray[4].ToString();
+ int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼
+ string user = sArray[3].ToString();
try
{
if (!DBUtility.ClsPub.Security_Log("JIT_NeedMaterPlanConfigBill_Edit", 1, false, user))
@@ -558,6 +1073,12 @@
omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsXt_BaseBillMain>(msg2);
string BillType = "4615";
+
+ ds = ds = oCN.RunProcReturn($"select * from h_v_JIT_NeedMaterPlanConfigBillList where hmainid={omdelMian.HInterID} and 鍗曟嵁鍙�='{omdelMian.HBillNo}'", "h_v_JIT_NeedMaterPlanConfigBillList");
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ OperationType = 3;
+ }
if (OperationType == 1)//鏂板
@@ -575,12 +1096,9 @@
",HUpDater='" + omdelMian.HMaker + "'" +
",HUpDateDate='" + DateTime.Now + "'" +
" where HInterID=" + omdelMian.HInterID.ToString());
-
- //鍒犻櫎瀛愯〃
- oCN.RunProc("delete from JIT_NeedMaterPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "' and HEntryID='" + hentryid + "'");
}
//淇濆瓨瀛愯〃
- objJsonResult = AddNeedBillSub(msg3, hentryid);
+ objJsonResult = AddNeedBillSub(msg3);
if (objJsonResult.code == "0")
{
objJsonResult.code = "0";
@@ -606,9 +1124,57 @@
}
}
- public json AddNeedBillSub(string msg3, int hentryid)
+ public json AddNeedBillSub(string msg3)
{
omodelNeedsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JIT_NeedMaterPlanConfigBillSub>>(msg3);
+
+ foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub)
+ {
+ if (oSub.HWorkShopID == 0 || oSub.HWorkShopID == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鐢熶骇杞﹂棿涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HMaterID == 0 || oSub.HMaterID == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鐗╂枡涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HLeadTime == 0 || oSub.HLeadTime == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = " JIT渚涜揣鎻愬墠鏈熶笉鑳戒负绌�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = " JIT鍒拌揣鍓嶇疆鏈熶笉鑳戒负绌�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = " JIT閫佽揣鎺у埗澶╂暟涓嶈兘涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ //鍒犻櫎瀛愯〃
+ oCN.RunProc("delete from JIT_NeedMaterPlanConfigBillSub where HInterID='" + omdelMian.HInterID.ToString() + "'");
+
int i = 1;
//鎻掑叆瀛愯〃
foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub)
@@ -616,7 +1182,7 @@
oCN.RunProc("insert into JIT_NeedMaterPlanConfigBillSub(HInterID,HEntryID,HRemark,HWorkShopID,HWorkShopName,HMaterID," +
"HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " +
"HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl)values" +
- $"({omdelMian.HInterID}, {(hentryid == -1 ? i : hentryid) }, '{oSub.HRemark}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HWorkShopName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
+ $"({omdelMian.HInterID}, {i}, '{oSub.HRemark}', {(oSub.HWorkShopID == null ? 0 : oSub.HWorkShopID)}, '{oSub.HWorkShopName}', {(oSub.HMaterID == null ? 0 : oSub.HMaterID)}," +
$" '{oSub.HMaterName}', '{oSub.HMaterModel}', '{oSub.HJITMaterGroup}', {(oSub.HJITSafeStock == null ? 0 : oSub.HJITSafeStock)}, {(oSub.HJITMaterDemand == null ? 0 : oSub.HJITMaterDemand)},{(oSub.HJITBatchQty == null ? 0 : oSub.HJITBatchQty)},{(oSub.HDeliveryPeriod == null ? 0 : oSub.HDeliveryPeriod)}," +
$" {(oSub.HLeadTime == null ? 0 : oSub.HLeadTime)}, {(oSub.HLeadTime_Sec == null ? 0 : oSub.HLeadTime_Sec)}, '{oSub.HDeliveryMode}', {(oSub.HDeliveryDaysCtrl == null ? 0 : oSub.HDeliveryDaysCtrl)}) ");
i++;
--
Gitblit v1.9.1