public ActionResult ProductLineMapSeachAdd(ProductLineMap search)
        {
            if (ModelState.IsValid)
            {
                //判断描述不能重复
                try
                {
                    if (this.genericMgr.FindAll<long>(CodeDuiplicateVerifyStatement, new object[] { search.SAPProductLine })[0] > 0)
                    {
                        base.SaveErrorMessage(Resources.CUST.ProductLineMap.ProductLineMap_Added_Existing_Code, search.SAPProductLine);
                    }
                    else
                    {
                        genericMgr.CreateWithTrim(search);
                        SaveSuccessMessage(Resources.CUST.ProductLineMap.ProductLineMap_Added);
                        return RedirectToAction("Edit", new { SAPProductLine = search.SAPProductLine });
                    }
                }
                catch (System.Exception ex)
                {
                  SaveErrorMessage(ex.Message);
                }
            }
            return View(search);

        }
Exemplo n.º 2
0
        private BusinessException VerifyVanOrderClose(OrderMaster orderMaster, ProductLineMap productLineMap)
        {
            BusinessException businessException = new BusinessException();
            #region 生产单关闭校验
            #region 条件5生产单的PlanBackflush全部关闭
            if (orderMaster.Type == CodeMaster.OrderType.Production
                || orderMaster.Type == CodeMaster.OrderType.SubContract)
            {

                #region 总装生产要校验总装、驾驶室和底盘的PlanBackflush
                string hql = "select count(*) as counter from PlanBackflush where OrderNo in (?, ?, ?) and IsClose = ?";
                long counter = this.genericMgr.FindAll<long>(hql, new Object[] { productLineMap.ProductLine, productLineMap.CabFlow, productLineMap.ChassisFlow, false })[0];
                if (counter > 0)
                {
                    businessException.AddMessage("加权平均扣料的零件还没有进行回冲,不能关闭订单{0}。", orderMaster.OrderNo);
                }
                #endregion
            }
            #endregion

            #region 条件6生产线上没有订单的投料
            if (orderMaster.Type == CodeMaster.OrderType.Production
                || orderMaster.Type == CodeMaster.OrderType.SubContract)
            {
                #region 总装生产要校验总装、驾驶室和底盘的订单投料
                string hql = "select count(*) as counter from ProductLineLocationDetail where OrderNo in (?, ?, ?) and IsClose = ?";
                long counter = this.genericMgr.FindAll<long>(hql, new Object[] { productLineMap.ProductLine, productLineMap.CabFlow, productLineMap.ChassisFlow, false })[0];
                if (counter > 0)
                {
                    businessException.AddMessage("生产线上还有投料的零件没有回冲,不能关闭订单{0}。", orderMaster.OrderNo);
                }
                #endregion
            }
            #endregion

            #region 条件7和TraceCode所有的失效模式关闭
            if ((orderMaster.Type == CodeMaster.OrderType.Production
               || orderMaster.Type == CodeMaster.OrderType.SubContract)
               && !string.IsNullOrWhiteSpace(orderMaster.TraceCode))
            {
                #region 只有总装的生产单关闭才需要校验,驾驶室和底盘的不需要
                string hql = "select count(*) as counter from IssueMaster where BackYards = ? and Status in (?,?,?)";
                long issueCounter = this.genericMgr.FindAll<long>(hql, new Object[] { orderMaster.TraceCode, CodeMaster.IssueStatus.Create, CodeMaster.IssueStatus.Submit, CodeMaster.IssueStatus.InProcess })[0];
                if (issueCounter > 0)
                {
                    businessException.AddMessage("失效模式没有全部关闭,不能关闭订单{0}。", orderMaster.OrderNo);
                }
                #endregion
            }
            #endregion

            #region 条件8生产单上的所有关键件全部投料,考虑到搭错的关键件Bom,不需要校验这条,可以给出警告信息
            if ((orderMaster.Type == CodeMaster.OrderType.Production
               || orderMaster.Type == CodeMaster.OrderType.SubContract))
            {
                //throw new NotImplementedException();
            }
            #endregion
            #endregion

            return businessException;
        }
