Ejemplo n.º 1
0
        public SingleitemQueryResponse Post([FromBody] SingleitemQueryRequest model, string customerId)
        {
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            var response = new SingleitemQueryResponse();

            response.Item = new SingleitemQueryResponse.ItemDomain();
            if (customerId == "RB")
            {
                using (SCVDBContainer dbContext = new SCVDBContainer())
                {
                    if (string.IsNullOrEmpty(model.ItemCode))
                    {
                        response.Flag    = "failure";
                        response.Code    = "-1";
                        response.Message = "查询条件错误";
                    }
                    else
                    {
                        var result = dbContext.ITEM.FirstOrDefault(i => i.COMPANY == customerId && i.ITEM1 == model.ItemCode);
                        if (result == null)
                        {
                            response.Flag    = "failure";
                            response.Code    = "-1";
                            response.Message = "无此商品";
                        }
                        else
                        {
                            response.Flag             = "success";
                            response.Code             = "1";
                            response.Message          = "查询成功";
                            response.Item.ItemCode    = result.ITEM1;
                            response.Item.ItemName    = result.ITEM_DESC;
                            response.Item.SkuProperty = result.ITEM_SIZE;
                            response.Item.Color       = result.ITEM_COLOR;
                            response.Item.GoodsCode   = result.ITEM_STYLE;
                        }
                    }
                }
            }
            else
            {
                response.Flag    = "failure";
                response.Code    = "-1";
                response.Message = "无数据";
            }
            return(response);
        }
Ejemplo n.º 2
0
        // POST: api/EntryorderQuery
        public EntryOrderQueryResponseModel Post([FromBody] EntryOrderQueryRequestModel model)
        {
            EntryOrderQueryResponseModel response = new EntryOrderQueryResponseModel();

            using (SCVDBContainer dbContext = new SCVDBContainer()) {
                DbSet <RECEIPT_HEADER> dbSet0 = dbContext.Set <RECEIPT_HEADER>();
                DbSet <RECEIPT_DETAIL> dbSet1 = dbContext.Set <RECEIPT_DETAIL>();

                RECEIPT_HEADER header = dbSet0.FirstOrDefault(h => h.RECEIPT_ID == model.EntryOrderCode && h.COMPANY == model.OwnerCode);
                if (header == null)
                {
                    response.Flag       = "failure";
                    response.Code       = "-1";
                    response.Message    = "无此入库单";
                    response.TotalLines = 0;
                    return(response);
                }

                EntryOrder entryOrder = new EntryOrder();
                entryOrder.EntryOrderCode = model.EntryOrderCode;
                entryOrder.OwnerCode      = header.COMPANY;
                entryOrder.WarehouseCode  = "LK01";
                entryOrder.EntryOrderId   = header.INTERNAL_RECEIPT_NUM.ToString();
                entryOrder.EntryOrderType = header.RECEIPT_TYPE;
                entryOrder.Status         = header.TRAILING_STS.ToString();

                List <OrderLine> orderLines = new List <OrderLine>();
                foreach (var item in header.RECEIPT_DETAIL)
                {
                    OrderLine orderLine = new OrderLine();
                    orderLine.OrderLineNo = item.INTERNAL_RECEIPT_LINE_NUM.ToString();
                    orderLine.ItemCode    = item.ITEM;
                    orderLine.ItemId      = item.INTERNAL_RECEIPT_NUM.ToString();
                    orderLine.ItemName    = item.ITEM_DESC;
                    orderLine.PlanQty     = Convert.ToInt32(item.TOTAL_QTY);
                    orderLine.ActualQty   = Convert.ToInt32(item.OPEN_QTY);
                    orderLines.Add(orderLine);
                }
                response.Flag       = "success";
                response.Code       = "1";
                response.Message    = "查询成功";
                response.TotalLines = header.RECEIPT_DETAIL.Count();
                response.EntryOrder = entryOrder;
                response.OrderLines = orderLines;
            }
            return(response);
        }
Ejemplo n.º 3
0
        //从线程中 操作数据的 方式二
        //[ThreadStatic]//ThreadStatic 用来修饰静态变量:将此变量 存入 当前处理线程中!
        //public static SCVDBContainer db;

        #region 1.0 从 当前处理线程中获取 EF容器对象 +DbContext GetEFContext()
        /// <summary>
        /// 从 当前处理线程中获取 EF容器对象
        /// </summary>
        /// <returns></returns>
        public static SCVDBContainer GetEFContext()
        {
            //if (db == null) db = new DBContainer();
            //return db;
            #region 从线程中 操作数据的 方式一
            //1.从线程中取出 键 对应的值
            var db = CallContext.GetData(typeof(SCVEFFatory).FullName) as SCVDBContainer;
            //2.如果为空(线程中不存在)
            if (db == null)
            {
                //3.实例化 EF容器 子类对象
                db = new SCVDBContainer();
                //4.并存入线程
                CallContext.SetData(typeof(SCVEFFatory).FullName, db);
            }
            //5.返回EF容器对象
            return(db);

            #endregion
        }
Ejemplo n.º 4
0
        // POST: api/DeliveryorderQuery
        public DeliveryorderQueryResponseModel Post([FromBody] DeliveryorderQueryRequestModel model)
        {
            DeliveryorderQueryResponseModel response = new DeliveryorderQueryResponseModel();

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                DbSet <SHIPMENT_HEADER> dbSet0 = dbContext.Set <SHIPMENT_HEADER>();
                DbSet <SHIPMENT_DETAIL> dbSet1 = dbContext.Set <SHIPMENT_DETAIL>();
                SHIPMENT_HEADER         header = dbSet0.FirstOrDefault(h => h.SHIPMENT_ID == model.OrderCode && h.COMPANY == model.OwnerCode);
                if (header == null)
                {
                    response.Flag       = "failure";
                    response.Code       = "-1";
                    response.Message    = "无此出库单";
                    response.TotalLines = 0;
                    return(response);
                }
                int page     = (int)model.Page;
                int pageSize = (int)model.PageSize;

                response.Flag       = "success";
                response.Code       = "1";
                response.Message    = "查询成功";
                response.TotalLines = header.SHIPMENT_DETAIL.Count();
                DeliveryorderQueryResponseModel.DeliveryOrderDomain    deliveryOrder = new DeliveryorderQueryResponseModel.DeliveryOrderDomain();
                DeliveryorderQueryResponseModel.PackageDomain          package       = new DeliveryorderQueryResponseModel.PackageDomain();
                List <DeliveryorderQueryResponseModel.PackageDomain>   packages      = new List <DeliveryorderQueryResponseModel.PackageDomain>();
                DeliveryorderQueryResponseModel.OrderLineDomain        orderLine     = new DeliveryorderQueryResponseModel.OrderLineDomain();
                List <DeliveryorderQueryResponseModel.OrderLineDomain> orderLines    = new List <DeliveryorderQueryResponseModel.OrderLineDomain>();

                deliveryOrder.DeliveryOrderCode = header.SHIPMENT_ID;
                deliveryOrder.DeliveryOrderId   = header.INTERNAL_SHIPMENT_NUM.ToString();
                deliveryOrder.WarehouseCode     = header.WAREHOUSE;
                deliveryOrder.OrderType         = header.SHIPMENT_TYPE;
                if (header.LEADING_STS == 900 && header.TRAILING_STS == 900)
                {
                    deliveryOrder.Status = DeliveryorderQueryStatusEnum.DELIVERED.ToString();
                }
            }
            return(response);
        }
        // POST: api/SingleitemSynchronize
        public SingleitemSynchronizeResponseModel Post([FromBody] SingleitemSynchronizeRequestModel model, string customerId)
        {
            //测试相关
            //if (customerId == "c1515046170643")
            //{
            //    customerId = "HPH";
            //}
            //---------------------------------
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            SingleitemSynchronizeResponseModel response = new SingleitemSynchronizeResponseModel();

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "SingleitemSynchronize";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                DbSet <ITEM> dbSet = dbContext.Set <ITEM>();
                DbSet <ITEM_UNIT_OF_MEASURE> dbSet1  = dbContext.Set <ITEM_UNIT_OF_MEASURE>();
                Apps.Models.ITEM             scvItem = null;
                if (model.ActionType == "update")
                {
                    scvItem = dbSet.FirstOrDefault(i => i.ITEM1 == model.Item.ItemCode && i.COMPANY == customerId);

                    if (scvItem != null)
                    {
                        scvItem.COMPANY          = model.OwnerCode;
                        scvItem.ITEM1            = model.Item.ItemCode;
                        scvItem.ITEM_DESC        = model.Item.ItemName;
                        scvItem.STORAGE_TEMPLATE = "三层模板";
                        scvItem.ACTIVE           = "Y";
                        scvItem.DATE_TIME_STAMP  = DateTime.Now;
                        scvItem.ATTRIBUTE_TRACK  = "N";
                        scvItem.ITEM_SIZE        = model.Item.SkuProperty;
                        scvItem.ITEM_COLOR       = model.Item.Color;
                        scvItem.ITEM_STYLE       = model.Item.GoodsCode;
                    }
                }
                if (model.ActionType == "add")
                {
                    scvItem                  = new Apps.Models.ITEM();
                    scvItem.COMPANY          = model.OwnerCode;
                    scvItem.ITEM1            = model.Item.ItemCode;
                    scvItem.ITEM_DESC        = model.Item.ItemName;
                    scvItem.STORAGE_TEMPLATE = "三层模板";
                    scvItem.ACTIVE           = "Y";
                    scvItem.DATE_TIME_STAMP  = DateTime.Now;
                    scvItem.ATTRIBUTE_TRACK  = "N";
                    scvItem.ITEM_SIZE        = model.Item.SkuProperty;
                    scvItem.ITEM_COLOR       = model.Item.Color;
                    scvItem.ITEM_STYLE       = model.Item.GoodsCode;
                    var scvItemUnit = dbSet1.FirstOrDefault(u => u.ITEM == model.Item.ItemCode && u.COMPANY == customerId);
                    if (scvItemUnit == null)
                    {
                        scvItemUnit                      = new Apps.Models.ITEM_UNIT_OF_MEASURE();
                        scvItemUnit.ITEM                 = model.Item.ItemCode;
                        scvItemUnit.COMPANY              = customerId;
                        scvItemUnit.SEQUENCE             = 1;
                        scvItemUnit.QUANTITY_UM          = "EA";
                        scvItemUnit.CONVERSION_QTY       = 1;
                        scvItemUnit.LENGTH               = model.Item.Length;
                        scvItemUnit.WIDTH                = model.Item.Width;
                        scvItemUnit.HEIGHT               = model.Item.Height;
                        scvItemUnit.DIMENSION_UM         = "CM";
                        scvItemUnit.WEIGHT               = model.Item.GrossWeight;
                        scvItemUnit.WEIGHT_UM            = "KG";
                        scvItemUnit.USER_STAMP           = "Interface";
                        scvItemUnit.DATE_TIME_STAMP      = DateTime.Now;
                        scvItemUnit.TREAT_FULL_PCT       = 100;
                        scvItemUnit.TREAT_AS_LOOSE       = "Y";
                        scvItemUnit.GROUP_DURING_CHECKIN = "Y";
                        scvItemUnit.USER_DEF7            = "0";
                        scvItemUnit.USER_DEF8            = "0";
                        dbSet1.Add(scvItemUnit);
                    }

                    dbSet.Add(scvItem);
                }

                if (dbContext.SaveChanges() >= 0)
                {
                    response.Code    = "0";
                    response.Flag    = "success";
                    response.Message = "商品同步成功";
                    response.ItemId  = scvItem.INTERNAL_ITEM_NUM.ToString();
                }
                else
                {
                    response.Code    = "-1";
                    response.Flag    = "failure";
                    response.Message = "商品同步失败,请重试";
                }
            }


            return(response);
        }
