示例#1
0
        /// <summary>
        /// 获取单据同步数据Json
        /// </summary>
        /// <param name="StockType">类型 10:入库 20:出库  99:基础资料</param>
        /// <param name="LastSyncTime">最后同步时间</param>
        /// <param name="ErpVoucherNo">ERP单号</param>
        /// <param name="wmsVourcherType">wms单据类型</param>
        /// <param name="db"></param>
        /// <returns></returns>
        private static string GetErpJson(int StockType, string LastSyncTime, string ErpVoucherNo, ParamaterField_Model Type, ParamaterFiled_DB db)
        {
            //取最后同步时间或者最大ERP单号单号
            //ERP单据号不为空的情况下,查询该单据的最后同步时间
            string lastSyncErpVoucherNo = String.Empty;

            if (!String.IsNullOrEmpty(ErpVoucherNo))
            {
                LastSyncTime = db.GetLastSyncTime(StockType, ErpVoucherNo);
            }
            else
            {
                if (StockType != 99) //99:基础资料同步
                {
                    //获取最大单号特殊处理
                    lastSyncErpVoucherNo = db.getLastSyncErpVoucherNo(StockType, Type.VoucherType.ToString(), Type.ErpVouType, Type.ErpVourcherType);
                }
            }
            BILBasic.Interface.T_Interface_Func TIF = new BILBasic.Interface.T_Interface_Func();
            string json = "{\"code\":\"" + ErpVoucherNo + "\",\"VoucherType\":\"" + Type.VoucherType.ToString() + "\",\"max_code\":\"" + lastSyncErpVoucherNo + "\",\"sync_time\":\"";

            json += !String.IsNullOrEmpty(LastSyncTime)?DateTime.Parse(LastSyncTime).ToString("yyyy-MM-dd"):"";
            json += "\",\"erp_vourcher_type\":\"" + Type.ErpVourcherType + "\"}";
            return(TIF.GetModelListByInterface(json));
        }
示例#2
0
        /// <summary>
        /// 获取SAP服务器时间
        /// </summary>
        /// <param name="para"></param>
        /// <returns></returns>
        internal static string GetSAPServerTime(string para)
        {
            BILBasic.Interface.T_Interface_Func TIF = new BILBasic.Interface.T_Interface_Func();
            string json = "{\"VoucherType\":\"" + para + "\"}";

            return(TIF.GetModelListByInterface(json));
            // return "2018-01-01";
        }
示例#3
0
        public bool SubmitMesStatus(string returnJson, ref string errMsg)
        {
            BILBasic.Interface.T_Interface_Func TIF = new BILBasic.Interface.T_Interface_Func();
            string result = TIF.PostModelListToInterface(returnJson);
            BaseMessage_Model <WOReturnModel> model = new BaseMessage_Model <WOReturnModel>();

            model = JsonConvert.DeserializeObject <BaseMessage_Model <WOReturnModel> >(result);
            if (model.HeaderStatus == "E" && !string.IsNullOrEmpty(model.Message))
            {
                errMsg = model.Message;
                return(false);
            }
            return(true);
        }
