| | |
| | | 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")] |
| | |
| | | { |
| | | if (oSystemParameter.omodel.WMS_CampanyName == "杭州斯莫尔") |
| | | { |
| | | |
| | | //判断当前流转卡 当前工序是否是开工 |
| | | 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) |
| | | if (HProcID == "90") //清洁工序进入自动开工模式 |
| | | { |
| | | //判断当前流转卡是否墨西哥的 |
| | | ds = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain"); |
| | | if (ds.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152") |
| | | //判断当前流转卡 当前工序是否是开工 |
| | | 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) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[3791-2-018]卡号:" + HBarCode + ",流转卡未开工!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } la |
| | | //判断当前流转卡是否墨西哥的 |
| | | ds2 = oCN.RunProcReturn("select HPRDORGID from Sc_ProcessExchangeBillMain with(nolock) where HBillNo = '" + HBarCode + "' ", "Sc_ProcessExchangeBillMain"); |
| | | if (ds2.Tables[0].Rows[0]["HPRDORGID"].ToString() != "7667152") |
| | | { |
| | | //获取生产状态临时表数据 |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "[0000-1-037]"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | if (HProcID == "90" || HProcID== "102") |
| | | { |
| | | 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.count = 2; |
| | | objJsonResult.Message = "[0000-1-037]"; |
| | | objJsonResult.data = dataSet.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "[0000-1-037]"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | } |
| | | |
| | | } |
| | | |
| | | return objJsonResult; |
| | |
| | | "(HInterID,HEntryID,HBillNo_bak,HSourceBillNo,HSourceInterID,HSourceEntryID,HMaterID" + |
| | | ",HProdOrgID,HSourceBillType,HAuxPropID,HProcID,HQty,HBatchNo,HBarCode,HMTONo,HPlanMode) " + |
| | | " values(" + HInterID + "," + (i + 1) + ",'" + HBillNo + "','" + tempList[i].HProcExchBillNo + "'," + tempList[i].HProcExchInterID + "," + tempList[i].HProcExchEntryID + "," + tempList[i].HMaterID + |
| | | ",'" + HOrgID + "','',0," + HProcID + "," + tempList[i].HQty + ",'"+ tempList[i].HBatchNo + "','" + tempList[i].HBarCode + "','','') "); |
| | | ",'" + HOrgID + "','',0," + tempList[i].HProcID + "," + tempList[i].HQty + ",'"+ tempList[i].HBatchNo + "','" + tempList[i].HBarCode + "','','') "); |
| | | } |
| | | |
| | | oCN.Commit(); |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //增加产线组装追溯单 |
| | | DataSet ds1 = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + omodel.HProcExchBillNo + "'," + omodel.HProcID, "h_p_Gy_BarCodeBillBomList"); |
| | | if (ds1.Tables[0].Rows.Count > 0) |
| | | if (omodel.HProcID!=90)//斯莫尔拍照清洁工序过滤 |
| | | { |
| | | //判配件数量是否等于0 |
| | | for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) |
| | | //增加产线组装追溯单 |
| | | DataSet ds1 = oCN.RunProcReturn("exec h_p_Gy_BarCodeBillBomList '" + omodel.HProcExchBillNo + "'," + omodel.HProcID, "h_p_Gy_BarCodeBillBomList"); |
| | | if (ds1.Tables[0].Rows.Count > 0) |
| | | { |
| | | double SYHQty = double.Parse(ds1.Tables[0].Rows[i]["配件数量"].ToString()); |
| | | string HMaterNamePJ = ds1.Tables[0].Rows[i]["配件代码"].ToString(); |
| | | if (SYHQty == 0) |
| | | //判配件数量是否等于0 |
| | | for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[3791-2-020]配件代码:" + HMaterNamePJ + ",数量为0!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | double SYHQty = double.Parse(ds1.Tables[0].Rows[i]["配件数量"].ToString()); |
| | | string HMaterNamePJ = ds1.Tables[0].Rows[i]["配件代码"].ToString(); |
| | | if (SYHQty == 0) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[3791-2-020]配件代码:" + HMaterNamePJ + ",数量为0!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | ds1 = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID =" + omodel.HProcExchInterID + " and HMainSourceEntryID =" + omodel.HProcExchEntryID + " and HBarCode_P = '" + omodel.HBarCode_P + "'", "Sc_AssemblyBillMain"); |
| | | ds1 = oCN.RunProcReturn("select * from Sc_AssemblyBillMain WITH(NOLOCK) where HMainSourceInterID =" + omodel.HProcExchInterID + " and HMainSourceEntryID =" + omodel.HProcExchEntryID + " and HBarCode_P = '" + omodel.HBarCode_P + "'", "Sc_AssemblyBillMain"); |
| | | |
| | | if (ds1.Tables[0].Rows.Count == 0) |
| | | { |
| | | Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | string prefix = omodel.HBarCode_P.Substring(0, 10); // 从索引0开始,截取10个字符 判断每个项目的O星圈配件数量 |
| | | |
| | | if (ds1.Tables[0].Rows.Count == 0) |
| | | { |
| | | Int64 HInterID1 = DBUtility.ClsPub.CreateBillID("3727", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | string HBillNo1 = DBUtility.ClsPub.CreateBillCode("3727", ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | string prefix = omodel.HBarCode_P.Substring(0, 10); // 从索引0开始,截取10个字符 判断每个项目的O星圈配件数量 |
| | | |
| | | //保存生产组装单主表 |
| | | string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate |
| | | string sql = $@"Insert Into Sc_AssemblyBillMain(HYear,HPeriod,HBillType,HBillSubType,HInterID,HDate |
| | | ,HBillNo,HBillStatus,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo |
| | | ,HICMOInterID,HICMOBillNo,HBarCode_P,HMaterID,HUnitID,HAssemblyStatus,HProdOrgID) |
| | | values('{DateTime.Now.Year}','{DateTime.Now.Month}','3727','3727',{HInterID1},getdate() |
| | | ,'{HBillNo1}','1','{user}',getdate(),{omodel.HProcExchInterID.ToString()},{omodel.HProcExchEntryID.ToString()},'{omodel.HProcExchBillNo.ToString()}' |
| | | ,{omodel.HICMOInterID.ToString()},'{omodel.HICMOBillNo.ToString()}','{omodel.HBarCode_P.ToString()}',{omodel.HMaterID},0,'汇报',{omodel.HProdOrgID})"; |
| | | oCN.RunProc(sql); |
| | | if (prefix == "#0TE911124") { |
| | | for (int i = 0; i < sub.Count; i++) |
| | | oCN.RunProc(sql); |
| | | if (prefix == "#0TE911124") |
| | | { |
| | | //子表存储 |
| | | string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo |
| | | for (int i = 0; i < sub.Count; i++) |
| | | { |
| | | //子表存储 |
| | | string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo |
| | | ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty |
| | | ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber) |
| | | values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,'' |
| | | ,'',{sub[i].HMaterID},0,0,0,3 |
| | | ,0,0,getdate(),'{sub[i].HBarCode}','{omodel.HBarCode_P}','') "; |
| | | oCN.RunProc(sq2); |
| | | oCN.RunProc(sq2); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | for (int i = 0; i < sub.Count; i++) |
| | | else |
| | | { |
| | | //子表存储 |
| | | string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo |
| | | for (int i = 0; i < sub.Count; i++) |
| | | { |
| | | //子表存储 |
| | | string sq2 = $@"Insert Into Sc_AssemblyBillSub(HInterID,HBillNo_bak,HEntryID,HSourceInterID,HSourceEntryID,HSourceBillNo |
| | | ,HSourceBillType,HMaterID,HSourceID,HEquipID,HUnitID,HQty |
| | | ,HGroupID,HWorkerID,HScanDate,HBarCode,HBarCode_P,HSNNumber) |
| | | values({HInterID1},'{HBillNo1}',{(i + 1)},0,0,'' |
| | | ,'',{sub[i].HMaterID},0,0,0,1 |
| | | ,0,0,getdate(),'{sub[i].HBarCode}','{omodel.HBarCode_P}','') "; |
| | | oCN.RunProc(sq2); |
| | | oCN.RunProc(sq2); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | 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(@"exec h_p_Gy_BadRecordsList " + HProcExchInterID + "," + HProcExchEntryID, "h_p_Gy_BadRecordsList"); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "[0000-1-037]"; |
| | | objJsonResult.data = ds; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[0000-1-010]没有返回任何记录!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | //根据主id+工序查 |
| | | [Route("Cj_SingleStation/BadRecordsList2")] |
| | | [HttpGet] |
| | | public object BadRecordsList2(string HProcExchInterID, string HProcID, string user) |
| | | { |
| | | try |
| | | { |
| | | //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Cj_StationOutBill_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "[0000-1-068]无查询权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn(@"exec h_p_Gy_BadRecordsList2 " + HProcExchInterID + "," + HProcID, "h_p_Gy_BadRecordsList2"); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | } |
| | | #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 工序单品过站 扫条码码校验返回信息(只用于验证批次是否入库) |