From 1e5c4412216cdba315ab37ebc8e85644f39a7df1 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期五, 11 七月 2025 16:50:02 +0800
Subject: [PATCH] PDA校验扫描物料条码方法修改,增加校验模块免扫物料条码系统参数

---
 WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs |  427 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 406 insertions(+), 21 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs b/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs
index a596213..a354e80 100644
--- a/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_EmployeeController.cs
@@ -6,8 +6,11 @@
 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.Models.鍩虹璧勬枡;
 using WebAPI.Service;
 
 namespace WebAPI.Controllers
@@ -21,7 +24,7 @@
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
-
+        string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
 
         /// <summary>
         /// 杩斿洖鑱屽憳鍒楄〃
@@ -36,7 +39,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;
@@ -47,11 +50,11 @@
                 string sql1 = string.Format(@"select * from h_v_IF_EmployeeList where 缁勭粐鍚嶇О='" + Organization + "'");
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn(sql1 + sWhere + " order by 鑱屽憳浠g爜", "h_v_IF_EmployeeList");
+                    ds = oCN.RunProcReturn(sql1 + sWhere, "h_v_IF_EmployeeList");
                 }
                 else
                 {
-                    string sql = sql1 + sWhere + " order by 鑱屽憳浠g爜";
+                    string sql = sql1 + sWhere;
                     ds = oCN.RunProcReturn(sql, "h_v_IF_EmployeeList");
                 }
 
@@ -265,6 +268,8 @@
         //        return objJsonResult;
         //    }
         //}
+
+
         /// <summary>
         /// 淇濆瓨鎸夐挳
         ///鍙傛暟锛歴tring sql銆�
