Ejemplo n.º 1
0
 public void GetAllEntityFrameWorkWithChildren()
 {
     using (var repo = new ERepository())
     {
         var data = repo.Tag.Include(x => x.Image).ToList();
         Assert.AreNotEqual(0, data.Count());
     }
 }
Ejemplo n.º 2
0
 public void GetAllEntityFrameWork()
 {
     using (var repo = new ERepository())
     {
         var data = repo.Tag.ToList();
         Assert.AreNotEqual(0, data.Count());
     }
 }
Ejemplo n.º 3
0
 public void AddEFramework()
 {
     using (var repo = new ERepository())
     {
         // FileName is not nullable, make sure to specify it
         // Primary Id cant be set for Image, This will be set automaticly. you cant specify the Id. EntityWorker will consider this as an update otherwise.
         var tag = new Tag {
             Filename = "tesdst", Interpret = "TestInterpret", Title = "Title", Image = new Image {
                 Data = new byte[10]
             }
         };
         repo.Tag.Add(tag);
         repo.SaveChanges(); // Comit to the database
     }
 }
Ejemplo n.º 4
0
 public IBaseRepository Repositories(ERepository repository)
 {
     return(_repositories.Where(e => e.repository == repository).FirstOrDefault());
 }
Ejemplo n.º 5
0
        public async Task <int> Create(ICMODailyCreatDto input)
        {
            var icmo = MRepository.GetAll().SingleOrDefault(p => p.任务单号 == input.FMOBillNo);

            if (icmo == null)
            {
                this.EX(-1, $"{input.FMOBillNo} 任务单不存在,请检查");
            }

            var oplist = await SUbRepository.GetAll().ToListAsync();

            var equipmentList = await ERepository.GetAll().Where(p => p.FType == PublicEnum.EquipmentType.设备).ToListAsync();

            var orgs = await ORepository.GetAll().Where(p => p.FWorkshopType).ToListAsync();

            var eqShifts = await EsRepository.GetAll().ToListAsync();

            if (icmo != null)
            {
                var schedule = GetOrCreateSchedule(icmo);

                var org = orgs.SingleOrDefault(o => o.DisplayName == icmo.车间);

                if (org == null)
                {
                    this.EX(-1, $"找不到此车间:{icmo.车间},请检查组织架构信息");
                }

                foreach (var dailyItem in input.Dailies)
                {
                    var equipments = equipmentList.Where(e => e.FName == dailyItem.FMachineName && e.FWorkCenterID == org.Id);

                    if (equipments.Count() > 1)
                    {
                        this.EX(-1, $"【{org.DisplayName}】车间存在多个【{dailyItem.FMachineName}】设备");
                    }

                    var equipment = equipments.SingleOrDefault();

                    if (equipment == null)
                    {
                        this.EX(-1, $"在【{icmo.车间}】车间找不到设备:{dailyItem.FMachineName} ,请检查设备档案");
                    }

                    var shift = eqShifts.SingleOrDefault(p =>
                                                         p.FEqiupmentID == equipment.FInterID && p.FShift == dailyItem.FShift);

                    if (shift == null)
                    {
                        this.EX(-1, $"设备:{dailyItem.FMachineName} 的班次信息中不存在 【{dailyItem.FShift}】,请检查设备的班次信息");
                    }

                    var entity = schedule.Dailies.SingleOrDefault(p =>
                                                                  p.FDate == dailyItem.FDate && p.FMachineID == equipment.FInterID &&
                                                                  p.FShift == shift.Id);

                    var op = oplist.SingleOrDefault(p => p.FName == dailyItem.FOperID);

                    var index = (schedule.Dailies.Count + 1).ToString("000");

                    if (entity == null && dailyItem.FPlanAuxQty > 0)
                    {
                        entity = new Entities.ICMODaily
                        {
                            FMachineID      = equipment.FInterID,
                            FWorkCenterID   = org.Id,
                            FShift          = shift.Id,
                            FID             = Guid.NewGuid().ToString(),
                            FBillNo         = "DA" + DateTime.Now.ToString("yyyyMMddHHmmss") + "-" + index, //任务计划单号
                            FMOInterID      = icmo.FMOInterID,                                              //任务单ID
                            FMOBillNo       = icmo.任务单号,                                                    //任务单号
                            FBiller         = AbpSession.UserId.ToString(),                                 //当前登录用户
                            FSrcID          = schedule.FID,
                            FPlanAuxQty     = dailyItem.FPlanAuxQty,
                            FBillTime       = DateTime.Now,
                            FDate           = dailyItem.FDate.Date,
                            FOperID         = op != null?op.FInterID:0,
                            FWorkCenterName = icmo.车间,
                            FWorker         = shift.FEmployeeID,
                            FPackQty        = dailyItem.PackQty
                        };
                        //插入新的日计划单
                        schedule.Dailies.Add(entity);
                    }
                    else if (dailyItem.FPlanAuxQty > 0)
                    {
                        schedule.FPlanAuxQty -= entity.FPlanAuxQty;
                        entity.FPlanAuxQty    = dailyItem.FPlanAuxQty;
                        schedule.FPlanAuxQty += entity.FPlanAuxQty;
                    }
                }

                //更新计划单
                SRepository.Update(schedule);
                return(schedule.Dailies.Count);
            }
            else
            {
                throw new UserFriendlyException(string.Format("任务单:{0}不存在", input.FMOBillNo));
            }
        }