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); }
static void Main(string[] args) { string str = EE.Name <EnumData>(x => x.DisplayMember); str = EE.Name <EnumData>(x => x.ValueMember); string UserInfoId1 = "84667fb5-4318-442f-99c7-243246c7c863"; var sqlCmd = MsGenerateSql.SelectFromTable <MenuInfo>(). LeftJoin <RoleMenuRelationship, MenuInfo>((t1, t2) => t1.MenuInfoId == t2.MenuInfoId). LeftJoin <RoleInfo, RoleMenuRelationship>((t1, t2) => t1.RoleInfoId == t2.RoleInfoId). LeftJoin <UserRoleRelationship, RoleInfo>((t1, t2) => t1.RoleInfoId == t2.RoleInfoId). LeftJoin <UserInfo, UserRoleRelationship>((t1, t2) => t1.UserInfoId == t2.UserInfoId).Distinct().Where <UserInfo>((t) => t.UserInfoId == UserInfoId1 && t.EmployeeNum == "101"); DateTime dt = DateTime.Parse("2019-07-01"); sqlCmd = MsGenerateSql.SelectFromTable <MaterialNumber>() .Where <MaterialNumber>((t) => t.ValidFrom > dt); EE.Name <MenuInfo>(t => t.MenuName); //MsGenerateSql.Name<MenuInfo>((t) => new object[] //{ // t.MenuName //}); string sql = sqlCmd.AutoMapDisplayItem <RoleInfo>().GenerateSql(); sql = sqlCmd.ManualMapDisplayItem(EE.NameSql <UserInfo>(t => new object[] { t.EmployeeNum, t.EmployeeName, t.Mobile, t.Email })).GenerateSql(); return; //EnumAttribute.EnumToList<MaterialType>(); //LocalLanguage("zh-CN,原材料;en-US,RawMaterial"); //SystemBusiness _UserInfoBusiness = new SystemBusiness(); //List<MenuInfo> itemList = new List<MenuInfo>(); //itemList = _UserInfoBusiness.GetAllEntitys<MenuInfo>(); // LoginStatus status = _UserInfoBusiness.Login("101", "123"); //_UserInfoBusiness.GetMenusByUserId("84667fb5-4318-442f-99c7-243246c7c863"); ////List<QCItemType> itemQCNewNewList = new List<QCItemType>(); ////List<MaterialNumber> mnUpdateList = new List<MaterialNumber>(); ////DateTime dt = DateTime.Now; ////MaterialNumber mn = mnd.GetEntityById(mnList.FirstOrDefault().MaterialNumberId); ////MaterialNumber itemMNU = ObjectHelper.DeepClone<MaterialNumber>(mn); ////MaterialNumber itemMNNew = ObjectHelper.DeepClone<MaterialNumber>(mn); ////itemMNU.MaterialName = mn.MaterialName + "更新"; ////mnUpdateList.Add(itemMNU); ////itemMNNew.MaterialNumberId = Guid.NewGuid().ToString(); ////itemMNNew.MaterialNum = mn.MaterialNum + "新建"; ////itemMNNew.MaterialName = mn.MaterialName + "新建"; ////mnUpdateList.Add(itemMNNew); //string path = @"C:\Users\koukou\Desktop\EMAS系统上线演示\基础数据\物料信息201922713399.xls"; //if(mnd.ImportBaseDataFromFile(path, "物料信息")) //{ // Console.Write("数据导入成功!"); //} //ProductionBusiness pb = new ProductionBusiness(); //path = @"C:\Users\koukou\Desktop\EMAS系统上线演示\基础数据\客户物料信息关联20192281579.xls"; //if (pb.ImportBaseDataFromFile(path, "客户物料信息关联")) //{ // Console.Write("数据导入成功!"); //} ////if(mnd.SaveBaseData(mnUpdateList)) ////{ //// Console.Write("保存成功"); ////} //foreach (var item in mnList) //{ // //if (mnUpdateList.Count == 0) // //{ // // MaterialNumber itemMNNew = ObjectHelper.DeepClone<MaterialNumber>(mn); // // //MaterialNumber itemMNNew = new MaterialNumber(); // // itemMNNew.MaterialNumberId = itemMNNew.MaterialNumberId; // // itemMNNew.MaterialName = itemMNNew.MaterialName+"更新"; // // mnUpdateList.Add(itemMNNew); // // QCItemType itemQCNew = new QCItemType(); // // itemQCNew.QCItemTypeId = Guid.NewGuid().ToString(); // // int typecode = dt.Year + dt.Month + dt.Day + dt.Hour + dt.Minute + dt.Second + dt.Millisecond; // // itemQCNew.QCItemTypeCode = typecode.ToString(); // // itemQCNew.QCItemTypeName = "首件"; // // itemQCNewNewList.Add(itemQCNew); // // mnd.TransactionOPEntitys((cn, transaction) => // // { // // bool result = false; // // result = mnd.TransactionOPEntitysAdd<QCItemType>(cn, transaction, EOPType.Insert, itemQCNewNewList); // // result = mnd.TransactionOPEntitysAdd<MaterialNumber>(cn, transaction, EOPType.Update, mnUpdateList); // // return result; // // } // // ); // //} // //Console.WriteLine(mn.MaterialName); // } }