コード例 #1
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public IpMaster ShipScheduleLine(string flow, IList<ScheduleLineInput> scheduleLineInputList)
        {
            IList<OrderDetail> shipOrderDetailList = new List<OrderDetail>();
            StringBuilder selectOrderDetailStatement = new StringBuilder();
            IList<object> selectOrderDetailParam = new List<object>();
            StringBuilder selectOrderMasterStatement = new StringBuilder();
            IList<object> selectOrderMasterParam = new List<object>();
            StringBuilder selectShippedQtyStatement = new StringBuilder();
            IList<object> selectShippedQtyParam = new List<object>();

            foreach (ScheduleLineInput scheduleLineInput in scheduleLineInputList)
            {
                if (selectOrderDetailStatement.Length == 0)
                {
                    selectOrderDetailStatement.Append("select * from ORD_OrderDet_8 where EBELN_EBELP in (?");
                    selectOrderMasterStatement.Append("select mstr.* from ORD_OrderMstr_8 as mstr inner join ORD_OrderDet_8 as det on mstr.OrderNo = det.OrderNo where det.EBELN_EBELP in (?");
                    selectShippedQtyStatement.Append(@"select EBELN_EBELP, SUM(CASE WHEN IsClose = 1 THEN RecQty ELSE (CASE WHEN RecQty = 0 THEN Qty ELSE RecQty END) END) as shipQty
                                                    from ORD_IpDet_8 with(NOLOCK) where type <> 1 and EBELN_EBELP in (?");
                }
                else
                {
                    selectOrderDetailStatement.Append(",?");
                    selectOrderMasterStatement.Append(",?");
                    selectShippedQtyStatement.Append(",?");
                }
                selectOrderDetailParam.Add(scheduleLineInput.EBELN + "&" + scheduleLineInput.EBELP);
                selectOrderMasterParam.Add(scheduleLineInput.EBELN + "&" + scheduleLineInput.EBELP);
                selectShippedQtyParam.Add(scheduleLineInput.EBELN + "&" + scheduleLineInput.EBELP);
            }
            selectOrderDetailStatement.Append(")");
            selectOrderMasterStatement.Append(")");
            selectShippedQtyStatement.Append(") group by EBELN_EBELP");

            IList<OrderDetail> orderDetailList = this.genericMgr.FindEntityWithNativeSql<OrderDetail>(selectOrderDetailStatement.ToString(), selectOrderDetailParam.ToArray());
            IList<OrderMaster> orderMasterList = this.genericMgr.FindEntityWithNativeSql<OrderMaster>(selectOrderMasterStatement.ToString(), selectOrderMasterParam.ToArray());
            IList<object[]> shippedQtyList = this.genericMgr.FindAllWithNativeSql<object[]>(selectShippedQtyStatement.ToString(), selectShippedQtyParam.ToArray());

            BusinessException businessException = new BusinessException();
            foreach (ScheduleLineInput scheduleLineInput in scheduleLineInputList)
            {
                OrderDetail orderDetail = orderDetailList.Where(det => det.ExternalOrderNo == scheduleLineInput.EBELN && det.ExternalSequence == scheduleLineInput.EBELP).Single();
                OrderMaster orderMaster = orderMasterList.Where(mstr => mstr.OrderNo == orderDetail.OrderNo).First();
                decimal shippedQty = shippedQtyList.Where(s => (string)s[0] == scheduleLineInput.EBELN + "&" + scheduleLineInput.EBELP).Select(s => (decimal)s[1]).SingleOrDefault();

                if (shippedQty + scheduleLineInput.ShipQty > scheduleLineInput.SureShipQty)
                {
                    businessException.AddMessage("计划协议号{0}行号{1}的需求数不足。", scheduleLineInput.EBELN, scheduleLineInput.EBELP);
                }

                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetail.AddOrderDetailInput(orderDetailInput);
                shipOrderDetailList.Add(orderDetail);
                orderDetail.CurrentOrderMaster = orderMaster;
                orderDetailInput.ShipQty = scheduleLineInput.ShipQty;
            }

            //计划协议发货判断待发货明细是否存在同一物料号既有寄售合同又有非寄售合同
            shipOrderDetailList.OrderBy(s => s.Item);
            for (int i = 1; i < shipOrderDetailList.Count(); i++)
            {
                if (shipOrderDetailList[i].Item == shipOrderDetailList[i - 1].Item)
                {
                    if (shipOrderDetailList[i].BillTerm != shipOrderDetailList[i - 1].BillTerm)
                    {
                        businessException.AddMessage("物料号{0}发货时存在两种结算状态", shipOrderDetailList[i].Item);
                        break;
                    }
                }
            }

            if (businessException.HasMessage)
            {
                throw businessException;
            }

            FlowMaster flowMaster = this.genericMgr.FindById<FlowMaster>(flow);
            flowMaster.FlowDetails = this.TryLoadFlowDetails(flowMaster, shipOrderDetailList.Select(det => det.Item).ToList());
            IpMaster ipMaster = ShipOrder(flowMaster, shipOrderDetailList, DateTime.Now);
            this.CreateIpDat(ipMaster);
            return ipMaster;
        }
コード例 #2
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        public void ProcessShipPlanResult4Hu(string transportOrderNo, IList<string> huIdList, DateTime? effDate)
        {
            DataSet ds = null;
            #region 处理发运计划
            User user = SecurityContextHolder.Get();
            SqlParameter[] paras = new SqlParameter[3];
            DataTable shipResultTable = new DataTable();
            shipResultTable.Columns.Add("HuId", typeof(string));
            foreach (var hu in huIdList)
            {
                DataRow row = shipResultTable.NewRow();
                row[0] = hu;
                shipResultTable.Rows.Add(row);
            }
            paras[0] = new SqlParameter("@ShipResultTable", SqlDbType.Structured);
            paras[0].Value = shipResultTable;
            paras[1] = new SqlParameter("@CreateUserId", SqlDbType.Int);
            paras[1].Value = user.Id;
            paras[2] = new SqlParameter("@CreateUserNm", SqlDbType.VarChar);
            paras[2].Value = user.FullName;

            try
            {
                ds = this.genericMgr.GetDatasetByStoredProcedure("USP_WMS_ProcessShipResult4Hu", paras);

                if (ds != null && ds.Tables != null && ds.Tables[0] != null
                    && ds.Tables[0].Rows != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow msg in ds.Tables[0].Rows)
                    {
                        if (msg[0].ToString() == "0")
                        {
                            MessageHolder.AddInfoMessage((string)msg[1]);
                        }
                        else if (msg[0].ToString() == "1")
                        {
                            MessageHolder.AddWarningMessage((string)msg[1]);
                        }
                        else
                        {
                            MessageHolder.AddErrorMessage((string)msg[1]);
                        }
                    }

                    return;
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.InnerException != null)
                    {
                        MessageHolder.AddErrorMessage(ex.InnerException.InnerException.Message);
                    }
                    else
                    {
                        MessageHolder.AddErrorMessage(ex.InnerException.Message);
                    }
                }
                else
                {
                    MessageHolder.AddErrorMessage(ex.Message);
                }

                return;
            }
            #endregion

            #region 创建ASN并添加到运输单中
            if (ds != null && ds.Tables != null && ds.Tables[1] != null
                   && ds.Tables[1].Rows != null && ds.Tables[1].Rows.Count > 0)
            {
                IList<object> orderDetailIdList = new List<object>();
                foreach (DataRow hu in ds.Tables[1].Rows)
                {
                    if (!orderDetailIdList.Contains(hu[3]))
                    {
                        orderDetailIdList.Add(hu[3]);
                    }
                }

                IList<OrderDetail> orderDetailList = genericMgr.FindAllIn<OrderDetail>("from OrderDetail where Id in(?", orderDetailIdList);
                IDictionary<string, IList<OrderDetail>> flowDic = new Dictionary<string, IList<OrderDetail>>();
                foreach (DataRow hu in ds.Tables[1].Rows)
                {
                    OrderDetail orderDetail = orderDetailList.Where(od => od.Id == (int)hu[3]).Single();
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.HuId = (string)hu[0];
                    orderDetailInput.LotNo = (string)hu[1];
                    orderDetailInput.ShipQty = (decimal)hu[2];
                    orderDetailInput.OccupyType = CodeMaster.OccupyType.Pick;
                    orderDetail.AddOrderDetailInput(orderDetailInput);

                    if (!flowDic.ContainsKey((string)hu[4]))
                    {
                        IList<OrderDetail> flowOrderDetailList = new List<OrderDetail>();
                        flowOrderDetailList.Add(orderDetail);
                        flowDic.Add((string)hu[4], flowOrderDetailList);
                    }
                    else
                    {
                        IList<OrderDetail> flowOrderDetailList = flowDic[(string)hu[4]];
                        if (!flowOrderDetailList.Contains(orderDetail))
                        {
                            flowOrderDetailList.Add(orderDetail);
                        }
                    }
                }

                if (!effDate.HasValue)
                {
                    effDate = DateTime.Now;
                }

                IList<string> ipNoList = new List<string>();
                foreach (var flow in flowDic)
                {
                    IpMaster ipMaster = ShipOrder(flow.Value, effDate.Value);
                    ipNoList.Add(ipMaster.IpNo);
                }

                if (!string.IsNullOrWhiteSpace(transportOrderNo))
                {
                    transportMgr.AddTransportOrderDetail(transportOrderNo, ipNoList);
                }
            }
            else
            {
                throw new TechnicalException("返回的条码信息为空。");
            }
            #endregion
        }
コード例 #3
0
        public ActionResult CreatePickList(string idStr, string qtyStr, OrderMasterSearchModel searchModel)
        {
            try
            {
                if (string.IsNullOrEmpty(idStr))
                {
                    throw new BusinessException(Resources.EXT.ControllerLan.Con_PickDetailCanNotBeEmpty);
                }
                string[] idArr = idStr.Split(',');
                string[] qtyArr = qtyStr.Split(',');

                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                for (int i = 0; i < idArr.Count(); i++)
                {

                    OrderDetail orderDetail = genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArr[i]));
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.PickQty = Convert.ToDecimal(qtyArr[i]);
                    orderDetail.AddOrderDetailInput(orderDetailInput);
                    //校验还没发
                    orderDetailList.Add(orderDetail);
                }

                PickListMaster pickListMaster = pickListMgr.CreatePickList(orderDetailList);
                SaveSuccessMessage(Resources.ORD.PickListMaster.PickListMaster_Created);
                return RedirectToAction("Edit/" + pickListMaster.PickListNo);
            }
            catch (BusinessException ex)
            {
                SaveErrorMessage(ex.GetMessages()[0].GetMessageString());
                TempData["OrderMasterSearchModel"] = searchModel;
                return RedirectToAction("DetailNew");

            }

        }
コード例 #4
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        private void BackflushVan(ProductLineMap productLineMap, IList<OrderDetail> nonZeroOrderDetailList, ReceiptMaster receiptMaster, OrderMaster orderMaster)
        {
            if (productLineMap.ProductLine == orderMaster.Flow)
            {
                #region 总装,回冲总装、驾驶室、底盘的物料
                #region 回冲驾驶室和底盘
                IList<string> subOrderMasterList = this.genericMgr.FindAll<string>("select OrderNo from OrderMaster where Type = ? and Flow in (?,?)", new object[] { CodeMaster.OrderType.Production, productLineMap.CabFlow, productLineMap.ChassisFlow, CodeMaster.OrderStatus.Close });

                if (subOrderMasterList != null && subOrderMasterList.Count > 0)
                {
                    string selectOrderDetHql = string.Empty;
                    string selectReceiptDetHql = string.Empty;
                    IList<object> parms = new List<object>();
                    foreach (string subOrderNo in subOrderMasterList)
                    {
                        if (selectOrderDetHql == string.Empty)
                        {
                            selectOrderDetHql = "from OrderDetail where OrderNo in (?";
                            selectReceiptDetHql = "from ReceiptDetail where OrderNo in (?";
                        }
                        else
                        {
                            selectOrderDetHql += ",?";
                            selectReceiptDetHql += ",?";
                        }

                        parms.Add(subOrderNo);
                    }
                    selectOrderDetHql += ")";
                    selectReceiptDetHql += ")";

                    IList<OrderDetail> subOrderDetailList = this.genericMgr.FindAll<OrderDetail>(selectOrderDetHql, parms.ToArray());
                    IList<ReceiptDetail> subReceiptDetailList = this.genericMgr.FindAll<ReceiptDetail>(selectReceiptDetHql, parms.ToArray());

                    foreach (OrderDetail subOrderDetail in subOrderDetailList)
                    {
                        OrderDetailInput subOrderDetailInput = new OrderDetailInput();
                        subOrderDetailInput.ReceiveQty = subOrderDetail.OrderedQty;
                        subOrderDetail.AddOrderDetailInput(subOrderDetailInput);
                        subOrderDetailInput.ReceiptDetails = subReceiptDetailList.Where(r => r.OrderDetailId == subOrderDetail.Id).ToList();

                        IList<OrderDetail> backFlushOrderDetailList = new List<OrderDetail>();
                        backFlushOrderDetailList.Add(subOrderDetail);
                        this.productionLineMgr.BackflushProductOrder(backFlushOrderDetailList, orderMaster, DateTime.Now);
                    }
                }
                #endregion

                #region 回冲总装
                foreach (OrderDetail orderDetail in nonZeroOrderDetailList)
                {
                    OrderDetailInput orderDetailInput = orderDetail.OrderDetailInputs[0];
                    orderDetailInput.ReceiptDetails = receiptMaster.ReceiptDetails.Where(r => r.OrderDetailId == orderDetail.Id).ToList();
                }
                this.productionLineMgr.BackflushProductOrder(nonZeroOrderDetailList, orderMaster, DateTime.Now);
                #endregion
                #endregion
            }
            else
            {
                #region 驾驶室、底盘,不回冲物料
                #endregion
            }
        }
コード例 #5
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        private void AddHuToOrderDetailInput(IList<OrderDetail> orderDetailList, IList<string> huIdList)
        {
            IList<HuStatus> huStatusList = huMgr.GetHuStatus(huIdList);
            IList<HuStatus> notInLocHu = huStatusList.Where(h => h.Status != CodeMaster.HuStatus.Location).ToList();
            if (notInLocHu != null && notInLocHu.Count > 0)
            {
                string strExeception = string.Empty;
                foreach (HuStatus hs in notInLocHu)
                {
                    if (string.IsNullOrEmpty(strExeception))
                        strExeception = "条码" + hs.HuId;
                    else
                        strExeception += "," + hs.HuId;

                }
                strExeception += "不在库存中";
                throw new BusinessException(strExeception);
            }

            foreach (HuStatus huStatus in huStatusList)
            {
                var h = orderDetailList.Where(o => o.Item == huStatus.Item && o.Uom == huStatus.Uom && o.LocationFrom == huStatus.Location).ToList();
                if (h == null || h.Count == 0)
                {
                    OrderDetail od = new OrderDetail();
                    od.Item = huStatus.Item;
                    od.Uom = huStatus.Uom;
                    od.UnitCount = huStatus.UnitCount;
                    od.ItemDescription = huStatus.ItemDescription;
                    od.ReferenceItemCode = huStatus.ReferenceItemCode;
                    od.LocationFrom = huStatus.Location;
                    od.OrderedQty = huStatus.Qty;

                    IList<OrderDetailInput> orderDetailInputList = new List<OrderDetailInput>();
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.HuId = huStatus.HuId;
                    orderDetailInput.HuQty = huStatus.Qty;
                    orderDetailInput.LotNo = huStatus.LotNo;
                    orderDetailInput.ReceiveQty = huStatus.Qty;
                    orderDetailInputList.Add(orderDetailInput);

                    od.OrderDetailInputs = orderDetailInputList;
                    orderDetailList.Add(od);
                }
                else
                {
                    OrderDetail od = h[0];
                    od.OrderedQty += huStatus.Qty;

                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.HuId = huStatus.HuId;
                    orderDetailInput.HuQty = huStatus.Qty;
                    orderDetailInput.LotNo = huStatus.LotNo;
                    orderDetailInput.ReceiveQty = huStatus.Qty;
                    od.OrderDetailInputs.Add(orderDetailInput);
                }
            }
        }
