Beispiel #1
0
        private static ClassWorkPlan CopyDayWorkPlan(DayClassWorkPlan item, DateTime PlanWorkDate, decimal ClassPlanQty, string CEmployeeNum, string CEmployeeName)
        {
            #region  检查日计划是否存在
            string   ProductionMakeWorkOrderId = item.ProductionMakeWorkOrderId;
            string   ProductionVersionName     = item.ProductionVersionName;
            string   MaterialNum = item.MaterialNum;
            DateTime dt          = PlanWorkDate;
            int      tst         = (int)TaskSheetType.DS;//工序日生产计划

            List <ClassWorkPlan> cwpLatest = BaseEntityFac.GetEntityByField <ClassWorkPlan>(x =>
                                                                                            x.PlanWorkDate == dt && x.TaskSheetType == tst &&
                                                                                            x.ProductionMakeWorkOrderId == ProductionMakeWorkOrderId &&
                                                                                            x.ProductionVersionName == ProductionVersionName
                                                                                            );

            if (cwpLatest != null && cwpLatest.Count > 0)
            {
                List <ClassWorkPlan> cwptempLatest = cwpLatest.OrderByDescending(x => x.CreateTime).ToList();

                ClassWorkPlan cwpItem = cwptempLatest.FirstOrDefault();

                cwpItem.ClassPlanQty = ClassPlanQty;//日作业量

                return(cwpItem);
            }

            #endregion
            ClassWorkPlan cwp = ObjectHelper.ObjectMap <DayClassWorkPlan, ClassWorkPlan>(item);
            cwp.PlanWorkDate          = PlanWorkDate;
            cwp.ClassWorkPlanId       = Guid.NewGuid().ToString();       //作业日期
            cwp.TaskSheetType         = (int)TaskSheetType.DS;           //工序日生产计划
            cwp.TaskSheetOPStatus     = (int)TaskSheetOPStatus.NotStart; //未开始作业
            cwp.ClassPlanQty          = ClassPlanQty;                    //日作业量
            cwp.ClassRealQty          = 0;                               //实际日报工量
            cwp.ClassNoSubmitScrapQty = 0;                               //未报工报废
            cwp.ClassSubmitScrapQty   = 0;                               //已报工报废
            cwp.CEmployeeName         = CEmployeeName;                   //创建人姓名
            cwp.CEmployeeNum          = CEmployeeNum;                    //创建人工号
            cwp.CreateTime            = BaseEntityFac.GetServerTime();
            cwp.FatherWorkPlanNo      = item.WorkPlanNo;
            cwp.WorkPlanNo            = item.WorkPlanNo + BaseEntityFac.GetNewSerialNumber("SubWorkPlanNo"); //父工单号+流水号
            cwp.QCProcessFlag         = (int)QCProcessFlag.Untested;
            cwp.QCProcessType         = item.QCProcessType;                                                  //复用父级工单
            cwp.QCEmployeeName        = string.Empty;                                                        //质检员姓名
            cwp.QCEmployeeNum         = string.Empty;                                                        //质检员工号
            return(cwp);
        }
