|  |  | 
 |  |  | using Newtonsoft.Json.Linq; | 
 |  |  | using Newtonsoft.Json; | 
 |  |  | using Newtonsoft.Json.Linq; | 
 |  |  | using Pub_Class; | 
 |  |  | using System; | 
 |  |  | using System.Collections; | 
 |  |  | 
 |  |  |         #region 返回委外工序接收单列表 | 
 |  |  |         [Route("Cj_StationEntrustOutBill/list")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object list(string sWhere) | 
 |  |  |         public object list(string sWhere,string user) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 List<object> columnNameList = new List<object>(); | 
 |  |  |                 //判断是否有查询权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Query", 1, false, user)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "无查询权限!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (sWhere == null || sWhere.Equals("")) | 
 |  |  |                 { | 
 |  |  |                     ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustOutBillList " + sWhere+ " order by 接收时间 desc", "h_v_MES_StationEntrustOutBillList"); | 
 |  |  |                     ds = oCN.RunProcReturn("select * from h_v_MES_StationEntrustOutBillList ", "h_v_MES_StationEntrustOutBillList"); | 
 |  |  |                     //order by hmainid desc 排序丢到数据库里进行处理 | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     string sql1 = "select * from h_v_MES_StationEntrustOutBillList where 1 = 1 "; | 
 |  |  |                     string sql = sql1 + sWhere; | 
 |  |  |                     string sql = sql1 + sWhere+ " order by hmainid desc"; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_v_MES_StationEntrustOutBillList"); | 
 |  |  |                 } | 
 |  |  |                 if (ds == null || ds.Tables[0].Rows.Count == 0) | 
 |  |  |  | 
 |  |  |                 //添加列名 | 
 |  |  |                 foreach (DataColumn col in ds.Tables[0].Columns) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "false!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                     Type dataType = col.DataType; | 
 |  |  |                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "1"; | 
 |  |  |                     objJsonResult.count = 1; | 
 |  |  |                     objJsonResult.Message = "Sucess!"; | 
 |  |  |                     objJsonResult.data = ds.Tables[0]; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |                 //if (ds.Tables[0].Rows.Count != 0 || ds != null) | 
 |  |  |                 //{ | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = "Sucess!"; | 
 |  |  |                 objJsonResult.list = columnNameList; | 
 |  |  |                 objJsonResult.data = ds.Tables[0]; | 
 |  |  |                 return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |                 //else | 
 |  |  |                 //{ | 
 |  |  |                 //objJsonResult.code = "0"; | 
 |  |  |                 //objJsonResult.count = 0; | 
 |  |  |                 //objJsonResult.Message = "无数据"; | 
 |  |  |                 //objJsonResult.data = null; | 
 |  |  |                 //return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  | 
 |  |  |         { | 
 |  |  |             var _value = oMain["oMain"].ToString(); | 
 |  |  |             string msg1 = _value.ToString(); | 
 |  |  |             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //部门基础资料反序列化 | 
 |  |  |                 msg1 = "[" + msg1.ToString() + "]"; | 
 |  |  |                 List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1); | 
 |  |  |                string msg2 = "[" + sArray[0].ToString() + "]"; | 
 |  |  |                 string user = sArray[1].ToString(); | 
 |  |  |  | 
 |  |  |                 //判断是否有编辑权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Edit", 1, false, user)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "无编辑权限!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2); | 
 |  |  |                 long HMainInterID = 0; | 
 |  |  |                 HMainInterID = list[0].HMainInterID; | 
 |  |  |                 string eventType = list[0].eventType; | 
 |  |  |                 long HInterID = list[0].HInterID;//递入type得到的单据ID | 
 |  |  |                 int HYear = 2021; | 
 |  |  | 
 |  |  |                 double HMoney = list[0].HMoney;//金额 | 
 |  |  |                 string HRemark = list[0].HRemark;//备注 | 
 |  |  |                 double HTaxRate = list[0].HTaxRate;//税率 | 
 |  |  |                 long HProcNo = list[0].HProcNo;//流水号 | 
 |  |  |                 string HProcNo = list[0].HProcNo;//流水号 | 
 |  |  |                 string HOrderProcNO = list[0].HOrderProcNO;//订单跟踪号 | 
 |  |  |                 int HWWWorkOrderInterID = 0;//委外工单号子内码 | 
 |  |  |                 int HWWWorkOrderEntryID = 0;//委外工单号主内吗 | 
 |  |  | 
 |  |  |                 double HMainSourceInterID = 0; | 
 |  |  |                 string HMainSourceBillNo = ""; | 
 |  |  |                 string HMainSourceBillType = "3792"; | 
 |  |  |                 long HPRDOrgID = list[0].HPRDOrgID;//组织ID | 
 |  |  |                 if (HProcExchInterID <= 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 if (HProcNo <= 0) | 
 |  |  |                 if (HProcNo == "") | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                     ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + | 
 |  |  |                     ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID" + | 
 |  |  |                     ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + | 
 |  |  |                     ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPrice_BHS,HMoney_BHS,HBadCount" + | 
 |  |  |                     ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HProcNo,HOrderProcNO,HLastSubProc,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID" + | 
 |  |  |                     ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPrice_BHS,HMoney_BHS,HBadCount" +               ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HProcNo,HOrderProcNO,HLastSubProc,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID,HMainInterID,HPRDOrgID" + | 
 |  |  |                     ") " + | 
 |  |  |                     " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate()" + | 
 |  |  |                     "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HInnerBillNo + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL + | 
 |  |  | 
 |  |  |                     ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + | 
 |  |  |                     "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + | 
 |  |  |                     "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPrice_BHS + "," + HMoney_BHS + "," + HBadCount + | 
 |  |  |                     "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + HProcNo + ",'" + HOrderProcNO + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + ",'" + HWWWorkOrderBillNo + "'," + HWWWorkOrderInterID + "," + HWWWorkOrderEntryID + | 
 |  |  |                     "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + HProcNo + ",'" + HOrderProcNO + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + ",'" + HWWWorkOrderBillNo + "'," + HWWWorkOrderInterID + "," + HWWWorkOrderEntryID + "," + HMainInterID + "," + HPRDOrgID + | 
 |  |  |                     ") "); | 
 |  |  |                 } | 
 |  |  |                 else if ("Modify".Equals(eventType)) | 
 |  |  | 
 |  |  |                     ",HUpDater='" + HMaker + "'" + | 
 |  |  |                     ",HUpDateDate=getdate()" + | 
 |  |  |                     ",HInnerBillNo='" + HInnerBillNo + "'" + | 
 |  |  |                     ",HWWWorkOrderBillNo='" + HWWWorkOrderBillNo + "'" + | 
 |  |  |                     ",HSupID=" + HSupID + | 
 |  |  |                     ",HEmpID=" + HEmpID + | 
 |  |  |                     ",HQty=" + HQty + | 
 |  |  |                     ",HPieceQty=" + HPieceQty + | 
 |  |  |                     ",HPrice=" + HPrice + | 
 |  |  | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") | 
 |  |  |                 { | 
 |  |  |                     oCN.RollBack(); | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 //if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") | 
 |  |  |                 //{ | 
 |  |  |                 //    oCN.RollBack(); | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |                 oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Out " + HInterID.ToString() + ",1"); | 
 |  |  |                 oCN.RunProc("exec h_p_WW_EntrustWorkOrderRelationQty_Out " + HInterID.ToString() + ",1"); | 
 |  |  |                 oCN.Commit(); | 
 |  |  | 
 |  |  |             { | 
 |  |  |  | 
 |  |  |                 //编辑权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Delete", 1, true, HDeleteMan)) | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log("MES_StationEntrustOutBill_Delete", 1, false, HDeleteMan)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //判断权限 | 
 |  |  |                 if (!ClsPub.Security_Log("MES_StationEntrustOutBill_Edit", 1, true, CurUserName)) | 
 |  |  |                 if (!ClsPub.Security_Log("MES_StationEntrustOutBill_Edit", 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 //string ModRightNameCheck = "MES_StationEntrustOutBill_Check"; | 
 |  |  |                 ////审核权限 | 
 |  |  |                 //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) | 
 |  |  |                 //{ | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = "审核失败!无权限!"; | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |                 string ModRightNameCheck = "MES_StationEntrustOutBill_Check"; | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "审核失败!无权限!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |                 if (HInterID == 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 string ModRightNameCheck = "MES_StationEntrustOutBill_Check"; | 
 |  |  |                 //审核权限 | 
 |  |  |                 if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  |                     objJsonResult.count = 0; | 
 |  |  |                     objJsonResult.Message = "反审核失败!无权限!"; | 
 |  |  |                     objJsonResult.data = null; | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 if (HInterID == 0) | 
 |  |  |                 { | 
 |  |  |                     objJsonResult.code = "0"; | 
 |  |  | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |         // | 
 |  |  |  | 
 |  |  |         //批量 | 
 |  |  |         #region 批量委外接收模块返回明细信息列表 | 
 |  |  |         [Route("Cj_StationEntrustOutBill/get_BarCodeDetail")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object get_BarCodeDetail(string HMainInterID) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 ds = oCN.RunProcReturn( | 
 |  |  |                     "select a.HBillNo,a.HInterID,a.HQty,a.HProcExchBillNo,a.HICMOBillNo" + | 
 |  |  |                     ",b.HNumber HMaterNumber,b.HName HMaterName,b.HModel HMaterModel,c.HName HSourceName,d.HName HGroupName" + | 
 |  |  |                     ",e.HName HEmpName,a.HMaker,a.HMakeDate " + | 
 |  |  |                     " from Sc_StationOutBillMain a " + | 
 |  |  |                     " left join Gy_Material b on a.HMaterID = b.HItemID " + | 
 |  |  |                     " left join Gy_Source c on a.HSourceID = c.HItemID " + | 
 |  |  |                     " left join Gy_Group d on a.HGroupID = d.HItemID " + | 
 |  |  |                     " left join Gy_Employee e on a.HEmpID = e.HItemID " + | 
 |  |  |                     " where HMainInterID = " + HMainInterID + " order by a.HMakeDate desc", "Sc_StationOutBillMain"); | 
 |  |  |                 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 = "1"; | 
 |  |  |                     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 | 
 |  |  |     } | 
 |  |  | } |