コード例 #6
0
        public JsonResult ShipOrder(string idStr, string qtyStr)
        {
            try
            {
                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                if (!string.IsNullOrEmpty(idStr))
                {
                    string[] idArray = idStr.Split(',');
                    string[] qtyArray = qtyStr.Split(',');

                    for (int i = 0; i < qtyArray.Count(); i++)
                    {
                        if (Convert.ToDecimal(qtyArray[i]) > 0)
                        {
                            OrderDetail od = base.genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));
                            OrderDetailInput input = new OrderDetailInput();
                            input.ReceiveQty = Convert.ToDecimal(qtyArray[i]);
                            od.AddOrderDetailInput(input);
                            orderDetailList.Add(od);
                        }
                    }
                }
                if (orderDetailList.Count() == 0)
                {
                    throw new BusinessException("发货明细不能为空");
                }

                var recMaster = orderMgr.ReceiveOrder(orderDetailList, DateTime.Now);
                SaveSuccessMessage("发货成功,生成收货单号:" + recMaster.ReceiptNo);
            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            return Json(null);
        }
コード例 #7
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
 private void AutoShipAndReceive(OrderMaster orderMaster)
 {
     #region 自动捡货/发货/收货
     if (orderMaster.IsQuick ||
         (orderMaster.IsAutoShip && orderMaster.IsAutoReceive && orderMaster.SubType == com.Sconit.CodeMaster.OrderSubType.Normal
         && !(orderMaster.IsCreatePickList && orderMaster.IsShipScanHu)))
     {
         foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
         {
             if (orderDetail.OrderDetailInputs == null || orderDetail.OrderDetailInputs.Count == 0)
             {
                 OrderDetailInput orderDetailInput = new OrderDetailInput();
                 if (orderDetail.OrderType == CodeMaster.OrderType.Production)
                 {
                     orderDetailInput.ScrapQty = orderDetail.CurrentScrapQty;
                     orderDetailInput.ReceiveQty = orderDetail.OrderedQty - orderDetail.CurrentScrapQty;
                     if (orderDetail.OrderedQty > 0)
                     {
                         orderDetailInput.ReceiveQty = orderDetailInput.ReceiveQty > 0 ? orderDetailInput.ReceiveQty : 0;
                     }
                     else
                     {
                         orderDetailInput.ReceiveQty = orderDetailInput.ReceiveQty < 0 ? orderDetailInput.ReceiveQty : 0;
                     }
                 }
                 else
                 {
                     orderDetailInput.ReceiveQty = orderDetail.OrderedQty;
                 }
                 orderDetail.AddOrderDetailInput(orderDetailInput);
             }
         }
         ReceiveOrder(orderMaster.OrderDetails, orderMaster.EffectiveDate.HasValue ? orderMaster.EffectiveDate.Value : DateTime.Now);
     }
     else if (!orderMaster.IsQuick && orderMaster.Type != com.Sconit.CodeMaster.OrderType.Production          //自动生成捡货单
         && orderMaster.Type != com.Sconit.CodeMaster.OrderType.SubContract
         && orderMaster.IsCreatePickList && orderMaster.IsShipScanHu
         && orderMaster.SubType == com.Sconit.CodeMaster.OrderSubType.Normal //过滤掉退货
         && orderMaster.QualityType == com.Sconit.CodeMaster.QualityType.Qualified)   //过滤掉不合格品和待验物料
     {
         foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
         {
             OrderDetailInput orderDetailInput = new OrderDetailInput();
             orderDetailInput.PickQty = orderDetail.OrderedQty;
             orderDetail.AddOrderDetailInput(orderDetailInput);
         }
         pickListMgr.CreatePickList(orderMaster.OrderDetails);
     }
     else if (!orderMaster.IsQuick && orderMaster.Type != com.Sconit.CodeMaster.OrderType.Production       //生产单和委外加工没有发货概念                
         && orderMaster.Type != com.Sconit.CodeMaster.OrderType.SubContract
         && orderMaster.IsAutoShip
         && orderMaster.SubType == com.Sconit.CodeMaster.OrderSubType.Normal                         //过滤掉退货
         //&& orderMaster.QualityType == com.Sconit.CodeMaster.QualityType.Qualified                      //过滤掉不合格品和待验物料
         && !(orderMaster.IsCreatePickList && orderMaster.IsShipScanHu))  //自动捡货和自动发货/自动收货冲突,如果设置了自动捡货将不考虑自动发货/自动收货选项
     {
         foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
         {
             if (orderDetail.OrderDetailInputs == null || orderDetail.OrderDetailInputs.Count == 0)
             {
                 OrderDetailInput orderDetailInput = new OrderDetailInput();
                 orderDetailInput.ShipQty = orderDetail.OrderedQty;
                 orderDetail.AddOrderDetailInput(orderDetailInput);
             }
         }
         ShipOrder(orderMaster.OrderDetails, orderMaster.EffectiveDate.HasValue ? orderMaster.EffectiveDate.Value : DateTime.Now);
     }
     //else if (orderMaster.IsQuick //&& !orderMaster.IsShipScanHu && !orderMaster.IsReceiveScanHu        //快速订单直接收货,跳过发货和捡货
     //    || (orderMaster.IsAutoReceive && !orderMaster.IsShipByOrder                                   //不是订单发货
     //     && orderMaster.SubType == com.Sconit.CodeMaster.OrderSubType.Normal                         //过滤掉退货
     //    && orderMaster.QualityType == com.Sconit.CodeMaster.QualityType.Qualified                      //过滤掉不合格品和待验物料
     //    && !(orderMaster.IsCreatePickList && orderMaster.IsShipScanHu)))  //支持不发货直接收货
     //{
     //    foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
     //    {
     //        if (orderDetail.OrderDetailInputs == null || orderDetail.OrderDetailInputs.Count == 0)
     //        {
     //            OrderDetailInput orderDetailInput = new OrderDetailInput();
     //            if (orderDetail.OrderType == CodeMaster.OrderType.Production)
     //            {
     //                orderDetailInput.ScrapQty = orderDetail.CurrentScrapQty;
     //                orderDetailInput.ReceiveQty = orderDetail.OrderedQty - orderDetail.CurrentScrapQty;
     //                if (orderDetail.OrderedQty > 0)
     //                {
     //                    orderDetailInput.ReceiveQty = orderDetailInput.ReceiveQty > 0 ? orderDetailInput.ReceiveQty : 0;
     //                }
     //                else
     //                {
     //                    orderDetailInput.ReceiveQty = orderDetailInput.ReceiveQty < 0 ? orderDetailInput.ReceiveQty : 0;
     //                }
     //            }
     //            else
     //            {
     //                orderDetailInput.ReceiveQty = orderDetail.OrderedQty;
     //            }
     //            orderDetail.AddOrderDetailInput(orderDetailInput);
     //        }
     //    }
     //    ReceiveOrder(orderMaster.OrderDetails, orderMaster.EffectiveDate.HasValue ? orderMaster.EffectiveDate.Value : DateTime.Now);
     //}
     #endregion
 }
コード例 #8
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public void ReceiveWMSIpMaster(WMSDatFile wMSDatFile, DateTime effectiveDate)
        {
            try
            {
                LesINLog lesInLog = new LesINLog();

                #region 获得orderdetail
                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                OrderDetail orderDetail = this.genericMgr.FindById<OrderDetail>(Convert.ToInt32(wMSDatFile.WmsLine));

                if (orderDetail.ReceiveLotSize == 1)
                {
                    throw new BusinessException(string.Format("单号{0}中物料{1}明细行已经关闭,不能收货。", orderDetail.OrderNo, orderDetail.Item));
                }

                //#region 订单头要配置成自动收货
                //OrderMaster ordermaster = this.genericMgr.FindById<OrderMaster>(orderDetail.OrderNo);
                //if (!ordermaster.IsAutoReceive)
                //{
                //    throw new BusinessException();
                //}
                //#endregion

                orderDetail.WmsFileID = wMSDatFile.WMSId;
                orderDetail.ManufactureParty = wMSDatFile.LIFNR;
                orderDetail.ExternalOrderNo = wMSDatFile.WMSId;
                //orderDetail.ExternalSequence = wMSDatFile.WBS;//项目代码
                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetailInput.ShipQty = wMSDatFile.CurrentReceiveQty;
                orderDetailInput.WMSIpNo = wMSDatFile.WMSId;//先记录WMSId号,目前安吉拣货单号只用在接口日志查询中
                orderDetailInput.WMSIpSeq = wMSDatFile.HuId;//WMS行
                orderDetailInput.MoveType = wMSDatFile.MoveType + wMSDatFile.SOBKZ;//移动类型
                //只有311K才传寄售供应商,如果是411K也不传,防止两边库位结算方式设置不一致造成差异
                if (wMSDatFile.SOBKZ.ToUpper() == "K" && wMSDatFile.MoveType == "311")
                    orderDetailInput.ConsignmentParty = wMSDatFile.LIFNR;//厂商代码
                orderDetail.AddOrderDetailInput(orderDetailInput);
                orderDetailList.Add(orderDetail);
                #endregion

                #region 调用发货
                var ipMstr = this.ShipOrder(orderDetailList, effectiveDate);

                if (!ipMstr.IsAutoReceive)
                {
                    foreach (IpDetail ipDetail in ipMstr.IpDetails)
                    {
                        if (ipDetail.IpDetailInputs != null && ipDetail.IpDetailInputs.Count > 0)
                        {
                            foreach (IpDetailInput ipDetailInput in ipDetail.IpDetailInputs)
                            {
                                ipDetailInput.ReceiveQty = ipDetailInput.ShipQty;
                            }
                        }
                        else
                        {
                            IpDetailInput ipDetailInput = new IpDetailInput();
                            ipDetailInput.ReceiveQty = ipDetail.Qty;
                            ipDetail.AddIpDetailInput(ipDetailInput);
                        }
                    }
                    this.genericMgr.FlushSession();
                    ReceiveIp(ipMstr.IpDetails, effectiveDate);
                }
                //var ipDetList = base.genericMgr.FindAll<IpDetail>("from IpDetail as d where d.IpNo=?", ipMstr.IpNo);
                //if (ipDetList != null && ipDetList.Count > 0)
                //{
                //    lesInLog.Qty = ipDetList.FirstOrDefault().ReceivedQty;
                //    lesInLog.QtyMark = true;
                //}
                lesInLog.Qty = wMSDatFile.CurrentReceiveQty;
                lesInLog.QtyMark = true;
                #endregion

                #region 新建Log记录
                lesInLog.Type = "MB1B";
                lesInLog.MoveType = wMSDatFile.MoveType + wMSDatFile.SOBKZ;
                lesInLog.Sequense = "";
                lesInLog.WMSNo = wMSDatFile.WMSId;
                lesInLog.WMSLine = wMSDatFile.WmsLine;
                lesInLog.Item = wMSDatFile.Item;
                lesInLog.HandResult = "S";
                lesInLog.FileName = wMSDatFile.FileName;
                lesInLog.HandTime = System.DateTime.Now;
                lesInLog.IsCreateDat = false;
                lesInLog.ASNNo = wMSDatFile.WmsNo;
                this.genericMgr.Create(lesInLog);
                #endregion

                #region 修改中间表
                wMSDatFile.ReceiveTotal = wMSDatFile.ReceiveTotal + wMSDatFile.CurrentReceiveQty;
                this.genericMgr.Update(wMSDatFile);
                #endregion

                this.genericMgr.FlushSession();
            }
            catch (BusinessException ex)
            {
                throw new BusinessException(ex.GetMessages()[0].GetMessageString());
            }
        }
コード例 #9
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public void BatchImportShipXls(Stream inputStream)
        {
            if (inputStream.Length == 0)
            {
                throw new BusinessException("Import.Stream.Empty");
            }

            HSSFWorkbook workbook = new HSSFWorkbook(inputStream);

            ISheet sheet = workbook.GetSheetAt(0);
            IEnumerator rows = sheet.GetRowEnumerator();

            ImportHelper.JumpRows(rows, 1);
            BusinessException businessException = new BusinessException();
            #region 列定义

            int colShipQty = 0;//发货数
            int colId = 1;// 明细ID
            int rowCount = 1;
            #endregion
            IList<OrderDetail> exactDetailList = new List<OrderDetail>();
            while (rows.MoveNext())
            {
                rowCount++;
                HSSFRow row = (HSSFRow)rows.Current;
                if (!ImportHelper.CheckValidDataRow(row, 0, 2))
                {
                    break;//边界
                }

                int detailId = 0;//明细Id
                decimal currentShipQty = 0;// 本次发货数

                OrderDetail readDet = null;
                OrderDetailInput input = new OrderDetailInput();

                #region 读取数据


                #region 读取明细Id
                string readId = ImportHelper.GetCellStringValue(row.GetCell(colId));
                if (string.IsNullOrWhiteSpace(readId))
                {
                    businessException.AddMessage(string.Format("第{0}行:明细Id不能为空。", rowCount));
                    continue;
                }
                else
                {
                    if (int.TryParse(readId, out detailId))
                    {
                        if (detailId <= 0)
                        {
                            businessException.AddMessage(string.Format("第{0}行:明细Id{1}填写不正确。", rowCount, readId));
                            continue;
                        }
                        else
                        {
                            try
                            {
                                readDet = this.genericMgr.FindById<OrderDetail>(detailId);
                            }
                            catch (Exception)
                            {
                                businessException.AddMessage(string.Format("第{0}行:明细Id{1}不存在。", rowCount, readId));
                                continue;
                            }
                        }
                    }
                    else
                    {
                        businessException.AddMessage(string.Format("第{0}行:明细Id{1}填写不正确。", rowCount, readId));
                        continue;
                    }
                }
                #endregion

                #region 读取发货数
                string readShipQty = ImportHelper.GetCellStringValue(row.GetCell(colShipQty));
                if (string.IsNullOrWhiteSpace(readShipQty))
                {
                    businessException.AddMessage(string.Format("第{0}行:发货数不能为空。", rowCount));
                    continue;
                }
                else
                {
                    if (decimal.TryParse(readShipQty, out currentShipQty))
                    {
                        if (currentShipQty < 0)
                        {
                            businessException.AddMessage(string.Format("第{0}行:发货数{1}填写不正确。", rowCount, currentShipQty));
                            continue;
                        }
                        else if (currentShipQty == 0)
                        {
                            continue;
                        }
                        else
                        {
                            input.ShipQty = currentShipQty;
                            readDet.AddOrderDetailInput(input);
                        }
                    }
                    else
                    {
                        businessException.AddMessage(string.Format("第{0}行:发货数{1}填写不正确。", rowCount, currentShipQty));
                        continue;
                    }
                }
                #endregion




                var checkDet = exactDetailList.Where(p => p.Id == detailId);

                if (checkDet.Count() <= 0)
                {
                    exactDetailList.Add(readDet);
                }
                else
                {
                    throw new BusinessException(string.Format("第{0}行:明细Id出现重复行请检查数据的准确性", rowCount));
                }

                #endregion


            }

            if (exactDetailList != null && exactDetailList.Count > 0)
            {
                ShipOrder(exactDetailList, DateTime.Now);
            }
            else
            {
                throw new BusinessException(string.Format("有效的数据行为0,可能是模板问题"));
            }

            if (businessException.HasMessage)
            {
                throw businessException;
            }
        }