示例#4
0
        /// <summary>
        /// 获取ERP数据
        /// </summary>
        /// <param name="type">单据类型</param>
        /// <param name="lastSyncTime">最后同步时间</param>
        /// <returns></returns>
        private string GetERPInfo(int stockType, string companyNo, string erpvouType, string wmsvouType, string ErpVoucherNo, string lastSyncTime)
        {
            //ERP单据号不为空的情况下,查询该单据的最后同步时间
            string            lastSyncErpVoucherNo = String.Empty;
            ParamaterFiled_DB db = new ParamaterFiled_DB();

            if (!String.IsNullOrEmpty(ErpVoucherNo))
            {
                lastSyncTime = db.GetLastSyncTime(stockType, ErpVoucherNo, companyNo, erpvouType);
            }
            else
            {
                if (stockType != 99)
                {
                    lastSyncErpVoucherNo = db.getLastSyncErpVoucherNo(stockType, wmsvouType, companyNo, erpvouType);// companyNo + "-" + erpvouType + "-" + "1702150000";//
                }
            }

            if (wmsvouType == "24" || wmsvouType == "23")//|| wmsvouType == "23"
            {
                lastSyncErpVoucherNo = string.Empty;
                if (String.IsNullOrEmpty(lastSyncTime))
                {
                    lastSyncTime = DateTime.Parse(lastSyncTime).AddDays(-10).ToString("yyyy-MM-dd");
                }
                else
                {
                    lastSyncTime = DateTime.Now.AddDays(-10).ToString("yyyy-MM-dd");
                }
            }

            BILBasic.Interface.T_Interface_Func TIF = new BILBasic.Interface.T_Interface_Func();
            // lastSyncErpVoucherNo = "CY1-PO1-1607020001";
            //string json = "{\"ErpVoucherNo\":\"" + ErpVoucherNo + "\",\"lastSyncErpVoucherNo\":\"" + lastSyncErpVoucherNo + "\",\"VoucherType\":\"" + wmsvouType + "\",\"ErpVoucherType\":\"" + erpvouType + "\",\"datetime\":\"" + lastSyncTime + "\"}";

            string stringVoucherNo = ErpVoucherNo.ToUpper().Contains("NSH") || ErpVoucherNo.ToUpper().Contains("RK7") ? "\"data_no1\":\"" + ErpVoucherNo : "\"data_no\":\"" + ErpVoucherNo;
            string json            = "{" + stringVoucherNo + "\",\"data_maxno\":\"" + lastSyncErpVoucherNo + "\",\"data_type\":\"" + erpvouType + "\",\"VoucherType\":\"" + wmsvouType + "\",\"companyNo\":\"" + companyNo + "\",\"edit_time\":\"" + DateTime.Parse(lastSyncTime).ToString("yyyy-MM-dd") + "\"}";

            //    string para = String.Format(json, type, lastSyncTime);
            return(TIF.GetModelListByInterface(json));
        }