@@ -274,8 +279,9 @@
         [HttpPost]
         public object ModifyByID([FromBody] JObject oMain)
         {
+
             try
-            {
+            {   
                 DAL.ClsGy_Employee_Ctl oDept = new DAL.ClsGy_Employee_Ctl();
                 DAL.ClsGy_Employee_View oDeptHlp = new DAL.ClsGy_Employee_View();
 
@@ -284,9 +290,10 @@
                 string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                 string msg2 = sArray[0].ToString();
                 string msg3 = sArray[1].ToString();
+                string msg4 = sArray[2].ToString();
                 //string msg4 = sArray[2].ToString();
                 //string msg5 = sArray[3].ToString();
-
+                oCN.BeginTran();
                 //缂栬緫鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log_second("Gy_Employee_Edit", 1, false, msg3))
                 {
@@ -300,6 +307,7 @@
                 //鍙嶅簭鍒楀寲
                 msg2 = "[" + msg2.ToString() + "]";
                 List<Gy_Employee> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_Employee>>(msg2);
+                List<ClsGy_EmployeeSub> list1 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsGy_EmployeeSub>>(msg4);
 
                 long HItemID = list[0].HItemID;
                 string HNumber = list[0].HNumber;
@@ -330,8 +338,8 @@
                 long HCTPrjID = list[0].HCTPrjID;
                 long HProcID = list[0].HProcID;
                 string HBasePay = list[0].HBasePay;
-                DateTime HInComDate = list[0].HInComDate;   //杩涘巶鏃ユ湡
-                DateTime HDimissionDate = list[0].HDimissionDate;   //绂昏亴鏃ユ湡 (鍏佽NULL)
+                DateTime HInComDate = list[0].HInComDate == null ? Convert.ToDateTime("1900/1/1") : list[0].HInComDate.Value;   //杩涘巶鏃ユ湡
+                DateTime HDimissionDate = list[0].HDimissionDate == null ? Convert.ToDateTime("1900/1/1") : list[0].HDimissionDate.Value;   //绂昏亴鏃ユ湡 (鍏佽NULL)
                 bool HOverType = list[0].HOverType;
                 string HEmpType = list[0].HEmpType;
                 string HOtherDeduct3 = list[0].HOtherDeduct3;
@@ -345,16 +353,16 @@
                 string HDimissionReason = list[0].HDimissionReason;
                 long HDormID = list[0].HDormID;
                 string HArchivesNo = list[0].HArchivesNo;
-                DateTime HStayCardEDate = list[0].HStayCardEDate;   //鏆備綇璇佸埌鏈熸棩
+                DateTime HStayCardEDate = list[0].HStayCardEDate == null ? Convert.ToDateTime("1900/1/1") : list[0].HStayCardEDate.Value;   //鏆備綇璇佸埌鏈熸棩
                 DateTime HCheckCardEDate = Convert.ToDateTime("1900/1/1");  //瀹℃璇佸埌鏈熸棩
                 string HJobCardNo = list[0].HJobCardNo ?? "";
                 DateTime HJobCardEDate = Convert.ToDateTime("1900/1/1");  //灏变笟璇佸埌鏈熸棩
                 string HWorkType = list[0].HWorkType;
                 long HContractYear = list[0].HContractYear;
-                DateTime HContractBDate = list[0].HContractBDate;  //鍚堝悓寮�濮嬫棩
-                DateTime HContractEDate = list[0].HContractEDate;   //鍚堝悓鍒版湡鏃�
+                DateTime HContractBDate = list[0].HContractBDate == null ?  Convert.ToDateTime("1900/1/1") : list[0].HContractBDate.Value;  //鍚堝悓寮�濮嬫棩
+                DateTime HContractEDate = list[0].HContractEDate == null ? Convert.ToDateTime("1900/1/1") : list[0].HContractEDate.Value;   //鍚堝悓鍒版湡鏃�
                 string HInsuranceNo = list[0].HInsuranceNo;
-                DateTime HInsuranceDate = list[0].HInsuranceDate;   //鍙備繚鏃ユ湡
+                DateTime HInsuranceDate = list[0].HInsuranceDate == null ? Convert.ToDateTime("1900/1/1") : list[0].HInsuranceDate.Value;   //鍙備繚鏃ユ湡
                 bool HInsuranceStatus = list[0].HInsuranceStatus;
                 DateTime HSignDate =  Convert.ToDateTime("1900/1/1");  //绛剧害鏃ユ湡
                 bool HSignStatus = list[0].HSignStatus;
@@ -365,7 +373,7 @@
                 string HSpec = list[0].HSpec ?? "";
                 string HCompLev = list[0].HCompLev ?? "";
                 string HEngLev = list[0].HEngLev ?? "";
-                DateTime HGradDate = list[0].HGradDate;  //姣曚笟鏃ユ湡
+                DateTime HGradDate = list[0].HGradDate == null ? Convert.ToDateTime("1900/1/1") : list[0].HGradDate.Value;  //姣曚笟鏃ユ湡
                 string HGradSchool = list[0].HGradSchool ?? "";
                 string HSalaryLev = list[0].HSalaryLev ?? "";
                 long HDutyID = list[0].HDutyID;
@@ -424,11 +432,23 @@
                 //    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)
                 {
-                    oCN.BeginTran();
+                   
                     oCN.RunProc("Insert into Gy_Employee (" +
                       "HNumber,HName,HShortNumber,HEmpRate,HExamRate" +
                       ",HLevel,HParentID,HEndflag,HHighestPay,HOverPayRate" +
@@ -446,7 +466,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 +484,52 @@
                       "','" + 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();
+
+                    DataSet temp_ds = oCN.RunProcReturn("select top 1 HItemID from Gy_Employee where HNumber = N'" + HNumber + "'", "Gy_Employee");
+
+                    if (temp_ds.Tables[0].Rows.Count < 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜锛氭彃鍏ユ暟鎹け璐�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    int itemID = int.Parse(temp_ds.Tables[0].Rows[0]["HItemID"].ToString());
+                    string sql3 = "";
+                    foreach (ClsGy_EmployeeSub listOne in list1)
+                    {
+                        sql3 += "insert into Gy_Employee_Post(HEmpID, HPostID, HRemark) Values("
+                        + itemID + "," + listOne.HPostID +",N'" + listOne.HRemark + "');";
+
+                    }
+                    LogService.Write(sql3);
+                    oCN.RunProcReturn(sql3, "Gy_Employee_Post");
+                    
                 }
                 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 + "'" +
@@ -558,8 +615,20 @@
 
                     ",HAddress='" +  HAddress.ToString() + "'" +
                     ",HDeptID= '" +  HDeptID + "' Where HItemID=" + HItemID);
-                    oCN.Commit();
+
+                    oCN.RunProcReturn("delete from Gy_Employee_Post where HEmpID = " + HItemID, "Gy_Employee_Post");
+
+                    string sql3 = "";
+                    foreach (ClsGy_EmployeeSub listOne in list1)
+                    {
+                        sql3 += "insert into Gy_Employee_Post(HEmpID, HPostID, HRemark) Values("
+                       + HItemID + "," + listOne.HPostID  + ",N'" + listOne.HRemark + "');";
+                    }
+                    LogService.Write(sql3);
+                    oCN.RunProcReturn(sql3, "Gy_WorkCenterSub");
+                    
                 }
+                oCN.Commit();
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
@@ -569,7 +638,7 @@
             }
             catch (Exception e)
             {
-                //oCN.RollBack();
+                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.Message;
@@ -577,6 +646,8 @@
                 return objJsonResult;
             }
         }
+
+
         ///// <summary>
         ///// 淇濆瓨鑱屽憳
         ///// </summary>
@@ -809,7 +880,52 @@
         //    }
         //}
 
+        /// <summary>
+        /// 鏌ヨ瀛愯〃鏂规硶
+        /// </summary>
+        [Route("Gy_Employee/listSub")]
+        [HttpGet]
+        public object listSub(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_Employee_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
+                ds = oCN.RunProcReturn("select * from h_v_IF_EmployeeSubList where 1 = 1 " + sWhere + " order by HItemID ", "h_v_IF_EmployeeSubList");
+
+                //娣诲姞鍒楀悕
+                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>
         /// 鑱屽憳璁剧疆鑾峰彇淇℃伅
@@ -854,6 +970,8 @@
                     return objJsonResult;
                 }
                 oCN.BeginTran();//寮�濮嬩簨鍔�
+                string HNumber = "";
+                string HName = "";
                 ds = oCN.RunProcReturn("select * from Gy_Employee where HItemID=" + HItemID, "Gy_Employee");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
@@ -862,7 +980,21 @@
                     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; ;
                 }
+                else
+                {
+                    HNumber = ds.Tables[0].Rows[0]["HNumber"].ToString();
+                    HName = ds.Tables[0].Rows[0]["HName"].ToString();
+                }
+
+
                 var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
                 if (HStopflag)
                 {
@@ -875,6 +1007,24 @@
                 }
 
                 oCN.RunProc("delete from Gy_Employee where HItemID=" + HItemID);
+
+
+
+                //鍐欏叆鏃ュ織
+                string Operation = "鍒犻櫎";                                          //鎿嶄綔
+                string ComputerName = System.Net.Dns.GetHostName();                 //璁惧鍚嶇О
+                string WorkList = Operation + "鑱屽憳锛岃亴鍛樹唬鐮侊細" + HNumber + "锛涜亴鍛樺悕绉帮細" + HName ;         //鎿嶄綔璇︽儏
+                string MvarReportTitle = "鑱屽憳鍒楄〃";                                //鎿嶄綔妯″潡
+                string SystemName = "LMES-" + MvarReportTitle + "妯″潡";             //鎿嶄綔妯″潡
+                string IPAddress = "";
+                //string IPAddress = Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString();   //IP鍦板潃
+                //string IPAddress = System.Web.HttpContext.Current.Request.UserHostAddress; 
+
+                oCN.RunProc("Insert into  System_Log(GeginDate,userid,WorkstationName,WorkList,SystemName,NetUserName,State) values " +
+                    "(getdate(),'" + user + "','" + ComputerName + "','" + WorkList + "','" + SystemName + "','" + IPAddress + "','" + Operation + "')"
+                    );
+
+
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -1280,7 +1430,7 @@
 	            ,HLevel,HEndFlag,HStopflag,HRemark,HDeptID,HGroupID,HUseFlag,HMakeTime,HCREATEORGID,HUSEORGID
                  )
                 values
