| | |
| | | using DocumentServiceAPI.Application.DocManage.Dtos; |
| | | using DocumentServiceAPI.Application.DocManage.Services; |
| | | using DocumentServiceAPI.Application.ProjectInfo.Services; |
| | | using DocumentServiceAPI.Application.System.Services; |
| | | using DocumentServiceAPI.Model.cyDocumentModel; |
| | | using DocumentServiceAPI.Services.IService; |
| | | using DocumentServiceAPI.Utility; |
| | | using Microsoft.AspNetCore.Mvc.RazorPages; |
| | | using Microsoft.Extensions.Caching.Memory; |
| | | using System.Linq.Expressions; |
| | | |
| | | namespace DocumentServiceAPI.Application.DocManage |
| | |
| | | private readonly DocumentManageService _docManageService; |
| | | private readonly OrganizationService _organizationService; |
| | | private readonly FileManageService _fileManageService; |
| | | private readonly ProjectManageService _projectService; |
| | | private readonly IRedisCacheService _redisCache; |
| | | |
| | | public DocumentManageAppService(DocClassificationService classService, DocumentManageService docService, OrganizationService orgService,FileManageService fileManageService) |
| | | public DocumentManageAppService(DocClassificationService classService, DocumentManageService docService, OrganizationService orgService, |
| | | FileManageService fileManageService, ProjectManageService projectService, IRedisCacheService redisCase) |
| | | { |
| | | _classificationService = classService; |
| | | _docManageService = docService; |
| | | _organizationService = orgService; |
| | | _fileManageService = fileManageService; |
| | | _projectService = projectService; |
| | | |
| | | _redisCache = redisCase; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 编辑文档时设置文档锁定状态 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns> |
| | | /// true:设置锁定成功 |
| | | /// false:锁定失败,文档已被锁定 |
| | | /// </returns> |
| | | public bool SetDocLockStatus(DocLock_Submit_Dto model) |
| | | { |
| | | bool msg = true; |
| | | string key = model.tenant_id.ToString().PadLeft(4,'0') + "_" + model.id.ToString().PadLeft(8,'0'); |
| | | if (_redisCache.Get<Document_Lock_Dto>(key) != null) |
| | | { |
| | | msg = false; |
| | | } |
| | | else |
| | | { |
| | | Document_Lock_Dto lk = new Document_Lock_Dto(); |
| | | lk.doc_id = model.id; |
| | | lk.lock_time = DateTime.Now; |
| | | lk.lock_user = model.username; |
| | | lk.lock_user_id = model.userid; |
| | | lk.status = 0; |
| | | lk.tenant_id = model.tenant_id; |
| | | |
| | | var db= _redisCache.Add<Document_Lock_Dto>(key,lk ,-1); |
| | | } |
| | | return msg; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询项目信息 |
| | | /// </summary> |
| | | /// <param name="search"></param> |
| | | /// <returns></returns> |
| | | public async Task<IActionResult> PostProjectItemList(ProjectItemSearch search) |
| | | { |
| | | var data = await _projectService.GetListAsync();//.GetListAsync(c => c.TenantID == search.tenant_id); |
| | | if (data != null) |
| | | { |
| | | var list = data.Select(c => new ProjectItem_List_Dto() |
| | | { |
| | | pro_id=c.ProjectId, |
| | | pro_name=c.ProjectName |
| | | }).OrderBy(c => c.pro_name).ToList(); |
| | | return new JsonResult(list); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | expression = expression.And(t => t.classification_id == model.class_id); |
| | | } |
| | | if (model.project_id.HasValue && model.project_id != 0) |
| | | { |
| | | expression = expression.And(t => t.project_id == model.project_id); |
| | | } |
| | | |
| | | if (model.id > 0) |
| | | { |
| | | expression = expression.And(t => t.id != model.id); |
| | |
| | | var data = await _docManageService.Context.Queryable<Doc_Info>() |
| | | .Includes(c => c.DocClassification) |
| | | .Includes(c=>c.DocOrganization) |
| | | .Includes(c=>c.DocProject) |
| | | .Where(expression) |
| | | .OrderByDescending(c=>c.id) |
| | | .ToPageListAsync(page.PageIndex, page.PageSize, total); |
| | | |
| | | if (data != null && total > 0) |
| | |
| | | org_id = c.org_id, |
| | | org_name = c.DocOrganization?.UnitName, |
| | | project_id = c.project_id, |
| | | project_name = "", |
| | | project_name = c.DocProject?.ProjectName, |
| | | status = c.status |
| | | }).ToList(); |
| | | |