异常开始结束带代码提交
This commit is contained in:
@@ -71,6 +71,14 @@ public static class DictConst
|
||||
/// 任务单状态-待排产
|
||||
/// </summary>
|
||||
public const string ToBeScheduledEncode = "ToBeScheduled";
|
||||
/// <summary>
|
||||
/// 模具维修状态码-待维修
|
||||
/// </summary>
|
||||
public const string MaintainStatusDWXCode = "DWX";
|
||||
/// <summary>
|
||||
/// 模具维修状态码-已完成
|
||||
/// </summary>
|
||||
public const string MaintainStatusYWCCode = "YWC";
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class BaseMoldMaintainInput
|
||||
{
|
||||
public string item_group_id { get; set; }
|
||||
public string id { get; set; }
|
||||
public List<string> ids { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
44
EquipMgr/Tnb.EquipMgr.Entities/Dto/ClosedownEndListOutput.cs
Normal file
44
EquipMgr/Tnb.EquipMgr.Entities/Dto/ClosedownEndListOutput.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class ClosedownEndListOutput
|
||||
{
|
||||
public string id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产场地
|
||||
/// </summary>
|
||||
public string workshop_name { get; set; }
|
||||
/// <summary>
|
||||
/// 停机原因
|
||||
/// </summary>
|
||||
public string reason { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 设备型号
|
||||
/// </summary>
|
||||
public string eqp_type_code { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人
|
||||
/// </summary>
|
||||
/// <param name=""></param>
|
||||
/// <returns></returns>
|
||||
public string operator_name { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
/// <summary>
|
||||
/// 停机开始时间
|
||||
/// </summary>
|
||||
public DateTime? closeddown_start_time { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,18 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 模具编码
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
public string? mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string mold_name { get;}
|
||||
public string? mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 库房编码
|
||||
/// </summary>
|
||||
public string? whcode { get; set; }
|
||||
/// <summary>
|
||||
/// 库位编码
|
||||
/// </summary>
|
||||
public string? location_code { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
23
EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainStatusUpInput.cs
Normal file
23
EquipMgr/Tnb.EquipMgr.Entities/Dto/MaintainStatusUpInput.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
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 MaintainStatusUpInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 维修任务单id数组
|
||||
/// </summary>
|
||||
public List<string> ids { get; set; }
|
||||
/// <summary>
|
||||
/// 维修单状态 DWX(待维修)、WXZ(维修中)、YWC(已维修)
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
}
|
||||
}
|
||||
20
EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainUpInput.cs
Normal file
20
EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainUpInput.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class MoldMaintainUpInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 维修任务Id数组
|
||||
/// </summary>
|
||||
public List<string> ids { get; set; }
|
||||
/// <summary>
|
||||
/// 维修状态
|
||||
/// </summary>
|
||||
public string status{ get; set; }
|
||||
}
|
||||
}
|
||||
@@ -183,5 +183,9 @@ public partial class EqpEquipment : BaseEntity<string>
|
||||
/// 模具Id
|
||||
/// </summary>
|
||||
public string? mold_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工位编码
|
||||
/// </summary>
|
||||
public string station_code { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 模具维修任务表
|
||||
/// </summary>
|
||||
[SugarTable("tool_mold_maintain_task")]
|
||||
public partial class ToolMoldMaintainTask : BaseEntity<string>
|
||||
{
|
||||
public ToolMoldMaintainTask()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 维修单号
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 模具id
|
||||
/// </summary>
|
||||
public string? mold_id { 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_strat_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维修结束时间
|
||||
/// </summary>
|
||||
public DateTime? modify_end_time { get; set; }
|
||||
/// <summary>
|
||||
/// 维修单状态
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
|
||||
}
|
||||
22
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.part.cs
Normal file
22
EquipMgr/Tnb.EquipMgr.Entities/Entity/ToolMolds.part.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 模具信息表
|
||||
/// </summary>
|
||||
public partial class ToolMolds
|
||||
{
|
||||
/// <summary>
|
||||
/// 库房编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string whcode { get; set; }
|
||||
/// <summary>
|
||||
/// 库位编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore =true)]
|
||||
public string location_code { get; set; }
|
||||
}
|
||||
24
EquipMgr/Tnb.EquipMgr.Entities/Enums/MaintainStatus.cs
Normal file
24
EquipMgr/Tnb.EquipMgr.Entities/Enums/MaintainStatus.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Enums
|
||||
{
|
||||
public enum MaintainStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 待维修
|
||||
/// </summary>
|
||||
DWX=1,
|
||||
/// <summary>
|
||||
/// 维修中
|
||||
/// </summary>
|
||||
WXZ=2,
|
||||
/// <summary>
|
||||
/// 已完成
|
||||
/// </summary>
|
||||
YWC=4,
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,9 @@ namespace Tnb.EquipMgr.Entities.Mapper
|
||||
.Map(dest => dest.item_id, src => src.id);
|
||||
config.ForType<ToolMolds, RelevanceMoldListOutput>()
|
||||
.Map(dest => dest.mold_id, src => src.id);
|
||||
config.ForType<ToolMolds, MaintainPlanMoldLstOutput>()
|
||||
.Map(dest => dest.mold_id, src => src.id);
|
||||
//.Map(dest=>dest.mold_name,src=>src.mold_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
16
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldHouseService.cs
Normal file
16
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldHouseService.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 目录库房服务接口
|
||||
/// </summary>
|
||||
public interface IToolMoldHouseService
|
||||
{
|
||||
Task<Dictionary<string, object>> GetHouseDictionary();
|
||||
}
|
||||
}
|
||||
16
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldLocationService.cs
Normal file
16
EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldLocationService.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具库位服务接口
|
||||
/// </summary>
|
||||
public interface IToolMoldLocationService
|
||||
{
|
||||
Task<Dictionary<string, object>> GetLocationDictionary();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具维修任务接口
|
||||
/// </summary>
|
||||
public interface IToolMoldMaintainTaskService
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建模具维修任务
|
||||
/// </summary>
|
||||
/// <param name="entity">维修任务记录 </param>
|
||||
/// <returns></returns>
|
||||
Task Create(ToolMoldMaintainTask entity);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
@@ -29,5 +31,22 @@ namespace Tnb.EquipMgr.Interfaces
|
||||
/// <param name="equipid"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> DetachData(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 获取列表根据传入的Id集合
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<List<ToolMolds>> GetListByIds(List<string> ids);
|
||||
/// <summary>
|
||||
/// 根据设备ID获取模具信息
|
||||
/// </summary>
|
||||
/// <param name="eqpId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<ToolMolds>> GetListByEqpId([FromRoute] string eqpId);
|
||||
/// <summary>
|
||||
/// 根据模具id获取模具信息
|
||||
/// </summary>
|
||||
/// <param name="moldId"></param>
|
||||
/// <returns></returns>
|
||||
Task<ToolMolds> GetListById(string moldId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Tnb.EquipMgr
|
||||
protected async Task Relevance<TSrc, TDest>(TSrc input, string mColumnName, string name, Expression<Func<TDest, bool>> deleleExp) where TDest : BaseEntity<string>, new()
|
||||
where TSrc : BaseMoldMaintainInput
|
||||
{
|
||||
await _db.Deleteable<TDest>().Where(deleleExp).ExecuteCommandAsync();
|
||||
if (input == null) throw new ArgumentNullException(nameof(input));
|
||||
await _db.Deleteable<TDest>().Where(deleleExp).ExecuteCommandAsync();
|
||||
var entities = new List<TDest>();
|
||||
if (input.ids?.Count > 0)
|
||||
{
|
||||
@@ -46,7 +46,7 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
var pk = id;
|
||||
TDest entity = new();
|
||||
entity.PropertySetValue(mColumnName, input.item_group_id);
|
||||
entity.PropertySetValue(mColumnName, input.id);
|
||||
entity.PropertySetValue(name, pk);
|
||||
entities.Add(entity);
|
||||
}
|
||||
|
||||
34
EquipMgr/Tnb.EquipMgr/ToolMoldHouseService.cs
Normal file
34
EquipMgr/Tnb.EquipMgr/ToolMoldHouseService.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.ClayObject.Extensions;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具库房服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldHouseService : IToolMoldHouseService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
public ToolMoldHouseService(ISqlSugarRepository<ToolWarehouse> repository)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
public async Task<Dictionary<string, object>> GetHouseDictionary()
|
||||
{
|
||||
return await _db.Queryable<ToolWarehouse>().ToDictionaryAsync(x => x.id, x => x.whcode);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs
Normal file
33
EquipMgr/Tnb.EquipMgr/ToolMoldLocationService.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具库位服务
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMoldLocationService : IToolMoldLocationService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
public ToolMoldLocationService(ISqlSugarRepository<ToolLocation> repository)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
public async Task<Dictionary<string, object>> GetLocationDictionary()
|
||||
{
|
||||
return await _db.Queryable<ToolLocation>().ToDictionaryAsync(x => x.id, x => x.location_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace Tnb.EquipMgr
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task RelevanceMaintianGroupAndItem(MoldMaintainGroupItemInput input) =>
|
||||
await Relevance<MoldMaintainGroupItemInput, ToolMoldMaintainGroupItem>(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.item_group_id);
|
||||
await Relevance<MoldMaintainGroupItemInput, ToolMoldMaintainGroupItem>(input, nameof(ToolMoldMaintainGroupItem.item_group_id), nameof(ToolMoldMaintainGroupItem.item_id), it => it.item_group_id == input.id);
|
||||
|
||||
/// <summary>
|
||||
/// 关联项目组与模具
|
||||
@@ -89,7 +89,7 @@ namespace Tnb.EquipMgr
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task RelevanceMaintianGroupAndMold(MoldMaintainGroupItemRelationInput input) =>
|
||||
await Relevance<MoldMaintainGroupItemRelationInput, ToolMoldMaintainGroupRelation>(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.item_group_id);
|
||||
await Relevance<MoldMaintainGroupItemRelationInput, ToolMoldMaintainGroupRelation>(input, nameof(ToolMoldMaintainGroupRelation.item_group_id), nameof(ToolMoldMaintainGroupRelation.mold_id), it => it.item_group_id == input.id);
|
||||
/// <summary>
|
||||
/// 删除项目组与模具检查项信息
|
||||
/// </summary>
|
||||
@@ -101,11 +101,11 @@ namespace Tnb.EquipMgr
|
||||
|
||||
if (input.table_name == "item")
|
||||
{
|
||||
await Delete<ToolMoldMaintainGroupItem>(it => it.item_group_id == input.item_group_id && input.ids.Contains(it.item_id));
|
||||
await Delete<ToolMoldMaintainGroupItem>(it => it.item_group_id == input.id && input.ids.Contains(it.item_id));
|
||||
}
|
||||
else
|
||||
{
|
||||
await Delete<ToolMoldMaintainGroupRelation>(it => it.item_group_id == input.item_group_id && input.ids.Contains(it.mold_id));
|
||||
await Delete<ToolMoldMaintainGroupRelation>(it => it.item_group_id == input.id && input.ids.Contains(it.mold_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,13 +5,16 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Logging;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Spire.Pdf.Widget;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
@@ -29,12 +32,29 @@ namespace Tnb.EquipMgr
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IToolMoldHouseService _moldHouseService;
|
||||
private readonly IToolMoldLocationService _moldLocationService;
|
||||
private readonly IToolMoldsService _moldService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public ToolMoldMaintainPlanService(ISqlSugarRepository<ToolMoldMaintainPlan> repository, IRunService runService, IVisualDevService visualDevService) : base(repository.AsSugarClient())
|
||||
|
||||
private static Dictionary<string, object> _dicHouse = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicLocation = new Dictionary<string, object>();
|
||||
|
||||
public ToolMoldMaintainPlanService(
|
||||
ISqlSugarRepository<ToolMoldMaintainPlan> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IToolMoldHouseService moldHouseService,
|
||||
IToolMoldLocationService moldLocationService,
|
||||
IToolMoldsService moldService
|
||||
) : base(repository.AsSugarClient())
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_moldHouseService = moldHouseService;
|
||||
_moldLocationService = moldLocationService;
|
||||
_moldService = moldService;
|
||||
OverideFuncs.CreateAsync = Create;
|
||||
|
||||
}
|
||||
@@ -54,20 +74,46 @@ namespace Tnb.EquipMgr
|
||||
}
|
||||
return await Task.FromResult("ok");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据规则id获取匹配的模具列表
|
||||
/// </summary>
|
||||
/// <param name="planId">计划Id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetMoldListByPlanId(RelevanceMoldFromPlanInput input)
|
||||
public async Task<dynamic> GetMoldListByPlanId([FromRoute] string planId)
|
||||
{
|
||||
var list = await _db.Queryable<ToolMoldMaintainPlanRelation>().Where(it => it.maintain_plan_id == input.item_group_id).ToListAsync();
|
||||
var result = new List<MaintainPlanMoldLstOutput>();
|
||||
if (_dicHouse.Count < 1)
|
||||
{
|
||||
_dicHouse = await _moldHouseService.GetHouseDictionary();
|
||||
}
|
||||
if (_dicLocation.Count < 1)
|
||||
{
|
||||
_dicLocation = await _moldLocationService.GetLocationDictionary();
|
||||
}
|
||||
var list = await _db.Queryable<ToolMoldMaintainPlanRelation>().Where(it => it.maintain_plan_id == planId).ToListAsync();
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
var ids = list.Select(it => it.mold_id).Distinct().ToList();
|
||||
if (ids?.Count > 0)
|
||||
{
|
||||
var items = await _moldService.GetListByIds(ids);
|
||||
_db.ThenMapper(items, it =>
|
||||
{
|
||||
if (!it.warehosue_id!.IsNullOrEmpty())
|
||||
{
|
||||
it.whcode = _dicHouse.ContainsKey(it.warehosue_id!) ? _dicHouse[it.warehosue_id!].ToString()! : "";
|
||||
}
|
||||
if (!it.location_id!.IsNullOrEmpty())
|
||||
{
|
||||
it.location_code = _dicLocation.ContainsKey(it.location_id!) ? _dicLocation[it.location_id!].ToString()! : "";
|
||||
}
|
||||
});
|
||||
|
||||
result = items.Adapt<List<MaintainPlanMoldLstOutput>>();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,15 +122,15 @@ namespace Tnb.EquipMgr
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task RelevanceMoldFromPlan(RelevanceMoldFromPlanInput input) =>
|
||||
await Relevance<RelevanceMoldFromPlanInput, ToolMoldMaintainPlanRelation>(input, nameof(ToolMoldMaintainPlanRelation.maintain_plan_id), nameof(ToolMoldMaintainPlanRelation.mold_id), it => it.maintain_plan_id == input.item_group_id);
|
||||
await Relevance<RelevanceMoldFromPlanInput, ToolMoldMaintainPlanRelation>(input, nameof(ToolMoldMaintainPlanRelation.maintain_plan_id), nameof(ToolMoldMaintainPlanRelation.mold_id), it => it.maintain_plan_id == input.id);
|
||||
/// <summary>
|
||||
/// 删除计划与模具关联关系
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="input">输入参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task DeleteMold(RelevanceMoldFromPlanInput input) =>
|
||||
await Delete<ToolMoldMaintainPlanRelation>(it => it.maintain_plan_id == input.item_group_id && input.ids.Contains(it.mold_id));
|
||||
await Delete<ToolMoldMaintainPlanRelation>(it => it.maintain_plan_id == input.id && input.ids.Contains(it.mold_id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
101
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainTaskService.cs
Normal file
101
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainTaskService.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Entities.Enums;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具维修任务接口
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class ToolMoldMaintainTaskService : IOverideVisualDevService, IToolMoldMaintainTaskService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26189001337381";
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private static Dictionary<string, (string code, string name)> _dicMold = new Dictionary<string, (string code, string name)>();
|
||||
public ToolMoldMaintainTaskService(
|
||||
ISqlSugarRepository<ToolMoldMaintainTask> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
if (_dicMold.Count < 1)
|
||||
{
|
||||
var items = await _db.Queryable<ToolMolds>().ToListAsync();
|
||||
_dicMold = items?.ToDictionary(x => x.id, x => (x.mold_code, x.mold_name))!;
|
||||
}
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list.Count > 0)
|
||||
{
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var pair = row[nameof(ToolMoldMaintainTask.mold_id)];
|
||||
if (pair.IsNotEmptyOrNull())
|
||||
{
|
||||
var multi = _dicMold[pair.ToString()!];
|
||||
row[nameof(ToolMoldMaintainTask.mold_id)] = $"{multi.code}/{multi.name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
|
||||
public async Task Create(ToolMoldMaintainTask entity)
|
||||
{
|
||||
var row = await _db.Insertable(entity).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
|
||||
}
|
||||
/// <summary>
|
||||
/// 修改任务单状态
|
||||
/// </summary>
|
||||
/// <param name="input">输入参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task UpdateStatus(MaintainStatusUpInput input)
|
||||
{
|
||||
DateTime? beginTiem = DateTime.Now;
|
||||
DateTime? endTime = null;
|
||||
if (input.status.ToEnum<MaintainStatus>() == MaintainStatus.YWC)
|
||||
{
|
||||
endTime = DateTime.Now;
|
||||
}
|
||||
var row = await _db.Updateable<ToolMoldMaintainTask>().SetColumns(it => new ToolMoldMaintainTask { status = input.status, modify_strat_time = beginTiem, modify_end_time = endTime })
|
||||
.Where(it => input.ids.Contains(it.id)).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,33 @@ namespace Tnb.EquipMgr
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取模具列表
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<List<ToolMolds>> GetListByIds(List<string> ids)
|
||||
{
|
||||
return await _repository.AsSugarClient().Queryable<ToolMolds>().Where(it => ids.Contains(it.id)).ToListAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据设备id 获取匹配的模具列表
|
||||
/// </summary>
|
||||
/// <param name="eqpId">设备Id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<List<ToolMolds>> GetListByEqpId([FromRoute] string eqpId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Queryable<ToolMolds>().InnerJoin<ToolMoldsEquipment>((a, b) => a.id == b.mold_id)
|
||||
.Where((a, b) => b.equipment_id == eqpId)
|
||||
.Select((a, b) => a)
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模具id获取设备集合
|
||||
/// </summary>
|
||||
@@ -51,11 +78,12 @@ namespace Tnb.EquipMgr
|
||||
.Select((a, b) => new EquipmentListOutput
|
||||
{
|
||||
id = a.id,
|
||||
eqp_code=a.code,
|
||||
eqp_name=a.name
|
||||
eqp_code = a.code,
|
||||
eqp_name = a.name
|
||||
}).ToListAsync();
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加模具设备绑定
|
||||
/// </summary>
|
||||
@@ -65,9 +93,9 @@ namespace Tnb.EquipMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SaveData(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var his= await _repository.AsSugarClient().Queryable<ToolMoldsEquipment>().ToListAsync();
|
||||
var his = await _repository.AsSugarClient().Queryable<ToolMoldsEquipment>().ToListAsync();
|
||||
var list = new List<ToolMoldsEquipment>();
|
||||
foreach (var equip in ToolMoldInput.equipid)
|
||||
{
|
||||
@@ -104,5 +132,10 @@ namespace Tnb.EquipMgr
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
public Task<ToolMolds> GetListById(string moldId)
|
||||
{
|
||||
return _repository.GetFirstAsync(it => it.id == moldId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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 CloseDownStartInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string eqp_id { get; set; }
|
||||
/// <summary>
|
||||
/// 停机类别
|
||||
/// </summary>
|
||||
public string category { get; set; }
|
||||
/// <summary>
|
||||
/// 停机原因
|
||||
/// </summary>
|
||||
public string reason { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据设备id 获取生产任务列表,输入参数
|
||||
/// </summary>
|
||||
public class PrdMoTaskFromEqpIdInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string eqp_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产状态
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarTable("prd_cancel_closedown")]
|
||||
public partial class PrdCancelClosedown : BaseEntity<string>
|
||||
{
|
||||
public PrdCancelClosedown()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 停机类别
|
||||
/// </summary>
|
||||
public string? catetory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 停机原因
|
||||
/// </summary>
|
||||
public string? reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string eqp_id { 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; }
|
||||
/// <summary>
|
||||
/// 停机开始时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_start_time { get; set; }
|
||||
/// <summary>
|
||||
/// 停机结束时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_end_time { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[SugarTable("prd_cancel_closedown_reason")]
|
||||
public partial class PrdCancelClosedownReason : BaseEntity<string>
|
||||
{
|
||||
public PrdCancelClosedownReason()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 停机类别字典id
|
||||
/// </summary>
|
||||
public string? category_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 停机原因编码
|
||||
/// </summary>
|
||||
public string? reason_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 停机原因
|
||||
/// </summary>
|
||||
public string? reason { 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,62 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 异常停机
|
||||
/// </summary>
|
||||
[SugarTable("prd_cancel_closedown_record")]
|
||||
public partial class PrdCancelClosedownRecord : BaseEntity<string>
|
||||
{
|
||||
public PrdCancelClosedownRecord()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 停机类别
|
||||
/// </summary>
|
||||
public string? catetory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 停机原因
|
||||
/// </summary>
|
||||
public string? reason { 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; }
|
||||
|
||||
/// <summary>
|
||||
/// 停机开始时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_start_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 停机结束时间
|
||||
/// </summary>
|
||||
public DateTime? closedown_end_time { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 异常停机服务接口
|
||||
/// </summary>
|
||||
public interface IPrdCancelCloseDownService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
@@ -11,5 +13,11 @@ namespace Tnb.ProductionMgr.Interfaces
|
||||
/// </summary>
|
||||
public interface IPrdMoTaskService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据设备Id获取生产任务
|
||||
/// </summary>
|
||||
/// <param name="eqpId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrdMoTask>> GetListByEqpId(string eqpId);
|
||||
}
|
||||
}
|
||||
|
||||
241
ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs
Normal file
241
ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs
Normal file
@@ -0,0 +1,241 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aop.Api.Domain;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 业务实现:生产管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
|
||||
public class PrdCancelCloseDownService : IPrdCancelCloseDownService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IToolMoldMaintainTaskService _maintainTaskService;
|
||||
private readonly IToolMoldsService _moldService;
|
||||
private readonly IPrdMoTaskService _prdMoTaskService;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
private static Dictionary<string, object> _dicWorkStationAndShopRelacion = new Dictionary<string, object>();
|
||||
private static Dictionary<string, object> _dicWorkShop = new Dictionary<string, object>();
|
||||
|
||||
|
||||
|
||||
public PrdCancelCloseDownService(
|
||||
ISqlSugarRepository<PrdCancelClosedown> repository,
|
||||
IPrdMoTaskService prdMoTaskService,
|
||||
IToolMoldsService moldsService,
|
||||
IToolMoldMaintainTaskService maintainTaskService,
|
||||
IUserManager userManager
|
||||
)
|
||||
{
|
||||
_prdMoTaskService = prdMoTaskService;
|
||||
_maintainTaskService = maintainTaskService;
|
||||
_moldService = moldsService;
|
||||
_userManager = userManager;
|
||||
_db = repository.AsSugarClient();
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据设备ID获取异常关机信息
|
||||
/// </summary>
|
||||
/// <param name="eqpId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetClosedownEndList([FromRoute] string eqpId)
|
||||
{
|
||||
if (_dicWorkShop.Count < 1)
|
||||
{
|
||||
var orgs = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workstation").ToListAsync();
|
||||
if (orgs?.Count > 0)
|
||||
{
|
||||
var shopIds = orgs.Select(x =>
|
||||
{
|
||||
var shopId = "";
|
||||
var orgTree = x.OrganizeIdTree.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (orgTree?.Length > 1)
|
||||
{
|
||||
shopId = orgTree[orgTree.Length - 2];
|
||||
_dicWorkStationAndShopRelacion[x.EnCode] = shopId;
|
||||
}
|
||||
return shopId;
|
||||
}).Where(x => !x.IsNullOrEmpty()).ToList();
|
||||
if (shopIds?.Count > 0)
|
||||
{
|
||||
_dicWorkShop = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "department" && shopIds.Contains(it.Id)).ToDictionaryAsync(x => x.Id, x => x.FullName);
|
||||
}
|
||||
}
|
||||
}
|
||||
var result = new List<ClosedownEndListOutput>();
|
||||
var closeDown = await _db.Queryable<PrdCancelClosedown>().FirstAsync(it => it.eqp_id == eqpId);
|
||||
if (closeDown != null)
|
||||
{
|
||||
if (!closeDown.reason.IsNullOrEmpty())
|
||||
{
|
||||
var eqp = await _db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||
EqpEquipType eqpTypeInfo = null;
|
||||
if (eqp != null)
|
||||
eqpTypeInfo = await _db.Queryable<EqpEquipType>().FirstAsync(it => it.id == eqp.equip_type_id);
|
||||
var reasonArr = closeDown.reason.Split(",");
|
||||
foreach (var reason in reasonArr)
|
||||
{
|
||||
ClosedownEndListOutput ot = new();
|
||||
if (eqp != null)
|
||||
{
|
||||
if (_dicWorkStationAndShopRelacion.ContainsKey(eqp.station_code))
|
||||
{
|
||||
var shopId = _dicWorkStationAndShopRelacion[eqp.station_code].ToString();
|
||||
ot.workshop_name = _dicWorkShop.ContainsKey(shopId) ? _dicWorkShop[shopId].ToString()! : "";
|
||||
}
|
||||
}
|
||||
ot.reason = reason;
|
||||
ot.eqp_code = eqp?.code;
|
||||
ot.eqp_type_code = eqpTypeInfo?.code;
|
||||
ot.operator_name = _userManager.RealName;
|
||||
ot.remark = closeDown.remark;
|
||||
ot.closeddown_start_time = closeDown.closedown_start_time;
|
||||
result.Add(ot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.Count < 1)
|
||||
{
|
||||
ClosedownEndListOutput output = new();
|
||||
result.Add(output);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异常停机-开始
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task CloseDownStart(CloseDownStartInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.eqp_id.IsNullOrWhiteSpace()) throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty");
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id);
|
||||
if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500);
|
||||
if (moTaskList.Count > 0)
|
||||
{
|
||||
var cancelCloseDown = input.Adapt<PrdCancelClosedown>();
|
||||
cancelCloseDown.id = SnowflakeIdHelper.NextId();
|
||||
cancelCloseDown.eqp_id = input.eqp_id;
|
||||
cancelCloseDown.create_id = _userManager.UserId;
|
||||
cancelCloseDown.create_time = DateTime.Now;
|
||||
cancelCloseDown.closedown_start_time = DateTime.Now;
|
||||
|
||||
await _db.Insertable(cancelCloseDown).ExecuteCommandAsync();
|
||||
var record = cancelCloseDown.Adapt<PrdCancelClosedownRecord>();
|
||||
await _db.Insertable(record).ExecuteCommandAsync();
|
||||
|
||||
var moldId = moTaskList.First().mold_id;
|
||||
if (!moldId.IsNullOrEmpty())
|
||||
{
|
||||
var mold = await _moldService.GetListById(moldId);
|
||||
var maintaindTask = new ToolMoldMaintainTask();
|
||||
maintaindTask.mold_id = moldId;
|
||||
maintaindTask.code = DictConst.MaintainStatusDWXCode;
|
||||
maintaindTask.create_id = _userManager.UserId;
|
||||
maintaindTask.create_time = DateTime.Now;
|
||||
|
||||
await _maintainTaskService.Create(maintaindTask);
|
||||
}
|
||||
}
|
||||
else throw Oops.Oh(ErrorCode.COM1001);
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("停机开始失败", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 停机结束
|
||||
/// </summary>
|
||||
/// <param name="maintainTaskId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task CloseDownEnd(CloseDownStartInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.eqp_id.IsNullOrWhiteSpace()) throw new ArgumentException($"parameter {nameof(input.eqp_id)} not be null or empty");
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var moTaskList = await _prdMoTaskService.GetListByEqpId(input.eqp_id);
|
||||
if (moTaskList?.Count > 1) throw new AppFriendlyException($"设备{input.eqp_id},目前有两条进行中的生产任务", 500);
|
||||
|
||||
var cancelCloseDown = input.Adapt<PrdCancelClosedown>();
|
||||
cancelCloseDown.id = SnowflakeIdHelper.NextId();
|
||||
cancelCloseDown.create_id = _userManager.UserId;
|
||||
cancelCloseDown.create_time = DateTime.Now;
|
||||
cancelCloseDown.closedown_start_time = DateTime.Now;
|
||||
|
||||
var row = await _db.Insertable(cancelCloseDown).ExecuteCommandAsync();
|
||||
|
||||
var moldId = moTaskList.First().mold_id;
|
||||
if (moldId.IsNullOrEmpty())
|
||||
{
|
||||
var mold = await _moldService.GetListById(moldId);
|
||||
var maintaindTask = new ToolMoldMaintainTask();
|
||||
maintaindTask.mold_id = moldId;
|
||||
maintaindTask.code = DictConst.MaintainStatusYWCCode;
|
||||
maintaindTask.create_id = _userManager.UserId;
|
||||
maintaindTask.create_time = DateTime.Now;
|
||||
|
||||
|
||||
await _maintainTaskService.Create(maintaindTask);
|
||||
}
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("停机开始失败", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
//var row = await _db.Updateable<ToolMoldMaintainTask>().SetColumns(c => new ToolMoldMaintainTask
|
||||
//{
|
||||
// status = DictConst.MaintainStatusDWXCode,
|
||||
// modify_id = _userManager.UserId,
|
||||
// modify_end_time = DateTime.Now,
|
||||
//})
|
||||
// .ExecuteCommandAsync();
|
||||
//if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1185,5 +1185,9 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<PrdMoTask>> GetListByEqpId(string eqpId)
|
||||
{
|
||||
return await _db.Queryable<PrdMoTask>().Where(it => it.eqp_id == eqpId && it.mo_task_status == DictConst.InProgressEnCode).ToListAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace JNPF.Common.Extension
|
||||
{
|
||||
public static class LambdaExpressionExtensions
|
||||
{
|
||||
public static void PropertySetValue<T>(this T instance, string propertyName,string value)
|
||||
public static void PropertySetValue<T>(this T instance, string propertyName, string value)
|
||||
{
|
||||
if (!PropertySet<T>.ValueFactories.TryGetValue(propertyName, out Action<object, object> setAction))
|
||||
{
|
||||
|
||||
@@ -455,17 +455,17 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra
|
||||
var eqpList = (jsonObj.Value<JArray>("roweqp"));
|
||||
var eqpIds = eqpList.Select(x => x.Value<string>("id")).ToList();
|
||||
|
||||
//isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
////工位与设备解绑操作
|
||||
//var eqpEntities = await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(it => it.station_code == input.enCode).ToListAsync();
|
||||
//if (eqpEntities?.Count > 0)
|
||||
//{
|
||||
// var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList();
|
||||
// if (unbindEqpIds?.Count > 0)
|
||||
// {
|
||||
// isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
// }
|
||||
//}
|
||||
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
//工位与设备解绑操作
|
||||
var eqpEntities = await _repository.AsSugarClient().Queryable<EqpEquipment>().Where(it => it.station_code == input.enCode).ToListAsync();
|
||||
if (eqpEntities?.Count > 0)
|
||||
{
|
||||
var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList();
|
||||
if (unbindEqpIds?.Count > 0)
|
||||
{
|
||||
isOK = await _repository.AsSugarClient().Updateable<EqpEquipment>().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
var processVal = jsonObj.GetValue("rowprocess");
|
||||
if (processVal is not null)
|
||||
|
||||
Reference in New Issue
Block a user