Example #1
0
        /// <summary>
        /// 监控erp计划完成状态
        /// </summary>
        private void TaskHandleThread()
        {
            try
            {
                string restr = "";
                List <ERP_Plan_ReportModel> reportList = bllErpPlanReport.GetUnReportModelList();
                if (reportList == null || reportList.Count == 0)
                {
                    return;
                }
                for (int i = 0; i < reportList.Count; i++)
                {
                    ERP_Plan_ReportModel      erpPlan  = reportList[i];
                    List <View_PlanListModel> viewPlan = bllViewPlanList.GetCompleteModelByPlanCode(erpPlan.ERP_Plan_Code);
                    if (viewPlan == null || viewPlan.Count == 0)
                    {
                        continue;
                    }
                    JBS_Service_Manager jbsService = JBS_Service_Manager.GetServiceManager();
                    string jsonStr = "";
                    if (viewPlan[0].Plan_Type_InOut == "1")//入库
                    {
                        bool jsonGetStatus = jbsService.erpSvrPresenter.InHouseResponse(viewPlan, ref jsonStr, ref restr);
                        SendToErp(erpERL, "PuApi", jsonStr);
                        if (jsonGetStatus == true)
                        {
                            ERP_Plan_ReportModel erpPlanUpdate = bllErpPlanReport.GetModelByPlanCode(viewPlan[0].Plan_Code);
                            erpPlanUpdate.ERP_Plan_IsReported = true;
                            bllErpPlanReport.Update(erpPlanUpdate);
                        }

                        //调用erp接口
                        //object reObj = WCFHelper.WebHttpPost("http://localhost/WMS_To_ERP_Svc/MaterialPlanOrder", jsonStr, out restr);
                    }
                    else
                    {
                        bool jsonGetStatus = jbsService.erpSvrPresenter.OutHouseResponse(viewPlan, ref jsonStr, ref restr);
                        //调用erp接口
                        if (jsonGetStatus == true)
                        {
                            ERP_Plan_ReportModel erpPlanUpdate = bllErpPlanReport.GetModelByPlanCode(viewPlan[0].Plan_Code);
                            erpPlanUpdate.ERP_Plan_IsReported = true;
                            bllErpPlanReport.Update(erpPlanUpdate);
                        }
                        //出库不需要上报了erp定的
                        //  SendToErp(erpERL, "produceApi", jsonStr);
                        //调用erp接口
                        //object reObj = WCFHelper.WebHttpPost("http://localhost/WMS_To_ERP_Svc/MaterialPlanOrder", jsonStr, out restr);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("系统发送异常:" + ex.Message);
            }
        }
Example #2
0
        /// <summary>
        /// 出入库订单用一个接口,只是订单类型不同
        /// </summary>
        /// <param name="materialInBoundOrderJson"></param>
        /// <returns></returns>

        public string MaterialPlanOrder(string materialPlanOrderJson)
        {
            ResponseData response = new ResponseData();

            try
            {
                Console.WriteLine(materialPlanOrderJson);
                //materialPlanOrderJson = GetInBoundOrderTestJson();
                InHouseOrder inHouseOrder = Newtonsoft.Json.JsonConvert.DeserializeObject <InHouseOrder>(materialPlanOrderJson);
                if (inHouseOrder == null)
                {
                    response.Describe = "订单数据格式错误!";
                    response.Status   = false;
                    MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "提示", response.Describe + "信息内容:" + materialPlanOrderJson);
                    return(response.ToJson());
                }

                if (inHouseOrder.order_code == "")
                {
                    response.Describe = "订单编码不能为空!";
                    response.Status   = false;
                    MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "提示", response.Describe + "信息内容:" + materialPlanOrderJson);
                    return(response.ToJson());
                }
                if (inHouseOrder.InOut_Flag == "")
                {
                    response.Describe = "出入库标识不能为空!";
                    response.Status   = false;
                    MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "提示", response.Describe + "信息内容:" + materialPlanOrderJson);
                    return(response.ToJson());
                }
                //if (inHouseOrder.warehouse_code == "")
                //{
                //    response.Describe = "库房编码不能为空!";
                //    response.Status = false;
                //    MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "提示", response.Describe + "信息内容:" + materialPlanOrderJson);
                //    return response.ToJson();
                //}

                List <PlanListModel> planList = new List <PlanListModel>();
                foreach (OderMaterialInfo material in inHouseOrder.MaterilaList)
                {
                    PlanListModel plm = new PlanListModel();
                    plm.规格型号   = material.material_model;
                    plm.计划创建时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    plm.计划单号   = inHouseOrder.order_code;
                    plm.计划列表编码 = Guid.NewGuid().ToString();
                    plm.计划数量   = material.material_number;
                    plm.计量单位   = material.material_unit;
                    plm.物料编码   = material.material_code;
                    plm.物料名称   = material.material_name;
                    plm.物料批次   = material.material_batch;
                    planList.Add(plm);
                }
                string planTypeName = "";
                if (inHouseOrder.InOut_Flag.Trim() == "1")//入库
                {
                    planTypeName = "入库";
                }
                else//出库
                {
                    planTypeName = "出库";
                }

                string restr  = "";
                bool   status = wmsExtern.AddExternPlan(inHouseOrder.order_code, planTypeName,
                                                        inHouseOrder.order_maker, DateTime.Parse(inHouseOrder.order_date), inHouseOrder.warehouse_code, planList, inHouseOrder.order_voucherType, ref restr);
                if (status == false)
                {
                    response.Describe = "入库订单数据导入失败!" + restr;
                    response.Status   = false;
                    MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "提示", response.Describe + "信息内容:" + materialPlanOrderJson);
                    return(response.ToJson());
                }
                ERP_Plan_ReportModel existPlan = bllErpPlanReport.GetModelByPlanCode(inHouseOrder.order_code);
                if (existPlan == null)
                {
                    ERP_Plan_ReportModel erpReport = new ERP_Plan_ReportModel();
                    erpReport.ERP_Plan_Code           = inHouseOrder.order_code;
                    erpReport.ERP_Plan_IsReported     = false;
                    erpReport.ERP_Plan_Report_Content = materialPlanOrderJson;
                    erpReport.ERP_Plan_Report_ID      = Guid.NewGuid().ToString();
                    bllErpPlanReport.Add(erpReport);
                }

                response.Describe = "订单数据导入成功!";
                response.Status   = true;
                MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "提示", response.Describe + "信息内容:" + materialPlanOrderJson);
                return(response.ToJson());
            }
            catch (Exception ex)
            {
                response.Describe = "订单数据导入失败!错误原因:" + ex.StackTrace.ToString();
                response.Status   = false;
                MainFrameHandler.GetMainFrame().WriteLog("WMS_To_ERP服务", "", "错误", response.Describe + "信息内容:" + materialPlanOrderJson);
                return(response.ToJson());
            }
        }