From d3681038d9acf00d05af1e43f756e9613607c408 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 20 九月 2024 09:10:03 +0800
Subject: [PATCH] 导入功能部分实现
---
sdk_dingding/TopSdk/bin/Debug/TopSdk.dll | 0
WebAPI/Controllers/BaseSet/Gy_ModelTypeController.cs | 265 +++++
WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs | 266 +++++
WebAPI/Properties/PublishProfiles/FolderProfilewtt.pubxml.user | 40
WebAPI/Controllers/BaseSet/Gy_MaterialController.cs | 1033 ++++++++++++++++++++
SyntacticSugar/bin/Debug/SyntacticSugar.pdb | 0
WebAPI/Controllers/基础资料/基础资料/Gy_MaterTypeBillController.cs | 326 ++++++
sdk_dingding/TopSdk/obj/Debug/TopSdk.dll | 0
WebAPI/Controllers/WebAPIController.cs | 517 ++++++++++
SyntacticSugar/obj/Debug/SyntacticSugar.dll | 0
sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.AssemblyReference.cache | 0
sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.FileListAbsolute.txt | 6
SyntacticSugar/obj/Debug/SyntacticSugar.pdb | 0
sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb | 0
SyntacticSugar/bin/Debug/SyntacticSugar.dll | 0
WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs | 530 ++++++++++
sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb | 0
17 files changed, 2,959 insertions(+), 24 deletions(-)
diff --git a/SyntacticSugar/bin/Debug/SyntacticSugar.dll b/SyntacticSugar/bin/Debug/SyntacticSugar.dll
index 55b6c53..95849dc 100644
--- a/SyntacticSugar/bin/Debug/SyntacticSugar.dll
+++ b/SyntacticSugar/bin/Debug/SyntacticSugar.dll
Binary files differ
diff --git a/SyntacticSugar/bin/Debug/SyntacticSugar.pdb b/SyntacticSugar/bin/Debug/SyntacticSugar.pdb
index ceb9ba6..be6ecd0 100644
--- a/SyntacticSugar/bin/Debug/SyntacticSugar.pdb
+++ b/SyntacticSugar/bin/Debug/SyntacticSugar.pdb
Binary files differ
diff --git a/SyntacticSugar/obj/Debug/SyntacticSugar.dll b/SyntacticSugar/obj/Debug/SyntacticSugar.dll
index 55b6c53..95849dc 100644
--- a/SyntacticSugar/obj/Debug/SyntacticSugar.dll
+++ b/SyntacticSugar/obj/Debug/SyntacticSugar.dll
Binary files differ
diff --git a/SyntacticSugar/obj/Debug/SyntacticSugar.pdb b/SyntacticSugar/obj/Debug/SyntacticSugar.pdb
index ceb9ba6..be6ecd0 100644
--- a/SyntacticSugar/obj/Debug/SyntacticSugar.pdb
+++ b/SyntacticSugar/obj/Debug/SyntacticSugar.pdb
Binary files differ
diff --git a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
index c4222fd..e0f7774 100644
--- a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs
@@ -14,6 +14,8 @@
using WebAPI.Models;
using WebAPI.Service;
using System.Text.RegularExpressions;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers
{
@@ -656,6 +658,453 @@
}
}
+ #region 鐗╂枡 鏂囦欢瀵煎叆淇濆瓨
+ #region 鐗╂枡 鏂囦欢涓婁紶
+ [Route("Gy_Material/Gy_Material_Excel")]
+ [HttpPost]
+ public object Gy_Material_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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("HMaterClsID", typeof(Int32));//鐗╂枡灞炴�D
+ tb2.Columns.Add("HUnitGroupID", typeof(Int32));//璁¢噺鍗曚綅缁処D
+ tb2.Columns.Add("HUnitID", typeof(Int32));//鍗曚綅ID
+ tb2.Columns.Add("HSecUnitID", typeof(Int32));//杈呭姪璁¢噺鍗曚綅ID
+ tb2.Columns.Add("HWhID", typeof(Int32));//榛樿浠撳簱ID
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var error = "";
+
+ //鍒ゆ柇瀵煎叆鏂囦欢鍒楁槸鍚﹀畬鏁�
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ 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("鐗╂枡灞炴��"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欏睘鎬с�戠殑鏍囬,";
+
+ 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("榛樿浠撳簱"))
+ error += "娌℃湁鎵惧埌銆愰粯璁や粨搴撱�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鏈�楂樺簱瀛�"))
+ error += "娌℃湁鎵惧埌銆愭渶楂樺簱瀛樸�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鏈�浣庡簱瀛�"))
+ error += "娌℃湁鎵惧埌銆愭渶浣庡簱瀛樸�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀹夊叏搴撳瓨"))
+ error += "娌℃湁鎵惧埌銆愬畨鍏ㄥ簱瀛樸�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("閲囪喘鍗曚环"))
+ error += "娌℃湁鎵惧埌銆愰噰璐崟浠枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("閿�鍞崟浠�"))
+ error += "娌℃湁鎵惧埌銆愰攢鍞崟浠枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁″垝鍗曚环"))
+ error += "娌℃湁鎵惧埌銆愯鍒掑崟浠枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鏍囧噯鎴愭湰"))
+ error += "娌℃湁鎵惧埌銆愭爣鍑嗘垚鏈�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("淇濊川鏈�"))
+ error += "娌℃湁鎵惧埌銆愪繚璐ㄦ湡銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鏈�灏忚璐ч噺"))
+ error += "娌℃湁鎵惧埌銆愭渶灏忚璐ч噺銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鏈�澶ц璐ч噺"))
+ error += "娌℃湁鎵惧埌銆愭渶澶ц璐ч噺銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鑻辨枃鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愯嫳鏂囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鑻辨枃瑙勬牸"))
+ error += "娌℃湁鎵惧埌銆愯嫳鏂囪鏍笺�戠殑鏍囬,";
+
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HMaterName = "";
+ string HMaterNumber = "";
+ string HORGNumber = "";
+ string HORGName = "";
+ string HMaterClsName = "";
+ string HUnitGroupName = "";
+ string HUnitNumber = "";
+ string HUnitName = "";
+ string HSecUnitName = "";
+ string HWhName = "";
+
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+ HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString());
+ HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString());
+ HMaterClsName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡灞炴��"].ToString());
+ HUnitGroupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅缁�"].ToString());
+ HUnitNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅浠g爜"].ToString());
+ HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString());
+ HSecUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["杈呭姪璁¢噺鍗曚綅"].ToString());
+ HWhName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撳簱"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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();
+ //鏌ヨ灞炴��
+ if (HMaterClsName == "澶栬喘")
+ {
+ tb2.Rows[i]["HMaterClsID"] = 1;
+ }
+ else if(HMaterClsName == "鑷埗")
+ {
+ tb2.Rows[i]["HMaterClsID"] = 2;
+ }
+ else if (HMaterClsName == "濮斿")
+ {
+ tb2.Rows[i]["HMaterClsID"] = 3;
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡灞炴�т笉瀛樺湪锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //鏌ヨ璁¢噺鍗曚綅缁�
+ ds = oCN.RunProcReturn("select * from Gy_UnitGroup where HName='" + HUnitGroupName + "'", "Gy_UnitGroup");
+
+ if (ds.Tables[0].Rows.Count == 0 && HUnitGroupName != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + "璁¢噺鍗曚綅缁�:" + HUnitGroupName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else if (HMaterNumber == "")
+ {
+ tb2.Rows[i]["HUnitGroupID"] = 0;
+ }
+ else
+ {
+ tb2.Rows[i]["HUnitGroupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ鍗曚綅
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HNumber='" + HUnitNumber + "' and HUSEORGID=" + HORGid + "", "Gy_Unit");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HUnitName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ杈呭姪鍗曚綅
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HSecUnitName + "' and HUSEORGID=" + HORGid + "", "Gy_Unit");
+
+ if (ds.Tables[0].Rows.Count == 0 && HSecUnitName != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HSecUnitName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }else if (HSecUnitName == "")
+ {
+ tb2.Rows[i]["HSecUnitID"] = 0;
+ }
+ else
+ {
+ tb2.Rows[i]["HSecUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ浠撳簱
+ ds = oCN.RunProcReturn("select * from Gy_Warehouse where HName='" + HWhName + "' and HUSEORGID=" + HORGid + "", "Gy_Warehouse");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撳簱:" + HWhName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HWHID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鐗╂枡鍚嶇О
+ if (HMaterName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //鐗╂枡浠g爜
+ if (HMaterNumber == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡缂栧彿涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鐗╂枡椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_Material/Gy_Material_btnSave")]
+ [HttpPost]
+ public object Gy_Material_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("Gy_Material_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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)
+ {
+ DLL.ClsGy_Material_Ctl oBill = new DLL.ClsGy_Material_Ctl();
+ ClsGy_Material_Model oItem = new ClsGy_Material_Model();
+ //璧嬪�煎墠绔紶鍏ョ殑
+ oItem.HUSEORGID = int.Parse(item["HOrgID"].ToString());
+ oItem.HNumber = item["鐗╂枡浠g爜"].ToString();
+ oItem.HName = item["鐗╂枡鍚嶇О"].ToString();
+ oItem.HModel = item["瑙勬牸鍨嬪彿"].ToString();
+ oItem.HHelpCode = item["鍔╄鐮�"].ToString();
+ oItem.HVersion = item["鐗堟湰鍙�"].ToString();
+ oItem.HMaterClsID = int.Parse(item["HMaterClsID"].ToString());
+ oItem.HUnitGroupID = int.Parse(item["HUnitGroupID"].ToString());
+ oItem.HUnitID = int.Parse(item["HUnitID"].ToString());
+ oItem.HSecUnitID = int.Parse(item["HSecUnitID"].ToString());
+ oItem.HSecUnitRate = double.Parse(item["鎹㈢畻鐜�"].ToString()==""?"0": item["鎹㈢畻鐜�"].ToString());
+ oItem.HWhID = int.Parse(item["HWhID"].ToString());
+ oItem.HHighStock = int.Parse(item["鏈�楂樺簱瀛�"].ToString() == "" ? "0" : item["鏈�楂樺簱瀛�"].ToString());
+ oItem.HLowStock = int.Parse(item["鏈�浣庡簱瀛�"].ToString() == "" ? "0" : item["鏈�浣庡簱瀛�"].ToString());
+ oItem.HSafeStock = int.Parse(item["瀹夊叏搴撳瓨"].ToString() == "" ? "0" : item["瀹夊叏搴撳瓨"].ToString());
+ oItem.HOrderPrice = int.Parse(item["閲囪喘鍗曚环"].ToString() == "" ? "0" : item["閲囪喘鍗曚环"].ToString());
+ oItem.HSalePrice = int.Parse(item["閿�鍞崟浠�"].ToString() == "" ? "0" : item["閿�鍞崟浠�"].ToString());
+ oItem.HPlanPrice = int.Parse(item["璁″垝鍗曚环"].ToString() == "" ? "0" : item["璁″垝鍗曚环"].ToString());
+ oItem.HstdPrice = int.Parse(item["鏍囧噯鎴愭湰"].ToString() == "" ? "0" : item["鏍囧噯鎴愭湰"].ToString());
+ oItem.HKeepDays = int.Parse(item["淇濊川鏈�"].ToString() == "" ? "0" : item["淇濊川鏈�"].ToString());
+ oItem.HQtyMin = int.Parse(item["鏈�灏忚璐ч噺"].ToString() == "" ? "0" : item["鏈�灏忚璐ч噺"].ToString());
+ oItem.HQtyMin = int.Parse(item["鏈�澶ц璐ч噺"].ToString() == "" ? "0" : item["鏈�澶ц璐ч噺"].ToString());
+ oItem.HEngName = item["鑻辨枃鍚嶇О"].ToString();
+ oItem.HEngModel = item["鑻辨枃瑙勬牸"].ToString();
+ //甯歌璧嬪��
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ oItem.HShortNumber = sShortNumber;//鐭唬鐮�
+ oItem.HEndFlag = true;//鏈骇鏍囧織
+ oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇
+ oBill.oModel = oItem;
+ if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + oItem.HNumber.Trim() + "'", "Gy_Material");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+
+ oBill.AddNew();
+ }
+ else
+ {
+
+ int HItemID = int.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());
+ oBill.ModifyByID(HItemID);
+
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
/// <summary>
/// 鐗╂枡璁剧疆鍒犻櫎鍔熻兘
/// </summary>
@@ -2710,5 +3159,589 @@
}
#endregion
+ #region 鍣ㄥ叿妗f 鏂囦欢瀵煎叆淇濆瓨
+ #region 鍣ㄥ叿妗f 鏂囦欢涓婁紶
+ [Route("Gy_MouldFile/Gy_MouldFile_Excel")]
+ [HttpPost]
+ public object Gy_Mould_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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("HMaterID", typeof(Int32));//鐗╂枡ID
+ tb2.Columns.Add("HMouldTypeID", typeof(Int32));//鍒嗙被ID
+ tb2.Columns.Add("HUnitID", typeof(Int32));//鍗曚綅ID
+ tb2.Columns.Add("HDeptID", typeof(Int32));//閮ㄩ棬ID
+ tb2.Columns.Add("HWHID", typeof(Int32));//浠撳簱ID
+ tb2.Columns.Add("HSupID", typeof(Int32));//渚涘簲鍟咺D
+ tb2.Columns.Add("HSPID", typeof(Int32));//浠撲綅ID
+ tb2.Columns.Add("HMadeSupID", typeof(Int32));//鍒堕�犲晢ID
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var 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("鍣ㄥ叿鍒嗙被"))
+ error += "娌℃湁鎵惧埌銆愬櫒鍏峰垎绫汇�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍣ㄥ叿瑙勬牸"))
+ error += "娌℃湁鎵惧埌銆愬櫒鍏疯鏍笺�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍣ㄥ叿鍨嬪彿"))
+ error += "娌℃湁鎵惧埌銆愬櫒鍏峰瀷鍙枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("绌存暟"))
+ error += "娌℃湁鎵惧埌銆愮┐鏁般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("杈呭姪灞炴��1"))
+ error += "娌℃湁鎵惧埌銆愯緟鍔╁睘鎬�1銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("杈呭姪灞炴��2"))
+ error += "娌℃湁鎵惧埌銆愯緟鍔╁睘鎬�2銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍥惧彿"))
+ error += "娌℃湁鎵惧埌銆愬浘鍙枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀵瑰簲ERP鐗╂枡浠g爜"))
+ error += "娌℃湁鎵惧埌銆愬搴擡RP鐗╂枡浠g爜銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀵瑰簲ERP鐗╂枡"))
+ error += "娌℃湁鎵惧埌銆愬搴擡RP鐗╂枡銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁¢噺鍗曚綅"))
+ error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶃�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍣ㄥ叿鍑哄巶缂栧彿"))
+ error += "娌℃湁鎵惧埌銆愬櫒鍏峰嚭鍘傜紪鍙枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("浣跨敤閮ㄩ棬"))
+ error += "娌℃湁鎵惧埌銆愪娇鐢ㄩ儴闂ㄣ�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐘舵��"))
+ error += "娌℃湁鎵惧埌銆愮姸鎬併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("榛樿浠撳簱"))
+ error += "娌℃湁鎵惧埌銆愰粯璁や粨搴撱�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("榛樿浠撲綅"))
+ error += "娌℃湁鎵惧埌銆愰粯璁や粨浣嶃�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗堟湰鍙�"))
+ error += "娌℃湁鎵惧埌銆愮増鏈彿銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁捐瀵垮懡"))
+ 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("鍒堕�犲晢"))
+ error += "娌℃湁鎵惧埌銆愬埗閫犲晢銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HMouldName = "";
+ string HMouldNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+ string HMaterNumber = "";
+ string HMaterName = "";
+ string HUnitName = "";
+ string HDeptName = "";
+ string HWHName = "";
+ string HSPName = "";
+ string HSupName = "";
+ string HSupNumber = "";
+ string HMadeSupName = "";
+ string HMouldTypeName = "";
+
+ HMouldName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿鍚嶇О"].ToString());
+ HMouldNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿缂栧彿"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+ HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡浠g爜"].ToString());
+ HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡"].ToString());
+ HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString());
+ HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["浣跨敤閮ㄩ棬"].ToString());
+ HWHName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撳簱"].ToString());
+ HSPName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撲綅"].ToString());
+ HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString());
+ HSupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString());
+ HMadeSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍒堕�犲晢"].ToString());
+ HMouldTypeName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿鍒嗙被"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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_MouldType where HName='" + HMouldTypeName + "' ", "Gy_MouldType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,鍒嗙被:" + HMouldTypeName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HMouldTypeID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ鐗╂枡
+ ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumber + "' and HUSEORGID=" + HORGid + "", "Gy_Department");
+
+ if (ds.Tables[0].Rows.Count == 0 && HMaterNumber != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鐗╂枡:" + HMaterName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else if (HMaterNumber == "")
+ {
+ tb2.Rows[i]["HMaterID"] = 0;
+ }
+ else
+ {
+ tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ鍗曚綅
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HUnitName + "' and HUSEORGID=" + HORGid + "", "Gy_Unit");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HUnitName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ閮ㄩ棬
+ ds = oCN.RunProcReturn("select * from Gy_Department where HName='" + HDeptName + "' and HUSEORGID=" + HORGid + "", "Gy_Department");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,閮ㄩ棬:" + HDeptName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ浠撳簱
+ ds = oCN.RunProcReturn("select * from Gy_Warehouse where HName='" + HWHName + "' and HUSEORGID=" + HORGid + "", "Gy_Warehouse");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撳簱:" + HWHName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HWHID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ string HWHID = tb2.Rows[i]["HWHID"].ToString();
+ //鏌ヨ浠撲綅
+ ds = oCN.RunProcReturn("select * from Gy_StockPlace where HName='" + HSPName + "'and HSPGroupID=" + HWHID+ " and HUSEORGID=" + HORGid + "", "Gy_Warehouse");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撲綅:" + HSPName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HSPID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ渚涘簲鍟�
+ ds = oCN.RunProcReturn("select * from Gy_Supplier where HNumber='" + HSupNumber + "' 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_Supplier where HName='" + HMadeSupName + "' and HUSEORGID=" + HORGid + "", "Gy_Supplier");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍒堕�犲晢:" + HMadeSupName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HMadeSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+ //鍣ㄥ叿妗f鍚嶇О
+ if (HMouldName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鍣ㄥ叿妗f鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //鍣ㄥ叿妗f浠g爜
+ if (HMouldNum == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鍣ㄥ叿妗f浠g爜涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鍣ㄥ叿妗f椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_MouldFile/Gy_MouldFile_btnSave")]
+ [HttpPost]
+ public object Gy_Mould_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("Gy_MouldFile_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string BillType = "3899";
+ //寰楀埌mainid
+ long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ string HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); ;//閫掑叆type寰楀埌鐨勫崟鎹彿
+ DateTime HDate = DateTime.Now;//鏃ユ湡
+ int HYear = DBUtility.ClsPub.isInt(DateTime.Now.Year);
+ double HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+ string HMouldNo = item["鍣ㄥ叿缂栧彿"].ToString();
+ string HBarCode = item["鏉″舰鐮�"].ToString();
+ string HName = item["鍣ㄥ叿鍚嶇О"].ToString();
+ string HModel = item["鍣ㄥ叿瑙勬牸"].ToString();
+ string HModel2 = item["鍣ㄥ叿鍨嬪彿"].ToString();
+ string HDiameter = "";//鐩村緞
+ string HSubjoin = item["杈呭姪灞炴��1"].ToString();
+ string HSubjoin2 = item["杈呭姪灞炴��2"].ToString();
+ string HPICNo = item["鍥惧彿"].ToString();
+ string HWorkMaterModel = "";//鐢熶骇浜у搧鍨嬪彿
+ long HMaterID = int.Parse(item["HMaterID"].ToString());
+ long HMouleTypeID = int.Parse(item["HMouldTypeID"].ToString());
+ long HUnitID = int.Parse(item["HUnitID"].ToString());
+ DateTime HOutComDate = DateTime.Now;
+ string HOutComNo = item["鍣ㄥ叿鍑哄巶缂栧彿"].ToString();
+ long HDeptID = int.Parse(item["HDeptID"].ToString());
+ long HSupID = int.Parse(item["HSupID"].ToString());
+ string HMouldStatus = item["鐘舵��"].ToString();
+ long HWHID = int.Parse(item["HWHID"].ToString());
+ long HRoutingID = 0;//宸ヨ壓璺嚎id
+ long HBOMID = 0;
+ string HVersion = "";//鐗堟湰
+ long HSPGroupID = 0;//榛樿浠撲綅缁�
+ long HSPID = int.Parse(item["HSPID"].ToString());//浠撲綅id
+ Double HDesignLife = item["璁捐瀵垮懡"].ToString()=="" ? 0: double.Parse(item["璁捐瀵垮懡"].ToString());
+ Double HUseLife = item["浣跨敤瀵垮懡"].ToString() == "" ? 0 : double.Parse(item["浣跨敤瀵垮懡"].ToString());
+ Double HInitLife = 0;//涓婄嚎鍒濆鍖栧鍛�
+ Double HLeaveLife = 0;//鍓╀綑瀵垮懡
+ Double HProdQty = 0;//宸茬敓浜ф暟閲�
+ Double HProdWeight = 0;//宸茬敓浜ч噸閲�
+ string HRemark = item["澶囨敞"].ToString();
+ string HMaker = user;
+ string HMaterNumber = item["瀵瑰簲ERP鐗╂枡浠g爜"].ToString();
+ string HSupNumber = item["渚涘簲鍟嗕唬鐮�"].ToString();
+ long HPrintQty = 0;//宸茬敓浜ф暟閲�
+ string HMouldOWNER = "鑷垂";//璐т富绫诲瀷
+ string HSaveLife = "";//瀹夊叏瀵垮懡
+ int HCaveQty = item["绌存暟"].ToString() == "" ? 0 : int.Parse(item["绌存暟"].ToString());
+ int HMouldDotCheckRuleInterID = 0;
+ int HMouldMaintainRuleInterID = 0;
+ int HNowSupID = 0;//铏氭嫙浠�
+ int HNowSupTypeID = 0;
+ int HMadeSupID = 0;
+ string HMouldClass = "妯″叿";//鍣ㄥ叿绫诲瀷
+ int HNowWHID = 0;
+ int HNowSPID = 0;
+
+
+ if (!DBUtility.ClsPub.AllowNumber(HMouldNo.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_MouldFileMain where HMouldNo='" + HMouldNo + "'", "Gy_MouldFileMain");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+
+ oCN.RunProc("Insert Into Gy_MouldFileMain " +
+ "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+ ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+ ",HMouldNo,HName,HModel,HModel2,HDiameter" +
+ ",HSubjoin,HSubjoin2,HPICNo,HWorkMaterModel" +
+ ",HMaterID,HMaterNumber,HMouldType,HUnitID" +
+ ",HOutComDate,HOutComNo,HDeptID,HSupID,HSupNumber" +
+ ",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" +
+ ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" +
+ ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" +
+ ",HMouldClass,HNowWHID,HNowSPID,HInitLife) " +
+ " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
+ "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" +
+ ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" +
+ ",'" + HSubjoin + "','" + HSubjoin2 + "','" + HPICNo + "','" + HWorkMaterModel + "'" +
+ "," + HMaterID + ",'" + HMaterNumber + "'," + HMouleTypeID + "," + HUnitID +
+ ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HSupID + ",'" + HSupNumber + "'" +
+ "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty +
+ "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" +
+ ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID +
+ ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "') ");
+ }
+ else
+ {
+ oCN.RunProc("UpDate Gy_MouldFileMain set " +
+ //" HBillNo='" + HBillNo + "'" + //鍥哄畾璧嬪��===============
+ //",HDate='" + HDate + "'" +
+ //",HYear='" + HYear.ToString() + "'" +
+ //",HPeriod='" + HPeriod.ToString() + "'" +
+ "HRemark='" + HRemark + "'" +
+ ",HUpDater='" + user + "'" +
+ ",HUpDateDate=getdate()" +
+ //========================================
+ //",HMouldNo='" + HMouldNo + "'" +
+ ",HName='" + HName + "'" +
+ ",HModel='" + HModel + "'" +
+ ",HModel2='" + HModel2 + "'" +
+ ",HDiameter='" + HDiameter + "'" +
+ ",HSubjoin='" + HSubjoin + "'" +
+ ",HSubjoin2='" + HSubjoin2 + "'" +
+ ",HPICNo='" + HPICNo + "'" +
+ ",HWorkMaterModel='" + HWorkMaterModel + "'" +
+ ",HMaterID=" + HMaterID.ToString() +
+ ",HMaterNumber='" + HMaterNumber + "'" +
+ ",HMouldClass='" + HMouldClass + "'" +
+ ",HMouldType=" + HMouleTypeID.ToString() +
+ ",HUnitID=" + HUnitID.ToString() +
+ ",HOutComDate='" + HOutComDate + "'" +
+ ",HOutComNo='" + HOutComNo + "'" +
+ ",HDeptID=" + HDeptID.ToString() +
+ ",HSupID=" + HSupID.ToString() +
+ ",HSupNumber='" + HSupNumber + "'" +
+ ",HPrintQty=" + HPrintQty.ToString() +
+ ",HMouldStatus='" + HMouldStatus + "'" +
+ ",HSaveLife='" + HSaveLife + "'" +
+ ",HWhID=" + HWHID.ToString() +
+ ",HRoutingID=" + HRoutingID.ToString() +
+ ",HBomID=" + HBOMID.ToString() +
+ ",HVersion='" + HVersion + "'" +
+ ",HSPGroupID=" + HSPGroupID.ToString() +
+ ",HSPID=" + HSPID.ToString() +
+ ",HDesignLife=" + HDesignLife.ToString() +
+ ",HCaveQty=" + HCaveQty.ToString() +
+ ",HUseLife=" + HUseLife.ToString() +
+ ",HLeaveLife=" + HLeaveLife.ToString() +
+ ",HProdQty=" + HProdQty.ToString() +
+ ",HMouldDotCheckRuleInterID=" + HMouldDotCheckRuleInterID.ToString() +
+ ",HMouldMaintainRuleInterID=" + HMouldMaintainRuleInterID.ToString() +
+ ",HMouldOWNER='" + HMouldOWNER + "'" +
+ ",HNowSupID=" + HNowSupID.ToString() +
+ ",HNowSupTypeID=" + HNowSupTypeID.ToString() +
+ ",HProdWeight=" + HProdWeight.ToString() +
+ ",HBarCode='" + HBarCode.ToString() + "'" +
+ ",HMadeSupID=" + HMadeSupID +
+ ",HNowWHID=" + HNowWHID +
+ ",HNowSPID=" + HNowSPID +
+ ",HInitLife='" + HInitLife +
+ "' where HMouldNo='" + HMouldNo.ToString()+"'");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
}
}
\ No newline at end of file
diff --git a/WebAPI/Controllers/BaseSet/Gy_ModelTypeController.cs b/WebAPI/Controllers/BaseSet/Gy_ModelTypeController.cs
index 43cab7d..8a8054d 100644
--- a/WebAPI/Controllers/BaseSet/Gy_ModelTypeController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_ModelTypeController.cs
@@ -9,7 +9,10 @@
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
-
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers.BaseSet
{
public class Gy_ModelTypeController : ApiController
@@ -553,5 +556,265 @@
}
#endregion
+ #region 鍣ㄥ叿鍒嗙被 鏂囦欢瀵煎叆淇濆瓨
+ #region 鍣ㄥ叿鍒嗙被 鏂囦欢涓婁紶
+ [Route("Gy_MouldType/Gy_MouldType_Excel")]
+ [HttpPost]
+ public object Gy_MouldType_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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
+
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var error = "";
+
+ //鏌ヨ娌℃湁鐨勫垪
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍣ㄥ叿鍒嗙被"))
+ error += "娌℃湁鎵惧埌銆愬櫒鍏峰垎绫诲悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍣ㄥ叿鍒嗙被浠g爜"))
+ error += "娌℃湁鎵惧埌銆愬櫒鍏峰垎绫讳唬鐮併�戠殑鏍囬,";
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+ if (!tb2.Columns.Contains("鍔╄鐮�"))
+ error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HProcessName = "";
+ string HProcessNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+
+
+ HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿鍒嗙被"].ToString());
+ HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿鍒嗙被浠g爜"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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();
+
+ //鍣ㄥ叿鍒嗙被鍚嶇О
+ if (HProcessName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鍣ㄥ叿鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //鍣ㄥ叿鍒嗙被浠g爜
+ if (HProcessNum == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鍣ㄥ叿鍒嗙被浠g爜涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鍣ㄥ叿鍒嗙被椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_MouldType/Gy_MouldType_btnSave")]
+ [HttpPost]
+ public object Gy_MouldType_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("Gy_ErrType_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HName = item["鍣ㄥ叿鍒嗙被"].ToString();
+ string HNumber = item["鍣ㄥ叿鍒嗙被浠g爜"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+ string HHelpCode = item["鍔╄鐮�"].ToString();
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ int HEndFlag = 1;//鏈骇鏍囧織
+ int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //绛夌骇
+
+
+ if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_MouldType where HNumber='" + HNumber + "'", "Gy_MouldType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ oCN.RunProc("Insert into Gy_MouldType " +
+ " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime) " +
+ " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 +
+ "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "',getdate())");
+ }
+ else
+ {
+ oCN.RunProc("update Gy_MouldType set HUSEORGID=" + HOrgID + ",HHelpCode = '"+ HHelpCode + "',HRemark='" + HRemark + "' where HNumber='" + HNumber + "'");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
}
}
diff --git a/WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs b/WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs
index dbb259b..bd0d21b 100644
--- a/WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs
+++ b/WebAPI/Controllers/SBGL/Gy_EquipFileMainController.cs
@@ -9,7 +9,10 @@
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
-
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers.SBGL
{
public class Gy_EquipFileMainController : ApiController
@@ -1315,5 +1318,530 @@
#endregion
+ #region 璁惧妗f 鏂囦欢瀵煎叆淇濆瓨
+ #region 璁惧妗f 鏂囦欢涓婁紶
+ [Route("Gy_EquipFileMain/Gy_EquipFileMain_Excel")]
+ [HttpPost]
+ public object Gy_EquipFile_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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("HMaterID", typeof(Int32));//鐗╂枡ID
+ tb2.Columns.Add("HEquipTypeID", typeof(Int32));//鍒嗙被ID
+ tb2.Columns.Add("HUnitID", typeof(Int32));//鍗曚綅ID
+ tb2.Columns.Add("HDeptID", typeof(Int32));//閮ㄩ棬ID
+ tb2.Columns.Add("HUseEmpID", typeof(Int32));//浣跨敤璐熻矗浜篒D
+ tb2.Columns.Add("HRepairEmpID", typeof(Int32));//缁存姢璐熻矗浜篒D
+ tb2.Columns.Add("HSupID", typeof(Int32));//渚涘簲鍟咺D
+ tb2.Columns.Add("HMadeSupID", typeof(Int32));//鍒堕�犲晢ID
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var 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("璁惧鍒嗙被"))
+ error += "娌℃湁鎵惧埌銆愯澶囧垎绫汇�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁惧瑙勬牸"))
+ error += "娌℃湁鎵惧埌銆愯澶囪鏍笺�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁惧鍨嬪彿"))
+ error += "娌℃湁鎵惧埌銆愯澶囧瀷鍙枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀵瑰簲ERP鐗╂枡浠g爜"))
+ error += "娌℃湁鎵惧埌銆愬搴擡RP鐗╂枡浠g爜銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀵瑰簲ERP鐗╂枡"))
+ error += "娌℃湁鎵惧埌銆愬搴擡RP鐗╂枡銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁¢噺鍗曚綅"))
+ error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶃�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁惧鍑哄巶鏃ユ湡"))
+ error += "娌℃湁鎵惧埌銆愯澶囧嚭鍘傛棩鏈熴�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁惧鍑哄巶缂栧彿"))
+ error += "娌℃湁鎵惧埌銆愯澶囧嚭鍘傜紪鍙枫�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("浣跨敤閮ㄩ棬"))
+ error += "娌℃湁鎵惧埌銆愪娇鐢ㄩ儴闂ㄣ�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("浣跨敤璐熻矗浜�"))
+ error += "娌℃湁鎵惧埌銆愪娇鐢ㄨ礋璐d汉銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁存姢璐熻矗浜�"))
+ error += "娌℃湁鎵惧埌銆愮淮鎶よ礋璐d汉銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀹夎鍦扮偣"))
+ error += "娌℃湁鎵惧埌銆愬畨瑁呭湴鐐广�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("瀹夎鏃ユ湡"))
+ error += "娌℃湁鎵惧埌銆愬畨瑁呮棩鏈熴�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("杩愯寮�濮嬫棩鏈�"))
+ error += "娌℃湁鎵惧埌銆愯繍琛屽紑濮嬫棩鏈熴�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("宸ョ▼缂栫爜"))
+ error += "娌℃湁鎵惧埌銆愬伐绋嬬紪鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鏉″舰鐮�"))
+ error += "娌℃湁鎵惧埌銆愭潯褰㈢爜銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("浜у湴"))
+ error += "娌℃湁鎵惧埌銆愪骇鍦般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍝佺墝"))
+ error += "娌℃湁鎵惧埌銆愬搧鐗屻�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("渚涘簲鍟�"))
+ error += "娌℃湁鎵惧埌銆愪緵搴斿晢銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍒堕�犲晢"))
+ error += "娌℃湁鎵惧埌銆愬埗閫犲晢銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HEquipName = "";
+ string HEquipNo = "";
+ string HORGNumber = "";
+ string HORGName = "";
+ string HMaterNumber = "";
+ string HMaterName = "";
+ string HUnitName = "";
+ string HDeptName = "";
+ string HUseEmpName = "";
+ string HRepairEmpName = "";
+ string HSupName = "";
+ string HMadeSupName = "";
+ string HEquipTypeName = "";
+
+ HEquipName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍚嶇О"].ToString());
+ HEquipNo = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧缂栧彿"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+ HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡浠g爜"].ToString());
+ HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡"].ToString());
+ HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString());
+ HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["浣跨敤閮ㄩ棬"].ToString());
+ HUseEmpName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["浣跨敤璐熻矗浜�"].ToString());
+ HRepairEmpName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁存姢璐熻矗浜�"].ToString());
+ HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString());;
+ HMadeSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍒堕�犲晢"].ToString());
+ HEquipTypeName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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_EquipFileType where HName='" + HEquipTypeName + "' ", "EquipFileType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,鍒嗙被:" + HEquipTypeName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HEquipTypeID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ鐗╂枡
+ ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumber + "' and HUSEORGID=" + HORGid + "", "Gy_Department");
+
+ if (ds.Tables[0].Rows.Count == 0 && HMaterNumber != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鐗╂枡:" + HMaterName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else if (HMaterNumber == "")
+ {
+ tb2.Rows[i]["HMaterID"] = 0;
+ }
+ else
+ {
+ tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ鍗曚綅
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HUnitName + "' and HUSEORGID=" + HORGid + "", "Gy_Unit");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HUnitName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ閮ㄩ棬
+ ds = oCN.RunProcReturn("select * from Gy_Department where HName='" + HDeptName + "' and HUSEORGID=" + HORGid + "", "Gy_Department");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,閮ㄩ棬:" + HDeptName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ浣跨敤璐熻矗浜�
+ ds = oCN.RunProcReturn("select * from Gy_Employee where HName='" + HUseEmpName + "' and HUSEORGID=" + HORGid + "", "Gy_Employee");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浣跨敤璐熻矗浜�:" + HUseEmpName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HUseEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ缁存姢璐熻矗浜�
+ ds = oCN.RunProcReturn("select * from Gy_Employee where HName='" + HRepairEmpName + "' and HUSEORGID=" + HORGid + "", "Gy_Employee");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,缁存姢璐熻矗浜轰汉:" + HRepairEmpName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HRepairEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ //鏌ヨ渚涘簲鍟�
+ ds = oCN.RunProcReturn("select * from Gy_Supplier where HName='" + HSupName + "' 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_Supplier where HName='" + HMadeSupName + "' and HUSEORGID=" + HORGid + "", "Gy_Supplier");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍒堕�犲晢:" + HMadeSupName + ",涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HMadeSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+
+ //璁惧妗f鍚嶇О
+ if (HEquipName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,璁惧妗f鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //璁惧妗f浠g爜
+ if (HEquipNo == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,璁惧妗f缂栧彿涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 璁惧妗f椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_EquipFileMain/Gy_EquipFileMain_btnSave")]
+ [HttpPost]
+ public object Gy_EquipFile_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("Gy_EquipFile_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string BillType = "3308";
+ //寰楀埌mainid
+ long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ string HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); ;//閫掑叆type寰楀埌鐨勫崟鎹彿
+ DateTime HDate = DateTime.Now;//鏃ユ湡
+ string HYear = DateTime.Now.Year.ToString();
+ string HEquipFileNumber = "";
+ string HEquipFileNo = item["璁惧缂栧彿"].ToString(); // varchar(50) //璁惧缂栫爜(鍞竴)
+ string HName = item["璁惧鍚嶇О"].ToString(); // 鈭� varchar(100) //璁惧鍚嶇О
+ string HModel = item["璁惧瑙勬牸"].ToString(); // 鈭� varchar(100) //璁惧瑙勬牸
+ string HModel2 = item["璁惧鍨嬪彿"].ToString(); // 鈭� varchar(100) //璁惧鍨嬪彿
+ int HMaterID = int.Parse(item["HMaterID"].ToString()); // 鈭� int //瀵瑰簲鐗╂枡
+ int HUnitID = int.Parse(item["HUnitID"].ToString()); // 鈭� int //鍗曚綅
+ string HOutComDate = item["璁惧鍑哄巶鏃ユ湡"].ToString() == "" ? DateTime.Now.ToString() : item["璁惧鍑哄巶鏃ユ湡"].ToString(); // 鈭� datetime //璁惧鍑哄巶鏃ユ湡
+ string HOutComNo = item["璁惧鍑哄巶缂栧彿"].ToString(); // 鈭� varchar(100) //璁惧鍑哄巶缂栧彿
+ int HDeptID = int.Parse(item["HDeptID"].ToString()); // 鈭� int //浣跨敤閮ㄩ棬锛坓y_Department锛�
+ int HUseEmpID = int.Parse(item["HUseEmpID"].ToString()); //鈭� int //浣跨敤璐熻矗浜猴紙gy_Employee锛�
+ int HRepairEmpID = int.Parse(item["HRepairEmpID"].ToString()); //鈭� int //缁存姢璐熻矗浜猴紙gy_Employee锛�
+ string HAddress = item["瀹夎鍦扮偣"].ToString(); // 鈭� varchar(500) //瀹夎鍦扮偣
+ string HSetupDate = item["瀹夎鏃ユ湡"].ToString() == "" ? DateTime.Now.ToString() : item["瀹夎鏃ユ湡"].ToString(); //鈭� datetime //瀹夎鏃ユ湡
+ string HStartupDate = item["杩愯寮�濮嬫棩鏈�"].ToString() == "" ? DateTime.Now.ToString() : item["杩愯寮�濮嬫棩鏈�"].ToString(); //鈭� datetime //杩愯寮�濮嬫棩鏈�
+ string HStatus = "绌洪棽"; // 鈭� varchar(20) //褰撳墠鐘舵�侊紙绌洪棽銆佸崰鐢ㄣ�佸姞宸ャ�佸叧鏈恒�佸紓甯稿仠鏈猴級
+ int HEquipFileTypeID = int.Parse(item["HEquipTypeID"].ToString()); //鈭� int //璁惧绫诲埆锛圙y_EquipFileType)
+ string HProNum = item["宸ョ▼缂栫爜"].ToString(); // 鈭� varchar(100) //宸ョ▼缂栫爜
+ string HBarCode = item["鏉″舰鐮�"].ToString(); //鈭� varchar(100) //鏉″舰鐮�(鏆傛椂淇濆瓨姝ゅ瓧娈�)
+ string HWorkArea = item["浜у湴"].ToString(); //鈭� varchar(50) //浜у湴
+ string HLogo = item["鍝佺墝"].ToString(); //鈭� varchar(50) //鍝佺墝
+ int HSellSupID = int.Parse(item["HSupID"].ToString()); // 鈭� int //渚涘簲鍟�(Gy_Supplier)
+ int HMakeSupID = int.Parse(item["HMadeSupID"].ToString()); // int //鍒堕�犲晢 (Gy_Supplier)
+ string HMainSourceFlag = "鍚�"; //varchar(10) //鏄惁涓荤敓浜ц澶�(鍚︼紝鏄�)
+ string HMacAddress = ""; // varchar(50) //鏁伴噰鐗╃悊鍦板潃
+ int HMainSourceID = 0; //int //鎵�灞炰富鐢熶骇璁惧锛圙y_EquipFileBillMain锛�
+ string HMaker = user;
+ string HMakeDate = DateTime.Now.Date.ToString();
+ int HEquipDotCheckRuleInterID = 0;
+ int HEquipMaintainRuleInterID = 0;
+ int HSourceID = 0;
+
+
+ if (!DBUtility.ClsPub.AllowNumber(HEquipFileNo.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_EquipFileBillMain where HEquipFileNo='" + HEquipFileNo + "'", "Gy_EquipFileBillMain");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+
+ oCN.RunProc("Insert into Gy_EquipFileBillMain " +
+ " (HInterID,hbillno,HEquipFileNumber,HEquipFileNo,HName,HModel,HModel2,HMaterID,HUnitID,HOutComDate" +
+ ",HOutComNo,HDeptID,HUseEmpID,HRepairEmpID,HAddress,HSetupDate,HStartupDate,HStatus," +
+"HEquipFileTypeID,HProNum,HBarCode,HWorkArea,HLogo,HSellSupID,HMakeSupID,hbilltype,HDate,HYear,HMaker,HMakeDate,HEquipMaintainRuleInterID,HEquipDotCheckRuleInterID,HSourceID,HMainSourceFlag,HMacAddress,HMainSourceID) " +
+ " Values(" + HInterID + ",'" + HBillNo + "','" + HEquipFileNumber + "','" + HEquipFileNo + "','" + HName + "','" + HModel + "','" + HModel2 + "'," + HMaterID + "," + HUnitID +
+ ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HUseEmpID + "," + HRepairEmpID + ",'" + HAddress +
+ "','" + HSetupDate + "','" + HStartupDate + "','" + HStatus + "'," + HEquipFileTypeID + ",'" + HProNum +
+ "','" + HBarCode + "','" + HWorkArea + "','" + HLogo + "'," + HSellSupID + "," + HMakeSupID + ",'3308','" + HDate + "','" + HYear + "','" + HMaker + "','" + HMakeDate + "','" + HEquipMaintainRuleInterID + "','" + HEquipDotCheckRuleInterID + "'," + HSourceID + ",'" + HMainSourceFlag + "','" + HMacAddress + "','" + HMainSourceID + "')");
+ }
+ else
+ {
+ oCN.RunProc("Update Gy_EquipFileBillMain set " +
+ " HEquipFileNumber='" + HEquipFileNumber + "'" +
+ //",HEquipFileNo='" + HEquipFileNo + "'" +
+ ",HName='" + HName + "'" +
+ ",HModel='" + HModel + "'" +
+ ",HModel2='" + HModel2 + "'" +
+ ",HMaterID=" + HMaterID +
+ ",HUnitID=" + HUnitID +
+ ",HOutComDate='" + HOutComDate + "'" +
+ ",HOutComNo='" + HOutComNo + "'" +
+ ",HDeptID=" + HDeptID +
+ ",HUseEmpID=" + HUseEmpID +
+ ",HRepairEmpID=" + HRepairEmpID +
+ ",HAddress='" + HAddress + "'" +
+ ",HSetupDate='" + HSetupDate + "'" +
+ ",HStartupDate='" + HStartupDate + "'" +
+ ",HStatus='" + HStatus + "'" +
+ ",HEquipFileTypeID=" + HEquipFileTypeID +
+ ",HProNum='" + HProNum + "'" +
+ ",HBarCode='" + HBarCode + "'" +
+ ",HWorkArea='" + HWorkArea + "'" +
+ ",HLogo='" + HLogo + "'" +
+ ",HSellSupID=" + HSellSupID +
+ ",HMakeSupID= " + HMakeSupID +
+ ",HUpDater= '" + user + "'" +
+ ",HUpDateDate= getdate()" + "" +
+ ",HEquipDotCheckRuleInterID='" + HEquipDotCheckRuleInterID + "'" +
+ ",HEquipMaintainRuleInterID='" + HEquipMaintainRuleInterID + "'" +
+ ",HSourceID='" + HSourceID + "'" +
+ ",HMainSourceFlag= '" + HMainSourceFlag + "'" +
+ ",HMacAddress= '" + HMacAddress + "'" +
+ ",HMainSourceID = '" + HMainSourceID + "'" +
+ " Where HEquipFileNo='" + HEquipFileNo + "'");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
}
}
diff --git a/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs b/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
index 8470eb3..898371b 100644
--- a/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
+++ b/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs
@@ -8,7 +8,10 @@
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
-
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers.SBGL
{
public class Gy_EquipTypeController : ApiController
@@ -569,5 +572,266 @@
}
#endregion
+ #region 璁惧鍒嗙被 鏂囦欢瀵煎叆淇濆瓨
+ #region 璁惧鍒嗙被 鏂囦欢涓婁紶
+ [Route("Gy_EquipType/Gy_EquipType_Excel")]
+ [HttpPost]
+ public object Gy_EquipType_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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
+
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var error = "";
+
+ //鏌ヨ娌℃湁鐨勫垪
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁惧鍒嗙被"))
+ error += "娌℃湁鎵惧埌銆愯澶囧垎绫诲悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璁惧鍒嗙被浠g爜"))
+ error += "娌℃湁鎵惧埌銆愯澶囧垎绫讳唬鐮併�戠殑鏍囬,";
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+ if (!tb2.Columns.Contains("鍔╄鐮�"))
+ error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HProcessName = "";
+ string HProcessNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+
+
+ HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被"].ToString());
+ HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被浠g爜"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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();
+
+ //璁惧鍒嗙被鍚嶇О
+ if (HProcessName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,璁惧鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //璁惧鍒嗙被浠g爜
+ if (HProcessNum == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,璁惧鍒嗙被浠g爜涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 璁惧鍒嗙被椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_EquipType/Gy_EquipType_btnSave")]
+ [HttpPost]
+ public object Gy_EquipType_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("Gy_ErrType_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HName = item["璁惧鍒嗙被"].ToString();
+ string HNumber = item["璁惧鍒嗙被浠g爜"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+ string HHelpCode = item["鍔╄鐮�"].ToString();
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ int HEndFlag = 1;//鏈骇鏍囧織
+ int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //绛夌骇
+
+
+ if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HNumber='" + HNumber + "'", "Gy_EquipType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ oCN.RunProc("Insert into Gy_EquipFileType " +
+ " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HMakeEmp) " +
+ " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 +
+ "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "',getdate(),'" + user + "')");
+ }
+ else
+ {
+ oCN.RunProc("update Gy_EquipFileType set HHelpCode='" + HHelpCode + "',HRemark='" + HRemark + "' where HNumber='" + HNumber + "'");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
}
}
diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 63e201a..b6336fa 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -15,6 +15,10 @@
using WebAPI;
using WebAPI.Models;
using WebAPI.Service;
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers
{
@@ -3091,6 +3095,263 @@
return objJsonResult;
}
}
+ #endregion
+
+ #region 寮傚父绫诲瀷 鏂囦欢瀵煎叆淇濆瓨
+ #region 寮傚父绫诲瀷 鏂囦欢涓婁紶
+ [Route("Gy_ErrType/Gy_ErrType_Excel")]
+ [HttpPost]
+ public object Gy_ErrType_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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
+
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var error = "";
+
+ //鏌ヨ宸ヨ壓璺嚎娌℃湁鐨勫垪
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("寮傚父绫诲瀷"))
+ error += "娌℃湁鎵惧埌銆愬紓甯哥被鍨嬪悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("寮傚父绫诲瀷浠g爜"))
+ error += "娌℃湁鎵惧埌銆愬紓甯哥被鍨嬩唬鐮併�戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HProcessName = "";
+ string HProcessNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+
+
+ HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["寮傚父绫诲瀷"].ToString());
+ HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["寮傚父绫诲瀷浠g爜"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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();
+
+ //寮傚父绫诲瀷鍚嶇О
+ if (HProcessName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,寮傚父绫诲瀷鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //寮傚父绫诲瀷浠g爜
+ if (HProcessNum == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,寮傚父绫诲瀷浠g爜涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 寮傚父绫诲瀷椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_ErrType/Gy_ErrType_btnSave")]
+ [HttpPost]
+ public object Gy_ErrType_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("Gy_ErrType_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HProcessName = item["寮傚父绫诲瀷"].ToString();
+ string HProcessNum = item["寮傚父绫诲瀷浠g爜"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//鐭唬鐮�
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ int HEndFlag = 1;//鏈骇鏍囧織
+ int HLevel = DBUtility.ClsPub.GetLevel(HProcessNum); //绛夌骇
+
+
+ if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_ErrType where HNumber='" + HProcessNum + "'", "Gy_ErrType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+
+ oCN.RunProc("Insert into " + "Gy_ErrType" +
+ " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HBarCode,HUSEORGID,HCREATEORGID,HUseFlag) " +
+ " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 +
+ "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + "'," + HOrgID + "," + HOrgID + ",'" + "鏈娴�" + "')");
+ }
+ else
+ {
+ oCN.RunProc("update Gy_ErrType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "' where HNumber='" + HProcessNum + "'");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
#endregion
/// <summary>
@@ -8965,6 +9226,262 @@
}
#endregion
+ #region 寮傚父鍙嶉绫诲瀷 鏂囦欢瀵煎叆淇濆瓨
+ #region 寮傚父鍙嶉绫诲瀷 鏂囦欢涓婁紶
+ [Route("Gy_ErrMsgBackType/Gy_ErrMsgBackType_Excel")]
+ [HttpPost]
+ public object Gy_ErrMsgBackType_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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
+
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var error = "";
+
+ //鏌ヨ宸ヨ壓璺嚎娌℃湁鐨勫垪
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("寮傚父鍙嶉绫诲瀷"))
+ error += "娌℃湁鎵惧埌銆愬紓甯稿弽棣堢被鍨嬪悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("寮傚父鍙嶉绫诲瀷浠g爜"))
+ error += "娌℃湁鎵惧埌銆愬紓甯稿弽棣堢被鍨嬩唬鐮併�戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HProcessName = "";
+ string HProcessNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+
+
+ HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["寮傚父鍙嶉绫诲瀷"].ToString());
+ HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["寮傚父鍙嶉绫诲瀷浠g爜"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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();
+
+ //寮傚父绫诲瀷鍚嶇О
+ if (HProcessName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,寮傚父鍙嶉绫诲瀷鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //寮傚父绫诲瀷浠g爜
+ if (HProcessNum == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,寮傚父鍙嶉绫诲瀷浠g爜涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 寮傚父鍙嶉椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_ErrMsgBackType/Gy_ErrMsgBackType_btnSave")]
+ [HttpPost]
+ public object Gy_ErrMsgBackType_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("Gy_ErrType_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HProcessName = item["寮傚父鍙嶉绫诲瀷"].ToString();
+ string HProcessNum = item["寮傚父鍙嶉绫诲瀷浠g爜"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//鐭唬鐮�
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ int HEndFlag = 1;//鏈骇鏍囧織
+ int HLevel = DBUtility.ClsPub.GetLevel(HProcessNum); //绛夌骇
+
+
+ if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_ErrMsgBackType where HNumber='" + HProcessNum + "'", "Gy_ErrMsgBackType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ oCN.RunProc("Insert into " + "Gy_ErrMsgBackType " +
+ " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " +
+ " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 +
+ "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')");
+ }
+ else
+ {
+ oCN.RunProc("update Gy_ErrMsgBackType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "' where HNumber='" + HProcessNum + "'");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
#region 涓嶈壇鐜拌薄 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
/// <summary>
/// 涓嶈壇鐜拌薄 淇濆瓨
diff --git "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MaterTypeBillController.cs" "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MaterTypeBillController.cs"
index eedb205..5e40452 100644
--- "a/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MaterTypeBillController.cs"
+++ "b/WebAPI/Controllers/\345\237\272\347\241\200\350\265\204\346\226\231/\345\237\272\347\241\200\350\265\204\346\226\231/Gy_MaterTypeBillController.cs"
@@ -7,7 +7,10 @@
using System.Web;
using System.Web.Http;
using WebAPI.Models;
-
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using SyntacticSugar.constant;
namespace WebAPI.Controllers.鍩虹璧勬枡.鍩虹璧勬枡
{
public class Gy_MaterTypeBillController : ApiController
@@ -201,6 +204,327 @@
}
#endregion
+ #region 鐗╂枡鍒嗙被 鏂囦欢瀵煎叆淇濆瓨
+ #region 鐗╂枡鍒嗙被 鏂囦欢涓婁紶
+ [Route("Gy_MaterType/Gy_MaterType_Excel")]
+ [HttpPost]
+ public object Gy_MaterType_Excel()
+ {
+ try
+ {
+ //鑾峰彇鏂囦欢鍚嶇О
+ 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("HParentID", typeof(Int32));//鐖剁被ID
+
+ //娣诲姞鏁版嵁
+ 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.Rows.Add(row);
+ }
+
+
+ var error = "";
+
+ //鏌ヨ娌℃湁鐨勫垪
+ if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗╂枡鍒嗙被"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欏垎绫诲悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐗╂枡鍒嗙被浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮墿鏂欏垎绫讳唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐖剁被鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愮埗绫诲悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鐖剁被浠g爜"))
+ error += "娌℃湁鎵惧埌銆愮埗绫讳唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("澶囨敞"))
+ error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍔╄鐮�"))
+ error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,";
+
+ if (error.Length > 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+ {
+ string HMaterTypeName = "";
+ string HMaterTypeNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+ string HParentNumber = "";
+ string HParentName = "";
+
+ HMaterTypeName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍒嗙被"].ToString());
+ HMaterTypeNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍒嗙被浠g爜"].ToString());
+ HParentName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐖剁被鍚嶇О"].ToString());
+ HParentNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐖剁被浠g爜"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].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 = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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();
+
+ if(HParentNumber!="" && HParentName != "")
+ {
+ //鏌ヨ鐖剁被id
+ ds = oCN.RunProcReturn("select * from Gy_MaterType where HNumber='" + HParentNumber + "' and Hname='" + HParentName + "'", "Gy_MaterType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐖剁被涓嶅瓨鍦紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ tb2.Rows[i]["HParentID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ string HParentID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ else {
+ tb2.Rows[i]["HParentID"] = "0";
+ }
+
+
+ //鐗╂枡鍒嗙被鍚嶇О
+ if (HMaterTypeName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //鐗╂枡鍒嗙被鍚嶇О
+ if (HMaterTypeNum == HParentNumber)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡绫诲瀷鐖剁被涓嶈兘鏄嚜宸憋紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //鐗╂枡鍒嗙被浠g爜
+ if (HMaterTypeNum == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡鍒嗙被浠g爜涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = error;
+ objJsonResult.data = tb2;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 鐗╂枡鍒嗙被椤圭洰 瀵煎叆(淇濆瓨)
+ [Route("Gy_MaterType/Gy_MaterType_btnSave")]
+ [HttpPost]
+ public object Gy_MaterType_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("Gy_ErrType_Edit", 1, false, user))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HName = item["鐗╂枡鍒嗙被"].ToString();
+ string HNumber = item["鐗╂枡鍒嗙被浠g爜"].ToString();
+ string HRemark = item["澶囨敞"].ToString();
+ string HHelpCode = item["鍔╄鐮�"].ToString();
+ string HParentID = item["HParentID"].ToString();
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ int HEndFlag = 1;//鏈骇鏍囧織
+ int HLevel = 1; //绛夌骇
+ DataSet ds2 = oCN.RunProcReturn("select HLevel from Gy_MaterType where HItemID =" + HParentID, "Gy_MaterType");//鎼滅储鐖剁被绛夌骇
+ //oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber); //绛夌骇
+ if (ds2.Tables[0].Rows.Count > 0)
+ {
+ HLevel = (int)ds2.Tables[0].Rows[0]["HLevel"] + 1;
+ }
+ else
+ {
+ HLevel = 1;
+ }
+
+ if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+
+ ds = oCN.RunProcReturn("select * from Gy_MaterType where HNumber='" + HNumber + "'", "Gy_MaterType");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ oCN.RunProc("Insert into " + "Gy_MaterType" +
+ " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HMakeEmp,HMakeTime,HStopEmp,HStopTime,HUSEORGID,HCREATEORGID,HUseFlag) " +
+ " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + HParentID.ToString() +
+ "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + user + "',getdate(),'" + "" + "','" + "" + "'," + HOrgID + "," + HOrgID + ",'" + "鏈娴�" + "')");
+ //淇敼涓婄骇涓洪潪鏈骇浠g爜
+ oCN.RunProc("Update Gy_MaterType" + " set HEndflag=0 where HItemID=" + HParentID);
+ }
+ else
+ {
+ oCN.RunProc("update Gy_MaterType set HUSEORGID=" + HOrgID + ",HParentID = " + HParentID + ",HHelpCode = '" + HHelpCode + "',HRemark='" + HRemark + "' where HNumber='" + HNumber + "'");
+ //淇敼涓婄骇涓洪潪鏈骇浠g爜
+ oCN.RunProc("Update Gy_MaterType" + " set HEndflag=0 where HItemID=" + HParentID);
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
#region 鐗╂枡鍒嗙被 鍒犻櫎
[Route("Gy_MaterType/DeleteMaterType")]
diff --git a/WebAPI/Properties/PublishProfiles/FolderProfilewtt.pubxml.user b/WebAPI/Properties/PublishProfiles/FolderProfilewtt.pubxml.user
index af6ed9a..9c96e89 100644
--- a/WebAPI/Properties/PublishProfiles/FolderProfilewtt.pubxml.user
+++ b/WebAPI/Properties/PublishProfiles/FolderProfilewtt.pubxml.user
@@ -45,28 +45,28 @@
<publishTime>02/22/2013 16:43:40</publishTime>
</File>
<File Include="bin/BLL.dll">
- <publishTime>09/13/2024 15:10:57</publishTime>
+ <publishTime>09/20/2024 08:59:29</publishTime>
</File>
<File Include="bin/BLL.pdb">
- <publishTime>09/13/2024 15:10:57</publishTime>
+ <publishTime>09/20/2024 08:59:29</publishTime>
</File>
<File Include="bin/BouncyCastle.Crypto.dll">
<publishTime>12/18/2020 05:32:28</publishTime>
</File>
<File Include="bin/DAL.dll">
- <publishTime>09/13/2024 15:10:55</publishTime>
+ <publishTime>09/20/2024 08:59:27</publishTime>
</File>
<File Include="bin/DAL.pdb">
- <publishTime>09/13/2024 15:10:55</publishTime>
+ <publishTime>09/20/2024 08:59:27</publishTime>
</File>
<File Include="bin/Dapper.dll">
<publishTime>07/22/2016 22:52:40</publishTime>
</File>
<File Include="bin/DBUtility.dll">
- <publishTime>09/13/2024 15:10:49</publishTime>
+ <publishTime>09/20/2024 08:59:19</publishTime>
</File>
<File Include="bin/DBUtility.pdb">
- <publishTime>09/13/2024 15:10:49</publishTime>
+ <publishTime>09/20/2024 08:59:19</publishTime>
</File>
<File Include="bin/Grpc.Core.Api.dll">
<publishTime>03/22/2022 13:17:26</publishTime>
@@ -111,10 +111,10 @@
<publishTime>07/25/2012 19:48:56</publishTime>
</File>
<File Include="bin/Model.dll">
- <publishTime>09/13/2024 15:10:50</publishTime>
+ <publishTime>09/20/2024 08:59:20</publishTime>
</File>
<File Include="bin/Model.pdb">
- <publishTime>09/13/2024 15:10:50</publishTime>
+ <publishTime>09/20/2024 08:59:20</publishTime>
</File>
<File Include="bin/Models/ClsSc_MouldScrapOutBillMain.cs">
<publishTime>04/15/2024 12:55:45</publishTime>
@@ -147,34 +147,34 @@
<publishTime>10/23/2021 17:07:54</publishTime>
</File>
<File Include="bin/Pub_Class.dll">
- <publishTime>09/13/2024 15:10:47</publishTime>
+ <publishTime>09/20/2024 08:59:17</publishTime>
</File>
<File Include="bin/Pub_Class.pdb">
- <publishTime>09/13/2024 15:10:47</publishTime>
+ <publishTime>09/20/2024 08:59:17</publishTime>
</File>
<File Include="bin/Pub_Control.dll">
- <publishTime>09/13/2024 15:10:48</publishTime>
+ <publishTime>09/20/2024 08:59:18</publishTime>
</File>
<File Include="bin/Pub_Control.pdb">
- <publishTime>09/13/2024 15:10:48</publishTime>
+ <publishTime>09/20/2024 08:59:18</publishTime>
</File>
<File Include="bin/RestSharp.dll">
<publishTime>08/31/2012 06:22:50</publishTime>
</File>
<File Include="bin/SQLHelper.dll">
- <publishTime>09/13/2024 15:10:48</publishTime>
+ <publishTime>09/20/2024 08:59:18</publishTime>
</File>
<File Include="bin/SQLHelper.pdb">
- <publishTime>09/13/2024 15:10:48</publishTime>
+ <publishTime>09/20/2024 08:59:18</publishTime>
</File>
<File Include="bin/Swashbuckle.Core.dll">
<publishTime>02/16/2015 01:57:08</publishTime>
</File>
<File Include="bin/SyntacticSugar.dll">
- <publishTime>09/13/2024 15:08:19</publishTime>
+ <publishTime>09/20/2024 08:56:16</publishTime>
</File>
<File Include="bin/SyntacticSugar.pdb">
- <publishTime>09/13/2024 15:08:19</publishTime>
+ <publishTime>09/20/2024 08:56:16</publishTime>
</File>
<File Include="bin/System.Buffers.dll">
<publishTime>07/19/2017 18:01:28</publishTime>
@@ -285,19 +285,19 @@
<publishTime>05/09/2023 10:43:40</publishTime>
</File>
<File Include="bin/TopSdk.dll">
- <publishTime>09/11/2024 21:15:43</publishTime>
+ <publishTime>09/20/2024 08:56:23</publishTime>
</File>
<File Include="bin/TopSdk.pdb">
- <publishTime>09/11/2024 21:15:51</publishTime>
+ <publishTime>09/20/2024 08:56:23</publishTime>
</File>
<File Include="bin/WebActivatorEx.dll">
<publishTime>11/24/2014 19:18:48</publishTime>
</File>
<File Include="bin/WebAPI.dll">
- <publishTime>09/13/2024 15:11:26</publishTime>
+ <publishTime>09/20/2024 08:59:57</publishTime>
</File>
<File Include="bin/WebAPI.pdb">
- <publishTime>09/13/2024 15:11:26</publishTime>
+ <publishTime>09/20/2024 08:59:57</publishTime>
</File>
<File Include="bin/WebAPI.XmlSerializers.dll">
<publishTime>08/16/2024 16:55:28</publishTime>
diff --git a/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll b/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll
index 98d4a8d..d9fdf9c 100644
--- a/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll
+++ b/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll
Binary files differ
diff --git a/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb b/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb
index b23d27f..ac7cc39 100644
--- a/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb
+++ b/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb
Binary files differ
diff --git a/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.AssemblyReference.cache b/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.AssemblyReference.cache
index b3a6f35..d6e21aa 100644
--- a/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.AssemblyReference.cache
+++ b/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.AssemblyReference.cache
Binary files differ
diff --git a/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.FileListAbsolute.txt b/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.FileListAbsolute.txt
index cc295df..0b82a49 100644
--- a/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.FileListAbsolute.txt
+++ b/sdk_dingding/TopSdk/obj/Debug/TopSdk.csproj.FileListAbsolute.txt
@@ -4,3 +4,9 @@
D:\缃戠珯鍙戝竷\鍚庣浠g爜\MES-WEB-API\MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.dll
D:\缃戠珯鍙戝竷\鍚庣浠g爜\MES-WEB-API\MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.pdb
D:\缃戠珯鍙戝竷\鍚庣浠g爜\MES-WEB-API\MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.csproj.AssemblyReference.cache
+C:\Users\86130\Desktop\鏅轰簯杩堟�漒MES-WEB-API\sdk_dingding\TopSdk\bin\Debug\TopSdk.dll
+C:\Users\86130\Desktop\鏅轰簯杩堟�漒MES-WEB-API\sdk_dingding\TopSdk\bin\Debug\TopSdk.pdb
+C:\Users\86130\Desktop\鏅轰簯杩堟�漒MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.csproj.CoreCompileInputs.cache
+C:\Users\86130\Desktop\鏅轰簯杩堟�漒MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.dll
+C:\Users\86130\Desktop\鏅轰簯杩堟�漒MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.pdb
+C:\Users\86130\Desktop\鏅轰簯杩堟�漒MES-WEB-API\sdk_dingding\TopSdk\obj\Debug\TopSdk.csproj.AssemblyReference.cache
diff --git a/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll b/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll
index 98d4a8d..d9fdf9c 100644
--- a/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll
+++ b/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll
Binary files differ
diff --git a/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb b/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb
index b23d27f..ac7cc39 100644
--- a/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb
+++ b/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb
Binary files differ
--
Gitblit v1.9.1