| | |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Diagnostics; |
| | | using System.IO; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using System.Windows.Forms; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers |
| | |
| | | { |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | |
| | | public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | |
| | | //反序列化 |
| | | string msg2 = "[" + sArray[0].ToString() + "]"; |
| | | string user = sArray[1].ToString();//用户名 |
| | | string OperationType = sArray[2].ToString();//类型 |
| | | string HComputerName = SystemInformation.ComputerName; //设备名称 |
| | | |
| | | //判断是否有编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user)) |
| | | if (OperationType == "5") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无编辑权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | //判断是否有编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "完工单无编辑权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else { |
| | | //判断是否有编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单无编辑权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | Stopwatch sw = new Stopwatch(); |
| | | sw.Start();//开始计时 |
| | | |
| | | List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg2); |
| | | long HMainInterID = 0; |
| | |
| | | int HBillStatus = 0; |
| | | string HMaker = user;//制单人 |
| | | string HMouldNum = list[0].HMouldNum;//模穴号 |
| | | int HYear = 2021; |
| | | double HPeriod = 1; |
| | | int HYear = DateTime.Now.Year; |
| | | double HPeriod = DateTime.Now.Month; |
| | | string HRemark = list[0].HRemark;//备注 |
| | | string HSourceName = list[0].HSourceName;//生产资源名称 |
| | | double HPieceQty = list[0].HPieceQty;//进站PCS数 |
| | |
| | | double HWorkTimes = list[0].HWorkTimes;//工时 |
| | | long HQCCheckID = list[0].HQCCheckID;//检验员ID |
| | | long HPRDOrgID = list[0].HPRDOrgID;//组织ID |
| | | double HmaterOutqty = list[0].HmaterOutqty;//白坯发布 |
| | | double HProcPriceRate = list[0].HProcPriceRate;//工价系数 |
| | | int HTemporaryAreaID = list[0].HTemporaryAreaID;//暂放区 |
| | | |
| | | LogService.Write($"1.字段赋值,用时" + sw.Elapsed ); |
| | | |
| | | //单据完整性判断 |
| | | if (HProcExchInterID <= 0) |
| | | { |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //if (HEmpID == 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "操作员没有选择!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | //if (HQCCheckID == 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | if (HSourceID == 0) |
| | | |
| | | //获取系统参数 |
| | | string Ret = ""; |
| | | if (oSystemParameter.ShowBill(ref Ret)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "生产资源没有选择!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | //判断客户不为龙山汽配 |
| | | if (oSystemParameter.omodel.WMS_CampanyName != "龙山汽配"&& oSystemParameter.omodel.WMS_CampanyName != "瑞与祺") //系统参数 |
| | | { |
| | | if (HSourceID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "生产资源没有选择!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //判断客户为龙山汽配 |
| | | else if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") |
| | | { |
| | | //判断是否为多工位 |
| | | ds = oCN.RunProcReturn("select * from h_v_GetStationOutBill_Detail where 工序ID = " + HProcID + " and 物料ID = " + HMaterID + " and 流转卡号 = '" + HProcExchBillNo + "'", "h_v_GetStationOutBill_Detail"); |
| | | if (ds != null && ds.Tables[0].Rows.Count <= 1) |
| | | { |
| | | if (HEmpID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "操作员没有选择!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | //判断客户为瑞与祺 |
| | | else if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺") |
| | | { |
| | | if (HEmpID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "操作员没有选择!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //if (HCenterID == 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | //LogService.Write($"2.条件判断,用时" + sw.Elapsed); |
| | | |
| | | var num = 0; |
| | | //LogService.Write($"3.事务开始,用时" + sw.Elapsed); |
| | | |
| | | //若MAINDI重复则重新获取 |
| | | oCN.BeginTran(); |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | LogService.Write($"3.1,用时" + sw.Elapsed); |
| | | oCN.RunProc("Insert Into Sc_StationOutBillMain " + |
| | | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" + |
| | | ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" + |
| | |
| | | ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" + |
| | | ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" + |
| | | ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" + |
| | | ",HmaterOutqty,HProcPriceRate,HTemporaryAreaID" + |
| | | ") " + |
| | | " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + |
| | | " values('" + BillType + "','" + (OperationType == "5" ? "SUB" : HBillSubType) + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + |
| | | "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL + |
| | | "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + |
| | | ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID + |
| | |
| | | "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" + |
| | | "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + |
| | | "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID + |
| | | ") "); |
| | | ","+ HmaterOutqty + "," + HProcPriceRate + ","+ HTemporaryAreaID + ") "); |
| | | |
| | | LogService.Write($"4.新增结束,用时" + sw.Elapsed); |
| | | LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",新增工序出站单据:" + HBillNo); |
| | | oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "新增工序出站单据:" + HBillNo + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','新增单据'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else if ("Modify".Equals(eventType)) |
| | | { |
| | |
| | | ",HQty=" + HQty + |
| | | ",HDSQty=" + HDSQty + |
| | | ",HChongQty=" + HChongQty + |
| | | ",HTemporaryAreaID=" + HTemporaryAreaID + |
| | | ",HMouldNum='" + HMouldNum + "'" + |
| | | ",HSourceNameList='" + HSourceNameList + "'" + |
| | | ",HWasterQty=" + HWasterQty + |
| | | ",HLastSubProc=" + Convert.ToString(HLastSubProc ? 1 : 0) + |
| | | " where HInterID=" + HInterID); |
| | | |
| | | LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",修改工序出站单据:" + HBillNo); |
| | | oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "修改工序出站单据:" + HBillNo + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','修改单据'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | //主表 |
| | | |
| | | //LogService.Write($"5.系统控制查询判断,用时" + sw.Elapsed); |
| | | ds = oCN.RunProcReturn("exec h_p_MES_StationOutBill_QtyCtrl " + HInterID + "", "h_p_MES_StationOutBill_QtyCtrl"); |
| | | if (ds == null) |
| | | { |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //LogService.Write($"5.1,用时" + sw.Elapsed); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //LogService.Write($"5.2,用时" + sw.Elapsed); |
| | | if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") |
| | | { |
| | | oCN.RollBack(); |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //LogService.Write($"6.判断结束,用时" + sw.Elapsed); |
| | | oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Out " + HInterID + ","+ num + ""); |
| | | //LogService.Write($"6.1,用时" + sw.Elapsed); |
| | | oCN.RunProc("exec h_p_Mes_ProcessExchangeChangeStatus " + HInterID + " "); |
| | | //LogService.Write($"6.2,用时" + sw.Elapsed); |
| | | oCN.RunProc("exec h_p_Mes_StationOutBillBackBarCode " + HInterID + " "); |
| | | //LogService.Write($"7.存储过程结束,用时" + sw.Elapsed); |
| | | //判断是否是 末道工序 |
| | | ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a " + |
| | | " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID " + |
| | |
| | | //判断末道 生产汇报汇报 是否勾选 |
| | | if (oSystemParameter.omodel.MES_StationOutBill_LastAutoICMOReport == "Y") //系统参数 |
| | | { |
| | | //LogService.Write($"7.1,用时" + sw.Elapsed); |
| | | //同步生产汇报单 |
| | | objJsonResult= (json)SaveICMOReportBill(HInterID.ToString(), user, HBillNo, HPRDOrgID.ToString()); |
| | | objJsonResult = (json)SaveICMOReportBill(HInterID.ToString(), user, HBillNo, HPRDOrgID.ToString()); |
| | | //LogService.Write($"7.2,用时" + sw.Elapsed); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //LogService.Write($"8.生产汇报结束,用时" + sw.Elapsed); |
| | | } |
| | | //判断末道 生产入库 是否勾选 |
| | | else if (oSystemParameter.omodel.MES_StationOutBill_AutoStockIn == "Y") //系统参数 |
| | | { |
| | | //LogService.Write($"8.1,用时" + sw.Elapsed); |
| | | //同步生产入库单 |
| | | objJsonResult=(json)SaveProcdutInBill(HBillNo); |
| | | objJsonResult =(json)SaveProcdutInBill(HBillNo); |
| | | //LogService.Write($"8.2,用时" + sw.Elapsed); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //LogService.Write($"9.生产入库结束,用时" + sw.Elapsed); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //LogService.Write($"10.事务结束,用时" + sw.Elapsed); |
| | | oCN.Commit(); |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.MES_StationOutBill_SaveAutoAddnew == "Y") //系统参数 页面保存自动变成新增状态 |
| | | { |
| | | objJsonResult.Verify = "Y"; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | } |
| | | sw.Stop();//结束计时 |
| | | LogService.Write($"11.参数查询结束,新增结束,用时" + sw.Elapsed); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "新增单据成功!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 批量新增单据-保存按钮 |
| | | [Route("Cj_StationOutBill/BatchAddBill")] |
| | | [HttpPost] |
| | | public object BatchAddBill([FromBody] JObject oMain) |
| | | { |
| | | var _value = oMain["oMain"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | try |
| | | { |
| | | //反序列化 |
| | | string msg2 = "[" + sArray[0].ToString() + "]"; //表头 |
| | | string user = sArray[1].ToString();//用户名 |
| | | string msg3 = sArray[2].ToString(); //表体 |
| | | Int64 OperationType = Convert.ToInt64(sArray[3]); //操作类型 |
| | | |
| | | //判断是否有编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_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); |
| | | List<StationBill> listSub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg3); |
| | | |
| | | oCN.BeginTran(); |
| | | for (int i = 0;i < listSub.Count; i++) |
| | | { |
| | | long HMainInterID = 0; |
| | | HMainInterID = list[0].HMainInterID; |
| | | string eventType = list[0].eventType; |
| | | string BillType = "3791"; |
| | | string HBillSubType = "3791"; |
| | | long HInterID = listSub[i].HInterID;//递入type得到的单据ID |
| | | string HBillNo = listSub[i].HBillNo;//递入type得到的单据号 |
| | | int HBillStatus = 0; |
| | | string HMaker = user;//制单人 |
| | | string HMouldNum = list[0].HMouldNum;//模穴号 |
| | | int HYear = DateTime.Now.Year; |
| | | double HPeriod = DateTime.Now.Month; |
| | | string HRemark = list[0].HRemark;//备注 |
| | | string HSourceName = listSub[i].HSourceName;//生产资源名称 |
| | | double HPieceQty = list[0].HPieceQty;//进站PCS数 |
| | | double HWasterQty = listSub[i].HWasterQty;//报废数量 |
| | | double HPlanPieceQty = list[0].HPlanPieceQty;//进站PNL数 |
| | | double HBadPNL = list[0].HBadPNL;//报废PNL数 |
| | | long HICMOInterID = listSub[i].HICMOInterID;//任务单ID |
| | | string HICMOBillNo = listSub[i].HICMOBillNo;//任务单 |
| | | int HProcPlanInterID = 0; |
| | | int HProcPlanEntryID = 0; |
| | | string HProcPlanBillNo = ""; |
| | | long HProcExchInterID = listSub[i].lngBillKey; |
| | | long HProcExchEntryID = listSub[i].lngBillSubKey; |
| | | string HProcExchBillNo = listSub[i].HProcExchBillNo;//流转卡 |
| | | long HMaterID = listSub[i].HMaterID;//产品ID |
| | | long HProcID = listSub[i].HProcID;//当前工序ID |
| | | double HICMOQty = listSub[i].HICMOQty;//任务单数量 |
| | | double HPlanQty = list[0].HPlanQty;//移交PNL数 |
| | | DateTime HStationOutTime = list[0].HStationOutTime;//汇报时间 |
| | | long HSourceID = listSub[i].HSourceID;//生产资源ID |
| | | long HPayProcID = list[0].HPayProcID;//核算工序ID |
| | | long HGroupID = list[0].HGroupID;//班组ID |
| | | long HDeptID = 0; |
| | | long HEmpID = listSub[i].HEmpID;//操作员ID |
| | | string HBarCode = list[0].HBarCode;//条形码 |
| | | string HAddr = ""; |
| | | string HBarCodeMaker = ""; |
| | | long HSourceID2 = list[0].HSourceID2;//生产资源2ID |
| | | long HSourceID3 = list[0].HSourceID3;//生产资源3ID |
| | | long HSourceID4 = list[0].HSourceID4;//生产资源4ID |
| | | long HSourceID5 = list[0].HSourceID5;//生产资源5ID |
| | | long HSupID = 0; |
| | | double HQty = listSub[i].HQty;//合格数量 |
| | | double HPrice = 0; |
| | | double HMoney = 0; |
| | | double HBadCount = list[0].HBadCount;//不良数量 |
| | | long HCenterID = listSub[0].HCenterID;//工作中心ID |
| | | string HProcNo = listSub[i].HProcNo;//流水号 |
| | | string HOrderProcNO = list[0].HOrderProcNO;//订单跟踪号 |
| | | string HSourceNameList = list[0].HSourceNameList;//设备清单 |
| | | long HMainSourceInterID = list[0].HInterID;//递入type得到的单据ID |
| | | string HMainSourceBillNo = list[0].HBillNo;//递入type得到的单据号 |
| | | string HMainSourceBillType = "3790"; |
| | | bool HLastSubProc = list[0].HLastSubProc;//转下工序 |
| | | long HEmpID2 = list[0].HEmpID2;//操作员2ID |
| | | long HEmpID3 = list[0].HEmpID3;//操作员3ID |
| | | long HEmpID4 = list[0].HEmpID4;//操作员4ID |
| | | long HEmpID5 = list[0].HEmpID5;//操作员5ID |
| | | double HDSQty = list[0].HDSQty;//折弯刀数 |
| | | double HChongQty = list[0].HChongQty;//NCT冲次数 |
| | | double HPriceRate = list[0].HPriceRate;//系数 |
| | | double HWorkTimes = list[0].HWorkTimes;//工时 |
| | | long HQCCheckID = list[0].HQCCheckID;//检验员ID |
| | | long HPRDOrgID = list[0].HPRDOrgID;//组织ID |
| | | |
| | | var num = 0; |
| | | |
| | | //若MAINDI重复则重新获取 |
| | | if (OperationType == 1)//新增 |
| | | { |
| | | num = 1; |
| | | if (!AllowbillNo(HBillNo)) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据号重复!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.RunProc("Insert Into Sc_StationOutBillMain " + |
| | | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate,HMouldNum" + |
| | | ",HYear,HPeriod,HRemark,HSourceName,HPieceQty,HWasterQty,HPlanPieceQty,HBadPNL" + |
| | | ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + |
| | | ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationOutTime,HSourceID,HPayProcID" + |
| | | ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate,HSourceID2,HSourceID3,HSourceID4,HSourceID5" + |
| | | ",HSupID,HQty,HPrice,HMoney,HBadCount,HCenterID,HProcNo,HOrderProcNO,HSourceNameList" + |
| | | ",HMainSourceInterID,HMainSourceBillNo,HMainSourceBillType,HLastSubProc" + |
| | | ",HEmpID2,HEmpID3,HEmpID4,HEmpID5,HDSQty,HChongQty,HPriceRate,HWorkTimes,HQCCheckID,HMainInterID,HPRDOrgID" + |
| | | ") " + |
| | | " values('" + BillType + "','" + HBillSubType + "'," + HInterID + ",'" + HBillNo + "'," + HBillStatus + ",getdate(),'" + HMaker + "',getdate(),'" + HMouldNum + "'" + |
| | | "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HSourceName + "'," + HPieceQty + "," + HWasterQty + "," + HPlanPieceQty + "," + HBadPNL + |
| | | "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + |
| | | ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + "," + HPayProcID + |
| | | "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + "," + HSourceID2 + "," + HSourceID3 + "," + HSourceID4 + "," + HSourceID5 + |
| | | "," + HSupID + "," + HQty + "," + HPrice + "," + HMoney + "," + HBadCount + "," + HCenterID + "," + HProcNo + ",'" + HOrderProcNO + "'" + ",'" + HSourceNameList + "'" + |
| | | "," + HMainSourceInterID + ",'" + HMainSourceBillNo + "','" + HMainSourceBillType + "'," + Convert.ToString(HLastSubProc ? 1 : 0) + |
| | | "," + HEmpID2 + "," + HEmpID3 + "," + HEmpID4 + "," + HEmpID5 + "," + HDSQty + "," + HChongQty + "," + HPriceRate + "," + HWorkTimes + "," + HQCCheckID + "," + HMainInterID + "," + HPRDOrgID + |
| | | ") "); |
| | | } |
| | | else |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "操作类型无效!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //主表 |
| | | |
| | | ds = oCN.RunProcReturn("exec h_p_MES_StationOutBill_QtyCtrl " + HInterID + "", "h_p_MES_StationOutBill_QtyCtrl"); |
| | | if (ds == null) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "判断数量失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "判断数量失败!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) == "2") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "数量控制," + ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_Out " + HInterID + "," + num + ""); |
| | | oCN.RunProc("exec h_p_Mes_ProcessExchangeChangeStatus " + HInterID + " "); |
| | | oCN.RunProc("exec h_p_Mes_StationOutBillBackBarCode " + HInterID + " "); |
| | | //判断是否是 末道工序 |
| | | ds1 = oCN.RunProcReturn(" select HLastProc,HFstProc from Sc_ProcessExchangeBillMain a " + |
| | | " inner join Sc_ProcessExchangeBillSub b on a.HInterID=b.HInterID " + |
| | | " Where a.HInterID=" + HProcExchInterID + " and b.HEntryID=" + HProcExchEntryID + " ", "Sc_ProcessExchangeBillMain"); |
| | | //判断是否是新增 |
| | | if (OperationType == 1) |
| | | { |
| | | //判断是否是末道工序 |
| | | if (ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HLastProc"]) == "是") |
| | | { |
| | | //获取系统参数 |
| | | string Return = ""; |
| | | if (oSystemParameter.ShowBill(ref Return)) |
| | | { |
| | | //判断末道 生产汇报汇报 是否勾选 |
| | | if (oSystemParameter.omodel.MES_StationOutBill_LastAutoICMOReport == "Y") //系统参数 |
| | | { |
| | | //同步生产汇报单 |
| | | objJsonResult = (json)SaveICMOReportBill(HInterID.ToString(), user, HBillNo, HPRDOrgID.ToString()); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //判断末道 生产入库 是否勾选 |
| | | else if (oSystemParameter.omodel.MES_StationOutBill_AutoStockIn == "Y") //系统参数 |
| | | { |
| | | //同步生产入库单 |
| | | objJsonResult = (json)SaveProcdutInBill(HBillNo); |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 末道工序 生产汇报 |
| | | public object SaveICMOReportBill(string InterID, string user, string BillNo, string OrganizationID) |
| | |
| | | //递入物料信息 返回未完全汇报的流转卡 |
| | | [Route("LEMS/Sc_StationOutBill_Mul_RYQ")] |
| | | [HttpGet] |
| | | public object Sc_StationOutBill_Mul_RYQ(String HMaterName, Int64 HOrgID) |
| | | public object Sc_StationOutBill_Mul_RYQ(String HMaterName,string HProcNumber, Int64 HOrgID) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds = oCN.RunProcReturn("exec h_p_CJGXPLHB_Query '" + HMaterName + "'," + HOrgID + "", "h_p_CJGXPLHB_Query"); |
| | | DataSet ds = oCN.RunProcReturn("exec h_p_CJGXPLHB_Query '" + HMaterName + "'," + HOrgID + ",'"+ HProcNumber + "'", "h_p_CJGXPLHB_Query"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | |
| | | #region 返回工序出站汇报单列表 |
| | | [Route("Cj_StationOutBill/get_Display")] |
| | | [HttpGet] |
| | | public object get_Display(string sWhere,string user) |
| | | public object get_Display(string sWhere,string user,string HBillSubType) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user)) |
| | | if (HBillSubType == "SUB") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查询权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "完工单无查询权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else { |
| | | //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单无查询权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | //获取系统参数 |
| | | string Ret = ""; |
| | | if (oSystemParameter.ShowBill(ref Ret)) |
| | | { |
| | | //判断客户为龙山汽配 |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") |
| | | { |
| | | //获取需要拼接的字符串 |
| | | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序汇报单列表"); |
| | | |
| | | if (sql_splice == "没有查询到相关用户信息") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有查询到相关用户信息!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | sWhere += sql_splice; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList order by hmainid desc", "h_v_MES_StationOutBillList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_MES_StationOutBillList where 1 = 1" + sWhere + "order by hmainid desc", "h_v_MES_StationOutBillList"); |
| | | } |
| | | else |
| | | { |
| | |
| | | #region 根据id删除出站单 |
| | | [Route("Cj_StationOutBill/del_StationOutBill")] |
| | | [HttpGet] |
| | | public object del_StationOutBill(long HInterID, string HDeleteMan) |
| | | public object del_StationOutBill(long HInterID, string HDeleteMan,string HBillSubType) |
| | | { |
| | | try |
| | | { |
| | | |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Drop", 1, false, HDeleteMan)) |
| | | string HComputerName = SystemInformation.ComputerName; //设备名称 |
| | | if (HBillSubType == "SUB") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); |
| | | if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | if (oBill.omodel.HMaker != HDeleteMan && (HDeleteMan != "admin" && HDeleteMan != "Admin")) |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Drop", 1, false, HDeleteMan)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "只能删除本人的单据!"; |
| | | objJsonResult.Message = "完工单无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else { |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Drop", 1, false, HDeleteMan)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); |
| | | if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn)) |
| | | { |
| | | if (oSystemParameter.omodel.MES_StationOutBill_DeleteCtl == "Y") |
| | | { |
| | | if (oBill.omodel.HMaker != HDeleteMan && (HDeleteMan != "admin" && HDeleteMan != "Admin")) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "只能删除本人的单据!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //写入删除日志 |
| | | string WorkList = "删除出站单:" + oBill.omodel.HBillNo; |
| | | if (!oBill.DeleteBill(oBill.omodel.HInterID, oBill.omodel.HProcExchInterID, oBill.omodel.HProcExchEntryID, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | } |
| | | else |
| | | { |
| | | //写入删除日志 |
| | | LogService.Write("用户:" + HDeleteMan + ",日期:" + DateTime.Now + ",删除工序出站单据:" + oBill.omodel.HBillNo); |
| | | oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + HDeleteMan + "','" + HComputerName + "','" + "删除工序出站单据:" + oBill.omodel.HBillNo + "','LMES-工序出站模块','" + DBUtility.ClsPub.IPAddress + "','删除单据'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "删除成功!"; |
| | |
| | | #region 审核 |
| | | [Route("Cj_StationOutBill/set_CheckBill")] |
| | | [HttpGet] |
| | | public object set_CheckBill(int HInterID, string CurUserName) |
| | | public object set_CheckBill(string HInterID, string CurUserName,string HBillSubType) |
| | | { |
| | | try |
| | | { |
| | | string ModRightNameCheck = "Cj_StationOutBill_Check"; |
| | | ////审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) |
| | | if (HBillSubType == "SUB") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (HInterID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据ID为0,不能审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); |
| | | //查看是否已审核,关闭,作废 |
| | | if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() != "") |
| | | ////审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Check", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已审核!不能再次审核"; |
| | | objJsonResult.Message = "完工单审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | { ////审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Check", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //审核 |
| | | if (Cj_StationOutBillCheckBill(HInterID, CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | |
| | | |
| | | var HBillNo = HInterID.Split(','); |
| | | DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); |
| | | |
| | | for (int i = 0; i < HBillNo.Length; i++) |
| | | { |
| | | 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; |
| | | if (HBillNo[i] == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第"+(i+1)+"行:单据ID为0,不能审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //查看是否已审核,关闭,作废 |
| | | if (oBill.ShowBill(long.Parse(HBillNo[i]), ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + (i + 1) + "行:单据已审核!不能再次审核"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + (i + 1) + "行:单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | int j = 0; |
| | | for (int i = 0; i < HBillNo.Length; i++) |
| | | { |
| | | //审核 |
| | | if (Cj_StationOutBillCheckBill(long.Parse(HBillNo[i]), CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | j += 1; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "成功:" + j + "行,第" + (i + 1) + "行:审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "全部执行成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | #region 反审核 |
| | | [Route("Cj_StationOutBill/set_AbandonCheck")] |
| | | [HttpGet] |
| | | public object set_AbandonCheck(int HInterID, string CurUserName) |
| | | public object set_AbandonCheck(string HInterID, string CurUserName,string HBillSubType) |
| | | { |
| | | try |
| | | { |
| | | string ModRightNameCheck = "Cj_StationOutBill_Check"; |
| | | ////审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) |
| | | if (HBillSubType == "SUB") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (HInterID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据ID为0,不能反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); |
| | | //查看是否已审核,关闭,作废 |
| | | if (oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() == "") |
| | | ////审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Check", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据未审核!不需要反审核!"; |
| | | objJsonResult.Message = "完工单反审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | ////审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Check", 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单反审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //反审核 |
| | | if (Cj_StationOutBillAbandonCheckBill(HInterID, CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | |
| | | |
| | | var HBillNo = HInterID.Split(','); |
| | | DAL.ClsSc_StationOutBill oBill = new DAL.ClsSc_StationOutBill(); |
| | | |
| | | //获取系统参数 |
| | | string Ret = ""; |
| | | oSystemParameter.ShowBill(ref Ret); |
| | | |
| | | for (int i = 0; i < HBillNo.Length; i++) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反审核成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | if (long.Parse(HBillNo[i]) == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + (i + 1) + "行:单据ID为0,不能反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //查看是否已审核,关闭,作废 |
| | | if (oBill.ShowBill(long.Parse(HBillNo[i]), ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + (i + 1) + "行:单据未审核!不需要反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //审核人必须和反审核人保持一致 乔一 |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "乔一") |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() != CurUserName) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + (i + 1) + "行:审核人和反审核人不一致!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + (i + 1) + "行:单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | |
| | | int j = 0; |
| | | for (int i = 0; i < HBillNo.Length; i++) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | //反审核 |
| | | if (Cj_StationOutBillAbandonCheckBill(long.Parse(HBillNo[i]), CurUserName, oBill.omodel.HLastSubProc, ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | j += 1; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "成功:" + j + "行,第" + (i + 1) + "行:反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "全部执行成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | #region 工序出站关闭/反关闭功能 |
| | | [Route("Cj_StationOutBill/CloseCj_StationOutBill")] |
| | | [HttpGet] |
| | | public object CloseCj_StationOutBill(string HInterID, int Type, string user,string HBillSubType) |
| | | { |
| | | try |
| | | { |
| | | if (HBillSubType == "SUB") |
| | | { |
| | | //判断是否有删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Sub_Close", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "完工单无权限关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else { |
| | | //判断是否有删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Close", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单无权限关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (string.IsNullOrWhiteSpace(HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsPub.CurUserName = user; |
| | | BillOld.MvarItemKey = "Sc_StationOutBillMain"; |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | //Type 1 关闭 2 反关闭 |
| | | if (Type == 1) |
| | | { |
| | | //判断单据是否已经关闭 |
| | | DataSet ds; |
| | | string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; |
| | | ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); |
| | | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已关闭!不需要再关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //关闭单据 |
| | | if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "关闭失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //判断单据是否已经反关闭 |
| | | DataSet ds; |
| | | string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; |
| | | ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); |
| | | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "单据已反关闭!不需要再反关闭!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //反关闭单据 |
| | | if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "反关闭失败!原因:" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit();//提交事务 |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "执行成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "执行失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | |
| | | //是否被关联 |
| | | public bool Cj_StationInBillisUse(Int64 lngBillKey, ref string sReturn) |
| | | { |