diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldPlanMaintainStatus.cs b/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldPlanMaintainStatus.cs
new file mode 100644
index 00000000..f013c856
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldPlanMaintainStatus.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.EquipMgr.Entities.Consts
+{
+ public class MoldPlanMaintainStatus
+ {
+ ///
+ /// 模具保养计划状态-已完成CODE
+ ///
+ public const string MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE = "Completed";
+ }
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs b/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs
new file mode 100644
index 00000000..db9570c7
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.EquipMgr.Entities.Consts
+{
+ public class MoldUseStatus
+ {
+ ///
+ /// 模具使用状态在库状态ID
+ ///
+ public const string MOLDUSESTATUSZKID = "26149307089941";
+ }
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
index 99baa593..a286ba6f 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/MoldMaintainRunUpInput.cs
@@ -23,5 +23,9 @@ namespace Tnb.EquipMgr.Entities.Dto
/// 保养项状态 0,未完成 1,已完成
///
public int? status { get; set; }
+ ///
+ /// 模具id
+ ///
+ public string mold_id { get; set; }
}
}
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs
index b0923bc0..c39705c9 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs
@@ -83,7 +83,7 @@ namespace Tnb.EquipMgr
})
.ToListAsync();
}
-
+
///
/// 关联模具
@@ -141,28 +141,29 @@ namespace Tnb.EquipMgr
await _db.Ado.BeginTranAsync();
var maintainRules = await _db.Queryable().Where(it => input.ruleIds.Contains(it.id)).ToListAsync();
- var ruleMoldRelations = await _db.Queryable().Where(it=>input.ruleIds.Contains(it.rule_id)).ToListAsync();
+ var ruleMoldRelations = await _db.Queryable().Where(it => input.ruleIds.Contains(it.rule_id)).ToListAsync();
if (ruleMoldRelations?.Count > 0)
{
List maintainPlans = new();
List maintainPlanRelations = new();
- foreach (var maintainRule in maintainRules)
+ foreach (var mrr in ruleMoldRelations)
{
- if (maintainRule.cycle.HasValue && maintainRule.cycle.Value > 0)
+ var rule = await _db.Queryable().FirstAsync(it => it.id == mrr.rule_id);
+ if (rule != null && rule.cycle.HasValue && rule.cycle.Value > 0)
{
ToolMoldMaintainPlan maintainPlan = new();
maintainPlan.plan_code = $"JHDM{DateTime.Now:yyyyMMddmmss}";
- maintainPlan.mode = maintainRule.mode;
+ maintainPlan.mode = rule.mode;
maintainPlan.status = DictConst.UnMaintainStatusCode;
maintainPlan.plan_start_date = DateTime.Now;
- maintainPlan.plan_end_date = DateTime.Now.AddDays(maintainRule.cycle.Value);
+ maintainPlan.plan_end_date = DateTime.Now.AddDays(rule.cycle.Value);
maintainPlan.create_id = _userManager.UserId;
maintainPlan.create_time = DateTime.Now;
maintainPlans.Add(maintainPlan);
ToolMoldMaintainPlanRelation maintainPlanReation = new();
maintainPlanReation.maintain_plan_id = maintainPlan.id;
- maintainPlanReation.mold_id = (await _db.Queryable().FirstAsync(it => it.rule_id == maintainRule.id))?.mold_id!;
+ maintainPlanReation.mold_id = mrr.mold_id;
maintainPlanRelations.Add(maintainPlanReation);
}
}
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
index 8918748b..970ce20d 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Aspose.Cells.Drawing;
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
+using JNPF.Common.Extension;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
@@ -14,8 +15,10 @@ using JNPF.Logging;
using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
+using StackExchange.Profiling.Internal;
using Tnb.BasicData;
using Tnb.EquipMgr.Entities;
+using Tnb.EquipMgr.Entities.Consts;
using Tnb.EquipMgr.Entities.Dto;
using Tnb.EquipMgr.Interfaces;
@@ -40,9 +43,8 @@ namespace Tnb.EquipMgr
_dictionaryDataService = dictionaryDataService;
}
-
///
- /// 根据计划id,获取相关联模具、设备、保养项目组、保养项,信息
+ /// 根据计划id,获取相关联模具、设备、信息
///
///
///
@@ -50,7 +52,16 @@ namespace Tnb.EquipMgr
public async Task GetMaintainInfoFromByPlanId([FromRoute] string planId)
{
dynamic info = new ExpandoObject();
- var planMoldRelation = await _db.Queryable().FirstAsync(it => it.maintain_plan_id == planId);
+ var planMoldRelation = await _db.Queryable()
+ .LeftJoin((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan
+ .LeftJoin((a, b, c) => b.plan_code == c.plan_code)
+ .Where(a => a.maintain_plan_id == planId)
+ .Select((a, b, c) => new
+ {
+ mold_id = a.mold_id,
+ plan_start_time = c.plan_start_time,
+ })
+ .FirstAsync();
if (planMoldRelation != null)
{
var mold = await _db.Queryable().FirstAsync(it => it.id == planMoldRelation.mold_id);
@@ -60,6 +71,7 @@ namespace Tnb.EquipMgr
info.mold_name = mold.mold_name;
info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status))?.FullName;
info.maintain_qty = mold.maintain_qty;
+ info.plan_start_time = planMoldRelation.plan_start_time;
var moldEqpRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id);
if (moldEqpRelation != null)
{
@@ -67,31 +79,41 @@ namespace Tnb.EquipMgr
info.eqp_code = eqp.code;
info.eqp_name = eqp.name;
}
- var itemGroupRelation = await _db.Queryable().FirstAsync(it => it.mold_id == mold.id);
- if (itemGroupRelation != null)
- {
- var checkItems = await _db.Queryable((a, b, c) => new JoinQueryInfos
- (
- JoinType.Left, a.id == b.item_group_id,
- JoinType.Left, b.item_id == c.id
- ))
- .Where(a => a.id == itemGroupRelation.item_group_id)
- .Select((a, b, c) => new
- {
- item_group_id = a.id,
- item_group_name = a.name,
- item_id = c.id,
- item_name = c.name,
- }).ToListAsync();
- if (checkItems?.Count > 0)
- {
- info.check_items = checkItems;
- }
- }
}
}
return info;
}
+ ///
+ /// 根据模具ID获取,保养组及项目信息
+ ///
+ /// 模具ID
+ ///
+ [HttpGet]
+ public async Task GetCheckItemAndGrpByMoldId([FromRoute] string moldId)
+ {
+ if (moldId.IsNullOrEmpty()) throw new ArgumentException($"parameter {nameof(moldId)} not be null or empty");
+
+ var itemGroupRelation = await _db.Queryable().FirstAsync(it => it.mold_id == moldId);
+ if (itemGroupRelation != null)
+ {
+ var checkItems = await _db.Queryable((a, b, c) => new JoinQueryInfos
+ (
+ JoinType.Left, a.id == b.item_group_id,
+ JoinType.Left, b.item_id == c.id
+ ))
+ .Where(a => a.id == itemGroupRelation.item_group_id)
+ .Select((a, b, c) => new
+ {
+ item_group_id = a.id,
+ item_group_name = a.name,
+ item_id = c.id,
+ item_name = c.name,
+ }).ToListAsync();
+ return checkItems;
+ }
+ return Enumerable.Empty();
+ }
+
///
/// 模具保养计划执行-开始模具保养
@@ -173,7 +195,32 @@ namespace Tnb.EquipMgr
public async Task MaintainFinish(MoldMaintainRunUpInput input)
{
if (input == null) throw new ArgumentNullException("input");
-
+ var grpIds = await _db.Queryable()
+ .LeftJoin((a, b) => a.mold_id == b.id)
+ .Where(a => a.mold_id == input.mold_id)
+ .Select((a, b) => a.item_group_id)
+ .Distinct()
+ .ToListAsync();
+ var itemIds = await _db.Queryable().Where(it => grpIds.Contains(it.item_group_id)).Select(it => it.item_id).ToListAsync();
+ if (itemIds?.Count > 0)
+ {
+ var items = await _db.Queryable().Where(it => itemIds.Contains(it.id) && it.status.HasValue && it.status.Value == 1).ToListAsync();
+ if (items?.Count < itemIds.Count)
+ {
+ throw new AppFriendlyException("当前模具有未完成的保养项目", 500);
+ }
+ var row = await _db.Updateable().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLDUSESTATUSZKID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
+ if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
+ var allMoldStatus = await _db.Queryable().InnerJoin((a, b) => a.mold_id == b.id)
+ .Where((a, b) => a.maintain_plan_id == input.plan_id)
+ .Select((a, b) => b.mold_status)
+ .ToListAsync();
+ if (allMoldStatus?.Count > 0 && allMoldStatus.All(x => x == MoldUseStatus.MOLDUSESTATUSZKID))
+ {
+ row = await _db.Updateable().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
+ }
+ if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
+ }
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs
index 7238c247..77744e16 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdCancelCloseDownService.cs
@@ -225,6 +225,7 @@ namespace Tnb.ProductionMgr
await _maintainTaskService.Create(maintaindTask);
}
+
}
else throw Oops.Oh(ErrorCode.COM1001);
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
index a2e25156..6f426481 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
@@ -35,7 +35,7 @@ namespace Tnb.ProductionMgr
{
private readonly ISqlSugarClient _db;
private readonly IDictionaryDataService _dictionaryDataService;
- private static Dictionary> _dicWorkLine = new Dictionary>();
+ private static Dictionary> _dicWorkLine = new Dictionary>();
public PrdPackReportService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService)
{
_db = repository.AsSugarClient();
@@ -53,12 +53,12 @@ namespace Tnb.ProductionMgr
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
if (_dicWorkLine.Count < 1)
{
- var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync();
+ var list = await _db.Queryable().Where(it => it.Category == "workline").ToListAsync();
_dicWorkLine = list.ToDictionary(x => x.Id, x => Tuple.Create(x.EnCode, x.FullName));
}
-
+
var items = await _db.Queryable().LeftJoin((a, b) => a.process_id == b.id).LeftJoin((a, b, c) => a.mo_id == c.id)
- .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code)
+ .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code.Trim())
.Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
.Select((a, b, c) => new PrdMoTask
{
@@ -123,7 +123,7 @@ namespace Tnb.ProductionMgr
mo_task_code = a.mo_task_code,
workline_id = a.workline_id,
process_id = a.process_id,
- process_code =b.process_code,
+ process_code = b.process_code,
process_name = b.process_name,
plan_start_date = a.estimated_start_date,
plan_end_date = a.estimated_end_date,