/// <summary> /// WMS 接收差异移库退单 /// </summary> /// <param name="sapDtros"></param> /// <returns></returns> public MessWms TransDtro(SapDtro[] sapDtros) { try { _logInfo.Info("TransDtro", "开始接收差异移库单\r\n"); AppConfig.Cache.IsAutoCache = false; AppConfig.Debug.OpenDebugInfo = true; if (sapDtros.Length > 0) { foreach (SapDtro bean in sapDtros) { SapDtrd[] sapDtrds = bean.sapDtrds; //取出明细 using (MAction action = new MAction("DTRO")) { action.BeginTransation(); action.AllowInsertID = false; //插入表头 action.Set("EBELN_T", bean.EbelnT); action.Set("EBELN_Y", bean.EbelnY); action.Set("BLDAT", CastUtil.CastDateTime(bean.Bldat)); action.Set("BNAME", bean.Bname); action.Set("EKGRP", bean.Ekgrp); bool issuccess = action.Insert(true); //插入明细表 action.ResetTable("DTRD", true); foreach (SapDtrd item in sapDtrds) { _logInfo.Info("TransDtro", "开始处理差异移库单:[" + bean.EbelnT + "]-[" + item.Matnr + "]\r\n"); action.Set("EBELN_T", bean.EbelnT); action.Set("Matnr", item.Matnr); action.Set("MAKTX", item.Maktx); action.Set("MENGE", CastUtil.CastDecimal(item.Menge)); action.Set("MEINS", item.Meins); action.Set("Werks", item.Werks); action.Set("LGORT_C", item.LgortC); action.Set("LGORT_R", item.LgortR); action.Insert(true); _logInfo.Info("TransDtro", action.DebugInfo + "\r\n"); } action.EndTransation();//处理 } } //写日志 _logInfo.Info("TransDtro", "差异移库单写入完毕\r\n"); } } catch (Exception e) { throw e; } return(new MessWms() { TYPE = MessWms.success, Mess = "处理成功!" }); }
/// <summary> /// WMS获取请配单 /// </summary> /// <returns></returns> public MessWms SetDeldet(SapDelo [] tasks) { _logInfo.Debug("Setputorder", "开始处理请配单\r\n"); try { AppConfig.Cache.IsAutoCache = false; AppConfig.Debug.OpenDebugInfo = true; foreach (SapDelo Demodel in tasks) { StringUtil <SapDelo> @delo = new StringUtil <SapDelo>(); _logInfo.Debug("Setputorder", "开始处理请配单表头:{[" + @delo.GetEntityToString(Demodel) + "]}\r\n"); SapDeld [] sapdelds = Demodel._delds; //取出明细 using (MAction action = new MAction("DELO")) { action.BeginTransation(); action.AllowInsertID = false; //插入表头 action.Set("Ebeln", Demodel.Ebeln); action.Set("Bsart", Demodel.Bsart); action.Set("Zjj", Demodel.Zjj); action.Set("Zfree", Demodel.Zfree); action.Set("Ztype", Demodel.Ztype); action.Set("Reswk", Demodel.Reswk); action.Set("Ekgrp", Demodel.Ekgrp); action.Set("Reslo", Demodel.Reslo); action.Set("Kunnr", Demodel.Kunnr); action.Set("Znwx", Demodel.Znwx); action.Set("Zregz", Demodel.Zregz); action.Set("EINDT", CastUtil.CastDateTime(Demodel.Eindt)); action.Set("Zbz", Demodel.Zbz); action.Set("Ernam", Demodel.Ernam); action.Set("AEDAT", CastUtil.CastDateTime(Demodel.Aedat)); action.Set("VSBED", Demodel.VSBED); action.Set("RETPO", Demodel.RETPO); action.Set("EbelnO", Demodel.EbelnO); bool issuccess = action.Insert(true); //插入明细表 action.ResetTable("DELD", true); foreach (SapDeld sapDeld in sapdelds) { StringUtil <SapDeld> @deld = new StringUtil <SapDeld>(); _logInfo.Debug("Setputorder", "开始处理请配单明细:{[" + @deld.GetEntityToString(sapDeld) + "]}\r\n"); action.Set("Ebeln", Demodel.Ebeln); action.Set("Ebelp", sapDeld.Ebelp); action.Set("Matnr", sapDeld.Matnr); action.Set("Maktx", sapDeld.Maktx); action.Set("Werks", sapDeld.Werks); action.Set("Menge", sapDeld.Menge); action.Set("Zbatch", sapDeld.Zbatch); action.Set("Zwmcw", sapDeld.Zwmcw); action.Set("DATBI", CastUtil.CastDateTime(sapDeld.Datbi)); action.Set("Charg", sapDeld.Charg); action.Set("Meins", sapDeld.Meins); action.Set("Wrbtr", sapDeld.Wrbtr); action.Set("Netpr", sapDeld.Netpr); action.Insert(true); _logInfo.Debug("SetDeldet", Demodel.Ebeln + "||" + action.DebugInfo + "\r\n"); } action.EndTransation();//处理 } } //写日志 _logInfo.Debug("TransTask", "请配单写入完毕\r\n"); } catch (Exception Ex) { _logInfo.Debug("TransTask", "请配单异常\r\n" + Ex); return(new MessWms() { TYPE = MessWms.failure, Mess = "处理失败!" + Ex.Message }); } return(new MessWms() { TYPE = MessWms.success, Mess = "处理成功!" }); }
/// <summary> /// WMS 处理 越库单 /// </summary> /// <param name="overruns"></param> /// <returns></returns> public MessWms TransOverRun(SapOverrun[] overruns) { _logInfo.Info("TransOverRun", "开始处理越库单\r\n"); StringUtil <SapOverrun> pf = new StringUtil <SapOverrun>(); try { AppConfig.Cache.IsAutoCache = false; AppConfig.Debug.OpenDebugInfo = true; foreach (SapOverrun komodel in overruns) { _logInfo.Info("TransOverRun", "单条:\r\n" + pf.GetEntityToString(komodel)); using (MAction action = new MAction("overrun")) { action.BeginTransation(); //查询本条数据 是否需要更新 action.SetSelectColumns(new string[] { "Elben" });//返回的字段 List <SapOverrun> beans = action.Select("Elben='" + komodel.Elben + "' and Matnr='" + komodel.Matnr + "'").ToList <SapOverrun>(); //如若 lfa1s.Count > 0,执行更新 if (beans != null && beans.Count > 0) { _logInfo.Debug("TransOverRun", "越库单号" + komodel.Elben + "重复传输!\r\n"); continue; } action.AllowInsertID = false; //插入表头 action.Set("Elben", komodel.Elben); action.Set("Elben2", komodel.Elben2); action.Set("Lgort", komodel.Lgort); action.Set("EKGRP", komodel.Ekgrp); action.Set("Retpo", komodel.Retpo); action.Set("Lifnr", komodel.Lifnr); action.Set("Reswk", komodel.Reswk); action.Set("Ernam", komodel.Ernam); action.Set("Aedat", CastUtil.CastDateTime(komodel.Aedat)); action.Set("Elelp", komodel.Elelp); action.Set("Matnr", komodel.Matnr); action.Set("MAKTX", komodel.Maktx); action.Set("Menge", komodel.Menge); action.Set("Meins", komodel.Meins); action.Set("Wrbtr1", komodel.Wrbtr1); action.Set("Netpr1", komodel.Netpr1); action.Set("Wrbtr2", komodel.Wrbtr2); action.Set("Netpr2", komodel.Netpr2); action.Set("Kunnr", komodel.Kunnr); action.Set("Zregz", komodel.Zregz); action.Set("Zbz", komodel.Zbz); action.Set("wmscode", "Y" + komodel.Elben); action.Set("pflag", "N"); action.Set("ts", DateTime.Now); bool issuccess = action.Insert(true); action.EndTransation(); //写日志 _logInfo.Debug("TransOverRun", komodel.Elben + action.DebugInfo + "\r\n"); } } } catch (Exception ex) { _logInfo.Error("TransOverRun", ex.ToString() + "\r\n"); return(new MessWms() { TYPE = MessWms.failure, Mess = "处理失败!" + ex.Message }); } return(new MessWms() { TYPE = MessWms.success, Mess = "处理成功!" }); }
/// <summary> /// 商品主数据接收 /// </summary> /// <returns></returns> public MessWms SetMainKi(SapMakt[] sapMakts) { _logInfo.Info("SetMainKi", " wms 开始接收商品主数据\r\n"); try { AppConfig.Cache.IsAutoCache = false; AppConfig.Debug.OpenDebugInfo = true; foreach (SapMakt item in sapMakts) { SapMarc[] SapMarcs = item.SapMarcs; SapMarm[] SapMarms = item.SapMarms; SapMean[] SapMeans = item.SapMeans; StringUtil <SapMakt> pf = new StringUtil <SapMakt>(); _logInfo.Info("SetMainKi", "单条 SapMakt @:\r\n" + pf.GetEntityToString(item)); using (MAction action = new MAction("MAKT")) //主表 { action.BeginTransation(); //提交事务 //查询本条数据 是否需要更新 action.SetSelectColumns(new string[] { "id", "Matnr" });//返回的字段 List <SapMakt> lfa1s = action.Select("Matnr='" + item.Matnr + "'").ToList <SapMakt>(); //如若 lfa1s.Count > 0,执行更新 if (lfa1s != null && lfa1s.Count > 0) { if (!action.Delete("Matnr='" + item.Matnr + "'")) { _logInfo.Error("SetMainKi", "删除重复数据失败\r\n"); action.RollBack(); return(new MessWms() { TYPE = MessWms.failure, Mess = "Trans failure !更新商品主数据失败, Matnr:" + item.Matnr }); } } action.AllowInsertID = false; //插入表头 action.Set("Matnr", item.Matnr); action.Set("Maktx", item.Maktx); action.Set("Maktm", item.Maktm); action.Set("MAKTX_E", item.Maktxe); action.Set("Mtart", item.Mtart); action.Set("Attyp", item.Attyp); action.Set("Matkl", item.Matkl); action.Set("Prdha", item.Prdha); action.Set("Zbrand", item.Zbrand); action.Set("Wherl", item.Wherl); action.Set("Wherr", item.Wherr); action.Set("Groes", item.Groes); action.Set("Taxm1", item.Taxm1); action.Set("Xchpf", item.Xchpf); action.Set("Hoehe", CastUtil.CastDecimal(item.Hoehe)); action.Set("Breit", CastUtil.CastDecimal(item.Breit)); action.Set("Laeng", CastUtil.CastDecimal(item.Laeng)); action.Set("Meabm", item.Meabm); action.Set("Mhdhb", CastUtil.CastDecimal(item.Mhdhb)); action.Set("Iprkz", item.Iprkz); action.Set("Raube", item.Raube); action.Set("Idnrk", item.Idnrk); action.Set("Tempb", item.Tempb); action.Set("Ferth", item.Ferth); action.Set("Iloos", item.Iloos); action.Set("Zyear", item.Zyear); action.Set("Zseason", item.Zseason); action.Set("Color", item.Color); action.Set("Size1", item.Size1); action.Set("FSH_SC_VCONV", item.FshScVconv); action.Set("Labor", item.Labor); bool issuccess = action.Insert(true); //插入明细表 action.ResetTable("MARC", true); //如若 lfa1s.Count > 0,执行更新 if (lfa1s != null && lfa1s.Count > 0) { if (!action.Delete("Matnr='" + item.Matnr + "'")) { _logInfo.Error("SetMainKi", "删除重复数据 MARC 失败\r\n"); action.RollBack(); return(new MessWms() { TYPE = MessWms.failure, Mess = "Trans failure !更新商品主数据失败, Matnr:" + item.Matnr }); } } foreach (SapMarc marcs in SapMarcs) { StringUtil <SapMarc> pf2 = new StringUtil <SapMarc>(); _logInfo.Info("SetMainKi", "单条 SapMarc @:\r\n" + pf2.GetEntityToString(marcs)); action.Set("Matnr", item.Matnr); action.Set("Asort", marcs.Asort); action.Set("Werks", marcs.Werks); action.Set("Datbi", CastUtil.CastDateTime(marcs.Datbi)); action.Set("Datab", CastUtil.CastDateTime(marcs.Datab)); action.Set("Mmsta", marcs.Mmsta); action.Set("Xmcng", marcs.Xmcng); action.Set("CONS_PROCG", marcs.ConsProcg); action.Set("Mwsk1", marcs.Mwsk1); action.Set("Zdsj", CastUtil.CastDecimal(marcs.Zdsj)); action.Set("Kbetr", CastUtil.CastDecimal(marcs.Kbetr)); action.Set("Zp03", CastUtil.CastDecimal(marcs.Zp03)); action.Set("Ekgrp", marcs.Ekgrp); action.Insert(true); } //插入明细表 action.ResetTable("MARM", true); //如若 lfa1s.Count > 0,执行更新 if (lfa1s != null && lfa1s.Count > 0) { if (!action.Delete("Matnr='" + item.Matnr + "'")) { _logInfo.Error("SetMainKi", "删除重复数据 MARM 失败\r\n"); action.RollBack(); return(new MessWms() { TYPE = MessWms.failure, Mess = "Trans failure !更新商品主数据失败, Matnr:" + item.Matnr }); } } foreach (SapMarm marms in SapMarms) { StringUtil <SapMarm> pf3 = new StringUtil <SapMarm>(); _logInfo.Info("SetMainKi", "单条 SapMarm @:\r\n" + pf3.GetEntityToString(marms)); action.Set("Matnr", item.Matnr); action.Set("Umrez", CastUtil.CastDecimal(marms.Umrez)); action.Set("Meins", marms.Meins); action.Set("Maktm", marms.Maktm); action.Set("Umren", CastUtil.CastDecimal(marms.Umren)); action.Set("Meinh", marms.Meinh); action.Insert(true); } //插入明细表 action.ResetTable("MEAN", true); //如若 lfa1s.Count > 0,执行更新 if (lfa1s != null && lfa1s.Count > 0) { if (!action.Delete("Matnr='" + item.Matnr + "'")) { _logInfo.Error("SetMainKi", "删除重复数据 MEAN 失败\r\n"); action.RollBack(); return(new MessWms() { TYPE = MessWms.failure, Mess = "Trans failure !更新商品主数据失败, Matnr:" + item.Matnr }); } _logInfo.Error("SetMainKi", "删除重复数据 MEAN 成功\r\n"); } foreach (SapMean means in SapMeans) { StringUtil <SapMean> pf4 = new StringUtil <SapMean>(); _logInfo.Info("SetMainKi", "单条 SapMean @:\r\n" + pf4.GetEntityToString(means)); action.Set("Matnr", item.Matnr); action.Set("Eantp", means.Eantp); action.Set("EAN11", means.Ean11); action.Insert(true); } action.EndTransation(); //写日志 _logInfo.Debug("SetMainKi", item.Matnr + action.DebugInfo + "\r\n"); } } } catch (Exception ex) { _logInfo.Error("SetMainKi", ex.ToString() + "\r\n"); return(new MessWms() { TYPE = MessWms.failure, Mess = "处理失败!" + ex.Message }); } return(new MessWms() { TYPE = MessWms.success, Mess = "处理成功!" }); }
/// <summary> /// WMS 接收大库调配 /// </summary> /// <param name="sapAllots"></param> /// <returns></returns> public MessWms TransAllot(SapAllot[] sapAllots) { _logInfo.Info("TransAllot", "开始处理大库请配"); AppConfig.Cache.IsAutoCache = false; AppConfig.Debug.OpenDebugInfo = true; try { foreach (SapAllot allot in sapAllots) { StringUtil <SapAllot> @string = new StringUtil <SapAllot>(); _logInfo.Info("TransAllot", @string.GetEntityToString(allot)); SapAllotdet[] sapAllotdet = allot.Allotdets; using (MAction action = new MAction("allot")) { action.BeginTransation(); action.AllowInsertID = false; action.Set("purcode", allot.Purcode); action.Set("purdate", CastUtil.CastDateTime(allot.Purdate)); action.Set("storeno", allot.Storeno); action.Set("grpno", allot.Grpno); action.Set("outshop", allot.Outshop); action.Set("inshop", allot.Inshop); action.Set("remark", allot.Remark); action.Set("wareno", allot.Wareno); action.Set("stat", "1"); action.Set("hzstat", "N"); action.Set("printflag", "N"); action.Set("pcnt", 0); action.Set("sendflag", "N"); action.Set("pcnt", 0); action.Insert(true); action.ResetTable("Allotdet", true); foreach (SapAllotdet @Allotdet in sapAllotdet) { action.AllowInsertID = false; action.Set("purcode", allot.Purcode); action.Set("incode", @Allotdet.Incode); action.Set("fname", @Allotdet.Fname); action.Set("Unit", @Allotdet.Unit); action.Set("qty", @Allotdet.Qty); action.Set("sqty", @Allotdet.Sqty); action.Set("rprc", @Allotdet.Rprc); action.Set("outprc", @Allotdet.Outprc); } action.BeginTransation(); _logInfo.Info("TransAllot", action.DebugInfo); } } _logInfo.Info("TransAllot", "大库请配单 处理完毕"); } catch (Exception ex) { _logInfo.Error("TransAllot", ex.ToString() + "\r\n"); return(new MessWms() { TYPE = MessWms.failure, Mess = "处理失败!" + ex.Message }); } return(new MessWms() { TYPE = MessWms.success, Mess = "处理成功!" }); }