Ejemplo n.º 6
0
        public void Execute(IJobExecutionContext context)
        {
            string url       = ConfigurationManager.AppSettings["URL"].ToString();
            string appkey    = ConfigurationManager.AppSettings["APPKEY"].ToString(); //"1023883919"; 23883919
            string secret    = ConfigurationManager.AppSettings["SECRET"].ToString(); //"sandboxff0b11ecc626508c171a5b2a2";
            string customeId = ConfigurationManager.AppSettings["CUSTOMEID"].ToString();
            string v         = ConfigurationManager.AppSettings["v"].ToString();

            string[] customerArr = customeId.Split(',');

            try
            {
                _logger.Info("ReturnorderConfirm 开始执行... " + DateTime.Now + "");
                foreach (var cId in customerArr)
                {
                    using (SCVDBContainer dbContext0 = new SCVDBContainer())
                        using (DBContainer dbContext1 = new DBContainer())
                        {
                            DbSet <RECEIPT_HEADER> header = dbContext0.Set <RECEIPT_HEADER>();
                            DbSet <RECEIPT_DETAIL> detail = dbContext0.Set <RECEIPT_DETAIL>();

                            //DbSet<QiMen_PushTimeStatus> dbSet0 = dbContext1.Set<QiMen_PushTimeStatus>();
                            DbSet <QiMen_PushLog> dbSet1 = dbContext1.Set <QiMen_PushLog>();

                            IQimenClient client           = new DefaultQimenClient(url, appkey, secret);
                            ReturnorderConfirmRequest req = new ReturnorderConfirmRequest();


                            //DateTime lastTime;
                            //QiMen_PushTimeStatus qmt = dbSet0.Where(q => q.CustomerId == cId && q.OrderType == RECEIPT && q.Interface == INTERFACE).FirstOrDefault();
                            //if (qmt == null)
                            //{
                            //    qmt = new QiMen_PushTimeStatus() { CustomerId = cId, ActualArriveTime = DateTime.Now, OrderType = RECEIPT, Interface = INTERFACE };
                            //    dbSet0.Add(qmt);
                            //    lastTime = DateTime.Now.AddMinutes(-1);
                            //}
                            //else
                            //{
                            //    lastTime = ((DateTime)qmt.ActualArriveTime).AddMinutes(-1);
                            //}

                            //var confirmlList = header.Where(h => h.COMPANY == cId && h.TRAILING_STS == 900 && (h.RECEIPT_TYPE).Equals("THRK",StringComparison.OrdinalIgnoreCase) && h.CLOSE_DATE >= lastTime).Include(r => r.RECEIPT_DETAIL).OrderByDescending(h => h.CLOSE_DATE).ToList();
                            var confirmlList = header.Where(h => h.COMPANY == cId &&
                                                            h.CREATE_USER == "ReturnorderCreate" &&
                                                            (h.USER_DEF8 == null || h.USER_DEF8 == QimenPushStatus.Failure.ToString() ||
                                                             h.USER_DEF8 == "1" || h.USER_DEF8 == "2" || h.USER_DEF8 == "3" || h.USER_DEF8 == "4" || h.USER_DEF8 == "5") &&
                                                            (h.TRAILING_STS == 800 || h.TRAILING_STS == 850 || h.TRAILING_STS == 900) &&
                                                            h.RECEIPT_TYPE.Equals("THRK", StringComparison.OrdinalIgnoreCase)
                                                            ).Include(s => s.RECEIPT_DETAIL).ToList();

                            if (cId == "XGQQG")
                            {
                                confirmlList.Clear();
                            }

                            //if (cId == "CQHGE")
                            //{
                            //    confirmlList = confirmlList.Where(l => l.CREATE_USER == "ReturnorderCreate").ToList();
                            //}

                            if (cId == "CH")
                            {
                                req.CustomerId = "CH1";
                            }
                            else
                            {
                                req.CustomerId = cId;
                            }
                            req.Version   = v;
                            req.Timestamp = DateTime.Now;
                            //bool pushFlag = true;

                            foreach (var itemHeader in confirmlList)
                            {
                                ReturnorderConfirmRequest.ReturnOrderDomain returnOrder = new ReturnorderConfirmRequest.ReturnOrderDomain();
                                returnOrder.ReturnOrderCode = itemHeader.RECEIPT_ID; //"R1234";//item.ERP_ORDER_ID;
                                returnOrder.WarehouseCode   = itemHeader.WAREHOUSE;
                                returnOrder.LogisticsCode   = "";                    //"SF";//item.CARRER;
                                returnOrder.OutBizCode      = itemHeader.INTERNAL_RECEIPT_NUM.ToString();
                                returnOrder.OrderType       = itemHeader.RECEIPT_TYPE;

                                ReturnorderConfirmRequest.SenderInfoDomain senderInfo = new ReturnorderConfirmRequest.SenderInfoDomain();
                                senderInfo.Name          = itemHeader.SHIP_FROM_NAME;                                                                             //"老王";//
                                senderInfo.Mobile        = itemHeader.SHIP_FROM_PHONE_NUM;                                                                        //"13214567869";//
                                senderInfo.Province      = itemHeader.SHIP_FROM_COUNTRY;                                                                          //"浙江省";//
                                senderInfo.City          = itemHeader.SHIP_FROM_CITY;                                                                             //"杭州"; //
                                senderInfo.DetailAddress = itemHeader.SHIP_FROM_ADDRESS1 != null ? itemHeader.SHIP_FROM_ADDRESS1 : itemHeader.SHIP_FROM_ADDRESS2; //"杭州市余杭区989号";//
                                returnOrder.SenderInfo   = senderInfo;
                                req.ReturnOrder          = returnOrder;

                                List <ReturnorderConfirmRequest.OrderLineDomain> orderLineList = new List <ReturnorderConfirmRequest.OrderLineDomain>();

                                foreach (var itemDetail in itemHeader.RECEIPT_DETAIL)
                                {
                                    ReturnorderConfirmRequest.OrderLineDomain orderLine = new ReturnorderConfirmRequest.OrderLineDomain();
                                    orderLine.ItemId     = itemDetail.INTERNAL_RECEIPT_LINE_NUM.ToString();
                                    orderLine.ItemName   = itemDetail.ITEM_DESC;
                                    orderLine.OwnerCode  = itemDetail.COMPANY;
                                    orderLine.ItemCode   = itemDetail.ITEM;
                                    orderLine.PlanQty    = (long)itemDetail.TOTAL_QTY;
                                    orderLine.ActualQty  = (itemDetail.TOTAL_QTY - itemDetail.OPEN_QTY).ToString();
                                    orderLine.OutBizCode = itemDetail.INTERNAL_RECEIPT_LINE_NUM.ToString();

                                    orderLineList.Add(orderLine);
                                }
                                req.OrderLines = orderLineList;

                                var rsp = client.Execute(req);

                                QiMen_PushLog log = new QiMen_PushLog();
                                log.InternalOrderID = itemHeader.INTERNAL_RECEIPT_NUM;
                                log.OrderType       = INTERFACE;
                                log.CustomerId      = cId;
                                log.Flag            = rsp.Flag;
                                log.Message         = rsp.Message;
                                log.CreateTime      = DateTime.Now;
                                dbSet1.Add(log);

                                if (rsp.Flag == "success")
                                {
                                    itemHeader.USER_DEF8 = QimenPushStatus.Success.ToString();
                                    _logger.Info("入库单:" + itemHeader.RECEIPT_ID + "确认成功----" + DateTime.Now);
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(itemHeader.USER_DEF8))
                                    {
                                        itemHeader.USER_DEF8 = "1";
                                    }
                                    else
                                    {
                                        int parseResult;
                                        if (int.TryParse(itemHeader.USER_DEF8, out parseResult))
                                        {
                                            itemHeader.USER_DEF8 = (parseResult + 1).ToString();
                                        }
                                    }
                                    //if (rsp.Message.Length > 50)
                                    //{
                                    //    pushFlag = false;
                                    //}
                                    _logger.Info("入库单:" + itemHeader.RECEIPT_ID + "确认失败:-" + rsp.Message + DateTime.Now);
                                }
                            }
                            //if (confirmlList.Count > 0 && pushFlag)
                            //{
                            //    qmt.ActualArriveTime = (DateTime)confirmlList.First().CLOSE_DATE;
                            //}
                            dbContext0.SaveChanges();
                            dbContext1.SaveChanges();
                        }
                }

                _logger.Info("ReturnorderConfirm 执行完成... " + DateTime.Now + "");
            }
            catch (Exception ex)
            {
                _logger.Error("ReturnorderConfirm 异常..." + DateTime.Now + " " + ex.Message);
            }
        }
Ejemplo n.º 7
0
        // POST: api/OrderCancel
        public OrderCancelResponseModel Post([FromBody] OrderCancelRequestModel model, string customerId)
        {
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            OrderCancelResponseModel response = new OrderCancelResponseModel();

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "OrderCancel";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                //DbSet<RECEIPT_HEADER> dbSet0 = dbContext.Set<RECEIPT_HEADER>();
                //DbSet<SHIPMENT_HEADER> dbSet1 = dbContext.Set<SHIPMENT_HEADER>();

                RECEIPT_HEADER  rHeader = dbContext.RECEIPT_HEADER.FirstOrDefault(r => r.RECEIPT_ID == model.OrderCode && r.COMPANY == customerId);
                SHIPMENT_HEADER sHeader = dbContext.SHIPMENT_HEADER.FirstOrDefault(r => r.SHIPMENT_ID == model.OrderCode && r.COMPANY == customerId);

                if (sHeader != null)
                {
                    if (sHeader.TRAILING_STS >= 750)
                    {
                        response.Flag    = "failure";
                        response.Code    = "-1";
                        response.Message = model.OrderCode + ":当前状态不允许取消";
                        return(response);
                    }

                    if (sHeader.PROCESS_TYPE.Equals("CANCEL", StringComparison.OrdinalIgnoreCase))
                    {
                        response.Flag    = "success";
                        response.Code    = "0";
                        response.Message = model.OrderCode + ":该订单已经取消";
                        return(response);
                    }
                    else
                    {
                        sHeader.PROCESS_TYPE       = "CANCEL";
                        sHeader.SHIPMENT_CATEGORY6 = "Cancel";
                    }
                }
                else if (rHeader != null)
                {
                    //response.Flag = "failure";
                    //response.Code = "-1";
                    //response.Message = model.OrderCode + ":入库单取消,请联系商务";
                    //return response;
                    if (rHeader.LEADING_STS == 100 && rHeader.TRAILING_STS == 100)
                    {
                        rHeader.LEADING_STS  = 900;
                        rHeader.TRAILING_STS = 900;
                        rHeader.USER_DEF8    = "Cancel";
                        //rHeader.CLOSE_DATE = DateTime.Now.AddHours(-4);
                    }
                    else
                    {
                        response.Flag    = "failure";
                        response.Code    = "-1";
                        response.Message = model.OrderCode + "已收货不允许取消";
                        return(response);
                    }
                }

                if (dbContext.SaveChanges() >= 0)
                {
                    response.Flag    = "success";
                    response.Code    = "0";
                    response.Message = model.OrderCode + ":取消成功";
                }
                else
                {
                    response.Flag    = "failure";
                    response.Code    = "-1";
                    response.Message = model.OrderCode + ":取消失败";
                }
            }

            return(response);
        }