示例#5
0
        internal static string GetSAPJson(int StockType, string erpVoucherNo, Sync_Model Type, ref SyncTime_Model syncTime)
        {
            syncTime = SyncTimeManager.GetInstance().GetLastSyncTime(Type.WmsType);
            if (syncTime == null)
            {
                syncTime = new SyncTime_Model();
                syncTime.SyncServerTime = DateTime.Now.AddDays(Convert.ToInt32(ConfigurationManager.ConnectionStrings["SyncAddDate"].ConnectionString)).ToString("yyyyMMdd,HHmmss");
                syncTime.WmsType        = Type.WmsType;
                syncTime.ID             = 0;
            }

            BILBasic.Interface.T_Interface_Func TIF = new BILBasic.Interface.T_Interface_Func();
            string json = "{\"code\":\"" + erpVoucherNo + "\",\"VoucherType\":\"" + Type.WmsType.ToString() + "\",\"sync_time\":\"";

            json += syncTime.SyncServerTime;
            json += "\",\"erp_vourcher_type\":\"" + Type.ErpType + "\"}";
            LogNet.SyncInfo(json);
            return //"{\"result\":1,\"resultValue\":\"\",\"data\":[{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431000180890\",\"cinvname\":\"LED消防应急标志灯线下款06  双面安全出口\",\"cinvstd\":\"NEP-XBZ06-021\",\"cbarcode\":\"2222220002565\",\"cinvdefine6\":\"883675\",\"cumName\":\"只\"}},{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431000180906\",\"cinvname\":\"LED消防应急标志灯线下款08   嵌入式左向\",\"cinvstd\":\"NEP-XBZ08-012\",\"cbarcode\":\"2222220002581\",\"cinvdefine6\":\"883691\",\"cumName\":\"只\"}},{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431001120306\",\"cinvname\":\"吸顶吊灯24 铜本色 玻璃灯罩 标配E27螺纹灯头,负载单头最大功率40W,整灯240W,出货不配光源\",\"cinvstd\":\"NEP-XDD24240X4\",\"cbarcode\":\"6941461102961\",\"cinvdefine6\":\"209479\",\"cumName\":\"只\"}},{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431001120322\",\"cinvname\":\"吸顶灯218 108W  双色 白色 方形\",\"cinvstd\":\"NEP-XD21810881-F\",\"cbarcode\":\"6941461103272\",\"cinvdefine6\":\"209510\",\"cumName\":\"只\"}},{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431001730064\",\"cinvname\":\"吸顶灯124款 32W 双色温  粉色面罩带厚亚克力\",\"cinvstd\":\"NEP-XD12403284-Y\",\"cbarcode\":\"6941461106815\",\"cinvdefine6\":\"209864\",\"cumName\":\"只\"}},{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431002170341\",\"cinvname\":\"线下新型筒灯22 3.5W 银色(铝面环) 6000K\",\"cinvstd\":\"NEP-TD2200363A\",\"cbarcode\":\"6941461103265\",\"cinvdefine6\":\"209509\",\"cumName\":\"只\"}},{\"head\":{\"cwhcode\":null,\"cwhname\":null,\"iquantity\":null,\"cinvcode\":\"710431000260017\",\"cinvname\":\"LED筒灯27 18W 白色 3000K\",\"cinvstd\":\"NEP-TD2701831G\",\"cbarcode\":\"2222220002644\",\"cinvdefine6\":\"883754\",\"cumName\":\"只\"}}]}";
                   //"{\"result\":1,\"resultValue\":\"\",\"data\":[{\"head\":{\"body\":[{\"cwhcode1\":\"013\",\"cbmemo\":\"\",\"boxQty\":10,\"rQty\":0,\"packQty\":1,\"cwhname\":\"\",\"cwhcode\":\"013\",\"cinvcode\":\"710431001120181\",\"cinvname\":\"吸顶灯188款,白色灯罩,12头组合,192W,3000K+5700K\",\"cinvstd\":\"NEP-XD18819281\",\"iquantity\":10.00,\"foutquantity\":10.0000000000,\"Qty\":0.0000000000,\"Qty1\":0.0000000000,\"itaxunitprice\":0.0,\"itaxrate\":0.0,\"invbatch\":null,\"irowno\":1,\"iunitprice\":0.0,\"itax\":0.0,\"cdlcode\":\"FH1811230008\",\"ccuscode\":\"10097701\",\"ccusname\":null,\"idlsid\":1002675166},{\"cwhcode1\":\"013\",\"cbmemo\":\"\",\"boxQty\":10,\"rQty\":0,\"packQty\":1,\"cwhname\":\"\",\"cwhcode\":\"013\",\"cinvcode\":\"710431001120181\",\"cinvname\":\"吸顶灯188款,白色灯罩,12头组合,192W,3000K+5700K\",\"cinvstd\":\"NEP-XD18819281\",\"iquantity\":10.00,\"foutquantity\":10.0000000000,\"Qty\":0.0000000000,\"Qty1\":0.0000000000,\"itaxunitprice\":0.0,\"itaxrate\":0.0,\"invbatch\":null,\"irowno\":2,\"iunitprice\":0.0,\"itax\":0.0,\"cdlcode\":\"FH1811230008\",\"ccuscode\":\"10097701\",\"ccusname\":null,\"idlsid\":1002675167}],\"ccusphone\":\"0551-64369575\",\"ccusperson\":\"王世珍\",\"DLID\":1000385412,\"cDLCode\":\"FH1811230008\",\"dDate\":\"2018-11-23T00:00:00\",\"cRdCode\":null,\"cDepCode\":\"030901\",\"cDepName\":\"营业\",\"cPersonCode\":null,\"cSOCode\":null,\"cCusCode\":\"10097701\",\"cCusAddress\":null,\"cShipAddress\":\"0551-64369575 15605699888 安徽省合肥市瑶海区瑶海工业园灵石路中段安徽百事兴电气有限公司 正泰仓库\",\"cexch_name\":\"\",\"iExchRate\":0.0,\"iTaxRate\":0.0,\"cMemo\":\"照明\",\"cDefine1\":null,\"cDefine2\":\"\",\"cDefine3\":\"\",\"cDefine4\":null,\"cDefine5\":null,\"cDefine6\":null,\"cDefine7\":null,\"cDefine8\":null,\"cDefine9\":\"\",\"cDefine10\":\"\",\"cDefine11\":\"\",\"cDefine12\":null,\"cDefine13\":\"\",\"cDefine14\":null,\"cDefine15\":null,\"cDefine16\":null,\"cMaker\":\"demo\",\"cCusName\":\"王世珍-安徽百事兴电气有限公司\",\"cBusType\":\"普通销售\"}}]}";
                   (TIF.GetModelListByInterface(json));
        }
