bug,设备迁移
This commit is contained in:
@@ -18,5 +18,12 @@ namespace Tnb.BasicData.Interfaces
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetHistoryList(EsopHistoryListQueryInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 根据生产bom工序id获取实体
|
||||
/// </summary>
|
||||
/// <param name="dic">mbomProcessId</param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetEntityByMbomProcessId(Dictionary<string,string> dic);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,18 @@ namespace Tnb.BasicData
|
||||
return PageResult<ESopListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetEntityByMbomProcessId(Dictionary<string, string> dic)
|
||||
{
|
||||
string mbomProcessId = dic["mbomProcessId"];
|
||||
if (!string.IsNullOrEmpty(mbomProcessId))
|
||||
{
|
||||
return await _repository.GetFirstAsync(x => x.mbom_process_id == mbomProcessId && x.enabled == 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> UploadNewVersion(UploadNewVersionInput input)
|
||||
{
|
||||
|
||||
@@ -21,5 +21,9 @@ namespace Tnb.EquipMgr
|
||||
/// 报废
|
||||
/// </summary>
|
||||
public const string SCRAP = "4";
|
||||
/// <summary>
|
||||
/// 未入场
|
||||
/// </summary>
|
||||
public const string NOTADMITTED = "4";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class EquipWorkshopChangeInput
|
||||
{
|
||||
public string equip_id { get; set; } = string.Empty;
|
||||
public string new_workshop_id { get; set; } = string.Empty;
|
||||
public string? new_installation_location { get; set; }
|
||||
public string? remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class EquipWorkshopChangeQueryOutput
|
||||
{
|
||||
public string id { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 旧车间id
|
||||
/// </summary>
|
||||
public string old_workshop_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 新车间id
|
||||
/// </summary>
|
||||
public string new_workshop_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 旧安装地点
|
||||
/// </summary>
|
||||
public string? old_installation_location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新安装地点
|
||||
/// </summary>
|
||||
public string? new_installation_location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public string? create_time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -187,5 +187,15 @@ public partial class EqpEquipment : BaseEntity<string>
|
||||
/// 工位编码
|
||||
/// </summary>
|
||||
public string? station_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 质保开始时间
|
||||
/// </summary>
|
||||
public DateTime? warranty_start_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 质保结束时间
|
||||
/// </summary>
|
||||
public DateTime? warranty_end_time { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备使用车间变更记录
|
||||
/// </summary>
|
||||
[SugarTable("eqp_workshop_change_log")]
|
||||
public partial class EqpWorkshopChangeLog : BaseEntity<string>
|
||||
{
|
||||
public EqpWorkshopChangeLog()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 旧车间id
|
||||
/// </summary>
|
||||
public string? old_workshop_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新车间id
|
||||
/// </summary>
|
||||
public string? new_workshop_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 旧安装地点
|
||||
/// </summary>
|
||||
public string? old_installation_location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 新安装地点
|
||||
/// </summary>
|
||||
public string? new_installation_location { 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 string? org_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备迁移服务
|
||||
/// </summary>
|
||||
public interface IEqpWorkshopChangeLogService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据设备id获取迁移记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetEquipWorkshopChangeList(EquipQueryInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 设备迁移
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> WorkshopChange(EquipWorkshopChangeInput input);
|
||||
}
|
||||
}
|
||||
95
EquipMgr/Tnb.EquipMgr/EqpWorkshopChangeLogService.cs
Normal file
95
EquipMgr/Tnb.EquipMgr/EqpWorkshopChangeLogService.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Filter;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.Systems.Entitys.Permission;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
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]")]
|
||||
public class EqpWorkshopChangeLogService : IEqpWorkshopChangeLogService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpWorkshopChangeLog> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpWorkshopChangeLogService(ISqlSugarRepository<EqpWorkshopChangeLog> repository, IUserManager userManager)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetEquipWorkshopChangeList(EquipQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
// Dictionary<string, string>? queryJson = new Dictionary<string, string>();
|
||||
// if (input!=null && !string.IsNullOrEmpty(input.queryJson))
|
||||
// {
|
||||
// queryJson = JsonConvert.DeserializeObject<Dictionary<string, string>>(input?.queryJson ?? "");
|
||||
// }
|
||||
var result = await db.Queryable<EqpWorkshopChangeLog>()
|
||||
.LeftJoin<OrganizeEntity>((a,b)=>a.old_workshop_id==b.Id)
|
||||
.LeftJoin<OrganizeEntity>((a,b,c)=>a.new_workshop_id==c.Id)
|
||||
.WhereIF(input!=null,a=>a.equip_id==input.equip_id)
|
||||
//.WhereIF(queryJson!=null && queryJson.ContainsKey("name"),a=>a.name.Contains(queryJson["name"]))
|
||||
.Select((a,b,c) => new EquipWorkshopChangeQueryOutput
|
||||
{
|
||||
id = a.id,
|
||||
old_workshop_id = b.FullName,
|
||||
new_workshop_id = c.FullName,
|
||||
old_installation_location = a.old_installation_location,
|
||||
new_installation_location = a.new_installation_location,
|
||||
remark = a.remark,
|
||||
create_time = a.create_time==null ? null : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
}).ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
|
||||
return PageResult<EquipWorkshopChangeQueryOutput>.SqlSugarPageResult(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> WorkshopChange(EquipWorkshopChangeInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
EqpEquipment eqpEquipment = await db.Queryable<EqpEquipment>().SingleAsync(x => x.id == input.equip_id);
|
||||
|
||||
EqpWorkshopChangeLog eqpWorkshopChangeLog = new EqpWorkshopChangeLog()
|
||||
{
|
||||
equip_id = input.equip_id,
|
||||
old_workshop_id = eqpEquipment.use_department_id,
|
||||
new_workshop_id = input.new_workshop_id,
|
||||
old_installation_location = eqpEquipment.installation_location,
|
||||
new_installation_location = input.new_installation_location,
|
||||
remark = input.remark,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId
|
||||
};
|
||||
|
||||
await _repository.InsertAsync(eqpWorkshopChangeLog);
|
||||
|
||||
await db.Updateable<EqpEquipment>()
|
||||
.SetColumns(x => x.use_department_id == input.new_workshop_id)
|
||||
.SetColumns(x => x.installation_location == input.new_installation_location)
|
||||
.Where(x => x.id == input.equip_id).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "迁移成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1070,7 +1070,8 @@ namespace Tnb.ProductionMgr
|
||||
record.masterial_name = material?.name;
|
||||
record.plan_start_date = taskInfo.estimated_start_date;
|
||||
record.plan_end_date = taskInfo.estimated_end_date;
|
||||
record.plan_qty = taskInfo.plan_qty;
|
||||
// record.plan_qty = taskInfo.plan_qty;
|
||||
record.plan_qty = taskInfo.scheduled_qty;
|
||||
record.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskInfo.eqp_id))?.code;
|
||||
record.mo_task_type = mo?.mo_type;
|
||||
record.status = taskInfo.mo_task_status;
|
||||
|
||||
@@ -150,8 +150,8 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
nsChild[i].parentId = parentId;
|
||||
nsChild[i].process_id = $"{items[i].process_code}/{items[i].process_name}";
|
||||
nsChild[i].plan_start_date = items[i].estimated_start_date.HasValue ? items[i].estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
nsChild[i].plan_end_date = items[i].estimated_end_date.HasValue ? items[i].estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
nsChild[i].plan_start_date = items[i].plan_start_date.HasValue ? items[i].plan_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
nsChild[i].plan_end_date = items[i].plan_end_date.HasValue ? items[i].plan_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
|
||||
if (nsChild[i].workline_id.IsNotEmptyOrNull())
|
||||
{
|
||||
|
||||
@@ -278,6 +278,7 @@ namespace Tnb.ProductionMgr
|
||||
// reported_qty = a.reported_qty,
|
||||
// prd_qty = a.prd_qty,
|
||||
eqp_code = d.code,
|
||||
mbom_process_id = a.mbom_process_id,
|
||||
}).FirstAsync();
|
||||
|
||||
return prdTask;
|
||||
|
||||
Reference in New Issue
Block a user