Ejemplo n.º 8
0
        public InventoryQueryResponse Post([FromBody] InventoryQueryRequest model, string customerId)
        {
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            var response = new InventoryQueryResponse();

            response.Items = new List <InventoryQueryResponse.ItemDomain>();

            if (customerId == "RB")
            {
                using (SCVDBContainer dbContext = new SCVDBContainer())
                {
                    foreach (var criteria in model.CriteriaList)
                    {
                        if (string.IsNullOrEmpty(criteria.ItemCode))
                        {
                            continue;
                        }

                        var lis = dbContext.LOCATION_INVENTORY.Where(l => l.COMPANY == customerId && l.ITEM == criteria.ItemCode);

                        foreach (var li in lis)
                        {
                            InventoryQueryResponse.ItemDomain itemDomain = new InventoryQueryResponse.ItemDomain();
                            itemDomain.WarehouseCode = "LK01";
                            itemDomain.ItemCode      = criteria.ItemCode;
                            if (li.INVENTORY_STS == "合格")
                            {
                                itemDomain.InventoryType = "ZP";
                            }
                            else
                            {
                                itemDomain.InventoryType = "CC";
                            }

                            itemDomain.Quantity     = Convert.ToInt32(li.ON_HAND_QTY);
                            itemDomain.LockQuantity = Convert.ToInt32(li.IN_TRANSIT_QTY) + Convert.ToInt32(li.ALLOCATED_QTY);
                            if (li.ATTRIBUTE3 != null)
                            {
                                itemDomain.ExpireDate = li.ATTRIBUTE3;
                            }

                            response.Items.Add(itemDomain);
                        }
                    }
                }
            }
            else
            {
                response.Flag    = "failure";
                response.Code    = "-1";
                response.Message = "无数据";
            }

            if (response.Items.Any())
            {
                response.Flag    = "success";
                response.Code    = "1";
                response.Message = "查询成功";
            }
            else
            {
                response.Flag    = "failure";
                response.Code    = "-1";
                response.Message = "无数据";
            }

            return(response);
        }
