Beispiel #1
0
        /// <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 = "处理成功!"
            });
        }
Beispiel #2
0
        /// <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 = "处理成功!"
            });
        }