1
This commit is contained in:
@@ -37,7 +37,7 @@ public static class DictConst
|
||||
/// 工单状态-强制接单
|
||||
/// </summary>
|
||||
public const string MoCloseId = "25501969636645";
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 工单状态 已下发字典Id
|
||||
@@ -71,7 +71,7 @@ public static class DictConst
|
||||
/// 任务单状态-待排产
|
||||
/// </summary>
|
||||
public const string ToBeScheduledEncode = "ToBeScheduled";
|
||||
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
@@ -86,5 +86,13 @@ public static class DictConst
|
||||
|
||||
#region EqpMgr
|
||||
|
||||
/// <summary>
|
||||
/// 模具保养TypeId
|
||||
/// </summary>
|
||||
public const string MaintainStatusTypeId = "26171564065301";
|
||||
/// <summary>
|
||||
/// 保养状态待保养Code
|
||||
/// </summary>
|
||||
public const string UnMaintainStatusCode = "UnMaintain";
|
||||
#endregion
|
||||
}
|
||||
19
EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanCrInput.cs
Normal file
19
EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainPlanCrInput.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成保养计划输入参数
|
||||
/// </summary>
|
||||
public class MaintainPlanCrInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 规则id
|
||||
/// </summary>
|
||||
public string rule_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,15 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 项目组Id
|
||||
/// </summary>
|
||||
public string item_group_id { get; set; }
|
||||
/// <summary>
|
||||
/// 项目名称
|
||||
/// </summary>
|
||||
public string item_group_name { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具规则选择列表输出类
|
||||
/// </summary>
|
||||
public class MoldRuleSelectorListOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具Id
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 项目组列表
|
||||
/// </summary>
|
||||
public List<MaintainItemGroupItem> groupItems { get; set; }
|
||||
}
|
||||
|
||||
public class MaintainItemGroupItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 保养项目组Id
|
||||
/// </summary>
|
||||
public string item_group_id { get; set; }
|
||||
public string name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,11 +9,33 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 模具规则定义,关键模具输入参数
|
||||
/// </summary>
|
||||
public class RelevanceMoldInput : BaseMoldMaintainInput
|
||||
public class RelevanceMoldInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 规则Id
|
||||
/// </summary>
|
||||
public string? rule_id { get; set; }
|
||||
public string rule_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 行id 包含模具id,项目组Id
|
||||
/// </summary>
|
||||
public List<RowIdItem> rowIds { get; set; }
|
||||
/// <summary>
|
||||
/// 模具Ids
|
||||
/// </summary>
|
||||
public List<string> ids { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class RowIdItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具id
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
/// <summary>
|
||||
/// 项目组id
|
||||
/// </summary>
|
||||
public string group_id { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarTable("tool_mold_maintain_plan")]
|
||||
public partial class ToolMoldMaintainPlan : BaseEntity<string>
|
||||
{
|
||||
public ToolMoldMaintainPlan()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 计划单号
|
||||
/// </summary>
|
||||
public string? plan_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养方式
|
||||
/// </summary>
|
||||
public string? mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划状态
|
||||
/// </summary>
|
||||
public string? status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始时间
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划完成时间
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制定人
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 制定时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改人
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarTable("tool_mold_maintain_plan_relation")]
|
||||
public partial class ToolMoldMaintainPlanRelation : BaseEntity<string>
|
||||
{
|
||||
public ToolMoldMaintainPlanRelation()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 保养计划id
|
||||
/// </summary>
|
||||
public string maintain_plan_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 模具Id
|
||||
/// </summary>
|
||||
public string mold_id { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,21 +11,25 @@ namespace Tnb.EquipMgr.Entities
|
||||
///模具保养规则与模具关联
|
||||
///</summary>
|
||||
[SugarTable("tool_mold_maintain_rule_relation")]
|
||||
public partial class ToolMoldMaintainRuleRelation:BaseEntity<string>
|
||||
public partial class ToolMoldMaintainRuleRelation : BaseEntity<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:保养规则id
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string rule_id {get;set;} = string.Empty;
|
||||
/// <summary>
|
||||
/// Desc:保养规则id
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string rule_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具id
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mold_id {get;set;} = string.Empty;
|
||||
/// <summary>
|
||||
/// Desc:模具id
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mold_id { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 项目组id
|
||||
/// </summary>
|
||||
public string item_group_id { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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<TDest>.ValueFactories.TryGetValue(mColumnName, out Action<object, object>? setGroupIdAction))
|
||||
{
|
||||
setGroupIdAction = PropertySet<TDest>.CreateSetPropertyValueAction(mColumnName);
|
||||
PropertySet<TDest>.ValueFactories.Add(mColumnName, setGroupIdAction);
|
||||
}
|
||||
setGroupIdAction(entity, input.item_group_id);
|
||||
if (!PropertySet<TDest>.ValueFactories.TryGetValue(name, out Action<object, object>? setAction))
|
||||
{
|
||||
setAction = PropertySet<TDest>.CreateSetPropertyValueAction(name);
|
||||
PropertySet<TDest>.ValueFactories.Add(name, setAction);
|
||||
}
|
||||
setAction(entity, pk);
|
||||
entity.PropertySetValue<TDest>(mColumnName, input.item_group_id);
|
||||
entity.PropertySetValue<TDest>(name,pk);
|
||||
entities.Add(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
59
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs
Normal file
59
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainPlanService.cs
Normal file
@@ -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<ToolMoldMaintainPlan> repository, IRunService runService, IVisualDevService visualDevService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
|
||||
}
|
||||
|
||||
private async Task<dynamic> 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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// </summary>
|
||||
[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<ToolMoldMaintainRule> repository) : base(repository.AsSugarClient())
|
||||
private readonly IUserManager _userManager;
|
||||
public ToolMoldMaintainRuleService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据规则Id获取匹配的模具列表
|
||||
@@ -44,10 +52,33 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
var ids = list.Select(it => it.mold_id).ToList();
|
||||
result = await _db.Queryable<ToolMolds>().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<ToolMoldMaintainGroup>().First(x => x.id == list.First().item_group_id).name!
|
||||
)
|
||||
.ToListAsync();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取模具选择列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetMoldRuleSelectorList()
|
||||
{
|
||||
return await _db.Queryable<ToolMolds>().Select(it => new MoldRuleSelectorListOutput
|
||||
{
|
||||
mold_id = it.id,
|
||||
}, true)
|
||||
.Mapper(it =>
|
||||
{
|
||||
var itemGroupIds = _db.Queryable<ToolMoldMaintainGroupRelation>().Where(x => x.mold_id == it.mold_id).Select(x => x.item_group_id).Distinct().ToList();
|
||||
it.groupItems = _db.Queryable<ToolMoldMaintainGroup>().Where(x => itemGroupIds.Contains(x.id)).Select(x => new MaintainItemGroupItem { item_group_id = x.id, name = x.name }).ToList();
|
||||
})
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关联模具
|
||||
@@ -56,8 +87,26 @@ namespace Tnb.EquipMgr
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
[HttpPost]
|
||||
public async Task RelevanceMold(RelevanceMoldInput input) =>
|
||||
await Relevance<RelevanceMoldInput, ToolMoldMaintainRuleRelation>(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<ToolMoldMaintainRuleRelation> 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);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除模具信息
|
||||
/// </summary>
|
||||
@@ -66,8 +115,56 @@ namespace Tnb.EquipMgr
|
||||
[HttpPost]
|
||||
public async Task DeleteMoldRelevance(RelevanceMoldInput input)
|
||||
{
|
||||
var row = await _db.Deleteable<ToolMoldMaintainRuleRelation>().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<ToolMoldMaintainRuleRelation>().Where(it => it.rule_id == input.rule_id && input.ids.Contains(it.mold_id)).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1002);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成模具保养计划
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task GenMaintainPlan(MaintainPlanCrInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var maintainRule = await _db.Queryable<ToolMoldMaintainRule>().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<ToolMoldMaintainRuleRelation>().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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
namespace Tnb.EquipMgr.Utils
|
||||
{
|
||||
public class PropertySet<T>
|
||||
{
|
||||
public static Dictionary<string, Action<object, object>> ValueFactories = new Dictionary<string, Action<object, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
//public class PropertySet<T>
|
||||
//{
|
||||
// public static Dictionary<string, Action<object, object>> ValueFactories = new Dictionary<string, Action<object, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static Action<object, object> 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<Action<object, object>>(setPropertyValue, target, propertyValue).Compile();
|
||||
}
|
||||
// public static Action<object, object> 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<Action<object, object>>(setPropertyValue, target, propertyValue).Compile();
|
||||
// }
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装,生产任务修改输入参数
|
||||
/// </summary>
|
||||
public class PackPrdTaskUpInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务id
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产线Id
|
||||
/// </summary>
|
||||
public string workline_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产bomid
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:预计开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int scheduled_qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装待下发列表输入参数
|
||||
/// </summary>
|
||||
public class PackScheldToBeIssueListInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务单号
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// </summary>
|
||||
public string material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 产线id
|
||||
/// </summary>
|
||||
public string workline_id { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
@@ -52,6 +56,22 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 工序任务量
|
||||
/// </summary>
|
||||
public int? process_task_qty { get; set; }
|
||||
/// <summary>
|
||||
/// bom_id
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// bom版本
|
||||
/// </summary>
|
||||
public string bom_version { get; set; }
|
||||
/// <summary>
|
||||
/// 预计开始时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date { get; set; }
|
||||
/// <summary>
|
||||
/// 预计结束时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,26 +241,7 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? process_task_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 设备类型编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string eqp_type_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 模具型腔数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int mold_cavity_qty { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities
|
||||
{
|
||||
///<summary>
|
||||
///生产任务信息
|
||||
///</summary>
|
||||
public partial class PrdMoTask
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备类型编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string eqp_type_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 模具型腔数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int mold_cavity_qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities
|
||||
{
|
||||
///<summary>
|
||||
///生产任务信息
|
||||
///</summary>
|
||||
[SugarTable("prd_mo_task_copy1")]
|
||||
public partial class PrdMoTaskCopy1
|
||||
{
|
||||
public PrdMoTaskCopy1(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际开工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际完工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建人
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string? create_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改人
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string? modify_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string? extras {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -76,11 +76,8 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region Get
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据产品ID获取模具列表
|
||||
/// </summary>
|
||||
@@ -98,8 +95,6 @@ namespace Tnb.ProductionMgr
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
|
||||
|
||||
[HttpGet("{materialId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string materialId)
|
||||
{
|
||||
@@ -415,24 +410,31 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetPackScheldToBeIssueList()
|
||||
public async Task<dynamic> GetPackScheldToBeIssueList([FromQuery] PackScheldToBeIssueListInput input)
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var result = await _db.Queryable<PrdMoTask>().Where(it => it.schedule_type == 2)
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
||||
.LeftJoin<PrdMo>((a, b, c, d) => a.mo_id == d.id)
|
||||
.Select((a, b, c, d) => new PackSechelToBeIssueListOutput
|
||||
.LeftJoin<BasMbom>((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;
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改组装、包装,生产任务信息
|
||||
/// </summary>
|
||||
/// <param name="updateToObj"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> UpdatePackMoTask(PackPrdTaskUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
var row = await _db.Updateable<PrdMoTask>().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
|
||||
|
||||
|
||||
39
common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
Normal file
39
common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
Normal file
@@ -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<T>(this T instance, string propertyName,string value)
|
||||
{
|
||||
if (!PropertySet<T>.ValueFactories.TryGetValue(propertyName, out Action<object, object> setAction))
|
||||
{
|
||||
setAction = PropertySet<T>.CreateSetPropertyValueAction(propertyName);
|
||||
PropertySet<T>.ValueFactories.Add(propertyName, setAction);
|
||||
}
|
||||
setAction(instance, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class PropertySet<T>
|
||||
{
|
||||
public static Dictionary<string, Action<object, object>> ValueFactories = new Dictionary<string, Action<object, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static Action<object, object> 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<Action<object, object>>(setPropertyValue, target, propertyValue).Compile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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("----------------------开始生成点巡检计划----------------------");
|
||||
|
||||
Reference in New Issue
Block a user