Ejemplo n.º 9
0
        // POST: api/DeliveryorderCreate
        public DeliveryorderCreateResponseModel Post([FromBody] DeliveryorderCreateRequestModel model, string customerId)
        {
            DeliveryorderCreateResponseModel response = new DeliveryorderCreateResponseModel();

            if (customerId == "CH1")
            {
                customerId = "CH";
            }

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "DeliveryorderCreate";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                //DbSet<SHIPMENT_HEADER> dbSet0 = dbContext.Set<SHIPMENT_HEADER>();
                //DbSet<SHIPMENT_DETAIL> dbSet1 = dbContext.Set<SHIPMENT_DETAIL>();
                DbSet <ITEM> dbSetItem = dbContext.Set <ITEM>();

                if (dbContext.SHIPMENT_HEADER.Where(h => h.SHIPMENT_ID == model.DeliveryOrder.DeliveryOrderCode && h.COMPANY == customerId).Any())
                {
                    response.Flag            = "success";
                    response.Code            = "0";
                    response.Message         = model.DeliveryOrder.DeliveryOrderCode + ":单号重复";
                    response.DeliveryOrderId = "";
                    return(response);
                }

                SHIPMENT_HEADER header = new SHIPMENT_HEADER();
                header.WAREHOUSE = "LK01";
                header.COMPANY   = customerId;

                header.USER_DEF2     = model.DeliveryOrder.ShopNick;
                header.SHIPMENT_NOTE = model.DeliveryOrder.SellerMessage;
                header.SHIPMENT_TYPE = model.DeliveryOrder.OrderType;
                header.SHIPMENT_ID   = model.DeliveryOrder.DeliveryOrderCode;
                DateTime time;
                if (DateTime.TryParse(model.DeliveryOrder.CreateTime, out time))
                {
                    header.CREATE_DATE_TIME = time;
                }
                header.LEADING_STS      = 100;
                header.TRAILING_STS     = 100;
                header.SHIP_TO_NAME     = model.DeliveryOrder.ReceiverInfo.Name;
                header.SHIP_TO_MOBILE   = model.DeliveryOrder.ReceiverInfo.Mobile;
                header.SHIP_TO_DISTRICT = model.DeliveryOrder.ReceiverInfo.Area;
                header.SHIP_TO_CITY     = model.DeliveryOrder.ReceiverInfo.City;
                header.SHIP_TO_STATE    = model.DeliveryOrder.ReceiverInfo.Province;
                //header.SHIPMENT_NOTE = model.DeliveryOrder.ReceiverInfo.Remark;
                header.SHIP_TO_ADDRESS1 = model.DeliveryOrder.ReceiverInfo.DetailAddress;
                header.PROCESS_TYPE     = "NORMAL";
                header.CARRIER          = model.DeliveryOrder.LogisticsCode;
                header.CREATE_USER      = "******";
                header.TOTAL_LINES      = model.OrderLines.Count();
                int totalQty = 0;

                foreach (var item in model.OrderLines)
                {
                    SHIPMENT_DETAIL detail = new SHIPMENT_DETAIL();
                    detail.WAREHOUSE   = "LK01";
                    detail.COMPANY     = item.OwnerCode;
                    detail.SHIPMENT_ID = model.DeliveryOrder.DeliveryOrderCode;
                    detail.ITEM        = item.ItemCode;
                    ITEM sItem = dbSetItem.Where(t => t.ITEM1 == item.ItemCode).FirstOrDefault();
                    if (sItem != null)
                    {
                        detail.ITEM_DESC = sItem.ITEM_DESC;
                    }
                    //detail.ITEM_DESC = item.ItemName;
                    detail.REQUEST_QTY     = Convert.ToInt32(item.PlanQty);
                    detail.QUANTITY_UM     = "EA";
                    detail.DATE_TIME_STAMP = time;
                    if (item.InventoryType == null)
                    {
                        detail.INVENTORY_STS = "合格";
                    }
                    else
                    {
                        if (string.Equals("ZP", item.InventoryType, StringComparison.CurrentCultureIgnoreCase))
                        {
                            detail.INVENTORY_STS = "合格";
                        }
                        else
                        {
                            detail.INVENTORY_STS = "不合格";
                        }
                    }


                    //detail.INVENTORY_STS = item.InventoryType;
                    detail.STATUS = 100;
                    totalQty     += Convert.ToInt32(item.PlanQty);
                    header.SHIPMENT_DETAIL.Add(detail);
                }

                header.TOTAL_QTY = totalQty;

                dbContext.SHIPMENT_HEADER.Add(header);

                if (dbContext.SaveChanges() > 0)
                {
                    response.Flag            = "success";
                    response.Code            = "1";
                    response.Message         = model.DeliveryOrder.DeliveryOrderCode + ":创建成功";
                    response.DeliveryOrderId = header.INTERNAL_SHIPMENT_NUM.ToString();
                }
                else
                {
                    response.Flag            = "failure";
                    response.Code            = "-1";
                    response.Message         = model.DeliveryOrder.DeliveryOrderCode + ":创建失败";
                    response.DeliveryOrderId = "";
                }
            }

            return(response);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 出库单确认
        /// </summary>
        public bool StockoutConfirm()
        {
            log.Info("----------------启用定时任务:出库单确认" + DateTime.Now.Hour + "--------------");
            try
            {
                dbContext = new SCVDBContainer();
                DbSet <SHIPMENT_HEADER>       dbset0     = dbContext.Set <SHIPMENT_HEADER>();
                DbSet <SHIPMENT_DETAIL>       dbset1     = dbContext.Set <SHIPMENT_DETAIL>();
                DbSet <SHIPMENT_HEADER_TEMP1> dbset_Temp = dbContext.Set <SHIPMENT_HEADER_TEMP1>();

                IQimenClient            client = new DefaultQimenClient(url, appkey, secret);
                StockoutConfirmRequest  req    = new StockoutConfirmRequest();
                StockoutConfirmResponse rsp    = new StockoutConfirmResponse();

                StockoutConfirmRequest.DeliveryOrderDomain obj1 = new StockoutConfirmRequest.DeliveryOrderDomain();

                StockoutConfirmRequest.PackageDomain        package     = new StockoutConfirmRequest.PackageDomain();
                List <StockoutConfirmRequest.PackageDomain> packageList = new List <StockoutConfirmRequest.PackageDomain>();

                StockoutConfirmRequest.ItemDomain        itemDomain     = new StockoutConfirmRequest.ItemDomain();
                List <StockoutConfirmRequest.ItemDomain> itemDomainList = new List <StockoutConfirmRequest.ItemDomain>();

                StockoutConfirmRequest.OrderLineDomain        orderLine     = new StockoutConfirmRequest.OrderLineDomain();
                List <StockoutConfirmRequest.OrderLineDomain> orderLineList = new List <StockoutConfirmRequest.OrderLineDomain>();
                for (int i = 0; i < customerArr.Length; i++)
                {
                    var confirmlList = dbset0
                                       .Where(t => t.TRAILING_STS.ToString() == "900" &&
                                              t.COMPANY == customeId)
                                       .OrderByDescending(t => t.INTERNAL_SHIPMENT_NUM)
                                       .Take(100).AsNoTracking().ToList();
                    var confirmTempList = dbset_Temp
                                          .Where(t => t.TRAILING_STS.ToString() == "900" &&
                                                 t.COMPANY == customeId)
                                          .OrderByDescending(t => t.INTERNAL_SHIPMENT_NUM)
                                          .Take(100).AsNoTracking().ToList();

                    List <SHIPMENT_DETAIL> detailList = new List <SHIPMENT_DETAIL>();
                    confirmlList = confirmlList
                                   .Where(a => !confirmTempList.Exists(t => a.INTERNAL_SHIPMENT_NUM == t.INTERNAL_SHIPMENT_NUM))
                                   .OrderByDescending(t => t.INTERNAL_SHIPMENT_NUM).ToList();

                    req.CustomerId = customerArr[i].Trim();
                    req.Version    = v;
                    req.Timestamp  = DateTime.Now;
                    if (confirmlList.Count == 0)
                    {
                        log.Info("客户:" + req.CustomerId + " " + "需确认的出库单为空,不需要确认!!!");
                        continue;
                    }
                    foreach (var item in confirmlList)
                    {
                        detailList             = dbset1.Where(t => t.INTERNAL_SHIPMENT_NUM == item.INTERNAL_SHIPMENT_NUM).ToList();
                        obj1.DeliveryOrderId   = item.SHIPMENT_ID.ToString();
                        obj1.OutBizCode        = Guid.NewGuid().ToString();
                        obj1.DeliveryOrderCode = item.SHIPMENT_ID;
                        obj1.WarehouseCode     = item.WAREHOUSE;
                        obj1.OrderType         = item.SHIPMENT_TYPE;
                        req.DeliveryOrder      = obj1;
                        foreach (var itemChildren in detailList)
                        {
                            itemDomain.ItemCode = itemChildren.ITEM;
                            itemDomain.Quantity = (long)itemChildren.REQUEST_QTY;
                            itemDomainList.Add(itemDomain);

                            package.ExpressCode = item.SHIPPING_CONTAINER
                                                  .Where(t => t.PARENT == 0 && t.STATUS == 900)
                                                  .FirstOrDefault().TRACKING_NUMBER;
                            package.Items         = itemDomainList;
                            package.LogisticsCode = item.CARRIER;
                            packageList.Add(package);

                            orderLine.ItemCode  = itemChildren.ITEM;
                            orderLine.ActualQty = (long)itemChildren.REQUEST_QTY;
                            orderLineList.Add(orderLine);
                        }
                        req.OrderLines = orderLineList;
                        req.Packages   = packageList;
                        try
                        {
                            rsp = client.Execute(req);
                            log.Info(" " + "出库确认--订单号:" + item.INTERNAL_SHIPMENT_NUM + " " + "确认结果:" + rsp.Flag + " " + "消息:" + rsp.Message);
                        }
                        catch (Exception ex)
                        {
                            log.Error("Error", ex);
                            continue;
                        }

                        if (rsp.Flag == "success")
                        {
                            SHIPMENT_HEADER_TEMP1 headerTemp = new SHIPMENT_HEADER_TEMP1()
                            {
                                LEADING_STS           = item.LEADING_STS,
                                DATE_TIME_STAMP       = DateTime.Now,
                                TRAILING_STS          = item.TRAILING_STS,
                                TOTAL_QTY             = item.TOTAL_QTY,
                                INTERNAL_SHIPMENT_NUM = item.INTERNAL_SHIPMENT_NUM,
                                SHIPMENT_ID           = item.SHIPMENT_ID,
                                WAREHOUSE             = item.WAREHOUSE,
                                COMPANY       = item.COMPANY,
                                SHIPMENT_TYPE = item.SHIPMENT_TYPE,
                                FLAG          = rsp.Flag,
                                CODE          = rsp.Code,
                                MESSAGE       = rsp.Message
                            };
                            dbset_Temp.Add(headerTemp);
                        }
                    }
                    dbContext.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                return(false);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 退货入库单确认
        /// </summary>
        public bool ReturnorderConfirm()
        {
            log.Info("----------------启用定时任务:退货入库单确认" + DateTime.Now.Hour + "--------------");
            try
            {
                dbContext = new SCVDBContainer();
                DbSet <RECEIPT_HEADER>      dbset0     = dbContext.Set <RECEIPT_HEADER>();
                DbSet <RECEIPT_DETAIL>      dbset1     = dbContext.Set <RECEIPT_DETAIL>();
                DbSet <RECEIPT_HEADER_TEMP> dbset_Temp = dbContext.Set <RECEIPT_HEADER_TEMP>();
                IQimenClient client            = new DefaultQimenClient(url, appkey, secret);
                ReturnorderConfirmRequest  req = new ReturnorderConfirmRequest();
                ReturnorderConfirmResponse rsp = new ReturnorderConfirmResponse();
                //退货单信息
                ReturnorderConfirmRequest.ReturnOrderDomain obj1 = new ReturnorderConfirmRequest.ReturnOrderDomain();
                //发件人信息
                ReturnorderConfirmRequest.SenderInfoDomain send = new ReturnorderConfirmRequest.SenderInfoDomain();
                //订单信息
                ReturnorderConfirmRequest.OrderLineDomain        orderLine     = new ReturnorderConfirmRequest.OrderLineDomain();
                List <ReturnorderConfirmRequest.OrderLineDomain> orderLineList = new List <ReturnorderConfirmRequest.OrderLineDomain>();
                for (int i = 0; i < customerArr.Length; i++)
                {
                    var confirmlList = dbset0
                                       .Where(t =>
                                              t.TRAILING_STS.ToString() == "900" &&
                                              (
                                                  t.RECEIPT_TYPE.Contains("THRK") ||
                                                  t.RECEIPT_TYPE.Contains("HHRK")
                                              ) && t.COMPANY == customeId)
                                       .OrderByDescending(t => t.INTERNAL_RECEIPT_NUM)
                                       .Take(100).AsNoTracking().ToList();
                    var confirmTempList = dbset_Temp
                                          .Where(t =>
                                                 t.TRAILING_STS.ToString() == "900" &&
                                                 (
                                                     t.RECEIPT_TYPE.Contains("THRK") ||
                                                     t.RECEIPT_TYPE.Contains("HHRK")
                                                 ) && t.COMPANY == customeId)
                                          .OrderByDescending(t => t.INTERNAL_RECEIPT_NUM)
                                          .Take(100).AsNoTracking().ToList();

                    List <RECEIPT_HEADER_TEMP> tempList   = new List <RECEIPT_HEADER_TEMP>();
                    List <RECEIPT_DETAIL>      detailList = new List <RECEIPT_DETAIL>();
                    //排除已确认的数据,并且一次性只处理100个订单
                    confirmlList = confirmlList
                                   .Where(a => !confirmTempList.Exists(t => a.INTERNAL_RECEIPT_NUM == t.INTERNAL_RECEIPT_NUM))
                                   .OrderByDescending(t => t.INTERNAL_RECEIPT_NUM).ToList();

                    req.CustomerId = customerArr[i].Trim();
                    req.Version    = v;
                    req.Timestamp  = DateTime.Now;
                    if (confirmlList.Count == 0)
                    {
                        log.Info("客户:" + req.CustomerId + " " + "需确认的退货入库单为空,不需要确认!!!");
                        continue;
                    }

                    foreach (var item in confirmlList)
                    {
                        detailList = dbset1.Where(t => t.INTERNAL_RECEIPT_NUM == item.INTERNAL_RECEIPT_NUM).ToList();

                        obj1.ReturnOrderCode = item.RECEIPT_ID;                                                                     //"R1234";//item.ERP_ORDER_ID;
                        obj1.WarehouseCode   = item.WAREHOUSE;
                        obj1.LogisticsCode   = "SF";                                                                                //"SF";//item.CARRER;
                        obj1.OutBizCode      = Guid.NewGuid().ToString();
                        send.Name            = item.SHIP_FROM_NAME;                                                                 //"老王";//
                        send.Mobile          = item.SHIP_FROM_PHONE_NUM;                                                            //"13214567869";//
                        send.Province        = item.SHIP_FROM_COUNTRY;                                                              //"浙江省";//
                        send.City            = item.SHIP_FROM_CITY;                                                                 //"杭州"; //
                        send.DetailAddress   = item.SHIP_FROM_ADDRESS1 != null ? item.SHIP_FROM_ADDRESS1 : item.SHIP_FROM_ADDRESS2; //"杭州市余杭区989号";//
                        obj1.SenderInfo      = send;

                        foreach (var itemChildren in detailList)
                        {
                            orderLine.OwnerCode = itemChildren.COMPANY;
                            orderLine.ItemCode  = itemChildren.ITEM;
                            orderLine.PlanQty   = (long)itemChildren.OPEN_QTY;//12L;//
                            orderLine.ActualQty = itemChildren.TOTAL_QTY.ToString();
                            orderLineList.Add(orderLine);
                        }
                        req.ReturnOrder = obj1;
                        req.OrderLines  = orderLineList;
                        try
                        {
                            rsp = client.Execute(req);
                            log.Info(" " + "退货入库确认--订单号:" + item.INTERNAL_RECEIPT_NUM + " " + "确认结果:" + rsp.Flag + " " + "消息:" + rsp.Message);
                        }
                        catch (Exception ex)
                        {
                            log.Error("Error", ex);
                            continue;
                        }
                        if (rsp.Flag == "success")
                        {
                            DbSet <RECEIPT_HEADER_TEMP> header = dbContext.Set <RECEIPT_HEADER_TEMP>();

                            RECEIPT_HEADER_TEMP headerTemp = new RECEIPT_HEADER_TEMP()
                            {
                                INTERNAL_RECEIPT_NUM = item.INTERNAL_RECEIPT_NUM,
                                DATE_TIME_STAMP      = DateTime.Now,
                                RECEIPT_ID           = item.RECEIPT_ID,
                                WAREHOUSE            = item.WAREHOUSE,
                                RECEIPT_TYPE         = item.RECEIPT_TYPE,
                                TRAILING_STS         = item.TRAILING_STS,
                                LEADING_STS          = item.LEADING_STS,
                                FLAG    = rsp.Flag,
                                CODE    = rsp.Code,
                                MESSAGE = rsp.Message
                            };
                            header.Add(headerTemp);
                        }
                    }
                    dbContext.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                return(false);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 入库单确认
        /// </summary>
        public bool EntryorderConfirm()
        {
            log.Info("----------------启用定时任务:入库单确认" + DateTime.Now.Hour + "--------------");
            try
            {
                dbContext = new SCVDBContainer();
                DbSet <RECEIPT_HEADER>      dbset0     = dbContext.Set <RECEIPT_HEADER>();
                DbSet <RECEIPT_DETAIL>      dbset1     = dbContext.Set <RECEIPT_DETAIL>();
                DbSet <RECEIPT_HEADER_TEMP> dbset_Temp = dbContext.Set <RECEIPT_HEADER_TEMP>();

                IQimenClient              client = new DefaultQimenClient(url, appkey, secret);
                EntryorderConfirmRequest  req    = new EntryorderConfirmRequest();
                EntryorderConfirmResponse rsp    = new EntryorderConfirmResponse();

                EntryorderConfirmRequest.EntryOrderDomain obj1 = new EntryorderConfirmRequest.EntryOrderDomain();

                EntryorderConfirmRequest.OrderLineDomain        orderLine     = new EntryorderConfirmRequest.OrderLineDomain();
                List <EntryorderConfirmRequest.OrderLineDomain> orderLineList = new List <EntryorderConfirmRequest.OrderLineDomain>();
                for (int i = 0; i < customerArr.Length; i++)
                {
                    var confirmlList = dbset0
                                       .Where(t =>
                                              t.TRAILING_STS.ToString() == "900" &&
                                              (t.RECEIPT_TYPE.Contains("SCRK") ||
                                               t.RECEIPT_TYPE.Contains("LYRK") ||
                                               t.RECEIPT_TYPE.Contains("CCRK") ||
                                               t.RECEIPT_TYPE.Contains("CGRK") ||
                                               t.RECEIPT_TYPE.Contains("DBRK") ||
                                               t.RECEIPT_TYPE.Contains("QTRK") ||
                                               t.RECEIPT_TYPE.Contains("B2BRK") &&
                                               t.COMPANY == customeId)
                                              ).OrderByDescending(t => t.INTERNAL_RECEIPT_NUM)
                                       .Take(100).AsNoTracking().ToList();
                    var confirmTempList = dbset_Temp.Where(t =>
                                                           t.TRAILING_STS.ToString() == "900" &&
                                                           (t.RECEIPT_TYPE.Contains("SCRK") ||
                                                            t.RECEIPT_TYPE.Contains("LYRK") ||
                                                            t.RECEIPT_TYPE.Contains("CCRK") ||
                                                            t.RECEIPT_TYPE.Contains("CGRK") ||
                                                            t.RECEIPT_TYPE.Contains("DBRK") ||
                                                            t.RECEIPT_TYPE.Contains("QTRK") ||
                                                            t.RECEIPT_TYPE.Contains("B2BRK") &&
                                                            t.COMPANY == customeId)
                                                           ).OrderByDescending(t => t.INTERNAL_RECEIPT_NUM)
                                          .Take(100).AsNoTracking().ToList();

                    List <RECEIPT_DETAIL> tempList = new List <RECEIPT_DETAIL>();
                    //过滤已确认的数据
                    confirmlList = confirmlList
                                   .Where(a => !confirmTempList.Exists(t => a.INTERNAL_RECEIPT_NUM == t.INTERNAL_RECEIPT_NUM))
                                   .ToList();

                    req.CustomerId = customerArr[i].Trim();
                    req.Version    = v;
                    req.Timestamp  = DateTime.Now;
                    if (confirmlList.Count == 0)
                    {
                        log.Info("客户:" + req.CustomerId + " " + "需确认的入库单为空,不需要确认!!!");
                        continue;
                    }
                    foreach (var item in confirmlList)
                    {
                        tempList             = dbset1.Where(t => t.INTERNAL_RECEIPT_NUM == item.INTERNAL_RECEIPT_NUM).ToList();
                        obj1.EntryOrderCode  = item.RECEIPT_ID;
                        obj1.OwnerCode       = item.COMPANY;
                        obj1.WarehouseCode   = item.WAREHOUSE;
                        obj1.OutBizCode      = Guid.NewGuid().ToString();
                        obj1.Status          = "FULFILLED";//item.TRAILING_STS.ToString();
                        obj1.ConfirmType     = 0L;
                        obj1.TotalOrderLines = (long)item.TOTAL_LINES;
                        obj1.EntryOrderId    = item.RECEIPT_ID;
                        req.EntryOrder       = obj1;
                        foreach (var itemChildren in tempList)
                        {
                            orderLine.ItemId    = itemChildren.ITEM;
                            orderLine.OwnerCode = itemChildren.COMPANY;
                            orderLine.ItemCode  = itemChildren.ITEM;
                            orderLine.PlanQty   = (long)itemChildren.OPEN_QTY;
                            orderLine.ActualQty = (long)itemChildren.TOTAL_QTY;
                            orderLineList.Add(orderLine);
                        }
                        req.OrderLines = orderLineList;
                        try
                        {
                            rsp = client.Execute(req);
                            log.Info(" " + "入库确认--订单号:" + item.INTERNAL_RECEIPT_NUM + " " + "确认结果:" + rsp.Flag + " " + "消息:" + rsp.Message);
                        }
                        catch (Exception ex)
                        {
                            log.Error("Error", ex);
                            continue;
                        }

                        if (rsp.Flag == "success")
                        {
                            DbSet <RECEIPT_HEADER_TEMP> header = dbContext.Set <RECEIPT_HEADER_TEMP>();

                            RECEIPT_HEADER_TEMP headerTemp = new RECEIPT_HEADER_TEMP()
                            {
                                COMPANY              = item.COMPANY,
                                ACTUAL_ARRIVE_DATE   = DateTime.Now,
                                TRAILING_STS         = item.TRAILING_STS,
                                INTERNAL_RECEIPT_NUM = item.INTERNAL_RECEIPT_NUM,
                                DATE_TIME_STAMP      = DateTime.Now,
                                RECEIPT_ID           = item.RECEIPT_ID,
                                WAREHOUSE            = item.WAREHOUSE,
                                RECEIPT_TYPE         = item.RECEIPT_TYPE,
                                FLAG    = rsp.Flag,
                                CODE    = rsp.Code,
                                MESSAGE = rsp.Message
                            };
                            header.Add(headerTemp);
                        }
                    }
                    dbContext.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                log.Error("Error", ex);
                return(false);
            }
        }
Ejemplo n.º 13
0
        public void Execute(IJobExecutionContext context)
        {
            string url       = ConfigurationManager.AppSettings["URL"].ToString();
            string appkey    = ConfigurationManager.AppSettings["APPKEY"].ToString(); //"1023883919"; 23883919
            string secret    = ConfigurationManager.AppSettings["SECRET"].ToString(); //"sandboxff0b11ecc626508c171a5b2a2";
            string customeId = ConfigurationManager.AppSettings["CUSTOMEID"].ToString();
            string v         = ConfigurationManager.AppSettings["v"].ToString();

            string[] customerArr = customeId.Split(',');

            try
            {
                _logger.Info("StockoutConfirmJob 开始执行... " + DateTime.Now + "");
                foreach (var cId in customerArr)
                {
                    using (SCVDBContainer dbContext = new SCVDBContainer())
                        using (DBContainer dbContext1 = new DBContainer())
                        {
                            DbSet <SHIPMENT_HEADER> header = dbContext.Set <SHIPMENT_HEADER>();
                            DbSet <SHIPMENT_DETAIL> detail = dbContext.Set <SHIPMENT_DETAIL>();
                            //DbSet<QiMen_PushTimeStatus> dbSet0 = dbContext1.Set<QiMen_PushTimeStatus>();
                            DbSet <QiMen_PushLog> dbSet1 = dbContext1.Set <QiMen_PushLog>();
                            IQimenClient          client;
                            if (cId == "RB")
                            {
                                string rbUrl = "";
                                client = new DefaultQimenClient(rbUrl, appkey, secret, true);
                            }
                            else
                            {
                                client = new DefaultQimenClient(url, appkey, secret);
                            }


                            StockoutConfirmRequest req = new StockoutConfirmRequest();


                            //DateTime lastTime;
                            //QiMen_PushTimeStatus qmt = dbSet0.Where(q => q.CustomerId == cId && q.OrderType == SHIPMENT && q.Interface == INTERFACE).FirstOrDefault();
                            //if (qmt == null)
                            //{
                            //    qmt = new QiMen_PushTimeStatus() { CustomerId = cId, ActualShipTime = DateTime.Now, OrderType = SHIPMENT, Interface = INTERFACE };
                            //    dbSet0.Add(qmt);
                            //    lastTime = DateTime.Now.AddMinutes(-1);
                            //}
                            //else
                            //{
                            //    lastTime = ((DateTime)qmt.ActualShipTime).AddMinutes(-1);
                            //}
                            //&& (h.SHIPMENT_TYPE.Equals("LKCK", StringComparison.OrdinalIgnoreCase))
                            //var confirmlList = header.Where(h => h.COMPANY == cId && h.TRAILING_STS == 900 && h.ACTUAL_SHIP_DATE_TIME >= lastTime).OrderByDescending(h => h.ACTUAL_SHIP_DATE_TIME).Include(s => s.SHIPMENT_DETAIL).Include(s => s.SHIPPING_CONTAINER).AsNoTracking().ToList();
                            var confirmlList = new List <SHIPMENT_HEADER>();

                            if (cId == "XGQQG")
                            {
                                confirmlList = header.Where(h => h.COMPANY == cId &&
                                                            (h.SHIPMENT_CATEGORY6 == null || h.SHIPMENT_CATEGORY6 == QimenPushStatus.Failure.ToString() ||
                                                             h.SHIPMENT_CATEGORY6 == "1" || h.SHIPMENT_CATEGORY6 == "2" || h.SHIPMENT_CATEGORY6 == "3" || h.SHIPMENT_CATEGORY6 == "4" || h.SHIPMENT_CATEGORY6 == "5") &&
                                                            (h.TRAILING_STS == 800 || h.TRAILING_STS == 850 || h.TRAILING_STS == 900) &&
                                                            (h.PROCESS_TYPE == "NORMAL")
                                                            ).Include(s => s.SHIPMENT_DETAIL).Include(s => s.SHIPPING_CONTAINER).ToList();
                            }
                            else
                            {
                                confirmlList = header.Where(h => h.COMPANY == cId &&
                                                            h.CREATE_USER == "StockOutCreate" &&
                                                            (h.SHIPMENT_CATEGORY6 == null || h.SHIPMENT_CATEGORY6 == QimenPushStatus.Failure.ToString() ||
                                                             h.SHIPMENT_CATEGORY6 == "1" || h.SHIPMENT_CATEGORY6 == "2" || h.SHIPMENT_CATEGORY6 == "3" || h.SHIPMENT_CATEGORY6 == "4" || h.SHIPMENT_CATEGORY6 == "5") &&
                                                            (h.TRAILING_STS == 800 || h.TRAILING_STS == 850 || h.TRAILING_STS == 900) &&
                                                            (h.PROCESS_TYPE == "NORMAL")
                                                            ).Include(s => s.SHIPMENT_DETAIL).Include(s => s.SHIPPING_CONTAINER).ToList();
                            }


                            //if (cId == "CQHGE")
                            //{
                            //    confirmlList = confirmlList.Where(l => l.CREATE_USER == "StockOutCreate").ToList();
                            //}

                            if (cId == "XGQQG")
                            {
                                CustomHttpClient.Request.YSJsonDeliveryorderConfirmRequest ysReq = new CustomHttpClient.Request.YSJsonDeliveryorderConfirmRequest();
                                string ysUrl = ysReq.GetApiName();
                                CustomHttpClient.ICustomClient customClient = new CustomHttpClient.DefaultCustomClient(ysUrl, null, null);
                                ysReq.Db       = "shop01";
                                ysReq.Function = "sp_mobile";
                                ysReq.Intype   = "qrcode_out";
                                foreach (var itemHeader in confirmlList)
                                {
                                    var snList = dbContext.SERIAL_NUMBER.Where(s => s.INTERNAL_SHIPMENT_NUM == itemHeader.INTERNAL_SHIPMENT_NUM).ToList();

                                    if (!snList.Any())
                                    {
                                        itemHeader.SHIPMENT_CATEGORY6 = "Skip";
                                    }

                                    int successCount = 0;

                                    foreach (var sn in snList)
                                    {
                                        ysReq.Inpara = itemHeader.SHIPMENT_ID + "," + sn.SERIAL_NUMBER1;
                                        //ysReq.Inpara = "20170416591020," + "MAI2800000009001";
                                        CustomHttpClient.Response.YSJsonDeliveryorderConfirmResponse ysRsp = customClient.Execute(ysReq);
                                        QiMen_PushLog log = new QiMen_PushLog();
                                        log.InternalOrderID = itemHeader.INTERNAL_SHIPMENT_NUM;
                                        log.OrderType       = INTERFACE;
                                        log.CustomerId      = cId;
                                        log.Flag            = ysRsp.Success ? "success" : "failure";
                                        log.Message         = ysRsp.Err + ":" + ysRsp.OutContext;
                                        log.CreateTime      = DateTime.Now;
                                        dbSet1.Add(log);

                                        if (ysRsp.Success)
                                        {
                                            successCount++;
                                            if (successCount == snList.Count())
                                            {
                                                itemHeader.SHIPMENT_CATEGORY6 = QimenPushStatus.Success.ToString();
                                                _logger.Info("出库单:" + itemHeader.SHIPMENT_ID + "确认成功----" + DateTime.Now);
                                            }
                                        }
                                        else
                                        {
                                            if (string.IsNullOrEmpty(itemHeader.SHIPMENT_CATEGORY6))
                                            {
                                                itemHeader.SHIPMENT_CATEGORY6 = "1";
                                            }
                                            else
                                            {
                                                int parseResult;
                                                if (int.TryParse(itemHeader.SHIPMENT_CATEGORY6, out parseResult))
                                                {
                                                    itemHeader.SHIPMENT_CATEGORY6 = (parseResult + 1).ToString();
                                                }
                                            }
                                            _logger.Info("出库单:" + itemHeader.SHIPMENT_ID + "确认失败:-" + ysRsp.OutContext + DateTime.Now);
                                        }
                                    }
                                }
                                dbContext.SaveChanges();
                                dbContext1.SaveChanges();
                                continue;
                            }

                            if (cId == "CH")
                            {
                                req.CustomerId = "CH1";
                            }
                            else
                            {
                                req.CustomerId = cId;
                            }
                            req.Version   = v;
                            req.Timestamp = DateTime.Now;
                            //bool pushFlag = true;

                            foreach (var itemHeader in confirmlList)
                            {
                                StockoutConfirmRequest.DeliveryOrderDomain deliveryOrder = new StockoutConfirmRequest.DeliveryOrderDomain();

                                deliveryOrder.DeliveryOrderCode = itemHeader.SHIPMENT_ID;
                                deliveryOrder.WarehouseCode     = itemHeader.WAREHOUSE;
                                deliveryOrder.OrderType         = itemHeader.SHIPMENT_TYPE;
                                deliveryOrder.ConfirmType       = 0L;
                                deliveryOrder.DeliveryOrderId   = itemHeader.INTERNAL_SHIPMENT_NUM.ToString();
                                deliveryOrder.OutBizCode        = itemHeader.INTERNAL_SHIPMENT_NUM.ToString();
                                deliveryOrder.TotalOrderLines   = (long)itemHeader.TOTAL_LINES;
                                deliveryOrder.Status            = "DELIVERED";

                                req.DeliveryOrder = deliveryOrder;

                                List <StockoutConfirmRequest.PackageDomain>   packageList   = new List <StockoutConfirmRequest.PackageDomain>();
                                List <StockoutConfirmRequest.OrderLineDomain> orderLineList = new List <StockoutConfirmRequest.OrderLineDomain>();

                                foreach (var container in itemHeader.SHIPPING_CONTAINER.Where(t => t.PARENT == 0))
                                {
                                    var childContainer = itemHeader.SHIPPING_CONTAINER.Where(c => c.PARENT == container.INTERNAL_CONTAINER_NUM);
                                    List <StockoutConfirmRequest.ItemDomain> itemList = new List <StockoutConfirmRequest.ItemDomain>();
                                    StockoutConfirmRequest.PackageDomain     package  = new StockoutConfirmRequest.PackageDomain();

                                    foreach (var child in childContainer)
                                    {
                                        StockoutConfirmRequest.ItemDomain itemDomain = new StockoutConfirmRequest.ItemDomain();
                                        itemDomain.ItemCode = child.ITEM;
                                        itemDomain.Quantity = (int)child.QUANTITY;
                                        itemList.Add(itemDomain);
                                    }

                                    if (string.IsNullOrEmpty(deliveryOrder.ExpressCode) || string.IsNullOrEmpty(deliveryOrder.LogisticsCode))
                                    {
                                        deliveryOrder.ExpressCode   = container.TRACKING_NUMBER;
                                        deliveryOrder.LogisticsCode = itemHeader.CARRIER;
                                    }
                                    package.ExpressCode   = container.TRACKING_NUMBER;
                                    package.LogisticsCode = itemHeader.CARRIER;
                                    package.Items         = itemList;
                                    packageList.Add(package);
                                }

                                //---------------package add test data

                                //if (!packageList.Any())
                                //{

                                //    for (int i = 0; i < 1; i++)
                                //    {
                                //        List<StockoutConfirmRequest.ItemDomain> itemList = new List<StockoutConfirmRequest.ItemDomain>();
                                //        StockoutConfirmRequest.PackageDomain package = new StockoutConfirmRequest.PackageDomain();
                                //        StockoutConfirmRequest.ItemDomain itemDomain = new StockoutConfirmRequest.ItemDomain();
                                //        itemDomain.ItemCode = "1000000000203";
                                //        itemDomain.Quantity = 30;
                                //        itemList.Add(itemDomain);
                                //        package.ExpressCode = "012345678905" + i;
                                //        package.LogisticsCode = "SF";
                                //        package.Items = itemList;
                                //        packageList.Add(package);
                                //    }
                                //}
                                //---------------package add test data


                                foreach (var itemDetail in itemHeader.SHIPMENT_DETAIL)
                                {
                                    StockoutConfirmRequest.OrderLineDomain orderLine = new StockoutConfirmRequest.OrderLineDomain();

                                    orderLine.PlanQty       = (int)itemDetail.REQUEST_QTY;
                                    orderLine.ItemCode      = itemDetail.ITEM;
                                    orderLine.ActualQty     = (int)itemDetail.REQUEST_QTY;
                                    orderLine.OutBizCode    = itemDetail.INTERNAL_SHIPMENT_LINE_NUM.ToString();
                                    orderLine.InventoryType = itemDetail.INVENTORY_STS == "合格" ? "ZP" : "CC";
                                    orderLineList.Add(orderLine);
                                }

                                req.Packages   = packageList;
                                req.OrderLines = orderLineList;


                                var rsp = client.Execute(req);

                                QiMen_PushLog log = new QiMen_PushLog();
                                log.InternalOrderID = itemHeader.INTERNAL_SHIPMENT_NUM;
                                log.OrderType       = INTERFACE;
                                log.CustomerId      = cId;
                                log.Flag            = rsp.Flag;
                                log.Message         = rsp.Message;
                                log.CreateTime      = DateTime.Now;
                                dbSet1.Add(log);

                                if (rsp.Flag == "success")
                                {
                                    itemHeader.SHIPMENT_CATEGORY6 = QimenPushStatus.Success.ToString();
                                    _logger.Info("出库单:" + itemHeader.SHIPMENT_ID + "确认成功----" + DateTime.Now);
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(itemHeader.SHIPMENT_CATEGORY6))
                                    {
                                        itemHeader.SHIPMENT_CATEGORY6 = "1";
                                    }
                                    else
                                    {
                                        int parseResult;
                                        if (int.TryParse(itemHeader.SHIPMENT_CATEGORY6, out parseResult))
                                        {
                                            itemHeader.SHIPMENT_CATEGORY6 = (parseResult + 1).ToString();
                                        }
                                    }
                                    //if (rsp.Message.Length > 50)
                                    //{
                                    //    pushFlag = false;
                                    //}
                                    _logger.Info("出库单:" + itemHeader.SHIPMENT_ID + "确认失败:-" + rsp.Message + DateTime.Now);
                                }
                            }
                            //  if (confirmlList.Count > 0 && pushFlag) {
                            //if (confirmlList.Count > 0 && pushFlag)
                            //{
                            //    qmt.ActualShipTime = (DateTime)confirmlList.First().ACTUAL_SHIP_DATE_TIME;
                            //}
                            dbContext.SaveChanges();
                            dbContext1.SaveChanges();
                        }
                }
                _logger.Info("StockoutConfirmJob 执行完成... " + DateTime.Now + "");
            }
            catch (Exception ex)
            {
                _logger.Error("StockoutConfirmJob 异常..." + DateTime.Now + " " + ex.Message);
            }
        }
Ejemplo n.º 14
0
        // POST: api/ReturnorderCreate
        public ReturnorderCreateResponseModel Post([FromBody] ReturnorderCreateRequestModel model, [FromUri] string customerId)
        {
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            ReturnorderCreateResponseModel response = new ReturnorderCreateResponseModel();

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "ReturnorderCreate";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                //DbSet<RECEIPT_HEADER> dbSet0 = dbContext.Set<RECEIPT_HEADER>();
                //DbSet<RECEIPT_DETAIL> dbSet1 = dbContext.Set<RECEIPT_DETAIL>();
                DbSet <ITEM> dbSetItem = dbContext.Set <ITEM>();

                if (dbContext.RECEIPT_HEADER.Where(h => h.RECEIPT_ID == model.ReturnOrder.ReturnOrderCode && h.COMPANY == customerId).Any())
                {
                    response.Flag          = "success";
                    response.Code          = "0";
                    response.Message       = model.ReturnOrder.ReturnOrderCode + ":单号重复";
                    response.ReturnOrderId = "";
                    return(response);
                }

                RECEIPT_HEADER header = new RECEIPT_HEADER();
                header.COMPANY      = customerId;
                header.RECEIPT_ID   = model.ReturnOrder.ReturnOrderCode;
                header.WAREHOUSE    = "LK01";
                header.LEADING_STS  = 100;
                header.TRAILING_STS = 100;
                header.RECEIPT_TYPE = model.ReturnOrder.OrderType;
                header.CREATE_USER  = "******";

                if (!string.IsNullOrEmpty(model.ReturnOrder.ExpressCode))
                {
                    header.ERP_ORDER_ID = model.ReturnOrder.ExpressCode;
                }
                if (!string.IsNullOrEmpty(model.ReturnOrder.SenderInfo.DetailAddress))
                {
                    header.SHIP_FROM_ADDRESS1 = model.ReturnOrder.SenderInfo.DetailAddress;
                }
                if (!string.IsNullOrEmpty(model.ReturnOrder.SenderInfo.City))
                {
                    header.SHIP_FROM_CITY = model.ReturnOrder.SenderInfo.City;
                }
                if (!string.IsNullOrEmpty(model.ReturnOrder.SenderInfo.Province))
                {
                    header.SHIP_FROM_STATE = model.ReturnOrder.SenderInfo.Province;
                }
                if (!string.IsNullOrEmpty(model.ReturnOrder.SenderInfo.ZipCode))
                {
                    header.SHIP_FROM_POSTAL_CODE = model.ReturnOrder.SenderInfo.ZipCode;
                }
                if (!string.IsNullOrEmpty(model.ReturnOrder.SenderInfo.Name))
                {
                    header.SHIP_FROM              = model.ReturnOrder.SenderInfo.Name;
                    header.SHIP_FROM_NAME         = model.ReturnOrder.SenderInfo.Name;
                    header.SHIP_FROM_ATTENTION_TO = model.ReturnOrder.SenderInfo.Name;
                }

                if (!string.IsNullOrEmpty(model.ReturnOrder.SenderInfo.Mobile))
                {
                    header.SHIP_FROM_FAX_NUM = model.ReturnOrder.SenderInfo.Mobile;
                }
                header.USER_STAMP        = "Interface";
                header.SHIP_FROM_COUNTRY = "CN";

                //DateTime orderCreateTime;
                //if (DateTime.TryParse(model.ReturnOrder.OrderCreateTime, out orderCreateTime))
                //{
                header.CREATE_DATE = DateTime.Now;
                //}
                //int totalLines = Convert.ToInt32(model.EntryOrder.TotalOrderLines);

                int totalLines = model.OrderLines.Count();
                int totalQty   = 0;
                header.TOTAL_LINES = totalLines;

                foreach (var item in model.OrderLines)
                {
                    RECEIPT_DETAIL detail = new RECEIPT_DETAIL();
                    detail.RECEIPT_ID = model.ReturnOrder.ReturnOrderCode;
                    detail.WAREHOUSE  = "LK01";
                    detail.COMPANY    = item.OwnerCode;
                    detail.ITEM       = item.ItemCode;

                    ITEM sItem = dbSetItem.Where(t => t.ITEM1 == item.ItemCode).FirstOrDefault();
                    if (sItem != null)
                    {
                        detail.ITEM_DESC = sItem.ITEM_DESC;
                    }
                    detail.TOTAL_QTY   = item.PlanQty;
                    detail.OPEN_QTY    = item.PlanQty;
                    detail.QUANTITY_UM = "EA";
                    totalQty          += Convert.ToInt32(item.PlanQty);
                    header.RECEIPT_DETAIL.Add(detail);
                    //if (string.Equals("ZP", item.InventoryType, StringComparison.CurrentCultureIgnoreCase))
                    //{
                    //    detail.INVENTORY_STS = "合格";
                    //}
                    //else
                    //{
                    //    detail.INVENTORY_STS = "不合格";
                    //}

                    if (item.InventoryType == null)
                    {
                        detail.INVENTORY_STS = "合格";
                    }
                    else
                    {
                        if (string.Equals("ZP", item.InventoryType, StringComparison.CurrentCultureIgnoreCase))
                        {
                            detail.INVENTORY_STS = "合格";
                        }
                        else
                        {
                            detail.INVENTORY_STS = "不合格";
                        }
                    }
                }

                header.TOTAL_QTY = totalQty;
                dbContext.RECEIPT_HEADER.Add(header);

                if (dbContext.SaveChanges() > 0)
                {
                    response.Flag          = "success";
                    response.Code          = "1";
                    response.Message       = "入库单:" + model.ReturnOrder.ReturnOrderCode + ":创建成功";
                    response.ReturnOrderId = header.INTERNAL_RECEIPT_NUM.ToString();
                }
                else
                {
                    response.Flag          = "failure";
                    response.Code          = "-1";
                    response.Message       = "入库单:" + model.ReturnOrder.ReturnOrderCode + ":创建失败";
                    response.ReturnOrderId = "";
                }
            }
            return(response);
        }
Ejemplo n.º 15
0
        //ValidationErrors error = new ValidationErrors();

        public void Execute(IJobExecutionContext context)
        {
            //IServiceSession serviceSession = DI.GetObject<IService.IServiceSession>("ServiceSession");
            //ISCVServiceSession sserviceSession = DI.GetObject<IService.SCV.ISCVServiceSession>("SCVServiceSession");


            using (SCVDBContainer _SCVdbContext = new SCVDBContainer())
                using (DBContainer dbContext = new DBContainer())
                {
                    DbSet <Spm_ExpressInfo> dbSet  = dbContext.Set <Spm_ExpressInfo>();
                    DbSet <Spm_LastTime>    dbSet0 = dbContext.Set <Spm_LastTime>();
                    Spm_LastTime            sl     = dbSet0.Find("1");
                    Spm_LastTime            sl0    = dbSet0.Find("Trackingmore0");
                    Spm_LastTime            sl1    = dbSet0.Find("Trackingmore1");
                    Spm_LastTime            sl2    = dbSet0.Find("Trackingmore2");
                    Spm_LastTime            sl3    = dbSet0.Find("Trackingmore3");
                    Spm_LastTime            sl4    = dbSet0.Find("Trackingmore4");
                    Spm_LastTime            sl5    = dbSet0.Find("Trackingmore5");

                    int num0 = (int)sl0.Kd100Flag;
                    int num1 = (int)sl1.Kd100Flag;
                    int num2 = (int)sl2.Kd100Flag;
                    int num3 = (int)sl3.Kd100Flag;
                    int num4 = (int)sl4.Kd100Flag;
                    int num5 = (int)sl5.Kd100Flag;

                    DateTime lastTime = ((DateTime)sl.ActualShipDateTime).AddMinutes(-5);

                    //DateTime lastTime = DateTime.Parse("2017-05-08 00:00:00.000");

                    //IQueryable spmContainer;
                    //------------------
                    //DateTime time1 = DateTime.Now.AddHours(-60);
                    //DateTime time2 = DateTime.Now.AddHours(-45);
                    //-------------------

                    var spmContainer =
                        (
                            from h in _SCVdbContext.SHIPMENT_HEADER
                            join c in _SCVdbContext.SHIPPING_CONTAINER
                            on h.INTERNAL_SHIPMENT_NUM equals c.INTERNAL_SHIPMENT_NUM
                            where h.TRAILING_STS == 900 && h.ACTUAL_SHIP_DATE_TIME >= lastTime &&
                            c.PARENT == 0 && c.STATUS == 900
                            select new { h, c }
                        ).Distinct(o => o.c.TRACKING_NUMBER).OrderByDescending(a => a.h.ACTUAL_SHIP_DATE_TIME).ToList();
                    //Distinct(o => o.c.TRACKING_NUMBER).

                    //var spmContainer = _SCVdbContext.Set<SHIPPING_CONTAINER>().Where(s => s.PARENT == 0 && s.STATUS == 900 && s.OQC_END_DATE_TIME > lastTime).OrderByDescending(o => o.OQC_END_DATE_TIME);
                    //var spmContainer = _SCVdbContext.Set<SHIPPING_CONTAINER>().Where(s => s.PARENT == 0 && s.STATUS == 900 && s.OQC_END_DATE_TIME > lastTime).OrderByDescending(o => o.OQC_END_DATE_TIME);
                    //KdApiOrderDistinguish orderDistinguish = new KdApiOrderDistinguish();
                    //int spmCount = spmContainer.Count();

                    List <Spm_ExpressInfo> exInfoList = dbSet.ToList();
                    List <Spm_ExpressInfo> addList    = new List <Spm_ExpressInfo>();
                    List <SubscribeModel>  ttList     = new List <SubscribeModel>();


                    ParallelOptions parallelOptions = new ParallelOptions();
                    parallelOptions.MaxDegreeOfParallelism = 6;
                    System.Object lockThis = new System.Object();

                    Parallel.ForEach(spmContainer, parallelOptions, item =>
                    {
                        KdApiSubscribe subscribe = new KdApiSubscribe();
                        //Dictionary<string, string> dic = OrderIdentification.Distinguish(item.h.CARRIER);

                        //if (dic["Code"] != "LK")
                        //{
                        //    try
                        //    {

                        //        KdApiSubscribeModel resultB = JsonConvert.DeserializeObject<KdApiSubscribeModel>(subscribe.orderTracesSubByJson(item.c.TRACKING_NUMBER, dic["Code"]));
                        //        if (resultB.Success)
                        //        {

                        //        }
                        //    }
                        //    catch (Exception ex)
                        //    {

                        //        ILog log = LogManager.GetLogger(typeof(SpmExpressJob));
                        //        log.Error("订阅快递鸟出错", ex);
                        //    }
                        //}

                        //int count;
                        //using (DBContainer tempC = new DBContainer())
                        //{
                        //    count = tempC.Set<Spm_ExpressInfo>().Where(s => s.TrackingNumber == item.c.TRACKING_NUMBER).Count();
                        //}
                        if (exInfoList.Where(s => s.TrackingNumber == item.c.TRACKING_NUMBER).Count() <= 0)
                        //if (count <= 0)
                        {
                            Spm_ExpressInfo eModel = new Spm_ExpressInfo()
                            {
                                Id = ResultHelper.NewId,
                                ActualShipDateTime = (DateTime)item.h.ACTUAL_SHIP_DATE_TIME,
                                TrackingNumber     = item.c.TRACKING_NUMBER,
                                Company            = item.h.COMPANY,
                                State         = item.c.STATUS.ToString(),
                                ShipmentId    = item.c.SHIPMENT_ID,
                                DateTimeStamp = item.c.DATE_TIME_STAMP,
                                PushTime      = DateTime.Now,
                            };

                            Dictionary <string, string> dic = OrderIdentification.Distinguish(item.h.CARRIER);

                            if (dic["Code"] != "LK")
                            {
                                if (dic["Code"] == "HHTT")
                                {
                                    ttList.Add(new SubscribeModel
                                    {
                                        tracking_number = item.c.TRACKING_NUMBER
                                        ,
                                        carrier_code = "ttkd"
                                    });
                                }
                                try
                                {
                                    KdApiSubscribeModel resultB = JsonConvert.DeserializeObject <KdApiSubscribeModel>(subscribe.orderTracesSubByJson(item.c.TRACKING_NUMBER, dic["Code"]));
                                    if (resultB.Success)
                                    {
                                        eModel.ShipperCode = dic["Code"] + ":" + dic["Name"];
                                    }
                                    else
                                    {
                                        eModel.ShipperCode = dic["Code"] + ":" + dic["Name"];
                                        eModel.State       = "-1";
                                    }
                                }
                                catch (Exception ex)
                                {
                                    eModel.State       = "-1";
                                    eModel.ShipperCode = dic["Code"] + ":" + dic["Name"];
                                    ILog log           = LogManager.GetLogger(typeof(SpmExpressJob));
                                    log.Error("订阅出错", ex);
                                }
                            }
                            else
                            {
                                eModel.ShipperCode = dic["Code"] + ":" + dic["Name"];
                            }
                            //dbSet.Add(eModel);
                            lock (lockThis)
                            {
                                addList.Add(eModel);
                            }
                            //dbContext.Entry<Spm_ExpressInfo>(eModel).State = EntityState.Added;
                        }
                    });



                    if (ttList.Count() > 0)
                    {
                        int count = ttList.Count() / 40;
                        for (int i = 0; i <= count; i++)
                        {
                            int    ct = i * 40;
                            string requestdata;
                            IEnumerable <SubscribeModel> sbData = new List <SubscribeModel>();
                            if (i == count)
                            {
                                int tk = ttList.Count() % 40;
                                sbData = ttList.Skip(ct).Take(tk);
                            }
                            else
                            {
                                sbData = ttList.Skip(ct).Take(40);
                            }

                            try
                            {
                                int requestCount = sbData.Count();
                                //string requestdata = "[{\"tracking_number\": \"1047435554520\",\"carrier_code\":\"china-ems\"},{\"tracking_number\": \"1047435555420\",\"carrier_code\":\"china-ems\"}]";
                                if (requestCount > 0)
                                {
                                    requestdata = JsonConvert.SerializeObject(sbData);
                                    string result = null;
                                    if (num0 >= requestCount)
                                    {
                                        num0  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper0().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num1 >= requestCount)
                                    {
                                        num1  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper1().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num2 >= requestCount)
                                    {
                                        num2  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper2().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num3 >= requestCount)
                                    {
                                        num3  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper3().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num4 >= requestCount)
                                    {
                                        num4  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper4().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num5 >= requestCount)
                                    {
                                        num5  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper5().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    if (!string.IsNullOrEmpty(result))
                                    {
                                        TrackingBatchModel tbm = JsonConvert.DeserializeObject <TrackingBatchModel>(result);
                                        if (tbm != null && tbm.data.errors != null)
                                        {
                                            foreach (var item in tbm.data.errors)
                                            {
                                                if (item.code != 4016)
                                                {
                                                    addList.Where(o => o.TrackingNumber == item.tracking_number).First().State = "-1";
                                                    //dbSet.Where(o => o.TrackingNumber == item.tracking_number).First().State = "-1";
                                                }
                                            }
                                        }
                                    }
                                }
                                Thread.Sleep(200);
                            }
                            catch
                            {
                                foreach (var item in sbData)
                                {
                                    addList.Where(o => o.TrackingNumber == item.tracking_number).First().State = "-1";
                                    //dbSet.Where(o => o.TrackingNumber == item.tracking_number).First().State = "-1";
                                }
                                Thread.Sleep(200);
                            }
                        }
                    }

                    if (spmContainer.Count() > 0)
                    {
                        //foreach (var item in spmContainer)
                        //{
                        //}
                        dbSet.AddRange(addList);
                        //foreach (var item in addList) {
                        //    dbSet.AddRange(list);
                        //}
                        sl.ActualShipDateTime = (DateTime)spmContainer.First().h.ACTUAL_SHIP_DATE_TIME;
                    }


                    List <Spm_ExpressInfo> dy0 = dbSet.Where(o => o.State == "-1" && o.ShipperCode == "HHTT:天天快递").ToList();

                    //IQueryable<Spm_ExpressInfo> dy0 = dbSet.Where(o => o.State == "-1" && o.ShipperCode == "HHTT:天天快递");
                    if (dy0.Count() > 0)
                    {
                        List <SubscribeModel> sbData0 = new List <SubscribeModel>();
                        foreach (var item in dy0)
                        {
                            sbData0.Add(new SubscribeModel {
                                tracking_number = item.TrackingNumber, carrier_code = "ttkd"
                            });
                        }

                        int count = sbData0.Count() / 40;
                        for (int i = 0; i <= count; i++)
                        {
                            int    ct = i * 40;
                            string requestdata;
                            IEnumerable <SubscribeModel> sbData = new List <SubscribeModel>();
                            if (i == count)
                            {
                                int tk = sbData0.Count() % 40;
                                sbData = sbData0.Skip(ct).Take(tk);
                            }
                            else
                            {
                                sbData = sbData0.Skip(ct).Take(40);
                            }

                            try
                            {
                                int requestCount = sbData.Count();
                                //string requestdata = "[{\"tracking_number\": \"1047435554520\",\"carrier_code\":\"china-ems\"},{\"tracking_number\": \"1047435555420\",\"carrier_code\":\"china-ems\"}]";
                                if (requestCount > 0)
                                {
                                    requestdata = JsonConvert.SerializeObject(sbData);
                                    string result = null;
                                    if (num0 >= requestCount)
                                    {
                                        num0  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper0().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num1 >= requestCount)
                                    {
                                        num1  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper1().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num2 >= requestCount)
                                    {
                                        num2  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper2().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num3 >= requestCount)
                                    {
                                        num3  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper3().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num4 >= requestCount)
                                    {
                                        num4  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper4().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    else if (num5 >= requestCount)
                                    {
                                        num5  -= requestCount;
                                        result = new KdHelper.TrackingMoreHelper5().getOrderTracesByJson(requestdata, null, "batch");
                                    }
                                    if (!string.IsNullOrEmpty(result))
                                    {
                                        TrackingBatchModel tbm = JsonConvert.DeserializeObject <TrackingBatchModel>(result);
                                        if (tbm != null && tbm.data.errors != null)
                                        {
                                            foreach (var item in tbm.data.errors)
                                            {
                                                if (item.code != 4016)
                                                {
                                                    dbSet.Where(o => o.TrackingNumber == item.tracking_number).First().State = "-1";
                                                }
                                            }
                                        }
                                        else
                                        {
                                            foreach (var item in sbData)
                                            {
                                                dbSet.Where(o => o.TrackingNumber == item.tracking_number).First().State = "0";
                                            }
                                        }
                                    }
                                }
                                Thread.Sleep(200);
                            }
                            catch
                            {
                                foreach (var item in sbData)
                                {
                                    dbSet.Where(o => o.TrackingNumber == item.tracking_number).First().State = "1";
                                }
                                Thread.Sleep(200);
                            }
                        }
                    }

                    sl0.Kd100Flag = num0;
                    sl1.Kd100Flag = num1;
                    sl2.Kd100Flag = num2;
                    sl3.Kd100Flag = num3;
                    sl4.Kd100Flag = num4;
                    sl5.Kd100Flag = num5;



                    IQueryable <Spm_ExpressInfo> dy = dbSet.Where(o => o.State == "-1" && o.ShipperCode != "HHTT:天天快递");

                    if (dy.Count() > 0)
                    {
                        KdApiSubscribe subscribe = new KdApiSubscribe();
                        foreach (var item in dy)
                        {
                            try
                            {
                                KdApiSubscribeModel resultB = JsonConvert.DeserializeObject <KdApiSubscribeModel>(subscribe.orderTracesSubByJson(item.TrackingNumber, item.ShipperCode.Split(':')[0]));
                                if (resultB.Success)
                                {
                                    item.State = "900";
                                }
                                else
                                {
                                    item.State = "-1";
                                }
                            }
                            catch (Exception ex)
                            {
                                item.State = "-1";
                                ILog log = LogManager.GetLogger(typeof(SpmExpressJob));
                                log.Error("订阅快递鸟出错", ex);
                            }
                        }
                    }

                    Spm_ExpressInfo t = dbSet.Where(o => o.Id == "test").First();
                    t.DateTimeStamp = DateTime.Now.AddYears(-1);

                    DateTime resetTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).AddMinutes(5);
                    if (DateTime.Now < resetTime)
                    {
                        sl0.ActualShipDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                        sl0.Kd100Flag          = 200;

                        sl1.ActualShipDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                        sl1.Kd100Flag          = 500;

                        sl2.ActualShipDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                        sl2.Kd100Flag          = 500;

                        sl3.ActualShipDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                        sl3.Kd100Flag          = 500;

                        sl4.ActualShipDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                        sl4.Kd100Flag          = 500;

                        sl5.ActualShipDateTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                        sl5.Kd100Flag          = 500;
                    }

                    dbContext.SaveChanges();
                }
        }
Ejemplo n.º 16
0
        public void Execute(IJobExecutionContext context)
        {
            string url       = ConfigurationManager.AppSettings["URL"].ToString();
            string appkey    = ConfigurationManager.AppSettings["APPKEY"].ToString(); //"1023883919"; 23883919
            string secret    = ConfigurationManager.AppSettings["SECRET"].ToString(); //"sandboxff0b11ecc626508c171a5b2a2";
            string customeId = ConfigurationManager.AppSettings["CUSTOMEID"].ToString();
            string v         = ConfigurationManager.AppSettings["v"].ToString();

            string[] customerArr = customeId.Split(',');


            try
            {
                _logger.Info("DeliveryorderConfirmJob 开始执行... " + DateTime.Now + "");
                //_logger.Info(1,"Reicept","123", "Success","开始执行");
                //for (int i = 0; i < 5; i++)
                //{
                //    _logger.Info("SimpleQuartzJob start... " + i + " " + DateTime.Now + "");
                //    Console.WriteLine("SimpleQuartzJob running..." + i);
                //}
                foreach (var cId in customerArr)
                {
                    using (SCVDBContainer dbContext = new SCVDBContainer())
                        using (DBContainer dbContext1 = new DBContainer())
                        {
                            DbSet <SHIPMENT_HEADER> header = dbContext.Set <SHIPMENT_HEADER>();
                            DbSet <SHIPMENT_DETAIL> detail = dbContext.Set <SHIPMENT_DETAIL>();
                            //DbSet<SHIPMENT_HEADER_TEMP> headerTemp = dbContext.Set<SHIPMENT_HEADER_TEMP>();
                            //DbSet<QiMen_PushTimeStatus> dbSet0 = dbContext1.Set<QiMen_PushTimeStatus>();
                            DbSet <QiMen_PushLog> dbSet1 = dbContext1.Set <QiMen_PushLog>();
                            //Spm_LastTime sl = dbSet0.Find("1");
                            //DateTime lastTime = ((DateTime)sl.ActualShipDateTime).AddMinutes(-1);

                            IQimenClient client             = new DefaultQimenClient(url, appkey, secret);
                            DeliveryorderConfirmRequest req = new DeliveryorderConfirmRequest();


                            //DateTime lastTime;
                            //QiMen_PushTimeStatus qmt = dbSet0.Where(q => q.CustomerId == cId && q.OrderType == SHIPMENT && q.Interface == INTERFACE).FirstOrDefault();
                            //if (qmt == null)
                            //{
                            //    qmt = new QiMen_PushTimeStatus() { CustomerId = cId, ActualShipTime = DateTime.Now, OrderType = SHIPMENT, Interface = INTERFACE };
                            //    dbSet0.Add(qmt);
                            //    lastTime = DateTime.Now.AddMinutes(-1);
                            //}
                            //else
                            //{
                            //    lastTime = ((DateTime)qmt.ActualShipTime).AddMinutes(-1);
                            //}
                            //DateTime lastTime = dbSet0.Where()   //&& !(h.SHIPMENT_TYPE.Equals("LKCK", StringComparison.OrdinalIgnoreCase))
                            //var confirmlList = header.Where(h => h.COMPANY == cId && h.TRAILING_STS == 900 && h.ACTUAL_SHIP_DATE_TIME >= lastTime).OrderByDescending(h => h.ACTUAL_SHIP_DATE_TIME).Include(s => s.SHIPMENT_DETAIL).Include(s => s.SHIPPING_CONTAINER).AsNoTracking().ToList();
                            var confirmlList = header.Where(h => h.COMPANY == cId &&
                                                            h.CREATE_USER == "DeliveryorderCreate" &&
                                                            (h.SHIPMENT_CATEGORY6 == null || h.SHIPMENT_CATEGORY6 == QimenPushStatus.Failure.ToString() ||
                                                             h.SHIPMENT_CATEGORY6 == "1" || h.SHIPMENT_CATEGORY6 == "2" || h.SHIPMENT_CATEGORY6 == "3" || h.SHIPMENT_CATEGORY6 == "4" || h.SHIPMENT_CATEGORY6 == "5") &&
                                                            (h.TRAILING_STS == 800 || h.TRAILING_STS == 850 || h.TRAILING_STS == 900) &&
                                                            (h.PROCESS_TYPE == "NORMAL")
                                                            ).Include(s => s.SHIPMENT_DETAIL).Include(s => s.SHIPPING_CONTAINER).ToList();

                            if (cId == "XGQQG")
                            {
                                confirmlList.Clear();
                            }


                            //if (cId == "CQHGE")
                            //{
                            //    confirmlList = confirmlList.Where(l => l.CREATE_USER == "DeliveryorderCreate").ToList();
                            //}

                            if (cId == "CH")
                            {
                                req.CustomerId = "CH1";
                            }
                            else
                            {
                                req.CustomerId = cId;
                            }
                            req.Version   = v;
                            req.Timestamp = DateTime.Now;
                            //bool pushFlag = true;

                            foreach (var itemHeader in confirmlList)
                            {
                                DeliveryorderConfirmRequest.DeliveryOrderDomain deliveryOrder = new DeliveryorderConfirmRequest.DeliveryOrderDomain();
                                deliveryOrder.DeliveryOrderCode = itemHeader.SHIPMENT_ID;
                                deliveryOrder.WarehouseCode     = itemHeader.WAREHOUSE;
                                deliveryOrder.OrderType         = itemHeader.SHIPMENT_TYPE; //"JYCK"
                                deliveryOrder.ConfirmType       = 0L;                       //仅仅确认最终状态的订单
                                deliveryOrder.OutBizCode        = itemHeader.INTERNAL_SHIPMENT_NUM.ToString();
                                deliveryOrder.DeliveryOrderId   = itemHeader.INTERNAL_SHIPMENT_NUM.ToString();
                                req.DeliveryOrder = deliveryOrder;


                                List <DeliveryorderConfirmRequest.PackageDomain>   packageList   = new List <DeliveryorderConfirmRequest.PackageDomain>();
                                List <DeliveryorderConfirmRequest.OrderLineDomain> orderLineList = new List <DeliveryorderConfirmRequest.OrderLineDomain>();

                                foreach (var container in itemHeader.SHIPPING_CONTAINER.Where(t => t.PARENT == 0))
                                {
                                    var childContainer = itemHeader.SHIPPING_CONTAINER.Where(c => c.PARENT == container.INTERNAL_CONTAINER_NUM);
                                    List <DeliveryorderConfirmRequest.ItemDomain> itemList = new List <DeliveryorderConfirmRequest.ItemDomain>();
                                    DeliveryorderConfirmRequest.PackageDomain     package  = new DeliveryorderConfirmRequest.PackageDomain();

                                    foreach (var child in childContainer)
                                    {
                                        DeliveryorderConfirmRequest.ItemDomain itemDomain = new DeliveryorderConfirmRequest.ItemDomain();
                                        itemDomain.ItemCode = child.ITEM;
                                        itemDomain.Quantity = (int)child.QUANTITY;
                                        itemList.Add(itemDomain);
                                    }

                                    package.ExpressCode   = container.TRACKING_NUMBER;
                                    package.LogisticsCode = itemHeader.CARRIER;
                                    package.Items         = itemList;
                                    packageList.Add(package);
                                }
                                //---------------package add test data
                                //if (!packageList.Any())
                                //{

                                //    for (int i = 0; i < 1; i++)
                                //    {
                                //        List<DeliveryorderConfirmRequest.ItemDomain> itemList = new List<DeliveryorderConfirmRequest.ItemDomain>();
                                //        DeliveryorderConfirmRequest.PackageDomain package = new DeliveryorderConfirmRequest.PackageDomain();
                                //        DeliveryorderConfirmRequest.ItemDomain itemDomain = new DeliveryorderConfirmRequest.ItemDomain();
                                //        itemDomain.ItemCode = "1000000000203";
                                //        itemDomain.Quantity = 30;
                                //        itemList.Add(itemDomain);
                                //        package.ExpressCode = "000123456780" + i;
                                //        package.LogisticsCode = "FAST";
                                //        package.Items = itemList;
                                //        packageList.Add(package);
                                //    }
                                //}
                                //---------------package add test data

                                foreach (var itemDetail in itemHeader.SHIPMENT_DETAIL)
                                {
                                    DeliveryorderConfirmRequest.OrderLineDomain orderLine = new DeliveryorderConfirmRequest.OrderLineDomain();

                                    orderLine.PlanQty    = itemDetail.REQUEST_QTY.ToString();
                                    orderLine.ItemCode   = itemDetail.ITEM;
                                    orderLine.ActualQty  = itemDetail.REQUEST_QTY.ToString();
                                    orderLine.OutBizCode = itemDetail.INTERNAL_SHIPMENT_LINE_NUM.ToString();
                                    orderLineList.Add(orderLine);
                                }
                                req.Packages   = packageList;
                                req.OrderLines = orderLineList;

                                var rsp = client.Execute(req);

                                QiMen_PushLog log = new QiMen_PushLog();
                                log.InternalOrderID = itemHeader.INTERNAL_SHIPMENT_NUM;
                                log.OrderType       = INTERFACE;
                                log.CustomerId      = cId;
                                log.Flag            = rsp.Flag;
                                log.Message         = rsp.Message;
                                log.CreateTime      = DateTime.Now;
                                dbSet1.Add(log);

                                if (rsp.Flag == "success")
                                {
                                    itemHeader.SHIPMENT_CATEGORY6 = QimenPushStatus.Success.ToString();
                                    _logger.Info("发货单:" + itemHeader.SHIPMENT_ID + "确认成功----" + DateTime.Now);
                                }
                                else
                                {
                                    if (string.IsNullOrEmpty(itemHeader.SHIPMENT_CATEGORY6))
                                    {
                                        itemHeader.SHIPMENT_CATEGORY6 = "1";
                                    }
                                    else
                                    {
                                        int parseResult;
                                        if (int.TryParse(itemHeader.SHIPMENT_CATEGORY6, out parseResult))
                                        {
                                            itemHeader.SHIPMENT_CATEGORY6 = (parseResult + 1).ToString();
                                        }
                                    }
                                    //if (rsp.Message.Length > 50)
                                    //{
                                    //    pushFlag = false;
                                    //}
                                    _logger.Info("发货单:" + itemHeader.SHIPMENT_ID + "确认失败:-" + rsp.Message + DateTime.Now);
                                }
                            }

                            //if (confirmlList.Count > 0 && pushFlag)
                            //{
                            //    qmt.ActualShipTime = (DateTime)confirmlList.First().ACTUAL_SHIP_DATE_TIME;
                            //}
                            dbContext.SaveChanges();
                            dbContext1.SaveChanges();
                        }
                }
                _logger.Info("DeliveryorderConfirmJob 执行完成... " + DateTime.Now + "");
            }
            catch (Exception ex)
            {
                _logger.Error("DeliveryorderConfirmJob 异常..." + DateTime.Now + " " + ex.Message);
            }
        }