示例#1
0
 public static bool ChangePlanQTY(string planCode, int num, string userID)
 {
     DB.GetInstance().BeginTransaction();
     try
     {
         PlanEntity               entPlan      = PlanFactory.GetByKey(planCode);
         List <PlanBomEntity>     allBOMs      = PlanBOMFactory.GetByPlanCode(planCode);
         List <PlanProcessEntity> allProcesses = PlanProcessFactory.GetByPlan(planCode);
         //更改所有BOM的数量信息
         foreach (var b in allBOMs)
         {
             b.ITEM_QTY = (b.ITEM_QTY / entPlan.PLAN_QTY) * num;
             DB.GetInstance().Update(b);
         }
         //更改所有工序的数量信息和标准工序的处理数量信息
         foreach (var p in allProcesses)
         {
             PlanProcessMainEntity mainProcess = PlanProcessMainFactory.GetByOrderCodeAndProcessCode(p.ORDER_CODE, p.PROCESS_CODE);
             mainProcess.HANDLED_QTY = mainProcess.HANDLED_QTY - entPlan.PLAN_QTY + num;
             if (mainProcess.HANDLED_QTY >= int.Parse(mainProcess.PLAN_QTY))
             {
                 mainProcess.HANDLED_FLAG = "F";
             }
             else if (mainProcess.HANDLED_QTY < int.Parse(mainProcess.PLAN_QTY))
             {
                 mainProcess.HANDLED_FLAG = "N";
             }
             p.PLAN_QTY = num.ToString();
             DB.GetInstance().Update(mainProcess);
             DB.GetInstance().Update(p);
         }
         //更改已导入的订单的处理数量信息
         List <PlanProcessMainEntity> orderProcesses = PlanProcessMainFactory.GetByOrderCode(entPlan.ORDER_CODE);
         var            minQTY = (from o in orderProcesses select o.HANDLED_QTY).Min();
         PlanTempEntity pt     = PlanTempFactory.GetByOrderCode(entPlan.ORDER_CODE);
         pt.HANDLED_QTY = minQTY;
         if (pt.HANDLED_QTY >= pt.PLAN_QTY)
         {
             pt.HANDLE_FLAG = "F";
         }
         else if (pt.HANDLED_QTY < pt.PLAN_QTY)
         {
             pt.HANDLE_FLAG = "N";
         }
         DB.GetInstance().Update(pt);
         //更改计划数量信息
         entPlan.PLAN_QTY = num;
         DB.GetInstance().Update(entPlan);
         DB.GetInstance().CompleteTransaction();
         return(true);
     }
     catch (Exception e)
     {
         DB.GetInstance().AbortTransaction();
         return(false);
     }
 }
示例#2
0
        public static string TransStore(string planCode, string resourceStore, string itemCode, string destinationStore, int transQTY)
        {
            DB.GetInstance().BeginTransaction();
            try
            {
                List <PlanBomEntity> planBOMs = PlanBOMFactory.GetByPlanCode(planCode);
                planBOMs = (from p in planBOMs where p.ITEM_CODE == itemCode && p.LINESIDE_STOCK_CODE == resourceStore select p).ToList <PlanBomEntity>();
                List <LineSideStockEntity> all   = DB.GetInstance().Fetch <LineSideStockEntity>("");
                PlanBomEntity       resouece     = planBOMs[0];
                LineSideStockEntity rsourceStore = LineSideStockFactory.GetStoreItem(resourceStore, itemCode);
                LineSideStockEntity destination  = LineSideStockFactory.GetStoreItem(destinationStore, itemCode);
                rsourceStore.ITEM_QTY = rsourceStore.ITEM_QTY - transQTY;
                DB.GetInstance().Update(rsourceStore);
                if (destination == null)
                {
                    LineSideStockEntity newEntity = new LineSideStockEntity()//
                    {
                        ITEM_CODE    = itemCode,
                        ITEM_QTY     = transQTY,
                        STORE_CODE   = destinationStore,
                        COMPANY_CODE = resouece.COMPANY_CODE,
                        VENDOR_CODE  = resouece.VENDOR_CODE,
                        PLINE_CODE   = resouece.PLINE_CODE,
                    };
                    DB.GetInstance().Insert(newEntity);
                }
                else
                {
                    destination.ITEM_QTY = destination.ITEM_QTY + transQTY;
                    DB.GetInstance().Update(destination);
                }

                IMESLine2LineEntity line2lineEntity = new IMESLine2LineEntity
                {
                    AUFNR  = resouece.ORDER_CODE,
                    WERKS  = resouece.FACTORY,
                    VORNR  = resouece.PROCESS_CODE,
                    SUBMAT = resouece.ITEM_CODE,
                    MENGE  = transQTY.ToString(),
                    TLGORT = destinationStore,
                    SLGORT = resourceStore,
                    PRIND  = "0",
                };
                DB.GetInstance().Insert(line2lineEntity);


                SAPMessageTransEntity msgEntity = new SAPMessageTransEntity
                {
                    MESSAGE_CODE = "0047",
                    WORK_DATE    = DateTime.Now,
                    HANDLE_FLAG  = "0",
                };
                DB.GetInstance().Insert(msgEntity);
                DB.GetInstance().CompleteTransaction();
                return("true");
            }
            catch (Exception e)
            {
                DB.GetInstance().AbortTransaction();
                return(e.Message);
            }
        }