Exemplo n.º 3
0
        private void CloseVanOrder(OrderMaster vanOrder, ProductLineMap productLineMap)
        {
            DateTime dateTimeNow = DateTime.Now;
            User user = SecurityContextHolder.Get();

            #region 总装生产单关闭时,关闭所有子生产单
            IList<OrderMaster> subOrderMasterList = this.genericMgr.FindAll<OrderMaster>("from OrderMaster where Type = ? and Flow in (?,?) and Status <> ?", new object[] { CodeMaster.OrderType.Production, productLineMap.CabFlow, productLineMap.ChassisFlow, CodeMaster.OrderStatus.Close });

            if (subOrderMasterList != null && subOrderMasterList.Count > 0)
            {
                foreach (OrderMaster subOrderMaster in subOrderMasterList)
                {
                    if (subOrderMaster.Status != CodeMaster.OrderStatus.Complete)
                    {
                        throw new BusinessException("子生产单{0}的状态为{1},整车生产单{2}不能关闭。", subOrderMaster.OrderNo,
                            systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)subOrderMaster.Status).ToString()),
                            vanOrder.OrderNo);
                    }
                    else
                    {
                        subOrderMaster.Status = CodeMaster.OrderStatus.Close;
                        subOrderMaster.CloseDate = dateTimeNow;
                        subOrderMaster.CloseUserId = user.Id;
                        subOrderMaster.CloseUserName = user.FullName;
                        this.genericMgr.Update(subOrderMaster);
                    }
                }
            }
            #endregion

            #region 关闭总装生产单
            vanOrder.Status = CodeMaster.OrderStatus.Close;
            vanOrder.CloseDate = dateTimeNow;
            vanOrder.CloseUserId = user.Id;
            vanOrder.CloseUserName = user.FullName;
            this.genericMgr.Update(vanOrder);
            #endregion
        }
Exemplo n.º 4
0
        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
            }
        }