コード例 #10
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public string CreateHuTransferOrder(string flowCode, IList<string> huIdList, DateTime effectiveDate)
        {
            FlowMaster flow = genericMgr.FindById<FlowMaster>(flowCode);
            OrderMaster order = TransferFlow2Order(flow, false);
            IList<OrderDetail> orderDetailList = new List<OrderDetail>();

            IList<HuStatus> huStatusList = huMgr.GetHuStatus(huIdList);
            IList<HuStatus> notInLocHu = huStatusList.Where(h => h.Status != CodeMaster.HuStatus.Location).ToList();
            //新条码逻辑
            if (flow.IsShipScanHu)
            {
                if (notInLocHu != null && notInLocHu.Count > 0)
                {
                    string strExeception = string.Empty;
                    foreach (HuStatus hs in notInLocHu)
                    {
                        if (string.IsNullOrEmpty(strExeception))
                            strExeception = "条码" + hs.HuId;
                        else
                            strExeception += "," + hs.HuId;

                    }
                    strExeception += "不在库存中";
                    throw new BusinessException(strExeception);
                }
            }
            else if (!flow.IsShipScanHu && flow.IsReceiveScanHu)
            {
                //快速移库暂不支持,逻辑还没想清楚
                throw new BusinessException("快速移库不支持数量发货条码收货的配置");
            }

            foreach (HuStatus huStatus in huStatusList)
            {
                var h = orderDetailList.Where(o => o.Item == huStatus.Item && o.Uom == huStatus.Uom && o.LocationFrom == huStatus.Location).ToList();
                if (h == null || h.Count == 0)
                {
                    OrderDetail od = new OrderDetail();
                    od.Item = huStatus.Item;
                    od.Uom = huStatus.Uom;
                    od.UnitCount = huStatus.UnitCount;
                    od.ItemDescription = huStatus.ItemDescription;
                    od.ReferenceItemCode = huStatus.ReferenceItemCode;
                    od.LocationFrom = huStatus.Location;
                    od.OrderedQty = huStatus.Qty;

                    IList<OrderDetailInput> orderDetailInputList = new List<OrderDetailInput>();
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.HuId = huStatus.HuId;
                    orderDetailInput.HuQty = huStatus.Qty;
                    orderDetailInput.LotNo = huStatus.LotNo;
                    orderDetailInput.ReceiveQty = huStatus.Qty;
                    orderDetailInputList.Add(orderDetailInput);

                    od.OrderDetailInputs = orderDetailInputList;
                    orderDetailList.Add(od);
                }
                else
                {
                    OrderDetail od = h[0];
                    od.OrderedQty += huStatus.Qty;

                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.HuId = huStatus.HuId;
                    orderDetailInput.HuQty = huStatus.Qty;
                    orderDetailInput.LotNo = huStatus.LotNo;
                    orderDetailInput.ReceiveQty = huStatus.Qty;
                    od.OrderDetailInputs.Add(orderDetailInput);
                }

            }
            order.OrderDetails = orderDetailList;
            order.EffectiveDate = effectiveDate;
            order.WindowTime = DateTime.Now;
            order.StartDate = DateTime.Now;
            order.IsQuick = true;
            CreateOrder(order);
            return order.OrderNo;

        }
コード例 #11
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public void ReportOrderOp(int orderOpId, decimal reportQty, decimal scrapQty, DateTime effectiveDate)
        {
            OrderOperation orderOperation = this.genericMgr.FindById<OrderOperation>(orderOpId);
            OrderMaster orderMaster = this.genericMgr.FindEntityWithNativeSql<OrderMaster>("select * from ORD_OrderMstr_4 WITH(NOLOCK) where OrderNo = ?", orderOperation.OrderNo).Single();
            OrderDetail orderDetail = this.genericMgr.FindEntityWithNativeSql<OrderDetail>("select * from ORD_OrderDet_4 WITH(NOLOCK) where OrderNo = ?", orderOperation.OrderNo).Single();
            IList<ProductLineMap> prodLineMapList = this.genericMgr.FindAll<ProductLineMap>("select s from ProductLineMap as s where s.ProductLine = ?", orderMaster.Flow);
            //            IList<OrderOperation> refOrderOperationList = null;
            //            if (orderOperation.NeedReport)
            //            {
            //                refOrderOperationList = this.genericMgr.FindEntityWithNativeSql<OrderOperation>(@"select * from ORD_OrderOp WITH(NOLOCK) where OrderNo= ?
            //                    and Op > ISNULL((select Op from ORD_OrderOp WITH(NOLOCK) where OrderNo = ? and Op < ? and NeedReport = ?), 0) and Op < ?"
            //                        , new object[] { orderMaster.OrderNo, orderMaster.OrderNo, orderOperation.Operation, true, orderOperation.Operation });
            //            }

            if (orderMaster.Status != CodeMaster.OrderStatus.InProcess)
            {
                throw new BusinessException("状态为{1}的生产单{0}不能报工",
                            orderMaster.OrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)orderMaster.Status).ToString()));
            }

            if (!orderOperation.NeedReport)
            {
                throw new BusinessException("不是报工工序不能报工。");
            }

            #region 检查比报工工序小的工序是否报工
            //2013-10-23 三勇说对于试制订单来说不要去严格限制报工顺序
            int notSkipCheck = (from prodLine in prodLineMapList
                                where prodLine.SAPProductLine == "ZP01"
                                || prodLine.SAPProductLine == "ZP02"
                                || prodLine.SAPProductLine == "Z904"
                                select prodLine).Count();
            if (notSkipCheck == 0)
            {
                int count = this.genericMgr.FindAllWithNativeSql<int>(@"select count(*) as counter 
                                                        from ORD_OrderOp as op 
                                                        left join SAP_ProdOpReport as rp on op.Id = rp.OrderOpId and rp.IsCancel = ?
                                                        where op.OrderNo = ? and op.NeedReport = ? and op.Op < ? and rp.Id is null", new object[] { false, orderOperation.OrderNo, true, orderOperation.Operation }).SingleOrDefault();

                if (count > 0)
                {
                    throw new BusinessException("有小于报工工序的工序还未报工。");
                }
            }
            #endregion

            DateTime dateTimeNow = DateTime.Now;

            #region 报工
            if (reportQty > 0)
            {
                OrderOperationReport orderOperationReport = new OrderOperationReport();
                orderOperationReport.OrderNo = orderMaster.OrderNo;
                orderOperationReport.OrderDetailId = orderDetail.Id;
                orderOperationReport.OrderOperationId = orderOperation.Id;
                orderOperationReport.Operation = orderOperation.Operation;
                orderOperationReport.ReportQty = reportQty;
                orderOperationReport.ScrapQty = 0;
                orderOperationReport.BackflushQty = reportQty;
                orderOperationReport.WorkCenter = orderOperation.WorkCenter;
                orderOperationReport.Status = CodeMaster.OrderOpReportStatus.Close;
                orderOperationReport.EffectiveDate = effectiveDate;

                com.Sconit.Entity.SAP.ORD.ProdOpReport prodOpReport = new com.Sconit.Entity.SAP.ORD.ProdOpReport();
                prodOpReport.AUFNR = orderMaster.ExternalOrderNo;
                prodOpReport.WORKCENTER = orderOperation.WorkCenter;
                prodOpReport.GAMNG = reportQty;
                prodOpReport.Status = Entity.SAP.StatusEnum.Pending;
                prodOpReport.CreateDate = dateTimeNow;
                prodOpReport.LastModifyDate = dateTimeNow;
                prodOpReport.ErrorCount = 0;
                prodOpReport.SCRAP = 0;
                prodOpReport.IsCancel = false;
                prodOpReport.OrderNo = orderOperation.OrderNo;
                prodOpReport.OrderOpId = orderOperation.Id;
                prodOpReport.EffectiveDate = effectiveDate;
                prodOpReport.ProdLine = orderMaster.Flow;

                #region 成品收货
                if (orderOperation.IsReceiveFinishGoods)
                {
                    orderDetail.OrderDetailInputs = new List<OrderDetailInput>();
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = reportQty;
                    orderDetail.OrderDetailInputs.Add(orderDetailInput);
                    IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                    orderDetailList.Add(orderDetail);

                    ReceiptMaster receiptMaster = this.ReceiveOrder(orderDetailList);

                    orderOperationReport.ReceiptNo = receiptMaster.ReceiptNo;
                    prodOpReport.ReceiptNo = receiptMaster.ReceiptNo;
                }
                #endregion

                this.genericMgr.Create(orderOperationReport);

                prodOpReport.OrderOpReportId = orderOperationReport.Id;
                this.genericMgr.Create(prodOpReport);

                #region 反冲物料
                //if (orderOperation.NeedReport)
                //{
                //    orderOperation.CurrentReportQty = reportQty;
                //    this.productionLineMgr.BackflushProductOrder(orderOperation, orderOperationReport);

                //    if (refOrderOperationList != null && refOrderOperationList.Count > 0)
                //    {
                //        foreach (OrderOperation refOrderOperation in refOrderOperationList)
                //        {
                //            refOrderOperation.CurrentReportQty = reportQty;
                //            this.productionLineMgr.BackflushProductOrder(refOrderOperation, orderOperationReport);

                //            refOrderOperation.BackflushQty += reportQty;
                //            refOrderOperation.ReportQty += reportQty;
                //        }
                //    }
                //}
                #endregion

                //orderOperation.BackflushQty += reportQty;
                if (orderOperation.ReportQty >= orderDetail.OrderedQty)
                {
                    throw new BusinessException("已报工数量大于等于订单数量。");
                }

                orderOperation.ReportQty += reportQty;
            }
            else if (reportQty < 0)
            {
                throw new BusinessException("报工数量不能小于0。");
            }
            #endregion

            #region 废品
            if (scrapQty > 0)
            {
                OrderOperationReport orderOperationReport = new OrderOperationReport();
                orderOperationReport.OrderNo = orderMaster.OrderNo;
                orderOperationReport.OrderDetailId = orderDetail.Id;
                orderOperationReport.OrderOperationId = orderOperation.Id;
                orderOperationReport.Operation = orderOperation.Operation;
                orderOperationReport.ReportQty = 0;
                orderOperationReport.ScrapQty = scrapQty;
                orderOperationReport.BackflushQty = scrapQty;
                orderOperationReport.WorkCenter = orderOperation.WorkCenter;
                orderOperationReport.Status = CodeMaster.OrderOpReportStatus.Close;
                orderOperationReport.EffectiveDate = effectiveDate;

                com.Sconit.Entity.SAP.ORD.ProdOpReport prodOpReport = new com.Sconit.Entity.SAP.ORD.ProdOpReport();
                prodOpReport.AUFNR = orderMaster.ExternalOrderNo;
                prodOpReport.WORKCENTER = orderOperation.WorkCenter;
                prodOpReport.GAMNG = 0;
                prodOpReport.Status = Entity.SAP.StatusEnum.Pending;
                prodOpReport.CreateDate = dateTimeNow;
                prodOpReport.LastModifyDate = dateTimeNow;
                prodOpReport.ErrorCount = 0;
                prodOpReport.SCRAP = scrapQty;
                prodOpReport.IsCancel = false;
                prodOpReport.OrderNo = orderOperation.OrderNo;
                prodOpReport.OrderOpId = orderOperation.Id;
                prodOpReport.EffectiveDate = effectiveDate;
                prodOpReport.ProdLine = orderMaster.Flow;

                #region 成品收货
                if (orderOperation.IsReceiveFinishGoods)
                {
                    orderDetail.OrderDetailInputs = new List<OrderDetailInput>();
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ScrapQty = scrapQty;
                    orderDetail.OrderDetailInputs.Add(orderDetailInput);
                    IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                    orderDetailList.Add(orderDetail);

                    ReceiptMaster receiptMaster = this.ReceiveOrder(orderDetailList);

                    orderOperationReport.ReceiptNo = receiptMaster.ReceiptNo;
                    prodOpReport.ReceiptNo = receiptMaster.ReceiptNo;
                }
                #endregion

                this.genericMgr.Create(orderOperationReport);

                prodOpReport.OrderOpReportId = orderOperationReport.Id;
                this.genericMgr.Create(prodOpReport);

                #region 反冲物料
                //if (orderOperation.NeedReport)
                //{
                //    orderOperation.CurrentReportQty = 0;
                //    orderOperation.CurrentScrapQty = scrapQty;
                //    this.productionLineMgr.BackflushProductOrder(orderOperation, orderOperationReport);

                //    if (refOrderOperationList != null && refOrderOperationList.Count > 0)
                //    {
                //        foreach (OrderOperation refOrderOperation in refOrderOperationList)
                //        {
                //            refOrderOperation.CurrentReportQty = 0;
                //            refOrderOperation.CurrentScrapQty = scrapQty;
                //            this.productionLineMgr.BackflushProductOrder(refOrderOperation, orderOperationReport);

                //            refOrderOperation.BackflushQty += scrapQty;
                //            refOrderOperation.ScrapQty += scrapQty;
                //        }
                //    }
                //}
                #endregion

                //orderOperation.BackflushQty += scrapQty;            
                orderOperation.ScrapQty += scrapQty;
            }
            else if (scrapQty < 0)
            {
                throw new BusinessException("废品数量不能小于0。");
            }
            #endregion

            this.genericMgr.Update(orderOperation);
            //if (refOrderOperationList != null && refOrderOperationList.Count > 0)
            //{
            //    foreach (OrderOperation refOrderOperation in refOrderOperationList)
            //    {
            //        this.genericMgr.Update(refOrderOperation);
            //    }
            //}
        }
