生产bom工序表添加工艺路线子表id,esop
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
namespace Tnb.BasicData.Entities.Dto
|
||||
{
|
||||
public class ESopListOutput
|
||||
{
|
||||
public string id { get; set; } = string.Empty;
|
||||
public string code { get; set; } = string.Empty;
|
||||
public string name { get; set; } = string.Empty;
|
||||
public string mbom_id { get; set; } = string.Empty;
|
||||
public string mbom_process_id { get; set; } = string.Empty;
|
||||
public string version { get; set; } = string.Empty;
|
||||
public string enabled { get; set; } = string.Empty;
|
||||
public string attachment { get; set; } = string.Empty;
|
||||
public string? remark { get; set; }
|
||||
public string create_id { get; set; } = string.Empty;
|
||||
public string create_time { get; set; } = string.Empty;
|
||||
public string mbom_id_id { get; set; } = string.Empty;
|
||||
public string mbom_process_id_id { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Tnb.BasicData.Entities.Dto
|
||||
{
|
||||
public class EsopHistoryListQueryInput
|
||||
{
|
||||
public string mbom_id { get; set; } = string.Empty;
|
||||
public string mbom_process_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 当前页码:pageIndex.
|
||||
/// </summary>
|
||||
public virtual int currentPage { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 每页行数.
|
||||
/// </summary>
|
||||
public virtual int pageSize { get; set; } = 50;
|
||||
|
||||
public string? queryJson { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace Tnb.BasicData.Entities.Dto
|
||||
{
|
||||
public class UploadNewVersionInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 编号
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 生产bomid
|
||||
/// </summary>
|
||||
public string mbom_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产bom工序id
|
||||
/// </summary>
|
||||
public string mbom_process_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附件对象.
|
||||
/// </summary>
|
||||
public string attachment { get; set; } = string.Empty;
|
||||
|
||||
public string version { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,8 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
|
||||
public class MbomProcessOutDto
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产bomid
|
||||
/// Default:
|
||||
|
||||
@@ -67,6 +67,8 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
|
||||
public class MbomProcessDto
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产bomid
|
||||
/// Default:
|
||||
@@ -102,6 +104,11 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// </summary>
|
||||
public int byproduct_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线子表id
|
||||
/// </summary>
|
||||
public string route_detail_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:投产方式
|
||||
/// Default:NULL::character varying
|
||||
|
||||
92
BasicData/Tnb.BasicData.Entities/Entity/BasESop.cs
Normal file
92
BasicData/Tnb.BasicData.Entities/Entity/BasESop.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.BasicData.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// esop
|
||||
/// </summary>
|
||||
[SugarTable("bas_e_sop")]
|
||||
public partial class BasESop : BaseEntity<string>
|
||||
{
|
||||
public BasESop()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 编号
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产bomid
|
||||
/// </summary>
|
||||
public string mbom_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 生产bom工序id
|
||||
/// </summary>
|
||||
public string mbom_process_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附件对象.
|
||||
/// </summary>
|
||||
public string attachment { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 版本
|
||||
/// </summary>
|
||||
public string version { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否有效
|
||||
/// </summary>
|
||||
public int enabled { 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; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
|
||||
}
|
||||
@@ -48,5 +48,10 @@ public partial class BasMbomProcess : BaseEntity<string>
|
||||
/// 投产方式
|
||||
/// </summary>
|
||||
public string? production_method { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线子表id
|
||||
/// </summary>
|
||||
public string route_detail_id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
22
BasicData/Tnb.BasicData.Interfaces/IBasESopService.cs
Normal file
22
BasicData/Tnb.BasicData.Interfaces/IBasESopService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
|
||||
namespace Tnb.BasicData.Interfaces
|
||||
{
|
||||
public interface IBasESopService
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传新版本
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> UploadNewVersion(UploadNewVersionInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取历史记录
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> GetHistoryList(EsopHistoryListQueryInput input);
|
||||
|
||||
}
|
||||
}
|
||||
169
BasicData/Tnb.BasicData/BasESopService.cs
Normal file
169
BasicData/Tnb.BasicData/BasESopService.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
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.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData.Entities.Dto;
|
||||
using Tnb.BasicData.Interfaces;
|
||||
|
||||
namespace Tnb.BasicData
|
||||
{
|
||||
/// <summary>
|
||||
/// esop关联
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModelId)]
|
||||
public class BasESopService : IBasESopService,IOverideVisualDevService,IDynamicApiController, ITransient
|
||||
{
|
||||
public const string ModelId = "26919620992277";
|
||||
private readonly ISqlSugarRepository<BasESop> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
public BasESopService(
|
||||
IUserManager userManager,
|
||||
ISqlSugarRepository<BasESop> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ESOP列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
Dictionary<string, object>? queryJson = string.IsNullOrEmpty(input.queryJson) ? null : input.queryJson.ToObject<Dictionary<string, object>>();
|
||||
string code = queryJson!=null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
string name = queryJson!=null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
||||
string version = queryJson!=null && queryJson.ContainsKey("version") ? queryJson["version"].ToString() : "";
|
||||
var list = await db.Queryable<BasESop, BasMbom, BasMbomProcess, UserEntity,BasProcess>((a, b, c, d,e) => new object[]
|
||||
{
|
||||
JoinType.Left, a.mbom_id == b.id,
|
||||
JoinType.Left, a.mbom_process_id == c.id,
|
||||
JoinType.Left, a.create_id == d.Id,
|
||||
JoinType.Left, c.process_id == e.id,
|
||||
})
|
||||
.WhereIF(!string.IsNullOrEmpty(code), (a, b, c, d) => a.code.Contains(code))
|
||||
.WhereIF(!string.IsNullOrEmpty(name), (a, b, c, d) => a.name.Contains(name))
|
||||
.WhereIF(!string.IsNullOrEmpty(version), (a, b, c, d) => a.version.Contains(version))
|
||||
.Where((a,b,c)=>a.enabled==1)
|
||||
.Select((a, b, c, d,e) => new ESopListOutput
|
||||
{
|
||||
id = a.id,
|
||||
code = a.code,
|
||||
name = a.name,
|
||||
mbom_id = b.version,
|
||||
mbom_process_id = e.process_name,
|
||||
version = a.version,
|
||||
enabled = a.enabled==1 ? "是" : "否",
|
||||
attachment = a.attachment,
|
||||
remark = a.remark,
|
||||
create_id = d.RealName,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
mbom_id_id = a.mbom_id,
|
||||
mbom_process_id_id = a.mbom_process_id
|
||||
}).ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
|
||||
return PageResult<ESopListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetHistoryList(EsopHistoryListQueryInput 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 ?? "");
|
||||
}
|
||||
string code = queryJson!=null && queryJson.ContainsKey("code") ? queryJson["code"].ToString() : "";
|
||||
string name = queryJson!=null && queryJson.ContainsKey("name") ? queryJson["name"].ToString() : "";
|
||||
string version = queryJson!=null && queryJson.ContainsKey("version") ? queryJson["version"].ToString() : "";
|
||||
var list = await db.Queryable<BasESop, BasMbom, BasMbomProcess, UserEntity,BasProcess>((a, b, c, d,e) => new object[]
|
||||
{
|
||||
JoinType.Left, a.mbom_id == b.id,
|
||||
JoinType.Left, a.mbom_process_id == c.id,
|
||||
JoinType.Left, a.create_id == d.Id,
|
||||
JoinType.Left, c.process_id == e.id,
|
||||
})
|
||||
.WhereIF(!string.IsNullOrEmpty(code), (a, b, c, d) => a.code.Contains(code))
|
||||
.WhereIF(!string.IsNullOrEmpty(name), (a, b, c, d) => a.name.Contains(name))
|
||||
.WhereIF(!string.IsNullOrEmpty(version), (a, b, c, d) => a.version.Contains(version))
|
||||
.Where((a,b,c)=>a.mbom_id==input.mbom_id && a.mbom_process_id==input.mbom_process_id)
|
||||
.Select((a, b, c, d,e) => new ESopListOutput
|
||||
{
|
||||
id = a.id,
|
||||
code = a.code,
|
||||
name = a.name,
|
||||
mbom_id = b.version,
|
||||
mbom_process_id = e.process_name,
|
||||
version = a.version,
|
||||
enabled = a.enabled==1 ? "是" : "否",
|
||||
attachment = a.attachment,
|
||||
remark = a.remark,
|
||||
create_id = d.RealName,
|
||||
create_time = a.create_time==null ? "" : a.create_time.Value.ToString("yyyy-MM-dd"),
|
||||
mbom_id_id = a.mbom_id
|
||||
}).ToPagedListAsync((input?.currentPage??1), (input?.pageSize??50));
|
||||
|
||||
return PageResult<ESopListOutput>.SqlSugarPageResult(list);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> UploadNewVersion(UploadNewVersionInput input)
|
||||
{
|
||||
if (_repository.IsAny(x => x.mbom_id == input.mbom_id && x.mbom_process_id == input.mbom_process_id && x.version == input.version))
|
||||
{
|
||||
throw Oops.Bah("已存在该版本");
|
||||
}
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new BasESop()
|
||||
{
|
||||
enabled = 0,
|
||||
}, x => x.mbom_id == input.mbom_id && x.mbom_process_id == input.mbom_process_id);
|
||||
|
||||
BasESop basESop = new BasESop()
|
||||
{
|
||||
code = input.code,
|
||||
name = input.name,
|
||||
version = input.version,
|
||||
attachment = input.attachment,
|
||||
mbom_id = input.mbom_id,
|
||||
mbom_process_id = input.mbom_process_id,
|
||||
remark = input.remark,
|
||||
create_id = _userManager.UserId,
|
||||
create_time = DateTime.Now,
|
||||
org_id = _userManager.GetUserInfo().Result.organizeId,
|
||||
enabled = 1,
|
||||
};
|
||||
|
||||
await _repository.InsertAsync(basESop);
|
||||
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
return result.IsSuccess ? "上传成功" : result.ErrorMessage;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -114,6 +114,7 @@ namespace Tnb.BasicData
|
||||
{
|
||||
mbomProcessOutDtos.Add(new MbomProcessOutDto()
|
||||
{
|
||||
id = process.id,
|
||||
mbom_id = mbom.id,
|
||||
process_id = process.process_id,
|
||||
preparation_time = process.preparation_time,
|
||||
@@ -159,7 +160,8 @@ namespace Tnb.BasicData
|
||||
var result = await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
// .LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.route_detail_id == d.id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||
.Where((a, b, c, d, e) => a.id == bomId)
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
@@ -293,6 +295,7 @@ namespace Tnb.BasicData
|
||||
station = process?.station ?? "",
|
||||
byproduct_status = process.byproduct_status,
|
||||
production_method = process.production_method,
|
||||
route_detail_id = process.route_detail_id,
|
||||
|
||||
});
|
||||
|
||||
@@ -379,7 +382,7 @@ namespace Tnb.BasicData
|
||||
|
||||
}, x => x.id == mbomSaveDataInput.id);
|
||||
}
|
||||
List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
// List<BasMbomProcess> processes = new List<BasMbomProcess>();
|
||||
List<BasMbomInput> inputs = new List<BasMbomInput>();
|
||||
List<BasMbomOutput> outputs = new List<BasMbomOutput>();
|
||||
|
||||
@@ -387,19 +390,29 @@ namespace Tnb.BasicData
|
||||
{
|
||||
foreach (var process in mbomSaveDataInput.processes)
|
||||
{
|
||||
string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
processes.Add(new BasMbomProcess()
|
||||
{
|
||||
id = mbomProcessId,
|
||||
org_id = orgId ?? "",
|
||||
mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
process_id = process?.process_id ?? "",
|
||||
preparation_time = process?.preparation_time ?? 0,
|
||||
station = process.station,
|
||||
byproduct_status = process.byproduct_status,
|
||||
production_method = process.production_method,
|
||||
|
||||
});
|
||||
string mbomProcessId = process.id;
|
||||
// string mbomProcessId = SnowflakeIdHelper.NextId();
|
||||
// processes.Add(new BasMbomProcess()
|
||||
// {
|
||||
// id = mbomProcessId,
|
||||
// org_id = orgId ?? "",
|
||||
// mbom_id = mbomSaveDataInput?.id ?? "",
|
||||
// process_id = process?.process_id ?? "",
|
||||
// preparation_time = process?.preparation_time ?? 0,
|
||||
// station = process.station,
|
||||
// byproduct_status = process.byproduct_status,
|
||||
// production_method = process.production_method,
|
||||
// route_detail_id = process.route_detail_id,
|
||||
//
|
||||
// });
|
||||
|
||||
decimal preparation_time = process?.preparation_time ?? 0;
|
||||
await _repository.AsSugarClient().Updateable<BasMbomProcess>()
|
||||
.SetColumns(x => x.preparation_time == preparation_time)
|
||||
.SetColumns(x => x.station == process.station)
|
||||
.SetColumns(x => x.byproduct_status == process.byproduct_status)
|
||||
.SetColumns(x => x.production_method == process.production_method)
|
||||
.Where(x => x.id == process.id).ExecuteCommandAsync();
|
||||
|
||||
if (process.inputs != null)
|
||||
{
|
||||
@@ -442,14 +455,14 @@ namespace Tnb.BasicData
|
||||
|
||||
if (mbomSaveDataInput != null && !string.IsNullOrEmpty(mbomSaveDataInput.id))
|
||||
{
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
// await _repository.AsSugarClient().Deleteable<BasMbomProcess>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomInput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
await _repository.AsSugarClient().Deleteable<BasMbomOutput>().Where(x => x.mbom_id == mbomSaveDataInput.id).ExecuteCommandAsync();
|
||||
}
|
||||
if (processes.Count > 0)
|
||||
{
|
||||
await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
}
|
||||
// if (processes.Count > 0)
|
||||
// {
|
||||
// await _repository.AsSugarClient().Insertable<BasMbomProcess>(processes).ExecuteCommandAsync();
|
||||
// }
|
||||
|
||||
if (inputs.Count > 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user