| using DLL; | 
| using 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.IO; | 
| using System.Threading.Tasks; | 
| using System.Web; | 
| using System.Web.Http; | 
| using WebAPI.Models; | 
|   | 
| namespace WebAPI.Controllers | 
| { | 
|   | 
|     public class SB_EquipICMOTechParamBillController : ApiController | 
|     { | 
|         public DBUtility.ClsPub.Enum_BillStatus BillStatus; | 
|         Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
|         public const string ModName = "3919";                   //单据类型 | 
|         public const string ModCaption = "设备工艺参数订单点检表";          //单据名称 | 
|         public const string ModRightName = "SB_EquipICMOTechParamBill"; | 
|         public const string ModRightNameList = ModRightName + "List";       //列表 | 
|         public const string ModRightNameEdit = ModRightName + "_Edit";      //编辑 | 
|         public const string ModRightNameCheck = ModRightName + "_Check";    //审核 | 
|         public const string ModRightNameClose = ModRightName + "_Close";    //关闭 | 
|         public const string ModRightNameDelete = ModRightName + "_Delete";  //作废 | 
|         public const string ModRightNameDrop = ModRightName + "_Drop";      //删除 | 
|         public DataSet ds = new DataSet(); | 
|         private json objJsonResult = new json(); | 
|         SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|         public DAL.ClsSB_EquipICMOTechParamBill oBill = new DAL.ClsSB_EquipICMOTechParamBill(); | 
|         string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; | 
|   | 
|         #region 设备工艺参数订单点检表列表信息 | 
|         /// <summary> | 
|         /// 获取设备工艺参数订单点检表列表信息 | 
|         /// </summary> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBillList_Json")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBillList_Json(string sWhere, string HMaker, string OperationType, string ViewName) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (OperationType == "1") | 
|                 { | 
|                     //判断权限 | 
|                     if (!DBUtility.ClsPub.Security_Log(ModRightNameList, 3, false, HMaker)) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "您没有该模块权限,请与管理员联系!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                 } | 
|   | 
|                 //返回列表信息 | 
|                 ds = oCn.RunProcReturn("select * from " + ViewName + " where 1=1 " + sWhere + " order by hmainid desc", ViewName); | 
|                 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));  //获取到DataColumn列对象的列名 | 
|                 } | 
|                 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 设备工艺参数分页查询 | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBillList_Page")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBillList_Page(string sWhere, string user, int page, int size) | 
|         { | 
|             try | 
|             { | 
|                 List<object> columnNameList = new List<object>(); | 
|                 //编辑权限 | 
|                 if (!DBUtility.ClsPub.Security_Log_second(ModRightNameList, 3, false, user)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "无查看权限!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                 sWhere = sWhere.Replace("'", "''"); | 
|                 if (sWhere == null || sWhere.Equals("")) | 
|                 { | 
|                     ds = oCn.RunProcReturn("exec h_p_SB_EquipICMOTechParamBillListPage " + page + "," + size + ",''", "h_p_SB_EquipICMOTechParamBillListPage"); | 
|                 } | 
|                 else | 
|                 { | 
|                     ds = oCn.RunProcReturn("exec h_p_SB_EquipICMOTechParamBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_SB_EquipICMOTechParamBillListPage"); | 
|                 } | 
|   | 
|                 //添加列名 | 
|                 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));//获取到DataColumn列对象的列名 | 
|                 } | 
|   | 
|                 objJsonResult.code = "1"; | 
|                 objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); | 
|                 objJsonResult.Message = "Sucess!"; | 
|                 objJsonResult.list = columnNameList; | 
|                 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; | 
|             } | 
|         } | 
|         #endregion        | 
|   | 
|         #region 设备工艺参数订单点检表删除 | 
|         /// <summary> | 
|         /// 删除设备工艺参数订单点检表 | 
|         /// </summary> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Delete_Json")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBill_Delete_Json(Int64 HInterID, string HMaker) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (!DBUtility.ClsPub.Security_Log(ModRightNameDrop, 3, false, HMaker)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "您没有该模块删除功能权限,请与管理员联系!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //判断存在性 | 
|                 if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) | 
|                 { | 
|                     //判断会计期是否合理 | 
|                     string s = ""; | 
|                     int sYear = 0; | 
|                     int sPeriod = 0; | 
|                     if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = s; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //删除前控制 | 
|                     DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_SB_EquipICMOTechParamBill_BeforeDelCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_SB_EquipICMOTechParamBill_BeforeDelCtrl"); | 
|                     if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "删除前判断失败!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     else | 
|                     { | 
|                         if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "删除失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                     //删除单据(包含删除后控制、写入日志) | 
|                     if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_SB_EquipICMOTechParamBill_AfterDelCtrl", HMaker, ref ClsPub.sExeReturnInfo)) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "删除失败!原因:" + ClsPub.sExeReturnInfo; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     else | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 1; | 
|                         objJsonResult.Message = "删除设备工艺参数订单点检表成功!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     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 设备工艺参数订单点检表审核/反审核 | 
|         /// <summary> | 
|         /// 审核/反审核设备工艺参数订单点检表 | 
|         /// </summary> | 
|         /// <param name="HInterID">单据ID</param> | 
|         /// <param name="Type">审核(1),反审核(2)</param> | 
|         /// <param name="HMaker">审核人</param> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Check_Json")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBill_Check_Json(Int64 HInterID, int Type, string HMaker) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 3, false, HMaker)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "您没有该模块审核/反审核功能权限,请与管理员联系!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //判断存在性 | 
|                 if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) | 
|                 { | 
|                     //判断会计期是否合理 | 
|                     string s = ""; | 
|                     int sYear = 0; | 
|                     int sPeriod = 0; | 
|                     if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = s; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     //Type 1 审核  2  反审核 | 
|                     if (Type == 1) | 
|                     { | 
|                         if (oBill.omodel.HChecker.Trim() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已审核,不能再次审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         if (oBill.omodel.HCloseMan.Trim() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已关闭,不能再次审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         if (oBill.omodel.HDeleteMan.Trim() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废,不能再次审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //审核前控制 | 
|                         DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_SB_EquipICMOTechParamBill_BeforeCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_SB_EquipICMOTechParamBill_BeforeCheckCtrl"); | 
|                         if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "审核前判断失败!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) | 
|                             { | 
|                                 objJsonResult.code = "0"; | 
|                                 objJsonResult.count = 0; | 
|                                 objJsonResult.Message = "审核失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); | 
|                                 objJsonResult.data = null; | 
|                                 return objJsonResult; | 
|                             } | 
|                         } | 
|                         //审核单据 | 
|                         if (!oBill.CheckBill(HInterID, oBill.omodel.HBillNo, "h_p_SB_EquipICMOTechParamBill_AfterCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         {                             | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "单据号:"+ oBill.omodel.HBillNo+ " 审核成功!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; ; | 
|                         } | 
|                     } | 
|                     else | 
|                     { | 
|                         if (oBill.omodel.HChecker.Trim() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未审核,不需要反审核!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反审核前控制 | 
|                         DataSet BeforeDs = oCn.RunProcReturn("Exec h_p_SB_EquipICMOTechParamBill_BeforeUnCheckCtrl " + HInterID.ToString() + ",'" + HMaker + "'", "h_p_SB_EquipICMOTechParamBill_BeforeUnCheckCtrl"); | 
|                         if (BeforeDs == null || BeforeDs.Tables[0].Rows.Count == 0) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "反审核前判断失败!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             if (DBUtility.ClsPub.isLong(BeforeDs.Tables[0].Rows[0]["HBack"]) == 1) | 
|                             { | 
|                                 objJsonResult.code = "0"; | 
|                                 objJsonResult.count = 0; | 
|                                 objJsonResult.Message = "反审核失败!" + DBUtility.ClsPub.isStrNull(BeforeDs.Tables[0].Rows[0]["HRemark"]); | 
|                                 objJsonResult.data = null; | 
|                                 return objJsonResult; | 
|                             } | 
|                         } | 
|   | 
|                         //反审核单据 | 
|                         if (!oBill.AbandonCheck(HInterID, oBill.omodel.HBillNo, "h_p_SB_EquipICMOTechParamBill_AfterUnCheckCtrl", HMaker, ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "反审核失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 反审核成功!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; ; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     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 设备工艺参数订单点检表关闭/反关闭 | 
|         /// <summary> | 
|         /// 关闭/反关闭设备工艺参数订单点检表 | 
|         /// </summary> | 
|         /// <param name="HInterID">单据ID</param> | 
|         /// <param name="Type">关闭(1),反关闭(2)</param> | 
|         /// <param name="HMaker">关闭人</param> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Close_Json")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBill_Close_Json(Int64 HInterID, int Type, string HMaker) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (!DBUtility.ClsPub.Security_Log(ModRightNameClose, 3, false, HMaker)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "您没有该模块关闭/反关闭功能权限,请与管理员联系!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //判断存在性 | 
|                 if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) | 
|                 { | 
|                     //判断会计期是否合理 | 
|                     string s = ""; | 
|                     int sYear = 0; | 
|                     int sPeriod = 0; | 
|                     if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = s; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     //Type 1 关闭  2  反关闭 | 
|                     if (Type == 1) | 
|                     { | 
|                         if (oBill.omodel.HCloseMan.Trim() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已关闭,不能再次关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         string sql = ""; | 
|                         //关闭前控制===============================================Begin=================================================================== | 
|                         sql = "exec h_p_Sb_EquipICMOTechParamBill_BeforeCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + HMaker + "'"; | 
|                         ds = oCn.RunProcReturn(sql, "h_p_Sb_EquipICMOTechParamBill_BeforeCloseCtrl"); | 
|                         if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "关闭失败!原因:关闭前前判断失败,无返回信息,请与网络管理人员联系"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|   | 
|                         } | 
|                         if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //关闭前控制===============================================End=================================================================== | 
|   | 
|                         //关闭提交 | 
|                         if (oBill.CloseBill(Convert.ToInt32(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipICMOTechParamBill_AfterCloseCtrl", HMaker, ref DBUtility.ClsPub.sExeReturnInfo) == true) | 
|                         { | 
|                             objJsonResult.code = "1"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "关闭成功"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         }                        | 
|                     } | 
|                     else | 
|                     { | 
|                         if (oBill.omodel.HCloseMan.Trim() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未关闭,不需要反关闭!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|   | 
|                         string sql = ""; | 
|                         //反关闭前控制===============================================Begin=================================================================== | 
|                         sql = "exec h_p_Sb_EquipICMOTechParamBill_BeforeUnCloseCtrl " + HInterID + ",'" + oBill.omodel.HBillNo + "','" + HMaker + "'"; | 
|                         ds = oCn.RunProcReturn(sql, "h_p_Sb_EquipICMOTechParamBill_BeforeUnCloseCtrl"); | 
|                         if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "反关闭失败!原因:反关闭前前判断失败,无返回信息,请与网络管理人员联系"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|   | 
|                         } | 
|                         if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "反关闭失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反关闭前控制===============================================End=================================================================== | 
|   | 
|                         //反关闭提交 | 
|                         if (oBill.CancelClose(Convert.ToInt32(HInterID), oBill.omodel.HBillNo, "h_p_Sb_EquipICMOTechParamBill_AfterUnCloseCtrl", HMaker, ref DBUtility.ClsPub.sExeReturnInfo) == true) | 
|                         { | 
|                             objJsonResult.code = "1"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "反关闭成功"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         }                         | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     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 设备工艺参数订单点检表作废/反作废 | 
|         /// <summary> | 
|         /// 作废/反作废设备工艺参数订单点检表 | 
|         /// </summary> | 
|         /// <param name="HInterID">单据ID</param> | 
|         /// <param name="Type">作废(1),反作废(2)</param> | 
|         /// <param name="HMaker">作废人</param> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Cancelltion_Json")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBill_Cancelltion_Json(Int64 HInterID, int Type, string HMaker) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 3, false, HMaker)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "您没有该模块作废/反作废功能权限,请与管理员联系!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //判断存在性 | 
|                 if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) | 
|                 { | 
|                     //判断会计期是否合理 | 
|                     string s = ""; | 
|                     int sYear = 0; | 
|                     int sPeriod = 0; | 
|                     if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oBill.omodel.HDate, ref sYear, ref sPeriod, ref s) == false) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = s; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     //Type 1 作废  2  反作废 | 
|                     if (Type == 1) | 
|                     { | 
|                         if (oBill.omodel.HDeleteMan.Trim() != "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据已作废,不能再次作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //作废单据 | 
|                         if (!oBill.Cancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 作废成功!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; ; | 
|                         } | 
|                     } | 
|                     else | 
|                     { | 
|                         if (oBill.omodel.HDeleteMan.Trim() == "") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "单据未作废,不需要反作废!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         //反作废单据 | 
|                         if (!oBill.AbandonCancelltion(HInterID, oBill.omodel.HBillNo, HMaker, ref ClsPub.sExeReturnInfo)) | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                         else | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 1; | 
|                             objJsonResult.Message = "单据号:" + oBill.omodel.HBillNo + " 反作废成功!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; ; | 
|                         } | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     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 设备工艺参数订单点检表模块   从列表选中打开单据,返回单据信息时调用 | 
|         /// <summary> | 
|         /// 设备工艺参数订单点检表编辑时,根据单据ID获取单据信息 | 
|         /// </summary> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Json")] | 
|         [HttpGet] | 
|         public object GetSB_EquipICMOTechParamBill_Json(Int64 HInterID, string HMaker) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 3, false, HMaker)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //返回列表信息 | 
|                 ds = oCn.RunProcReturn("exec h_p_SB_EquipICMOTechParamBill_EditInit " + HInterID, "h_p_SB_EquipICMOTechParamBill_EditInit"); | 
|                 if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "未查询到该设备工艺参数订单点检表,请刷新数据后重新选择!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 1; | 
|                     objJsonResult.Message = "成功!"; | 
|                     objJsonResult.data = ds.Tables[0]; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "返回设备工艺参数订单点检表信息失败!" + e.ToString(); | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|         #endregion | 
|   | 
|         #region 设备工艺参数订单点检表保存 | 
|         /// <summary> | 
|         /// 设备工艺参数订单点检表保存 | 
|         /// </summary> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSB_EquipICMOTechParamBill_Save_Json")] | 
|         [HttpPost] | 
|         public object GetSB_EquipICMOTechParamBill_Save_Json([FromBody] JObject sMainSub) | 
|         { | 
|             var _value = sMainSub["sMainSub"].ToString(); | 
|             string msg1 = _value.ToString(); | 
|             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|             string sMainStr = sArray[0].ToString();         //主表数据 | 
|             string sSubStr = sArray[1].ToString();          //子表数据 | 
|             string OperationType = sArray[2].ToString();    //操作类型(1新增、2编辑) | 
|             string HMaker = sArray[3].ToString();           //制单人 | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (OperationType == "1") | 
|                 { | 
|                     BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; | 
|                     //判断新增权限 | 
|                     if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, false, HMaker)) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "您没有该模块新增权限,请与管理员联系!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                 } | 
|                 else | 
|                 { | 
|                     BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; | 
|                     //判断编辑权限 | 
|                     if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, false, HMaker)) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                 } | 
|                 //表头赋值 | 
|                 sMainStr = sMainStr.Replace("\\", ""); | 
|                 sMainStr = sMainStr.Replace("\n", ""); | 
|                 sMainStr = "[" + sMainStr.ToString() + "]"; | 
|                 List<Model.ClsSB_EquipICMOTechParamBillMain> lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSB_EquipICMOTechParamBillMain>>(sMainStr); | 
|                 foreach (Model.ClsSB_EquipICMOTechParamBillMain oItem in lsmain) | 
|                 { | 
|                     //单据号是否重复 | 
|                     if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID)) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = "单据号重复!不允许保存!"; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|                     //判断会计期是否合理 | 
|                     string s = ""; | 
|                     int sYear = 0; | 
|                     int sPeriod = 0; | 
|                     if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oItem.HDate, ref sYear, ref sPeriod, ref s) == false) | 
|                     { | 
|                         objJsonResult.code = "0"; | 
|                         objJsonResult.count = 0; | 
|                         objJsonResult.Message = s; | 
|                         objJsonResult.data = null; | 
|                         return objJsonResult; | 
|                     } | 
|   | 
|                     oItem.HYear = sYear; | 
|                     oItem.HPeriod = sPeriod; | 
|                     DBUtility.ClsPub.CurUserName = oItem.HMaker; | 
|                     oBill.omodel = oItem; | 
|                 } | 
|                 //表体赋值 | 
|                 //按 },{来拆分数组 //去掉【和】 | 
|                 sSubStr = sSubStr.Substring(1, sSubStr.Length - 2); | 
|                 sSubStr = sSubStr.Replace("\\", ""); | 
|                 sSubStr = sSubStr.Replace("\n", ""); | 
|                 sSubStr = "[" + sSubStr.ToString() + "]"; | 
|                 List<Model.ClsSB_EquipICMOTechParamBillSub> ls = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Model.ClsSB_EquipICMOTechParamBillSub>>(sSubStr); | 
|                 int i = 0; | 
|                 foreach (Model.ClsSB_EquipICMOTechParamBillSub oItemSub in ls) | 
|                 { | 
|                     i++; | 
|                     oItemSub.HEntryID = i; | 
|                     oItemSub.HSourceInterID = oBill.omodel.HMainSourceInterID; | 
|                     oItemSub.HSourceEntryID = oBill.omodel.HMainSourceEntryID; | 
|                     oItemSub.HSourceBillNo = oBill.omodel.HMainSourceBillNo; | 
|                     oItemSub.HSourceBillType = oBill.omodel.HMainSourceBillType; | 
|                     oBill.DetailColl.Add(oItemSub); | 
|                 } | 
|   | 
|                 //获取系统参数 | 
|                 string Ret = ""; | 
|                 if (oSystemParameter.ShowBill(ref Ret)) | 
|                 { | 
|                     if (oSystemParameter.omodel.SB_EquipICMOTechParamBill_MustBeginWorkCtl == "Y") | 
|                     { | 
|                         ds = oCn.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceID = '" + oBill.omodel.HSourceID + "' and HSourceBillNo = '" + oBill.omodel.HProcExchBillNo + "' and HSourceInterID = '" + oBill.omodel.HProcExchInterID + "'and HSourceEntryID = '" + oBill.omodel.HProcExchEntryID + "' and hicmostatus =1", "Sc_ICMOBillStatus_Tmp"); | 
|                         if (ds.Tables[0].Rows[0]["HICMOStatus"].ToString() != "1") | 
|                         { | 
|                             objJsonResult.code = "0"; | 
|                             objJsonResult.count = 0; | 
|                             objJsonResult.Message = "当前工单不是开工状态不能进行设备工艺参数点检!"; | 
|                             objJsonResult.data = null; | 
|                             return objJsonResult; | 
|                         } | 
|                     } | 
|                 } | 
|   | 
|                     //保存 | 
|                     bool bResult; | 
|                 if (OperationType == "1")   //新增保存 | 
|                 { | 
|                     bResult = oBill.AddBill (ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 } | 
|                 else                        //编辑保存 | 
|                 { | 
|                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); | 
|                 } | 
|   | 
|                 if (bResult) | 
|                 { | 
|   | 
|                     //自动审核设置 | 
|                     if (OperationType == "1") | 
|                     { | 
|                         objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID | 
|                         //系统参数  自动审核 | 
|                         string sReturn = ""; | 
|                         if (oSystemParameter.ShowBill(ref sReturn) == true) | 
|                         { | 
|                             if (oSystemParameter.omodel.SB_EquipICMOTechParamBill_Check == "Y") //系统参数  自动审核  | 
|                             { | 
|                                 objJsonResult.Verify = "Y"; | 
|                             } | 
|                             else | 
|                             { | 
|                                 objJsonResult.Verify = "N"; | 
|                             } | 
|                         } | 
|                     } | 
|                     else                    | 
|                     { | 
|                         objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID | 
|                         objJsonResult.Verify = "N"; | 
|                     } | 
|   | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 1; | 
|                     objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;  //成功! | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|                 else | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "保存失败!" + e.Message; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|         } | 
|   | 
|         #endregion | 
|   | 
|         #region 异常工艺参数预警列表信息 | 
|         /// <summary> | 
|         /// 异常工艺参数预警列表信息 | 
|         /// </summary> | 
|         /// <returns></returns> | 
|         [Route("SB_EquipICMOTechParamBillController/GetSb_EquipMentCollectionTechParam_ERR")] | 
|         [HttpGet] | 
|         public object GetSb_EquipMentCollectionTechParam_ERR(string sWhere, string HMaker) | 
|         { | 
|             try | 
|             { | 
|                 //判断权限 | 
|                 if (!DBUtility.ClsPub.Security_Log(ModRightNameList, 3, false, HMaker)) | 
|                 { | 
|                     objJsonResult.code = "0"; | 
|                     objJsonResult.count = 0; | 
|                     objJsonResult.Message = "您没有该模块权限,请与管理员联系!"; | 
|                     objJsonResult.data = null; | 
|                     return objJsonResult; | 
|                 } | 
|   | 
|                 //返回列表信息 | 
|                 ds = oCn.RunProcReturn("select * from h_v_Sb_EquipMentCollectionTechParam_ERRList where 1=1 " + sWhere + " order by 发现异常时间 desc", "h_v_Sb_EquipMentCollectionTechParam_ERRList"); | 
|                 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));  //获取到DataColumn列对象的列名 | 
|                 } | 
|                 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 设备点检记录拍照上传 | 
|         [Route("SB_EquipICMOTechParamBillController/UploadFile")] | 
|         [HttpPost] | 
|         public object 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/EquipTechParamFolder/" + HBillNo); | 
|             //string path = @"D:\\Files\\"+ 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/EquipTechParamFolder/" + 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/EquipTechParamFolder/" + 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("SB_EquipICMOTechParamBillController/Filelist")] | 
|         [HttpGet] | 
|         public object Filelist(string HBillNo) | 
|         { | 
|             var url = fileip + "/files/EquipTechParamFolder/" + 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("SB_EquipICMOTechParamBillController/DeleteFilelist")] | 
|         [HttpGet] | 
|         public object 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 | 
|   | 
|         # region 手工点检表出现NG发送信息   | 
|         [Route("SB_EquipICMOTechParamBillController/HSendDDMeg")] | 
|         [HttpGet] | 
|   | 
|         public async Task<object> HSendDDMeg(string HInterID) | 
|         { | 
|             try | 
|             { | 
|                 //查询子表是否有NG值                | 
|                 ds = oCn.RunProcReturn("select  * from SB_EquipICMOTechParamBillMain a inner join SB_EquipICMOTechParamBillSub b on a.HInterID=b.HInterID where b.HResult='NG' and a.HInterID=" + HInterID, "SB_EquipICMOTechParamBillMain"); | 
|                 if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count != 0) | 
|                 { | 
|                     //查询并合并异常工艺参数值 | 
|                     string sql = @"SELECT 生产车间,  STUFF((SELECT ', ' + CAST(hsubid AS VARCHAR(10)) FROM h_v_SB_EquipICMOTechParamBillList_Detail AS InnerTable  WHERE InnerTable.生产车间 = OuterTable.生产车间 AND InnerTable.检测结果 = 'NG' AND InnerTable.hmainid ='"+HInterID+"' FOR XML PATH('')), 1, 2, '') AS hsubid,STUFF((  SELECT '; ' + 设备编码 + ' - ' + 工艺参数 + ' - 工艺参数值: ' + CAST(工艺参数值 AS VARCHAR(10)) + ' - 标准值: ' + CAST(标准值 AS VARCHAR(10)) + ' - 上限: ' + CAST(上限 AS VARCHAR(10)) + ' - 下限: ' + CAST(下限 AS VARCHAR(10)) FROM h_v_SB_EquipICMOTechParamBillList_Detail AS InnerTable  WHERE InnerTable.生产车间 = OuterTable.生产车间  AND InnerTable.检测结果 = 'NG' FOR XML PATH('') ), 1, 2, '') AS 内容  FROM h_v_SB_EquipICMOTechParamBillList_Detail AS OuterTable where OuterTable.hmainid = '" + HInterID + "'  GROUP BY 生产车间"; | 
|                     ds = oCn.RunProcReturn(sql, "h_v_SB_EquipICMOTechParamBillList_Detail"); | 
|                     var HDeptName = ds.Tables[0].Rows[0]["生产车间"].ToString(); | 
|                     var HDescription = ds.Tables[0].Rows[0]["内容"].ToString(); | 
|                     var HSubID = ds.Tables[0].Rows[0]["hsubid"].ToString(); | 
|                     //查询接收人 | 
|                     string newSql1 = @"select a.HDingDingUserID 钉钉id,a.Czymc 接收人 from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId | 
|                                 left join System_UserGroup c on b.GroupId = c.GroupID  where c.GroupName = '" + HDeptName + "工艺异常预警接收人'"; | 
|                     DataSet dt = oCn.RunProcReturn(newSql1, "Gy_Czygl"); | 
|                     if (dt.Tables[0].Rows.Count > 0) | 
|                     { | 
|   | 
|                         string appKey = ""; | 
|                         string appSecret = ""; | 
|                         string sReturn = ""; | 
|                         string agentIds = ""; | 
|                         Cls_DDMsg msg = new Cls_DDMsg(); | 
|                         if (oSystemParameter.ShowBill(ref sReturn) == true) | 
|                         { | 
|                             //系统参数是否 N为本地,Y为斯莫尔 | 
|                             if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "N") | 
|                             { | 
|                                 appKey = "dingrsrzhdyn3mlaof95"; | 
|                                 appSecret = "RAqH6YtZnPLCpDbuqfaYQkKkVtVdS0wqfC8I26X6qiS-8eoCJCNrzx3fubGND4Sq"; | 
|                                 agentIds = "3118119317"; | 
|                             } | 
|                             else if (oSystemParameter.omodel.OA_ErrMsgBackBill_SendDingDingMsg == "Y") | 
|                             { | 
|                                 appKey = "dingkdddbhdcssk7jduw"; | 
|                                 appSecret = "iv07c-GLfJPnzfJaNAAOfJDl3Z-eODvDAhlInMZCZhGorkle5Evbaxx3ImylvdjQ"; | 
|                                 agentIds = "3151454458"; | 
|                             } | 
|   | 
|                         }                        | 
|   | 
|                         //获取企业的access_token的值 | 
|                         string response = msg.GetAccessToken(appKey, appSecret); | 
|                         JObject responseJson = JObject.Parse(response); | 
|                         // 获取access_token的值 | 
|                         string accessToken = responseJson["accessToken"].ToString(); | 
|   | 
|   | 
|                         string HName = "";  // 用于存储拼接后的钉钉ID | 
|                         List<string> dingDingIds = new List<string>();  // 用来存储钉钉ID的集合 | 
|   | 
|                         // 拼接钉钉ID | 
|                         for (int i = 0; i < dt.Tables[0].Rows.Count; i++) | 
|                         {                         | 
|                             dingDingIds.Add(dt.Tables[0].Rows[i]["钉钉id"].ToString());  // 将每个钉钉ID添加到列表中 | 
|                         } | 
|   | 
|                         // 使用逗号将钉钉ID拼接成一个字符串 | 
|                         HName = string.Join(",", dingDingIds); | 
|                         //更新为NG的子表字段 未  已发送 1 | 
|                         oCn.RunProc("update SB_EquipICMOTechParamBillSub set HSendFlag =1 where HInterID='" + HInterID + "' and HEntryID in(" + HSubID + ")"); | 
|                         response = await msg.SendTextMessage(accessToken, agentIds, HName, "0", "false", HDescription); | 
|                         return response;                        | 
|                     }                    | 
|                 } | 
|   | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 1; | 
|                 objJsonResult.Message = "无NG工艺参数!"; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|   | 
|             } | 
|             catch (Exception e) | 
|             { | 
|                 objJsonResult.code = "0"; | 
|                 objJsonResult.count = 0; | 
|                 objJsonResult.Message = "发送失败!" + e.Message; | 
|                 objJsonResult.data = null; | 
|                 return objJsonResult; | 
|             } | 
|   | 
|         } | 
|         #endregion | 
|     } | 
| } |