コード例 #12
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        //public string CreateTransferOrderFromXls(Stream inputStream, string regionFromCode, string regionToCode, DateTime effectiveDate, string manufactureParty, string Consignment, bool isQuick, bool isReturn)
        public string CreateTransferOrderFromXls(string shift, string shipToContact, Stream inputStream, bool isQuick, bool isReturn, DateTime effectiveDate)
        {

            #region 导入数据
            if (inputStream.Length == 0)
            {
                throw new BusinessException("Import.Stream.Empty");
            }

            HSSFWorkbook workbook = new HSSFWorkbook(inputStream);

            ISheet sheet = workbook.GetSheetAt(0);
            IEnumerator rows = sheet.GetRowEnumerator();

            BusinessException businessException = new BusinessException();

            ImportHelper.JumpRows(rows, 10);

            #region 列定义
            int colItem = 1;//物料代码
            int colManufuctureParty = 3;//寄售供应商
            int colLocFrom = 4;// 来源库位
            int colLocTo = 5;// 目的库位
            int colQty = 6;//数量
            int colWindowTime = 7;//窗口时间
            int colZOPWZ = 8;//备注
            #endregion

            DateTime dateTimeNow = DateTime.Now;

            int rowCount = 10;

            IList<OrderDetail> exactOrderDetailList = new List<OrderDetail>();
            DateTime windowTime = System.DateTime.Now;
            com.Sconit.Entity.ACC.User user = SecurityContextHolder.Get();
            while (rows.MoveNext())
            {
                rowCount++;
                HSSFRow row = (HSSFRow)rows.Current;
                if (!ImportHelper.CheckValidDataRow(row, 1, 6))
                {
                    break;//边界
                }
                OrderDetail od = new OrderDetail();
                string itemCode = string.Empty;
                decimal qty = 0;
                string manufactureParty = string.Empty;
                string locationFromCode = string.Empty;
                string locationToCode = string.Empty;
                string masterPartyFrom = string.Empty;
                string masterPartyTo = string.Empty;
                string ZOPWZ = string.Empty;

                #region 读取数据
                #region 读取物料代码
                itemCode = ImportHelper.GetCellStringValue(row.GetCell(colItem));
                if (itemCode == null || itemCode.Trim() == string.Empty)
                {
                    businessException.AddMessage(string.Format("第{0}行:物料编号不能为空。", rowCount));
                }
                else
                {
                    var items = this.genericMgr.FindAll<Item>(" select i from Item as i where i.Code=? ", itemCode);
                    if (items == null || items.Count == 0)
                    {
                        businessException.AddMessage(string.Format("第{0}行:物料编号{1}不存在。", rowCount, itemCode));
                    }
                    else
                    {
                        od.Item = items.First().Code;
                        od.ItemDescription = items.First().Description;
                        od.ReferenceItemCode = items.First().ReferenceCode;
                        od.Uom = items.First().Uom;
                        od.BaseUom = items.First().Uom;
                    }
                }
                #endregion

                #region 读取来源库位
                locationFromCode = ImportHelper.GetCellStringValue(row.GetCell(colLocFrom));
                if (string.IsNullOrWhiteSpace(locationFromCode))
                {
                    businessException.AddMessage(string.Format("第{0}行:来源库位不能为空。", rowCount));
                }
                else
                {
                    IList<Location> locationFromList = genericMgr.FindAll<Location>("select l from Location as l where l.Code=?", locationFromCode);
                    if (locationFromList != null && locationFromList.Count > 0)
                    {
                        od.LocationFrom = locationFromCode;
                        od.MastPartyFrom = locationFromList.First().Region;
                    }
                    else
                    {
                        businessException.AddMessage(string.Format("第{0}行:来源库位{1}不存在", rowCount, locationFromCode));
                    }
                }

                //  Location locationFrom = genericMgr.FindById<Location>(locationFromCode);


                #endregion

                #region 读取目的库位
                locationToCode = ImportHelper.GetCellStringValue(row.GetCell(colLocTo));
                if (string.IsNullOrWhiteSpace(locationToCode))
                {
                    businessException.AddMessage(string.Format("第{0}行:目的库位不能为空。", rowCount));
                }
                else
                {
                    IList<Location> locationToList = genericMgr.FindAll<Location>("select l from Location as l where l.Code=?", locationToCode);
                    if (locationToList != null && locationToList.Count > 0)
                    {
                        od.LocationTo = locationToCode;
                        od.MastPartyTo = locationToList.First().Region;
                    }
                    else
                    {
                        businessException.AddMessage(string.Format("第{0}行:目的库位{1}不存在", rowCount, locationToCode));
                    }
                }
                #endregion

                #region 检查来源目的区域权限
                if (!string.IsNullOrWhiteSpace(od.MastPartyFrom) && !string.IsNullOrWhiteSpace(od.MastPartyTo))
                {
                    string checkRegionSql = @"select COUNT(*) from VIEW_UserPermission as u where u.UserId =? and  u.CategoryType = ? and u.PermissionCode in(?,?)  ";
                    if (!isReturn && isQuick)//Url_TransferOrder_View
                    {
                        //if (od.MastPartyFrom != od.MastPartyTo)
                        //{
                        //    throw new BusinessException("厂内快速移库不支持跨区域移库。");
                        //}
                        if (this.genericMgr.FindAllWithNativeSql<int>(checkRegionSql, new object[] { user.Id, (int)com.Sconit.CodeMaster.PermissionCategoryType.Region, od.MastPartyFrom, od.MastPartyTo }, new IType[] { NHibernateUtil.Int32, NHibernateUtil.Int32, NHibernateUtil.String, NHibernateUtil.String }).SingleOrDefault() == 0)
                        {
                            businessException.AddMessage(string.Format("第{2}行:用户没有对应的区域{0}、{1}的权限。", od.MastPartyFrom, od.MastPartyTo, rowCount));
                        }

                    }
                    else if (!isReturn && !isQuick)
                    {
                        if (this.genericMgr.FindAllWithNativeSql<int>(checkRegionSql, new object[] { user.Id, (int)com.Sconit.CodeMaster.PermissionCategoryType.Region, string.Empty, od.MastPartyTo }, new IType[] { NHibernateUtil.Int32, NHibernateUtil.Int32, NHibernateUtil.String, NHibernateUtil.String }).SingleOrDefault() == 0)
                        {
                            businessException.AddMessage(string.Format("第{2}行:用户没有对应的区域{0}的权限。", od.MastPartyTo, rowCount));
                        }
                    }

                }
                #endregion

                #region 读取数量
                try
                {
                    qty = Convert.ToDecimal(row.GetCell(colQty).NumericCellValue);
                    od.OrderedQty = qty;

                    if (!isQuick && !isReturn)
                    {
                        string hql = " select fd from FlowDetail as fd where Item=? and exists( select 1 from FlowMaster as fm where fm.Code=fd.Flow and fm.PartyFrom=? and fm.PartyTo=? and fm.Type=2 ) ";
                        var flowDetails = this.genericMgr.FindAll<FlowDetail>(hql, new object[] { od.Item, od.MastPartyFrom, od.MastPartyTo }, new IType[] { NHibernateUtil.String, NHibernateUtil.String, NHibernateUtil.String });
                        if (flowDetails != null && flowDetails.Count > 0)
                        {
                            if (flowDetails.FirstOrDefault().RoundUpOption != com.Sconit.CodeMaster.RoundUpOption.None)
                            {
                                if (od.OrderedQty % flowDetails.FirstOrDefault().MinUnitCount > 0)
                                {
                                    businessException.AddMessage(string.Format("第{0}行明细物料{1}的要货数{2}不符合圆整包装,包装系数为{3}!", rowCount, od.Item, od.OrderedQty, flowDetails.FirstOrDefault().MinUnitCount));
                                }
                            }
                        }
                    }
                }
                catch
                {
                    businessException.AddMessage(string.Format("第{0}行:数量{1}填写有误", rowCount, qty));
                }
                #endregion

                #region 窗口时间
                if (!isQuick && !isReturn)
                {
                    string readWindowTime = ImportHelper.GetCellStringValue(row.GetCell(colWindowTime));
                    if (string.IsNullOrWhiteSpace(readWindowTime))
                    {
                        businessException.AddMessage(string.Format("第{0}行:窗口时间不能为空。", rowCount));
                    }
                    else
                    {
                        if (!DateTime.TryParse(readWindowTime, out windowTime))
                        {
                            businessException.AddMessage(string.Format("第{0}行:窗口时间{1}填写有误", rowCount, readWindowTime));
                            continue;
                        }
                        if (string.IsNullOrWhiteSpace(od.MastPartyTo))
                        {
                            continue;
                        }
                        var workingCalendars = this.genericMgr.FindAll<WorkingCalendar>(" select w from WorkingCalendar as w where w.Region=? and w.WorkingDate=? ", new object[] { od.MastPartyTo, windowTime.Date });
                        if (workingCalendars != null && workingCalendars.Count > 0)
                        {
                            if (workingCalendars.First().Type == com.Sconit.CodeMaster.WorkingCalendarType.Rest)
                            {
                                businessException.AddMessage(string.Format("第{0}行:窗口时间{1}是休息时间,请确认。", rowCount, readWindowTime));
                                continue;
                            }
                            string times = (windowTime.Hour).ToString().PadLeft(2, '0') + ":" + (windowTime.Minute).ToString().PadLeft(2, '0');

                            var shiftDet = this.genericMgr.FindAll<ShiftDetail>(" select s from ShiftDetail as s where s.Shift=? ", new object[] { workingCalendars.FirstOrDefault().Shift });
                            if (shiftDet != null || shiftDet.Count > 0)
                            {
                                DateTime nowTime = this.ParseDateTime(times);
                                bool isTure = false;
                                foreach (var det in shiftDet)
                                {
                                    DateTime prevTime = this.ParseDateTime(det.StartTime);
                                    DateTime nextTime = this.ParseDateTime(det.EndTime);
                                    if (nextTime < prevTime) nextTime = nextTime.AddDays(1);
                                    if (nowTime >= prevTime && nowTime <= nextTime)
                                    {
                                        isTure = true;
                                        break;
                                    }
                                }
                                if (!isTure)
                                {
                                    throw new BusinessException(string.Format("窗口时间{0}是休息时间,请确认。", windowTime));
                                }
                            }
                            else
                            {
                                throw new BusinessException(string.Format("没有找到区域的工作日历。"));
                            }
                        }
                    }
                }
                if (windowTime < dateTimeNow)
                {
                    businessException.AddMessage(string.Format("第{0}行:窗口时间{1}不能小于当前时间,请确认。", rowCount, windowTime));
                    continue;
                }
                od.MastWindowTime = windowTime;
                #endregion

                #region 备注
                ZOPWZ = ImportHelper.GetCellStringValue(row.GetCell(colZOPWZ));
                od.ZOPWZ = ZOPWZ;
                #endregion

                #region 填充数据
                exactOrderDetailList.Add(od);
                #endregion

                od.QualityType = com.Sconit.CodeMaster.QualityType.Qualified;

                #region 读取寄售供应商
                manufactureParty = ImportHelper.GetCellStringValue(row.GetCell(colManufuctureParty));
                if (!string.IsNullOrWhiteSpace(manufactureParty))
                {
                    IList<Supplier> suppliers = genericMgr.FindAll<Supplier>("select l from Supplier as l where l.Code=?", manufactureParty);
                    if (suppliers == null || suppliers.Count == 0)
                    {
                        businessException.AddMessage(string.Format("第{0}行:读取寄售供应商{1}填写有误", rowCount, qty));
                        continue;
                    }

                }
                if (!isReturn && isQuick) //快速移库 寄售供应商 存orderdetailinput 
                {
                    if (od.MastPartyFrom == "SQC" || od.MastPartyFrom == "LOC" || od.MastPartyTo == "LOC" || od.MastPartyTo == "SQC")
                    {
                        businessException.AddMessage(string.Format("第{0}行:厂内快速移库不能对LOC,SQC 移库", rowCount));
                        continue;
                    }
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = od.OrderedQty;
                    orderDetailInput.ConsignmentParty = !string.IsNullOrWhiteSpace(manufactureParty) ? manufactureParty : null;
                    orderDetailInput.QualityType = od.QualityType;
                    od.AddOrderDetailInput(orderDetailInput);
                }
                else if (!isReturn && !isQuick)//要货单导入 供应商 存orderdetail
                {
                    od.ManufactureParty = !string.IsNullOrWhiteSpace(manufactureParty) ? manufactureParty : null;
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = od.OrderedQty;
                    orderDetailInput.QualityType = od.QualityType;
                    od.AddOrderDetailInput(orderDetailInput);
                }
                else if (isReturn && !isQuick)//退货
                {
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = od.OrderedQty;
                    orderDetailInput.QualityType = od.QualityType;
                    od.AddOrderDetailInput(orderDetailInput);
                }
                else if (isReturn && isQuick) //快速退货 
                {
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = od.OrderedQty;
                    orderDetailInput.QualityType = od.QualityType;
                    od.AddOrderDetailInput(orderDetailInput);
                }
                #endregion
                #endregion

            }

            #endregion


            if (businessException.HasMessage)
            {
                throw businessException;
            }

            if (exactOrderDetailList == null || exactOrderDetailList.Count == 0)
            {
                throw new BusinessException("导入的有效数据为0,。");
            }
            else
            {
                if (!isReturn && !isQuick)
                {
                    var groups = (from tak in exactOrderDetailList
                                  group tak by new
                                  {
                                      tak.MastWindowTime,
                                      tak.MastPartyFrom,
                                      tak.MastPartyTo,
                                      tak.LocationFrom,
                                  }
                                      into result
                                      select new
                                      {
                                          PartyFrom = result.Key.MastPartyFrom,
                                          PartyTo = result.Key.MastPartyTo,
                                          WindowTime = result.Key.MastWindowTime,
                                          LocationFrom = result.Key.LocationFrom,
                                          list = result.ToList()
                                      }
                        ).ToList();
                    string orderNos = string.Empty;
                    foreach (var order in groups)
                    {
                        if (order.list.Select(io => io.LocationFrom).Distinct().Count() > 1)
                        {
                            throw new BusinessException(string.Format("手工要货,不能同时向多个库位要货。"));
                        }
                        orderNos += CreateFreeTransferOrderMaster(shift, order.PartyFrom, order.PartyTo, shipToContact, order.list, effectiveDate, order.WindowTime, isQuick, isReturn) + "*";
                    }
                    return orderNos.Substring(0, orderNos.Length - 1);
                }
                else
                {
                    var groups = (from tak in exactOrderDetailList
                                  group tak by new
                                  {
                                      tak.MastWindowTime,
                                      tak.MastPartyFrom,
                                      tak.MastPartyTo,
                                  }
                                      into result
                                      select new
                                      {
                                          PartyFrom = result.Key.MastPartyFrom,
                                          PartyTo = result.Key.MastPartyTo,
                                          WindowTime = result.Key.MastWindowTime,
                                          list = result.ToList()
                                      }
                           ).ToList();
                    string orderNos = string.Empty;
                    foreach (var order in groups)
                    {
                        orderNos += CreateFreeTransferOrderMaster(shift, order.PartyFrom, order.PartyTo, shipToContact, order.list, effectiveDate, order.WindowTime, isQuick, isReturn) + "*";
                    }
                    return orderNos.Substring(0, orderNos.Length - 1);
                }

            }


            //return CreateFreeTransferOrderMaster(regionFromCode, regionToCode, exactOrderDetailList, effectiveDate, windowTime, isQuick, isReturn);
        }
コード例 #13
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public void MakeupReceiveOrder()
        {
            IList<OrderMaster> orderMasterList = this.genericMgr.FindEntityWithNativeSql<OrderMaster>(@"select * from ORD_OrderMstr_2 where OrderNo in (
                                                                                                select ord.OrderNo from ORD_OrderDet_2 as ord
                                                                                                left join ORD_RecDet_2 as rec on ord.Id = rec.OrderDetId
                                                                                                where ord.RecQty <> 0 and rec.Id is null)");

            foreach (OrderMaster orderMaster in orderMasterList)
            {
                SecurityContextHolder.Set(this.genericMgr.FindById<User>(orderMaster.CreateUserId));
                try
                {
                    IList<OrderDetail> orderDetailList = this.genericMgr.FindEntityWithNativeSql<OrderDetail>(@"select * from ORD_OrderDet_2 where OrderNo = ?", orderMaster.OrderNo);
                    orderMaster.OrderDetails = orderDetailList;
                    #region 发货
                    #region OrderDetailInput赋发货数量
                    foreach (OrderDetail orderDetail in orderDetailList)
                    {
                        OrderDetailInput orderDetailInput = new OrderDetailInput();
                        orderDetailInput.ShipQty = orderDetail.OrderedQty;
                        orderDetailInput.ReceiveQty = orderDetail.OrderedQty;
                        orderDetail.AddOrderDetailInput(orderDetailInput);
                    }
                    #endregion

                    IpMaster ipMaster = null;
                    IList<OrderMaster> omList = new List<OrderMaster>();
                    omList.Add(orderMaster);
                    ipMaster = this.ipMgr.TransferOrder2Ip(omList);

                    #region 循环发货
                    foreach (IpDetail ipDetail in ipMaster.IpDetails)
                    {
                        ipDetail.CurrentPartyFrom = ipMaster.PartyFrom;  //为了记录库存事务
                        ipDetail.CurrentPartyFromName = ipMaster.PartyFromName;  //为了记录库存事务
                        ipDetail.CurrentPartyTo = ipMaster.PartyTo;      //为了记录库存事务
                        ipDetail.CurrentPartyToName = ipMaster.PartyToName;      //为了记录库存事务
                        OrderDetail orderDetail = orderDetailList.Where(det => det.Id == ipDetail.OrderDetailId).Single();

                        #region 建立发货库明细和IpDetailInput的关系
                        ipDetail.IpLocationDetails = new List<IpLocationDetail>();
                        IpLocationDetail ipLocationDetail = new IpLocationDetail();
                        ipLocationDetail.HuId = null;
                        ipLocationDetail.LotNo = null;
                        ipLocationDetail.IsCreatePlanBill = false;
                        ipLocationDetail.IsConsignment = false;
                        ipLocationDetail.PlanBill = null;
                        ipLocationDetail.ActingBill = null;
                        ipLocationDetail.QualityType = CodeMaster.QualityType.Qualified;
                        ipLocationDetail.IsFreeze = false;
                        ipLocationDetail.IsATP = true;
                        ipLocationDetail.OccupyType = CodeMaster.OccupyType.None;
                        ipLocationDetail.OccupyReferenceNo = null;
                        ipLocationDetail.Qty = orderDetail.OrderedQty;

                        ipDetail.AddIpLocationDetail(ipLocationDetail);
                        #endregion
                    }
                    #endregion

                    #region 生成收货的IpInput
                    foreach (OrderDetail orderDetail in orderDetailList)
                    {
                        //订单收货一定是一条订单明细对应一条发货单明细
                        IpDetail ipDetail = ipMaster.IpDetails.Where(det => det.OrderDetailId == orderDetail.Id).Single();
                        ipDetail.IpDetailInputs = null;  //清空Ip的发货数据,准备添加收货数据

                        foreach (OrderDetailInput orderDetailInput in orderDetail.OrderDetailInputs)
                        {
                            IpDetailInput ipDetailInput = new IpDetailInput();
                            ipDetailInput.ReceiveQty = orderDetailInput.ShipQty;
                            ipDetail.AddIpDetailInput(ipDetailInput);
                        }
                    }

                    foreach (IpDetail ipDetail in ipMaster.IpDetails)
                    {
                        CycleMatchIpDetailInput(ipDetail, ipDetail.IpDetailInputs, ipDetail.IpLocationDetails);
                    }
                    #endregion
                    #endregion

                    #region 收货
                    ReceiptMaster receiptMaster = null;
                    receiptMaster = this.receiptMgr.TransferIp2Receipt(ipMaster);
                    this.receiptMgr.CreateReceipt(receiptMaster, false, orderMaster.CreateDate);
                    #endregion
                    this.genericMgr.FlushSession();
                }
                catch (Exception ex)
                {
                    this.genericMgr.CleanSession();
                    log.Error(ex);
                }
            }
        }
