From 4441719f8b9dba3bb533c6b4c43627d1443dc171 Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期一, 21 十一月 2022 10:32:16 +0800
Subject: [PATCH] 工作日设置
---
WebAPI/Controllers/BaseSet/Gy_WorkDayController.cs | 277 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
WebAPI/Models/基础资料/WorkDay.cs | 19 +++
WebAPI/WebAPI.csproj | 2
WebAPI/Controllers/POStockInBillController.cs | 1
4 files changed, 298 insertions(+), 1 deletions(-)
diff --git a/WebAPI/Controllers/BaseSet/Gy_WorkDayController.cs b/WebAPI/Controllers/BaseSet/Gy_WorkDayController.cs
new file mode 100644
index 0000000..2ccd2ff
--- /dev/null
+++ b/WebAPI/Controllers/BaseSet/Gy_WorkDayController.cs
@@ -0,0 +1,277 @@
+锘縰sing Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Pub_Class;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Web.Http;
+using WebAPI.Models;
+
+namespace WebAPI.Controllers
+{
+ public class Gy_WorkDayController : ApiController
+ {
+ public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+
+ private json objJsonResult = new json();
+ SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+ DataSet ds;
+ /// <summary>
+ /// 杩斿洖浠撳簱鍒楄〃
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Gy_WorkDay/list")]
+ [HttpGet]
+ public object list(string sWhere, string user)
+ {
+ try
+ {
+ List<object> columnNameList = new List<object>();
+ //缂栬緫鏉冮檺
+ //if (!DBUtility.ClsPub.Security_Log_second("Gy_WorkDay", 1, false, user))
+ //{
+ // objJsonResult.code = "0";
+ // objJsonResult.count = 0;
+ // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+ // objJsonResult.data = null;
+ // return objJsonResult;
+ //}
+ string sql1 = string.Format(@"select * from H_v_Gy_WorkDay where 1='" + 1 + "'");
+ if (sWhere == null || sWhere.Equals(""))
+ {
+ ds = oCN.RunProcReturn(sql1 + sWhere + "", "H_v_Gy_WorkDay");
+ }
+ else
+ {
+ string sql = sql1 + sWhere;
+ ds = oCN.RunProcReturn(sql, "H_v_Gy_WorkDay");
+ }
+
+ //娣诲姞鍒楀悕
+ 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)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 淇濆瓨鎸夐挳
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Gy_WorkDay/ModifyByID")]
+ [HttpPost]
+ public object ModifyByID([FromBody] JObject oMain)
+ {
+ try
+ {
+ var _value = oMain["oMain"].ToString();
+ string msg1 = _value.ToString();
+ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+ string msg2 = sArray[0].ToString();
+ string msg3 = sArray[1].ToString();
+
+ //鍙嶅簭鍒楀寲
+ msg2 = "[" + msg2.ToString() + "]";
+ List<WorkDay> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<WorkDay>>(msg2);
+
+ long HItemID = list[0].HItemID;
+
+ //淇濆瓨
+ //淇濆瓨瀹屾瘯鍚庡鐞�
+ if (HItemID == 0)
+ {
+ oCN.BeginTran();
+ string sql = string.Format(@"insert into Gy_WorkDay (HDate,HWorkBegin,HWorkEnd,HNoonbreakBegin,HNoonbreakEnd,HNightbreakBegin,HNightbreakEnd)
+values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", list[0].HDate, list[0].HWorkBegin, list[0].HWorkEnd, list[0].HNoonbreakBegin, list[0].HNoonbreakEnd, list[0].HNightbreakBegin, list[0].HNightbreakEnd);
+ oCN.RunProc(sql);
+ oCN.Commit();
+ }
+ else
+ {
+ //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
+ oCN.BeginTran();
+ //涓昏〃
+ oCN.RunProc("Update Gy_WorkDay set " +
+ " HDate='" + list[0].HDate + "'" +
+ ",HWorkBegin='" + list[0].HWorkBegin + "'" +
+ ",HWorkEnd='" + list[0].HWorkEnd + "'" +
+ ",HNoonbreakBegin='" + list[0].HNoonbreakBegin + "'" +
+ ",HNoonbreakEnd=" + list[0].HNoonbreakEnd +
+ ",HNightbreakBegin=" + list[0].HNightbreakBegin +
+ ",HNightbreakEnd=" + list[0].HNightbreakEnd +
+ " Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
+ //
+ oCN.Commit();
+ }
+ objJsonResult.code = "0";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+ //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+ objJsonResult.data = 1;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ //oCN.RollBack();
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.Message;
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁鍩虹璧勬枡ID 鏌ユ壘璁板綍
+ ///鍙傛暟锛歴tring sql銆�
+ ///杩斿洖鍊硷細object銆�
+ /// </summary>
+ [Route("Gy_WorkDay/cx")]
+ [HttpGet]
+ public object cx(long HInterID)
+ {
+ try
+ {
+
+ ds = oCN.RunProcReturn("select * from Gy_WorkDay where HitemID=" + HInterID, "Gy_WorkDay");
+ if (ds == null || ds.Tables[0].Rows.Count == 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "false锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ else
+ {
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = ds.Tables[0];
+ return objJsonResult;
+ }
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+
+ /// <summary>
+ /// 鍖呰鏂瑰紡鍒楄〃鍒犻櫎鍔熻兘
+ /// </summary>
+ /// <returns></returns>
+ [Route("DeltetGy_WorkDay")]
+ [HttpGet]
+ public object DeltetGy_WorkDay(string HItemID, string user)
+ {
+ DataSet ds;
+ DataSet ds1;
+ try
+ {
+ ////鍒犻櫎鏉冮檺
+ //if (!DBUtility.ClsPub.Security_Log("Gy_Warehouse_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_WorkDay where HItemID=" + HItemID, "Gy_WorkDay");
+ 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;
+ //}
+ ds1 = oCN.RunProcReturn("Select HItemID from Gy_WorkDay Where HParentID='" + HItemID + "'", "Gy_WorkDay");
+ if (ds1.Tables[0].Rows.Count != 0)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "姝ら」鐩瓨鍦ㄥ瓙椤圭洰锛屼笉鑳藉垹闄わ紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ string HUseFlag = Convert.ToString(ds.Tables[0].Rows[0]["HUseFlag"]);
+ if (HUseFlag == "宸蹭娇鐢�")
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "姝ら」鐩凡浣跨敤锛屼笉鑳藉垹闄わ紒";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+
+ oCN.RunProc("delete from Gy_WorkDay 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;
+ }
+ }
+
+
+ }
+}
\ No newline at end of file
diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs
index e579bda..38913c9 100644
--- a/WebAPI/Controllers/POStockInBillController.cs
+++ b/WebAPI/Controllers/POStockInBillController.cs
@@ -1113,7 +1113,6 @@
}
-
#region 鍒拌揣纭
[Route("POStockInBillList/Get_ReciveBill")]
[HttpGet]
diff --git "a/WebAPI/Models/\345\237\272\347\241\200\350\265\204\346\226\231/WorkDay.cs" "b/WebAPI/Models/\345\237\272\347\241\200\350\265\204\346\226\231/WorkDay.cs"
new file mode 100644
index 0000000..36320f9
--- /dev/null
+++ "b/WebAPI/Models/\345\237\272\347\241\200\350\265\204\346\226\231/WorkDay.cs"
@@ -0,0 +1,19 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace WebAPI.Models
+{
+ public class WorkDay
+ {
+ public long HItemID { get; set; } //涓婚敭
+ public DateTime HDate { get; set; }
+ public DateTime HWorkBegin { get; set; }
+ public DateTime HWorkEnd { get; set; }
+ public DateTime HNoonbreakBegin { get; set; }
+ public DateTime HNoonbreakEnd { get; set; }
+ public DateTime HNightbreakBegin { get; set; }
+ public DateTime HNightbreakEnd { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index 9e9eac2..87cbfbd 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -322,6 +322,7 @@
<Compile Include="App_Start\WebApiConfig.cs" />
<Compile Include="Controllers\BaseSet\Gy_BarCodeBillController.cs" />
<Compile Include="Controllers\BaseSet\Gy_ConkTypeController.cs" />
+ <Compile Include="Controllers\BaseSet\Gy_WorkDayController.cs" />
<Compile Include="Controllers\BaseSet\Gy_PackTypeController.cs" />
<Compile Include="Controllers\BaseSet\Gy_RoutingGroupController.cs" />
<Compile Include="Controllers\BaseSet\Gy_TechnologyController.cs" />
@@ -616,6 +617,7 @@
<Compile Include="Models\鍩虹璧勬枡\ConkType.cs" />
<Compile Include="Models\鍩虹璧勬枡\Gy_ClassTimePrj.cs" />
<Compile Include="Models\鍩虹璧勬枡\Gy_Duty.cs" />
+ <Compile Include="Models\鍩虹璧勬枡\WorkDay.cs" />
<Compile Include="Models\鍩虹璧勬枡\PackType.cs" />
<Compile Include="Models\鍩虹璧勬枡\WorkStation.cs" />
<Compile Include="Models\宸ヨ祫绠$悊\ClsGy_ClassTimePrj_Model.cs" />
--
Gitblit v1.9.1