diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRefuseInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRefuseInput.cs new file mode 100644 index 00000000..3c30a548 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipRepairRefuseInput.cs @@ -0,0 +1,9 @@ +namespace Tnb.EquipMgr.Entities.Dto +{ + public class EquipRepairRefuseInput + { + public string id { get; set; } + public string reason { get; set; } + + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairRefuse.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairRefuse.cs new file mode 100644 index 00000000..098edb22 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairRefuse.cs @@ -0,0 +1,52 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities; + +/// +/// 设备维修拒绝表 +/// +[SugarTable("eqp_repair_refuse")] +public partial class EqpRepairRefuse : BaseEntity +{ + public EqpRepairRefuse() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 拒绝理由 + /// + public string reason { get; set; } = string.Empty; + + /// + /// 报修id + /// + public string repair_apply_id { get; set; } = string.Empty; + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairRefuseService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairRefuseService.cs new file mode 100644 index 00000000..b1417e66 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairRefuseService.cs @@ -0,0 +1,15 @@ +namespace Tnb.EquipMgr.Interfaces +{ + /// + /// 维修拒绝服务 + /// + public interface IEqpRepairRefuseService + { + /// + /// 根据维修id获取拒绝列表 + /// + /// + /// + public Task GetRepairRefuseByRepairApplyId(Dictionary dic); + } +} \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs b/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs index c16efefb..5b7dd85d 100644 --- a/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs +++ b/EquipMgr/Tnb.EquipMgr/EqpRepairApplyService.cs @@ -82,10 +82,25 @@ namespace Tnb.EquipMgr public async Task Refuse(Dictionary dic) { string id = dic["id"]; - await _repository.UpdateAsync(x => new EqpRepairApply() + string reason = dic["reason"]; + var db = _repository.AsSugarClient(); + DbResult result = await db.Ado.UseTranAsync(async () => { - status = RepairApplyStatus.REFUSE, - }, x => x.id == id); + await _repository.UpdateAsync(x => new EqpRepairApply() + { + status = RepairApplyStatus.REFUSE, + }, x => x.id == id); + EqpRepairRefuse eqpRepairRefuse = new EqpRepairRefuse() + { + repair_apply_id = id, + reason = reason, + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId + }; + await db.Insertable(eqpRepairRefuse).ExecuteCommandAsync(); + }); + if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008); return "拒绝成功"; } diff --git a/EquipMgr/Tnb.EquipMgr/EqpRepairRefuseService.cs b/EquipMgr/Tnb.EquipMgr/EqpRepairRefuseService.cs new file mode 100644 index 00000000..ffa74714 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/EqpRepairRefuseService.cs @@ -0,0 +1,36 @@ +using JNPF.Common.Core.Manager; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + /// + /// 设备维修拒绝 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class EqpRepairRefuseService : IEqpRepairRefuseService, IDynamicApiController, ITransient + { + private readonly ISqlSugarRepository _repository; + private readonly IUserManager _userManager; + + public EqpRepairRefuseService(ISqlSugarRepository repository, + IUserManager userManager) + { + _repository = repository; + _userManager = userManager; + } + + [HttpPost] + public async Task GetRepairRefuseByRepairApplyId(Dictionary dic) + { + string repairApplyId = dic["repairApplyId"]; + return await _repository.GetListAsync(x => x.repair_apply_id == repairApplyId); + } + } +} \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs index 5d32519b..99c5bcb4 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs @@ -14,5 +14,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 生产任务编号 /// public string mo_task_code { get; set; } + /// + /// 开始时间 + /// + public long[] estimated_start_date { get; set; } + /// + /// 结束时间 + /// + public long[] estimated_end_date { get; set; } + + /// + /// 产线 + /// + public string workline { get; set; } + /// + /// 工序 + /// + public string process { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 8d34e4f0..79fe64ea 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1070,8 +1070,7 @@ namespace Tnb.ProductionMgr record.masterial_name = material?.name; record.plan_start_date = taskInfo.estimated_start_date; record.plan_end_date = taskInfo.estimated_end_date; - // record.plan_qty = taskInfo.plan_qty; - record.plan_qty = taskInfo.scheduled_qty; + record.plan_qty = taskInfo.plan_qty; record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskInfo.eqp_id))?.code; record.mo_task_type = mo?.mo_type; record.status = taskInfo.mo_task_status; diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 7b3d309c..0699bd34 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -51,14 +51,35 @@ namespace Tnb.ProductionMgr if (input == null) throw new ArgumentNullException("input"); List trees = new(); var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync(); if (_dicWorkLine.Count < 1) { - var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync(); + _dicWorkLine = list.ToDictionary(x => x.Id, x => Tuple.Create(x.EnCode, x.FullName)); } + bool start = false; + bool end=false; + DateTime[] startTimes = new DateTime[2]; + DateTime[] endTimes = new DateTime[2]; + if (input.estimated_start_date != null && input.estimated_start_date.Count() == 2) + { + start=true; + startTimes[0] = GetDateTimeMilliseconds(input.estimated_start_date![0]); + startTimes[1] = GetDateTimeMilliseconds(input.estimated_start_date![1]); + } + if (input.estimated_end_date != null && input.estimated_end_date.Count() == 2) + { + end = true; + endTimes[0] = GetDateTimeMilliseconds(input.estimated_end_date![0]); + endTimes[1] = GetDateTimeMilliseconds(input.estimated_end_date![1]); + + } var items = await _db.Queryable().LeftJoin((a, b) => a.process_id == b.id).LeftJoin((a, b, c) => a.mo_id == c.id) .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code.Trim()) + .WhereIF(start, a => startTimes[0] <= a.estimated_start_date && startTimes[1] >= a.estimated_start_date) + .WhereIF(end, a => endTimes[0] <= a.estimated_end_date && endTimes[1] >= a.estimated_end_date) + .WhereIF(!string.IsNullOrEmpty(input.workline), a => list.Where(p => p.EnCode.Contains(input.workline) || p.FullName.Contains(input.workline)).Select(p => p.Id).ToList().Contains(a.workline_id!)) .Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled") .Select((a, b, c) => new PrdMoTask { @@ -101,6 +122,23 @@ namespace Tnb.ProductionMgr } } var treeList = trees.ToTree(); + if (!string.IsNullOrEmpty(input.process)) + { + foreach (var item in treeList) + { + bool flag = false; + if (item.process_id != null && item.process_id.Contains(input.process)) + flag = true; + if (item.children != null) + { + List childs = (List)(Object)item.children; + if (childs.Where(p => p.process_id.Contains(input.process)).Any()) + flag = true; + } + if (!flag) + treeList.Remove(item); + } + } SqlSugarPagedList pagedList = new() { list = treeList, @@ -113,15 +151,24 @@ namespace Tnb.ProductionMgr }; return PageResult.SqlSugarPageResult(pagedList); } + private static DateTime GetDateTimeMilliseconds(long timestamp) + { + long begtime = timestamp * 10000; + DateTime dt_1970 = new DateTime(1970, 1, 1, 8, 0, 0); + long tricks_1970 = dt_1970.Ticks;//1970年1月1日刻度 + long time_tricks = tricks_1970 + begtime;//日志日期刻度 + DateTime dt = new DateTime(time_tricks);//转化为DateTime + return dt; + } private async Task GetChild(string parentId, List nodes, Dictionary dic) { var items = await _db.Queryable() .LeftJoin((a, b) => a.process_id == b.id) .LeftJoin((a, b, c) => a.mo_id == c.id) - .LeftJoin((a,b,c,d)=>a.mbom_process_id==d.id) + .LeftJoin((a, b, c, d) => a.mbom_process_id == d.id) .Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled") - .OrderBy((a,b,c,d)=>d.ordinal) + .OrderBy((a, b, c, d) => d.ordinal) .Select((a, b, c) => new PrdMoTask { id = a.id, @@ -134,7 +181,7 @@ namespace Tnb.ProductionMgr plan_end_date = a.estimated_end_date, plan_qty = c.scheduled_qty, //complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty), - complete_qty = a.reported_work_qty+a.scrap_qty, + complete_qty = a.reported_work_qty + a.scrap_qty, mo_task_status = a.mo_task_status, }).ToListAsync(); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs index 1ad7ad01..2bb31058 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -278,7 +278,6 @@ namespace Tnb.ProductionMgr // reported_qty = a.reported_qty, // prd_qty = a.prd_qty, eqp_code = d.code, - mbom_process_id = a.mbom_process_id, }).FirstAsync(); return prdTask; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs index 7398487d..5143677d 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAFeedingService.cs @@ -61,11 +61,9 @@ namespace Tnb.WarehouseMgr /// /// /// - [HttpPost] - public async Task WmsPDAFeedingRecord(VisualDevModelDataCrInput input) + + private async Task WmsPDAFeedingRecord(VisualDevModelDataCrInput input) { - - var isOk = false; try {