コード例 #14
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        private ReceiptMaster ShipQtyPickList(PickListMaster pickListMaster)
        {
            #region 获取订单明细
            IList<OrderDetail> orderDetailList = TryLoadOrderDetails(pickListMaster);
            #endregion

            #region 更新捡货单头
            pickListMaster.Status = CodeMaster.PickListStatus.Close;
            pickListMaster.CloseDate = DateTime.Now;
            pickListMaster.CloseUserId = SecurityContextHolder.Get().Id;
            pickListMaster.CloseUserName = SecurityContextHolder.Get().FullName;

            this.genericMgr.Update(pickListMaster);
            #endregion

            #region 更新订单明细的捡货数和发货数
            foreach (OrderDetail orderDetail in orderDetailList)
            {
                orderDetail.PickedQty -= pickListMaster.PickListDetails.Where(p => p.OrderDetailId == orderDetail.Id).Sum(p => p.Qty);
                //orderDetail.ShippedQty += pickListMaster.PickListDetails.Where(p => p.OrderDetailId == orderDetail.Id).Sum(p => p.PickedQty);
                //this.genericMgr.Update(orderDetail);

                IList<PickListDetail> pickListDetailList = pickListMaster.PickListDetails.Where(p => p.OrderDetailId == orderDetail.Id).ToList();
                foreach (PickListDetail pickListDetail in pickListDetailList)
                {
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = pickListDetail.PickedQty;
                    orderDetailInput.ConsignmentParty = pickListDetail.ConsignmentSupplier;
                    orderDetail.AddOrderDetailInput(orderDetailInput);
                }
            }
            #endregion

            #region 发货/收货
            return this.ReceiveOrder(orderDetailList, pickListMaster.EffectiveDate);
            #endregion
        }
コード例 #15
0
 public void AddOrderDetailInput(OrderDetailInput orderDetailInput)
 {
     if (OrderDetailInputs == null)
     {
         OrderDetailInputs = new List<OrderDetailInput>();
     }
     OrderDetailInputs.Add(orderDetailInput);
 }
コード例 #16
0
ファイル: OrderMgrImpl.cs プロジェクト: Novthirteen/sih-les
        public void TyreReceive(IList<OrderDetail> orderDetails)
        {
            if (orderDetails == null || orderDetails.Count == 0)
            {
                throw new BusinessException("收货明细为空。");
            }
            lock (tyreReceiveLock)
            {


                var loadAllDetails = this.genericMgr.FindAll<OrderDetail>(string.Format(" from OrderDetail as d where d.Id in({0}) ", string.Join(",", orderDetails.Select(d => d.Id).Distinct().ToArray())));
                foreach (var det in loadAllDetails)
                {
                    det.OrderDetailInputs = new List<OrderDetailInput>();
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetailInput.ReceiveQty = det.OrderedQty - det.ReceivedQty;
                    det.OrderDetailInputs.Add(orderDetailInput);
                }
                var vans = loadAllDetails.Select(l => l.ReserveNo).Distinct();
                foreach (var van in vans)
                {
                    TyreOrderMaster tyreOrderMaster = new TyreOrderMaster { TyreOrderNo = "T" + System.DateTime.Now.ToString("yyMMddHHmmss") };
                    this.ReceiveOrder(loadAllDetails.Where(d => d.ReserveNo == van).ToList());
                    IList<TyreOrderDetail> tyreOrderDets = Mapper.Map<IList<OrderDetail>, IList<TyreOrderDetail>>(orderDetails.Where(d => d.ReserveNo == van).ToList());
                    this.genericMgr.Create(tyreOrderMaster);
                    foreach (var to in tyreOrderDets)
                    {
                        var det = orderDetails.Where(l => l.Id == to.Id).First();
                        to.DetId = det.Id;
                        to.TyreOrderNo = tyreOrderMaster.TyreOrderNo;
                        to.SeqGroup = det.SequenceGroup;
                        to.VanNo = det.ReserveNo;
                        to.ShippedQty = det.OrderedQty - det.ReceivedQty;
                        to.ReceivedQty = det.OrderedQty - det.ReceivedQty;
                        this.genericMgr.Create(to);
                    }
                }


            }

        }
コード例 #17
0
        public JsonResult ReceiveOrder(string idStr, string qtyStr, string checkedOrders)
        {
            try
            {
                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                if (!string.IsNullOrEmpty(idStr))
                {
                    string[] idArray = idStr.Split(',');
                    string[] qtyArray = qtyStr.Split(',');

                    for (int i = 0; i < idArray.Count(); i++)
                    {
                        if (Convert.ToDecimal(qtyArray[i]) > 0)
                        {
                            OrderDetail od = base.genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));
                            OrderDetailInput input = new OrderDetailInput();
                            input.ReceiveQty = Convert.ToDecimal(qtyArray[i]);
                            od.AddOrderDetailInput(input);
                            orderDetailList.Add(od);
                        }
                    }
                }
                if (orderDetailList.Count() == 0)
                {
                    throw new BusinessException("收货明细不能为空");
                }

                orderMgr.ReceiveOrder(orderDetailList);
                SaveSuccessMessage(Resources.ORD.OrderMaster.OrderMaster_Received, checkedOrders);
                return Json(new { SuccessData = checkedOrders });

            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            return Json(null);
        }
コード例 #18
0
        public ReceiptMaster ReceiveExOrder(MrpExShiftPlan mrpExShiftPlan)
        {
            OrderMaster orderMaster = new OrderMaster();
            if(!string.IsNullOrWhiteSpace(mrpExShiftPlan.OrderNo))
            {
                try
                {
                    orderMaster = orderMgr.LoadOrderMaster(mrpExShiftPlan.OrderNo, true, false, true);
                    if(orderMaster.Status != CodeMaster.OrderStatus.InProcess)
                    {
                        orderMaster = CreateExOrder(mrpExShiftPlan);
                    }
                }
                catch(Exception)
                {
                    orderMaster = CreateExOrder(mrpExShiftPlan);
                }
            }
            else
            {
                orderMaster = CreateExOrder(mrpExShiftPlan);
            }
            var receiptMaster = new ReceiptMaster();
            if(mrpExShiftPlan.CurrentQty <= 0)//只是打印废品条码
            {
                //打印废品条码
                var item = new Item();
                if(!string.IsNullOrWhiteSpace(mrpExShiftPlan.Section) && mrpExShiftPlan.Section != "299999")
                {
                    item = itemMgr.GetCacheItem(mrpExShiftPlan.Section);
                }
                else
                {
                    this.itemMgr.GetCacheItem(mrpExShiftPlan.Item);
                }
                Hu hu = new Hu();
                hu.Qty = 0;
                hu.Item = item.Code;
                hu.ItemDescription = item.Description;
                hu.BaseUom = item.Uom;
                hu.Uom = item.Uom;
                hu.UnitCount = item.UnitCount;
                hu.UnitQty = 1;
                hu.Qty = 0;
                hu.HuTemplate = "BarCodeEXScrap.xls";
                hu.ManufactureDate = mrpExShiftPlan.PlanDate;
                hu.LotNo = Utility.LotNoHelper.GenerateLotNo(hu.ManufactureDate);
                hu.PrintCount = 0;
                hu.ConcessionCount = 0;
                hu.ReferenceItemCode = item.ReferenceCode;
                hu.LocationTo = mrpExShiftPlan.LocationTo;
                hu.OrderNo = orderMaster.OrderNo;
                hu.Shift = mrpExShiftPlan.Shift;
                hu.Flow = mrpExShiftPlan.ProductLine;
                hu.ManufactureParty = orderMaster.PartyFrom;
                //hu.HuId = Guid.NewGuid().ToString();
                //hu.IsOdd = hu.Qty < hu.UnitCount;
                //hu.IsChangeUnitCount = false;
                //hu.UnitCountDescription = null;
                //hu.SupplierLotNo = null;
                //hu.ContainerDesc = null;
                receiptMaster.HuList = new List<Hu>();
                receiptMaster.HuList.Add(hu);
                receiptMaster.CreateHuOption = orderMaster.CreateHuOption;
                receiptMaster.HuTemplate = orderMaster.HuTemplate;
            }
            else
            {
                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetailInput.ReceiveQty = (decimal)mrpExShiftPlan.CurrentQty;

                orderMaster.OrderDetails[0].AddOrderDetailInput(orderDetailInput);
                orderMaster.OrderDetails[0].IsInspect = mrpExShiftPlan.IsFreeze;
                orderMaster.IsInspect = true;

                receiptMaster = orderMgr.ReceiveOrder(orderMaster.OrderDetails);
                mrpExShiftPlan.ReceivedQty += mrpExShiftPlan.CurrentQty;
                this.genericMgr.Update(mrpExShiftPlan);

                receiptMaster.HuList = receiptMaster.ReceiptDetails.SelectMany(p => p.ReceiptLocationDetails.Select(q => q.HuId))
                    .Select(p => { return this.genericMgr.FindById<Hu>(p); }).ToList();
                foreach(var hu in receiptMaster.HuList)
                {
                    hu.ItemVersion = mrpExShiftPlan.ProductType;
                    this.genericMgr.Update(hu);
                }
            }
            return receiptMaster;
        }
コード例 #19
0
 public ActionResult ShipOrderByOrderNo(string orderNo)
 {
     string hql = " select d from OrderDetail as d where d.OrderNo=? ";
     IList<OrderDetail> orderDetailList = base.genericMgr.FindAll<OrderDetail>(hql, orderNo);
     try
     {
         foreach (var det in orderDetailList)
         {
             OrderDetailInput input = new OrderDetailInput();
             input.ReceiveQty = det.OrderedQty;
             det.AddOrderDetailInput(input);
         }
         orderMgr.ReceiveOrder(orderDetailList, System.DateTime.Now);
         SaveSuccessMessage("发货成功。");
     }
     catch (BusinessException ex)
     {
         SaveBusinessExceptionMessage(ex);
     }
     catch (Exception ex)
     {
         SaveErrorMessage(ex);
     }
     OrderMaster orderMaster = base.genericMgr.FindById<OrderMaster>(orderNo);
     return View("Edit", orderMaster);
 }
コード例 #20
0
        public ReceiptMaster ReceiveUrgentExOrder(FlowDetail flowDetail)
        {
            var flowMaster = flowDetail.CurrentFlowMaster;
            if(flowMaster == null)
            {
                flowMaster = genericMgr.FindById<FlowMaster>(flowDetail.Flow);
            }

            var orderMaster = orderMgr.TransferFlow2Order(flowMaster, false);

            OrderDetail orderDetail = new OrderDetail();
            var item = this.itemMgr.GetCacheItem(flowDetail.Item);
            orderDetail.Item = item.Code;
            orderDetail.UnitCount = flowDetail.UnitCount;
            orderDetail.Uom = flowDetail.Uom;
            orderDetail.ItemDescription = item.Description;
            orderDetail.BaseUom = item.Uom;
            orderDetail.Sequence = 10;
            orderDetail.MinUnitCount = item.UnitCount;
            orderDetail.OrderedQty = (decimal)flowDetail.CurrentQty;
            orderDetail.IsInspect = flowDetail.IsFreeze;
            orderDetail.ReferenceItemCode = item.ReferenceCode;
            orderDetail.UnitCountDescription = flowDetail.UnitCountDescription;
            orderDetail.ContainerDescription = flowDetail.ContainerDescription;

            orderDetail.Remark = flowDetail.Remark;
            if(item.ItemOption == com.Sconit.CodeMaster.ItemOption.NeedAging)
            {
                orderDetail.OldOption = Sconit.CodeMaster.HuOption.UnAging;
            }
            else
            {
                orderDetail.OldOption = Sconit.CodeMaster.HuOption.NoNeed;
            }
            var productType = this.genericMgr.FindById<ProductType>(flowDetail.ProductType);
            orderDetail.ScheduleType = productType.SubType;
            orderMaster.AddOrderDetail(orderDetail);

            if(flowMaster.Code == "EXV")
            {
                orderMaster.ProductLineFacility = "EXV";
            }

            orderMaster.IsAutoRelease = true;
            orderMaster.IsAutoStart = true;
            orderMaster.IsAutoReceive = false;
            orderMaster.IsOpenOrder = false;
            orderMaster.Shift = flowDetail.Shift;
            DateTime startTime = DateTime.Now;
            DateTime windowTime = DateTime.Now;
            workingCalendarMgr.GetStartTimeAndWindowTime(orderMaster.Shift, DateTime.Now.AddHours(-7.75).Date, out startTime, out windowTime);
            orderMaster.StartTime = startTime;
            orderMaster.WindowTime = windowTime;
            orderMaster.Priority = CodeMaster.OrderPriority.Urgent;
            orderMaster.CreateHuOption = Sconit.CodeMaster.CreateHuOption.Receive;
            orderMaster.EffectiveDate = startTime.Date;

            var bomDetail = this.bomMgr.GetOnlyNextLevelBomDetail(flowDetail.Item, orderMaster.StartTime)
                    .Where(p => p.Item.StartsWith("29")).FirstOrDefault();
            if(bomDetail != null)
            {
                item = itemMgr.GetCacheItem(bomDetail.Item);
                orderMaster.ReferenceOrderNo = bomDetail.Item;
            }
            orderMaster.SubType = CodeMaster.OrderSubType.Normal;
            orderMgr.CreateOrder(orderMaster);

            var receiptMaster = new ReceiptMaster();
            if(flowDetail.CurrentQty <= 0)
            {
                Hu hu = new Hu();
                hu.Qty = 0;
                hu.Item = item.Code;
                hu.ItemDescription = item.Description;
                hu.BaseUom = item.Uom;
                hu.Uom = item.Uom;
                hu.UnitCount = item.UnitCount;
                hu.UnitQty = 1;
                hu.Qty = 0;
                hu.HuTemplate = "BarCodeEXScrap.xls";
                hu.ManufactureDate = DateTime.Now.AddHours(-7.75).Date;
                hu.LotNo = Utility.LotNoHelper.GenerateLotNo(hu.ManufactureDate);
                hu.PrintCount = 0;
                hu.ConcessionCount = 0;
                hu.ReferenceItemCode = item.ReferenceCode;
                hu.LocationTo = flowDetail.LocationTo;
                if(string.IsNullOrWhiteSpace(hu.LocationTo))
                {
                    hu.LocationTo = flowMaster.LocationTo;
                }
                hu.Shift = flowDetail.Shift;
                hu.Flow = flowDetail.Flow;
                hu.OrderNo = orderMaster.OrderNo;

                receiptMaster.HuList = new List<Hu>();
                receiptMaster.HuList.Add(hu);
                receiptMaster.CreateHuOption = orderMaster.CreateHuOption;
                receiptMaster.HuTemplate = orderMaster.HuTemplate;
                orderMgr.ManualCloseOrder(orderMaster);
            }
            else
            {
                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetailInput.ReceiveQty = (decimal)flowDetail.CurrentQty;
                orderMaster.OrderDetails[0].AddOrderDetailInput(orderDetailInput);
                receiptMaster = orderMgr.ReceiveOrder(orderMaster.OrderDetails);
                receiptMaster.HuList = receiptMaster.ReceiptDetails.SelectMany(p => p.ReceiptLocationDetails.Select(q => q.HuId))
                    .Select(p => { return this.genericMgr.FindById<Hu>(p); }).ToList();
                foreach(var hu in receiptMaster.HuList)
                {
                    hu.ItemVersion = flowDetail.ProductType;
                    this.genericMgr.Update(hu);
                }
            }
            return receiptMaster;
        }
