| | |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Controllers.SCGL; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers.CJGL |
| | |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | DataSet ds; |
| | | DataSet ds,ds2; |
| | | |
| | | #region 工序单品不良采集 用户查询关联字段 |
| | | [Route("Cj_SingleStation/Cj_CollectionOfSingleProductDefectsUserList")] |
| | |
| | | #region 工序单品不良采集 扫码查询 |
| | | [Route("Cj_SingleStation/HBardCodeList")] |
| | | [HttpGet] |
| | | public object HBardCodeList(string HBarCode, string user) |
| | | public object HBardCodeList(string HBarCode,int HProcID, string user) |
| | | { |
| | | try |
| | | { |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from gy_czygl WITH(NOLOCK) where czymc='" + user + "'", "gy_czygl"); |
| | | string HProcID = ds.Tables[0].Rows[0]["HProcID"].ToString(); |
| | | |
| | | ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBillHICOMProcessExchange WITH(NOLOCK) where 条码='" + HBarCode + "' ", "h_v_Gy_BarCodeBillHICOMProcessExchange"); |
| | | ds = oCN.RunProcReturn(@"select * from h_v_Gy_BarCodeBillHICOMProcessExchange WITH(NOLOCK) where 条码='" + HBarCode + "' and HProcID='"+ HProcID + "' ", "h_v_Gy_BarCodeBillHICOMProcessExchange"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "条码查无数据!"; |
| | | objJsonResult.Message = "条码跟当前工序查无数据!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | int num = 0; |
| | | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | if (ds.Tables[0].Rows[i]["HProcID"].ToString() == HProcID) |
| | | { |
| | | num = 1; |
| | | } |
| | | } |
| | | if (num == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "当前条码与当前工序不匹配!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //int num = 0; |
| | | //for (int i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | //{ |
| | | // if (ds.Tables[0].Rows[i]["HProcID"].ToString() == HProcID) |
| | | // { |
| | | // num = 1; |
| | | // } |
| | | //} |
| | | //if (num == 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "当前条码与当前工序不匹配!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | if (ds.Tables[0].Rows[0]["HStatus"].ToString() != "正常") |
| | | { |
| | |
| | | //修改条码表的状态 |
| | | oCN.RunProc("update Gy_BarCodeBill set HStatus='"+ HResult + "' where HBarCode='"+ oSub.HBarCode + "'"); |
| | | |
| | | LogService.Write("类型:" + oSub.HBadTypeID + ",制单人:" + oSub.HMaker + ",制单日期:" + oSub.HMakeDate); |
| | | //查询当前条码对应的出站单id |
| | | ds= oCN.RunProcReturn("select * from Sc_StationOutBillSub_SN where HBarCode='" + oSub.HBarCode + "' and HSourceEntryID='" + oSub.HProcExchEntryID + "'", "Sc_StationOutBillSub_SN"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | linterid= ds.Tables[0].Rows[0]["HInterID"].ToString(); |
| | | } |
| | | LogService.Write("类型:" + oSub.HBadTypeID + ",制单人:" + oSub.HMaker + ",制单日期:" + oSub.HMakeDate + ",工序:" + oSub.HProcID + ",流转卡:"+ oSub.HProcExchBillNo + ",出站单id:"+ linterid); |
| | | //修改出站单的 不良 报废数量 |
| | | if (HResult == "不良") |
| | | { |
| | |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔") |
| | | { |
| | | |
| | | //判断当前流转卡是否是开工 |
| | | ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0'", "Sc_ICMOBillStatus_Tmp"); |
| | | //判断当前流转卡 当前工序是否是开工 |
| | | ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HICMOStatus<>'0' and HProcID='"+ HProcID + "'", "Sc_ICMOBillStatus_Tmp"); |
| | | //查不到证明没有开工进入下一句查询 |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | //判断当前流转卡是否墨西哥的 |
| | | ds = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain"); |
| | | if (ds.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152") |
| | | ds2 = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain"); |
| | | if (ds2.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[3791-2-018]卡号:" + HBarCode + ",流转卡未开工!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | //获取生产状态临时表数据 |
| | | ds = oCN.RunProcReturn("select * from Sc_ICMOBillStatus_Tmp where HSourceBillNo='" + HBarCode + "' and HProcID='" + HProcID + "'", "Sc_ICMOBillStatus_Tmp"); |
| | | //传入 生产状态临时补 单据类型、主id、源单子ID、源单单号、当前登录人、源单单据类型 |
| | | objJsonResult = SaveMESBeginWorkFrom_ZD(ds.Tables[0].Rows[0]["HBillType"].ToString(),ds.Tables[0].Rows[0]["HInterID"].ToString(), ds.Tables[0].Rows[0]["HSourceEntryID"].ToString(), ds.Tables[0].Rows[0]["HSourceBillNo"].ToString(),user, ds.Tables[0].Rows[0]["HSourceBillType"].ToString()); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomList '" + HBarCode + "'," + HProcID, "h_p_Gy_BarCodeBillBomList"); |
| | | //2026 0228斯莫尔 两道工序要合并投料 自动分配 老的 h_p_Gy_BarCodeBillBomList 用于精准查询 新的 h_p_Gy_BarCodeBillBomList2 用于查询出要全部的上料 |
| | | //ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomList '" + HBarCode + "'," + HProcID, "h_p_Gy_BarCodeBillBomList"); |
| | | ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomList2 '" + HBarCode + "'," + HProcID, "h_p_Gy_BarCodeBillBomList2"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | DataSet dataSet = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList '" + HBarCode + "'," + HProcID, "h_p_Sc_ProcessExchangeBillList"); |
| | | //2026 0228斯莫尔 两道工序要合并投料 自动分配 老的 h_p_Sc_ProcessExchangeBillList 用于精准查询 新的 h_p_Sc_ProcessExchangeBillList2 用于查询出要全部的上料 |
| | | //DataSet dataSet = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList '" + HBarCode + "'," + HProcID, "h_p_Sc_ProcessExchangeBillList"); |
| | | |
| | | DataSet dataSet = oCN.RunProcReturn(@"exec h_p_Sc_ProcessExchangeBillList2 '" + HBarCode + "'," + HProcID, "h_p_Sc_ProcessExchangeBillList2"); |
| | | if (dataSet.Tables[0].Rows.Count > 0) |
| | | { |
| | | objJsonResult.code = "2"; |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | if (double.Parse(ds.Tables[0].Rows[0][0].ToString()) == 0) |
| | | { |
| | | //传入流转卡 单据类型、主id、子ID、单号、当前登录人、单据类型 |
| | | objJsonResult = SaveMESEndWorkFrom_ZD("3772", HProcExchInterID, HProcExchEntryID, HProcExchBillNo, user, ""); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "出站单保存成功,自动完工生成失败" + objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | ds = oCN.RunProcReturn("select * from Sc_SourceLineRepairBillSub_Mater where HInterID=" + model.HInterID+ " order by HEntryID desc", "Sc_SourceLineRepairBillSub_Mater"); |
| | | |
| | | oCN.RunProc($@"insert into Sc_SourceLineRepairBillSub_Mater |
| | | (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID |
| | | ,HSourceEntryID,HSourceBillNo,HSourceBillType,HMaterID |
| | | ,HUnitID,HBarCode,HBatchNo )values |
| | | ({model.HInterID},{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{model.HBillNo}','',{temp.HProcExchInterID} |
| | | ,{temp.HProcExchEntryID},'{temp.HProcExchBillNo}','',{temp.HMaterID},0,'{temp.HBarCode}','{temp.HBatchNo}')"); |
| | | (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID |
| | | ,HSourceEntryID,HSourceBillNo,HSourceBillType,HMaterID |
| | | ,HUnitID,HBarCode,HBatchNo )values |
| | | ({model.HInterID},{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{model.HBillNo}','',{temp.HProcExchInterID} |
| | | ,{temp.HProcExchEntryID},'{temp.HProcExchBillNo}','',{temp.HMaterID},0,'{temp.HBarCode}','{temp.HBatchNo}')"); |
| | | |
| | | //修改产线追溯单绑定的条码批号 |
| | | oCN.RunProc("update Sc_AssemblyBillSub set HBarCode='" + temp.HBarCode + "' where HInterID=" + temp.HInterID + " and HEntryID=" + temp.HEntryID); |
| | |
| | | model = JsonConvert.DeserializeObject<Model.ClsSc_SourceLineRepairBillMain>(sMainStr); |
| | | |
| | | oCN.RunProc($@"insert into Sc_SourceLineRepairBillMain(HYear, HPeriod, HBillType, HBillSubType, HInterID, |
| | | HDate, HBillNo, HBillStatus, HRemark, HEmpID, HDeptID, HSourceID, HProdOrgID, HMaterID, HWorkStationID, |
| | | HProcess, HIPAddr, HMacAddr, HProdMac, HBarCode,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo) |
| | | values('{DateTime.Now.Year}','{DateTime.Now.Month}','3748','3748',{model.HInterID} |
| | | ,getdate(),'{model.HBillNo}','1','{HResult}',{model.HEmpID},{model.HDeptID},{model.HSourceID},{model.HProdOrgID},{model.HMaterID},0 |
| | | ,{model.HProcess},'','','','{model.HBarCode}','{user}',getdate(),{model.HICMOInterID},{model.HICMOEntryID},'{model.HICMOBillNo}')"); |
| | | HDate, HBillNo, HBillStatus, HRemark, HEmpID, HDeptID, HSourceID, HProdOrgID, HMaterID, HWorkStationID, |
| | | HProcess, HIPAddr, HMacAddr, HProdMac, HBarCode,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo) |
| | | values('{DateTime.Now.Year}','{DateTime.Now.Month}','3748','3748',{model.HInterID} |
| | | ,getdate(),'{model.HBillNo}','1','{HResult}',{model.HEmpID},{model.HDeptID},{model.HSourceID},{model.HProdOrgID},{model.HMaterID},0 |
| | | ,{model.HProcess},'','','','{model.HBarCode}','{user}',getdate(),{model.HICMOInterID},{model.HICMOEntryID},'{model.HICMOBillNo}')"); |
| | | |
| | | List<Model.ClsSc_SourceLineRepairBillSub> subLsit = new List<Model.ClsSc_SourceLineRepairBillSub>(); |
| | | sMainStr = "[" + sMainStr + "]"; |
| | | subLsit = JsonConvert.DeserializeObject<List<Model.ClsSc_SourceLineRepairBillSub>>(sMainStr); |
| | | |
| | | oCN.RunProc($@"insert into Sc_SourceLineRepairBillSub |
| | | (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType |
| | | ,HBadReasonID,HBadTypeID,HBadResultID,HBadProcID,HRepairResult,HCreator,HCreateDate) |
| | | values({model.HInterID},1,'{model.HBillNo}','',{subLsit[0].HProcExchInterID},{subLsit[0].HProcExchEntryID},'{subLsit[0].HProcExchBillNo}','' |
| | | ,{subLsit[0].HBadReasonID},{subLsit[0].HBadTypeID},{subLsit[0].HBadResultID},{model.HBadProcID},'{HResult}','{subLsit[0].HCreator}',getdate())"); |
| | | (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType |
| | | ,HBadReasonID,HBadTypeID,HBadResultID,HBadProcID,HRepairResult,HCreator,HCreateDate) |
| | | values({model.HInterID},1,'{model.HBillNo}','{model.HRemark}',{subLsit[0].HProcExchInterID},{subLsit[0].HProcExchEntryID},'{subLsit[0].HProcExchBillNo}','' |
| | | ,{subLsit[0].HBadReasonID},{subLsit[0].HBadTypeID},{subLsit[0].HBadResultID},{model.HBadProcID},'{HResult}','{subLsit[0].HCreator}',getdate())"); |
| | | |
| | | if (HResult == "OK") |
| | | { |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 工序单品过站自动开、完工 |
| | | //自动开工 |
| | | public json SaveMESBeginWorkFrom_ZD(string HBillType, string HSourceInterID, string HSourceEntryID, string HSourceBillNo, string user, string HSourceBillType) |
| | | { |
| | | |
| | | |
| | | //保存权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("MES_MESBeginWorkBill_Edit", 1, false, user)) |
| | | { |
| | | 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(DateTime.Now, ref sYear, ref sPeriod, ref s) == false) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = s; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("exec h_p_JIT_GetInfoByICMOStatusInterID @HSourceInterID=" + HSourceInterID + ",@HSourceEntryID=" + HSourceEntryID + ",@HSourceBillNo='" + HSourceBillNo + "',@HSourceBillType='" + HBillType + "'", "h_p_JIT_GetInfoByICMOStatusInterID"); |
| | | |
| | | Models.ClsSc_MESBeginWorkBillMain ClsSc_MESBeginWorkBillMain = new Models.ClsSc_MESBeginWorkBillMain(); |
| | | ClsSc_MESBeginWorkBillMain.HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HMaterID = int.Parse(ds.Tables[0].Rows[0]["HMaterID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HSourceID = int.Parse(ds.Tables[0].Rows[0]["HSourceID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HMainSourceBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString(); |
| | | ClsSc_MESBeginWorkBillMain.HMainSourceInterID = int.Parse(ds.Tables[0].Rows[0]["HSourceInterID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HMainSourceEntryID = ds.Tables[0].Rows[0]["HSourceEntryID"].ToString(); |
| | | ClsSc_MESBeginWorkBillMain.HMainSourceBillType = HSourceBillType == null ? "" : HSourceBillType; |
| | | ClsSc_MESBeginWorkBillMain.HDeptID = int.Parse(ds.Tables[0].Rows[0]["HDeptID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HICMOInterID = int.Parse(ds.Tables[0].Rows[0]["HICMOInterID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HICMOEntryID = int.Parse(ds.Tables[0].Rows[0]["HICMOEntryID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString(); |
| | | ClsSc_MESBeginWorkBillMain.HProcExchInterID = int.Parse(ds.Tables[0].Rows[0]["HProcExchInterID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HProcExchEntryID = int.Parse(ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString(); |
| | | ClsSc_MESBeginWorkBillMain.HPeopleSum =1; |
| | | |
| | | //获取班次 |
| | | DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + int.Parse(ds.Tables[0].Rows[0]["HDeptID"].ToString()) + "," + int.Parse(ds.Tables[0].Rows[0]["HCenterID"].ToString()), "h_p_Gy_GetWorkShiftInfo"); |
| | | if (set.Tables[0].Rows.Count > 0) |
| | | { |
| | | ClsSc_MESBeginWorkBillMain.HWorkShiftID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString()); |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_xt_UserAssociationSelect where Czymc='" + user + "'", "h_v_xt_UserAssociationSelect"); |
| | | |
| | | |
| | | if (ds.Tables[0].Rows[0]["HEmployeeID"].ToString() == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "自动开工保存失败!用户没有绑定职员!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | ClsSc_MESBeginWorkBillMain.HGroupID = int.Parse(ds.Tables[0].Rows[0]["HGroupID"].ToString()); |
| | | ClsSc_MESBeginWorkBillMain.HEmpID = int.Parse(ds.Tables[0].Rows[0]["HEmployeeID"].ToString()); |
| | | |
| | | DLL.ClsSc_MESBeginWorkBill oBill = new DLL.ClsSc_MESBeginWorkBill(); |
| | | List<Models.ClsSc_MESBeginWorkBillMain> lsmain = new List<Models.ClsSc_MESBeginWorkBillMain>(); |
| | | lsmain.Add(ClsSc_MESBeginWorkBillMain); |
| | | ClsXt_SystemParameter oClsXt_SystemParameter = new ClsXt_SystemParameter(); |
| | | |
| | | DBUtility.ClsPub.CurUserName = user; |
| | | |
| | | foreach (Models.ClsSc_MESBeginWorkBillMain oItem in lsmain) |
| | | { |
| | | oItem.HBillNo = DBUtility.ClsPub.CreateBillCode("3787", ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | |
| | | oItem.HBillType = "3787"; |
| | | oItem.HBillSubType = "3787"; |
| | | oItem.HBillStatus = 1; //单据状态(1未审,2审核通过,3关闭,4作废,5审核退回,6审核中,7已阅,8已回复,9结案,10验证,11下达,12开工,13申请审批,15申请检验,16 判定合格,17判定不合格) |
| | | oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | | oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); |
| | | oItem.HMaker = user; |
| | | oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oItem.HBarCodeMakeDate = Convert.ToDateTime(DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"))); //扫描日期(年-月-日-时-分-秒) |
| | | oItem.HRemark = "自动开工"; |
| | | oBill.omodel = oItem; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult = false; |
| | | if (oBill.omodel.HInterID == 0) |
| | | { |
| | | |
| | | bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | ds = oCN.RunProcReturn("select * from Sc_MESBeginWorkBillMain where HBillNo='" + oBill.omodel.HBillNo + "'", "Sc_MESBeginWorkBillMain"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "查无单据!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sAutoCheck = oClsXt_SystemParameter.GetSingleSystemParameter("Sc_MESBeginWorkBill_AutoCheck", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | if (sAutoCheck == "Y") |
| | | { |
| | | |
| | | if (!oBill.CheckBill(long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString()), ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | if (bResult) |
| | | { |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = e.Message; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | //自动完工 |
| | | public json SaveMESEndWorkFrom_ZD(string HBillType, long HSourceInterID, long HSourceEntryID, string HSourceBillNo, string user, string HSourceBillType) |
| | | { |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //保存权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("MES_MESEndWorkBill_Edit", 1, false, user)) |
| | | { |
| | | 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(DateTime.Now, ref sYear, ref sPeriod, ref s) == false) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = s; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("exec h_p_JIT_GetInfoByICMOStatusInterID @HSourceInterID=" + HSourceInterID + ",@HSourceEntryID=" + HSourceEntryID + ",@HSourceBillNo='" + HSourceBillNo + "',@HSourceBillType='" + HBillType + "'", "h_p_JIT_GetInfoByICMOStatusInterID"); |
| | | |
| | | Models.ClsSc_MESEndWorkBillMain ClsSc_MESEndWorkBillMain = new Models.ClsSc_MESEndWorkBillMain(); |
| | | ClsSc_MESEndWorkBillMain.HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HMaterID = int.Parse(ds.Tables[0].Rows[0]["HMaterID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HSourceID = int.Parse(ds.Tables[0].Rows[0]["HSourceID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HMainSourceBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString(); |
| | | ClsSc_MESEndWorkBillMain.HMainSourceInterID = int.Parse(ds.Tables[0].Rows[0]["HSourceInterID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HMainSourceEntryID = long.Parse(ds.Tables[0].Rows[0]["HSourceEntryID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HMainSourceBillType = HSourceBillType == null ? "" : HSourceBillType; |
| | | ClsSc_MESEndWorkBillMain.HDeptID = int.Parse(ds.Tables[0].Rows[0]["HDeptID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HICMOInterID = int.Parse(ds.Tables[0].Rows[0]["HICMOInterID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HICMOEntryID = int.Parse(ds.Tables[0].Rows[0]["HICMOEntryID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HICMOBillNo = ds.Tables[0].Rows[0]["HICMOBillNo"].ToString(); |
| | | ClsSc_MESEndWorkBillMain.HProcExchInterID = int.Parse(ds.Tables[0].Rows[0]["HProcExchInterID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HProcExchEntryID = int.Parse(ds.Tables[0].Rows[0]["HProcExchEntryID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HProcExchBillNo = ds.Tables[0].Rows[0]["HProcExchBillNo"].ToString(); |
| | | |
| | | |
| | | //获取班次 |
| | | DataSet set = oCN.RunProcReturn("exec h_p_Gy_GetWorkShiftInfo " + int.Parse(ds.Tables[0].Rows[0]["HDeptID"].ToString()) + "," + int.Parse(ds.Tables[0].Rows[0]["HCenterID"].ToString()), "h_p_Gy_GetWorkShiftInfo"); |
| | | if (set.Tables[0].Rows.Count > 0) |
| | | { |
| | | ClsSc_MESEndWorkBillMain.HWorkShiftID = int.Parse(set.Tables[0].Rows[0]["HInterID"].ToString()); |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Cj_GetDefValByUser where 用户名称='" + user + "'", "h_v_xt_UserAssociationSelect"); |
| | | |
| | | if (ds.Tables[0].Rows[0]["HEmpID"].ToString() == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!用户没有绑定职员!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsSc_MESEndWorkBillMain.HGroupID = int.Parse(ds.Tables[0].Rows[0]["HGroupID"].ToString()); |
| | | ClsSc_MESEndWorkBillMain.HEmpID = int.Parse(ds.Tables[0].Rows[0]["HEmpID"].ToString()); |
| | | |
| | | DLL.ClsSc_MESEndWorkBill oBill = new DLL.ClsSc_MESEndWorkBill(); |
| | | List<Models.ClsSc_MESEndWorkBillMain> lsmain = new List<Models.ClsSc_MESEndWorkBillMain>(); |
| | | lsmain.Add(ClsSc_MESEndWorkBillMain); |
| | | ClsXt_SystemParameter oClsXt_SystemParameter = new ClsXt_SystemParameter(); |
| | | |
| | | DBUtility.ClsPub.CurUserName = user; |
| | | |
| | | foreach (Models.ClsSc_MESEndWorkBillMain oItem in lsmain) |
| | | { |
| | | oItem.HBillNo = DBUtility.ClsPub.CreateBillCode("3788", ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | |
| | | oItem.HBillType = "3788"; |
| | | oItem.HBillSubType = "3788"; |
| | | oItem.HReportType = "3";//(1条码扫描,2机器汇报,3手工录入) |
| | | oItem.HBillStatus = 1; //单据状态(1未审,2审核通过,3关闭,4作废,5审核退回,6审核中,7已阅,8已回复,9结案,10验证,11下达,12开工,13申请审批,15申请检验,16 判定合格,17判定不合格) |
| | | oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); |
| | | oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); |
| | | oItem.HMaker = user; |
| | | oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); |
| | | oItem.HBarCodeMakeDate = Convert.ToDateTime(DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"))); //扫描日期(年-月-日-时-分-秒) |
| | | oItem.HRemark = "自动完工"; |
| | | oBill.omodel = oItem; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult = false; |
| | | if (oBill.omodel.HInterID == 0) |
| | | { |
| | | |
| | | bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | if (!bResult) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | ds = oCN.RunProcReturn("select * from Sc_MESEndWorkBillMain where HBillNo='" + oBill.omodel.HBillNo + "'", "Sc_MESEndWorkBillMain"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "查无单据!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sAutoCheck = oClsXt_SystemParameter.GetSingleSystemParameter("Sc_MESEndWorkBill_AutoCheck", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | if (sAutoCheck == "Y") |
| | | { |
| | | |
| | | if (!oBill.CheckBill(long.Parse(ds.Tables[0].Rows[0]["HInterID"].ToString()), ref DBUtility.ClsPub.sExeReturnInfo)) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | if (bResult) |
| | | { |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "自动完工保存失败!" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = e.Message; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 小卫单品过站接口 |
| | | |
| | | #region 工序单品过站 扫条码码校验返回信息(只用于验证批次是否入库) |
| | |
| | | try |
| | | { |
| | | //判断所扫条码是否存在条码档案当中 |
| | | ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill"); |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | //条码档案中没有本次扫描的条码,则根据规则解析生成条码 |
| | | //ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill"); |
| | | //if (ds.Tables[0].Rows.Count == 0) |
| | | //{ |
| | | // //条码档案中没有本次扫描的条码,则根据规则解析生成条码 |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "该条码不存在:" + HBarCode; |
| | | objJsonResult.data = ""; |
| | | return objJsonResult; |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "该条码不存在:" + HBarCode; |
| | | // objJsonResult.data = ""; |
| | | // return objJsonResult; |
| | | |
| | | } |
| | | //} |
| | | |
| | | //条码档案中已有本次扫描的条码,查询配件信息(扫描条码信息写入临时表) |
| | | ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomBindByHProcExch_XW '" + HBillNo + "','" + HBarCode + "','" + HBarCode_P + "','" + HProcID + "','" + HOrgID + "'", "h_p_Gy_BarCodeBillBomBindByHProcExch_XW"); |
| | |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_UnbindStation_BarList order by 条码日期 desc", "h_v_Sc_UnbindStation_BarList"); |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_UnbindStation_BarList" + |
| | | " order by 条码日期 desc", "h_v_Sc_UnbindStation_BarList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Sc_UnbindStation_BarList where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by 条码日期 desc"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sc_UnbindStation_BarList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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 = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 过站解绑列表 查询 |
| | | [Route("Cj_SingleStation/ShippingExportList")] |
| | | [HttpGet] |
| | | public object ShippingExportList(string sWhere, string user, string gnsy) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | if (gnsy != "" && gnsy != null) |
| | | { |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log(gnsy, 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_Cj_SingleStation_ShippingExportList" + |
| | | " order by 栈板码 desc,中箱码,SN码", "h_v_Cj_SingleStation_ShippingExportList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Cj_SingleStation_ShippingExportList where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by 栈板码 desc,中箱码,SN码"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Cj_SingleStation_ShippingExportList"); |
| | | } |
| | | |
| | | //添加列名 |
| | |
| | | |
| | | oCN.RunProc(sql);//插入蓝牙测试数据 |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.code = "success"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "蓝牙测试数据接收成功!lotSn:" + lotSn; |
| | | objJsonResult.data = null; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.code = "error"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "发生异常!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 小卫组托缓存 查询 |
| | | [Route("Cj_SingleStation/xiaoweizutuo_CacheList")] |
| | | [HttpGet] |
| | | public object xiaoweizutuo_CacheList(string sWhere, string user, string gnsy) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | if (gnsy != "" && gnsy != null) |
| | | { |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log(gnsy, 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_Sc_PackUnionBill_Temp" + |
| | | " order by 栈板码 desc,中箱码,SN码", "h_v_Sc_PackUnionBill_Temp"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Sc_PackUnionBill_Temp where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by 栈板码 desc,中箱码,SN码"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sc_PackUnionBill_Temp"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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 = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 小卫组托缓存 删除 |
| | | /// <summary> |
| | | ///参数:string HInterID。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Cj_SingleStation/deleteBill")] |
| | | [HttpGet] |
| | | public object deleteBill(string HInterID, string user,string gnsy) |
| | | { |
| | | try |
| | | { |
| | | if (gnsy != "" && gnsy != null) |
| | | { |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log(gnsy, 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | if (HInterID == null || HInterID.Equals("")) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | |
| | | oCN.RunProc("delete from Sc_PackUnionBill_Temp where HInterID = " + HInterID); |
| | | |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | 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 |
| | | |
| | | #endregion |
| | | |
| | | } |