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
|
{
|
/// <summary>
|
/// 资料管理
|
/// </summary>
|
public class DocumentManageAppService : IDynamicApiController
|
{
|
private readonly DocClassificationService _classificationService;
|
private readonly DocumentManageService _docManageService;
|
private readonly OrganizationService _organizationService;
|
private readonly FileManageService _fileManageService;
|
private readonly ProjectManageService _projectService;
|
private readonly DocAchievementService _achievementService;
|
private readonly IRedisCacheService _redisCache;
|
private readonly DocShebeinengliService _shebeinengliService;
|
|
public DocumentManageAppService(DocClassificationService classService, DocumentManageService docService, OrganizationService orgService,
|
FileManageService fileManageService, ProjectManageService projectService, DocAchievementService achievementService, IRedisCacheService redisCase
|
, DocShebeinengliService shebeinengliService)
|
{
|
_classificationService = classService;
|
_docManageService = docService;
|
_organizationService = orgService;
|
_fileManageService = fileManageService;
|
_projectService = projectService;
|
_achievementService = achievementService;
|
_shebeinengliService = shebeinengliService;
|
|
_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>
|
/// 根据文档类型查询文档列表
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostDocumentItemList(DocumentSearch search)
|
{
|
if(search.Code == "002")
|
{
|
var data = await _achievementService.GetListAsync(c => c.status == 1 && c.tenant_code == search.TenantID);
|
if (search.class_id > 0)
|
{
|
data = data.Where(c => c.classification_id == search.class_id).ToList();
|
}
|
|
return new JsonResult(data.OrderBy(x => x.sort).Select(c => new { name = c.achievement_name, idcode = c.id+ "/002" }).ToList());
|
}
|
else if (search.Code == "006")
|
{
|
var data = await _shebeinengliService.GetListAsync(c => c.status == 1 && c.tenant_code == search.TenantID);
|
if (search.class_id > 0)
|
{
|
data = data.Where(c => c.classification_id == search.class_id).ToList();
|
}
|
|
return new JsonResult(data.OrderBy(x => x.sort).Select(c => new { name = c.shebeinengli_name, idcode = c.id + "/006" }).ToList());
|
}
|
else
|
{
|
var data = await _docManageService.GetListAsync(c => c.status == 1 && c.is_del == false && c.doc_code == search.Code && c.org_id == search.TenantID);
|
if (search.class_id > 0)
|
{
|
data = data.Where(c => c.classification_id == search.class_id).ToList();
|
}
|
|
return new JsonResult(data.OrderBy(x => x.sort).Select(c => new { name = c.doc_name , idcode = c.id + "/" + c.doc_code }).ToList());
|
}
|
|
}
|
|
/// <summary>
|
/// 检查名称重复
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public async Task<bool> CheckNameDuplicate(Document_Submit_Dto model)
|
{
|
var msg = false;
|
Expression<Func<Doc_Info, bool>> expression = t => true;
|
expression = expression.And(c => c.tenant_code == model.tenant_id && c.doc_name == model.name && c.doc_code == model.code && c.is_del == false );
|
if (model.class_id.HasValue && model.class_id!=0)
|
{
|
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 ck =await _docManageService.GetFirstAsync(expression);
|
if (ck != null)
|
{
|
msg = true;
|
}
|
return msg;
|
}
|
|
/// <summary>
|
/// 根据分页条件查询分页数据
|
/// </summary>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostListPage(DocumentPageSearch page)
|
{
|
PageResult<Document_List_Dto> result = new PageResult<Document_List_Dto>();
|
|
try
|
{
|
Expression<Func<Doc_Info, bool>> expression = t => true;
|
|
expression = expression.And(t =>t.tenant_code==page.TenantID && t.doc_code == page.Code && t.is_del==false);
|
if (page.ClassCode.HasValue)
|
{
|
expression = expression.And(t => t.classification_id == page.ClassCode);
|
}
|
if (!string.IsNullOrEmpty(page.Name))
|
{
|
expression = expression.And(t => t.doc_name.Contains(page.Name));
|
}
|
if (page.Status.HasValue)
|
{
|
expression = expression.And(t => t.status == page.Status);
|
}
|
if (page.OrganizationCode.HasValue)
|
{
|
expression = expression.And(t => t.org_id == page.OrganizationCode);
|
}
|
RefAsync<int> total = 0;
|
var data = await _docManageService.Context.Queryable<Doc_Info>()
|
.Includes(c => c.DocClassification)
|
.Includes(c=>c.DocOrganization)
|
.Includes(c=>c.DocProject)
|
.Where(expression)
|
.OrderBy(c=>c.sort)
|
.ToPageListAsync(page.PageIndex, page.PageSize, total);
|
|
if (data != null && total > 0)
|
{
|
result.Items = data.Select(c => new Document_List_Dto()
|
{
|
add_time = c.add_time,
|
class_id = c.classification_id,
|
class_name = c.DocClassification?.doc_classification,
|
doc_name = c.doc_name,
|
id = c.id,
|
org_id = c.org_id,
|
org_name = c.DocOrganization?.UnitName,
|
project_id = c.project_id,
|
project_name = c.DocProject?.ProjectName,
|
status = c.status,
|
sort = c.sort,
|
zb_time = c.zb_time.HasValue ? c.zb_time.Value.ToString("yyyy/MM/dd") : "",
|
zige_code = c.zige_code,
|
zige_code_name = c.document_Dictionary?.Name
|
}).ToList();
|
|
}
|
result.PageIndex = page.PageIndex;
|
result.PageSize = page.PageSize;
|
result.TotalCount = total;
|
}
|
catch (Exception er)
|
{
|
Log.Error(er.Message, er);
|
}
|
|
return new JsonResult(result);
|
}
|
|
/// <summary>
|
/// 根据文档号查询
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostDocumentInfo(DocumentSearch search)
|
{
|
var data = await _docManageService.GetFirstAsync(c => c.is_del == false && c.id == search.ID && c.tenant_code==search.TenantID);
|
if (data != null)
|
{
|
var list = await _fileManageService.GetListAsync(c =>c.status==1 && c.doc_id == search.ID);
|
Document_Info_Dto info = new Document_Info_Dto(data, list.Select(c => new FileInfo_List_Dto(c)).OrderBy(c => c.sort).ToList());
|
return new JsonResult(info);
|
}
|
|
return null;
|
}
|
|
/// <summary>
|
/// 添加数据
|
/// </summary>
|
/// <param name="info"></param>
|
/// <returns></returns>
|
public async Task<bool> PostAddDocumentInfo(Document_Submit_Dto info)
|
{
|
bool msg = false;
|
|
Doc_Info doc = new Doc_Info();
|
doc.add_time = DateTime.Now;
|
doc.classification_id = info.class_id;
|
doc.doc_code = info.code;
|
doc.doc_name = info.name;
|
doc.is_del = false;
|
doc.org_id = info.org_id;
|
doc.status = info.status;
|
doc.tenant_code = info.tenant_id;
|
doc.sort = info.sort;
|
doc.zb_time = info.zb_time;
|
doc.zige_code = info.zige_code;
|
|
var id =await _docManageService.InsertReturnIdentityAsync(doc);
|
if (id > 0)
|
{
|
if(info.newfiles!=null&& info.newfiles.Count > 0)
|
{
|
foreach (var item in info.newfiles)
|
{
|
File_Info file = new File_Info();
|
file.doc_id = id;
|
file.filenewname = item.filenewname.Length > 40 ? item.filenewname.Substring(item.filenewname.Length - 40) : item.filenewname;
|
file.fileoldname = item.fileoldname.Length > 40 ? item.fileoldname.Substring(item.fileoldname.Length - 40) : item.fileoldname;
|
file.filepath = item.filepath;
|
file.fileservername = item.fileservername;
|
file.filesize = item.filesize;
|
file.filetype = item.filetype;
|
file.status = 1;
|
file.suffix = item.suffix;
|
file.uptime = DateTime.Now;
|
file.up_userid = item.up_userid;
|
file.up_username = item.up_username;
|
file.sort = item.sort;
|
await _fileManageService.InsertAsync(file);
|
}
|
}
|
msg = true;
|
}
|
return msg;
|
}
|
|
/// <summary>
|
/// 修改数据
|
/// </summary>
|
/// <param name="info"></param>
|
/// <returns></returns>
|
public async Task<bool> PostEdtDocumentInfo(Document_Submit_Dto info)
|
{
|
bool msg = false;
|
|
var doc= _docManageService.GetById(info.id);
|
if (info.tenant_id == doc.tenant_code && doc.is_del==false)
|
{
|
doc.add_time = DateTime.Now;
|
doc.classification_id = info.class_id;
|
doc.doc_name = info.name;
|
doc.org_id = info.org_id;
|
doc.status = info.status;
|
doc.sort = info.sort;
|
doc.zb_time = info.zb_time;
|
doc.zige_code = info.zige_code;
|
if (await _docManageService.UpdateAsync(doc))
|
{
|
//新提交的文件
|
if (info.newfiles != null && info.newfiles.Count > 0)
|
{
|
foreach (var item in info.newfiles)
|
{
|
File_Info file = new File_Info();
|
file.doc_id = doc.id;
|
file.filenewname = item.filenewname.Length > 40 ? item.filenewname.Substring(item.filenewname.Length - 40) : item.filenewname;
|
file.fileoldname = item.fileoldname.Length > 40 ? item.fileoldname.Substring(item.fileoldname.Length - 40) : item.fileoldname;
|
file.filepath = item.filepath;
|
file.fileservername = item.fileservername;
|
file.filesize = item.filesize;
|
file.filetype = item.filetype;
|
file.status = 1;
|
file.suffix = item.suffix;
|
file.uptime = DateTime.Now;
|
file.up_userid = item.up_userid;
|
file.up_username = item.up_username;
|
file.sort = item.sort;
|
await _fileManageService.InsertAsync(file);
|
}
|
}
|
|
//修改资源名称的文件
|
if (info.editfiles != null && info.editfiles.Count > 0)
|
{
|
foreach (var item in info.editfiles)
|
{
|
var file= _fileManageService.GetById(item.id);
|
if (file != null && file.doc_id==doc.id)
|
{
|
file.fileoldname = file.filenewname;
|
file.filenewname = item.filenewname.Length > 40 ? item.filenewname.Substring(item.filenewname.Length - 40) : item.filenewname;
|
file.uptime = DateTime.Now;
|
file.sort = item.sort;
|
await _fileManageService.UpdateAsync(file);
|
}
|
}
|
}
|
|
//删除资源
|
if (info.delfiles != null && info.delfiles.Count > 0)
|
{
|
foreach (var item in info.delfiles)
|
{
|
var file = _fileManageService.GetById(item);
|
if (file != null && file.doc_id == doc.id)
|
{
|
file.status = 0;
|
file.uptime = DateTime.Now;
|
await _fileManageService.UpdateAsync(file);
|
}
|
}
|
}
|
|
msg = true;
|
}
|
}
|
|
return msg;
|
}
|
|
/// <summary>
|
/// 删除文档数据
|
/// </summary>
|
/// <param name="doc"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostDelInfo(Document_Submit_Dto doc)
|
{
|
bool msg = false;
|
//假删除
|
var model = await _docManageService.GetByIdAsync(doc.id);
|
if (model != null)
|
{
|
if(model.tenant_code==doc.tenant_id && !model.is_del)
|
{
|
model.is_del = true;
|
msg = await _docManageService.UpdateAsync(model);
|
}
|
}
|
return new JsonResult(msg);
|
}
|
|
#region 文档的文件
|
|
/// <summary>
|
/// 根据文档号查询文件数据
|
/// </summary>
|
/// <param name="id"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> GetDocumentFilesList(int id,string code)
|
{
|
if (code == "002")
|
{
|
var data = await _achievementService.GetByIdAsync(id);
|
List<FileInfo_List_Dto> list_Dtos = new List<FileInfo_List_Dto> ();
|
if (data != null)
|
{
|
if (!string.IsNullOrEmpty(data.zbtzs_url))
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.zbtzs_url;
|
fileInfo_List_Dto.fileNewName = "中标通知书";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.zbtzs_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.ht_url))
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.ht_url;
|
fileInfo_List_Dto.fileNewName = "合同";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.ht_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.ysbg_url))
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.ysbg_url;
|
fileInfo_List_Dto.fileNewName = "验收报告";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.ysbg_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.fkpz_url))
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.fkpz_url;
|
fileInfo_List_Dto.fileNewName = "付款凭证";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.fkpz_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.yhpj_url))
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.yhpj_url;
|
fileInfo_List_Dto.fileNewName = "用户评价";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.yhpj_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.hjzs_url))
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.hjzs_url;
|
fileInfo_List_Dto.fileNewName = "获奖证书";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.hjzs_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
}
|
|
|
|
return new JsonResult(list_Dtos);
|
}
|
else if (code == "006")
|
{
|
var data = await _shebeinengliService.GetByIdAsync(id);
|
List<FileInfo_List_Dto> list_Dtos = new List<FileInfo_List_Dto>();
|
if (data != null)
|
{
|
if (!string.IsNullOrEmpty(data.sbzp_url) && data.sbzp_fuhe > 0)
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.sbzp_url;
|
fileInfo_List_Dto.fileNewName = "设备照片";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.sbzp_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.gmht_url) && data.gmht_fuhe > 0)
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.gmht_url;
|
fileInfo_List_Dto.fileNewName = "购买合同";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.gmht_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.fp_url) && data.fp_fuhe > 0)
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.fp_url;
|
fileInfo_List_Dto.fileNewName = "发票";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.fp_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.fkpz_url) && data.fkpz_fuhe > 0)
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.fkpz_url;
|
fileInfo_List_Dto.fileNewName = "付款凭证";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.fkpz_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
|
if (!string.IsNullOrEmpty(data.csmp_url) && data.csmp_fuhe > 0)
|
{
|
FileInfo_List_Dto fileInfo_List_Dto = new FileInfo_List_Dto();
|
fileInfo_List_Dto.filePath = data.csmp_url;
|
fileInfo_List_Dto.fileNewName = "参数(铭牌)";
|
fileInfo_List_Dto.suffix = Path.GetExtension(data.csmp_url);
|
list_Dtos.Add(fileInfo_List_Dto);
|
}
|
}
|
|
|
|
return new JsonResult(list_Dtos);
|
}
|
else
|
{
|
var data = await _fileManageService.GetListAsync(c => c.status == 1 && c.doc_id == id);
|
|
var list = data.Select(c => new FileInfo_List_Dto(c)).OrderBy(c => c.sort).ToList();
|
|
return new JsonResult(list);
|
}
|
|
|
}
|
|
#endregion
|
|
#region 业绩管理
|
|
/// <summary>
|
/// 根据分页条件查询分页数据
|
/// </summary>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostAchievementListPage(DocumentPageSearch page)
|
{
|
PageResult<Achievement_List_Dto> result = new PageResult<Achievement_List_Dto>();
|
|
try
|
{
|
Expression<Func<Doc_Achievement, bool>> expression = t => true;
|
|
expression = expression.And(t => t.tenant_code == page.TenantID && t.status == 1);
|
if (page.ClassCode.HasValue)
|
{
|
expression = expression.And(t => t.classification_id == page.ClassCode);
|
}
|
if (!string.IsNullOrEmpty(page.Name))
|
{
|
expression = expression.And(t => t.achievement_name.Contains(page.Name));
|
}
|
if (page.zbtzs.HasValue)
|
{
|
if (page.zbtzs == 1)
|
{
|
expression = expression.And(t => t.zbtzs_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.zbtzs_url == null);
|
}
|
|
}
|
if (page.ht.HasValue)
|
{
|
if (page.ht == 1)
|
{
|
expression = expression.And(t => t.ht_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.ht_url == null);
|
}
|
|
}
|
|
if (page.ysbg.HasValue)
|
{
|
if (page.ysbg == 1)
|
{
|
expression = expression.And(t => t.ysbg_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.ysbg_url == null);
|
}
|
|
}
|
|
if (page.fkpz.HasValue)
|
{
|
if (page.fkpz == 1)
|
{
|
expression = expression.And(t => t.fkpz_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.fkpz_url == null);
|
}
|
|
}
|
|
if (page.yhpj.HasValue)
|
{
|
if (page.yhpj == 1)
|
{
|
expression = expression.And(t => t.yhpj_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.yhpj_url == null);
|
}
|
|
}
|
|
if (page.hjzs.HasValue)
|
{
|
if (page.hjzs == 1)
|
{
|
expression = expression.And(t => t.hjzs_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.hjzs_url == null);
|
}
|
|
}
|
|
RefAsync<int> total = 0;
|
var data = await _achievementService.Context.Queryable<Doc_Achievement>()
|
.Includes(c => c.DocClassification)
|
.Includes(c => c.DocProject)
|
.Where(expression)
|
.OrderBy(c => c.sort)
|
.ToPageListAsync(page.PageIndex, page.PageSize, total);
|
|
if (data != null && total > 0)
|
{
|
result.Items = data.Select(c => new Achievement_List_Dto()
|
{
|
add_time = c.add_time,
|
class_id=c.classification_id,
|
class_name = c.DocClassification?.doc_classification,
|
id = c.id,
|
project_id = c.project_id,
|
project_name = c.achievement_name,//c.DocProject?.ProjectName,
|
fkpz=c.fkpz_url,
|
hjzs=c.hjzs_url,
|
ht=c.ht_url,
|
yhpj=c.yhpj_url,
|
ysbg=c.ysbg_url,
|
zbtzs=c.zbtzs_url,
|
status = c.status,
|
sort = c.sort,
|
zb_time = c.zb_time.HasValue? c.zb_time.Value.ToString("yyyy/MM/dd") :"",
|
}).ToList();
|
|
}
|
result.PageIndex = page.PageIndex;
|
result.PageSize = page.PageSize;
|
result.TotalCount = total;
|
}
|
catch (Exception er)
|
{
|
Log.Error(er.Message, er);
|
}
|
|
return new JsonResult(result);
|
}
|
|
/// <summary>
|
/// 检查重复
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public async Task<bool> CheckDocAchievementDuplicate(Document_Submit_Dto model)
|
{
|
var msg = false;
|
var ck = await _achievementService.GetFirstAsync(c=>c.status==1 && c.tenant_code==model.tenant_id
|
&& c.achievement_name==model.name && c.classification_id== model.class_id);
|
if (ck != null)
|
{
|
if (model.id <= 0 || (model.id > 0 && model.id != ck.id))
|
{
|
msg = true;
|
}
|
else
|
{
|
msg = false;
|
}
|
|
}
|
return msg;
|
}
|
|
/// <summary>
|
/// 添加数据
|
/// </summary>
|
/// <param name="info"></param>
|
/// <returns></returns>
|
public async Task<bool> PostAddDocAchievement(Achievement_Submit_Dto info)
|
{
|
if (info.id > 0)
|
{
|
Doc_Achievement doc = new Doc_Achievement();
|
doc.id = info.id;
|
doc.add_time = DateTime.Now;
|
doc.classification_id = info.class_id;
|
doc.project_id = info.project_id;
|
doc.achievement_name = info.name;
|
|
doc.fkpz_url = info.fkpz;
|
doc.hjzs_url = info.hjzs;
|
doc.ht_url = info.ht;
|
doc.yhpj_url = info.yhpj;
|
doc.ysbg_url = info.ysbg;
|
doc.zbtzs_url = info.zbtzs;
|
|
doc.status = 1;
|
doc.tenant_code = info.tenant_id;
|
doc.sort = info.sort;
|
doc.zb_time = info.zb_time;
|
return await _achievementService.UpdateAsync(doc);
|
}
|
else
|
{
|
Doc_Achievement doc = new Doc_Achievement();
|
doc.add_time = DateTime.Now;
|
doc.classification_id = info.class_id;
|
doc.project_id = info.project_id;
|
doc.achievement_name = info.name;
|
|
doc.fkpz_url = info.fkpz;
|
doc.hjzs_url = info.hjzs;
|
doc.ht_url = info.ht;
|
doc.yhpj_url = info.yhpj;
|
doc.ysbg_url = info.ysbg;
|
doc.zbtzs_url = info.zbtzs;
|
|
doc.status = 1;
|
doc.tenant_code = info.tenant_id;
|
doc.sort = info.sort;
|
doc.zb_time = info.zb_time;
|
|
return await _achievementService.InsertAsync(doc);
|
}
|
|
}
|
|
|
|
/// <summary>
|
/// 删除文档数据
|
/// </summary>
|
/// <param name="doc"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostDelAchievement(Achievement_Submit_Dto doc)
|
{
|
bool msg = false;
|
var sss = new Doc_Achievement();
|
sss.id = doc.id;
|
|
msg = await _achievementService.DeleteAsync(sss);
|
return new JsonResult(msg);
|
}
|
|
|
/// <summary>
|
/// 根据文档号查询
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostAchievementInfo(DocumentSearch search)
|
{
|
var data = await _achievementService.GetFirstAsync(c => c.id == search.ID && c.tenant_code == search.TenantID);
|
if (data != null)
|
{
|
Achievement_Submit_Dto achievement_Submit_Dto = new Achievement_Submit_Dto();
|
achievement_Submit_Dto.id = data.id;
|
achievement_Submit_Dto.class_id = data.classification_id.Value;
|
//achievement_Submit_Dto.project_id = data.project_id.Value;
|
achievement_Submit_Dto.name = data.achievement_name;
|
achievement_Submit_Dto.zbtzs = data.zbtzs_url;
|
achievement_Submit_Dto.ht = data.ht_url;
|
achievement_Submit_Dto.ysbg = data.ysbg_url;
|
achievement_Submit_Dto.fkpz = data.fkpz_url;
|
achievement_Submit_Dto.yhpj = data.yhpj_url;
|
achievement_Submit_Dto.hjzs = data.hjzs_url;
|
achievement_Submit_Dto.tenant_id = data.tenant_code;
|
achievement_Submit_Dto.status = data.status;
|
achievement_Submit_Dto.sort = data.sort;
|
achievement_Submit_Dto.zb_time = data.zb_time;
|
|
|
return new JsonResult(achievement_Submit_Dto);
|
}
|
|
return null;
|
}
|
|
#endregion
|
|
|
|
#region 设备能力
|
|
/// <summary>
|
/// 根据分页条件查询分页数据
|
/// </summary>
|
/// <param name="page"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostShebeinengliListPage(DocumentPageSearch page)
|
{
|
PageResult<Achievement_List_Dto> result = new PageResult<Achievement_List_Dto>();
|
|
try
|
{
|
Expression<Func<Doc_Shebeinengli, bool>> expression = t => true;
|
|
expression = expression.And(t => t.tenant_code == page.TenantID && t.status == 1);
|
if (page.ClassCode.HasValue)
|
{
|
expression = expression.And(t => t.classification_id == page.ClassCode);
|
}
|
if (!string.IsNullOrEmpty(page.Name))
|
{
|
expression = expression.And(t => t.shebeinengli_name.Contains(page.Name));
|
}
|
if (page.sbzp.HasValue)
|
{
|
if (page.sbzp == 1)
|
{
|
expression = expression.And(t => t.sbzp_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.sbzp_url == null);
|
}
|
|
}
|
if (page.gmht.HasValue)
|
{
|
if (page.gmht == 1)
|
{
|
expression = expression.And(t => t.gmht_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.gmht_url == null);
|
}
|
|
}
|
|
if (page.fp.HasValue)
|
{
|
if (page.fp == 1)
|
{
|
expression = expression.And(t => t.fp_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.fp_url == null);
|
}
|
|
}
|
|
if (page.fkpz.HasValue)
|
{
|
if (page.fkpz == 1)
|
{
|
expression = expression.And(t => t.fkpz_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.fkpz_url == null);
|
}
|
|
}
|
|
if (page.csmp.HasValue)
|
{
|
if (page.csmp == 1)
|
{
|
expression = expression.And(t => t.csmp_url != null);
|
}
|
else
|
{
|
expression = expression.And(t => t.csmp_url == null);
|
}
|
|
}
|
|
|
|
RefAsync<int> total = 0;
|
var data = await _shebeinengliService.Context.Queryable<Doc_Shebeinengli>()
|
.Includes(c => c.DocClassification)
|
//.Includes(c => c.DocProject)
|
.Where(expression)
|
.OrderBy(c => c.sort)
|
.ToPageListAsync(page.PageIndex, page.PageSize, total);
|
|
if (data != null && total > 0)
|
{
|
result.Items = data.Select(c => new Achievement_List_Dto()
|
{
|
add_time = c.add_time,
|
class_id = c.classification_id,
|
class_name = c.DocClassification?.doc_classification,
|
id = c.id,
|
project_id = c.project_id,
|
project_name = c.shebeinengli_name,//c.DocProject?.ProjectName,
|
|
sbzp = c.sbzp_url,
|
gmht = c.gmht_url,
|
fp = c.fp_url,
|
fkpz = c.fkpz_url,
|
csmp = c.csmp_url,
|
status = c.status,
|
sort = c.sort,
|
zb_time = c.zb_time.HasValue ? c.zb_time.Value.ToString("yyyy/MM/dd") : "",
|
zige_code = (c.sbzp_zige.HasValue&& c.sbzp_zige >0 )
|
|| (c.gmht_zige.HasValue && c.gmht_zige > 0)
|
|| (c.fp_zige.HasValue && c.fp_zige > 0)
|
|| (c.fkpz_zige.HasValue && c.fkpz_zige > 0)
|
|| (c.csmp_zige.HasValue && c.csmp_zige > 0) ? 1:null,
|
}).ToList();
|
|
}
|
result.PageIndex = page.PageIndex;
|
result.PageSize = page.PageSize;
|
result.TotalCount = total;
|
}
|
catch (Exception er)
|
{
|
Log.Error(er.Message, er);
|
}
|
|
return new JsonResult(result);
|
}
|
|
/// <summary>
|
/// 检查重复
|
/// </summary>
|
/// <param name="model"></param>
|
/// <returns></returns>
|
public async Task<bool> CheckDocShebeinengliDuplicate(Document_Submit_Dto model)
|
{
|
var msg = false;
|
var ck = await _shebeinengliService.GetFirstAsync(c => c.status == 1 && c.tenant_code == model.tenant_id
|
&& c.shebeinengli_name == model.name && c.classification_id == model.class_id);
|
if (ck != null)
|
{
|
if (model.id <= 0 || (model.id > 0 && model.id != ck.id))
|
{
|
msg = true;
|
}
|
else
|
{
|
msg = false;
|
}
|
|
}
|
return msg;
|
}
|
|
/// <summary>
|
/// 添加数据
|
/// </summary>
|
/// <param name="info"></param>
|
/// <returns></returns>
|
public async Task<bool> PostAddDocShebeinengli(Achievement_Submit_Dto info)
|
{
|
if (info.id > 0)
|
{
|
Doc_Shebeinengli doc = new Doc_Shebeinengli();
|
doc.id = info.id;
|
doc.add_time = DateTime.Now;
|
doc.classification_id = info.class_id;
|
doc.project_id = info.project_id;
|
doc.shebeinengli_name = info.name;
|
|
|
doc.sbzp_url = info.sbzp;
|
doc.gmht_url = info.gmht;
|
doc.fp_url = info.fp;
|
doc.fkpz_url = info.fkpz;
|
doc.csmp_url = info.csmp;
|
|
doc.status = 1;
|
doc.tenant_code = info.tenant_id;
|
doc.sort = info.sort;
|
doc.zb_time = info.zb_time;
|
doc.zige_code = info.zige_code;
|
|
doc.sbzp_zige = info.sbzp_zige;
|
doc.gmht_zige = info.gmht_zige;
|
doc.fp_zige = info.fp_zige;
|
doc.fkpz_zige = info.fkpz_zige;
|
doc.csmp_zige = info.csmp_zige;
|
|
doc.sbzp_fuhe = info.sbzp_fuhe;
|
doc.gmht_fuhe = info.gmht_fuhe;
|
doc.fp_fuhe = info.fp_fuhe;
|
doc.fkpz_fuhe = info.fkpz_fuhe;
|
doc.csmp_fuhe = info.csmp_fuhe;
|
|
return await _shebeinengliService.UpdateAsync(doc);
|
}
|
else
|
{
|
Doc_Shebeinengli doc = new Doc_Shebeinengli();
|
doc.add_time = DateTime.Now;
|
doc.classification_id = info.class_id;
|
doc.project_id = info.project_id;
|
doc.shebeinengli_name = info.name;
|
|
doc.sbzp_url = info.sbzp;
|
doc.gmht_url = info.gmht;
|
doc.fp_url = info.fp;
|
doc.fkpz_url = info.fkpz;
|
doc.csmp_url = info.csmp;
|
|
doc.status = 1;
|
doc.tenant_code = info.tenant_id;
|
doc.sort = info.sort;
|
doc.zb_time = info.zb_time;
|
doc.zige_code = info.zige_code;
|
|
doc.sbzp_zige = info.sbzp_zige;
|
doc.gmht_zige = info.gmht_zige;
|
doc.fp_zige = info.fp_zige;
|
doc.fkpz_zige = info.fkpz_zige;
|
doc.csmp_zige = info.csmp_zige;
|
|
doc.sbzp_fuhe = info.sbzp_fuhe;
|
doc.gmht_fuhe = info.gmht_fuhe;
|
doc.fp_fuhe = info.fp_fuhe;
|
doc.fkpz_fuhe = info.fkpz_fuhe;
|
doc.csmp_fuhe = info.csmp_fuhe;
|
|
return await _shebeinengliService.InsertAsync(doc);
|
}
|
|
}
|
|
|
|
/// <summary>
|
/// 删除文档数据
|
/// </summary>
|
/// <param name="doc"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostDelShebeinengli(Achievement_Submit_Dto doc)
|
{
|
bool msg = false;
|
var sss = new Doc_Shebeinengli();
|
sss.id = doc.id;
|
|
msg = await _shebeinengliService.DeleteAsync(sss);
|
return new JsonResult(msg);
|
}
|
|
|
/// <summary>
|
/// 根据文档号查询
|
/// </summary>
|
/// <param name="search"></param>
|
/// <returns></returns>
|
public async Task<IActionResult> PostShebeinengliInfo(DocumentSearch search)
|
{
|
var data = await _shebeinengliService.GetFirstAsync(c => c.id == search.ID && c.tenant_code == search.TenantID);
|
if (data != null)
|
{
|
Achievement_Submit_Dto achievement_Submit_Dto = new Achievement_Submit_Dto();
|
achievement_Submit_Dto.id = data.id;
|
achievement_Submit_Dto.class_id = data.classification_id.Value;
|
//achievement_Submit_Dto.project_id = data.project_id.Value;
|
achievement_Submit_Dto.name = data.shebeinengli_name;
|
achievement_Submit_Dto.sbzp = data.sbzp_url;
|
achievement_Submit_Dto.gmht = data.gmht_url;
|
achievement_Submit_Dto.fp = data.fp_url;
|
achievement_Submit_Dto.fkpz = data.fkpz_url;
|
achievement_Submit_Dto.csmp = data.csmp_url;
|
achievement_Submit_Dto.tenant_id = data.tenant_code;
|
achievement_Submit_Dto.status = data.status;
|
achievement_Submit_Dto.sort = data.sort;
|
achievement_Submit_Dto.zb_time = data.zb_time;
|
achievement_Submit_Dto.zige_code = data.zige_code;
|
|
achievement_Submit_Dto.sbzp_zige = data.sbzp_zige;
|
achievement_Submit_Dto.gmht_zige = data.gmht_zige;
|
achievement_Submit_Dto.fp_zige = data.fp_zige;
|
achievement_Submit_Dto.fkpz_zige = data.fkpz_zige;
|
achievement_Submit_Dto.csmp_zige = data.csmp_zige;
|
|
achievement_Submit_Dto.sbzp_fuhe = data.sbzp_fuhe;
|
achievement_Submit_Dto.gmht_fuhe = data.gmht_fuhe;
|
achievement_Submit_Dto.fp_fuhe = data.fp_fuhe;
|
achievement_Submit_Dto.fkpz_fuhe = data.fkpz_fuhe;
|
achievement_Submit_Dto.csmp_fuhe = data.csmp_fuhe;
|
|
return new JsonResult(achievement_Submit_Dto);
|
}
|
|
return null;
|
}
|
|
#endregion
|
}
|
}
|