From 9559165536397332a28d9ba096d10716617ff402 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Fri, 4 Aug 2023 15:10:14 +0800 Subject: [PATCH] 1 --- QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs | 16 ++++ QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs | 83 +++++++++++++++++++++ QcMgr/Tnb.QcMgr/QcCheckTaskService.cs | 59 ++++++++++++++- 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs diff --git a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs index a451bb01..cbe7eed4 100644 --- a/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs +++ b/QcMgr/Tnb.QcMgr.Entities/Dto/CheckTask.cs @@ -6,6 +6,22 @@ using System.Threading.Tasks; namespace Tnb.QcMgr.Entities.Dto { + public class QcCheckExecHOut + { + public string? id { get; set; } + public string? materialid { get; set; } + public string? checktype { get; set; } + public string? workid { get; set; } + public string? processid { get; set; } + public string? wareid { get; set; } + public string? checknum { get; set; } + public string? status { get; set; } + public string? result { get; set; } + public string? tasktime { get; set; } + public string? exectime { get; set; } + public string? execuser { get; set; } + + } public class CheckTaskOut { public string? mainid { get; set; } diff --git a/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs b/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs new file mode 100644 index 00000000..21c4a099 --- /dev/null +++ b/QcMgr/Tnb.QcMgr/QcCheckTaskResultService.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.Common.Core.Manager; +using JNPF.Common.Filter; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Systems.Entitys.Permission; +using JNPF.Systems.Entitys.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.QcMgr.Entities; +using Tnb.QcMgr.Entities.Dto; + +namespace Tnb.QcMgr +{ /// + /// 质检任务模块 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 800)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class QcCheckTaskResultServic:IDynamicApiController, ITransient, IOverideVisualDevService + { + private const string ModuleId = "26873741070613"; + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public QcCheckTaskResultServic(ISqlSugarRepository repository, IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + OverideFuncs.GetListAsync = GetListAsync; + } + private async Task GetListAsync(VisualDevModelListQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string materialid = queryJson.ContainsKey("materialid") ? queryJson["materialid"].ToString() : ""; + string checktype = queryJson.ContainsKey("checktype") ? queryJson["checktype"].ToString() : ""; + string status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : ""; + var list = await db.Queryable() + .LeftJoin((a, b) => a.DictionaryTypeId == b.Id) + .Where((a, b) => b.FullName == "质检状态" || b.FullName == "质检类型选择").ToListAsync(); + var result = await db.Queryable() + .LeftJoin((a, b) => a.materialid == b.id) + .LeftJoin((a, b, c) => a.processid == c.id) + .LeftJoin((a, b, c, d) => a.workid == d.Id) + .LeftJoin((a, b, c, d, e) => a.execuser == e.Id) + .WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d, e) => a.materialid == materialid) + .WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype) + .WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status) + .Where((a, b, c, d, e) => a.status == list.Where(p => p.FullName == "已完成").First().Id) + .Select((a, b, c, d, e) => new QcCheckExecHOut + { + id = a.id, + materialid = b.name, + checktype = a.checktype, + workid = d.FullName, + processid = c.process_name, + wareid = a.wareid, + checknum = a.checknum, + status = a.status, + result = a.result, + tasktime = a.tasktime == null ? "" : a.tasktime, + exectime = a.exectime == null ? "" : a.exectime, + execuser = e.RealName == null ? "" : e.RealName, + }).OrderByDescending(a => a.tasktime).ToPagedListAsync(input.currentPage, input.pageSize); + foreach (var item in result.list) + { + item.checktype = list.Select(p => p.Id).Contains(item.checktype) ? list.Where(p => p.Id == item.checktype).First().FullName : ""; + item.status = list.Select(p => p.Id).Contains(item.status) ? list.Where(p => p.Id == item.status).First().FullName : ""; + } + return PageResult.SqlSugarPageResult(result); + } + } +} diff --git a/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs b/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs index d18ec401..7d57caca 100644 --- a/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs +++ b/QcMgr/Tnb.QcMgr/QcCheckTaskService.cs @@ -1,11 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using Aspose.Cells.Drawing; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; +using JNPF.Common.Filter; using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; @@ -13,13 +15,22 @@ using JNPF.FriendlyException; using JNPF.JsonSerialization; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys.Dto.VisualDevModelData; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.BasicData; +using Tnb.EquipMgr.Entities; +using Tnb.ProductionMgr.Entities.Dto; +using Tnb.ProductionMgr.Entities; using Tnb.QcMgr.Entities; using Tnb.QcMgr.Entities.Dto; using Tnb.QcMgr.Entities.Entity; using Tnb.QcMgr.Interfaces; +using JNPF.Common.Extension; namespace Tnb.QcMgr { @@ -28,14 +39,60 @@ namespace Tnb.QcMgr /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 800)] [Route("api/[area]/[controller]/[action]")] - public class QcCheckTaskService : IQcCheckTaskService, IDynamicApiController, ITransient + [OverideVisualDev(ModuleId)] + public class QcCheckTaskService : IQcCheckTaskService, IDynamicApiController, ITransient, IOverideVisualDevService { + private const string ModuleId = "26745613138709"; private readonly ISqlSugarRepository _repository; private readonly IUserManager _userManager; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); public QcCheckTaskService(ISqlSugarRepository repository, IUserManager userManager) { _repository = repository; _userManager = userManager; + OverideFuncs.GetListAsync = GetListAsync; + } + + private async Task GetListAsync(VisualDevModelListQueryInput input) + { + var db = _repository.AsSugarClient(); + Dictionary queryJson = !string.IsNullOrEmpty(input.queryJson) ? JsonConvert.DeserializeObject>(input.queryJson) : new Dictionary(); + string materialid = queryJson.ContainsKey("materialid") ? queryJson["materialid"].ToString() : ""; + string checktype = queryJson.ContainsKey("checktype") ? queryJson["checktype"].ToString() : ""; + string status = queryJson.ContainsKey("status") ? queryJson["status"].ToString() : ""; + var list = await db.Queryable() + .LeftJoin((a, b) => a.DictionaryTypeId == b.Id) + .Where((a, b) => b.FullName == "质检状态" || b.FullName == "质检类型选择").ToListAsync(); + var result = await db.Queryable() + .LeftJoin((a, b) => a.materialid == b.id) + .LeftJoin((a, b, c) => a.processid == c.id) + .LeftJoin((a, b, c, d) => a.workid == d.Id) + .LeftJoin((a, b, c, d, e) => a.execuser == e.Id) + .WhereIF(!string.IsNullOrEmpty(materialid), (a, b, c, d, e) => a.materialid == materialid) + .WhereIF(!string.IsNullOrEmpty(checktype), (a, b, c, d, e) => a.checktype == checktype) + .WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d, e) => a.status == status) + .Where((a,b,c,d,e)=>a.status== list.Where(p=>p.FullName=="待执行").First().Id) + .Select((a, b, c, d, e) => new QcCheckExecHOut + { + id = a.id, + materialid = b.name, + checktype = a.checktype, + workid = d.FullName, + processid = c.process_name, + wareid = a.wareid, + checknum = a.checknum, + status = a.status, + result = a.result, + tasktime = a.tasktime == null ? "" : a.tasktime, + exectime = a.exectime == null ? "" : a.exectime, + execuser = e.RealName == null ? "" : e.RealName, + }).OrderByDescending(a => a.tasktime).ToPagedListAsync(input.currentPage, input.pageSize); + foreach (var item in result.list) + { + item.checktype = list.Select(p => p.Id).Contains(item.checktype) ? list.Where(p => p.Id == item.checktype).First().FullName : ""; + item.status = list.Select(p => p.Id).Contains(item.status) ? list.Where(p => p.Id == item.status).First().FullName : ""; + } + return PageResult.SqlSugarPageResult(result); } /// /// 获取任务执行明细