重写模具保养
This commit is contained in:
@@ -100,16 +100,16 @@ namespace Tnb.EquipMgr
|
||||
.Mapper(a =>
|
||||
{
|
||||
a.status = a.status == "1" ? "待执行" : a.status == "2" ? "待复核" : "已完成";
|
||||
a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString(DbTimeFormat.SS);
|
||||
a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString(DbTimeFormat.SS);
|
||||
a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString(DbTimeFormat.SS);
|
||||
a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString(DbTimeFormat.SS);
|
||||
})
|
||||
.ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
var EqpMaintainRecordHs = await db.Queryable<EqpMaintainRecordH>().Where(p => list.list.Select(p => p.equip_id_id).ToList().Contains(p.equip_id)).ToListAsync();
|
||||
foreach (var data in list.list)
|
||||
{
|
||||
data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
data.last_execute_time = EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).Any() ? EqpMaintainRecordHs.Where(x => data.equip_id_id == x.equip_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString(DbTimeFormat.SS) : "";
|
||||
}
|
||||
return PageResult<EqpMaintainRecordListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
148
EquipMgr/Tnb.EquipMgr/ToolMaintainTemService.cs
Normal file
148
EquipMgr/Tnb.EquipMgr/ToolMaintainTemService.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
|
||||
namespace Tnb.MoldMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具保养检模板管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class ToolMaintainTemService : IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<ToolMaintainTemH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public ToolMaintainTemService(ISqlSugarRepository<ToolMaintainTemH> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模板id发布到设备
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public async Task<string> Publish(ToolTemPublishInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
ToolMaintainTemH ToolMaintainTemH = await _repository.GetSingleAsync(x => x.id == input.id);
|
||||
List<ToolMaintainTemD> ToolMaintainTemDs = await db.Queryable<ToolMaintainTemD>().Where(x => x.maintain_tem_id == input.id).ToListAsync();
|
||||
|
||||
if (input.moldIds != null && input.moldIds.Length > 0)
|
||||
{
|
||||
List<ToolMaintainTemMoldH> insertToolMaintainTemMoldHs = new();
|
||||
List<ToolMaintainTemMoldD> insertToolMaintainTemMoldDs = new();
|
||||
foreach (string moldId in input.moldIds)
|
||||
{
|
||||
string id = SnowflakeIdHelper.NextId();
|
||||
string code = $"{DateTime.Now.ToString("yyyyMMdd") + moldId}";
|
||||
ToolMaintainTemMoldH ToolMaintainTemMoldH = new()
|
||||
{
|
||||
id = id,
|
||||
code = code,
|
||||
name = ToolMaintainTemH.name + moldId,
|
||||
plan_cycle = ToolMaintainTemH.plan_cycle,
|
||||
plan_cycle_unit = ToolMaintainTemH.plan_cycle_unit,
|
||||
plan_run_notice = ToolMaintainTemH.plan_run_notice,
|
||||
plan_delay = ToolMaintainTemH.plan_delay,
|
||||
start_time = ToolMaintainTemH.start_time,
|
||||
is_start = ToolMaintainTemH.is_start.ToString(),
|
||||
is_repeat = ToolMaintainTemH.is_repeat.ToString(),
|
||||
is_send = ToolMaintainTemH.is_send,
|
||||
maintain_tem_id = input.id,
|
||||
mold_id = moldId,
|
||||
remark = ToolMaintainTemH.remark,
|
||||
plan_run_notice_unit = ToolMaintainTemH.plan_run_notice_unit,
|
||||
plan_delay_unit = ToolMaintainTemH.plan_delay_unit,
|
||||
repeat_post_info_user_id = ToolMaintainTemH.repeat_post_info_user_id,
|
||||
send_post_info_user_id = ToolMaintainTemH.send_post_info_user_id,
|
||||
send_post_id = ToolMaintainTemH.send_post_id,
|
||||
org_id = ToolMaintainTemH.org_id,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
duty_user_id= ToolMaintainTemH.duty_user_id,
|
||||
repeat_user_id= ToolMaintainTemH.repeat_user_id
|
||||
};
|
||||
insertToolMaintainTemMoldHs.Add(ToolMaintainTemMoldH);
|
||||
|
||||
if (ToolMaintainTemDs != null && ToolMaintainTemDs.Count > 0)
|
||||
{
|
||||
foreach (ToolMaintainTemD ToolMaintainTem in ToolMaintainTemDs)
|
||||
{
|
||||
ToolMaintainTemMoldD ToolMaintainTemMoldD = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
maintain_item_id = ToolMaintainTem.maintain_item_id,
|
||||
maintain_tem_mold_id = id,
|
||||
};
|
||||
insertToolMaintainTemMoldDs.Add(ToolMaintainTemMoldD);
|
||||
}
|
||||
}
|
||||
|
||||
ToolMaintainTemMoldH oldMaintainTemMoldH = await db.Queryable<ToolMaintainTemMoldH>().Where(x => x.maintain_tem_id == input.id && x.mold_id == moldId).FirstAsync();
|
||||
_ = await db.Deleteable<ToolMaintainTemMoldH>().Where(x => x.maintain_tem_id == input.id && x.mold_id == moldId).ExecuteCommandAsync();
|
||||
if (oldMaintainTemMoldH != null)
|
||||
{
|
||||
_ = await db.Deleteable<ToolMaintainTemMoldD>().Where(x => x.maintain_tem_mold_id == oldMaintainTemMoldH.id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
if (insertToolMaintainTemMoldHs != null && insertToolMaintainTemMoldHs.Count > 0)
|
||||
{
|
||||
_ = await db.Insertable(insertToolMaintainTemMoldHs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
if (insertToolMaintainTemMoldDs != null && insertToolMaintainTemMoldDs.Count > 0)
|
||||
{
|
||||
_ = await db.Insertable(insertToolMaintainTemMoldDs).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "发布成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task Stop(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await db.Updateable<ToolMaintainTemMoldH>()
|
||||
.SetColumns(x => x.is_start == "0")
|
||||
.Where(x => x.id == id)
|
||||
.ExecuteCommandAsync();
|
||||
List<string> ids = await _repository.AsSugarClient().Queryable<ToolMoldMaintainRecordH>()
|
||||
.Where(x => x.maintain_tem_mold_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED)
|
||||
.Select(x => x.id).ToListAsync();
|
||||
_ = await _repository.AsSugarClient().Deleteable<ToolMoldMaintainRecordH>()
|
||||
.Where(x => x.maintain_tem_mold_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync();
|
||||
|
||||
_ = await _repository.AsSugarClient().Deleteable<ToolMoldMaintainRecordD>()
|
||||
.Where(x => ids.Contains(x.maintain_record_id)).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
throw Oops.Oh(ErrorCode.COM1008);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
304
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs
Normal file
304
EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRecordService.cs
Normal file
@@ -0,0 +1,304 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
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 ToolMoldMaintainRecordService : IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "35902722254101";
|
||||
private readonly ISqlSugarRepository<ToolMoldMaintainRecordH> _repository;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public ToolMoldMaintainRecordService(ISqlSugarRepository<ToolMoldMaintainRecordH> repository,
|
||||
IRunService runService,
|
||||
IUserManager userManager,
|
||||
IVisualDevService visualDevService)
|
||||
{
|
||||
_repository = repository;
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_userManager = userManager;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
// OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
||||
}
|
||||
|
||||
private async Task<object> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = (input == null || string.IsNullOrEmpty(input.queryJson)) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string moldInfo = queryJson.ContainsKey("query_info") ? (queryJson["query_info"].ToString() ?? "") : "";
|
||||
string status = queryJson.ContainsKey("status") ? (queryJson["status"].ToString() ?? "") : "";
|
||||
DateTime? start_time = queryJson.ContainsKey("start_time") ? queryJson["start_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["start_time"]) : null;
|
||||
DateTime? end_time = queryJson.ContainsKey("end_time") ? queryJson["end_time"].ToString() == "" ? null : Convert.ToDateTime(queryJson["end_time"]) : null;
|
||||
|
||||
if (string.IsNullOrEmpty(input.sidx))
|
||||
{
|
||||
input.sidx = "a.create_time";
|
||||
input.sort = "desc";
|
||||
}
|
||||
else
|
||||
{
|
||||
input.sidx = "a." + input.sidx;
|
||||
}
|
||||
|
||||
SqlSugarPagedList<ToolMoldMaintainRecordListOutput> list = await db.Queryable<ToolMoldMaintainRecordH, ToolMolds, UserEntity, UserEntity>((a, b, c, d) => new object[]
|
||||
{
|
||||
JoinType.Left, a.mold_id == b.id,
|
||||
JoinType.Left, a.execute_user_id == c.Id,
|
||||
JoinType.Left, a.repeat_user_id == d.Id,
|
||||
})
|
||||
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c) => a.status == status)
|
||||
.WhereIF(!string.IsNullOrEmpty(moldInfo), (a, b, c) => b.mold_code.Contains(moldInfo) || b.mold_name.Contains(moldInfo))
|
||||
.WhereIF(status == "3" && start_time != null, a => a.execute_time >= start_time)
|
||||
.WhereIF(status == "3" && end_time != null, a => a.execute_time <= end_time)
|
||||
.OrderBy($"{input.sidx} {input.sort}")
|
||||
.Select((a, b, c, d) => new ToolMoldMaintainRecordListOutput
|
||||
{
|
||||
id = a.id,
|
||||
mold_id = b.mold_code + "/" + b.mold_name,
|
||||
mold_id_id = a.mold_id,
|
||||
status = a.status,
|
||||
result = a.result == "1" ? "合格" : "不合格",
|
||||
repeat_result = a.repeat_result == "1" ? "合格" : "不合格",
|
||||
date_create_time = a.create_time,
|
||||
date_execute_time = a.execute_time,
|
||||
date_repeat_time = a.repeat_time,
|
||||
execute_user_id = c.RealName,
|
||||
execute_user_id_id = a.execute_user_id,
|
||||
repeat_user_id = d.RealName,
|
||||
repeat_user_id_id = a.repeat_user_id,
|
||||
result_remark = a.result_remark,
|
||||
repeat_remark = a.repeat_remark,
|
||||
date_last_execute_time = SqlFunc.Subqueryable<ToolMoldMaintainRecordH>().Where(x => a.mold_id == x.mold_id && a.execute_time != null).OrderByDesc(x => x.execute_time).Select(x => x.execute_time)
|
||||
})
|
||||
.Mapper(a =>
|
||||
{
|
||||
a.status = a.status == "1" ? "待执行" : a.status == "2" ? "待复核" : "已完成";
|
||||
a.create_time = a.date_create_time == null ? "" : a.date_create_time.Value.ToString(DbTimeFormat.SS);
|
||||
a.execute_time = a.date_execute_time == null ? "" : a.date_execute_time.Value.ToString(DbTimeFormat.SS);
|
||||
a.repeat_time = a.date_repeat_time == null ? "" : a.date_repeat_time.Value.ToString(DbTimeFormat.SS);
|
||||
a.last_execute_time = a.date_last_execute_time == null ? "" : a.date_last_execute_time.Value.ToString(DbTimeFormat.SS);
|
||||
})
|
||||
.ToPagedListAsync(input?.currentPage ?? 1, input?.pageSize ?? 50);
|
||||
var ToolMoldMaintainRecordHs = await db.Queryable<ToolMoldMaintainRecordH>().Where(p => list.list.Select(p => p.mold_id_id).ToList().Contains(p.mold_id)).ToListAsync();
|
||||
foreach (var data in list.list)
|
||||
{
|
||||
data.last_execute_time = ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).Any() ? ToolMoldMaintainRecordHs.Where(x => data.mold_id_id == x.mold_id && x.execute_time != null).OrderByDescending(x => x.execute_time).FirstOrDefault()!.execute_time!.Value.ToString(DbTimeFormat.SS) : "";
|
||||
}
|
||||
return PageResult<ToolMoldMaintainRecordListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行模具保养计划
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ExecuteMaintain(SpotInsRecordExecuteInput input)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
ToolMoldMaintainRecordH eqpSpotInsRecordH = _repository.GetSingle(x => x.id == input.id);
|
||||
string status = eqpSpotInsRecordH.is_repeat == "1" ? SpotInsRecordExecutionStatus.TOBECHECK : SpotInsRecordExecutionStatus.COMPLETED;
|
||||
_ = await _repository.UpdateAsync(x => new ToolMoldMaintainRecordH()
|
||||
{
|
||||
result = input.result,
|
||||
attachment = input.attachment,
|
||||
result_remark = input.result_remark,
|
||||
status = status,
|
||||
execute_time = DateTime.Now,
|
||||
execute_user_id = _userManager.UserId
|
||||
}, x => x.id == input.id);
|
||||
|
||||
if (input != null && input.details != null)
|
||||
{
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
_ = await _repository.AsSugarClient().Updateable<ToolMoldMaintainRecordD>()
|
||||
.SetColumns(x => x.result == item["result"])
|
||||
.SetColumnsIF(item.ContainsKey("maintain_descrip"), x => x.maintain_descrip == item["maintain_descrip"])
|
||||
.Where(x => x.id == item["id"])
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : (dynamic)(result.IsSuccess ? "执行成功" : result.ErrorMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取模具保养计划复核信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ToolMoldMaintainRecordRepeatOutput> GetMaintainRecordRepeatInfo(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
ToolMoldMaintainRecordH eqpSpotInsRecordH = await _repository.GetSingleAsync(x => x.id == id);
|
||||
ToolMolds toolMolds = await _repository.AsSugarClient().Queryable<ToolMolds>().SingleAsync(x=>x.id==eqpSpotInsRecordH.mold_id);
|
||||
List<ToolMoldMaintainRecordD> eqpSpotInsRecordDs = await _repository.AsSugarClient().Queryable<ToolMoldMaintainRecordD>()
|
||||
.Where(x => x.maintain_record_id == id).ToListAsync();
|
||||
Dictionary<string, object> typeDic = await _repository.AsSugarClient().Queryable<DictionaryTypeEntity>()
|
||||
.LeftJoin<DictionaryDataEntity>((a, b) => a.Id == b.DictionaryTypeId)
|
||||
.Where((a, b) => a.EnCode == DictConst.EqpMaintainType)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
b.EnCode,
|
||||
b.FullName
|
||||
})
|
||||
.MergeTable()
|
||||
.ToDictionaryAsync(it => it.EnCode, it => it.FullName);
|
||||
eqpSpotInsRecordDs.ForEach(x =>
|
||||
{
|
||||
x.maintain_type = typeDic.ContainsKey(x.maintain_type) ? typeDic[x.maintain_type] + "" : x.maintain_type;
|
||||
});
|
||||
// eqpSpotInsRecordH.mold_id = (toolMolds?.mold_code ?? "") + "/" + (toolMolds?.mold_name ?? "");
|
||||
ToolMoldMaintainRecordRepeatOutput output = new()
|
||||
{
|
||||
model = eqpSpotInsRecordH,
|
||||
details = eqpSpotInsRecordDs,
|
||||
};
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复核模具保养计划
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<string> RepeatMaintain(MaintainRecordRepeatInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
ToolMoldMaintainRecordH toolMoldMaintainRecordH = await _repository.GetSingleAsync(x => x.id == input.id);
|
||||
if (toolMoldMaintainRecordH.status == "1")
|
||||
{
|
||||
throw Oops.Bah("状态错误");
|
||||
}
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
|
||||
if (input != null && input.details != null)
|
||||
{
|
||||
foreach (Dictionary<string, string> item in input.details)
|
||||
{
|
||||
_ = await db.Updateable<ToolMoldMaintainRecordD>()
|
||||
.SetColumnsIF(item.ContainsKey("repeat_descrip"), x => x.repeat_descrip == item["repeat_descrip"])
|
||||
.SetColumns(x => x.repeat_result == item["repeat_result"])
|
||||
.Where(x => x.id == item["id"]).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
if (input != null)
|
||||
{
|
||||
_ = await _repository.UpdateAsync(x => new ToolMoldMaintainRecordH()
|
||||
{
|
||||
fhattachment=input.attachment,
|
||||
repeat_result = input.repeat_result,
|
||||
repeat_remark = input.repeat_remark,
|
||||
repeat_user_id = _userManager.UserId,
|
||||
repeat_time = DateTime.Now,
|
||||
status = SpotInsRecordExecutionStatus.COMPLETED
|
||||
}, x => x.id == input.id);
|
||||
}
|
||||
});
|
||||
|
||||
return !result.IsSuccess ? throw Oops.Oh(ErrorCode.COM1008) : result.IsSuccess ? "复核成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetMaintainRecordList(EquipQueryInput input)
|
||||
{
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
Dictionary<string, string>? queryJson = new();
|
||||
if (!string.IsNullOrEmpty(input.queryJson))
|
||||
{
|
||||
queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input.queryJson);
|
||||
}
|
||||
SqlSugarPagedList<EquipMaintainRecordQueryOutput> result = await db.Queryable<ToolMoldMaintainRecordH>()
|
||||
.LeftJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.LeftJoin<UserEntity>((a, b, c) => a.execute_user_id == c.Id)
|
||||
.LeftJoin<UserEntity>((a, b, c, d) => a.repeat_user_id == d.Id)
|
||||
.Where(a => a.mold_id == input.mold_id)
|
||||
.Select((a, b, c, d) => new EquipMaintainRecordQueryOutput
|
||||
{
|
||||
id = a.id,
|
||||
attachment = a.attachment,
|
||||
fhattachment= a.fhattachment,
|
||||
create_time = a.create_time == null ? null : a.create_time.Value.ToString(DbTimeFormat.MM),
|
||||
mold_id = b.mold_code,
|
||||
mold_id_id = a.mold_id,
|
||||
repeat_remark = a.repeat_remark,
|
||||
repeat_result = a.repeat_result == "1" ? "合格" : "不合格",
|
||||
repeat_time = a.repeat_time == null ? null : a.repeat_time.Value.ToString(DbTimeFormat.MM),
|
||||
repeat_user_id = d.RealName,
|
||||
result = a.result == "1" ? "合格" : "不合格",
|
||||
result_remark = a.result_remark,
|
||||
maintain_tem_equip_id = a.maintain_tem_mold_id,
|
||||
execute_time = a.execute_time == null ? null : a.execute_time.Value.ToString(DbTimeFormat.MM),
|
||||
execute_user_id = c.RealName,
|
||||
status = SqlFunc.IF(a.status.Equals("1")).Return("待执行").ElseIF(a.status.Equals("2")).Return("待复核").ElseIF(a.status.Equals("3")).Return("已完成").End("")
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
|
||||
return PageResult<EquipMaintainRecordQueryOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取保养相关信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic?> GetEqpMaintainRecordInfoById(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic.ContainsKey("id") ? dic["id"] : "";
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
return await db.Queryable<ToolMoldMaintainRecordH>()
|
||||
.LeftJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.Where((a, b) => a.id == id)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
a.id,
|
||||
a.mold_id,
|
||||
mold_code = b.mold_code,
|
||||
mold_name = b.mold_name,
|
||||
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
a.result_remark,
|
||||
a.result,
|
||||
a.status,
|
||||
}).FirstAsync();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,6 +60,7 @@ namespace Tnb.EquipMgr
|
||||
ToolMoldMaintainRule toolMoldMaintainRule = new()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
name = input.data["name"].ToString(),
|
||||
mode = input.data["mode"].ToString(),
|
||||
cycle = cycle,
|
||||
startandend_date = startTime.ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
@@ -9,7 +10,11 @@ using JNPF.Logging;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using JNPF.Systems.Entitys.System;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using StackExchange.Profiling.Internal;
|
||||
using Tnb.BasicData;
|
||||
@@ -25,18 +30,71 @@ namespace Tnb.EquipMgr
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
|
||||
public class ToolMoldMaintainPlanRunService : IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class ToolMoldMaintainPlanRunService : IOverideVisualDevService,IToolMoldMaintainPlanRunService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "26186915586085";
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
public ToolMoldMaintainPlanRunService(ISqlSugarRepository<ToolMoldMaintainRule> repository, IUserManager userManager, IDictionaryDataService dictionaryDataService)
|
||||
public ToolMoldMaintainPlanRunService(ISqlSugarRepository<ToolMoldMaintainRule> repository,
|
||||
IUserManager userManager,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService,
|
||||
IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
_userManager = userManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产bom列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
Dictionary<string, object> queryJson = string.IsNullOrEmpty(input.queryJson) ? new Dictionary<string, object>() : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string planCode = queryJson.GetValueOrDefault("plan_code", "").ToString();
|
||||
string status = queryJson.GetValueOrDefault("status", "").ToString();
|
||||
DateTime[] planStartDateArr = queryJson.ContainsKey("plan_start_date") ? queryJson["plan_start_date"].ToObject<long[]>().Select(x => DateTimeOffset.FromUnixTimeSeconds(x / 1000).ToLocalTime().DateTime).ToArray() : null;
|
||||
DateTime[] planEndDateArr = queryJson.ContainsKey("plan_end_date") ? queryJson["plan_end_date"].ToObject<long[]>().Select(x => DateTimeOffset.FromUnixTimeSeconds(x / 1000).ToLocalTime().DateTime).ToArray() : null;
|
||||
SqlSugarPagedList<ToolMoldMaintainPlanRunListOutput> list = await _db.Queryable<ToolMoldMaintainPlan, DictionaryDataEntity, UserEntity,DictionaryDataEntity,UserEntity>((a, b, c, d,e) => new object[]
|
||||
{
|
||||
JoinType.Left, a.mode == b.Id,
|
||||
JoinType.Left, a.create_id == c.Id,
|
||||
JoinType.Left,a.status==d.EnCode && d.DictionaryTypeId==DictConst.MaintainStatusTypeId,
|
||||
JoinType.Left, a.starter_id == e.Id,
|
||||
})
|
||||
.WhereIF(!string.IsNullOrEmpty(planCode), (a, b, c, d) => a.plan_code.Contains(planCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(status), (a, b, c, d) => a.status==status)
|
||||
.WhereIF(planStartDateArr!=null,(a, b, c, d) =>a.plan_start_date>=planStartDateArr[0] && a.plan_start_date<=planStartDateArr[1])
|
||||
.WhereIF(planEndDateArr!=null,(a, b, c, d) =>a.plan_end_date>=planEndDateArr[0] && a.plan_end_date<=planEndDateArr[1])
|
||||
.Select((a, b, c, d,e) => new ToolMoldMaintainPlanRunListOutput
|
||||
{
|
||||
id = a.id,
|
||||
plan_code = a.plan_code,
|
||||
mode = b.FullName,
|
||||
status = d.FullName,
|
||||
create_id = c.RealName,
|
||||
create_time = a.create_time == null ? "" : a.create_time.Value.ToString(DbTimeFormat.SS),
|
||||
plan_start_date = a.plan_start_date == null ? "" : a.plan_start_date.Value.ToString(DbTimeFormat.SS),
|
||||
plan_end_date = a.plan_end_date == null ? "" : a.plan_end_date.Value.ToString(DbTimeFormat.SS),
|
||||
remark = a.remark,
|
||||
act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS),
|
||||
starter_id = e.RealName,
|
||||
}).ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
|
||||
return PageResult<ToolMoldMaintainPlanRunListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -367,6 +425,13 @@ namespace Tnb.EquipMgr
|
||||
|
||||
if (plan is not null)
|
||||
{
|
||||
|
||||
await _db.Updateable<ToolMoldMaintainPlan>()
|
||||
.SetColumns(x => x.act_start_date == DateTime.Now)
|
||||
.SetColumns(x => x.starter_id == _userManager.UserId)
|
||||
.Where(x => x.id == plan.id)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
//插入保养计划记录
|
||||
ToolMoldMaintainRunRecord record = new()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user