示例#6
0
        public string PostZh(string UserJson, string ModelJson, string Guid)
        {
            BaseMessage_Model <List <T_OutBarCodeInfo> > messageModel = new BaseMessage_Model <List <T_OutBarCodeInfo> >();

            try
            {
                string strError = "";
                if (Guid != "")
                {
                    if (!CheckGuid(Guid, ref strError))
                    {
                        messageModel.HeaderStatus = "E";
                        messageModel.Message      = "GUID已经存在,不能重复提交-" + strError;
                        return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(messageModel));
                    }
                }

                if (string.IsNullOrEmpty(UserJson) || string.IsNullOrEmpty(ModelJson) || string.IsNullOrEmpty(Guid))
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = "参数不能为空";
                    return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(messageModel));
                }

                List <U9Zh> modelList = JSONHelper.JsonToObject <List <U9Zh> >(ModelJson);
                UserModel   user      = JSONHelper.JsonToObject <UserModel>(UserJson);

                modelList.ForEach(t => t.PostUser = user.UserNo);
                modelList.ForEach(t => t.GUID     = Guid);

                modelList.ForEach(item =>
                {
                    item.PostUser = user.UserName;
                    item.GUID     = Guid;

                    List <U9ZhDetail> detail = new List <U9ZhDetail>();
                    //检验明细里面有没有重复的条码
                    item.detail.ForEach(itemdetail => {
                        foreach (var barcode in itemdetail.barcodeList)
                        {
                            U9ZhDetail itemdetailLimk = T_Material_Batch_DB.DeepCopyByXml <U9ZhDetail>(itemdetail);
                            itemdetailLimk.Qty        = barcode.Qty;
                            itemdetailLimk.BatchNo    = barcode.BatchNo;
                            detail.Add(itemdetailLimk);
                        }
                    });
                    item.detail = detail;
                });


                //modelList.ForEach(item=> {
                //    item.PostUser = user.UserNo;
                //    item.GUID = Guid;

                //    if (item.Type == 0 && item.barcodeList.Count > 0)
                //    {
                //        item.BatchNo = item.barcodeList[0].BatchNo;
                //    }
                //    if (item.Type == 1 && item.barcodeList.Count == item.detail.Count)
                //    {
                //        //扫描的条码给明细行赋值
                //        for (int i = 0; i < item.detail.Count; i++)
                //        {
                //            for (int j = 0; j < item.barcodeList.Count; j++)
                //            {
                //                if (item.detail[i].MaterialNo == item.barcodeList[j].MaterialNo)
                //                {
                //                    item.detail[i].BatchNo = item.barcodeList[j].BatchNo;
                //                }
                //            }
                //        }
                //    }

                //});


                string ERPJson = BILBasic.JSONUtil.JSONHelper.ObjectToJson <List <U9Zh> >(modelList);

                BILBasic.Interface.T_Interface_Func tfunc = new BILBasic.Interface.T_Interface_Func();
                LogNet.LogInfo("---------------------------ERPJsonBefore:" + ERPJson);
                string interfaceJson = tfunc.PostModelListToInterface(ERPJson);

                messageModel = BILBasic.JSONUtil.JSONHelper.JsonToObject <BaseMessage_Model <List <T_OutBarCodeInfo> > >(interfaceJson);

                LogNet.LogInfo("--------------------------ERPJsonAfter:" + messageModel);

                //过账失败直接返回
                if (messageModel.HeaderStatus == "E" && !string.IsNullOrEmpty(messageModel.Message))
                {
                    return(interfaceJson);
                }
                else if (messageModel.HeaderStatus == "S" && !string.IsNullOrEmpty(messageModel.MaterialDoc)) //过账成功,并且生成了凭证要记录数据库
                {
                    modelList.ForEach(t => t.MaterialDoc = messageModel.MaterialDoc);
                }

                LogNet.LogInfo("ymh:ERPtoWMS-" + BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(messageModel));
                string SerialNos = "";
                if (db.PostZh(user, modelList, ref strError, ref SerialNos) == false)
                {
                    messageModel.HeaderStatus = "E";
                    messageModel.Message      = strError;
                    LogNet.LogInfo("ymh:WMS-失败");
                }
                else
                {
                    SerialNos = SerialNos.Substring(0, SerialNos.Length - 1);
                    T_OutBarCode_Func       fuc    = new T_OutBarCode_Func();
                    List <T_OutBarCodeInfo> models = new List <T_OutBarCodeInfo>();
                    fuc.GetOutBarCodeInfoBySerialNos(SerialNos, ref models, ref strError);
                    messageModel.HeaderStatus = "S";
                    messageModel.Message      = "转换操作成功!";
                    messageModel.ModelJson    = models;
                    LogNet.LogInfo("ymh:WMS-成功");
                }

                return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(messageModel));
            }
            catch (Exception ex)
            {
                messageModel.HeaderStatus = "E";
                messageModel.Message      = ex.Message;
                return(BILBasic.JSONUtil.JSONHelper.ObjectToJson <BaseMessage_Model <List <T_OutBarCodeInfo> > >(messageModel));
            }
        }