Exemple #1
0
        private string GetInBoundOrderTestJson()
        {
            InHouseOrder inHouseOrder = new InHouseOrder();

            inHouseOrder.order_code        = "K8";
            inHouseOrder.order_date        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            inHouseOrder.order_maker       = "admin";
            inHouseOrder.order_voucherType = "采购接收";
            inHouseOrder.warehouse_code    = "A1";
            OderMaterialInfo materialInfo = new OderMaterialInfo();

            materialInfo.material_batch    = "b123";
            materialInfo.material_code     = "LSTL0001";
            materialInfo.material_makedate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            materialInfo.material_model    = "TB009";
            materialInfo.material_name     = "极片";
            materialInfo.material_unit     = "片";
            materialInfo.material_number   = "2";

            OderMaterialInfo materialInfo2 = new OderMaterialInfo();

            materialInfo2.material_batch    = "b123";
            materialInfo2.material_code     = "KS-60001";
            materialInfo2.material_makedate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            materialInfo2.material_model    = "TB009";
            materialInfo2.material_name     = "极片";
            materialInfo2.material_unit     = "片";
            materialInfo2.material_number   = "2.3";
            List <OderMaterialInfo> materialList = new List <OderMaterialInfo>();

            materialList.Add(materialInfo);
            materialList.Add(materialInfo2);
            inHouseOrder.MaterilaList = materialList;
            return(Newtonsoft.Json.JsonConvert.SerializeObject(inHouseOrder));
        }
Exemple #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());
            }
        }