From 83e0b1294bca175a6a77e2ac75356d5ddf63934f Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Wed, 28 Jun 2023 14:02:20 +0800
Subject: [PATCH] bug
---
.../Consts/CodeTemplateConst.cs | 23 +++++++++
.../IBasDefectService.cs | 15 ++++++
BasicData/Tnb.BasicData/BasDefectService.cs | 43 +++++++++++++++++
.../Consts/DictionaryConstants.cs | 9 ----
.../Tnb.ProductionMgr/PrdFeedingService.cs | 2 +-
.../PrdMaterialReceiptService.cs | 2 +-
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 48 +++++++++++--------
.../Tnb.ProductionMgr/PrdTaskManageService.cs | 6 ++-
8 files changed, 116 insertions(+), 32 deletions(-)
create mode 100644 BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs
create mode 100644 BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs
create mode 100644 BasicData/Tnb.BasicData/BasDefectService.cs
diff --git a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs
new file mode 100644
index 00000000..a62d9c12
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs
@@ -0,0 +1,23 @@
+namespace Tnb.BasicData
+{
+ ///
+ /// 单据模板业务编码
+ ///
+ public class CodeTemplateConst
+ {
+ ///
+ /// 物料签收编码
+ ///
+ public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
+
+ ///
+ /// 生产投料编码
+ ///
+ public const string FEEDING_CODE = "Feeding";
+
+ ///
+ /// 生产任务单号单据模板编码
+ ///
+ public const string PRDMOTASK_CODE = "ProductionPlanAndSchedule";
+ }
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs
new file mode 100644
index 00000000..21992ccb
--- /dev/null
+++ b/BasicData/Tnb.BasicData.Interfaces/IBasDefectService.cs
@@ -0,0 +1,15 @@
+namespace Tnb.BasicData.Interfaces
+{
+ ///
+ /// 次品项服务
+ ///
+ public interface IBasDefectService
+ {
+ ///
+ /// 根据工序id获取次品项列表
+ ///
+ ///
+ ///
+ public Task GetDefectListByProcessId(Dictionary dic);
+ }
+}
\ No newline at end of file
diff --git a/BasicData/Tnb.BasicData/BasDefectService.cs b/BasicData/Tnb.BasicData/BasDefectService.cs
new file mode 100644
index 00000000..2ee6d6ba
--- /dev/null
+++ b/BasicData/Tnb.BasicData/BasDefectService.cs
@@ -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
+{
+ ///
+ /// 物料清单
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class BasDefectService: IBasDefectService,IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+ private readonly DataBaseManager _dbManager;
+ private readonly IDictionaryDataService _dictionaryDataService;
+
+ public BasDefectService(
+ ISqlSugarRepository repository,DataBaseManager dbManager,IDictionaryDataService dictionaryDataService)
+ {
+ _repository = repository;
+ _dbManager = dbManager;
+ _dictionaryDataService = dictionaryDataService;
+ }
+
+ [HttpPost]
+ public async Task GetDefectListByProcessId(Dictionary dic)
+ {
+ string processId = dic["processId"];
+ return await _repository.AsSugarClient().Queryable()
+ .LeftJoin((a, b) => a.process_id == b.id)
+ .LeftJoin((a, b, c) => a.defective_id == c.id)
+ .Where((a, b, c) => a.process_id == processId)
+ .Select((a, b, c) => c).ToListAsync();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs
index a97b121c..cd925157 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Consts/DictionaryConstants.cs
@@ -20,15 +20,6 @@ namespace Tnb.ProductionMgr.Entities.Consts
///
public const string WaitProductId = "25019244276501";
- ///
- /// 物料签收编码
- ///
- public const string MATERIAL_RECEIPT_CODE = "MaterialReceipt";
-
- ///
- /// 生产投料编码
- ///
- public const string FEEDING_CODE = "Feeding";
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
index 047a6725..e45e0109 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs
@@ -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,
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
index 7a2baec7..bf6d721d 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs
@@ -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,
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 79fe64ea..0fd84c98 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -63,6 +63,7 @@ namespace Tnb.ProductionMgr
private static Dictionary _dicWorkLine = new Dictionary();
private static Dictionary _dicProcess = new Dictionary();
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((a, b, c) => a.material_id == c.id)
.LeftJoin((a, b, c, d) => a.workline_id == d.Id)
.LeftJoin((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().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().FirstAsync(it => it.id == input.mo_id);
var moCode = mo?.mo_code;
- var taskCode = await _db.Queryable().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().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().FirstAsync(it => it.id == moTask.material_id);
//添加生产任务操作记录日志
@@ -860,6 +867,7 @@ namespace Tnb.ProductionMgr
.LeftJoin((a, b, c, d) => b.route_detail_id == d.id)
.LeftJoin((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,
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
index 2bb31058..6501a0e1 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
@@ -257,8 +257,10 @@ namespace Tnb.ProductionMgr
.LeftJoin((a,b,c)=>a.mold_id==c.id)
.LeftJoin((a,b,c,d)=>a.eqp_id==d.id)
.LeftJoin((a,b,c,d,e)=>e.DictionaryTypeId==DictConst.PrdTaskStatusTypeId && a.mo_task_status==e.EnCode)
+ .LeftJoin((a,b,c,d,e,f)=>a.workline_id==f.Id)
+ .LeftJoin((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;