コード例 #21
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        public IpMaster ShipScheduleLine(IList<ScheduleLineInput> scheduleLineInputList)
        {
            IList<OrderDetail> shipOrderDetailList = new List<OrderDetail>();
            foreach (ScheduleLineInput scheduleLineInput in scheduleLineInputList)
            {
                decimal remainShipQty = scheduleLineInput.ShipQty;

                IList<OrderDetail> orderDetailList = this.genericMgr.FindEntityWithNativeSql<OrderDetail>("select * from ORD_OrderDet_8 where ExtNo = ? and ExtSeq like ? and ScheduleType = ? and OrderQty > ShipQty order by EndDate",
                    new object[] { scheduleLineInput.EBELN, scheduleLineInput.EBELP + "-%", CodeMaster.ScheduleType.Firm });

                foreach (OrderDetail orderDetail in orderDetailList)
                {
                    OrderDetailInput orderDetailInput = new OrderDetailInput();
                    orderDetail.AddOrderDetailInput(orderDetailInput);
                    shipOrderDetailList.Add(orderDetail);

                    if (remainShipQty > orderDetail.RemainShippedQty)
                    {
                        orderDetailInput.ShipQty = orderDetail.RemainShippedQty;
                        remainShipQty -= orderDetail.RemainShippedQty;
                    }
                    else
                    {
                        orderDetailInput.ShipQty = remainShipQty;
                        remainShipQty = 0;
                        break;
                    }
                }

                if (remainShipQty > 0)
                {
                    throw new BusinessException("计划协议号{0}行号{1}的需求数不足。", scheduleLineInput.EBELN, scheduleLineInput.EBELP);
                }
            }

            return ShipOrder(shipOrderDetailList);
        }
コード例 #22
0
        private static void AddBackflushInput(OrderMaster orderMaster, OrderDetail orderDetail, List<BackflushInput> backflushInputList, OrderBomDetail orderBomDetail, OrderDetailInput orderDetailInput, ReceiptDetail receiptDetail, decimal backFlushInputQty)
        {
            BackflushInput backFlushInput = new BackflushInput();

            backFlushInput.ProductLine = orderMaster.Flow;
            backFlushInput.ProductLineFacility = orderMaster.ProductLineFacility;
            backFlushInput.CurrentProductLine = orderMaster.CurrentFlowMaster;
            backFlushInput.OrderNo = orderMaster.OrderNo;
            backFlushInput.OrderType = orderMaster.Type;
            backFlushInput.OrderSubType = orderMaster.SubType;
            backFlushInput.OrderDetailId = orderDetail.Id;
            backFlushInput.OrderDetailSequence = orderDetail.Sequence;
            backFlushInput.OrderBomDetail = orderBomDetail;
            backFlushInput.ReceiptNo = receiptDetail.ReceiptNo;
            backFlushInput.ReceiptDetailId = receiptDetail.Id;
            backFlushInput.ReceiptDetailSequence = receiptDetail.Sequence;
            backFlushInput.FGItem = orderDetail.Item;
            backFlushInput.Item = orderBomDetail.Item;
            backFlushInput.ItemDescription = orderBomDetail.ItemDescription;
            backFlushInput.ReferenceItemCode = orderBomDetail.ReferenceItemCode;
            backFlushInput.Uom = orderBomDetail.Uom;
            backFlushInput.BaseUom = orderBomDetail.BaseUom;
            backFlushInput.UnitQty = orderBomDetail.UnitQty;   //基本单位转换率 = 订单单位/库存单位,转换为库存单位消耗 = 单位用量(订单单位) / 基本单位转换率
            backFlushInput.TraceCode = orderDetailInput.TraceCode;
            //backFlushInput.QualityType = CodeMaster.QualityType.Qualified;
            backFlushInput.FGQualityType = orderDetailInput.QualityType;  //收货成品的质量状态
            //backFlushInput.HuId = orderDetailInput.HuId;
            //backFlushInput.LotNo = orderDetailInput.LotNo;
            backFlushInput.Qty = backFlushInputQty;
            backFlushInput.ReceivedQty = receiptDetail.ReceivedQty;

            if (orderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.GoodsReceive)
            {
                #region 按比例回冲
                //backFlushInput.ProductLineLocationDetailList = productLineLocationDetailList.Where(p => p.Item == orderBomDetail.Item).ToList();
                backFlushInput.Operation = orderBomDetail.Operation;
                backFlushInput.OpReference = orderBomDetail.OpReference;
                #endregion
            }
            backflushInputList.Add(backFlushInput);
        }
