From 2609bffee3a8de0d1e08b1b2c3fa3cfe13064f4e Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 24 三月 2025 11:40:14 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/BaseSet/Gy_UnitController.cs | 814 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 792 insertions(+), 22 deletions(-)
diff --git a/WebAPI/Controllers/BaseSet/Gy_UnitController.cs b/WebAPI/Controllers/BaseSet/Gy_UnitController.cs
index 5bf2cfd..bfffd0d 100644
--- a/WebAPI/Controllers/BaseSet/Gy_UnitController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_UnitController.cs
@@ -1,4 +1,7 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰sing Model;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using NPOI.SS.Formula.Functions;
using Pub_Class;
using System;
using System.Collections;
@@ -6,13 +9,18 @@
using System.Data;
using System.Data.SqlClient;
using System.Web.Http;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
using WebAPI.Models;
+using WebAPI.Service;
+
namespace WebAPI.Controllers
{
public class Gy_UnitController : ApiController
{
+ //鑾峰彇绯荤粺鍙傛暟
+ Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
public DBUtility.ClsPub.Enum_BillStatus BillStatus;
-
+ public DAL.ClsGy_Unit_Ctl BillOld = new DAL.ClsGy_Unit_Ctl();
private json objJsonResult = new json();
SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
DataSet ds;
@@ -25,36 +33,46 @@
/// </summary>
[Route("Gy_Unit/list1")]
[HttpGet]
- public object list(string sWhere)
+ public object list(string sWhere, string user, string Organization)
{
try
{
- if (sWhere == null || sWhere.Equals(""))
- {
- ds = oCN.RunProcReturn("select * from h_v_Gy_UnitList " + sWhere, "h_v_Gy_UnitList");
- }
- else
- {
- string sql1 = "select * from h_v_Gy_UnitList where 1 = 1 ";
- string sql = sql1 + sWhere;
- ds = oCN.RunProcReturn(sql, "h_v_Gy_UnitList");
- }
- if (ds == null || ds.Tables[0].Rows.Count == 0)
+ List<object> columnNameList = new List<object>();
+ //缂栬緫鏉冮檺
+ if (!DBUtility.ClsPub.Security_Log_second("Gy_UnitGroup", 1, false, user))
{
objJsonResult.code = "0";
objJsonResult.count = 0;
- objJsonResult.Message = "false锛�";
+ objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
objJsonResult.data = null;
return objJsonResult;
}
+
+ string sql1 = string.Format(@"select * from h_v_Gy_UnitList where 缁勭粐鍚嶇О='" + Organization + "'");
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ ds = oCN.RunProcReturn(sql1 + sWhere + "order by 璁¢噺鍗曚綅浠g爜 ", "h_v_Gy_UnitList");
+ }
else
{
- objJsonResult.code = "1";
- objJsonResult.count = 1;
- objJsonResult.Message = "Sucess锛�";
- objJsonResult.data = ds.Tables[0];
- return objJsonResult;
+ string sql = sql1 + sWhere + "order by 璁¢噺鍗曚綅浠g爜 ";
+ ds = oCN.RunProcReturn(sql, "h_v_Gy_UnitList");
}
+
+ //娣诲姞鍒楀悕
+ 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鍒楀璞$殑鍒楀悕
+ }
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ objJsonResult.list = columnNameList;
+ return objJsonResult;
}
catch (Exception e)
{
@@ -66,6 +84,159 @@
}
}
+ [Route("Gy_Unit/AuditGy_Unit")]
+ [HttpGet]
+ public object AuditGy_Unit(string HInterID, int Type, string user)
+ {
+ try
+ {
+ //鍒ゆ柇鏄惁鏈夊鏍告潈闄�
+ if (!DBUtility.ClsPub.Security_Log("Gy_Unit_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)
+ {
+ //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳
+ DataSet ds;
+ string sql = "select * from Gy_Unit where HItemID = " + HInterID;
+ ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+ if (ds.Tables[0].Rows[0]["HCheckEmp"] != null && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //瀹℃牳鍗曟嵁
+ if (!BillOld.AuditByID(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ else
+ {
+ //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍�
+ DataSet ds;
+ string sql = "select * from Gy_Unit where HItemID = " + HInterID;
+ ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
+ if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
+ {
+ if (ds.Tables[0].Rows[0]["HCheckEmp"] == null || ds.Tables[0].Rows[0]["HCheckEmp"].ToString() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //鍙嶅鏍稿崟鎹�
+ if (!BillOld.DeAuditByID(Int64.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;
+ }
+ }
+
+ [Route("Gy_Unit/JY_Json")]
+ [HttpGet]
+ public object JY_Json(long HItemID)
+ {
+ try
+ {
+ ds = oCN.RunProcReturn("update Gy_Unit set HStopFlag = 1 where HItemID = " + HItemID, "Gy_Unit");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "绂佺敤鎴愬姛";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 閮ㄩ棬鍒楄〃鍙嶇鐢ㄦ寜閽�
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Gy_Unit/FJY_Json")]
+ [HttpGet]
+ public object FJY_Json(long HItemID)
+ {
+ try
+ {
+ ds = oCN.RunProcReturn("update Gy_Unit set HStopFlag = 0 where HItemID = " + HItemID, "Gy_Unit");
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
[Route("Gy_Unit/LoadTree")]
[HttpGet]
@@ -73,7 +244,7 @@
{
SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN();
//ds = oCN.RunProcReturn("select * from h_v_IF_GroupList " + sWhere, "h_v_IF_GroupList");
- ds = oCN.RunProcReturn("select * from h_v_UnitLoadTree", "h_v_UnitLoadTree");
+ ds = oCN.RunProcReturn("select * from h_v_Gy_UnitList", "h_v_Gy_UnitList");
if (ds == null || ds.Tables[0].Rows.Count == 0)
{
objJsonResult.code = "0";
@@ -93,8 +264,607 @@
}
+ /// <summary>
+ /// 淇濆瓨璁¢噺鍗曚綅
+ /// </summary>
+ /// <param name="msg"></param>
+ /// <returns></returns>
+ [Route("SaveGy_UnitList")]
+ [HttpPost]
+ public object SaveGy_UnitList([FromBody] JObject msg)
+ {
+ DataSet ds;
+ var _value = msg["msg"].ToString();
+ string msg4 = _value.ToString();
+ string[] sArray = msg4.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg1 = sArray[0].ToString();
+ string msg3 = sArray[1].ToString();
+ string msg_HUSEORGID = sArray[2].ToString();
+ Single msg_HRate = float.Parse(sArray[3]);
+ Int64 HItemID = 0;
+ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+
+ //鑾峰彇鏈�澶D鍊艰祴鍊�
+ DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_Unit ", "Gy_Unit");
+ if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
+ {
+ //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
+ var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]);
+ maxid += 1;
+ HItemID = maxid;
+ }
+ ListModels oListModels = new ListModels();
+ try
+ {
+ //缂栬緫鏉冮檺
+ if (!DBUtility.ClsPub.Security_Log_second("Gy_UnitGroup_Edit", 1, false, msg3))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ DAL.ClsGy_Unit_Ctl oBill = new DAL.ClsGy_Unit_Ctl();
+ List<Model.ClsGy_Unit_Model> lsmain = new List<Model.ClsGy_Unit_Model>();
+ msg1 = msg1.Replace("\\", "");
+ msg1 = msg1.Replace("\n", ""); //\n
+ lsmain = oListModels.getObjectByJson_Gy_Unit(msg1);
+ foreach (Model.ClsGy_Unit_Model oItem in lsmain)
+ {
+ if (oItem.HNumber.Trim() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷笉鑳戒负绌猴紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ if (oItem.HName.Trim() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佸悕绉颁笉鑳戒负绌猴紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim()))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮�
+
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_Unit");
+ if (oItem.HNumber.Trim() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷负绌猴紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ //鏂板鏃跺垽鏂�
+ if (oItem.HItemID == 0)
+ {
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦�
+ string sParent;
+ sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
+ if (sParent.Trim() == "")
+ {
+ oBill.oModel.HParentID = 0;
+ }
+ else
+ {
+ if (oBill.HavParentCode(sParent.Trim(), HItemID))
+ {
+ oBill.oModel.HParentID = oBill.oModel.HItemID;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ }
+ }
+ else//缂栬緫鏃跺垽鏂�
+ {
+ //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦�
+ string sParent;
+ sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
+ if (sParent.Trim() == "")
+ {
+ oBill.oModel.HParentID = 0;
+ }
+ else
+ {
+ if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID))
+ {
+ oBill.oModel.HParentID = oBill.oModel.HItemID;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ }
+ }
+ //寰楀埌鐭唬鐮�
+ string sShortNumber;
+ sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
+ if (sShortNumber.Trim() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ oItem.HUSEORGID = Convert.ToInt32(msg_HUSEORGID); //缁勭粐id
+ oItem.HShortNumber = sShortNumber;//鐭唬鐮�
+ oItem.HEndFlag = true;//鏈骇鏍囧織
+ oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇
+ oItem.HRate = msg_HRate;//鎹㈢畻姣斾緥
+ oBill.oModel = oItem;
+ }
+
+ //淇濆瓨
+ //淇濆瓨瀹屾瘯鍚庡鐞�
+ bool bResult;
+ if (oBill.oModel.HItemID == 0)
+ {
+ // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+ bResult = oBill.AddNew();
+ }
+ else
+ {
+ bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+ }
+ if (bResult)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+ //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ }
+
+ [Route("Gy_Unit/SaveGy_UnitListApi")]
+ [HttpPost]
+ public object SaveGy_UnitListApi([FromBody] JObject msg)
+ {
+ try
+ {
+ LogService.Write("鍗曚綅锛�" + msg.ToString());
+ var _value = msg["model"].ToString();
+ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+ ListModels oListModels = new ListModels();
+ List<Model.ClsGy_Unit_Model> lsmain = new List<Model.ClsGy_Unit_Model>();
+ lsmain = oListModels.getObjectByJson_Gy_Unit(_value);
+ string sql = string.Empty;
+ //淇濆瓨
+ oCN.BeginTran();
+ sql = $"delete Gy_Unit where HItemID = {lsmain[0].HItemID}";
+ oCN.RunProc(sql);
+ sql = "set identity_insert Gy_Unit on";
+ oCN.RunProc(sql);
+
+ LogService.Write("鍗曚綅锛�" + "Insert into Gy_Unit" +
+ " (HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HRate,HStandard,HUSEORGID,HCREATEORGID) " +
+ " Values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "'," + lsmain[0].HParentID.ToString() +
+ "," + lsmain[0].HLevel.ToString() + "," + Convert.ToString(lsmain[0].HEndFlag ? 1 : 0) + "," + Convert.ToString(lsmain[0].HStopflag ? 1 : 0) + ",'" + lsmain[0].HRemark +
+ "'," + lsmain[0].HRate.ToString() + "," + DBUtility.ClsPub.BoolToString(lsmain[0].HStandard) + "," + lsmain[0].HUSEORGID + "," + lsmain[0].HCREATEORGID + ")");
+
+ oCN.RunProc("Insert into Gy_Unit" +
+ " (HItemID,HNumber,HName,HHelpCode,HShortNumber,HParentID" +
+ ",HLevel,HEndFlag,HStopflag,HRemark,HRate,HStandard,HUSEORGID,HCREATEORGID,HERPItemID) " +
+ " Values('" + lsmain[0].HItemID + "','" + lsmain[0].HNumber + "','" + lsmain[0].HName + "','" + lsmain[0].HHelpCode + "','" + lsmain[0].HShortNumber + "'," + lsmain[0].HParentID.ToString() +
+ "," + lsmain[0].HLevel.ToString() + "," + Convert.ToString(lsmain[0].HEndFlag ? 1 : 0) + "," + Convert.ToString(lsmain[0].HStopflag ? 1 : 0) + ",'" + lsmain[0].HRemark +
+ "'," + lsmain[0].HRate.ToString() + "," + DBUtility.ClsPub.BoolToString(lsmain[0].HStandard) + "," + lsmain[0].HUSEORGID + "," + lsmain[0].HCREATEORGID + "," + lsmain[0].HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
+ //淇敼涓婄骇涓洪潪鏈骇浠g爜
+ sql = "set identity_insert Gy_Unit off";
+ oCN.RunProc(sql);
+ oCN.Commit();
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ }
+ /// <summary>
+ /// 璁¢噺鍗曚綅鑾峰彇淇℃伅
+ /// </summary>
+ /// <returns></returns>
+ [Route("GetGy_UnitDetail")]
+ [HttpGet]
+ public ApiResult<DataSet> GetGy_UnitDetail(string HID)
+ {
+ var model = LuBaoSevice.GetGy_UnitBillDetail(HID);
+ return model;
+ }
+
+ /// <summary>
+ /// 璁¢噺鍗曚綅鍒犻櫎鍔熻兘
+ /// </summary>
+ /// <returns></returns>
+ [Route("DeltetGy_Unit")]
+ [HttpGet]
+ public object DeltetGy_Unit(string HItemID, string user)
+ {
+ DataSet ds;
+ //string ModRightNameCheck = "Sc_ProcessReport_check";
+ try
+ {
+ //鍒犻櫎鏉冮檺
+ if (!DBUtility.ClsPub.Security_Log("Gy_UnitGroup_Delete", 1, false, user))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏃犲垹闄ゆ潈闄�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+ if (string.IsNullOrWhiteSpace(HItemID))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "HItemID涓虹┖锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ oCN.BeginTran();//寮�濮嬩簨鍔�
+ ds = oCN.RunProcReturn("select * from Gy_Unit where HItemID=" + HItemID, "Gy_Unit");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+ objJsonResult.data = null;
+ return objJsonResult; ;
+ }
+ var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
+ if (HStopflag)
+ {
+ oCN.RollBack();//鍥炴粴浜嬪姟
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鏁版嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ oCN.RunProc("delete from Gy_Unit where HItemID=" + HItemID);
+ 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;
+ }
+ }
+
+ #region [鍚屾鍩虹璧勬枡]
+ [Route("Gy_Unit/Gy_UnitViewApi")]
+ [HttpGet]
+ public json Gy_UnitViewApi(string Number, string Type)
+ {
+ string sql = string.Empty;
+ string sReturn = "";
+ if (oSystemParameter.ShowBill(ref sReturn) == true)
+ {
+ //绯荤粺鍙傛暟鏄惁涓虹鏈変簯妯″紡,N涓哄叕鏈変簯妯″紡锛孻涓虹鏈変簯妯″紡
+ if (oSystemParameter.omodel.WMS_CloudMode == "Y")
+ {
+ #region [绉佹湁浜戞ā寮忥紝鐩存帴璋冪敤鏁版嵁搴撳瓨鍌ㄨ繃绋嬫洿鏂癩
+ try
+ {
+ oCN.BeginTran();
+ SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+ DataSet DS = oCn.RunProcReturn("exec h_p_WMS_ERPBasicInfoToLocal '" + Number + "','" + Type + "'", "h_p_WMS_ERPBasicInfoToLocal");
+ if (DS == null)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍩虹璧勬枡鍚屾澶辫触";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ if (DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBack"]) == "2")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "ERP涓笉瀛樺湪璇ヤ唬鐮�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍩虹璧勬枡鍚屾鎴愬姛";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ #endregion
+ }
+ else
+ {
+ #region [鍏湁浜戞ā寮忥紝璋冪敤WEBAPI鐨勬柟寮忚繘琛屾洿鏂癩
+ var json = new
+ {
+ CreateOrgId = 0,
+ Number = Number,
+ Id = ""
+ };
+ #region [閲戣澏閮ㄥ垎]
+ //鐧诲綍閲戣澏
+ var loginRet = InvokeHelper.Login();
+ var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>();
+ //鍒ゆ柇鏄惁鐧诲綍鎴愬姛
+ if (isSuccess < 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = loginRet;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ //鏌ョ湅 鑾峰彇鏁版嵁
+ var _result = InvokeHelper.View("BD_UNIT", JsonConvert.SerializeObject(json));
+ var _saveObj = JObject.Parse(_result);
+ //鍒ゆ柇鏁版嵁鏄惁鑾峰彇鎴愬姛
+ if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "閲戣澏璁¢噺鍗曚綅鍚屾澶辫触jsonRoot锛�" + _result;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ #endregion
+ //鑾峰彇鏁版嵁
+ DataSet Ds;
+ Ds = oCN.RunProcReturn("select * from Gy_Unit where HNumber = '" + Number + "'", "Gy_Unit");
+ if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"].ToString()) != 0)
+ {
+
+ }
+
+ #region [琛ㄦ暟鎹祴鍊糫
+ var jsonData = new
+ {
+ HItemID = _saveObj["Result"]["Result"]["Id"],
+ HERPItemID = _saveObj["Result"]["Result"]["Id"],
+ HNumber = _saveObj["Result"]["Result"]["Number"],
+ HName = _saveObj["Result"]["Result"]["Name"][0]["Value"],
+ HShortNumber = _saveObj["Result"]["Result"]["Number"],
+ HParentID = 0,
+ HLevel = 1,
+ HEndFlag = 1,
+ HStopflag = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1,
+ HRemark = "CLD-ERP瀵煎叆",
+ HUseFlag = "鏈娴�",
+ HRate = "1",
+ HMakeTime = _saveObj["Result"]["Result"]["CreateDate"],
+ HStandard = 1,
+ HCREATEORGID = _saveObj["Result"]["Result"]["CreatorId_Id"],
+ HUSEORGID = 0,
+ };
+ #endregion
+ // 鍒犻櫎涓昏〃瀵瑰簲鏁版嵁
+ sql = $"delete from Gy_Unit where HItemID = " + jsonData.HItemID + " and HNumber = '" + Number + "'";
+ oCN.RunProc(sql);
+
+ sql = "set identity_insert Gy_Unit on";
+ oCN.RunProc(sql);
+
+ //鎻掑叆琛�
+ sql = $@"
+ insert into Gy_Unit
+ (HItemID,HERPItemID,HNumber,HName,HShortNumber,HParentID
+ ,HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HRate,HMakeTime,HStandard,HCREATEORGID,HUSEORGID
+ )
+ values
+ ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}',
+ '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}','{jsonData.HUseFlag}','{jsonData.HRate}','{jsonData.HMakeTime}',{jsonData.HStandard},{jsonData.HCREATEORGID},{jsonData.HUSEORGID})";
+
+ oCN.RunProc(sql);
+
+ sql = "set identity_insert Gy_Unit off";
+ oCN.RunProc(sql);
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "璁¢噺鍗曚綅鍚屾鎴愬姛锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+
+ #endregion
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍩虹璧勬枡璇诲彇澶辫触锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
- //
+ #region 绂佺敤銆佸弽绂佺敤
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="HInterID">鍗曟嵁ID</param>
+ /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param>
+ /// <param name="CurUserName">瀹℃牳浜�</param>
+ /// <returns></returns>
+ [Route("Gy_Unit/StopGy_Unit")]
+ [HttpGet]
+ public object StopGy_MaterType(int HInterID, int IsStop, string CurUserName)
+ {
+ try
+ {
+ //瀹℃牳鏉冮檺
+ if (!DBUtility.ClsPub.Security_Log_second("Gy_Unit_Stop", 1, false, CurUserName))
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ var ds = oCN.RunProcReturn("select * from Gy_Unit where HItemID=" + HInterID, "Gy_Unit");
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ if (IsStop == 0) //绂佺敤鍒ゆ柇
+ {
+ if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+ {
+ if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() == "")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁鏈鐢�!涓嶉渶瑕佸弽绂佺敤!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ }
+ else
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ oCN.BeginTran();
+
+ if (IsStop == 0) //绂佺敤鍒ゆ柇
+ {
+ oCN.RunProc("update Gy_Unit set HStopEmp='" + CurUserName + "',HStopDate=getdate(),HStopflag=1 where HItemID=" + HInterID);
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "绂佺敤鎴愬姛";
+ objJsonResult.data = null;
+ }
+ if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+ {
+ oCN.RunProc("update Gy_Unit set HStopEmp='',HStopDate=null,HStopflag=0 where HItemID=" + HInterID);
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�";
+ objJsonResult.data = null;
+ }
+ oCN.Commit();
+
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "绂佺敤澶辫触鎴栬�呭弽绂佺敤澶辫触锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1