This commit is contained in:
2023-06-28 14:02:20 +08:00
parent 4e8c1e372a
commit 83e0b1294b
8 changed files with 116 additions and 32 deletions

View File

@@ -0,0 +1,23 @@
namespace Tnb.BasicData
{
/// <summary>
/// 单据模板业务编码
/// </summary>
public class CodeTemplateConst
{
/// <summary>
/// 物料签收编码
/// </summary>
public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
/// <summary>
/// 生产投料编码
/// </summary>
public const string FEEDING_CODE = "Feeding";
/// <summary>
/// 生产任务单号单据模板编码
/// </summary>
public const string PRDMOTASK_CODE = "ProductionPlanAndSchedule";
}
}

View File

@@ -0,0 +1,15 @@
namespace Tnb.BasicData.Interfaces
{
/// <summary>
/// 次品项服务
/// </summary>
public interface IBasDefectService
{
/// <summary>
/// 根据工序id获取次品项列表
/// </summary>
/// <param name="dic"></param>
/// <returns></returns>
public Task<dynamic> GetDefectListByProcessId(Dictionary<string, string> dic);
}
}

View File

@@ -0,0 +1,43 @@
using JNPF.Common.Core.Manager;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.BasicData.Interfaces;
namespace Tnb.BasicData
{
/// <summary>
/// 物料清单
/// </summary>
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
[Route("api/[area]/[controller]/[action]")]
public class BasDefectService: IBasDefectService,IDynamicApiController, ITransient
{
private readonly ISqlSugarRepository<BasDefect> _repository;
private readonly DataBaseManager _dbManager;
private readonly IDictionaryDataService _dictionaryDataService;
public BasDefectService(
ISqlSugarRepository<BasDefect> repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
{
_repository = repository;
_dbManager = dbManager;
_dictionaryDataService = dictionaryDataService;
}
[HttpPost]
public async Task<dynamic> GetDefectListByProcessId(Dictionary<string, string> dic)
{
string processId = dic["processId"];
return await _repository.AsSugarClient().Queryable<BasProcessDefective>()
.LeftJoin<BasProcess>((a, b) => a.process_id == b.id)
.LeftJoin<BasDefect>((a, b, c) => a.defective_id == c.id)
.Where((a, b, c) => a.process_id == processId)
.Select((a, b, c) => c).ToListAsync();
}
}
}

View File

@@ -20,15 +20,6 @@ namespace Tnb.ProductionMgr.Entities.Consts
/// </summary>
public const string WaitProductId = "25019244276501";
/// <summary>
/// 物料签收编码
/// </summary>
public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
/// <summary>
/// 生产投料编码
/// </summary>
public const string FEEDING_CODE = "Feeding";
}

View File

