|  |  |  | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 入库——生产汇报单 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="InterID">工序汇报单主ID</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Sc_ProcessMangement/SaveICMOReportBill_Batch")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object SaveICMOReportBill_Batch([FromBody] JObject msg) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var _value = msg["msg"].ToString(); | 
|---|
|  |  |  | string msg1 = _value.ToString(); | 
|---|
|  |  |  | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | string InterID = sArray[0].ToString(); | 
|---|
|  |  |  | string user = sArray[1].ToString(); | 
|---|
|  |  |  | string BillNo = sArray[2].ToString(); | 
|---|
|  |  |  | string OrganizationID = sArray[3].ToString(); | 
|---|
|  |  |  | ArrayList InterIDArray = new ArrayList(InterID.Split(',')); | 
|---|
|  |  |  | ArrayList BillNoArray = new ArrayList(BillNo.Split(',')); | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string bResult; | 
|---|
|  |  |  | string HMessage = ""; | 
|---|
|  |  |  | string HSuccessBillNo = ""; | 
|---|
|  |  |  | string HFailBillNo = ""; | 
|---|
|  |  |  | WebAPI.Controllers.Sc_ProcessMangementController oBill = new WebAPI.Controllers.Sc_ProcessMangementController(); | 
|---|
|  |  |  | if (InterIDArray.Count != BillNoArray.Count) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "数据不完整,内码数量不等于单据号数量"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | for (int i = 0; i < InterIDArray.Count;i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | bResult = JsonConvert.SerializeObject(oBill.SaveICMOReportBill(InterIDArray[i].ToString(), user, BillNoArray[i].ToString(), OrganizationID)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //反序列化 | 
|---|
|  |  |  | bResult = "[" + bResult.ToString() + "]"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<JsonResult> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JsonResult>>(bResult); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (list[0].count == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HSuccessBillNo = HSuccessBillNo + BillNoArray[i].ToString()+"," + "\r\n" ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HFailBillNo = HFailBillNo + BillNoArray[i].ToString() + ":" + list[0].Message + "," + "\r\n"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HMessage = "汇报成功单号:" + HSuccessBillNo + "\r\n" + "  汇报失败单号:" + HFailBillNo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = HMessage; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 入库——生产汇报单 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sErr = ""; | 
|---|
|  |  |  | oSystemParameter.ShowBill(ref sErr); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取生产汇报单最大InterID和单据号 | 
|---|
|  |  |  | Int64 HInterID = DBUtility.ClsPub.CreateBillID("3711", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  | string HBillNo = DBUtility.ClsPub.CreateBillCode("3711", ref DBUtility.ClsPub.sExeReturnInfo, true); | 
|---|
|  |  |  | 
|---|
|  |  |  | FentityModel.Add("FFinishQty", item["接收数量"].ToString());//完成数量1 | 
|---|
|  |  |  | FentityModel.Add("FQuaQty", item["合格数量"].ToString());//合格数量1FFailQty | 
|---|
|  |  |  | FentityModel.Add("FFailQty", item["不良数量"].ToString());//不合格数量 | 
|---|
|  |  |  | FentityModel.Add("FScrapQty", item["报废数量"].ToString());//报废数量 | 
|---|
|  |  |  | FentityModel.Add("FStockInOrgId ", new JObject() { ["Fnumber"] = OrganizationNUM });// 入库组织 | 
|---|
|  |  |  | FentityModel.Add("FStockId", new JObject() { ["Fnumber"] = dr1["FStockNUM"].ToString() }); // 仓库 | 
|---|
|  |  |  | FentityModel.Add("FMOID", dr1["FMOID"].ToString());// | 
|---|
|  |  |  | 
|---|
|  |  |  | FentityModel.Add("FCostRate", dr1["FCostRate"].ToString());// 成本权重 | 
|---|
|  |  |  | FentityModel.Add("FISBACKFLUSH", dr1["FISBACKFLUSH"].ToString() == "1" ? true : false);// 倒冲领料 | 
|---|
|  |  |  | FentityModel.Add("FMOMAINENTRYID", dr1["FMOENTRYID"].ToString());// | 
|---|
|  |  |  | //FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() }); //包装标识 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | FentityModel.Add("F_bsv_Base1", new JObject() { ["Fnumber"] = dr1["FPREBDONENUMBER"].ToString() });//包装标识 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | FentityModel.Add("FLot", new JObject() { ["FNumber"] = dr1["FBATCHNO"].ToString() }); //批号 | 
|---|
|  |  |  | FentityModel.Add("F_bsv_Text", dr1["工序流转卡号"].ToString()); //流转卡号 | 
|---|
|  |  |  | JArray Fentity2 = new JArray(); | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.Message = "保存成功!"; | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | oCN.RollBack(); | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "Exception!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 入库——生产汇报单 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | /// <param name="InterID">工序汇报单主ID</param> | 
|---|
|  |  |  | /// <returns></returns> | 
|---|
|  |  |  | [Route("Sc_ProcessMangement/SaveProcdutInBill_Batch")] | 
|---|
|  |  |  | [HttpPost] | 
|---|
|  |  |  | public object SaveProcdutInBill_Batch([FromBody] JObject msg) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | var _value = msg["msg"].ToString(); | 
|---|
|  |  |  | string msg1 = _value.ToString(); | 
|---|
|  |  |  | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); | 
|---|
|  |  |  | string BillNo = sArray[0].ToString(); | 
|---|
|  |  |  | BillNo = BillNo.Replace("\r\n", "").Replace("[ ", "").Replace("]", ""); | 
|---|
|  |  |  | BillNo = BillNo.Replace("\\", "").Replace("\n", "").Replace("\"", ""); | 
|---|
|  |  |  | BillNo = BillNo.Trim(); | 
|---|
|  |  |  | ArrayList BillNoArray = new ArrayList(BillNo.Split(',')); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string bResult; | 
|---|
|  |  |  | string HMessage = ""; | 
|---|
|  |  |  | string HSuccessBillNo = ""; | 
|---|
|  |  |  | string HFailBillNo = ""; | 
|---|
|  |  |  | WebAPI.Controllers.Sc_ProcessMangementController oBill = new WebAPI.Controllers.Sc_ProcessMangementController(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (int i = 0; i < BillNoArray.Count; i++) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | bResult = JsonConvert.SerializeObject(oBill.SaveProcdutInBill(BillNoArray[i].ToString().Trim())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //反序列化 | 
|---|
|  |  |  | bResult = "[" + bResult.ToString() + "]"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<JsonResult> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JsonResult>>(bResult); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (list[0].count == 1) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HSuccessBillNo = HSuccessBillNo + BillNoArray[i].ToString() + "," + "\r\n"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | HFailBillNo = HFailBillNo + BillNoArray[i].ToString() + ":" + list[0].Message + "," + "\r\n"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HMessage = "入库成功单号:" + HSuccessBillNo + "\r\n" + "  入库失败单号:" + HFailBillNo; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = HMessage; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断唯一ID是否为空 | 
|---|
|  |  |  | foreach (DataRow item in ds1.Tables[0].Rows) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (item["HWYID"].ToString() == null || item["HWYID"].ToString() == "" || item["HWYID"].ToString() == "undefined") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "唯一ID为空,请重新手动入库或联系管理员!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //DataSet ds1 = oCN.RunProcReturn("select * from  h_v_TOERPProcduct_LastProc where HLastProc = '是' and  hbillno='" + BillNo.ToString() + "'", "h_v_TOERPProcduct_LastProc"); | 
|---|
|  |  |  | DataSet ds1 = oCN.RunProcReturn("exec h_p_TOERPProcduct_LastProc_BF '" + BillNo + "'", "h_p_TOERPProcduct_LastProc_BF"); | 
|---|
|  |  |  | if (ds1.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "操作失败,查不到对应的出站单据!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DataRow dr1 = ds1.Tables[0].Rows[0]; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JObject model = new JObject(); | 
|---|
|  |  |  | 
|---|
|  |  |  | FentityModel.Add("FSrcInterId", item["HSourceInterID"].ToString());// | 
|---|
|  |  |  | FentityModel.Add("FBasePrdRealQty", item["数量"].ToString());// | 
|---|
|  |  |  | FentityModel.Add("FIsFinished", "false");// | 
|---|
|  |  |  | FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT08_SYS" }); // | 
|---|
|  |  |  | FentityModel.Add("FStockStatusId", new JObject() { ["FNumber"] = "KCZT001" }); // | 
|---|
|  |  |  | FentityModel.Add("FSrcEntrySeq", item["HSourceSeQ"].ToString());//  源单分录行号 | 
|---|
|  |  |  | FentityModel.Add("FMOMAINENTRYID", item["HMOEntryID"].ToString());// | 
|---|
|  |  |  | FentityModel.Add("FKeeperTypeId", "BD_KeeperOrg"); | 
|---|
|  |  |  | 
|---|
|  |  |  | Int64 HSourceEntryID, string HSourceBillNo, string user, | 
|---|
|  |  |  | Int64 HWHID, Int64 HSPID, Int64 HSupID, Int64 HKeeperID, | 
|---|
|  |  |  | Int64 HMaterID, string HSourceBillType, Int64 HSLInterID, | 
|---|
|  |  |  | Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID) | 
|---|
|  |  |  | Int64 HSLEntryID, string HSLBillNo, Int64 HSLSeQ, string HBillNo, Int64 HInterID, string HBatchNo) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | FentityModel.Add("FBaseAcceptQty", HRightQty.ToString());//基本单位接收数 | 
|---|
|  |  |  | FentityModel.Add("FCurrency", new JObject() { ["Fnumber"] = "PRE001" });//币别 | 
|---|
|  |  |  | FentityModel.Add("FIsSplitRow ", false);// 是否拆分行 | 
|---|
|  |  |  | FentityModel.Add("FLot", new JObject() { ["Fnumber"] = HBatchNo.ToString() });//批号 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | JArray Fentity2 = new JArray(); | 
|---|
|  |  |  | JObject FentityModel2 = new JObject(); | 
|---|