|  |  |  | 
|---|
|  |  |  | //委外工序发出反序列化 | 
|---|
|  |  |  | msg1 = "[" + msg1.ToString() + "]"; | 
|---|
|  |  |  | List<StationBill> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<StationBill>>(msg1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | string eventType = list[0].eventType; | 
|---|
|  |  |  | long HInterID = list[0].HInterID;//递入type得到的单据ID | 
|---|
|  |  |  | int HYear = 2021; | 
|---|
|  |  |  | double HPeriod = list[0].HPeriod;//单价 | 
|---|
|  |  |  | 
|---|
|  |  |  | string HInnerBillNo = list[0].HInnerBillNo;//送货单号 | 
|---|
|  |  |  | string HICMOBillNo = list[0].HICMOBillNo;//生产订单号 | 
|---|
|  |  |  | long HICMOInterID = list[0].HICMOInterID;//生产订单号ID | 
|---|
|  |  |  | int HProcExchInterID = 0; | 
|---|
|  |  |  | int HProcExchEntryID = 0; | 
|---|
|  |  |  | long HProcExchInterID = list[0].lngBillKey; | 
|---|
|  |  |  | long HProcExchEntryID = list[0].lngBillSubKey; | 
|---|
|  |  |  | string HProcExchBillNo = list[0].HProcExchBillNo;//流转卡 | 
|---|
|  |  |  | long HProcID = list[0].HProcID;//当前工序 | 
|---|
|  |  |  | long HMaterID = list[0].HMaterID;//产品ID | 
|---|
|  |  |  | 
|---|
|  |  |  | string HBarCode = list[0].HBarCode;//条形码 | 
|---|
|  |  |  | string HAddr = ""; | 
|---|
|  |  |  | string HBarCodeMaker = ""; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (HProcExchInterID <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "流转卡没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HProcExchEntryID <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "流水号2没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HProcNo <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "流水号没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HProcExchBillNo == "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "流转卡号没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HMaterID <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "产品没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HSupID <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "供应商没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HProcID <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "当前工序没有选择!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (HQty <= 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "发出数量不能为0!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //若MAINDI重复则重新获取 | 
|---|
|  |  |  | oCN.BeginTran(); | 
|---|
|  |  |  | //主表 | 
|---|
|  |  |  | oCN.RunProc("Insert Into Sc_StationInBillMain " + | 
|---|
|  |  |  | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + | 
|---|
|  |  |  | ",HYear,HPeriod,HRemark,HInnerBillNo" + | 
|---|
|  |  |  | ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + | 
|---|
|  |  |  | ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" + | 
|---|
|  |  |  | ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + | 
|---|
|  |  |  | ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPieceQty" + | 
|---|
|  |  |  | ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID" + | 
|---|
|  |  |  | ") " + | 
|---|
|  |  |  | " values('3792','3792'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillStatus.ToString() + "',getdate(),'" + HMaker + "',getdate()" + | 
|---|
|  |  |  | ",'" + HYear.ToString() + "','" + HPeriod.ToString() + "','" + HRemark + "','" + HInnerBillNo + "'" + | 
|---|
|  |  |  | "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + | 
|---|
|  |  |  | ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + | 
|---|
|  |  |  | "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + | 
|---|
|  |  |  | "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPieceQty + | 
|---|
|  |  |  | ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "" + | 
|---|
|  |  |  | ") "); | 
|---|
|  |  |  | if ("Add".Equals(eventType)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (!AllowbillNo(HBillNo)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "单据号重复!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //主表 | 
|---|
|  |  |  | oCN.RunProc("Insert Into Sc_StationInBillMain " + | 
|---|
|  |  |  | "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" + | 
|---|
|  |  |  | ",HYear,HPeriod,HRemark,HInnerBillNo" + | 
|---|
|  |  |  | ",HICMOInterID,HICMOBillNo,HProcPlanInterID,HProcPlanEntryID,HProcPlanBillNo,HProcExchInterID,HProcExchEntryID" + | 
|---|
|  |  |  | ",HProcExchBillNo,HMaterID,HProcID,HICMOQty,HPlanQty,HStationInTime,HSourceID" + | 
|---|
|  |  |  | ",HGroupID,HDeptID,HEmpID,HBarCode,HAddr,HBarCodeMaker,HBarCodeMakeDate" + | 
|---|
|  |  |  | ",HSupID,HTaxRate,HQty,HPrice,HMoney,HPieceQty" + | 
|---|
|  |  |  | ",HProcNo,HOrderProcNO,HWWWorkOrderBillNo,HWWWorkOrderInterID,HWWWorkOrderEntryID" + | 
|---|
|  |  |  | ") " + | 
|---|
|  |  |  | " values('3792','3792'," + HInterID.ToString() + ",'" + HBillNo + "','" + HBillStatus.ToString() + "',getdate(),'" + HMaker + "',getdate()" + | 
|---|
|  |  |  | ",'" + HYear.ToString() + "','" + HPeriod.ToString() + "','" + HRemark + "','" + HInnerBillNo + "'" + | 
|---|
|  |  |  | "," + HICMOInterID + ",'" + HICMOBillNo + "'," + HProcPlanInterID + "," + HProcPlanEntryID + ",'" + HProcPlanBillNo + "'," + HProcExchInterID + "," + HProcExchEntryID + | 
|---|
|  |  |  | ",'" + HProcExchBillNo + "'," + HMaterID + "," + HProcID + "," + HICMOQty + "," + HPlanQty + ",getdate()," + HSourceID + | 
|---|
|  |  |  | "," + HGroupID + "," + HDeptID + "," + HEmpID + ",'" + HBarCode + "','" + HAddr + "','" + HBarCodeMaker + "',getdate()" + | 
|---|
|  |  |  | "," + HSupID + "," + HTaxRate + "," + HQty + "," + HPrice + "," + HMoney + "," + HPieceQty + | 
|---|
|  |  |  | ",'" + HProcNo + "','" + HOrderProcNO + "'" + ",'" + HWWWorkOrderBillNo + "'" + "," + HWWWorkOrderInterID + "" + "," + HWWWorkOrderEntryID + "" + | 
|---|
|  |  |  | ") "); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if ("Modify".Equals(eventType)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //删除关联 | 
|---|
|  |  |  | oCN.RunProc("exec h_p_Mes_ProcessExchangeRelationQty_In " + HInterID + ",-1"); | 
|---|
|  |  |  | oCN.RunProc("exec h_p_WW_EntrustWorkOrderRelationQty_In " + HInterID + ",-1"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新主表 | 
|---|
|  |  |  | oCN.RunProc("UpDate Sc_StationInBillMain set  " + | 
|---|
|  |  |  | "HBillNo='" + HBillNo + "'" + | 
|---|
|  |  |  | ",HRemark='" + HRemark + "'" + | 
|---|
|  |  |  | ",HUpDater='" + DBUtility.ClsPub.CurUserName + "'" + | 
|---|
|  |  |  | ",HUpDateDate=getdate()" + | 
|---|
|  |  |  | ",HInnerBillNo='" + HInnerBillNo + "'" + | 
|---|
|  |  |  | ",HSupID=" + HSupID + | 
|---|
|  |  |  | ",HQty=" + HQty + | 
|---|
|  |  |  | ",HPieceQty=" + HPieceQty + | 
|---|
|  |  |  | ",HPrice=" + HPrice + | 
|---|
|  |  |  | ",HMoney=" + HMoney + | 
|---|
|  |  |  | ",HTaxRate=" + HTaxRate + | 
|---|
|  |  |  | ",HMaterID=" + HMaterID + | 
|---|
|  |  |  | ",HProcID=" + HProcID + | 
|---|
|  |  |  | ",HProcNo=" + HProcNo + | 
|---|
|  |  |  | ",HOrderProcNO='" + HOrderProcNO + "'" + | 
|---|
|  |  |  | " where HInterID=" + HInterID); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "操作类型无效!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ds = oCN.RunProcReturn("exec h_p_MES_StationInBill_QtyCtrl " + HInterID + "", "h_p_MES_StationInBill_QtyCtrl"); | 
|---|
|  |  |  | if (ds == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.Message; | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private bool AllowbillNo(string HBillNo) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select HBillNo from Sc_StationInBillMain where  HBillNo = '" + HBillNo + "'", "Sc_StationInBillMain"); | 
|---|
|  |  |  | if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return true; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 编辑页面根据id获取委外工序接收单信息 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Cj_StationEntrustInBill/GetStationEntrustInBill")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object GetStationEntrustInBill(int HInterID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_GetStationInBill where HInterID = " + HInterID, "h_v_GetStationOutBill"); | 
|---|
|  |  |  | if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "委外工序接收单信息获取失败!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "Sucess!"; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|