コード例 #23
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        public ReceiptMaster ReceiveIp(IList<IpDetail> ipDetailList, bool isCheckKitTraceItem, DateTime effectiveDate)
        {
            #region 判断送货单是否合并收货
            if ((from det in ipDetailList select det.IpNo).Distinct().Count() > 1)
            {
                throw new TechnicalException("送货单不能合并收货。");
            }
            #endregion

            #region 判断是否全0发货
            if (ipDetailList == null || ipDetailList.Count == 0)
            {
                throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveDetailIsEmpty);
            }

            IList<IpDetail> nonZeroIpDetailList = ipDetailList.Where(o => o.ReceiveQtyInput != 0).ToList();

            if (nonZeroIpDetailList.Count == 0)
            {
                throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveDetailIsEmpty);
            }
            #endregion

            #region 查询送货单头对象
            string ipNo = (from det in nonZeroIpDetailList select det.IpNo).Distinct().Single();
            IpMaster ipMaster = this.genericMgr.FindById<IpMaster>(ipNo);
            ipMaster.IpDetails = nonZeroIpDetailList;
            #endregion

            #region 查询订单头对象
            IList<OrderMaster> orderMasterList = LoadOrderMasters((from det in nonZeroIpDetailList
                                                                   select det.OrderNo).Distinct().ToArray());

            //foreach (var orderMaster in orderMasterList)
            //{
            //    if (!Utility.SecurityHelper.HasPermission(orderMaster))
            //    {
            //        throw new BusinessException("没有此订单{0}的操作权限。", orderMaster.OrderNo);
            //    }
            //}

            #endregion

            #region 获取收货订单类型
            IList<com.Sconit.CodeMaster.OrderType> orderTypeList = (from orderMaster in orderMasterList
                                                                    group orderMaster by orderMaster.Type into result
                                                                    select result.Key).ToList();

            if (orderTypeList.Count > 1)
            {
                throw new BusinessException(Resources.ORD.OrderMaster.Errors_CannotMixOrderTypeReceive);
            }

            com.Sconit.CodeMaster.OrderType orderType = orderTypeList.First();
            #endregion

            #region 排序单/KIT收货顺序判断
            //没有考虑多个路线的排序单/Kit单同时发货
            //var groupedSeqOrderMaster = from mstr in orderMasterList
            //                            where !string.IsNullOrWhiteSpace(mstr.Flow)
            //                                    && (mstr.OrderStrategy == CodeMaster.FlowStrategy.KIT
            //                                    || mstr.OrderStrategy == CodeMaster.FlowStrategy.SEQ)
            //                            group mstr by new { Flow = mstr.Flow, OrderStrategy = mstr.OrderStrategy } into result
            //                            select new
            //                            {
            //                                Flow = result.Key.Flow,
            //                                OrderStrategy = result.Key.OrderStrategy,
            //                                List = result.ToList()
            //                            };

            //if (groupedSeqOrderMaster != null && groupedSeqOrderMaster.Count() > 0)
            //{
            //    BusinessException businessException = new BusinessException();
            //    foreach (var seqOrderMaster in groupedSeqOrderMaster)
            //    {
            //        OrderMaster biggestSeqOrderMaster = seqOrderMaster.List.OrderBy(o => o.Sequence).LastOrDefault();

            //        if (this.GetSpecifiedStatusOrderCount(biggestSeqOrderMaster, CodeMaster.OrderStatus.InProcess)           //小与等于最大序号的待收货排序单/Kit单的总数,状态为InProcess
            //            > seqOrderMaster.List.Count())                                                                       //当前待收货排序单/Kit单的总数
            //        {
            //            if (biggestSeqOrderMaster.OrderStrategy == CodeMaster.FlowStrategy.KIT)
            //            {
            //                businessException.AddMessage("KIT路线{0}没有按顺序进行收货。", biggestSeqOrderMaster.Flow);
            //            }
            //            else
            //            {
            //                businessException.AddMessage("排序路线{0}没有按顺序进行收货。", biggestSeqOrderMaster.Flow);
            //            }
            //        }
            //    }

            //    if (businessException.HasMessage)
            //    {
            //        throw businessException;
            //    }
            //}
            #endregion

            #region 查询订单明细对象
            IList<OrderDetail> orderDetailList = LoadOrderDetails((from det in nonZeroIpDetailList
                                                                   where det.OrderDetailId.HasValue
                                                                   select det.OrderDetailId.Value).Distinct().ToArray());
            #endregion

            #region 查询送货单库存对象
            IList<IpLocationDetail> ipLocationDetailList = LoadIpLocationDetails((from det in nonZeroIpDetailList
                                                                                  select det.Id).ToArray());
            #endregion

            //FlowMaster flowMaster = null;
            //if (ipMaster.OrderType == CodeMaster.OrderType.Procurement)
            //{
            //    flowMaster = this.genericMgr.FindById<FlowMaster>(ipMaster.Flow);
            //}

            #region 循环检查发货明细
            foreach (IpDetail ipDetail in nonZeroIpDetailList)
            {
                #region 整包装收货判断
                if (ipMaster.IsReceiveFulfillUC)
                {
                    //不合格品不作为收货数
                    if (ipDetail.ReceiveQtyInput % ipDetail.UnitCount != 0)
                    {
                        //不是整包装
                        throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveQtyNotFulfillUnitCount, ipDetail.Item, ipDetail.UnitCount.ToString());
                    }
                }
                #endregion

                #region 是否过量收货判断
                if (orderType != CodeMaster.OrderType.ScheduleLine)
                {
                    if (Math.Abs(ipDetail.ReceivedQty) >= Math.Abs(ipDetail.Qty))
                    {
                        //送货单的收货数已经大于等于发货数
                        throw new BusinessException(Resources.ORD.IpMaster.Errors_ReceiveQtyExcceedOrderQty, ipMaster.IpNo, ipDetail.Item);
                    }
                    else if (!ipMaster.IsReceiveExceed && Math.Abs(ipDetail.ReceivedQty + ipDetail.ReceiveQtyInput) > Math.Abs(ipDetail.Qty))
                    {
                        //送货单的收货数 + 本次收货数大于发货数
                        throw new BusinessException(Resources.ORD.IpMaster.Errors_ReceiveQtyExcceedOrderQty, ipMaster.IpNo, ipDetail.Item);
                    }
                }
                #endregion

                #region 发货明细是否已经关闭
                if (ipDetail.IsClose)
                {
                    throw new BusinessException("送货单{0}零件{1}已经关闭,不能进行收货。", ipMaster.IpNo, ipDetail.Item);
                }
                #endregion

                #region 采购收货是否有价格单判断
                //if (ipMaster.OrderType == CodeMaster.OrderType.Procurement)
                //{
                //    if (!flowMaster.IsAllowProvEstRec)
                //    {
                //        if (ipDetail.IsProvisionalEstimate || ipDetail.UnitPrice == 0M)
                //        {
                //            throw new BusinessException("此采购路线{0}不允许暂估价收货", ipMaster.Flow);
                //        }
                //    }
                //}

                //if (orderHead.Type == BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PROCUREMENT
                //    && !bool.Parse(entityPreference.Value))
                //{
                //    if (orderDetail.UnitPrice == Decimal.Zero)
                //    {
                //        //重新查找一次价格
                //        PriceListDetail priceListDetail = priceListDetailMgrE.GetLastestPriceListDetail(
                //            orderDetail.DefaultPriceList,
                //            orderDetail.Item,
                //            orderHead.StartTime,
                //            orderHead.Currency,
                //            orderDetail.Uom);

                //        if (priceListDetail != null)
                //        {
                //            orderDetail.UnitPrice = priceListDetail.UnitPrice;
                //            orderDetail.IsProvisionalEstimate = priceListDetail.IsProvisionalEstimate;
                //            orderDetail.IsIncludeTax = priceListDetail.IsIncludeTax;
                //            orderDetail.TaxCode = priceListDetail.TaxCode;
                //        }
                //        else
                //        {
                //            throw new BusinessErrorException("Order.Error.NoPriceListReceipt", orderDetail.Item.Code);
                //        }
                //    }
                //}
                #endregion
            }
            #endregion

            #region KIT单收货判断
            //if (ipMaster.Type == CodeMaster.IpType.KIT)
            //{
            //    string anjiRegion = systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.WMSAnjiRegion);
            //    if (ipMaster.PartyFrom != anjiRegion)
            //    {
            //        CheckKitIpDetail(ipMaster, isCheckKitTraceItem);
            //    }
            //}
            #endregion

            #region 关闭排序装箱单
            if (ipMaster.Type == CodeMaster.IpType.SEQ &&
                !string.IsNullOrWhiteSpace(ipMaster.SequenceNo))
            {
                SequenceMaster sequenceMaster = this.genericMgr.FindById<SequenceMaster>(ipMaster.SequenceNo);
                sequenceMaster.Status = CodeMaster.SequenceStatus.Close;
                sequenceMaster.CloseDate = DateTime.Now;
                sequenceMaster.CloseUserId = SecurityContextHolder.Get().Id;
                sequenceMaster.CloseUserName = SecurityContextHolder.Get().FullName;

                this.genericMgr.Update(sequenceMaster);

                foreach (SequenceDetail sequenceDetail in TryLoadSequenceDetails(sequenceMaster).Where(s => !s.IsClose))
                {
                    sequenceDetail.IsClose = true;
                    this.genericMgr.Update(sequenceDetail);
                }
            }
            #endregion

            #region 循环更新订单明细
            if (orderType == CodeMaster.OrderType.Production || orderType == CodeMaster.OrderType.SubContract)
            {
                //nothing todo
            }
            else if (orderType != CodeMaster.OrderType.ScheduleLine)
            {
                foreach (OrderDetail orderDetail in orderDetailList)
                {
                    IList<IpDetail> targetIpDetailList = (from det in nonZeroIpDetailList
                                                          where det.OrderDetailId == orderDetail.Id
                                                          select det).ToList();

                    //更新订单的收货数
                    orderDetail.ReceivedQty += targetIpDetailList.Sum(det => det.ReceiveQtyInput);
                    genericMgr.Update(orderDetail);
                }
            }
            else
            {
                foreach (IpDetail ipDetail in nonZeroIpDetailList)
                {
                    decimal remainReceiveQty = ipDetail.ReceiveQtyInput;

                    IList<OrderDetail> scheduleOrderDetailList = this.genericMgr.FindEntityWithNativeSql<OrderDetail>("select * from ORD_OrderDet_8 where ExtNo = ? and ExtSeq like ? and ScheduleType = ? and ShipQty > RecQty order by EndDate",
                                                new object[] { ipDetail.ExternalOrderNo, ipDetail.ExternalSequence + "-%", CodeMaster.ScheduleType.Firm });

                    if (scheduleOrderDetailList != null && scheduleOrderDetailList.Count > 0)
                    {
                        foreach (OrderDetail scheduleOrderDetail in scheduleOrderDetailList)
                        {

                            if (remainReceiveQty > (scheduleOrderDetail.ShippedQty - scheduleOrderDetail.ReceivedQty))
                            {
                                remainReceiveQty -= (scheduleOrderDetail.ShippedQty - scheduleOrderDetail.ReceivedQty);
                                scheduleOrderDetail.ReceivedQty = scheduleOrderDetail.ShippedQty;
                            }
                            else
                            {
                                scheduleOrderDetail.ReceivedQty += remainReceiveQty;
                                remainReceiveQty = 0;
                                break;
                            }

                            this.genericMgr.Update(scheduleOrderDetail);
                        }
                    }

                    if (remainReceiveQty > 0)
                    {
                        throw new BusinessException(Resources.ORD.IpMaster.Errors_ReceiveQtyExcceedOrderQty, ipMaster.IpNo, ipDetail.Item);
                    }
                }
            }
            #endregion

            #region 循环IpDetail,处理超收差异
            IList<IpDetail> gapIpDetailList = new List<IpDetail>();
            foreach (IpDetail targetIpDetail in nonZeroIpDetailList)
            {
                #region 收货输入和送货单库存明细匹配
                IList<IpLocationDetail> targetIpLocationDetailList = (from ipLocDet in ipLocationDetailList
                                                                      where ipLocDet.IpDetailId == targetIpDetail.Id
                                                                      select ipLocDet).OrderByDescending(d => d.IsConsignment).ToList();  //排序为了先匹配寄售的

                bool isContainHu = targetIpLocationDetailList.Where(ipLocDet => !string.IsNullOrWhiteSpace(ipLocDet.HuId)).Count() > 0;

                if (ipMaster.IsReceiveScanHu)
                {
                    #region 收货扫描条码
                    if (isContainHu)
                    {
                        #region 条码匹配条码

                        #region 匹配到的条码
                        IList<IpLocationDetail> matchedIpLocationDetailList = new List<IpLocationDetail>();
                        foreach (IpDetailInput ipDetailInput in targetIpDetail.IpDetailInputs)
                        {
                            IpLocationDetail matchedIpLocationDetail = targetIpLocationDetailList.Where(locDet => locDet.HuId == ipDetailInput.HuId).SingleOrDefault();

                            if (matchedIpLocationDetail != null)
                            {
                                ipDetailInput.AddReceivedIpLocationDetail(matchedIpLocationDetail);
                                matchedIpLocationDetailList.Add(matchedIpLocationDetail);

                                #region 更新库存状态
                                matchedIpLocationDetail.ReceivedQty = matchedIpLocationDetail.Qty;
                                matchedIpLocationDetail.IsClose = true;

                                genericMgr.Update(matchedIpLocationDetail);
                                #endregion
                            }
                        }
                        #endregion

                        #region 未匹配到的条码,记录差异
                        var matchedHuIdList = matchedIpLocationDetailList.Select(locDet => locDet.HuId);
                        var gapIpDetailInputList = targetIpDetail.IpDetailInputs.Where(input => !matchedHuIdList.Contains(input.HuId));

                        #region 记录差异
                        if (gapIpDetailInputList != null && gapIpDetailInputList.Count() > 0)
                        {
                            IpDetail gapIpDetail = Mapper.Map<IpDetail, IpDetail>(targetIpDetail);
                            gapIpDetail.Type = com.Sconit.CodeMaster.IpDetailType.Gap;
                            gapIpDetail.GapReceiptNo = string.Empty;                            //todo 记录产生差异的收货单号
                            //gapIpDetail.Qty = gapIpDetailInputList.Sum(gap => -gap.ReceiveQty / targetIpDetail.UnitQty); //多收的条码,数量为负,转为订单单位
                            gapIpDetail.Qty = gapIpDetailInputList.Sum(gap => -gap.ReceiveQty); //多收的条码,数量为负
                            gapIpDetail.ReceivedQty = 0;
                            gapIpDetail.IsClose = false;
                            gapIpDetail.GapIpDetailId = targetIpDetail.Id;

                            gapIpDetail.IpLocationDetails = (from gap in gapIpDetailInputList
                                                             select new IpLocationDetail
                                                             {
                                                                 IpNo = ipMaster.IpNo,
                                                                 OrderType = targetIpDetail.OrderType,
                                                                 OrderDetailId = targetIpDetail.OrderDetailId,
                                                                 Item = targetIpDetail.Item,
                                                                 //HuId = gap.HuId,      //多收的条码按数量记录差异
                                                                 //LotNo = gap.LotNo,
                                                                 IsCreatePlanBill = false,
                                                                 PlanBill = null,
                                                                 ActingBill = null,
                                                                 IsFreeze = false,
                                                                 IsATP = false,          //差异不能进行MRP运算
                                                                 QualityType = targetIpDetail.QualityType,
                                                                 OccupyType = com.Sconit.CodeMaster.OccupyType.None,
                                                                 OccupyReferenceNo = null,
                                                                 Qty = -gap.ReceiveQty * gapIpDetail.UnitQty,    //多收,产生负数的差异
                                                                 ReceivedQty = 0,
                                                                 IsClose = false
                                                             }).ToList();

                            gapIpDetailList.Add(gapIpDetail);
                        }
                        #endregion
                        #endregion
                        #endregion
                    }
                    else
                    {
                        #region 数量匹配条码
                        IpDetail gapIpDetail = CycleMatchIpDetailInput(targetIpDetail, targetIpDetail.IpDetailInputs, targetIpLocationDetailList);
                        if (gapIpDetail != null)
                        {
                            gapIpDetailList.Add(gapIpDetail);
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    #region 收货不扫描条码
                    if (isContainHu)
                    {
                        #region 条码匹配数量
                        IpDetail gapIpDetail = CycleMatchIpDetailInput(targetIpDetail, targetIpDetail.IpDetailInputs, targetIpLocationDetailList);
                        if (gapIpDetail != null)
                        {
                            gapIpDetailList.Add(gapIpDetail);
                        }
                        #endregion
                    }
                    else
                    {
                        //采购数量超收,用收货输入数补发货数
                        if (ipMaster.OrderType == CodeMaster.OrderType.Procurement)
                        {
                            var remainSum = targetIpLocationDetailList.Sum(t => t.RemainReceiveQty);
                            var receiveSum = targetIpDetail.IpDetailInputs.Sum(t => t.ReceiveQty);
                            if (remainSum < receiveSum)
                            {
                                var firstIpLocationDetail = targetIpLocationDetailList.FirstOrDefault();
                                firstIpLocationDetail.Qty = firstIpLocationDetail.Qty + (receiveSum - remainSum);
                                this.genericMgr.Update(firstIpLocationDetail);
                            }
                        }
                        #region 数量匹配数量
                        IpDetail gapIpDetail = CycleMatchIpDetailInput(targetIpDetail, targetIpDetail.IpDetailInputs, targetIpLocationDetailList);
                        if (gapIpDetail != null)
                        {
                            gapIpDetailList.Add(gapIpDetail);
                        }
                        #endregion
                    }
                    #endregion
                }
                #endregion

                #region 更新IpDetail上的收货数
                targetIpDetail.ReceivedQty += targetIpDetail.ReceiveQtyInput;
                if (targetIpLocationDetailList.Where(i => !i.IsClose).Count() == 0)
                {
                    //只有所有的IpLocationDetail关闭才能关闭
                    targetIpDetail.IsClose = true;
                }
                genericMgr.Update(targetIpDetail);
                #endregion
            }
            #endregion

            #region 送货单一次性收货,未收货差异
            if (ipMaster.IsAsnUniqueReceive)
            {
                #region 查找未关闭送货单明细
                List<IpDetail> openIpDetailList = (from det in nonZeroIpDetailList where !det.IsClose select det).ToList();

                #region 查询剩余的未关闭送货单明细
                IList<IpDetail> exceptIpDetailList = LoadExceptIpDetails(ipMaster.IpNo, (nonZeroIpDetailList.Select(det => det.Id)).ToArray());
                #endregion

                #region 合并未关闭送货单明细
                if (exceptIpDetailList != null && exceptIpDetailList.Count > 0)
                {
                    openIpDetailList.AddRange(exceptIpDetailList);
                }
                #endregion
                #endregion

                #region 查找未关闭送货单库存对象
                List<IpLocationDetail> openIpLocationDetailList = (from det in ipLocationDetailList where !det.IsClose select det).ToList();

                #region 查询剩余未关闭送货单库存对象
                IList<IpLocationDetail> expectIpLocationDetailList = LoadExceptIpLocationDetails(ipMaster.IpNo, (nonZeroIpDetailList.Select(det => det.Id)).ToArray());
                #endregion

                #region 合并未关闭送货单库存对象
                if (expectIpLocationDetailList != null && expectIpLocationDetailList.Count > 0)
                {
                    openIpLocationDetailList.AddRange(expectIpLocationDetailList);
                }
                #endregion
                #endregion

                #region 生成未收货差异
                if (openIpDetailList != null && openIpDetailList.Count > 0)
                {
                    foreach (IpDetail openIpDetail in openIpDetailList)
                    {
                        var targetOpenIpLocationDetailList = openIpLocationDetailList.Where(o => o.IpDetailId == openIpDetail.Id);

                        IpDetail gapIpDetail = Mapper.Map<IpDetail, IpDetail>(openIpDetail);
                        gapIpDetail.Type = com.Sconit.CodeMaster.IpDetailType.Gap;
                        gapIpDetail.GapReceiptNo = string.Empty;                            //todo 记录产生差异的收货单号
                        gapIpDetail.Qty = targetOpenIpLocationDetailList.Sum(o => o.RemainReceiveQty / openIpDetail.UnitQty);
                        gapIpDetail.ReceivedQty = 0;
                        gapIpDetail.IsClose = false;
                        gapIpDetail.GapIpDetailId = openIpDetail.Id;

                        gapIpDetail.IpLocationDetails = (from locDet in targetOpenIpLocationDetailList
                                                         select new IpLocationDetail
                                                         {
                                                             IpNo = locDet.IpNo,
                                                             OrderType = locDet.OrderType,
                                                             OrderDetailId = locDet.OrderDetailId,
                                                             Item = locDet.Item,
                                                             HuId = locDet.HuId,
                                                             LotNo = locDet.LotNo,
                                                             IsCreatePlanBill = locDet.IsCreatePlanBill,
                                                             IsConsignment = locDet.IsConsignment,
                                                             PlanBill = locDet.PlanBill,
                                                             ActingBill = locDet.ActingBill,
                                                             IsFreeze = locDet.IsFreeze,
                                                             //IsATP = locDet.IsATP,
                                                             IsATP = false,
                                                             QualityType = locDet.QualityType,
                                                             OccupyType = locDet.OccupyType,
                                                             OccupyReferenceNo = locDet.OccupyReferenceNo,
                                                             Qty = locDet.RemainReceiveQty,
                                                             ReceivedQty = 0,
                                                             IsClose = false
                                                         }).ToList();

                        gapIpDetailList.Add(gapIpDetail);
                    }
                }
                #endregion

                #region 关闭未收货送货单明细和库存明细
                if (openIpDetailList != null && openIpDetailList.Count > 0)
                {
                    foreach (IpDetail openIpDetail in openIpDetailList)
                    {
                        openIpDetail.IsClose = true;
                        this.genericMgr.Update(openIpDetail);
                    }
                }

                if (openIpLocationDetailList != null && openIpLocationDetailList.Count > 0)
                {
                    foreach (IpLocationDetail openIpLocationDetail in openIpLocationDetailList)
                    {
                        openIpLocationDetail.IsClose = true;
                        this.genericMgr.Update(openIpLocationDetail);
                    }
                }
                //string batchupdateipdetailstatement = "update from ipdetail set isclose = true where ipno = ? and isclose = false";
                //genericmgr.update(batchupdateipdetailstatement, ipmaster.ipno);

                //string batchUpdateIpLocationDetailStatement = "update from IpLocationDetail set IsClose = True where IpNo = ? and IsClose = False";
                //genericMgr.Update(batchUpdateIpLocationDetailStatement, ipMaster.IpNo);                
                #endregion
            }
            else
            {
                ipMaster.Status = CodeMaster.IpStatus.InProcess;
            }
            #endregion

            #region 收货

            ReceiptMaster receiptMaster = null;
            if (orderType == CodeMaster.OrderType.Production
                || orderType == CodeMaster.OrderType.SubContract)
            {
                foreach (var orderDetail in orderDetailList)
                {
                    var _ipDetail = nonZeroIpDetailList.First(i => i.OrderDetailId == orderDetail.Id);
                    foreach (var ipDetailInput in _ipDetail.IpDetailInputs)
                    {
                        OrderDetailInput orderDetailInput = new OrderDetailInput();
                        orderDetailInput.Bin = ipDetailInput.Bin;
                        orderDetailInput.HuId = ipDetailInput.HuId;
                        orderDetailInput.LotNo = ipDetailInput.LotNo;
                        orderDetailInput.ManufactureParty = ipDetailInput.ManufactureParty;
                        orderDetailInput.OccupyReferenceNo = ipDetailInput.OccupyReferenceNo;
                        orderDetailInput.OccupyType = ipDetailInput.OccupyType;
                        orderDetailInput.ReceiveQty = ipDetailInput.ReceiveQty;
                        if (_ipDetail.Id != 0)
                        {
                            orderDetailInput.IpNo = _ipDetail.IpNo;
                            orderDetailInput.IpDetId = _ipDetail.Id;
                        }
                        orderDetail.AddOrderDetailInput(orderDetailInput);
                    }
                }
                receiptMaster = this.ReceiveOrder(orderDetailList, ipNo);
            }
            else
            {
                receiptMaster = this.receiptMgr.TransferIp2Receipt(ipMaster);
                this.receiptMgr.CreateReceipt(receiptMaster, effectiveDate);

                #region 尝试关闭订单
                foreach (OrderMaster orderMaster in orderMasterList)
                {
                    TryCloseOrder(orderMaster);
                }
                #endregion
            }
            #endregion

            #region 记录收货差异
            if (gapIpDetailList != null && gapIpDetailList.Count > 0)
            {
                if (!string.IsNullOrWhiteSpace(ipMaster.SequenceNo))
                {
                    throw new BusinessException("排序单装箱单{0}的收货数和发货数不一致。", ipMaster.SequenceNo);
                }

                foreach (IpDetail gapIpDetail in gapIpDetailList)
                {
                    gapIpDetail.GapReceiptNo = receiptMaster.ReceiptNo;
                    this.genericMgr.Create(gapIpDetail);

                    foreach (IpLocationDetail gapIpLocationDetail in gapIpDetail.IpLocationDetails)
                    {
                        gapIpLocationDetail.IpDetailId = gapIpDetail.Id;
                        this.genericMgr.Create(gapIpLocationDetail);
                    }
                }

                #region 调整发货方库存
                if (ipMaster.ReceiveGapTo == CodeMaster.ReceiveGapTo.AdjectLocFromInv)
                {
                    foreach (IpDetail gapIpDetail in gapIpDetailList)
                    {
                        gapIpDetail.IpDetailInputs = null;

                        foreach (IpLocationDetail gapIpLocationDetail in gapIpDetail.IpLocationDetails)
                        {
                            IpDetailInput input = new IpDetailInput();
                            input.ReceiveQty = gapIpLocationDetail.Qty / gapIpDetail.UnitQty; //转为订单单位
                            if (ipMaster.IsReceiveScanHu)
                            {
                                input.HuId = gapIpLocationDetail.HuId;
                                input.LotNo = gapIpLocationDetail.LotNo;
                            }
                            gapIpDetail.AddIpDetailInput(input);
                        }
                    }

                    this.AdjustIpGap(gapIpDetailList, CodeMaster.IpGapAdjustOption.GI);
                }
                #endregion
            }
            #endregion

            #region 更新送货单状态
            ipMaster.Status = CodeMaster.IpStatus.InProcess;
            this.genericMgr.Update(ipMaster);
            #endregion

            #region 尝试关闭送货单
            this.ipMgr.TryCloseIp(ipMaster);
            #endregion

            return receiptMaster;
        }
コード例 #24
0
        public string ShipPerOrder(IList<string> pickedhus, string vehicleno, string picker)
        {
            IList<PickResult> results = new List<PickResult>();
            IDictionary<string, OrderDetail> odDict = new Dictionary<string, OrderDetail>();
            //IDictionary<string,PickTask> resultDict = new Dictionary<string,PickTask>();
            //IList<PickTask> pickTaskList = new List<PickTask>();
            IDictionary<string, PickTask> taskDict = new Dictionary<string, PickTask>();
            IDictionary<string, OrderMaster> ip = new Dictionary<string, OrderMaster>();
            foreach (string hu in pickedhus)
            {
                PickResult result = this.genericMgr.FindAll<PickResult>("from PickResult where PickedHu = ?",
                     hu).SingleOrDefault();
                if (result == null)
                {
                    throw new BusinessException("找不到拣货结果,条码:" + hu);
                }
                else
                {
                    results.Add(result);
                    if (!odDict.ContainsKey(result.PickId))
                    {
                        PickTask task = this.genericMgr.FindAll<PickTask>("from PickTask where PickId = ? ",
                            result.PickId).SingleOrDefault();
                        if (task == null)
                        {
                            throw new BusinessException("找不到拣货任务:" + result.PickId);
                        }
                        else
                        {
                            //记录pickid与task的映射关系
                            if (!taskDict.ContainsKey(result.PickId))
                            {
                                taskDict.Add(result.PickId, task);
                            }

                            //记录pickid与orderdetail的关系
                            OrderDetail od = this.genericMgr.FindAll<OrderDetail>("from OrderDetail where Id = ? ",
                                task.OrdDetId).SingleOrDefault();
                            if (od == null)
                            {
                                throw new BusinessException("找不到订单明细,ID:" + task.OrdDetId);
                            }
                            else
                            {
                                odDict.Add(result.PickId, od);
                            }
                        }
                    }

                    //添加占用明细
                    OrderDetailInput odi = new OrderDetailInput();
                    //将拣货条码记录到wmsipseq,后续收货需要使用
                    odi.WMSIpSeq = result.PickedHu;
                    odi.ShipQty = result.PickedQty;
                    odi.OccupyType = CodeMaster.OccupyType.Pick;
                    odi.OccupyReferenceNo = result.ResultId;
                    odi.ConsignmentParty = taskDict[result.PickId].Supplier;

                    odDict[result.PickId].AddOrderDetailInput(odi);
                }
            }//foreach hu

            IDictionary<string, OrderMaster> omDict = new Dictionary<string, OrderMaster>();
            foreach (KeyValuePair<string, OrderDetail> kv in odDict)
            {
                if (omDict.ContainsKey(kv.Value.OrderNo))
                {
                    omDict[kv.Value.OrderNo].AddOrderDetail(kv.Value);
                }
                else
                {
                    OrderMaster om = this.genericMgr.FindAll<OrderMaster>("from OrderMaster where Status in (1,2) and OrderNo = ? ", kv.Value.OrderNo).SingleOrDefault();
                    if (om == null)
                    {
                        throw new BusinessException("找不到订单:" + kv.Value.OrderNo);
                    }
                    else
                    {
                        om.AddOrderDetail(kv.Value);
                        omDict.Add(kv.Value.OrderNo, om);
                    }
                }
                #region 循环更新订单明细
                kv.Value.ShippedQty += kv.Value.ShipQtyInput;
                genericMgr.Update(kv.Value);
                #endregion
            } //foreach oddict

            string ipNos = string.Empty;
            foreach (KeyValuePair<string, OrderMaster> kv in omDict)
            {
                if (kv.Value.Status == com.Sconit.CodeMaster.OrderStatus.Submit
                    && kv.Value.Type != com.Sconit.CodeMaster.OrderType.Production
                    && kv.Value.Type != com.Sconit.CodeMaster.OrderType.SubContract)
                {
                    kv.Value.Status = com.Sconit.CodeMaster.OrderStatus.InProcess;
                    kv.Value.StartDate = DateTime.Now;
                    User user = SecurityContextHolder.Get();
                    kv.Value.StartUserId = user.Id;
                    kv.Value.StartUserName = user.FullName;
                    genericMgr.Update(kv.Value);
                }

                IpMaster ipm = ipMgr.TransferOrder2Ip(new OrderMaster[] { kv.Value });
                ipm.Vehicle = vehicleno;
                ipMgr.CreateIp(ipm);

                ipNos += ipm.IpNo + ",";
            }
            //发货成功后更新PickTask的ShippedQty
            foreach (KeyValuePair<string, OrderDetail> okv in odDict)
            {
                taskDict[okv.Key].ShippedQty += okv.Value.OrderDetailInputs.Sum(odi => odi.ShipQty);

                this.genericMgr.Update(taskDict[okv.Key]);
            }

            //更新pickresult的发货标记
            foreach (PickResult pr in results)
            {
                pr.IsShip = true;
                this.genericMgr.Update(pr);
            }
            return ipNos;
        }
コード例 #25
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        public void CreateInspectTransfer(Location location, IList<InspectDetail> inspectDetailList)
        {
            var orderMaster = new Entity.ORD.OrderMaster();
            var inspectNoList = (from inp in inspectDetailList select inp.InspectNo).Distinct().ToList();
            if (inspectNoList.Count() > 1)
            {
                throw new BusinessException("多个报验单待验明细不能合并移库。");
            }

            InspectMaster inspectMaster = genericMgr.FindById<InspectMaster>(inspectNoList[0]);

            var locationFrom = this.genericMgr.FindById<Entity.MD.Location>(inspectDetailList[0].LocationFrom);
            var partyFrom = this.genericMgr.FindById<Entity.MD.Party>(locationFrom.Region);
            var partyTo = this.genericMgr.FindById<Entity.MD.Party>(location.Region);

            orderMaster.LocationFrom = locationFrom.Code;
            orderMaster.IsShipScanHu = inspectMaster.Type == com.Sconit.CodeMaster.InspectType.Barcode;
            orderMaster.IsReceiveScanHu = inspectMaster.Type == com.Sconit.CodeMaster.InspectType.Barcode;
            orderMaster.LocationFromName = locationFrom.Name;
            orderMaster.LocationTo = location.Code;
            orderMaster.LocationToName = location.Name;
            orderMaster.PartyFrom = partyFrom.Code;
            orderMaster.PartyFromName = partyFrom.Name;
            orderMaster.PartyTo = partyTo.Code;
            orderMaster.PartyToName = partyTo.Name;
            orderMaster.Type = CodeMaster.OrderType.Transfer;
            orderMaster.StartTime = DateTime.Now;
            orderMaster.WindowTime = DateTime.Now;
            orderMaster.EffectiveDate = DateTime.Now;
            orderMaster.QualityType = com.Sconit.CodeMaster.QualityType.Inspect;

            orderMaster.IsQuick = true;
            orderMaster.OrderDetails = new List<OrderDetail>();
            int seq = 1;

            var groupInspectDetailList = from d in inspectDetailList group d by new { d.Item, d.CurrentLocation } into result select result;


            foreach (var inspectDetail in groupInspectDetailList)
            {
                var currentInspectDetailList = inspectDetailList.Where(p => p.Item == inspectDetail.Key.Item && p.CurrentLocation == inspectDetail.Key.CurrentLocation).ToList();

                var orderDetail = new OrderDetail();
                var orderDetailInputList = new List<OrderDetailInput>();
                Mapper.Map(currentInspectDetailList[0], orderDetail);
                orderDetail.OrderType = com.Sconit.CodeMaster.OrderType.Transfer;
                orderDetail.QualityType = com.Sconit.CodeMaster.QualityType.Inspect;
                orderDetail.LocationFrom = inspectDetail.Key.CurrentLocation;
                orderDetail.LocationFromName = genericMgr.FindById<Location>(inspectDetail.Key.CurrentLocation).Name;
                orderDetail.LocationTo = location.Code;
                orderDetail.LocationToName = location.Name;
                orderDetail.Sequence = seq++;

                foreach (InspectDetail insp in currentInspectDetailList)
                {
                    var orderDetailInput = new OrderDetailInput();
                    if (inspectMaster.Type == com.Sconit.CodeMaster.InspectType.Barcode)
                    {
                        orderDetailInput.HuId = insp.HuId;
                        orderDetailInput.LotNo = insp.LotNo;
                    }

                    orderDetailInput.QualityType = com.Sconit.CodeMaster.QualityType.Inspect;
                    orderDetailInput.OccupyType = com.Sconit.CodeMaster.OccupyType.Inspect;
                    orderDetailInput.OccupyReferenceNo = inspectMaster.InspectNo;
                    orderDetailInput.ReceiveQty = insp.CurrentTransferQty;

                    orderDetail.RequiredQty += insp.CurrentTransferQty;
                    orderDetail.OrderedQty += insp.CurrentTransferQty;
                    orderDetailInputList.Add(orderDetailInput);

                }
                orderDetail.OrderDetailInputs = orderDetailInputList;
                orderMaster.OrderDetails.Add(orderDetail);
            }


            CreateOrder(orderMaster);

            #region 更新检验明细
            foreach (InspectDetail insp in inspectDetailList)
            {
                insp.CurrentLocation = location.Code;
                genericMgr.Update(insp);
            }
            #endregion
        }
コード例 #26
0
        public ActionResult ShipOrder(string idStr, string qtyStr)
        {
            try
            {
                if (!string.IsNullOrEmpty(idStr))
                {
                    IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                    string[] idArray = idStr.Split(',');
                    string[] qtyArray = qtyStr.Split(',');
                    for (int i = 0; i < qtyArray.Count(); i++)
                    {
                        if (Convert.ToDecimal(qtyArray[i]) > 0)
                        {
                            OrderDetail od = base.genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));

                            OrderDetailInput input = new OrderDetailInput();
                            input.ShipQty = Convert.ToDecimal(qtyArray[i]);
                            od.AddOrderDetailInput(input);
                            orderDetailList.Add(od);
                        }
                    }
                    IpMaster ipMaster = orderMgr.ShipOrder(orderDetailList);

                    if (ipMaster != null)
                    {
                        SaveSuccessMessage(string.Format("发货成功,生成送货单号{0}。", ipMaster.IpNo));
                        return new RedirectToRouteResult(new RouteValueDictionary  
                                                               { 
                                                                   { "action", "_Edit" }, 
                                                                   { "controller", "SupplierIpMaster" },
                                                                   { "IpNo", ipMaster.IpNo },
                                                                   { "UrlId", "SupplierShipOrder" },
                                                                   { "OrderNo",orderDetailList.First().OrderNo}
                                                               });
                    }
                }
                else
                {
                    throw new BusinessException("发货明细不能为空。");
                }

            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            return Content("");
        }