Exemplo n.º 5
0
        private ReceiptMaster ReceiveOrder(IList<OrderDetail> orderDetailList, bool isCheckKitTraceItem, ProductLineMap productLineMap, DateTime effectiveDate, string ipNo)
        {
            #region 判断是否全0收货
            if (orderDetailList == null || orderDetailList.Count == 0)
            {
                throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveDetailIsEmpty);
            }

            IList<OrderDetail> nonZeroOrderDetailList = orderDetailList.Where(o => o.ReceiveQtyInput != 0 || o.ScrapQtyInput != 0).ToList();

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

            #region 查询订单头对象
            IList<OrderMaster> orderMasterList = LoadOrderMasters(nonZeroOrderDetailList.Select(p => p.OrderNo).Distinct(), true);
            #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 计划协议不能按收货校验
            if (orderType == CodeMaster.OrderType.ScheduleLine)
            {
                throw new BusinessException("计划协议不能按订单收货。");
            }
            #endregion

            #region 排序单不能按订单收货校验
            if (orderMasterList.Where(o => o.OrderStrategy == CodeMaster.FlowStrategy.SEQ).Count() > 0)
            {
                throw new BusinessException("排序单不能按订单收货。");
            }
            #endregion

            #region 循环订单头检查
            foreach (OrderMaster orderMaster in orderMasterList)
            {
                //if (!Utility.SecurityHelper.HasPermission(orderMaster))
                //{
                //    throw new BusinessException("没有此订单{0}的操作权限。", orderMaster.OrderNo);
                //}

                orderMaster.OrderDetails = nonZeroOrderDetailList.Where(det => det.OrderNo == orderMaster.OrderNo).ToList();

                //如果非生产,把Submit状态改为InProcess
                if (orderMaster.Status == com.Sconit.CodeMaster.OrderStatus.Submit
                    && orderMaster.Type != com.Sconit.CodeMaster.OrderType.Production
                    && orderMaster.Type != com.Sconit.CodeMaster.OrderType.SubContract)
                {
                    UpdateOrderMasterStatus2InProcess(orderMaster);
                }

                //判断OrderHead状态
                if (orderMaster.Status != com.Sconit.CodeMaster.OrderStatus.InProcess)
                {
                    throw new BusinessException(Resources.ORD.OrderMaster.Errors_StatusErrorWhenReceive,
                            orderMaster.OrderNo, systemMgr.GetCodeDetailDescription(com.Sconit.CodeMaster.CodeMaster.OrderStatus, ((int)orderMaster.Status).ToString()));
                }

                #region 订单、生产线暂停检查
                if (orderMaster.IsPause)
                {
                    if (orderMaster.Type == CodeMaster.OrderType.Production)
                    {
                        throw new BusinessException("生产单{0}已经暂停,不能收货。", orderMaster.OrderNo);
                    }
                    else if (orderMaster.OrderStrategy == CodeMaster.FlowStrategy.KIT)
                    {
                        throw new BusinessException("KIT单{0}已经暂停,不能收货。", orderMaster.OrderNo);
                    }
                    else if (orderMaster.OrderStrategy == CodeMaster.FlowStrategy.SEQ)
                    {
                        throw new BusinessException("排序单{0}已经暂停,不能收货。", orderMaster.OrderNo);
                    }
                    else
                    {
                        throw new BusinessException("订单{0}已经暂停,不能收货。", orderMaster.OrderNo);
                    }
                }

                //if ((orderMaster.Type == CodeMaster.OrderType.Production
                //    || orderMaster.Type == CodeMaster.OrderType.SubContract
                //    //生产线暂停可以收货
                //    //|| orderMaster.OrderStrategy == CodeMaster.FlowStrategy.KIT
                //    //|| orderMaster.OrderStrategy == CodeMaster.FlowStrategy.SEQ
                //    )
                //    && !string.IsNullOrWhiteSpace(orderMaster.Flow))
                //{
                //    FlowMaster flowMaster = this.genericMgr.FindById<FlowMaster>(orderMaster.Flow);
                //    if (flowMaster.IsPause)
                //    {
                //        throw new BusinessException("生产线{0}已经暂停,不能收货。", orderMaster.Flow);
                //    }
                //}
                #endregion

                #region 整包装收货判断,快速的不要判断
                if (orderMaster.IsReceiveFulfillUC
                    && orderMaster.SubType == com.Sconit.CodeMaster.OrderSubType.Normal
                    && !(orderMaster.IsAutoRelease && orderMaster.IsAutoStart))
                {
                    foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
                    {
                        //不合格品不作为收货数
                        //if (orderDetail.ReceiveQualifiedQtyInput % orderDetail.UnitCount != 0)
                        if (orderDetail.ReceiveQtyInput % orderDetail.UnitCount != 0)
                        {
                            //不是整包装
                            throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveQtyNotFulfillUnitCount, orderDetail.Item);
                        }
                    }
                }
                #endregion

                #region 是否过量发货判断,未发货即收货也要判断是否过量发货
                foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
                {
                    if (!orderMaster.IsOpenOrder
                        && orderMaster.Type != com.Sconit.CodeMaster.OrderType.Production   //生产和委外不需要判断
                        && orderMaster.Type != com.Sconit.CodeMaster.OrderType.SubContract)
                    {
                        if (Math.Abs(orderDetail.ShippedQty) > Math.Abs(orderDetail.OrderedQty))
                        {
                            //订单的发货数已经大于等于订单数
                            throw new BusinessException(Resources.ORD.OrderMaster.Errors_ShipQtyExcceedOrderQty, orderDetail.OrderNo, orderDetail.Item);
                        }
                        else if (!orderMaster.IsShipExceed
                            && Math.Abs(orderDetail.ShippedQty + orderDetail.ReceiveQtyInput) > Math.Abs(orderDetail.OrderedQty))   //不允许过量收货
                        {
                            //订单的发货数 + 本次发货数大于订单数
                            throw new BusinessException(Resources.ORD.OrderMaster.Errors_ShipQtyExcceedOrderQty, orderDetail.OrderNo, orderDetail.Item);
                        }
                    }
                }
                #endregion

                #region 是否过量收货判断
                foreach (OrderDetail orderDetail in orderMaster.OrderDetails)
                {
                    if (!orderMaster.IsOpenOrder)
                    {
                        var orderDeviationQty = decimal.MaxValue;
                        if (!orderMaster.IsReceiveExceed)
                        {
                            orderDeviationQty = Math.Abs(orderDetail.OrderedQty);
                        }
                        else
                        {
                            if (orderMaster.CurrentFlowMaster.OrderDeviation > 0)
                            {
                                orderDeviationQty = Math.Abs(orderDetail.OrderedQty * (((decimal)orderMaster.CurrentFlowMaster.OrderDeviation / 100) + 1));
                            }
                        }
                        //订单的收货数已经大于等于订单数
                        if (Math.Abs(orderDetail.ReceivedQty) >= Math.Abs(orderDetail.OrderedQty))
                        {
                            throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveQtyExcceedOrderQty, orderDetail.OrderNo, orderDetail.Item);
                        }
                        else if (Math.Abs(orderDetail.ReceivedQty + orderDetail.RejectedQty + orderDetail.ScrapQty + orderDetail.ReceiveQtyInput + orderDetail.ScrapQtyInput) > orderDeviationQty)   //不允许过量收货
                        {
                            //订单的收货数 + 本次收货数大于订单数
                            throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveQtyExcceedOrderQty, orderDetail.OrderNo, orderDetail.Item);
                        }
                    }
                }
                #endregion

                #region KIT单收货判断
                if (orderMaster.OrderStrategy == CodeMaster.FlowStrategy.KIT)
                {
                    CheckKitOrderDetail(orderMaster, isCheckKitTraceItem, false);
                }
                #endregion
            }
            #endregion

            #region 校验发货先进先出
            CheckShipFiFo(orderMasterList);
            #endregion

            #region 循环更新订单明细
            foreach (OrderDetail orderDetail in nonZeroOrderDetailList)
            {
                //未发货直接收货需要累加已发货数量
                if (orderDetail.OrderType != com.Sconit.CodeMaster.OrderType.Production
                    && orderDetail.OrderType != com.Sconit.CodeMaster.OrderType.SubContract)
                {
                    orderDetail.ShippedQty += orderDetail.ReceiveQtyInput;
                }

                if (orderDetail.OrderType != com.Sconit.CodeMaster.OrderType.Production
                    && orderDetail.OrderType != com.Sconit.CodeMaster.OrderType.SubContract)
                {
                    //orderDetail.ReceivedQty += orderDetail.ReceiveQualifiedQtyInput;
                    orderDetail.ReceivedQty += orderDetail.ReceiveQtyInput;
                }
                else
                {
                    //生产收货更新合格数和不合格数量
                    //orderDetail.ReceivedQty += orderDetail.ReceiveQualifiedQtyInput;
                    orderDetail.ReceivedQty += orderDetail.ReceiveQtyInput;
                    orderDetail.ScrapQty += orderDetail.ScrapQtyInput;
                }
                genericMgr.Update(orderDetail);
            }
            #endregion

            #region 发货
            #region OrderDetailInput赋发货数量
            foreach (OrderDetail orderDetail in nonZeroOrderDetailList)
            {
                foreach (OrderDetailInput orderDetailInput in orderDetail.OrderDetailInputs)
                {
                    orderDetailInput.ShipQty = orderDetailInput.ReceiveQty;
                }
            }
            #endregion

            IpMaster ipMaster = null;
            var subType = orderMasterList.First().SubType;
            if ((orderType == com.Sconit.CodeMaster.OrderType.Production || orderType == com.Sconit.CodeMaster.OrderType.SubContract)
                && subType != CodeMaster.OrderSubType.Return)
            {
                //生产和委外的非退货单 
            }
            else
            {
                //物流单 生产和委外的退货单也要创建Ip
                ipMaster = this.ipMgr.TransferOrder2Ip(orderMasterList);
                #region 循环发货
                foreach (IpDetail ipDetail in ipMaster.IpDetails)
                {
                    ipDetail.CurrentPartyFrom = ipMaster.PartyFrom;  //为了记录库存事务
                    ipDetail.CurrentPartyFromName = ipMaster.PartyFromName;  //为了记录库存事务
                    ipDetail.CurrentPartyTo = ipMaster.PartyTo;      //为了记录库存事务
                    ipDetail.CurrentPartyToName = ipMaster.PartyToName;      //为了记录库存事务
                    //ipDetail.CurrentOccupyType = com.Sconit.CodeMaster.OccupyType.None; //todo-默认出库未占用库存,除非捡货或检验的出库

                    IList<InventoryTransaction> inventoryTransactionList = this.locationDetailMgr.InventoryOut(ipDetail, effectiveDate);

                    #region 建立发货库明细和IpDetailInput的关系
                    if (inventoryTransactionList != null && inventoryTransactionList.Count > 0)
                    {
                        ipDetail.IpLocationDetails = (from trans in inventoryTransactionList
                                                      group trans by new
                                                      {
                                                          HuId = trans.HuId,
                                                          LotNo = trans.LotNo,
                                                          IsCreatePlanBill = trans.IsCreatePlanBill,
                                                          IsConsignment = trans.IsConsignment,
                                                          PlanBill = trans.PlanBill,
                                                          ActingBill = trans.ActingBill,
                                                          QualityType = trans.QualityType,
                                                          IsFreeze = trans.IsFreeze,
                                                          IsATP = trans.IsATP,
                                                          OccupyType = trans.OccupyType,
                                                          OccupyReferenceNo = trans.OccupyReferenceNo
                                                      } into g
                                                      select new IpLocationDetail
                                                      {
                                                          HuId = g.Key.HuId,
                                                          LotNo = g.Key.LotNo,
                                                          IsCreatePlanBill = g.Key.IsCreatePlanBill,
                                                          IsConsignment = g.Key.IsConsignment,
                                                          PlanBill = g.Key.PlanBill,
                                                          ActingBill = g.Key.ActingBill,
                                                          QualityType = g.Key.QualityType,
                                                          IsFreeze = g.Key.IsFreeze,
                                                          IsATP = g.Key.IsATP,
                                                          OccupyType = g.Key.OccupyType,
                                                          OccupyReferenceNo = g.Key.OccupyReferenceNo,
                                                          Qty = g.Sum(t => -t.Qty),                      //发货的库存事务为负数,转为收货数应该取负数
                                                          //PlanBillQty = g.Sum(t=>-t.PlanBillQty),
                                                          //ActingBillQty = g.Sum(t=>-t.ActingBillQty)
                                                      }).ToList();
                    }
                    #endregion
                }
                #endregion

                #region 生成收货的IpInput
                foreach (OrderDetail orderDetail in nonZeroOrderDetailList)
                {
                    OrderMaster orderMaster = orderMasterList.Where(o => o.OrderNo == orderDetail.OrderNo).Single();
                    //订单收货一定是一条订单明细对应一条发货单明细
                    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;
                        if (orderMaster.IsReceiveScanHu || orderMaster.OrderStrategy == CodeMaster.FlowStrategy.KIT)
                        {
                            ipDetailInput.HuId = orderDetailInput.HuId;
                            ipDetailInput.LotNo = orderDetailInput.LotNo;
                        }

                        ipDetail.AddIpDetailInput(ipDetailInput);
                    }
                }

                if (orderMasterList.Where(o => o.OrderStrategy == CodeMaster.FlowStrategy.KIT).Count() > 0)
                {
                    #region Kit单生成收货Input
                    foreach (IpDetail ipDetail in ipMaster.IpDetails)
                    {
                        foreach (IpDetailInput ipDetailInput in ipDetail.IpDetailInputs)
                        {
                            if (!string.IsNullOrEmpty(ipDetailInput.HuId))
                            {
                                #region 按条码匹配
                                IpLocationDetail matchedIpLocationDetail = ipDetail.IpLocationDetails.Where(locDet => locDet.HuId == ipDetailInput.HuId).SingleOrDefault();
                                matchedIpLocationDetail.ReceivedQty = matchedIpLocationDetail.Qty;
                                if (matchedIpLocationDetail != null)
                                {
                                    ipDetailInput.AddReceivedIpLocationDetail(matchedIpLocationDetail);
                                }
                                #endregion
                            }
                            else
                            {
                                #region 按数量匹配
                                IpDetail gapIpDetail = new IpDetail();
                                MatchIpDetailInput(ipDetail, ipDetailInput, ipDetail.IpLocationDetails, ref gapIpDetail);
                                #endregion
                            }
                        }
                    }
                    #endregion
                }
                else
                {
                    #region 其它订单生成收货Input
                    if (ipMaster.IsShipScanHu && ipMaster.IsReceiveScanHu)
                    {
                        #region 按条码匹配
                        foreach (IpDetail ipDetail in ipMaster.IpDetails)
                        {
                            foreach (IpDetailInput ipDetailInput in ipDetail.IpDetailInputs)
                            {
                                IpLocationDetail matchedIpLocationDetail = ipDetail.IpLocationDetails.Where(locDet => locDet.HuId == ipDetailInput.HuId).SingleOrDefault();
                                matchedIpLocationDetail.ReceivedQty = matchedIpLocationDetail.Qty;
                                if (matchedIpLocationDetail != null)
                                {
                                    ipDetailInput.AddReceivedIpLocationDetail(matchedIpLocationDetail);
                                }
                            }
                        }
                        #endregion
                    }
                    else
                    {
                        #region 按数量匹配
                        foreach (IpDetail ipDetail in ipMaster.IpDetails)
                        {
                            CycleMatchIpDetailInput(ipDetail, ipDetail.IpDetailInputs, ipDetail.IpLocationDetails);
                        }
                        #endregion
                    }
                    #endregion
                }
                #endregion
            }
            #endregion

            #region 收货 生产和委外退货的逻辑在CreateReceipt中实现
            ReceiptMaster receiptMaster = null;
            if (subType != CodeMaster.OrderSubType.Return &&
               (orderType == com.Sconit.CodeMaster.OrderType.Production || orderType == com.Sconit.CodeMaster.OrderType.SubContract))
            {
                #region 生产和委外正常收货 消耗原材料,收成品
                if (orderMasterList.Count > 1 && orderType == com.Sconit.CodeMaster.OrderType.Production)
                {
                    throw new TechnicalException("生产单不能合并收货。");
                }

                foreach (OrderMaster orderMaster in orderMasterList)
                {
                    orderMaster.IpNo = ipNo;
                    receiptMaster = this.receiptMgr.TransferOrder2Receipt(orderMaster);
                    this.receiptMgr.CreateReceipt(receiptMaster);

                    #region 回冲物料
                    if (productLineMap != null)
                    {
                        #region 整车
                        BackflushVan(productLineMap, nonZeroOrderDetailList, receiptMaster, orderMaster);
                        #endregion
                    }
                    else
                    {
                        #region 非整车
                        foreach (OrderDetail orderDetail in nonZeroOrderDetailList)
                        {
                            //OrderDetailInput orderDetailInput = orderDetail.OrderDetailInputs[0];
                            foreach (var orderDetailInput in orderDetail.OrderDetailInputs)
                            {
                                orderDetailInput.ReceiptDetails = receiptMaster.ReceiptDetails.Where(r => r.OrderDetailId == orderDetail.Id).ToList();
                            }
                        }
                        this.productionLineMgr.BackflushProductOrder(nonZeroOrderDetailList, orderMaster, DateTime.Now);
                        #endregion
                    }
                    #endregion
                }
                #endregion
            }
            else
            {
                #region 物流收货
                receiptMaster = this.receiptMgr.TransferIp2Receipt(ipMaster);
                if (orderMasterList.Where(o => o.OrderStrategy == CodeMaster.FlowStrategy.KIT).Count() > 0)
                {
                    //kit收货特殊处理
                    this.receiptMgr.CreateReceipt(receiptMaster, true, effectiveDate);
                }
                else
                {
                    this.receiptMgr.CreateReceipt(receiptMaster, false, effectiveDate);
                }
                #endregion
            }
            #endregion

            #region 尝试关闭订单
            foreach (OrderMaster orderMaster in orderMasterList)
            {
                if (orderMaster.Type == CodeMaster.OrderType.Production)
                {
                    #region 生产
                    if (productLineMap != null && productLineMap.ProductLine == orderMaster.Flow)
                    {
                        #region 总装生产单
                        CloseVanOrder(orderMaster, productLineMap);
                        #endregion
                    }
                    else if (productLineMap != null && (productLineMap.CabFlow == orderMaster.Flow || productLineMap.ChassisFlow == orderMaster.Flow))
                    {
                        #region  驾驶室和底盘
                        //驾驶室和底盘下线完工订单,总装下线后一起关闭
                        CompleteVanSubOrder(orderMaster);
                        #endregion
                    }
                    else
                    {
                        #region  非整车
                        TryCloseOrder(orderMaster);
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    #region 物流
                    TryCloseOrder(orderMaster);
                    #endregion
                }
            }
            #endregion

            return receiptMaster;
        }
 public ActionResult SaveEdit(GridCommand command, ProductLineMap search)
 {
     if (ModelState.IsValid)
     {
         try
         {
             genericMgr.UpdateWithTrim(search);
             SaveSuccessMessage(Resources.CUST.ProductLineMap.ProductLineMap_Added);
             return RedirectToAction("Edit", new { SAPProductLine = search.SAPProductLine });
         }
         catch (System.Exception ex)
         {
             
            SaveErrorMessage(ex.Message);
         }
     }
     return View(search);
 }
