Ejemplo n.º 1
0
        public async Task <DingDingVisitRecordInputDto> GetCreateDingDingVisitRecordAsync(Guid scheduleDetailId)
        {
            var query = from sd in _scheduleDetailRepository.GetAll()
                        join t in _visitTaskRepository.GetAll() on sd.TaskId equals t.Id
                        where sd.Id == scheduleDetailId
                        select new
            {
                sd.Id,
                sd.EmployeeId,
                sd.GrowerId,
                sd.GrowerName,
                t.Name,
                t.Type,
                t.Desc,
                TaskId = t.Id
            };
            var dmdata = await query.FirstOrDefaultAsync();

            var result = new DingDingVisitRecordInputDto()
            {
                ScheduleDetailId = dmdata.Id,
                EmployeeId       = dmdata.EmployeeId,
                GrowerId         = dmdata.GrowerId,
                GrowerName       = dmdata.GrowerName,
                TaskDesc         = string.Format("{0}({1}),{2}", dmdata.Name, dmdata.Type.ToString(), dmdata.Desc)
            };

            var examines = await _taskExamineRepository.GetAll().Where(t => t.TaskId == dmdata.TaskId).OrderBy(e => e.Seq).ToListAsync();

            result.Examines = examines.MapTo <List <DingDingTaskExamineDto> >();
            return(result);
        }
Ejemplo n.º 2
0
        public async Task <APIResultDto> SaveDingDingVisitRecordAsync(DingDingVisitRecordInputDto input)
        {
            var vistitRecord = input.MapTo <VisitRecord>();

            vistitRecord.SignTime = DateTime.Now;
            //计划明细
            var detail = await _scheduleDetailRepository.GetAsync(input.ScheduleDetailId);

            //生成水印图片
            vistitRecord.ImgPath = GenerateWatermarkImg(vistitRecord.ImgPath, vistitRecord.Location, detail.EmployeeName, detail.GrowerName);
            //拜访记录
            var vrId = await _visitrecordRepository.InsertAndGetIdAsync(vistitRecord);

            await CurrentUnitOfWork.SaveChangesAsync();

            //考核项
            foreach (var item in input.Examines)
            {
                var ve = new VisitExamine()
                {
                    EmployeeId    = input.EmployeeId,
                    GrowerId      = input.GrowerId,
                    Score         = item.Score,
                    TaskExamineId = item.Id,
                    VisitRecordId = vrId
                };
                await _visitExamineRepository.InsertAsync(ve);
            }

            detail.CompleteNum++;
            detail.Status = detail.CompleteNum == detail.VisitNum ? ScheduleStatusEnum.已完成 : ScheduleStatusEnum.进行中;

            return(new APIResultDto()
            {
                Code = 0, Msg = "保存数据成功"
            });
        }