From cee055eb7cdecf5d995cc65d379494e471bde9c8 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期三, 02 四月 2025 10:06:03 +0800
Subject: [PATCH] 合并
---
WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs | 846 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 838 insertions(+), 8 deletions(-)
diff --git a/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs b/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs
index 5494a1d..9ec2784 100644
--- a/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs
+++ b/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing DBUtility;
+using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
@@ -8,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 Sb_EquipMaintainRuleBillController : ApiController
@@ -74,6 +78,70 @@
}
#endregion
+ #region 璁惧淇濆吇瑙勭▼鍗曞垪琛≒DA
+ [Route("Sb_EquipMaintainRuleBill/GetEquipMaintainRuleListPDA")]
+ [HttpGet]
+ public object GetEquipMaintainRuleListPDA(string sWhere, string user)
+ {
+ try
+ {
+ List<object> columnNameList = new List<object>();
+ if (!DBUtility.ClsPub.Security_Log("Sb_EquipMaintainRuleBillList", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ ds = oCN.RunProcReturn("select * from h_v_Sb_GetMaintainRuleListByEquip " + sWhere, "h_v_Sb_GetMaintainRuleListByEquip");
+ }
+ else
+ {
+ string sql1 = "select * from h_v_Sb_GetMaintainRuleListByEquip where 1 = 1";
+ string sql = sql1 + sWhere;
+ ds = oCN.RunProcReturn(sql, "h_v_Sb_GetMaintainRuleListByEquip");
+ }
+
+ //娣诲姞鍒楀悕
+ foreach (DataColumn col in ds.Tables[0].Columns)
+ {
+ Type dataType = col.DataType;
+ string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+ columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+ }
+ //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+ //{
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ objJsonResult.list = columnNameList;
+ return objJsonResult;
+ //}
+ //else
+ //{
+ //objJsonResult.code = "0";
+ //objJsonResult.count = 0;
+ //objJsonResult.Message = "鏃犳暟鎹�";
+ //objJsonResult.data = null;
+ //return objJsonResult;
+ //}
+ }
+ catch (Exception ex)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
#region 璁惧淇濆吇瑙勭▼璁板綍鍒犻櫎鍔熻兘
[Route("Sb_EquipMaintainRuleBill/DeleteEquipMaintainRuleBillList")]
[HttpGet]
@@ -98,9 +166,10 @@
return objJsonResult;
}
DLL.ClsSb_EquipMaintainRuleBill oBill = new DLL.ClsSb_EquipMaintainRuleBill();
- if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
+ ds = oCN.RunProcReturn("select * from Sb_EquipMaintainRuleBillMain where HInterID=" + HInterID, "Sb_EquipMaintainRuleBillMain");
+ if (ds.Tables[0].Rows.Count > 0)
{
- if (oBill.omodel.HBillStatus > 1)
+ if (DBUtility.ClsPub.isInt(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1)
{
objJsonResult.code = "0";
objJsonResult.count = 0;
@@ -108,7 +177,7 @@
objJsonResult.data = null;
return objJsonResult;
}
- if (oBill.omodel.HChecker != ""&& oBill.omodel.HChecker != null)
+ if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
{
objJsonResult.code = "0";
objJsonResult.count = 0;
@@ -117,7 +186,29 @@
return objJsonResult;
}
- bool IsDete = oBill.DeleteBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo);
+ //鍒犻櫎鍓嶆帶鍒�=========================================
+ string sql1 = "exec h_p_Sb_EquipMaintainRuleBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipMaintainRuleBill_BeforeDelCtrl");
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //==================================================================================
+
+ bool IsDete = oBill.DeleteBill(lngBillKey, BillOld.omodel.HBillNo, "h_p_Sb_EquipMaintainRuleBill_AfterDelCtrl",user, ref DBUtility.ClsPub.sExeReturnInfo);
if (IsDete)
{
objJsonResult.code = "0";
@@ -199,9 +290,9 @@
if (string.IsNullOrEmpty(HID))
return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" };
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
- var dataSet = oCN.RunProcReturn("select top 1 * from Sb_EquipMaintainRuleBillMain where HInterID= " + HID + " ", "Sb_EquipMaintainRuleBillMain");
+ var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sb_EquipMaintainRuleBillList where HInterID= " + HID + " ", "h_v_Sb_EquipMaintainRuleBillList");
if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
- return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄧ偣妫�璁″垝琛�" };
+ return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄤ繚鍏昏绋嬭〃" };
return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
}
#endregion
@@ -399,5 +490,744 @@
}
}
#endregion
+
+ #region 璁惧淇濆吇瑙勭▼鍗曞鏍�/鍙嶅鏍稿姛鑳�
+ [Route("Sb_EquipMaintainRuleBill/CheckSb_EquipMaintainRuleBill")]
+ [HttpGet]
+ public object CheckSb_EquipMaintainRuleBill(string HInterID, int Type, string user)
+ {
+ try
+ {
+ //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+ if (!DBUtility.ClsPub.Security_Log("Sb_EquipMaintainRuleBill_Check", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犳潈闄愬鏍�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ if (string.IsNullOrWhiteSpace(HInterID))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "HInterID涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ ClsPub.CurUserName = user;
+ oCN.BeginTran();//寮�濮嬩簨鍔�
+
+ //Type 1 瀹℃牳 2 鍙嶅鏍�
+ if (Type == 1)
+ {
+ //瀹℃牳鍓嶆帶鍒�=========================================
+ string sql1 = "exec h_p_Sb_EquipMaintainRuleBill_BeforeCheckCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipMaintainRuleBill_BeforeCheckCtrl");
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+ objJsonResult.data = null;
+ oCN.RollBack();
+ return objJsonResult;
+ }
+
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+ objJsonResult.data = null;
+ oCN.RollBack();
+ return objJsonResult;
+ }
+ //==================================================================================
+
+ if (!BillOld.CheckBill(int.Parse(HInterID), BillOld.omodel.HBillNo, "h_p_Sb_EquipMaintainRuleBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ //鍙嶅鏍稿墠鎺у埗=========================================
+ string sql1 = "exec h_p_Sb_EquipMaintainRuleBill_BeforeUnCheckCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipMaintainRuleBill_BeforeUnCheckCtrl");
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+ objJsonResult.data = null;
+ return objJsonResult;
+
+ }
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //===========================================================
+
+ if (BillOld.AbandonCheck(int.Parse(HInterID),BillOld.omodel.HBillNo, "h_p_Sb_EquipMaintainRuleBill_AfterUnCheckCtrl",user, ref ClsPub.sExeReturnInfo))
+ {
+ SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ oCN.Commit();//鎻愪氦浜嬪姟
+
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎵ц鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult; ;
+
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 璁惧淇濆吇瑙勭▼鍗曞叧闂�/鍙嶅叧闂姛鑳�
+ [Route("Sb_EquipMaintainRuleBill/CloseSb_EquipMaintainRuleBill")]
+ [HttpGet]
+ public object CloseSb_EquipMaintainRuleBill(string HInterID, int Type, string user)
+ {
+ try
+ {
+ //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+ if (!DBUtility.ClsPub.Security_Log("Sb_EquipMaintainRuleBill_Close", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犳潈闄愬叧闂�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ if (string.IsNullOrWhiteSpace(HInterID))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "HInterID涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ ClsPub.CurUserName = user;
+
+ oCN.BeginTran();//寮�濮嬩簨鍔�
+
+ //Type 1 鍏抽棴 2 鍙嶅叧闂�
+ if (Type == 1)
+ {
+ if (!BillOld.CloseBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ if (!BillOld.CancelClose(int.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ oCN.Commit();//鎻愪氦浜嬪姟
+
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎵ц鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult; ;
+
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 璁惧淇濆吇瑙勭▼浣滃簾/鍙嶄綔搴熷姛鑳�
+ [Route("Sb_EquipMaintainRuleBill/DeleteSb_EquipMaintainRuleBill")]
+ [HttpGet]
+ public object DeleteSb_EquipMaintainRuleBill(string HInterID, int Type, string user)
+ {
+ try
+ {
+ //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄�
+ if (!DBUtility.ClsPub.Security_Log("Sb_EquipMaintainRuleBill_Drop", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犳潈闄愪綔搴�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ if (string.IsNullOrWhiteSpace(HInterID))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "HInterID涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ DLL.ClsSb_EquipMaintainRuleBill oBill = new DLL.ClsSb_EquipMaintainRuleBill();
+ ClsPub.CurUserName = user;
+ Int64 lngBillKey = 0;
+ lngBillKey = DBUtility.ClsPub.isLong(HInterID);
+ //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+ if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇璇ュ崟鎹殑鏁版嵁
+ {
+ if (oBill.omodel.HChecker.Trim() != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ if (Type == 1) //浣滃簾鍒ゆ柇
+ {
+ if (oBill.omodel.HDeleteMan.Trim() != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘鍐嶄綔搴燂紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ if (Type == 2) //鍙嶄綔搴熷垽鏂�
+ {
+ if (oBill.omodel.HDeleteMan.Trim() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸弽浣滃簾锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ oCN.BeginTran();//寮�濮嬩簨鍔�
+
+ //Type 1 浣滃簾 2 鍙嶄綔搴�
+ if (Type == 1)
+ {
+ //浣滃簾鍓嶆帶鍒�=========================================
+ string sql1 = "exec h_p_Sb_EquipMaintainRuleBill_BeforeDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipMaintainRuleBill_BeforeDropCtrl");
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:浣滃簾鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+ objJsonResult.data = null;
+ oCN.RollBack();
+ return objJsonResult;
+ }
+
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+ objJsonResult.data = null;
+ oCN.RollBack();
+ return objJsonResult;
+ }
+ //==================================================================================
+
+ if (!oBill.Cancelltion(int.Parse(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipMaintainRuleBill_AfterDropCtrl", user, ref ClsPub.sExeReturnInfo))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ else
+ {
+ //鍙嶄綔搴熷墠鎺у埗=========================================
+ string sql1 = "exec h_p_Sb_EquipMaintainRuleBill_BeforeUnDropCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+ ds = oCN.RunProcReturn(sql1, "h_p_Sb_EquipMaintainRuleBill_BeforeUnDropCtrl");
+ if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:鍙嶄綔搴熷墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+ objJsonResult.data = null;
+ return objJsonResult;
+
+ }
+ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //===========================================================
+
+ if (!oBill.AbandonCancelltion(int.Parse(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipMaintainRuleBill_AfterUnDropCtrl", user, ref ClsPub.sExeReturnInfo))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ oCN.Commit();//鎻愪氦浜嬪姟
+
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鎵ц鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult; ;
+
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鎵ц澶辫触锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
+ #region 璁惧淇濆吇瑙勭▼ 鏂囦欢瀵煎叆淇濆瓨
+ #region 璁惧淇濆吇瑙勭▼ 鏂囦欢涓婁紶
+ [Route("Sb_EquipMaintainRuleBill/Sb_EquipMaintainRuleBill_Excel")]
+ [HttpPost]
+ public object Sb_EquipMaintainRuleBill_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("HMaintainItemID", typeof(Int32));//淇濆吇椤圭洰ID
+ tb2.Columns.Add("HManagerID", typeof(Int32));//璐熻矗浜篒D
+ //娣诲姞鏁版嵁
+ 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("淇濆吇椤圭洰浠g爜"))
+ error += "娌℃湁鎵惧埌銆愪繚鍏婚」鐩唬鐮併�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("淇濆吇椤圭洰鍚嶇О"))
+ error += "娌℃湁鎵惧埌銆愪繚鍏婚」鐩悕绉般�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("淇濆吇閮ㄤ綅"))
+ error += "娌℃湁鎵惧埌銆愪繚鍏婚儴浣嶃�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("鍏蜂綋瑕佹眰"))
+ error += "娌℃湁鎵惧埌銆愬叿浣撹姹傘�戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璐熻矗浜轰唬鐮�"))
+ error += "娌℃湁鎵惧埌銆愯礋璐d汉浠g爜銆戠殑鏍囬,";
+
+ if (!tb2.Columns.Contains("璐熻矗浜�"))
+ error += "娌℃湁鎵惧埌銆愯礋璐d汉銆戠殑鏍囬,";
+
+ 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 HName = "";
+ string HNum = "";
+ string HORGNumber = "";
+ string HORGName = "";
+ string HManagerName = "";
+ string HManagerNumber = "";
+ string HMaintainItemNumber = "";
+ string HMaintainItemName = "";
+
+ HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勭▼缂栧彿"].ToString());
+ HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勭▼鍚嶇О"].ToString());
+ HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+ HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+ HManagerNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璐熻矗浜轰唬鐮�"].ToString());
+ HManagerName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璐熻矗浜�"].ToString());
+ HMaintainItemNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["淇濆吇椤圭洰浠g爜"].ToString());
+ HMaintainItemName = 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();
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //淇濆吇椤圭洰浠g爜
+ if (HMaintainItemNumber != "")
+ {
+ //鏌ヨ缁勭粐
+ ds = oCN.RunProcReturn("select * from Gy_Maintain where HNumber='" + HMaintainItemNumber + "' and Hname='" + HMaintainItemName + "'", "Gy_Maintain");
+
+ 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]["HMaintainItemID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ string HMaintainItemID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ else
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,淇濆吇椤圭洰浠g爜涓虹┖";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //璐熻矗浜轰唬鐮�
+ if (HManagerNumber != "")
+ {
+ //鏌ヨ缁勭粐
+ ds = oCN.RunProcReturn("select * from Gy_Employee where HNumber='" + HManagerNumber + "' and Hname='" + HManagerName + "'", "Gy_Employee");
+
+ 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]["HManagerID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ }
+ //璁惧淇濆吇瑙勭▼鍚嶇О
+ if (HName == "")
+ {
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "绗�" + index + "琛�,璁惧淇濆吇瑙勭▼鍚嶇О涓嶈兘涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ //璁惧淇濆吇瑙勭▼浠g爜
+ if (HNum == "")
+ {
+ 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("Sb_EquipMaintainRuleBill/Sb_EquipMaintainRuleBill_btnSave")]
+ [HttpPost]
+ public object Sb_EquipMaintainRuleBill_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("Sb_EquipMaintainRuleBill_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 HBillType = "3912";
+ string HMaker = user;//鍒跺崟浜�
+ DateTime HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --鏃ユ湡
+ long HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+ long HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
+ string HOrgID = item["HOrgID"].ToString();//缁勭粐ID
+ string HName = item["瑙勭▼鍚嶇О"].ToString();
+ string HBillNo = item["瑙勭▼缂栧彿"].ToString();
+ string HCycleUnit = item["鍛ㄦ湡鍗曚綅"].ToString();
+ string HCheckCycle = item["淇濆吇鍛ㄦ湡"].ToString();
+ string HExplanation = item["鎽樿"].ToString();
+ string HRemark = item["琛ㄥご澶囨敞"].ToString();
+ //瀛愯〃
+ string HMaintainItemID = item["HMaintainItemID"].ToString();//淇濆吇椤圭洰
+ string HManagerID = item["HManagerID"].ToString() == "" ? "0" : item["HManagerID"].ToString();//璐熻矗浜�
+ string HMaintainPart = item["淇濆吇閮ㄤ綅"].ToString();
+ string HClaim = item["鍏蜂綋瑕佹眰"].ToString();
+ string HSubRemark = item["琛ㄤ綋澶囨敞"].ToString();
+ string HMaintainItem = item["淇濆吇椤圭洰鍚嶇О"].ToString();
+ ds = oCN.RunProcReturn("select * from Sb_EquipMaintainRuleBillMain where HBillNo='" + HBillNo + "'", "Sb_EquipMaintainRuleBillMain");
+
+ if (ds.Tables[0].Rows.Count == 0)
+ {
+ long HInterID = DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ //鎻掑叆涓昏〃
+ oCN.RunProc("Insert Into Sb_EquipMaintainRuleBillMain " +
+ "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" +
+ ",HYear,HPeriod,HRemark" +
+ ",HCheckCycle,HCycleUnit,HExplanation,HInnerBillNo,HMaintainLevID,HSafeDays,HErrWarDays" +
+ ") " +
+ " values('" + HBillType + "','" + HBillType + "'," + HInterID.ToString() + ",'" + HBillNo + "','" + HDate + "','" + HMaker + "',getdate()" +
+ "," + HYear.ToString() + "," + HPeriod.ToString() + ",'" + HRemark +
+ "'," + HCheckCycle.ToString() + ",'" + HCycleUnit + "','" + HExplanation + "','" + "" + "'," + 0 + "," + 0 + ", " + 0 +
+ ") ");
+ //鎻掑叆瀛愯〃
+ oCN.RunProc("Insert into Sb_EquipMaintainRuleBillSub_Item" +
+ " (HInterID,HEntryID,HMaintainItemID,HMaintainItem" +
+ ",HMaintainPart,HClaim" +
+ ",HManagerID" +
+ ",HCloseMan,HCloseType,HRemark" +
+ ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+ ") values("
+ + HInterID.ToString() + "," + 1 + "," + HMaintainItemID.ToString() + ",'" + HMaintainItem.ToString() + "'" +
+ ",'" + HMaintainPart.ToString() + "','" + HClaim.ToString() + "'" +
+ "," + HManagerID.ToString() +
+ ",'" + "" + "'," + Convert.ToString(false ? 1 : 0) + ",'" + HSubRemark + "'" +
+ "," + 0 + "," + 0 + ",'" + "" + "','" + "" + "'," + 0 + "," + 0 +
+ ") ");
+ }
+ else
+ {
+ long HInterID = long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString());
+ //鑾峰彇鏈�澶у瓙id
+ DataSet ds2 = oCN.RunProcReturn("select max(HEntryID) HEntryID from Sb_EquipMaintainRuleBillSub_Item where HInterID='" + HInterID + "'", "Sb_EquipMaintainRuleBillSub_Item");
+ long HEntryID = 1;
+ if (ds2.Tables[0].Rows.Count > 0)
+ {
+ HEntryID = long.Parse(ds2.Tables[0].Rows[0]["HEntryID"].ToString()) + 1;
+ }
+ //鎻掑叆瀛愯〃
+ //鎻掑叆瀛愯〃
+ oCN.RunProc("Insert into Sb_EquipMaintainRuleBillSub_Item" +
+ " (HInterID,HEntryID,HMaintainItemID,HMaintainItem" +
+ ",HMaintainPart,HClaim" +
+ ",HManagerID" +
+ ",HCloseMan,HCloseType,HRemark" +
+ ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+ ") values("
+ + HInterID.ToString() + "," + HEntryID + "," + HMaintainItemID.ToString() + ",'" + HMaintainItem.ToString() + "'" +
+ ",'" + HMaintainPart.ToString() + "','" + HClaim.ToString() + "'" +
+ "," + HManagerID.ToString() +
+ ",'" + "" + "'," + Convert.ToString(false ? 1 : 0) + ",'" + HSubRemark + "'" +
+ "," + 0 + "," + 0 + ",'" + "" + "','" + "" + "'," + 0 + "," + 0 +
+ ") ");
+ }
+
+ i++;
+ }
+
+ oCN.Commit();
+
+ objJsonResult.code = CodeConstant.SUCCEED;
+ objJsonResult.count = CountConstant.SUCCEED;
+ objJsonResult.Message = "瀵煎叆鎴愬姛!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e);
+ oCN.RollBack();
+ objJsonResult.code = CodeConstant.FAIL;
+ objJsonResult.count = CountConstant.FAIL;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+ #endregion
+
}
}
--
Gitblit v1.9.1