-                ({jsonData.HItemID},{jsonData.HERPItemID},'{jsonData.HNumber}','{jsonData.HName}',
+                ({jsonData.HItemID},{jsonData.HItemID},'{jsonData.HNumber}','{jsonData.HName}',
                 '{jsonData.HShortNumber}',{jsonData.HParentID},{jsonData.HLevel},{jsonData.HEndFlag},{jsonData.HStopflag},'{jsonData.HRemark}',{jsonData.HDeptID},{jsonData.HGroupID},'{jsonData.HUseFlag}','{jsonData.HMakeTime}',{jsonData.HCREATEORGID},{jsonData.HUSEORGID})";
 
                     oCN.RunProc(sql);
@@ -1308,5 +1458,240 @@
         }
         #endregion
 
+        #region 鏍规嵁鐝粍杩斿洖鑱屽憳淇℃伅
+        /// <summary>
+        /// 鏍规嵁鐝粍杩斿洖鑱屽憳淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("Gy_EmployeeController/GetEmpInfoByGroup_Json")]
+        [HttpGet]
+        public object GetEmpInfoByGroup_Json(Int64 HGroupID)
+        {
+            try
+            {
+                //杩斿洖鍒楄〃淇℃伅
+                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";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鎵�閫夌彮缁勬棤瀵瑰簲鑱屽憳淇℃伅锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    List<object> columnNameList = new List<object>();
+                    //娣诲姞鍒楀悕
+                    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 = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鎴愬姛锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    objJsonResult.list = columnNameList;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏍规嵁鐝粍杩斿洖鑱屽憳淇℃伅澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #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