diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index 65d4215e..ff2bfac8 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -37,7 +37,7 @@ public static class DictConst /// 工单状态-强制接单 /// public const string MoCloseId = "25501969636645"; - + /// /// 工单状态 已下发字典Id @@ -71,7 +71,7 @@ public static class DictConst /// 任务单状态-待排产 /// public const string ToBeScheduledEncode = "ToBeScheduled"; - + #endregion @@ -86,5 +86,13 @@ public static class DictConst #region EqpMgr + /// + /// 模具保养TypeId + /// + public const string MaintainStatusTypeId = "26171564065301"; + /// + /// 保养状态待保养Code + /// + public const string UnMaintainStatusCode = "UnMaintain"; #endregion } \ No newline at end of file diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanCrInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanCrInput.cs new file mode 100644 index 00000000..cbc4ae56 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanCrInput.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + /// + /// 生成保养计划输入参数 + /// + public class MaintainPlanCrInput + { + /// + /// 规则id + /// + public string rule_id { get; set; } + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRuleMoldListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRuleMoldListOutput.cs index 4c5669bd..4d5917c6 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRuleMoldListOutput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainRuleMoldListOutput.cs @@ -23,5 +23,15 @@ namespace Tnb.EquipMgr.Entities.Dto /// 模具名称 /// public string mold_name { get; set; } + /// + /// 项目组Id + /// + public string item_group_id { get; set; } + /// + /// 项目名称 + /// + public string item_group_name { get; set; } + + } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldRuleSelectorListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldRuleSelectorListOutput.cs new file mode 100644 index 00000000..0ac562ab --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldRuleSelectorListOutput.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities.Dto +{ + /// + /// 模具规则选择列表输出类 + /// + public class MoldRuleSelectorListOutput + { + /// + /// 模具Id + /// + public string mold_id { get; set; } + /// + /// 模具编号 + /// + public string mold_code { get; set; } + /// + /// 模具名称 + /// + public string mold_name { get; set; } + /// + /// 项目组列表 + /// + public List groupItems { get; set; } + } + + public class MaintainItemGroupItem + { + /// + /// 保养项目组Id + /// + public string item_group_id { get; set; } + public string name { get; set; } + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldInput.cs index 9c2ea796..74cc333c 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldInput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RelevanceMoldInput.cs @@ -9,11 +9,33 @@ namespace Tnb.EquipMgr.Entities.Dto /// /// 模具规则定义,关键模具输入参数 /// - public class RelevanceMoldInput : BaseMoldMaintainInput + public class RelevanceMoldInput { /// /// 规则Id /// - public string? rule_id { get; set; } + public string rule_id { get; set; } + + /// + /// 行id 包含模具id,项目组Id + /// + public List rowIds { get; set; } + /// + /// 模具Ids + /// + public List ids { get; set; } + + } + + public class RowIdItem + { + /// + /// 模具id + /// + public string mold_id { get; set; } + /// + /// 项目组id + /// + public string group_id { get; set; } } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs new file mode 100644 index 00000000..0edddd10 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlan.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Entities +{ + using global::Tnb.Common.Contracts; + using JNPF.Common.Contracts; + using JNPF.Common.Security; + using SqlSugar; + + + /// + /// + /// + [SugarTable("tool_mold_maintain_plan")] + public partial class ToolMoldMaintainPlan : BaseEntity + { + public ToolMoldMaintainPlan() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 计划单号 + /// + public string? plan_code { get; set; } + + /// + /// 保养方式 + /// + public string? mode { get; set; } + + /// + /// 计划状态 + /// + public string? status { get; set; } + + /// + /// 计划开始时间 + /// + public DateTime? plan_start_date { get; set; } + + /// + /// 计划完成时间 + /// + public DateTime? plan_end_date { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 制定人 + /// + public string? create_id { get; set; } + + /// + /// 制定时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改人 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs new file mode 100644 index 00000000..1034816d --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainPlanRelation.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using JNPF.Common.Security; +using SqlSugar; +using Tnb.Common.Contracts; + +namespace Tnb.EquipMgr.Entities +{ + + /// + /// + /// + [SugarTable("tool_mold_maintain_plan_relation")] + public partial class ToolMoldMaintainPlanRelation : BaseEntity + { + public ToolMoldMaintainPlanRelation() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 保养计划id + /// + public string maintain_plan_id { get; set; } = string.Empty; + + /// + /// 模具Id + /// + public string mold_id { get; set; } = string.Empty; + + } + +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRuleRelation.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRuleRelation.cs index d2818d09..82dce3dd 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRuleRelation.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMoldMaintainRuleRelation.cs @@ -11,21 +11,25 @@ namespace Tnb.EquipMgr.Entities ///模具保养规则与模具关联 /// [SugarTable("tool_mold_maintain_rule_relation")] - public partial class ToolMoldMaintainRuleRelation:BaseEntity + public partial class ToolMoldMaintainRuleRelation : BaseEntity { - /// - /// Desc:保养规则id - /// Default: - /// Nullable:False - /// - public string rule_id {get;set;} = string.Empty; + /// + /// Desc:保养规则id + /// Default: + /// Nullable:False + /// + public string rule_id { get; set; } = string.Empty; - /// - /// Desc:模具id - /// Default: - /// Nullable:False - /// - public string mold_id {get;set;} = string.Empty; + /// + /// Desc:模具id + /// Default: + /// Nullable:False + /// + public string mold_id { get; set; } = string.Empty; + /// + /// 项目组id + /// + public string item_group_id { get; set; } = string.Empty; } } diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldMaintainPlanService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldMaintainPlanService.cs new file mode 100644 index 00000000..808506b2 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldMaintainPlanService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.EquipMgr.Interfaces +{ + public interface IToolMoldMaintainPlanService + { + } +} diff --git a/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs b/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs index 4b73b973..99d7a30a 100644 --- a/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs +++ b/EquipMgr/Tnb.EquipMgr/BaseMoldMaintainService.cs @@ -13,6 +13,7 @@ using Tnb.EquipMgr.Entities.Dto; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Utils; using Mapster; +using Tnb.Common.Extension; namespace Tnb.EquipMgr { @@ -47,18 +48,8 @@ namespace Tnb.EquipMgr var pk = id; TDest entity = new(); entity.id = SnowflakeIdHelper.NextId(); - if (!PropertySet.ValueFactories.TryGetValue(mColumnName, out Action? setGroupIdAction)) - { - setGroupIdAction = PropertySet.CreateSetPropertyValueAction(mColumnName); - PropertySet.ValueFactories.Add(mColumnName, setGroupIdAction); - } - setGroupIdAction(entity, input.item_group_id); - if (!PropertySet.ValueFactories.TryGetValue(name, out Action? setAction)) - { - setAction = PropertySet.CreateSetPropertyValueAction(name); - PropertySet.ValueFactories.Add(name, setAction); - } - setAction(entity, pk); + entity.PropertySetValue(mColumnName, input.item_group_id); + entity.PropertySetValue(name,pk); entities.Add(entity); } } diff --git a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj index b8cc1764..520c0756 100644 --- a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj +++ b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj @@ -9,6 +9,7 @@ + diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs new file mode 100644 index 00000000..e232378e --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.Common.Dtos.VisualDev; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.Logging; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData; +using Tnb.EquipMgr.Entities; +using Tnb.EquipMgr.Interfaces; + +namespace Tnb.EquipMgr +{ + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + [OverideVisualDev(ModuleId)] + public class ToolMoldMaintainPlanService : IOverideVisualDevService, IToolMoldMaintainPlanService, IDynamicApiController, ITransient + { + private const string ModuleId = "26165768858389"; + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public ToolMoldMaintainPlanService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + OverideFuncs.CreateAsync = Create; + + } + + private async Task Create(VisualDevModelDataCrInput visualDevModelDataCrInput) + { + try + { + visualDevModelDataCrInput.data[nameof(ToolMoldMaintainPlan.plan_code)] = $"JHDM{DateTime.Now:yyyyMMddmmss}"; + visualDevModelDataCrInput.data[nameof(ToolMoldMaintainPlan.status)] = DictConst.UnMaintainStatusCode; + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, visualDevModelDataCrInput); + } + catch (Exception ex) + { + Log.Error("新增时出错", ex); + } + return await Task.FromResult("ok"); + } + + + } +} diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs index e8719ebb..403f4f96 100644 --- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs +++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs @@ -3,17 +3,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Aop.Api.Domain; using Aspose.Cells.Drawing; using JNPF.Common.Core.Manager; using JNPF.Common.Enums; +using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Logging; using Mapster; using Microsoft.AspNetCore.Mvc; +using Microsoft.CodeAnalysis.CSharp.Syntax; using SqlSugar; +using Tnb.BasicData; using Tnb.EquipMgr.Entities; using Tnb.EquipMgr.Entities.Dto; +using Tnb.EquipMgr.Entities.Entity; using Tnb.EquipMgr.Interfaces; namespace Tnb.EquipMgr @@ -23,12 +29,14 @@ namespace Tnb.EquipMgr /// [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] [Route("api/[area]/[controller]/[action]")] - public class ToolMoldMaintainRuleService : BaseMoldMaintainService, IToolMoldMaintainRuleService, IDynamicApiController, ITransient + public class ToolMoldMaintainRuleService : IToolMoldMaintainRuleService, IDynamicApiController, ITransient { private readonly ISqlSugarClient _db; - public ToolMoldMaintainRuleService(ISqlSugarRepository repository) : base(repository.AsSugarClient()) + private readonly IUserManager _userManager; + public ToolMoldMaintainRuleService(ISqlSugarRepository repository, IUserManager userManager) { _db = repository.AsSugarClient(); + _userManager = userManager; } /// /// 根据规则Id获取匹配的模具列表 @@ -44,10 +52,33 @@ namespace Tnb.EquipMgr { var ids = list.Select(it => it.mold_id).ToList(); result = await _db.Queryable().Where(it => ids.Contains(it.id)) - .Select(it => new MaintainRuleMoldListOutput { mold_id = it.id }, true).ToListAsync(); + .Select(it => new MaintainRuleMoldListOutput { mold_id = it.id, item_group_id = list.First().item_group_id }, true) + .Mapper + ( + it => it.item_group_name = _db.Queryable().First(x => x.id == list.First().item_group_id).name! + ) + .ToListAsync(); } return result; } + /// + /// 获取模具选择列表 + /// + /// + [HttpGet] + public async Task GetMoldRuleSelectorList() + { + return await _db.Queryable().Select(it => new MoldRuleSelectorListOutput + { + mold_id = it.id, + }, true) + .Mapper(it => + { + var itemGroupIds = _db.Queryable().Where(x => x.mold_id == it.mold_id).Select(x => x.item_group_id).Distinct().ToList(); + it.groupItems = _db.Queryable().Where(x => itemGroupIds.Contains(x.id)).Select(x => new MaintainItemGroupItem { item_group_id = x.id, name = x.name }).ToList(); + }) + .ToListAsync(); + } /// /// 关联模具 @@ -56,8 +87,26 @@ namespace Tnb.EquipMgr /// /// [HttpPost] - public async Task RelevanceMold(RelevanceMoldInput input) => - await Relevance(input, nameof(ToolMoldMaintainRuleRelation.rule_id), nameof(ToolMoldMaintainRuleRelation.mold_id), it => it.rule_id == input.rule_id); + public async Task RelevanceMold(RelevanceMoldInput input) + { + if (input == null) throw new ArgumentNullException(nameof(input)); + if (input.rowIds?.Count > 0) + { + List entities = new(); + foreach (var item in input.rowIds) + { + ToolMoldMaintainRuleRelation entity = new(); + entity.id = SnowflakeIdHelper.NextId(); + entity.rule_id = input.rule_id; + entity.mold_id = item.mold_id; + entity.item_group_id = item.group_id; + + entities.Add(entity); + } + var row = await _db.Insertable(entities).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1000); + } + } /// /// 删除模具信息 /// @@ -66,8 +115,56 @@ namespace Tnb.EquipMgr [HttpPost] public async Task DeleteMoldRelevance(RelevanceMoldInput input) { - var row = await _db.Deleteable().Where(it => it.rule_id == input.rule_id && input.ids.Contains(it.mold_id)).ExecuteCommandAsync(); - if (row < 1) throw Oops.Oh(ErrorCode.COM1002); + if (input.ids?.Count > 0) + { + var row = await _db.Deleteable().Where(it => it.rule_id == input.rule_id && input.ids.Contains(it.mold_id)).ExecuteCommandAsync(); + if (row < 1) throw Oops.Oh(ErrorCode.COM1002); + } + } + /// + /// 生成模具保养计划 + /// + /// + [HttpPost] + public async Task GenMaintainPlan(MaintainPlanCrInput input) + { + if (input == null) throw new ArgumentNullException("input"); + + try + { + await _db.Ado.BeginTranAsync(); + + var maintainRule = await _db.Queryable().FirstAsync(it => it.id == input.rule_id); + if (maintainRule is not null) + { + if (maintainRule.cycle.HasValue && maintainRule.cycle.Value > 0) + { + ToolMoldMaintainPlan maintainPlan = new(); + maintainPlan.plan_code = $"JHDM{DateTime.Now:yyyyMMddmmss}"; + maintainPlan.mode = maintainRule.mode; + maintainPlan.status = DictConst.UnMaintainStatusCode; + maintainPlan.plan_start_date = DateTime.Now; + maintainPlan.plan_end_date = DateTime.Now.AddDays(maintainRule.cycle.Value); + maintainPlan.create_id = _userManager.UserId; + maintainPlan.create_time = DateTime.Now; + + await _db.Insertable(maintainPlan).ExecuteCommandAsync(); + + ToolMoldMaintainPlanRelation maintainPlanReation = new(); + maintainPlanReation.maintain_plan_id = maintainPlan.id; + maintainPlanReation.mold_id = (await _db.Queryable().FirstAsync(it => it.rule_id == maintainRule.id))?.mold_id!; + + await _db.Insertable(maintainPlanReation).ExecuteCommandAsync(); + + await _db.Ado.CommitTranAsync(); + } + } + } + catch (Exception ex) + { + Log.Error("生成保养计划失败", ex); + await _db.Ado.RollbackTranAsync(); + } } } } diff --git a/EquipMgr/Tnb.EquipMgr/Utils/PropertySet.cs b/EquipMgr/Tnb.EquipMgr/Utils/PropertySet.cs index 81464052..1ee63ccd 100644 --- a/EquipMgr/Tnb.EquipMgr/Utils/PropertySet.cs +++ b/EquipMgr/Tnb.EquipMgr/Utils/PropertySet.cs @@ -2,22 +2,22 @@ namespace Tnb.EquipMgr.Utils { - public class PropertySet - { - public static Dictionary> ValueFactories = new Dictionary>(StringComparer.OrdinalIgnoreCase); + //public class PropertySet + //{ + // public static Dictionary> ValueFactories = new Dictionary>(StringComparer.OrdinalIgnoreCase); - public static Action CreateSetPropertyValueAction(string propertyName) - { - var property = typeof(T).GetProperty(propertyName); - var target = Expression.Parameter(typeof(object)); - var propertyValue = Expression.Parameter(typeof(object)); - var castTarget = Expression.Convert(target, typeof(T)); - var castPropertyValue = Expression.Convert(propertyValue, property!.PropertyType); - var setPropertyValue = Expression.Call(castTarget, property.GetSetMethod()!, castPropertyValue); - return Expression.Lambda>(setPropertyValue, target, propertyValue).Compile(); - } + // public static Action CreateSetPropertyValueAction(string propertyName) + // { + // var property = typeof(T).GetProperty(propertyName); + // var target = Expression.Parameter(typeof(object)); + // var propertyValue = Expression.Parameter(typeof(object)); + // var castTarget = Expression.Convert(target, typeof(T)); + // var castPropertyValue = Expression.Convert(propertyValue, property!.PropertyType); + // var setPropertyValue = Expression.Call(castTarget, property.GetSetMethod()!, castPropertyValue); + // return Expression.Lambda>(setPropertyValue, target, propertyValue).Compile(); + // } - } + //} } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackPrdTaskUpInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackPrdTaskUpInput.cs new file mode 100644 index 00000000..f766406b --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackPrdTaskUpInput.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 组装、包装,生产任务修改输入参数 + /// + public class PackPrdTaskUpInput + { + /// + /// 生产任务id + /// + public string mo_task_id { get; set; } + /// + /// 产线Id + /// + public string workline_id { get; set; } + /// + /// 生产bomid + /// + public string bom_id { get; set; } + /// + /// Desc:预计开始时间 + /// Default: + /// Nullable:True + /// + public DateTime? estimated_start_date { get; set; } + + /// + /// Desc:预计结束时间 + /// Default: + /// Nullable:True + /// + public DateTime? estimated_end_date { get; set; } + /// + /// 已排产数量 + /// + public int scheduled_qty { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackScheldToBeIssueListInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackScheldToBeIssueListInput.cs new file mode 100644 index 00000000..f5d8e7aa --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackScheldToBeIssueListInput.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Entities.Dto.PrdManage +{ + /// + /// 组装、包装待下发列表输入参数 + /// + public class PackScheldToBeIssueListInput + { + /// + /// 生产任务单号 + /// + public string mo_task_code { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs index 972eb245..9eedff4b 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs @@ -25,6 +25,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// public string material_code { get; set; } /// + /// 产线id + /// + public string workline_id { get; set; } + /// /// 物料名称 /// public string material_name { get; set; } @@ -52,6 +56,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// 工序任务量 /// public int? process_task_qty { get; set; } + /// + /// bom_id + /// + public string bom_id { get; set; } + /// + /// bom版本 + /// + public string bom_version { get; set; } + /// + /// 预计开始时间 + /// + public DateTime? estimated_start_date { get; set; } + /// + /// 预计结束时间 + /// + public DateTime? estimated_end_date { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index 432953d1..bccd0a6f 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -241,26 +241,7 @@ namespace Tnb.ProductionMgr.Entities /// Nullable:True /// public int? process_task_qty { get; set; } - /// - /// 设备类型编码 - /// - [SugarColumn(IsIgnore = true)] - public string eqp_type_code { get; set; } - /// - /// 模具编号 - /// - [SugarColumn(IsIgnore = true)] - public string mold_code { get; set; } - /// - /// 模具名称 - /// - [SugarColumn(IsIgnore = true)] - public string mold_name { get; set; } - /// - /// 模具型腔数 - /// - [SugarColumn(IsIgnore = true)] - public int mold_cavity_qty { get; set; } + } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs new file mode 100644 index 00000000..3e6764db --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs @@ -0,0 +1,35 @@ +using System; +using System.Linq; +using System.Text; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities +{ + /// + ///生产任务信息 + /// + public partial class PrdMoTask + { + /// + /// 设备类型编码 + /// + [SugarColumn(IsIgnore = true)] + public string eqp_type_code { get; set; } + /// + /// 模具编号 + /// + [SugarColumn(IsIgnore = true)] + public string mold_code { get; set; } + /// + /// 模具名称 + /// + [SugarColumn(IsIgnore = true)] + public string mold_name { get; set; } + /// + /// 模具型腔数 + /// + [SugarColumn(IsIgnore = true)] + public int mold_cavity_qty { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskCopy1.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskCopy1.cs deleted file mode 100644 index d212749b..00000000 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskCopy1.cs +++ /dev/null @@ -1,83 +0,0 @@ -using System; -using System.Linq; -using System.Text; -using JNPF.Common.Security; -using SqlSugar; - -namespace Tnb.ProductionMgr.Entities -{ - /// - ///生产任务信息 - /// - [SugarTable("prd_mo_task_copy1")] - public partial class PrdMoTaskCopy1 - { - public PrdMoTaskCopy1(){ - - - } - /// - /// Desc:计划开始时间 - /// Default: - /// Nullable:True - /// - public DateTime? plan_start_date {get;set;} - - /// - /// Desc:计划结束时间 - /// Default: - /// Nullable:True - /// - public DateTime? plan_end_date {get;set;} - - /// - /// Desc:实际开工日期 - /// Default: - /// Nullable:True - /// - public DateTime? act_start_date {get;set;} - - /// - /// Desc:实际完工日期 - /// Default: - /// Nullable:True - /// - public DateTime? act_end_date {get;set;} - - /// - /// Desc:创建人 - /// Default: - /// Nullable:True - /// - public string? create_id {get;set;} - - /// - /// Desc:创建时间 - /// Default: - /// Nullable:True - /// - public DateTime? create_time {get;set;} - - /// - /// Desc:修改人 - /// Default: - /// Nullable:True - /// - public string? modify_id {get;set;} - - /// - /// Desc:修改时间 - /// Default: - /// Nullable:True - /// - public DateTime? modify_time {get;set;} - - /// - /// Desc:扩展字段 - /// Default: - /// Nullable:True - /// - public string? extras {get;set;} - - } -} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 3d3b7bb4..febdea50 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -76,11 +76,8 @@ namespace Tnb.ProductionMgr } - #region Get - - /// /// 根据产品ID获取模具列表 /// @@ -98,8 +95,6 @@ namespace Tnb.ProductionMgr ///
} ///
] /// - - [HttpGet("{materialId}")] public async Task GetMoldListByItemId(string materialId) { @@ -415,24 +410,31 @@ namespace Tnb.ProductionMgr /// /// [HttpGet] - public async Task GetPackScheldToBeIssueList() + public async Task GetPackScheldToBeIssueList([FromQuery] PackScheldToBeIssueListInput input) { var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); var result = await _db.Queryable().Where(it => it.schedule_type == 2) .LeftJoin((a, b) => a.material_id == b.id) .LeftJoin((a, b, c) => a.workline_id == c.Id) .LeftJoin((a, b, c, d) => a.mo_id == d.id) - .Select((a, b, c, d) => new PackSechelToBeIssueListOutput + .LeftJoin((a, b, c, d, e) => a.bom_id == e.id) + .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), (a, b, c, d, e) => a.mo_task_code.Contains(input.mo_task_code)) + .Select((a, b, c, d, e) => new PackSechelToBeIssueListOutput { mo_task_id = a.id, mo_task_code = a.mo_task_code, material_code = b.code, material_name = b.name, + workline_id = a.workline_id, workline_code = c.EnCode, workline_name = c.FullName, mo_task_status = a.mo_task_status, scheduled_qty = a.scheduled_qty, - plan_qty = d.plan_qty + plan_qty = d.plan_qty, + estimated_start_date = a.estimated_start_date, + estimated_end_date = a.estimated_end_date, + bom_id = e.id, + bom_version = e.version }) .Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "") .ToListAsync(); @@ -705,11 +707,11 @@ namespace Tnb.ProductionMgr } else { - var pos = taskCode.IndexOf("-", StringComparison.Ordinal); - if (pos > -1) + var pos = taskCode?.IndexOf("-", StringComparison.Ordinal); + if (pos.HasValue && pos.Value > -1) { - var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt(); - var code = taskCode.AsSpan().Slice(0, pos).ToString(); + var num = taskCode.AsSpan().Slice(pos.Value + 1).ToString().ParseToInt(); + var code = taskCode.AsSpan().Slice(0, pos.Value).ToString(); var n = (num + 1).ToString().PadLeft(2, '0'); moTask.mo_task_code = $"{code}-{n}"; } @@ -1083,6 +1085,26 @@ namespace Tnb.ProductionMgr }); return result.IsSuccess; } + /// + /// 修改组装、包装,生产任务信息 + /// + /// + /// + [HttpPost] + public async Task UpdatePackMoTask(PackPrdTaskUpInput input) + { + if (input == null) throw new ArgumentNullException("input"); + var row = await _db.Updateable().SetColumns(it => new PrdMoTask + { + workline_id = input.workline_id, + bom_id = input.bom_id, + estimated_start_date = input.estimated_start_date, + estimated_end_date = input.estimated_end_date, + scheduled_qty = input.scheduled_qty, + }) + .Where(it => it.id == input.mo_task_id).ExecuteCommandAsync(); + return row > 0; + } #endregion diff --git a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs new file mode 100644 index 00000000..838ec589 --- /dev/null +++ b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.Common.Extension +{ + public static class LambdaExpressionExtensions + { + public static void PropertySetValue(this T instance, string propertyName,string value) + { + if (!PropertySet.ValueFactories.TryGetValue(propertyName, out Action setAction)) + { + setAction = PropertySet.CreateSetPropertyValueAction(propertyName); + PropertySet.ValueFactories.Add(propertyName, setAction); + } + setAction(instance, value); + } + } + + public class PropertySet + { + public static Dictionary> ValueFactories = new Dictionary>(StringComparer.OrdinalIgnoreCase); + + public static Action CreateSetPropertyValueAction(string propertyName) + { + var property = typeof(T).GetProperty(propertyName); + var target = Expression.Parameter(typeof(object)); + var propertyValue = Expression.Parameter(typeof(object)); + var castTarget = Expression.Convert(target, typeof(T)); + var castPropertyValue = Expression.Convert(propertyValue, property!.PropertyType); + var setPropertyValue = Expression.Call(castTarget, property.GetSetMethod()!, castPropertyValue); + return Expression.Lambda>(setPropertyValue, target, propertyValue).Compile(); + } + + } +} diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs index fbce46ad..80e723b7 100644 --- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs +++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs @@ -17,7 +17,7 @@ namespace JNPF.TaskScheduler.Listener // _repository = repository; // } - [SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)] + //[SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)] public void GenerateSpotInspectionPlan(SpareTimer timer, long count) { Log.Information("----------------------开始生成点巡检计划----------------------");