From 5466e02176f2acf2f08ef1c16315c3185bae903f Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期一, 19 五月 2025 15:53:34 +0800
Subject: [PATCH] 异常反馈单,快捷开工接口调整

---
 WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs |  234 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 228 insertions(+), 6 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs b/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs
index a439450..4224555 100644
--- a/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs
@@ -6,6 +6,8 @@
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
+using System.IO;
+using System.Web;
 using System.Web.Http;
 using WebAPI.Models;
 using WebAPI.Service;
@@ -21,7 +23,7 @@
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
-
+        string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
 
         /// <summary>
         /// 杩斿洖鑱屽憳鍒楄〃
@@ -36,7 +38,7 @@
             {
                 List<object> columnNameList = new List<object>();
                 //缂栬緫鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee", 1, false, user))
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Query", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -265,6 +267,8 @@
         //        return objJsonResult;
         //    }
         //}
+
+
         /// <summary>
         /// 淇濆瓨鎸夐挳
         ///鍙傛暟锛歴tring sql銆�
@@ -424,6 +428,17 @@
                 //    objJsonResult.data = null;
                 //    return objJsonResult;
                 //}
+                //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮�
+                ds = oCN.RunProcReturn("Select HItemID from Gy_Employee  Where HItemID<>" + HItemID + " and HNumber='" + HNumber + "' and HUSEORGID=" + HUSEORGID, "Gy_Warehouse");
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒";
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 if (HItemID == 0)
@@ -446,7 +461,7 @@
                       ",HEmpType,HPayType,HOverType,HNoBrushFlag,HShiftFlag,HStopwagesFlag" +
                       ",HPostalCode,HBank,HBasePay,HExamLevPostMoney,HBSTDeptID" +
                       ",HOtherDeduct3,HInsurance,HMedicare,HDrydock" +
-                      ",HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HUSEORGID,HAddress" +
+                      ",HBankAccount,HGroupID,HDeptID,HWorkTypeID,HCTPrjID,HUSEORGID,HAddress,HMakeEmp" +
                       ") " +
                    " Values('" + HNumber + "','" + HName + "','" + HShortNumber + "','" + HEmpRate.ToString() + "','" + HExamRate.ToString() +
                       "','" + HLevel + "','" + HParentID + "','" + Convert.ToString(HEndFlag ? 1 : 0) + "','" + HHighestPay.ToString() + "','" + HOverPayRate.ToString() +
@@ -464,15 +479,29 @@
                       "','" + HEmpType + "'" + ",'" + HPayType + "'" + ",'" + DBUtility.ClsPub.BoolToString(HOverType) + "','" + DBUtility.ClsPub.BoolToString(HNoBrushFlag) + "','" + DBUtility.ClsPub.BoolToString(HShiftFlag) + "','" + DBUtility.ClsPub.BoolToString(HStopwagesFlag) +
                       "','" + HPostalCode + "','" + HBank + "','" + HBasePay.ToString() + "','" + HExamLevPostMoney.ToString() + "','" + HBSTDeptID + "'" +
                       ",'" + HOtherDeduct3.ToString() + "','" + HInsurance.ToString() + "','" + HMedicare.ToString() + "','" + HDrydock.ToString() +
-                      "','" + HBankAccount + "'" + ",'" + HGroupID.ToString() + "','" + HDeptID.ToString() + "','" + HWorkTypeID.ToString() + "','" + HCTPrjID.ToString() + "','" + HUSEORGID + "','" + HAddress + "')", ref DBUtility.ClsPub.sExeReturnInfo);
+                      "','" + HBankAccount + "'" + ",'" + HGroupID.ToString() + "','" + HDeptID.ToString() + "','" + HWorkTypeID.ToString() + "','" + HCTPrjID.ToString() + "','" + HUSEORGID + "','" + HAddress + "','"+ msg3 + "')", ref DBUtility.ClsPub.sExeReturnInfo);
                     //淇敼涓婄骇涓洪潪鏈骇浠g爜
                     oCN.RunProc("Update Gy_Employee set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.Commit();
                 }
                 else
                 {
+                    
                     //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
                     oCN.BeginTran();
+                    //宸插鏍镐笉鍏佽淇敼
+                    DataSet dss;
+                    dss = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HItemID, "Gy_Employee");
+                    //鍒ゆ柇鏄惁鍙紪杈�
+                    if (dss.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "姝ゅ崟鎹姸鎬佸凡缁忓鏍革紝涓嶅厑璁镐慨鏀癸紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     oCN.RunProc("Update Gy_Employee set " +
                     " HNumber='" +  HNumber + "'" +
                     ",HName='" +  HName + "'" +
@@ -577,6 +606,8 @@
                 return objJsonResult;
             }
         }
+
+
         ///// <summary>
         ///// 淇濆瓨鑱屽憳
         ///// </summary>
@@ -862,6 +893,13 @@
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }else 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; ;
                 }