コード例 #27
0
ファイル: OrderMgrImpl.cs プロジェクト: druidwang/Les_parts
        public ReceiptMaster ReceiveVanOrder(string orderNo)
        {
            OrderMaster orderMaster = this.genericMgr.FindById<OrderMaster>(orderNo);

            ProductLineMap productLineMap = null;
            IList<ProductLineMap> productLineMapList = genericMgr.FindAll<ProductLineMap>(@"from ProductLineMap as p 
                                                                                                  where (p.ProductLine = ? or p.CabFlow = ? or p.ChassisFlow = ?) 
                                                                                                  and p.ProductLine is not null 
                                                                                                  and p.CabFlow is not null 
                                                                                                  and p.ChassisFlow is not null", new object[] { orderMaster.Flow, orderMaster.Flow, orderMaster.Flow });

            if (productLineMapList != null && productLineMapList.Count > 0)
            {
                if (productLineMapList.Count > 1)
                {
                    throw new BusinessException("生产线{0}找到多条整车生产线映射。", orderMaster.Flow);
                }
                else
                {
                    productLineMap = productLineMapList.Single();
                }
            }
            else
            {
                throw new TechnicalException("收货的不是整车生产单。");
            }

            BusinessException businessException = VerifyVanOrderClose(orderMaster, productLineMap);

            #region 未扣减的工位扣减物料,只扣减自动投料至生产单的物料,不扣减收货回冲的物料
            IList<OrderBomDetail> orderBomDetailList = this.queryMgr.FindAllWithNativeSql<OrderBomDetail>(
                  NativeSqlStatement.SELECT_NOT_BACKFLUSH_ORDER_BOM_DETAIL_STATEMENT, new object[] { orderNo, false, CodeMaster.FeedMethod.ProductionOrder, true });

            BatchFeed(orderBomDetailList);

            if (orderBomDetailList.Count > 0)
            {
                if (orderMaster.CurrentOperation < orderBomDetailList.Max(det => det.Operation))
                {
                    orderMaster.CurrentOperation = orderBomDetailList.Max(det => det.Operation);
                    this.genericMgr.Update(orderMaster);
                }
            }
            #endregion

            IList<OrderDetail> orderDetailList = this.genericMgr.FindAll<OrderDetail>("from OrderDetail where OrderNo = ?", orderNo);
            foreach (OrderDetail orderDetail in orderDetailList)
            {
                OrderDetailInput orderDetailInput = new OrderDetailInput();
                orderDetailInput.ReceiveQty = 1;
                orderDetail.AddOrderDetailInput(orderDetailInput);
            }

            ReceiptMaster receiptMaster = ReceiveOrder(orderDetailList, false, productLineMap, DateTime.Now, null);

            return receiptMaster;
        }
コード例 #28
0
        public ActionResult ReceiveOrder(int[] id, decimal[] currentReceiveQty)
        {
            IList<OrderDetail> orderDetailList = new List<OrderDetail>();
            for (int i = 0; i < currentReceiveQty.Count(); i++)
            {
                if (currentReceiveQty[i] > 0)
                {
                    OrderDetail od = base.genericMgr.FindById<OrderDetail>(id[i]);

                    OrderDetailInput input = new OrderDetailInput();
                    input.ReceiveQty = currentReceiveQty[i];
                    od.AddOrderDetailInput(input);
                    orderDetailList.Add(od);
                }
            }

            if (orderDetailList.Count() == 0)
            {
                return HttpNotFound();
            }
            else
            {
                try
                {
                    orderMgr.ReceiveOrder(orderDetailList);
                    SaveSuccessMessage(Resources.ORD.OrderMaster.OrderMaster_Received);
                    return RedirectToAction("ReceiveIndex");
                }
                catch (BusinessException ex)
                {
                    SaveBusinessExceptionMessage(ex);
                    return View();
                }
            }
        }
コード例 #29
0
        public JsonResult ShipOrder(string idStr, string qtyStr)
        {
            try
            {
                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                if (!string.IsNullOrEmpty(idStr))
                {
                    string[] idArray = idStr.Split(',');
                    string[] qtyArray = qtyStr.Split(',');

                    for (int i = 0; i < qtyArray.Count(); i++)
                    {
                        if (Convert.ToDecimal(qtyArray[i]) > 0)
                        {
                            OrderDetail od = genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));

                            OrderDetailInput input = new OrderDetailInput();
                            input.ShipQty = Convert.ToDecimal(qtyArray[i]);
                            od.AddOrderDetailInput(input);
                            orderDetailList.Add(od);
                        }
                    }
                }
                if (orderDetailList.Count() == 0)
                {
                    throw new BusinessException(Resources.EXT.ControllerLan.Con_ShippingDetailCanNotBeEmpty);
                }

                IpMaster ipMaster = orderMgr.ShipOrder(orderDetailList);
                SaveSuccessMessage(Resources.EXT.ControllerLan.Con_ShipSuccessfully);
                object obj = new { SuccessMessage = string.Format(Resources.ORD.OrderMaster.ScheduleLine_Shipped), IpNo = ipMaster.IpNo };
                return Json(obj);
            }
            catch (BusinessException ex)
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode = 500;
                Response.Write(ex.GetMessages()[0].GetMessageString());
                return Json(null);
            }
        }
コード例 #30
0
        public JsonResult ShipOrder(string idStr, string qtyStr)
        {
            try
            {
                IList<OrderDetail> orderDetailList = new List<OrderDetail>();
                if (!string.IsNullOrEmpty(idStr))
                {
                    string[] idArray = idStr.Split(',');
                    string[] qtyArray = qtyStr.Split(',');

                    for (int i = 0; i < qtyArray.Count(); i++)
                    {
                        if (Convert.ToDecimal(qtyArray[i]) > 0)
                        {
                            OrderDetail od = base.genericMgr.FindById<OrderDetail>(Convert.ToInt32(idArray[i]));

                            OrderDetailInput input = new OrderDetailInput();
                            input.ShipQty = Convert.ToDecimal(qtyArray[i]);
                            od.AddOrderDetailInput(input);
                            orderDetailList.Add(od);
                        }
                    }
                }
                if (orderDetailList.Count() == 0)
                {
                    throw new BusinessException("发货明细不能为空");
                }

                IpMaster ipMaster = orderMgr.ShipOrder(orderDetailList);
                SaveSuccessMessage(Resources.ORD.OrderMaster.ScheduleLine_Shipped);
                return Json(new { IpNo = ipMaster.IpNo });
            }
            catch (BusinessException ex)
            {
                SaveBusinessExceptionMessage(ex);
            }
            catch (Exception ex)
            {
                SaveErrorMessage(ex);
            }
            return Json(null);
        }