@@ -52,7 +52,7 @@ namespace Tnb.ProductionMgr
.Select(x=>x.material_id)
.ToListAsync();
string code = await _billRullService.GetBillNumber(MoStatus.FEEDING_CODE);
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE);
PrdFeedingH prdFeedingH = new PrdFeedingH()
{
code = code,

View File

@@ -79,7 +79,7 @@ namespace Tnb.ProductionMgr
.Select(x=>x.material_id)
.ToListAsync();
string code = await _billRullService.GetBillNumber(MoStatus.MATERIAL_RECEIPT_CODE);
string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE);
PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH()
{
code = code,

View File

@@ -63,6 +63,7 @@ namespace Tnb.ProductionMgr
private static Dictionary<string, object> _dicWorkLine = new Dictionary<string, object>();
private static Dictionary<string, object> _dicProcess = new Dictionary<string, object>();
private readonly ISqlSugarClient _db;
private readonly IBillRullService _billRuleService;
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
@@ -71,6 +72,7 @@ namespace Tnb.ProductionMgr
IUserManager userManager,
IDictionaryDataService dictionaryDataService,
IRunService runService,
IBillRullService billRullService,
IVisualDevService visualDevService
)
{
@@ -82,6 +84,7 @@ namespace Tnb.ProductionMgr
_db = _repository.AsSugarClient();
OverideFuncs.DeleteAsync = Delete;
OverideFuncs.GetListAsync = GetList;
_billRuleService = billRullService;
}
@@ -321,7 +324,7 @@ namespace Tnb.ProductionMgr
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
.LeftJoin<BasProcess>((a,b,c,d,e)=>a.process_id==e.id)
.Where((a, b, c, d) => b.id == moId || b.parent_id == moId)
.Where((a, b, c, d) => (b.id == moId || b.parent_id == moId) && SqlFunc.IsNullOrEmpty(a.parent_id))
.Select((a, b, c, d,e) => new PrdMoTaskOutput
{
mo_task_code = a.mo_task_code,
@@ -411,6 +414,8 @@ namespace Tnb.ProductionMgr
scheduled_qty = a.scheduled_qty,
plan_qty = d.plan_qty,
process_task_qty = a.process_task_qty,
estimated_start_date = a.estimated_start_date,
estimated_end_date = a.estimated_end_date,
bom_version = SqlFunc.Subqueryable<BasMbom>().Where(it => it.material_id == a.material_id).Select(it => it.version)
})
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
@@ -764,25 +769,27 @@ namespace Tnb.ProductionMgr
moTask.scheduled_qty = input.scheduled_qty;
var mo = await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id);
var moCode = mo?.mo_code;
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
.OrderByDescending(it => it.mo_task_code)
.Select(it => it.mo_task_code)
.FirstAsync();
if (taskCode is null || taskCode.IsNullOrEmpty())
{
moTask.mo_task_code = $"{moCode}-01";
}
else
{
var pos = taskCode?.IndexOf("-", StringComparison.Ordinal);
if (pos.HasValue && pos.Value > -1)
{
var num = taskCode.AsSpan().Slice(pos.Value + 1).ToString().ParseToInt();
var code = taskCode.AsSpan().Slice(0, pos.Value).ToString();
var n = (num + 1).ToString().PadLeft(2, '0');
moTask.mo_task_code = $"{code}-{n}";
}
}
// var taskCode = await _db.Queryable<PrdMoTask>().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
// .OrderByDescending(it => it.mo_task_code)
// .Select(it => it.mo_task_code)
// .FirstAsync();
var taskCode = await _billRuleService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.PRDMOTASK_CODE);
moTask.mo_task_code = taskCode;
// if (taskCode is null || taskCode.IsNullOrEmpty())
// {
// moTask.mo_task_code = $"{moCode}-01";
// }
// else
// {
// var pos = taskCode?.IndexOf("-", StringComparison.Ordinal);
// if (pos.HasValue && pos.Value > -1)
// {
// var num = taskCode.AsSpan().Slice(pos.Value + 1).ToString().ParseToInt();
// var code = taskCode.AsSpan().Slice(0, pos.Value).ToString();
// var n = (num + 1).ToString().PadLeft(2, '0');
// moTask.mo_task_code = $"{code}-{n}";
// }
// }
row = await _db.Insertable(moTask).ExecuteCommandAsync();
var material_h = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
//添加生产任务操作记录日志
@@ -860,6 +867,7 @@ namespace Tnb.ProductionMgr
.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 == input.bom_id)
.OrderBy((a,b,c,d,e)=>b.ordinal)
.Select((a, b, c, d, e) => new SubBomListOutput
{
version = a.version,

View File

@@ -257,8 +257,10 @@ namespace Tnb.ProductionMgr
.LeftJoin<ToolMolds>((a,b,c)=>a.mold_id==c.id)
.LeftJoin<EqpEquipment>((a,b,c,d)=>a.eqp_id==d.id)
.LeftJoin<DictionaryDataEntity>((a,b,c,d,e)=>e.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==e.EnCode)
.LeftJoin<OrganizeEntity>((a,b,c,d,e,f)=>a.workline_id==f.Id)
.LeftJoin<BasProcess>((a,b,c,d,e,f,g)=>a.process_id==g.id)
.Where((a,b) => a.mo_task_code == mo_task_code)
.Select((a,b,c,d,e) => new
.Select((a,b,c,d,e,f,g) => new
{
id = a.id,
mo_task_code = a.mo_task_code,
@@ -278,6 +280,8 @@ namespace Tnb.ProductionMgr
// reported_qty = a.reported_qty,
// prd_qty = a.prd_qty,
eqp_code = d.code,
workline_name = f.FullName,
process_name = g.process_name
}).FirstAsync();
return prdTask;