@@ -1335,7 +1373,6 @@
         }
         #endregion
 
-
         #region 鏍规嵁鐝粍杩斿洖鑱屽憳淇℃伅
         /// <summary>
         /// 鏍规嵁鐝粍杩斿洖鑱屽憳淇℃伅
@@ -1348,7 +1385,8 @@
             try
             {
                 //杩斿洖鍒楄〃淇℃伅
-                ds = oCN.RunProcReturn("select * from h_v_IF_EmployeeList where 绂佺敤鏍囪='' and HGroupID=" + HGroupID + " order by 鑱屽憳浠g爜", "h_v_IF_EmployeeList");
+                ds = oCN.RunProcReturn("exec h_p_Pay_GetEmployeeByGroup " + HGroupID.ToString(), "h_p_Pay_GetEmployeeByGroup");
+                //ds = oCN.RunProcReturn("select * from h_v_IF_EmployeeList where 绂佺敤鏍囪='' and HGroupID=" + HGroupID + " order by 鑱屽憳浠g爜", "h_v_IF_EmployeeList");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -1386,5 +1424,189 @@
         }
         #endregion
 
+        #region 鑱屽憳闄勪欢涓婁紶
+        /// <summary>
+        /// 鏂囦欢涓婁紶
+        /// </summary>
+        /// <returns></returns>
+        [Route("Gy_Employee_UploadFile")]
+        [HttpPost]
+        public object Gy_Employee_UploadFile()
+        {
+
+            string HBillNo = HttpContext.Current.Request.Params["HBillNo"];  //鍗曟嵁鍙�
+            string HRemark = HttpContext.Current.Request.Params["HRemark"];  //澶囨敞
+            string HUserName = HttpContext.Current.Request.Params["HUserName"];  //鍒涘缓浜�
+            HttpPostedFile files = HttpContext.Current.Request.Files["file"];
+            string path = HttpContext.Current.Server.MapPath("~/../Files/Gy_Employee/" + HBillNo);
+
+            dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName);
+            if (dyResult != null && dyResult.result == 1)
+            {
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "涓婁紶鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = dyResult.returnval;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+
+        public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName)
+        {
+            dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" };
+            string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞
+            string fileExtension = Path.GetExtension(files.FileName);// 鏂囦欢鎵╁睍鍚�
+            string filename = files.FileName;//鏂囦欢鍚�
+            string fileSavePath = path;// 涓婁紶淇濆瓨璺緞
+            int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte
+            int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M
+            try
+            {
+                if (files == null || files.ContentLength <= 0)
+                {
+                    Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" };
+                    return Result_Ob;
+                }
+                if (filesize >= Maxsize)
+                {
+                    Result_Ob = new { result = 0, returnval = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒" };
+                    return Result_Ob;
+                }
+
+                string fileurl = Path.Combine(fileSavePath, filename);
+                if (Directory.Exists(fileurl) == true)  //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀�  
+                {
+                    Result_Ob = new { result = 0, returnval = "瀛樺湪鍚屽悕鏂囦欢锛�" };
+                    return Result_Ob;
+                }
+                //鍒犻櫎鏁版嵁琛ㄦ暟鎹�
+                ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList");
+                if (Directory.Exists(path))
+                {
+                    File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/Gy_Employee/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+                else
+                {
+                    Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶�
+                    files.SaveAs(fileurl);
+                    string StrPath = "/files/Gy_Employee/" + HBillNo + "/" + filename;
+                    if (File.Exists(fileurl))
+                    {
+                        //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱
+                        //鍐欏叆鏁版嵁琛�
+                        oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" +
+                                    ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" +
+                                    ",HFileClsID,HSourceBillNo" +
+                                   ") values('"
+                                    + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" +
+                                    ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize +
+                                    "','" + 0 + "','" + HBillNo +
+                                   "') ");
+                    }
+                    else
+                    {
+                        Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" };
+                    }
+                }
+
+            }
+            catch (Exception e)
+            {
+                Result_Ob = new { result = 0, returnval = e.Message };
+            }
+            return Result_Ob;
+        }
+
+        /// <summary>
+        /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛�
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Gy_Employee_Filelist")]
+        [HttpGet]
+        public object Gy_Employee_Filelist(string HBillNo)
+        {
+            var url = fileip + "/files/Gy_Employee/" + HBillNo + "/";
+            //@"C:\\files\\"
+            try
+            {
+                ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url  from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList");
+                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>
+        /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢
+        /// </summary>
+        /// <param name="sWhere"></param>
+        /// <returns></returns>
+        [Route("Gy_Employee_DeleteFilelist")]
+        [HttpGet]
+        public object Gy_Employee_DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName)
+        {
+            try
+            {
+
+                oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID);
+                string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipTechParamFolder/" + HSourceBillNo), HFileName);
+                File.Delete(fileurl);      //鍒犻櫎鎸囧畾鏂囦欢
+                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
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1