Beispiel #2
0
        public static List <ClassWorkPlan> CreateClassWorkPlans(ProductionOrderVersion item, List <ProductionMakeWorkOrderView> workList)
        {
            List <ClassWorkPlan> cwpList = new List <ClassWorkPlan>();

            string ProductionVersionId = item.ProductionVersionId;

            DateTime dt = BaseEntityFac.GetServerTime();
            //工序时间缓存
            List <ProductionMakeWorkOrderTime> procesTimeList = new List <ProductionMakeWorkOrderTime>();

            //获取该生产版本中工序在制品清单
            List <WorkOrderOutProduct> woopList = BaseEntityFac.GetEntityByField <WorkOrderOutProduct>(x => x.ProductionVersionId == ProductionVersionId);

            //跟工序作业顺序计算  升序
            List <ProductionMakeWorkOrderView> newworkList = workList.OrderBy(x => x.ProcessOrder).ToList();

            //公式 (订单量/产能)* (时间值)*(时间单位换算成的秒数)
            decimal totalWorkTime = (item.MakeQty / item.ProductMakeValue) * item.ProductMakeTimeValue * item.ProductMakeUnit;//作业时间 单位秒

            //最晚作业开始时间


            List <APSCalendar> ascList = GetAPSCalendarWorkDate(CalendarHelper.ALLResourceCode.ToString());

            DateTime LatestStartTime = CalendarHelper.GetAPSWorkTime(item.ProductionOrderEndDate, totalWorkTime, ascList);

            //获取工序时间(去掉非作业时间)
            List <ProductionMakeWorkOrderTime> tempprocesTimeList = CalculationProcessTime(item, newworkList,
                                                                                           woopList, LatestStartTime, dt, ascList);

            if (tempprocesTimeList == null)
            {
                return(null);
            }

            foreach (var pmw in newworkList)
            {
                //获取工序产出品 可能存在一个工序多个产出品的情况
                List <WorkOrderOutProduct> newwoopList = woopList.FindAll(x => x.WorkOrderNum == pmw.WorkOrderNum &&
                                                                          x.ProductionVersionId == pmw.ProductionVersionId);

                if (newwoopList != null && newwoopList.Count > 0)
                {
                    ProductionMakeWorkOrderTime processTime = tempprocesTimeList.Find(x =>
                                                                                      x.ProductionMakeWorkOrderId == pmw.ProductionMakeWorkOrderId);
                    foreach (var woopItem in newwoopList)
                    {
                        ClassWorkPlan cwp = new ClassWorkPlan();
                        cwp.ClassWorkPlanId              = Guid.NewGuid().ToString();
                        cwp.ProductionOrderNumbe         = item.ProductionOrderNumbe;         //生产订单编号
                        cwp.ProductionOrderVersionNumber = item.ProductionOrderVersionNumber; //订单工艺编号
                        cwp.CustomerNum               = item.CustomerNum;
                        cwp.CustomerName              = item.CustomerName;
                        cwp.WorkPlanNo                = dt.Year.ToString() + BaseEntityFac.GetNewSerialNumber(EE.Name <ClassWorkPlan>(x => x.WorkPlanNo)); //工单流水号
                        cwp.TaskSheetType             = (int)TaskSheetType.PS;                                                                             //工单大分类
                        cwp.FatherWorkPlanNo          = string.Empty;                                                                                      //父级工单流水号
                        cwp.ProductionVersionId       = pmw.ProductionVersionId;                                                                           //生产版本ID
                        cwp.ProductionVersionName     = pmw.ProductionVersionName;                                                                         //生产版本名称
                        cwp.ProductionMakeWorkOrderId = pmw.ProductionMakeWorkOrderId;                                                                     //生产版本中工序ID
                        cwp.WorkOrderOutProductId     = woopItem.WorkOrderOutProductId;                                                                    //工序在制品ID
                        cwp.WorkOrderPositionId       = string.Empty;                                                                                      //工序中工位ID
                        cwp.WorkOrderNum              = pmw.WorkOrderNum;                                                                                  //工序编码
                        cwp.WorkOrderName             = pmw.WorkOrderName;                                                                                 //工序名称
                        cwp.MaterialNum               = woopItem.MaterialNum;                                                                              //在制品编码
                        cwp.MaterialName              = woopItem.MaterialName;                                                                             //在制品名称
                        cwp.BatchNumber               = item.BatchNumber;                                                                                  //生产批次

                        cwp.MainProductionResourceCode = string.Empty;                                                                                     //主资源编码
                        cwp.MainProductionResourceName = string.Empty;                                                                                     //主资源名称
                        cwp.SubProductionResourceCode  = string.Empty;                                                                                     //副资源编码
                        cwp.SubProductionResourceName  = string.Empty;                                                                                     //副资源名称

                        cwp.WorkPositionNum       = string.Empty;                                                                                          //工位编码
                        cwp.WorkPositionName      = string.Empty;                                                                                          //工位名称
                        cwp.EmployeeNum           = string.Empty;                                                                                          //员工工号
                        cwp.PlanWorkDate          = dt;                                                                                                    //计划日期
                        cwp.ClassNoName           = string.Empty;                                                                                          //班次
                        cwp.EarliestStartTime     = processTime.EarliestStartTime;
                        cwp.LatestEndTime         = processTime.LatestEndTime;
                        cwp.PlanWorkStartTime     = cwp.EarliestStartTime;
                        cwp.PlanWorkEndTime       = cwp.LatestEndTime;
                        cwp.ClassPlanQty          = item.MakeQty * woopItem.Qty - InspectRegisterQty(item.ProductionOrderNumbe, woopItem.WorkOrderOutProductId); //工单计划作业量 去掉库存抵消量
                        cwp.ClassRealQty          = 0;                                                                                                           //工单实际作业量
                        cwp.ClassSubmitScrapQty   = 0;                                                                                                           //报工后出现的废品
                        cwp.ClassNoSubmitScrapQty = 0;                                                                                                           //调试出现的废品
                        cwp.UnitCode = item.UnitCode;                                                                                                            //物料单位

                        cwp.TaskSheetSmallType = (int)TaskSheetSmallType.Normal;                                                                                 //工单小分类
                        cwp.IsPublish          = (int)WhetherValue.No;
                        cwp.CustomFlag         = 0;                                                                                                              //1-表示插单
                        cwp.TaskSheetOPStatus  = (int)TaskSheetOPStatus.NotStart;                                                                                //工单操作
                        cwp.HandoverState      = (int)WhetherValue.No;                                                                                           //交接班

                        cwp.QCProcessType  = woopItem.QCProcessType;                                                                                             //质检类型 例如全检 抽检 免检
                        cwp.QCProcessFlag  = (int)QCProcessFlag.Untested;                                                                                        //质检状态
                        cwp.QCEmployeeName = string.Empty;                                                                                                       //质检员姓名
                        cwp.QCEmployeeNum  = string.Empty;                                                                                                       //质检员工号

                        cwp.Comments = string.Empty;                                                                                                             //工单备注

                        cwpList.Add(cwp);
                    }
                }
            }


            return(cwpList);
        }
Beispiel #3
0
 public string GetNewSerialNumber(string serialtype)
 {
     return(BaseEntityFac.GetNewSerialNumber(serialtype));
 }