Ejemplo n.º 1
0
        public async Task <EmployeeReceiptOutput> Create(CreateEmployeeReceiptInput input)
        {
            if (input.DocProperty == ReceiptDocProperty.Electronic && input.FileList.Count() == 0)
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "请上传正文。");
            }
            var newmodel = new EmployeeReceipt()
            {
                Title           = input.Title,
                DocReceiveDep   = input.DocReceiveDep,
                DocReceiveNo    = input.DocReceiveNo,
                DocType         = input.DocType,
                DocProperty     = input.DocProperty,
                Rank            = input.Rank,
                EmergencyDegree = input.EmergencyDegree,
                ReportMatters   = input.ReportMatters,
                Remark          = input.Remark,
                IsPrintQrcode   = input.IsPrintQrcode,
                QrCodeId        = _qrCodeManager.GetCreateId(QrCodeType.公文),
                Opinion         = ""//拟办意见为空
            };
            var lastNumber = Convert.ToInt32(_repository.GetAll().OrderByDescending(x => x.ReceiptNo).FirstOrDefault()?.ReceiptNo);

            Interlocked.Increment(ref lastNumber);
            newmodel.ReceiptNo = lastNumber;
            await _repository.InsertAsync(newmodel);

            if (input.FileList != null)
            {
                var fileList = new List <AbpFileListInput>();
                foreach (var item in input.FileList)
                {
                    fileList.Add(new AbpFileListInput()
                    {
                        Id = item.Id, Sort = item.Sort
                    });
                }
                await _abpFileRelationAppService.CreateAsync(new CreateFileRelationsInput()
                {
                    BusinessId   = newmodel.Id.ToString(),
                    BusinessType = (int)AbpFileBusinessType.收文附件,
                    Files        = fileList
                });
            }
            return(new EmployeeReceiptOutput()
            {
                InStanceId = newmodel.Id.ToString(), QrCodeId = newmodel.QrCodeId.Value
            });
        }
Ejemplo n.º 2
0
        private EmployeeReceiptLogDto GetChangeModel(EmployeeReceipt model, List <AbpFileChangeDto> files)
        {
            var ret  = model.MapTo <EmployeeReceiptLogDto>();
            var type = _gW_DocumentTypeRepository.GetAll().FirstOrDefault(y => y.Id == model.DocType);

            ret.DocType         = type?.Name;
            ret.DocProperty     = model.DocProperty.GetLocalizedDescription();
            ret.Rank            = model.Rank.GetLocalizedDescription();
            ret.EmergencyDegree = model.EmergencyDegree.GetLocalizedDescription();
            if (files.Count() > 0)
            {
                ret.Files = files;
            }
            return(ret);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 修改一个EmployeeReceipt
        /// </summary>
        /// <param name="input">实体</param>
        /// <returns></returns>
        public async Task Update(UpdateEmployeeReceiptInput input)
        {
            if (input.Id != Guid.Empty)
            {
                if (input.DocProperty == ReceiptDocProperty.Electronic && input.FileList.Count() == 0)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "请上传正文。");
                }
                var dbmodel = await _repository.FirstOrDefaultAsync(x => x.Id == input.Id);

                if (dbmodel == null)
                {
                    throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
                }
                var logModel = new EmployeeReceipt();
                if (input.IsUpdateForChange)
                {
                    logModel = dbmodel.DeepClone <EmployeeReceipt>();
                }
                dbmodel.Opinion         = input.Opinion;
                dbmodel.Title           = input.Title;
                dbmodel.Remark          = input.Remark;
                dbmodel.Rank            = input.Rank;
                dbmodel.IsPrintQrcode   = input.IsPrintQrcode;
                dbmodel.DocReceiveNo    = input.DocReceiveNo;
                dbmodel.DocReceiveDep   = input.DocReceiveDep;
                dbmodel.CopyForType     = input.CopyForType;
                dbmodel.TaskType        = input.TaskType;
                dbmodel.DocType         = input.DocType;
                dbmodel.CopyForUsers    = input.CopyForUsers;
                dbmodel.EmergencyDegree = input.EmergencyDegree;
                await _repository.UpdateAsync(dbmodel);

                var fileList = new List <AbpFileListInput>();
                if (input.FileList != null)
                {
                    foreach (var item in input.FileList)
                    {
                        fileList.Add(new AbpFileListInput()
                        {
                            Id = item.Id, Sort = item.Sort
                        });
                    }
                }
                await _abpFileRelationAppService.UpdateAsync(new CreateFileRelationsInput()
                {
                    BusinessId   = input.Id.ToString(),
                    BusinessType = (int)AbpFileBusinessType.收文附件,
                    Files        = fileList,
                });

                if (input.IsUpdateForChange)
                {
                    var flowModel = _workFlowCacheManager.GetWorkFlowModelFromCache(input.FlowId);
                    if (flowModel == null)
                    {
                        throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "流程不存在");
                    }
                    var files = input.OldFileList.Select(r => new AbpFileChangeDto {
                        FileName = r.FileName, Id = r.Id
                    }).ToList();
                    var newfiles = input.FileList.Select(r => new AbpFileChangeDto {
                        FileName = r.FileName, Id = r.Id
                    }).ToList();
                    var logs = GetChangeModel(logModel, files).GetColumnAllLogs(GetChangeModel(dbmodel, newfiles));
                    await _projectAuditManager.InsertAsync(logs, input.Id.ToString(), flowModel.TitleField.Table);

                    _workFlowTaskManager.CreateNoticeForTask(input.FlowId, input.Id.ToString(), "收文变更", dbmodel.Title);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该数据不存在。");
            }
        }