Exemplo n.º 7
0
        private BusinessException VerifyVanOrderClose(OrderMaster orderMaster, ProductLineMap productLineMap)
        {
            BusinessException businessException = new BusinessException();
            #region 生产单关闭校验
            #region 条件7和TraceCode所有的失效模式关闭
            if ((orderMaster.Type == CodeMaster.OrderType.Production
               || orderMaster.Type == CodeMaster.OrderType.SubContract)
               && !string.IsNullOrWhiteSpace(orderMaster.TraceCode))
            {
                #region 只有总装的生产单关闭才需要校验,驾驶室和底盘的不需要
                string hql = "select count(*) as counter from IssueMaster where BackYards = ? and Status in (?,?,?)";
                long issueCounter = this.genericMgr.FindAll<long>(hql, new Object[] { orderMaster.TraceCode, CodeMaster.IssueStatus.Create, CodeMaster.IssueStatus.Submit, CodeMaster.IssueStatus.InProcess })[0];
                if (issueCounter > 0)
                {
                    businessException.AddMessage("失效模式没有全部关闭,不能关闭订单{0}。", orderMaster.OrderNo);
                }
                #endregion
            }
            #endregion

            #region 条件8生产单上的所有关键件全部投料,考虑到搭错的关键件Bom,不需要校验这条,可以给出警告信息
            if ((orderMaster.Type == CodeMaster.OrderType.Production
               || orderMaster.Type == CodeMaster.OrderType.SubContract))
            {
                //throw new NotImplementedException();
            }
            #endregion
            #endregion

            return businessException;
        }