From ae41b9b78ba38a2ef1256592eb186a0c4045aac0 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Wed, 24 May 2023 11:52:47 +0800
Subject: [PATCH 01/15] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E5=A4=96=E4=BF=AE?=
=?UTF-8?q?=E7=99=BB=E8=AE=B0=20=E6=B5=81=E7=A8=8B=E8=BF=98=E4=B8=8D?=
=?UTF-8?q?=E6=94=AF=E6=8C=81=E9=80=80=E5=9B=9E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/RepairApplyOutRegisterInput.cs | 42 ++++++++
.../Entity/EqpRepairApply.cs | 2 +-
.../Entity/EqpRepairOutApply.cs | 22 +++++
.../Entity/EqpSpotInsItem.cs | 2 +-
.../IEqpRepairOutApplyService.cs | 12 +++
.../Tnb.EquipMgr/EqpRepairOutApplyService.cs | 97 ++++++++++++++++---
.../Tnb.EquipMgr/EquSpotInsRecordService.cs | 2 +-
.../Manager/User/UserManager.cs | 13 ++-
.../Tnb.WorkFlow/Service/FlowTaskService.cs | 1 +
9 files changed, 175 insertions(+), 18 deletions(-)
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs
new file mode 100644
index 00000000..22d61759
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/RepairApplyOutRegisterInput.cs
@@ -0,0 +1,42 @@
+namespace Tnb.EquipMgr.Entities.Dto
+{
+ public class RepairApplyOutRegisterInput
+ {
+ public string id { get; set; }
+
+ ///
+ /// 实际维修供应商id
+ ///
+ public string? real_supplier_id { get; set; }
+
+ ///
+ /// 附件
+ ///
+ public string? attachment { get; set; }
+
+ ///
+ /// 费用
+ ///
+ public decimal? cost { get; set; }
+
+ ///
+ /// 修复时间
+ ///
+ public DateTime? repair_time { get; set; }
+
+ ///
+ /// 维修耗时
+ ///
+ public decimal? repair_take_time { get; set; }
+
+ ///
+ /// 维修备注
+ ///
+ public string? repair_remark { get; set; }
+
+ ///
+ /// 报修申请id
+ ///
+ public string repair_apply_id { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs
index 874ef15f..96668b36 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairApply.cs
@@ -47,7 +47,7 @@ public partial class EqpRepairApply : BaseEntity
///
/// 设备ID
///
- public string? equip_id { get; set; }
+ public string equip_id { get; set; }
///
/// 申请用户ID
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs
index f8aca2cc..adc2cfe6 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpRepairOutApply.cs
@@ -113,5 +113,27 @@ public partial class EqpRepairOutApply : BaseEntity
/// 所属组织
///
public string? org_id { get; set; }
+
+ ///
+ /// 附件
+ ///
+ public string? attachment { get; set; }
+
+ ///
+ /// 实际维修供应商
+ ///
+ public string? real_supplier_id { get; set; }
+
+ ///
+ /// 流程id
+ ///
+ [SugarColumn(ColumnName = "f_flowid")]
+ public string? flow_id { get; set; }
+
+ ///
+ /// 流程任务id
+ ///
+ [SugarColumn(ColumnName = "f_flowtaskid")]
+ public string? flow_task_id { get; set; }
}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
index 086cad89..35deb165 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsItem.cs
@@ -82,7 +82,7 @@ public partial class EqpSpotInsItem : BaseEntity
///
/// 单位id
///
- public string unit_id { get; set; } = string.Empty;
+ public string? unit_id { get; set; } = string.Empty;
///
/// 点巡检方法
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs
index 8416d5f7..5e3b57dd 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpRepairOutApplyService.cs
@@ -6,11 +6,23 @@ namespace Tnb.EquipMgr.Interfaces
public interface IEqpRepairOutApplyService
{
+ ///
+ /// 获取外修申请信息
+ ///
+ ///
+ public Task GetInfo(Dictionary dic);
+
///
/// 外修申请
///
///
public Task OutApply(RepairOutApplyInput input);
+ ///
+ /// 外修登记
+ ///
+ ///
+ public Task Register(RepairApplyOutRegisterInput input);
+
}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs b/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
index 02b29e68..0707afa3 100644
--- a/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EqpRepairOutApplyService.cs
@@ -1,10 +1,13 @@
using JNPF.Common.Core.Manager;
using JNPF.Common.Enums;
+using JNPF.Common.Models.WorkFlow;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.FriendlyException;
+using JNPF.WorkFlow.Interfaces.Service;
using Microsoft.AspNetCore.Mvc;
+using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Entities.Dto;
@@ -21,36 +24,50 @@ namespace Tnb.EquipMgr
{
private readonly ISqlSugarRepository _repository;
private readonly IUserManager _userManager;
+ private readonly IFlowTaskService _flowTaskService;
+ private const string flowId = "26299060075302";
public EqpRepairOutApplyService(ISqlSugarRepository repository,
+ IFlowTaskService flowTaskService,
IUserManager userManager)
{
_repository = repository;
_userManager = userManager;
+ _flowTaskService = flowTaskService;
}
+ [HttpPost]
+ public async Task GetInfo(Dictionary dic)
+ {
+ string id = dic["id"];
+ EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable().SingleAsync(x => x.id == id);
+ return await _repository.GetSingleAsync(x => x.repair_apply_id==eqpRepairApply.id);
+ }
+
+ [HttpPost]
public async Task OutApply(RepairOutApplyInput input)
{
var db = _repository.AsSugarClient();
+ string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
DbResult result = await db.Ado.UseTranAsync(async () =>
{
if (string.IsNullOrEmpty(input.id))
{
- await _repository.InsertAsync(new EqpRepairOutApply
- {
- id = SnowflakeIdHelper.NextId(),
- repair_apply_id = input.repair_apply_id,
- equip_id = input.equip_id,
- supplier_id = input.supplier_id,
- estimated_cost = input.estimated_cost,
- construction_period_requirement = input.construction_period_requirement,
- out_apply_reason = input.out_apply_reason,
- remark = input.remark,
- create_id = _userManager.UserId,
- create_time = DateTime.Now,
- approve_status = RepairOutApplyStatus.TOBEAPPROVE,
- });
+ // await _repository.InsertAsync(new EqpRepairOutApply
+ // {
+ // id = id,
+ // repair_apply_id = input.repair_apply_id,
+ // equip_id = input.equip_id,
+ // supplier_id = input.supplier_id,
+ // estimated_cost = input.estimated_cost,
+ // construction_period_requirement = input.construction_period_requirement,
+ // out_apply_reason = input.out_apply_reason,
+ // remark = input.remark,
+ // create_id = _userManager.UserId,
+ // create_time = DateTime.Now,
+ // approve_status = RepairOutApplyStatus.TOBEAPPROVE,
+ // });
}
else
{
@@ -73,10 +90,62 @@ namespace Tnb.EquipMgr
.SetColumns(x=>x.status == RepairApplyStatus.OUTAPPLYAPPROVE)
.Where(x=>x.id==input.repair_apply_id).ExecuteCommandAsync();
+
+
});
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+
+ //todo 退回流程
+ if (result.IsSuccess)
+ {
+ _flowTaskService.Create(new FlowTaskSubmitModel()
+ {
+ flowId = flowId,
+ parentId = "0",
+ formData = new JObject()
+ {
+ {"id",id},
+ {"repair_apply_id",input.repair_apply_id},
+ {"equip_id",input.equip_id},
+ {"create_id",_userManager.UserId},
+ {"supplier_id",input.supplier_id},
+ {"estimated_cost",input.estimated_cost},
+ {"construction_period_requirement",input.construction_period_requirement},
+ {"out_apply_reason",input.out_apply_reason},
+ {"remark",input.remark},
+ {"approve_status",RepairOutApplyStatus.TOBEAPPROVE},
+ }
+
+ });
+ }
return result.IsSuccess ? "操作成功" : result.ErrorMessage;
}
+
+ [HttpPost]
+ public async Task Register(RepairApplyOutRegisterInput input)
+ {
+
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ await _repository.UpdateAsync(x => new EqpRepairOutApply()
+ {
+ real_supplier_id = input.real_supplier_id,
+ cost = input.cost,
+ repair_time = input.repair_time,
+ repair_take_time = input.repair_take_time,
+ repair_remark = input.repair_remark,
+ attachment = input.attachment,
+ }, x => x.id == input.id);
+
+ await db.Updateable().SetColumns(x => x.status == RepairApplyStatus.COMPLETED)
+ .Where(x => x.id == input.repair_apply_id).ExecuteCommandAsync();
+ });
+ if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+
+ return result.IsSuccess ? "登记成功" : result.ErrorMessage;
+ }
+
}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
index d7fc7a2f..cf3a76aa 100644
--- a/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsRecordService.cs
@@ -121,7 +121,7 @@ namespace Tnb.EquipMgr
{
repeat_result = input.repeat_result,
repeat_remark = input.repeat_remark,
- repeat_post_info_user_id = _userManager.UserId,
+ repeat_user_id = _userManager.UserId,
repeat_time = DateTime.Now,
status = SpotInsRecordExecutionStatus.COMPLETED
}, x => x.id == input.id);
diff --git a/common/Tnb.Common.Core/Manager/User/UserManager.cs b/common/Tnb.Common.Core/Manager/User/UserManager.cs
index 9f19adae..0d8f67ac 100644
--- a/common/Tnb.Common.Core/Manager/User/UserManager.cs
+++ b/common/Tnb.Common.Core/Manager/User/UserManager.cs
@@ -193,7 +193,18 @@ public class UserManager : IUserManager, IScoped
///
public string UserOrigin
{
- get => _httpContext?.Request.Headers["jnpf-origin"];
+ //modifyby zhoukeda 调用发起工作流接口取不到pc还是app 改成默认pc
+ get
+ {
+ try
+ {
+ return _httpContext?.Request.Headers["jnpf-origin"] ?? "pc";
+ }
+ catch (Exception e)
+ {
+ return "pc";
+ }
+ }
}
///
diff --git a/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs b/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs
index 262df2ba..ce7fdec1 100644
--- a/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs
+++ b/workflow/Tnb.WorkFlow/Service/FlowTaskService.cs
@@ -6,6 +6,7 @@ using JNPF.FriendlyException;
using JNPF.WorkFlow.Entitys.Model;
using JNPF.WorkFlow.Interfaces.Manager;
using JNPF.WorkFlow.Interfaces.Service;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace JNPF.WorkFlow.Service;
From 991f6618ee8dcd1bfd6c59a039db13a69dcf43ad Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Wed, 24 May 2023 17:24:05 +0800
Subject: [PATCH 02/15] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=BF=9D=E5=85=BB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/EqpMaintainItem.cs | 85 +--------
.../Entity/EqpMaintainRecordD.cs | 92 ++++++++++
.../Entity/EqpMaintainRecordH.cs | 167 ++++++++++++++++++
.../Entity/EqpMaintainTemD.cs | 27 +++
.../Entity/EqpMaintainTemEquipD.cs | 27 +++
.../Entity/EqpMaintainTemEquipH.cs | 137 ++++++++++++++
.../Entity/EqpMaintainTemH.cs | 132 ++++++++++++++
.../Entity/EqpSpotInsRecordD.cs | 7 +-
.../IEqpMaintainTemEquipService.cs | 13 ++
.../IEqpMaintainTemService.cs | 12 ++
.../IEquSpotInsTemEquipService.cs | 7 -
.../EqpMaintainTemEquipService.cs | 52 ++++++
.../Tnb.EquipMgr/EqpMaintainTemService.cs | 119 +++++++++++++
.../Tnb.EquipMgr/EquSpotInsTemEquipService.cs | 23 +--
.../GenerateMaintainPlanTimeWorker.cs | 153 ++++++++++++++++
.../GenerateSpotInspectionPlanTimeWorker.cs | 2 +-
16 files changed, 945 insertions(+), 110 deletions(-)
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
create mode 100644 taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs
index 1c6c27be..754685cf 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainItem.cs
@@ -5,7 +5,7 @@ using SqlSugar;
namespace Tnb.EquipMgr.Entities;
///
-/// 保养项目
+/// 设备保养项目
///
[SugarTable("eqp_maintain_item")]
public partial class EqpMaintainItem : BaseEntity
@@ -34,25 +34,20 @@ public partial class EqpMaintainItem : BaseEntity
///
public string? modify_id { get; set; }
- ///
- /// 设备类型
- ///
- public string? equip_type_id { get; set; }
-
///
/// 项目编码
///
- public string? item_code { get; set; }
+ public string? code { get; set; }
///
/// 项目名称
///
- public string? item_name { get; set; }
+ public string? name { get; set; }
///
/// 保养类型
///
- public int? maintain_type { get; set; }
+ public string maintain_type { get; set; }
///
/// 保养内容
@@ -74,79 +69,9 @@ public partial class EqpMaintainItem : BaseEntity
///
public int? ordinal { get; set; }
- ///
- /// 是否启用
- ///
- public int? enabled { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend01 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend02 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend03 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend04 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend05 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend06 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend07 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend08 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend09 { get; set; }
-
- ///
- /// TODO
- ///
- public string? extend10 { get; set; }
-
- ///
- /// 删除用户
- ///
- public string? delete_id { get; set; }
-
- ///
- /// 删除时间
- ///
- public DateTime? delete_time { get; set; }
-
- ///
- /// 删除标志
- ///
- public short? deleted { get; set; }
-
///
/// 所属组织
///
public string? org_id { get; set; }
-}
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
new file mode 100644
index 00000000..215c962a
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
@@ -0,0 +1,92 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养执行记录子表
+///
+[SugarTable("eqp_maintain_record_d")]
+public partial class EqpMaintainRecordD : BaseEntity
+{
+ public EqpMaintainRecordD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备保养执行记录id
+ ///
+ public string maintain_record_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养检项id
+ ///
+ public string maintain_item_id { get; set; } = string.Empty;
+
+ ///
+ /// 编码
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 名称
+ ///
+ public string? name { get; set; }
+
+ ///
+ /// 结果 1 通过 2 不通过
+ ///
+ public string? result { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public long ordinal { get; set; }
+
+ ///
+ /// 设备保养设备模板id
+ ///
+ public string? maintain_tem_equip_id { get; set; }
+
+ ///
+ /// 是否通过
+ ///
+ public string? is_pass { get; set; }
+
+ ///
+ /// 保养项描述
+ ///
+ public string? descrip { get; set; }
+
+ ///
+ /// 保养类型
+ ///
+ public string maintain_type { get; set; } = string.Empty;
+
+ ///
+ /// 保养内容
+ ///
+ public string? maintain_content { get; set; }
+
+ ///
+ /// 保养结果描述
+ ///
+ public string? maintain_descrip { get; set; }
+
+ ///
+ /// 复核 1 通过 2 不通过
+ ///
+ public string? repeat_result { get; set; }
+
+ ///
+ /// 复核结果描述
+ ///
+ public string? repeat_descrip { get; set; }
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
new file mode 100644
index 00000000..0b5aebc5
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
@@ -0,0 +1,167 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养执行记录主表
+///
+[SugarTable("eqp_maintain_record_h")]
+public partial class EqpMaintainRecordH : BaseEntity
+{
+ public EqpMaintainRecordH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 设备id
+ ///
+ public string equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养设备模板id
+ ///
+ public string maintain_tem_equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 结果1 合格2不合格
+ ///
+ public string? result { get; set; }
+
+ ///
+ /// 点巡检结果备注
+ ///
+ public string? result_remark { get; set; }
+
+ ///
+ /// 执行时间
+ ///
+ public DateTime? execute_time { get; set; }
+
+ ///
+ /// 状态 1待执行 2 待复核 3 已完成
+ ///
+ public string? status { get; set; }
+
+ ///
+ /// 执行人id
+ ///
+ public string? execute_user_id { get; set; }
+
+ ///
+ /// 设备类型id
+ ///
+ public string? equip_type_id { get; set; }
+
+ ///
+ /// 不合格推送
+ ///
+ public int? is_send { get; set; }
+
+ ///
+ /// 推送时间
+ ///
+ public DateTime? send_date_time { get; set; }
+
+ ///
+ /// 推送人id
+ ///
+ public string? send_id { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string? code { get; set; }
+
+ ///
+ /// 计划执行通知提前量
+ ///
+ public int? plan_run_notice { get; set; }
+
+ ///
+ /// 计划执行通知提前量单位 1 小时 2 天 3 周
+ ///
+ public string? plan_run_notice_unit { get; set; }
+
+ ///
+ /// 执行滞后推送时间
+ ///
+ public int? plan_delay { get; set; }
+
+ ///
+ /// 执行滞后推送时间单位 1 小时 2 天 3 周
+ ///
+ public string? plan_delay_unit { get; set; }
+
+ ///
+ /// 复核岗位id
+ ///
+ public string? repeat_post_info_user_id { get; set; }
+
+ ///
+ /// 责任岗位id
+ ///
+ public string? send_post_info_user_id { get; set; }
+
+ ///
+ /// 是否复核
+ ///
+ public string? is_repeat { get; set; }
+
+ ///
+ /// 复核时间
+ ///
+ public DateTime? repeat_time { get; set; }
+
+ ///
+ /// 复核备注
+ ///
+ public string? repeat_remark { get; set; }
+
+ ///
+ /// 复核人id
+ ///
+ public string? repeat_user_id { get; set; }
+
+ ///
+ /// 仅用于关联表字段查询用不存储数据
+ ///
+ public string? query_info { get; set; }
+
+ ///
+ /// 附件
+ ///
+ public string? attachment { get; set; }
+
+ ///
+ /// 复核结果
+ ///
+ public string? repeat_result { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
new file mode 100644
index 00000000..b33f7c47
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
@@ -0,0 +1,27 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养模板子表
+///
+[SugarTable("eqp_maintain_tem_d")]
+public partial class EqpMaintainTemD : BaseEntity
+{
+ public EqpMaintainTemD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备保养模板主表id
+ ///
+ public string maintain_tem_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养项id
+ ///
+ public string maintain_item_id { get; set; } = string.Empty;
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs
new file mode 100644
index 00000000..7f5cf251
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipD.cs
@@ -0,0 +1,27 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养设备模板子表
+///
+[SugarTable("eqp_maintain_tem_equip_d")]
+public partial class EqpMaintainTemEquipD : BaseEntity
+{
+ public EqpMaintainTemEquipD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备保养设备模板主表id
+ ///
+ public string maintain_tem_equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 设备保养项id
+ ///
+ public string maintain_item_id { get; set; } = string.Empty;
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
new file mode 100644
index 00000000..27755b9c
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
@@ -0,0 +1,137 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养设备模板主表
+///
+[SugarTable("eqp_maintain_tem_equip_h")]
+public partial class EqpMaintainTemEquipH : BaseEntity
+{
+ public EqpMaintainTemEquipH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建时间
+ ///
+ public DateTime create_time { get; set; } = DateTime.Now;
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 设备保养模板表id
+ ///
+ public string? maintain_tem_id { get; set; }
+
+ ///
+ /// 设备id
+ ///
+ public string? equip_id { get; set; }
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public int ordinal { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 名称
+ ///
+ public string name { get; set; } = string.Empty;
+
+ ///
+ /// 周期
+ ///
+ public int plan_cycle { get; set; }
+
+ ///
+ /// 周期方式 1 单次 2 循环
+ ///
+ public string? plan_cycle_unit { get; set; }
+
+ ///
+ /// 计划执行通知提前量
+ ///
+ public int? plan_run_notice { get; set; }
+
+ ///
+ /// 计划执行通知提前量单位 1 小时 2 天 3 周
+ ///
+ public string? plan_run_notice_unit { get; set; }
+
+ ///
+ /// 执行滞后推送时间
+ ///
+ public int? plan_delay { get; set; }
+
+ ///
+ /// 执行滞后推送时间单位 1 小时 2 天 3 周
+ ///
+ public string? plan_delay_unit { get; set; }
+
+ ///
+ /// 启用时间
+ ///
+ public DateTime start_time { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否启用
+ ///
+ public string is_start { get; set; }
+
+ ///
+ /// 是否复核
+ ///
+ public string is_repeat { get; set; }
+
+ ///
+ /// 复核岗位id
+ ///
+ public string repeat_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 不合格推送 0 不推送 1 推送
+ ///
+ public int is_send { get; set; }
+
+ ///
+ /// 推送人id
+ ///
+ public string? send_post_id { get; set; }
+
+ ///
+ /// 责任岗位id
+ ///
+ public string send_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
new file mode 100644
index 00000000..a666bf62
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
@@ -0,0 +1,132 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备保养模板主表
+///
+[SugarTable("eqp_maintain_tem_h")]
+public partial class EqpMaintainTemH : BaseEntity
+{
+ public EqpMaintainTemH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 设备类型id
+ ///
+ public string? equip_type_id { get; set; }
+
+ ///
+ /// 编码
+ ///
+ public string code { get; set; } = string.Empty;
+
+ ///
+ /// 名称
+ ///
+ public string name { get; set; } = string.Empty;
+
+ ///
+ /// 周期
+ ///
+ public int plan_cycle { get; set; }
+
+ ///
+ /// 周期方式 1 单次 2 循环
+ ///
+ public string plan_cycle_unit { get; set; }
+
+ ///
+ /// 计划执行通知提前量
+ ///
+ public int? plan_run_notice { get; set; }
+
+ ///
+ /// 计划执行通知提前量单位 1 小时 2 天 3 周
+ ///
+ public string? plan_run_notice_unit { get; set; }
+
+ ///
+ /// 执行滞后推送时间
+ ///
+ public int? plan_delay { get; set; }
+
+ ///
+ /// 执行滞后推送时间单位 1 小时 2 天 3 周
+ ///
+ public string? plan_delay_unit { get; set; }
+
+ ///
+ /// 启用时间
+ ///
+ public DateTime start_time { get; set; } = DateTime.Now;
+
+ ///
+ /// 是否启用
+ ///
+ public int is_start { get; set; }
+
+ ///
+ /// 是否复核
+ ///
+ public int is_repeat { get; set; }
+
+ ///
+ /// 复核岗位id
+ ///
+ public string repeat_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 备注
+ ///
+ public string? remark { get; set; }
+
+ ///
+ /// 排序
+ ///
+ public int? ordinal { get; set; }
+
+ ///
+ /// 不合格推送 0 不推送 1 推送
+ ///
+ public int is_send { get; set; }
+
+ ///
+ /// 推送人id
+ ///
+ public string? send_post_id { get; set; }
+
+ ///
+ /// 责任岗位id
+ ///
+ public string send_post_info_user_id { get; set; } = string.Empty;
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
index 2de21636..61c0ae8c 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
@@ -72,7 +72,7 @@ public partial class EqpSpotInsRecordD : BaseEntity
///
/// 单位id
///
- public string unit_id { get; set; } = string.Empty;
+ public string? unit_id { get; set; } = string.Empty;
///
/// 点巡检方法
@@ -108,5 +108,10 @@ public partial class EqpSpotInsRecordD : BaseEntity
/// 是否通过
///
public string? is_pass { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
}
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs
new file mode 100644
index 00000000..1b6496a5
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemEquipService.cs
@@ -0,0 +1,13 @@
+namespace Tnb.EquipMgr.Interfaces
+{
+ public interface IEqpMaintainTemEquipService
+ {
+
+ ///
+ /// 停止计划
+ ///
+ ///
+ ///
+ public Task Stop(Dictionary parameters);
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
new file mode 100644
index 00000000..59962bce
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
@@ -0,0 +1,12 @@
+using Tnb.EquipMgr.Entities.Dto;
+namespace Tnb.EquipMgr.Interfaces
+{
+ public interface IEqpMaintainTemService
+ {
+ ///
+ /// 根据模板id发布到设备
+ ///
+ ///
+ public Task Publish(SpotInsTemPublishInput input);
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs
index 48b4b400..38790883 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquSpotInsTemEquipService.cs
@@ -2,13 +2,6 @@ namespace Tnb.EquipMgr.Interfaces
{
public interface IEquSpotInsTemEquipService
{
- // ///
- // /// 获取数
- // ///
- // ///
- // ///
- // public Task GetTree();
-
///
/// 停止计划
///
diff --git a/EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
new file mode 100644
index 00000000..fc9f254a
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
@@ -0,0 +1,52 @@
+using JNPF.Common.Enums;
+using JNPF.Common.Security;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.EquipMgr.Interfaces;
+using Tnb.EquipMgr.Entities;
+
+namespace Tnb.EquipMgr
+{
+ ///
+ /// 设备保养设备模板
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class EqpMaintainTemEquipService : IEqpMaintainTemEquipService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+
+ public EqpMaintainTemEquipService(ISqlSugarRepository repository)
+ {
+ _repository = repository;
+ }
+
+
+ [HttpPost]
+ public async Task Stop(Dictionary parameters)
+ {
+ string id = parameters["id"];
+ DbResult result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
+ {
+ await _repository.UpdateAsync(x => new EqpMaintainTemEquipH()
+ {
+ is_start = "0"
+ }, x => x.id == id);
+ List ids = await _repository.AsSugarClient().Queryable()
+ .Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED)
+ .Select(x => x.id).ToListAsync();
+ await _repository.AsSugarClient().Deleteable()
+ .Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync();
+
+ await _repository.AsSugarClient().Deleteable()
+ .Where(x => ids.Contains(x.maintain_record_id)).ExecuteCommandAsync();
+
+ });
+
+ if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ }
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
new file mode 100644
index 00000000..bc1bc84f
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
@@ -0,0 +1,119 @@
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Enums;
+using JNPF.Common.Security;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.EquipMgr.Entities;
+using Tnb.EquipMgr.Entities.Dto;
+using Tnb.EquipMgr.Interfaces;
+
+namespace Tnb.EquipMgr
+{
+ ///
+ /// 设备保养检模板管理
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class EqpMaintainTemService : IEqpMaintainTemService, IDynamicApiController, ITransient
+ {
+ private const string ModuleId = "26123080740885";
+ private readonly ISqlSugarRepository _repository;
+ private readonly IUserManager _userManager;
+
+ public EqpMaintainTemService(ISqlSugarRepository repository,
+ IUserManager userManager)
+ {
+ _repository = repository;
+ _userManager = userManager;
+ }
+
+ ///
+ /// 根据模板id发布到设备
+ ///
+ ///
+ [HttpPost]
+ public async Task Publish(SpotInsTemPublishInput input)
+ {
+ var db = _repository.AsSugarClient();
+ DbResult result = await db.Ado.UseTranAsync(async () =>
+ {
+ EqpMaintainTemH eqpMaintainTemH = await _repository.GetSingleAsync(x => x.id == input.id);
+ List eqpMaintainTemDs = await db.Queryable().Where(x=>x.maintain_tem_id==input.id).ToListAsync();
+
+ if (input.equipIds != null && input.equipIds.Length > 0)
+ {
+ List insertEqpMaintainTemEquipHs = new List();
+ List insertEqpMaintainTemEquipDs = new List();
+ foreach (var equipId in input.equipIds)
+ {
+ string id = SnowflakeIdHelper.NextId();
+ string code = $"{DateTime.Now.ToString("yyyyMMdd") + equipId}";
+ EqpMaintainTemEquipH eqpMaintainTemEquipH = new EqpMaintainTemEquipH()
+ {
+ id = id,
+ code = code,
+ name = eqpMaintainTemH.name+equipId,
+ plan_cycle = eqpMaintainTemH.plan_cycle,
+ plan_cycle_unit = eqpMaintainTemH.plan_cycle_unit,
+ plan_run_notice = eqpMaintainTemH.plan_run_notice,
+ plan_delay = eqpMaintainTemH.plan_delay,
+ start_time = eqpMaintainTemH.start_time,
+ is_start = eqpMaintainTemH.is_start.ToString(),
+ is_repeat = eqpMaintainTemH.is_repeat.ToString(),
+ is_send = eqpMaintainTemH.is_send,
+ maintain_tem_id = input.id,
+ equip_id = equipId,
+ remark = eqpMaintainTemH.remark,
+ plan_run_notice_unit = eqpMaintainTemH.plan_run_notice_unit,
+ plan_delay_unit = eqpMaintainTemH.plan_delay_unit,
+ repeat_post_info_user_id = eqpMaintainTemH.repeat_post_info_user_id,
+ send_post_info_user_id = eqpMaintainTemH.send_post_info_user_id,
+ send_post_id = eqpMaintainTemH.send_post_id,
+ org_id = eqpMaintainTemH.org_id,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ };
+ insertEqpMaintainTemEquipHs.Add(eqpMaintainTemEquipH);
+
+ if (eqpMaintainTemDs != null && eqpMaintainTemDs.Count > 0)
+ {
+ foreach (var eqpMaintainTem in eqpMaintainTemDs)
+ {
+ EqpMaintainTemEquipD eqpMaintainTemEquipD = new EqpMaintainTemEquipD()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ maintain_item_id = eqpMaintainTem.maintain_item_id,
+ maintain_tem_equip_id = id,
+ };
+ insertEqpMaintainTemEquipDs.Add(eqpMaintainTemEquipD);
+ }
+ }
+
+ EqpMaintainTemEquipH oldMaintainTemEquipH = await db.Queryable().Where(x => x.maintain_tem_id == input.id && x.equip_id == equipId).FirstAsync();
+ await db.Deleteable().Where(x => x.maintain_tem_id == input.id && x.equip_id==equipId).ExecuteCommandAsync();
+ if(oldMaintainTemEquipH!=null)
+ await db.Deleteable().Where(x => x.maintain_tem_equip_id==oldMaintainTemEquipH.id).ExecuteCommandAsync();
+ }
+
+ if (insertEqpMaintainTemEquipHs != null && insertEqpMaintainTemEquipHs.Count > 0)
+ {
+ await db.Insertable(insertEqpMaintainTemEquipHs).ExecuteCommandAsync();
+ }
+
+ if (insertEqpMaintainTemEquipDs != null && insertEqpMaintainTemEquipDs.Count > 0)
+ {
+ await db.Insertable(insertEqpMaintainTemEquipDs).ExecuteCommandAsync();
+ }
+
+ }
+
+ });
+
+ if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
+ return result.IsSuccess ? "发布成功" : result.ErrorMessage;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs b/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
index f866e77c..b4ff4caa 100644
--- a/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EquSpotInsTemEquipService.cs
@@ -11,7 +11,7 @@ using Tnb.EquipMgr.Entities;
namespace Tnb.EquipMgr
{
///
- /// 设备管理
+ /// 点巡检设备模板
///
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
[Route("api/[area]/[controller]/[action]")]
@@ -24,26 +24,7 @@ namespace Tnb.EquipMgr
_repository = repository;
}
- // public async Task GetTree()
- // {
- // List eqpEquipments =
- // var data = _repository.AsSugarClient().Queryable()
- // .Where(x => x.status == 1)
- // .Select((x) => new TreeModel
- // {
- // id = x.id,
- // parentId = "-1",
- // hasChildren = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Any(),
- // isLeaf = false,
- // num = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Count(),
- // children = SqlFunc.Subqueryable().Where(y=>y.eqp_type_id==x.id).Select(y=>new TreeModel()
- // {
- //
- // }).ToList(model => ),
- // });
- // return new { list = 1 };
- // }
-
+ [HttpPost]
public async Task Stop(Dictionary parameters)
{
string id = parameters["id"];
diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs
new file mode 100644
index 00000000..2226d6eb
--- /dev/null
+++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateMaintainPlanTimeWorker.cs
@@ -0,0 +1,153 @@
+using JNPF.Common.Security;
+using JNPF.Logging;
+using Microsoft.AspNetCore.Components;
+using SqlSugar;
+using Tnb.EquipMgr.Entities;
+
+namespace JNPF.TaskScheduler.Listener
+{
+ ///
+ /// 生成设备保养计划
+ ///
+ public class GenerateMaintainPlanTimeWorker : ISpareTimeWorker
+ {
+ private ISqlSugarRepository _repository => App.GetService>();
+ // public GenerateSpotInspectionPlanTimeWorker(ISqlSugarRepository repository)
+ // {
+ // _repository = repository;
+ // }
+
+ [SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
+ public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
+ {
+ Log.Information("----------------------开始生成设备保养计划----------------------");
+
+ try
+ {
+ List eqpSpotInsTemEquipHsByOne = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "1");
+ List eqpSpotInsTemEquipHsByCirculate = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "2");
+ List tobeCreateList = new List();
+ List tobeCreateTemplets = new List();
+ var db = _repository.AsSugarClient();
+
+ foreach (var item in eqpSpotInsTemEquipHsByOne)
+ {
+ if (item.start_time.AddHours((double)item.plan_cycle).ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd"))
+ {
+ tobeCreateTemplets.Add(item);
+ }
+ }
+
+ if (eqpSpotInsTemEquipHsByCirculate != null && eqpSpotInsTemEquipHsByCirculate.Count > 0)
+ {
+
+ //整除表示一个周期到了
+ foreach (var item in eqpSpotInsTemEquipHsByCirculate)
+ {
+ TimeSpan ts1 = new TimeSpan(Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd")).Ticks);
+ TimeSpan ts2 = new TimeSpan(Convert.ToDateTime(item.start_time.ToString("yyyy-MM-dd")).Ticks);
+ TimeSpan ts3 = ts1.Subtract(ts2).Duration();
+ if (ts3.TotalDays * 10 % (10 * (double)item.plan_cycle)==0)
+ {
+ tobeCreateTemplets.Add(item);
+ }
+ }
+ }
+
+ if (tobeCreateTemplets != null && tobeCreateTemplets.Count > 0)
+ {
+ List equipments = db.Queryable().Where(x => x.life==Tnb.EquipMgr.EquipmentLife.ENABLE).ToList();
+ int index = 1;
+ foreach (var item in tobeCreateTemplets)
+ {
+ //只有启用设备才生成计划
+ if (equipments.FirstOrDefault(x => x.id == item.equip_id) == null)
+ continue;
+
+ string code = $"{DateTime.Now.ToString("yyyyMMdd")+(index++).ToString().PadLeft(3,'0')}";
+ tobeCreateList.Add(new EqpMaintainRecordH()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ code = code,
+ // equip_type_id = item.equip_type_id,
+ equip_id = item.equip_id,
+ maintain_tem_equip_id = item.id,
+ plan_run_notice = item.plan_run_notice,
+ plan_run_notice_unit = item.plan_run_notice_unit,
+ plan_delay = item.plan_delay,
+ plan_delay_unit = item.plan_delay_unit,
+ send_post_info_user_id = item.send_post_info_user_id,
+ is_repeat = item.is_repeat,
+ repeat_post_info_user_id = item.repeat_post_info_user_id,
+ is_send = item.is_send,
+ create_time = DateTime.Now,
+ status = Tnb.EquipMgr.SpotInsRecordExecutionStatus.TOBEEXECUTED
+ });
+ }
+ }
+
+
+ if (tobeCreateList != null && tobeCreateList.Count > 0)
+ {
+ List templetIDs = tobeCreateList.Select(x => x.maintain_tem_equip_id).ToList();
+ List spotInsTemEquipDs = db.Queryable().Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToList();
+ List spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList();
+ List spotCheckItems = db.Queryable().Where(x => spotInsItemIDs.Contains(x.id)).ToList();
+
+
+ foreach (var tobeCreatePlan in tobeCreateList)
+ {
+ List spotInsRecordDs = new List();
+ List spotInsItems = spotInsTemEquipDs
+ .Where(x => x.maintain_tem_equip_id == tobeCreatePlan.maintain_tem_equip_id)
+ .Select(x => x.maintain_item_id).ToList();
+ List tobeCreateItems = spotCheckItems.Where(x => spotInsItems.Contains(x.id)).ToList();
+ foreach (var tobeCreateItem in tobeCreateItems)
+ {
+ spotInsRecordDs.Add(new EqpMaintainRecordD()
+ {
+ id = SnowflakeIdHelper.NextId(),
+ maintain_record_id = tobeCreatePlan.id,
+ maintain_tem_equip_id = tobeCreatePlan.maintain_tem_equip_id,
+ maintain_item_id = tobeCreateItem.id,
+ code = tobeCreateItem.code,
+ name = tobeCreateItem.name,
+ maintain_type = tobeCreateItem.maintain_type,
+ maintain_content = tobeCreateItem.maintain_content,
+ descrip = tobeCreateItem.descrip,
+ remark = tobeCreateItem.remark
+ });
+ }
+
+ var dbResult = db.Ado.UseTran(() =>
+ {
+ if (tobeCreateList != null && tobeCreateList.Count > 0)
+ {
+ db.Insertable(tobeCreateList).ExecuteCommand();
+ }
+
+ if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
+ {
+ db.Insertable(spotInsRecordDs).ExecuteCommand();
+ }
+ });
+ if (!dbResult.IsSuccess)
+ {
+ Console.WriteLine(dbResult.ErrorMessage);
+ Log.Error(dbResult.ErrorMessage);
+ }
+ Log.Information($"---------------生成{tobeCreateList.Count}个计划---------------");
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e.Message);
+ Log.Error(e.Message);
+ }
+
+
+ Log.Information("----------------------结束生成设备保养计划----------------------");
+ }
+ }
+}
\ No newline at end of file
diff --git a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
index 80e723b7..fbce46ad 100644
--- a/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
+++ b/taskschedule/Tnb.TaskScheduler/Listener/GenerateSpotInspectionPlanTimeWorker.cs
@@ -17,7 +17,7 @@ namespace JNPF.TaskScheduler.Listener
// _repository = repository;
// }
- //[SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
+ [SpareTime("0 0,30 * * * ?", "生成点巡检计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
{
Log.Information("----------------------开始生成点巡检计划----------------------");
From d12e05d737845e5afae35b7c561de88bae8bc850 Mon Sep 17 00:00:00 2001
From: "DEVICE8\\12494"
Date: Wed, 24 May 2023 23:31:13 +0800
Subject: [PATCH 03/15] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=9F=E4=BA=A7bom?=
=?UTF-8?q?=E6=8B=86=E5=88=86=E5=AD=90=E5=B7=A5=E5=8D=95=E4=BB=A3=E7=A0=81?=
=?UTF-8?q?=E8=B0=83=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/SubBomListOutput.cs | 21 ++
BasicData/Tnb.BasicData/BasMbomService.cs | 59 +++--
.../IToolMoldsService.cs | 3 +-
.../Tnb.EquipMgr.Interfaces.csproj | 1 +
.../ToolMoldMaintainRuleService.cs | 1 +
.../ToolMoldMaintainRunService.cs | 2 +-
EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs | 5 +-
.../Dto/DictionaryTreeOutput.cs | 16 ++
.../Dto/PrdManage/GenSubMoCrInput.cs | 4 +-
.../Dto/PrdManage/PrdMotreeOutput.cs | 35 +--
.../Entity/PrdMoTaskDefect.cs | 4 +
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 206 +++++++++++++-----
.../Extension/DictionaryExtensions.cs | 31 ++-
.../Extension/LambdaExpressionExtensions.cs | 23 ++
common/Tnb.Common/Security/TreeHelper.cs | 2 +
visualdev/Tnb.VisualDev/RunService.cs | 21 +-
16 files changed, 336 insertions(+), 98 deletions(-)
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/DictionaryTreeOutput.cs
diff --git a/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs b/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs
index a666855d..f85c64e7 100644
--- a/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs
+++ b/BasicData/Tnb.BasicData.Entities/Dto/SubBomListOutput.cs
@@ -35,5 +35,26 @@ namespace Tnb.BasicData.Entities.Dto
/// 数量
///
public string num { get; set;}
+ ///
+ /// 单位id
+ ///
+ public string unit_id { get; set; }
+ ///
+ /// bomid
+ ///
+ public string bom_id { get; set; }
+ ///
+ /// 工序id
+ ///
+ public string process_id { get; set; }
+ ///
+ /// bom版本
+ ///
+ public string version { get; set; }
+
+ ///
+ /// 工艺路线名称
+ ///
+ public string route_name { get; set; }
}
}
diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs
index 62ec0678..ef2621e8 100644
--- a/BasicData/Tnb.BasicData/BasMbomService.cs
+++ b/BasicData/Tnb.BasicData/BasMbomService.cs
@@ -133,35 +133,51 @@ namespace Tnb.BasicData
///
/// 根据bomid获取对应的子bom列表
///
- ///
+ /// bomId
///
+ ///
+ ///
+ /// returns:
+ ///
{
+ ///
version:bom版本
+ ///
unit_id:单位id
+ ///
route_name:工艺路线名称
+ ///
process_id:工序id
+ ///
material_id:物料id
+ ///
material_code:物料编码
+ ///
material_name:物料名称
+ ///
material_category_code:类别code
+ ///
output_qty:输出参数
+ ///
}
+ ///
[HttpGet]
public async Task GetSubMoListByBomId([FromRoute] string bomId)
{
+
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
- var result = await _db.Queryable().LeftJoin((a, b) => a.route_id == b.route_id)
- .LeftJoin((a, b, c) => b.process_id == c.id)
- .LeftJoin((a, b, c, d) => c.id == d.process_id)
- .LeftJoin((a, b, c, d, e) => d.material_id == e.id)
- .LeftJoin((a, b, c, d, e, f) => e.category_id == f.id)
- .Where((a, b, c, d, e, f) => a.id == bomId)
- .Select((a, b, c, d, e, f) => new SubBomListOutput
- {
- material_id = e.id,
- material_code = e.code,
- material_name = e.name,
- material_category_code = f.category_code,
- num = d.num
- })
- .Mapper(it => it.output_qty = it.num.ParseToInt())
- .Distinct()
- .ToListAsync();
+ var result = await _db.Queryable()
+ .LeftJoin((a, b) => a.route_id == b.id)
+ .LeftJoin((a, b, c) => b.id == c.route_id)
+ .LeftJoin((a, b, c, d) => c.process_id == d.process_id)
+ .LeftJoin((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
+ .Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
+ .Select((a, b, c, d, e) => new SubBomListOutput
+ {
+ version = a.version,
+ unit_id = a.unit_id,
+ route_name = b.name,
+ process_id = c.process_id,
+ material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
+ material_code = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.code),
+ material_name = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.name),
+ material_category_code = "",
+ num = e.num,
+ })
+ .Mapper(it => it.output_qty = it.num.ParseToInt())
+ .ToListAsync();
return result;
}
-
-
-
///
/// 根据物料id获取生产bom
///
@@ -182,6 +198,7 @@ namespace Tnb.BasicData
[HttpGet]
public async Task GetMBomListByMaterialId([FromRoute] string materialId)
{
+
return await _db.Queryable()
.LeftJoin((a, b) => a.material_id == b.id)
.LeftJoin((a, b, c) => a.route_id == c.id)
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs
index 83bd40e9..e1e1f8d9 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IToolMoldsService.cs
@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Entities.Dto;
+using Tnb.ProductionMgr.Entities.Dto;
namespace Tnb.EquipMgr.Interfaces
{
@@ -16,7 +17,7 @@ namespace Tnb.EquipMgr.Interfaces
///
///
///
- public Task> GetEquipmentLists(ToolMoldInput ToolMoldInput);
+ public Task> GetEquipmentLists(ToolMoldInput ToolMoldInput);
///
/// 增加模具设备绑定
///
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj b/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj
index 8bbf5496..510df9dd 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/Tnb.EquipMgr.Interfaces.csproj
@@ -8,6 +8,7 @@
+
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs
index 3581442a..54165647 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRuleService.cs
@@ -141,6 +141,7 @@ 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();
if (maintainRules?.Count > 0)
{
List maintainPlans = new();
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
index 12db28d5..a172f95c 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldMaintainRunService.cs
@@ -47,7 +47,7 @@ namespace Tnb.EquipMgr
public async Task GetMaintainInfoFromByPlanId([FromRoute] string planId)
{
dynamic info = new ExpandoObject();
- var planMoldRelation = await _db.Queryable().FirstAsync(it => it.id == planId);
+ var planMoldRelation = await _db.Queryable().FirstAsync(it => it.maintain_plan_id == planId);
if (planMoldRelation != null)
{
var mold = await _db.Queryable().FirstAsync(it => it.id == planMoldRelation.mold_id);
diff --git a/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs b/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs
index d826c33b..86c41af4 100644
--- a/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs
+++ b/EquipMgr/Tnb.EquipMgr/ToolMoldsService.cs
@@ -18,6 +18,7 @@ using SqlSugar;
using Tnb.EquipMgr.Entities;
using Tnb.EquipMgr.Entities.Dto;
using Tnb.EquipMgr.Interfaces;
+using Tnb.ProductionMgr.Entities.Dto;
namespace Tnb.EquipMgr
{ ///
@@ -67,7 +68,7 @@ namespace Tnb.EquipMgr
///
///
[HttpPost]
- public async Task> GetEquipmentLists(ToolMoldInput ToolMoldInput)
+ public async Task> GetEquipmentLists(ToolMoldInput ToolMoldInput)
{
var db = _repository.AsSugarClient();
var list = await db.Queryable((a, b) => new object[]
@@ -75,7 +76,7 @@ namespace Tnb.EquipMgr
JoinType.Inner, a.id == b.equipment_id,
})
.Where((a, b) => b.mold_id == ToolMoldInput.mold)
- .Select((a, b) => new EquipmentListOutput
+ .Select((a, b) => new Tnb.EquipMgr.Entities.Dto.EquipmentListOutput
{
id = a.id,
eqp_code = a.code,
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/DictionaryTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/DictionaryTreeOutput.cs
new file mode 100644
index 00000000..a5aaca03
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/DictionaryTreeOutput.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.ProductionMgr.Entities.Dto
+{
+ public class DictionaryTreeOutput
+ {
+ public string id { get; set; }
+ public string parentId { get; set; }
+ public List Child { get; set; }
+ public bool HasChild { get; set; }
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GenSubMoCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GenSubMoCrInput.cs
index aa6b1f76..049cf59f 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GenSubMoCrInput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/GenSubMoCrInput.cs
@@ -8,12 +8,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
public class GenSubMoCrInput
{
+ public string bom_id { get; set; }
+
///
/// 父工单id
///
public string mo_id { get; set; }
///
- /// 子物料ids
+ /// 工序ids
///
public List ids { get; set; }
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs
index f274fe7c..166af51e 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs
@@ -7,8 +7,12 @@ using JNPF.Common.Security;
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
{
- public class PrdMotreeOutput : TreeModel
+ public class PrdMoTreeOutput : TreeModel
{
+
+ //public Dictionary row { get; set; }
+
+ #region 注释代码
public string? org_id { get; set; }
///
/// 工单id
@@ -25,6 +29,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
/// 物料编号
///
public string? material_code { get; set; }
+ ///
+ /// 物料名称
+ ///
+ public string material_name { get; set; }
///
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
@@ -39,37 +47,37 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
///
/// 计划生产数量
///
- public int? plan_qty { get; set; }
+ public string plan_qty { get; set; }
///
/// 已投入数量
///
- public int? input_qty { get; set; }
+ public string input_qty { get; set; }
///
/// 已完工数量
///
- public int? complete_qty { get; set; }
+ public string complete_qty { get; set; }
///
/// 报废数量
///
- public int? scrap_qty { get; set; }
+ public string scrap_qty { get; set; }
///
/// 计划开始时间
///
- public DateTime? plan_start_date { get; set; }
+ public string plan_start_date { get; set; }
///
/// 计划结束时间
///
- public DateTime? plan_end_date { get; set; }
+ public string plan_end_date { get; set; }
///
/// 是否生派工单
///
- public int? is_create_dispatch { get; set; }
+ public string is_create_dispatch { get; set; }
///
@@ -80,7 +88,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
///
/// 是否合并
///
- public int? is_merge { get; set; }
+ public string is_merge { get; set; }
///
/// 组合工单
@@ -100,7 +108,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
///
/// 创建时间
///
- public DateTime? create_time { get; set; }
+ public string create_time { get; set; }
///
/// 修改用户
@@ -110,19 +118,20 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
///
/// 修改时间
///
- public DateTime? modify_time { get; set; }
+ public string modify_time { get; set; }
///
/// 物料ID
///
public string? material_id { get; set; }
-
+ public string? material_id_id { get; set; }
///
/// 已排产数量
///
- public int? scheduled_qty { get; set; }
+ public string scheduled_qty { get; set; }
///
/// 父工单id
///
public string parent_id { get; set; }
+ #endregion
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs
index a298e511..d5d476f6 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs
@@ -48,5 +48,9 @@ public partial class PrdMoTaskDefect : BaseEntity
/// 批次
///
public string? batch { get; set; }
+ ///
+ /// 报废数量
+ ///
+ public int scrap_qty { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index cbcea7c3..7be62097 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -35,6 +35,11 @@ using Aspose.Cells.Drawing.Texts;
using JNPF.Systems.Entitys.Permission;
using WebSocketSharp.Frame;
using JNPF.Logging;
+using System.Dynamic;
+using Tnb.EquipMgr.Entities.Dto;
+using JNPF.Common.Filter;
+using Tnb.BasicData.Entities.Dto;
+using NPOI.SS.Formula.Functions;
namespace Tnb.ProductionMgr
{
@@ -45,6 +50,7 @@ namespace Tnb.ProductionMgr
public class PrdMoTaskService : IOverideVisualDevService, IPrdMoTaskService, IDynamicApiController, ITransient
{
private const string ModuleId = "25567924238373";
+ private const string MoModuleId = "25018860321301";
private readonly ISqlSugarRepository _repository;
private readonly IUserManager _userManager;
private readonly IDictionaryDataService _dictionaryDataService;
@@ -98,12 +104,12 @@ namespace Tnb.ProductionMgr
[HttpGet("{materialId}")]
public async Task GetMoldListByItemId(string materialId)
{
- var result = new List();
+ var result = new List();
result = await _db.Queryable()
.InnerJoin((a, b) => a.mold_id == b.id)
.InnerJoin((a, b, c) => a.material_id == c.id)
.Where((a, b, c) => a.material_id == materialId)
- .Select((a, b, c) => new MoldListOutput
+ .Select((a, b, c) => new Tnb.ProductionMgr.Entities.Dto.MoldListOutput
{
mold_id = a.id,
mold_code = b.mold_code,
@@ -125,7 +131,7 @@ namespace Tnb.ProductionMgr
{
var items = await _db.Queryable().InnerJoin((a, b) => a.equipment_id == b.id)
.Where((a, b) => a.mold_id == moldId)
- .Select((a, b) => new EquipmentListOutput
+ .Select((a, b) => new Entities.Dto.EquipmentListOutput
{
eqp_id = b.id,
eqp_code = b.code,
@@ -255,7 +261,7 @@ namespace Tnb.ProductionMgr
material_code = materialCode,
material_name = materialName,
prd_qty = it.prd_qty,
- //scrap_qty = SqlFunc.Subqueryable().Select(x => x.scrap_qty),
+ scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(x => x.scrap_qty),
})
.Mapper(it =>
{
@@ -271,7 +277,7 @@ namespace Tnb.ProductionMgr
icmo_qty = db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty,
reported_work_qty = 0,
prd_qty = 0,
- //scrap_qty = 0,
+ scrap_qty = 0,
};
return res;
}
@@ -471,29 +477,74 @@ namespace Tnb.ProductionMgr
///
///
[HttpGet]
- public async Task GetUnSchedulingList()
+ public async Task GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input)
{
- List trees = new();
- var list = await _db.Queryable().Where(it => string.IsNullOrEmpty(it.parent_id) && it.mo_status == DictConst.ScheduledId).ToListAsync();
- foreach (var item in list)
+ List trees = new();
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(MoModuleId, true);
+ var data = await _runService.GetListResult(templateEntity, input);
+
+ if (data?.list?.Count > 0)
{
- var node = item.Adapt();
- node.mo_id = item.id;
- node.id = SnowflakeIdHelper.NextId();
- node.parentId = "0";
- var items = await _db.Queryable().Where(it => it.parent_id == item.id).ToListAsync();
- if (items?.Count() > 0)
+ var parentIdField = nameof(PrdMo.parent_id);
+ var nodes = data.list.Where(it => it.ContainsKey(parentIdField) && it[parentIdField].IsNullOrEmpty()).ToList();
+ foreach (var row in nodes)
{
- var childNodes = items.Adapt>();
- for (int i = 0; i < items.Count; i++)
+ var pkName = "material_id_id";
+ var dic = row.ToDictionary(x => x.Key, x => x.Value);
+
+ PrdMoTreeOutput node = DictionaryToObject(row);
+ node.parentId = "0";
+ node.mo_id = node.id;
+ if (dic.ContainsKey(pkName))
{
- childNodes[i].mo_id = items[i].id;
+ var materialId = dic[pkName]?.ToString();
+ var material = await _db.Queryable().FirstAsync(it => it.id == materialId);
+ node.material_id_id = materialId;
+ node.material_code = material?.code;
+ node.material_name = material?.name;
}
- trees.AddRange(childNodes);
+
+ var queryObj = new { parent_id = node.id };
+ input.superQueryJson = "";
+ input.queryJson = queryObj.ToJsonString();
+ var subData = await _runService.GetListResult(templateEntity, input);
+ if (subData?.list?.Count > 0)
+ {
+ var childNodes = new List();
+ foreach (var item in subData.list)
+ {
+ dic = item.ToDictionary(x => x.Key, x => x.Value);
+ PrdMoTreeOutput subNode = DictionaryToObject(item);
+ subNode.parentId = node.id;
+ subNode.mo_id = subNode.id;
+ if (dic.ContainsKey(pkName))
+ {
+ var materialId = dic[pkName]?.ToString();
+ var material = await _db.Queryable().FirstAsync(it => it.id == materialId);
+ subNode.material_id_id = materialId;
+ subNode.material_code = material?.code;
+ subNode.material_name = material?.name;
+ }
+ childNodes.Add(subNode);
+ }
+ trees.AddRange(childNodes);
+ }
+ trees.Add(node);
}
- trees.Add(node);
}
- return trees.ToTree();
+ var treeList = trees.ToTree();
+ var list = treeList.Skip(input.currentPage - 1).Take(input.pageSize).ToList();
+ SqlSugarPagedList pagedList = new()
+ {
+ list = treeList,
+ pagination = new Pagination
+ {
+ CurrentPage = input.currentPage,
+ PageSize = input.pageSize,
+ Total = treeList.Count
+ }
+ };
+ return PageResult.SqlSugarPageResult(pagedList);
}
#endregion
@@ -769,7 +820,7 @@ namespace Tnb.ProductionMgr
}
catch (Exception ex)
{
- Log.Error("组装包装排产时报错", ex);
+ JNPF.Logging.Log.Error("组装包装排产时报错", ex);
await _db.Ado.RollbackTranAsync();
}
return row > 0;
@@ -1037,7 +1088,7 @@ namespace Tnb.ProductionMgr
defect.defective_item = dItem.defective_item;
defect.defective_item_qty = dItem.defective_item_qty;
defect.create_id = _userManager.UserId;
-
+ defect.scrap_qty = input.scrap_qty;
destDefects.Add(defect);
}
}
@@ -1084,45 +1135,92 @@ namespace Tnb.ProductionMgr
if (input.ids is null || input.ids.Count == 0) throw new ArgumentException($"{nameof(input.ids)} not be null or count zero");
var curMo = await _db.Queryable().FirstAsync(it => it.id == input.mo_id);
if (curMo == null) throw new ArgumentNullException("创建子工单时的父工单不能为null");
- List subMoList = new();
- var outputMaterials = await _db.Queryable().LeftJoin((a, b) => a.id == b.material_id)
- .Where((a, b) => input.ids.Contains(a.id))
- .Select((a, b) => new
+
+
+ var outMaterials = await _db.Queryable().InnerJoin((a, b) => a.id == b.mbom_id)
+ .InnerJoin((a, b, c) => a.id == c.mbom_id && b.id == c.mbom_process_id)
+ .Where((a, b, c) => a.id == input.bom_id && input.ids.Contains(b.process_id))
+ .Select((a, b, c) => new
+ {
+ material_id = a.material_id,
+ num = c.num,
+ })
+ .ToListAsync();
+
+ if (outMaterials?.Count > 0)
+ {
+ var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
+ var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList();
+ var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
+ List subMoList = new();
+ var outputMaterials = await _db.Queryable().Where(it => ids.Contains(it.id)).ToListAsync();
+ foreach (var om in outputMaterials)
{
- material_id = a.id,
- material_code = a.code,
- num = b.num,
- })
- .ToListAsync();
- foreach (var om in outputMaterials)
- {
- PrdMo subMo = new();
- subMo.material_id = om.material_id;
- subMo.material_code = om.material_code;
- subMo.plan_qty = om.num.ParseToInt() * curMo.plan_qty;
- subMo.mo_type = curMo.mo_type;
- subMo.parent_id = curMo.id;
- subMo.plan_start_date = curMo.plan_start_date;
- subMo.plan_end_date = curMo.plan_end_date;
- subMo.create_id = _userManager.UserId;
- subMo.create_time = DateTime.Now;
- subMo.mo_status = DictConst.WaitProductId;
- subMoList.Add(subMo);
+ PrdMo subMo = new();
+ subMo.material_id = om.id;
+ subMo.material_code = om.code;
+ subMo.plan_qty = dicOutMaterialNum.ContainsKey(om.id) ? dicOutMaterialNum[om.id] * curMo.plan_qty : 0;
+ subMo.mo_type = curMo.mo_type;
+ subMo.parent_id = curMo.id;
+ subMo.plan_start_date = curMo.plan_start_date;
+ subMo.plan_end_date = curMo.plan_end_date;
+ subMo.create_id = _userManager.UserId;
+ subMo.create_time = DateTime.Now;
+ subMo.mo_status = DictConst.WaitProductId;
+ subMoList.Add(subMo);
+ }
+ //生成子工单编码
+ for (int i = 0; i < subMoList.Count; i++)
+ {
+ var num = (i + 1).ToString().PadLeft(2, '0');
+ subMoList[i].mo_code = $"{curMo.mo_code}-{num}";
+ }
+ var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
+ if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
}
- //生成子工单编码
- for (int i = 0; i < subMoList.Count; i++)
- {
- var num = (i + 1).ToString().PadLeft(2, '0');
- subMoList[i].mo_code = $"{subMoList[i].mo_code}-{num}";
- }
- var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
- if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
+
}
#endregion
+ private static dynamic DictionaryToObject(IDictionary dictionary)
+ {
+ var expandoObj = new ExpandoObject();
+ var expandoObjCollection = (ICollection>)expandoObj;
+
+ foreach (var keyValuePair in dictionary)
+ {
+ expandoObjCollection.Add(keyValuePair);
+ }
+ dynamic eoDynamic = expandoObj;
+ return eoDynamic;
+ }
+
+ private static Dictionary dicProperties = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ private static T DictionaryToObject(IDictionary dictionary) where T : class, new()
+ {
+ var name = typeof(T).Name;
+ T instance = new();
+ if (!dicProperties.TryGetValue(name, out string[] properies))
+ {
+ properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
+ dicProperties[name] = properies;
+ }
+ //var properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
+ foreach (var pn in properies)
+ {
+ if (dictionary.ContainsKey(pn))
+ {
+ instance.PropertySetValue(pn, dictionary[pn]);
+ }
+ }
+ return instance;
+ }
+
+
+
private async Task GetList(VisualDevModelListQueryInput input)
{
diff --git a/common/Tnb.Common/Extension/DictionaryExtensions.cs b/common/Tnb.Common/Extension/DictionaryExtensions.cs
index 962810bf..750a273e 100644
--- a/common/Tnb.Common/Extension/DictionaryExtensions.cs
+++ b/common/Tnb.Common/Extension/DictionaryExtensions.cs
@@ -1,4 +1,5 @@
-using JNPF.DependencyInjection;
+using System.Reflection;
+using JNPF.DependencyInjection;
namespace JNPF.Common.Extension;
@@ -8,6 +9,7 @@ namespace JNPF.Common.Extension;
[SuppressSniffer]
public static class DictionaryExtensions
{
+
///
/// 从字典中获取值,不存在则返回字典类型的默认值.
///
@@ -55,4 +57,31 @@ public static class DictionaryExtensions
}
}
}
+
+ private static Dictionary dicProperties = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ ///
+ /// 字典转换成指定类型实例
+ /// added by ly on 20230524
+ ///
+ /// 转换的目标类型
+ /// 被转换的字典
+ /// 转换后的目标类型对象实例
+ public static T ToObject(this Dictionary dictionary) where T : class, new()
+ {
+ var name = typeof(T).Name;
+ T instance = new();
+ if (!dicProperties.TryGetValue(name, out string[] properies))
+ {
+ properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
+ dicProperties[name] = properies;
+ }
+ foreach (var pn in properies)
+ {
+ if (dictionary.ContainsKey(pn))
+ {
+ instance.PropertySetValue(pn, dictionary[pn]);
+ }
+ }
+ return instance;
+ }
}
\ No newline at end of file
diff --git a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
index 1c1dc7b7..c4c0ddd9 100644
--- a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
+++ b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
@@ -18,11 +18,22 @@ namespace JNPF.Common.Extension
}
setAction(instance, value);
}
+
+ public static void PropertySetValue(this T instance, string propertyName, object value)
+ {
+ if (!PropertySet.ValueFactories2.TryGetValue(propertyName, out Action setAction))
+ {
+ setAction = PropertySet.CreateSetPropertyValueAction2(propertyName);
+ PropertySet.ValueFactories2.Add(propertyName, setAction);
+ }
+ setAction(instance, value);
+ }
}
public class PropertySet
{
public static Dictionary> ValueFactories = new Dictionary>(StringComparer.OrdinalIgnoreCase);
+ public static Dictionary> ValueFactories2 = new Dictionary>(StringComparer.OrdinalIgnoreCase);
public static Action
public string route_name { get; set; }
+ ///
+ /// 工序排序序号
+ ///
+ public long? ordinal { get; set; }
}
}
diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs
index ef2621e8..b6bc02b4 100644
--- a/BasicData/Tnb.BasicData/BasMbomService.cs
+++ b/BasicData/Tnb.BasicData/BasMbomService.cs
@@ -155,26 +155,51 @@ namespace Tnb.BasicData
{
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
+
var result = await _db.Queryable()
- .LeftJoin((a, b) => a.route_id == b.id)
- .LeftJoin((a, b, c) => b.id == c.route_id)
- .LeftJoin((a, b, c, d) => c.process_id == d.process_id)
- .LeftJoin((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
- .Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
- .Select((a, b, c, d, e) => new SubBomListOutput
- {
- version = a.version,
- unit_id = a.unit_id,
- route_name = b.name,
- process_id = c.process_id,
- material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
- material_code = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.code),
- material_name = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.name),
- material_category_code = "",
- num = e.num,
- })
- .Mapper(it => it.output_qty = it.num.ParseToInt())
- .ToListAsync();
+ .LeftJoin((a, b) => a.id == b.mbom_id)
+ .LeftJoin((a, b, c) => a.route_id == c.id)
+ .LeftJoin((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_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 == bomId)
+ .Select((a, b, c, d, e) => new SubBomListOutput
+ {
+ version = a.version,
+ unit_id = a.unit_id,
+ route_name = c.name,
+ process_id = b.process_id,
+ material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
+ material_code = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.code),
+ material_name = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.name),
+ material_standard = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.material_standard),
+ num = e.num,
+ ordinal = d.ordinal,
+ })
+ .Mapper(it => it.output_qty = it.num.ParseToInt())
+ .ToListAsync();
+ #region 注释代码
+ //var result = await _db.Queryable()
+ // .LeftJoin((a, b) => a.route_id == b.id)
+ // .LeftJoin((a, b, c) => b.id == c.route_id)
+ // .LeftJoin((a, b, c, d) => c.process_id == d.process_id)
+ // .LeftJoin((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
+ // .Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
+
+ // .Select((a, b, c, d, e) => new SubBomListOutput
+ // {
+ // version = a.version,
+ // unit_id = a.unit_id,
+ // route_name = b.name,
+ // process_id = c.process_id,
+ // material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
+ // material_code = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.code),
+ // material_name = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.name),
+ // material_standard = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.material_standard),
+ // num = e.num,
+ // })
+ // .Mapper(it => it.output_qty = it.num.ParseToInt())
+ // .ToListAsync();
+ #endregion
return result;
}
@@ -198,7 +223,6 @@ namespace Tnb.BasicData
[HttpGet]
public async Task GetMBomListByMaterialId([FromRoute] string materialId)
{
-
return await _db.Queryable()
.LeftJoin((a, b) => a.material_id == b.id)
.LeftJoin((a, b, c) => a.route_id == c.id)
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs
index ad2901da..fe5d7e06 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSchedlingCrInput.cs
@@ -31,7 +31,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
///
/// 排产数量
///
- public string scheduled_qty { get; set; }
+ public int scheduled_qty { get; set; }
///
/// Desc:预计开始时间
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs
index 9eedff4b..08bc9117 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs
@@ -21,6 +21,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
///
public string mo_task_code { get; set; }
///
+ /// 物料id
+ ///
+ public string material_id { get; set; }
+ ///
/// 物料编号
///
public string material_code { get; set; }
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index 7be62097..e685cf04 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -381,7 +381,7 @@ namespace Tnb.ProductionMgr
result = await _db.Queryable().LeftJoin((a, b) => a.mo_id == b.id)
.LeftJoin((a, b, c) => a.material_id == c.id)
.LeftJoin((a, b, c, d) => a.workline_id == d.Id)
- .Where((a, b, c, d) => a.mo_id == moId)
+ .Where((a, b, c, d) => a.mo_id == moId && string.IsNullOrEmpty(a.parent_id))
.Select((a, b, c, d) => new PrdMoTaskOutput
{
mo_task_code = a.mo_task_code,
@@ -414,28 +414,29 @@ namespace Tnb.ProductionMgr
public async Task GetPackScheldToBeIssueList([FromQuery] PackScheldToBeIssueListInput input)
{
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
- var result = await _db.Queryable().Where(it => it.schedule_type == 2)
- .LeftJoin((a, b) => a.material_id == b.id)
- .LeftJoin((a, b, c) => a.workline_id == c.Id)
- .LeftJoin((a, b, c, d) => a.mo_id == d.id)
- .LeftJoin((a, b, c, d, e) => a.bom_id == e.id)
- .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), (a, b, c, d, e) => a.mo_task_code.Contains(input.mo_task_code))
- .Select((a, b, c, d, e) => new PackSechelToBeIssueListOutput
+ var result = await _db.Queryable()
+ .LeftJoin((a, b) => a.workline_id == b.Id)
+ .LeftJoin((a, b, c) => a.mo_id == c.id)
+ .LeftJoin((a, b, c, d) => a.bom_id == d.id)
+ .WhereIF(!string.IsNullOrEmpty(input.mo_task_code), (a, b, c, d) => a.mo_task_code.Contains(input.mo_task_code))
+ .Where((a, b, c, d) => a.schedule_type == 2 && string.IsNullOrEmpty(a.parent_id))
+ .Select((a, b, c, d) => new PackSechelToBeIssueListOutput
{
mo_task_id = a.id,
mo_task_code = a.mo_task_code,
- material_code = b.code,
- material_name = b.name,
+ material_id = a.material_id,
+ material_code = SqlFunc.Subqueryable().Where(it => it.id == a.material_id).Select(it => it.code),
+ material_name = SqlFunc.Subqueryable().Where(it => it.id == a.material_id).Select(it => it.name),
workline_id = a.workline_id,
- workline_code = c.EnCode,
- workline_name = c.FullName,
+ workline_code = b.EnCode,
+ workline_name = b.FullName,
mo_task_status = a.mo_task_status,
- scheduled_qty = a.scheduled_qty,
- plan_qty = d.plan_qty,
+ scheduled_qty = SqlFunc.Subqueryable().Where(it => it.mo_id == a.mo_id).Sum(it => it.scheduled_qty),
+ plan_qty = SqlFunc.Subqueryable().Where(it => it.id == a.mo_id).Select(it => it.plan_qty),
estimated_start_date = a.estimated_start_date,
estimated_end_date = a.estimated_end_date,
- bom_id = e.id,
- bom_version = e.version
+ bom_id = d.id,
+ bom_version = d.version
})
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
.ToListAsync();
@@ -467,8 +468,10 @@ namespace Tnb.ProductionMgr
scheduled_qty = a.scheduled_qty,
plan_qty = d.plan_qty,
process_task_qty = a.process_task_qty,
+ 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()! : "")
+ .OrderBy(a => a.mo_task_code, OrderByType.Asc)
.ToListAsync();
return result;
}
@@ -692,18 +695,21 @@ namespace Tnb.ProductionMgr
var moTask = input.Adapt();
moTask.id = SnowflakeIdHelper.NextId();
moTask.create_id = _userManager.UserId;
+ moTask.bom_id = input.bom_id;
+ moTask.workline_id = input.workline_id;
moTask.create_time = DateTime.Now;
moTask.schedule_type = 2;
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
moTask.estimated_start_date = input.estimated_start_date;
moTask.estimated_end_date = input.estimated_end_date;
+ 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.mo_task_code) && it.mo_task_code.Contains(moCode))
+ 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!.IsNullOrEmpty())
+ if (taskCode is null || taskCode.IsNullOrEmpty())
{
moTask.mo_task_code = $"{moCode}-01";
}
@@ -771,51 +777,98 @@ namespace Tnb.ProductionMgr
}
//根据生产bomId 拆解生产子任务
var outputList = new List();
- var bom = await _db.Queryable().FirstAsync(it => it.id == input.bom_id);
- if (bom != null && bom.route_id.IsNotEmptyOrNull())
+ var subTaskList = await _db.Queryable()
+ .LeftJoin((a, b) => a.id == b.mbom_id)
+ .LeftJoin((a, b, c) => a.route_id == c.id)
+ .LeftJoin((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_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 && d.ordinal < SqlFunc.Subqueryable().Where(it => it.route_id == a.route_id).OrderByDesc(it => it.ordinal).Select(it => it.ordinal))
+ .Select((a, b, c, d, e) => new SubBomListOutput
+ {
+ version = a.version,
+ unit_id = a.unit_id,
+ route_id = c.id,
+ route_name = c.name,
+ process_id = b.process_id,
+ material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
+ num = e.num,
+ ordinal = d.ordinal,
+ })
+ .Mapper(it => it.output_qty = it.num.ParseToInt())
+ .ToListAsync();
+
+ if (subTaskList?.Count > 0)
{
- var routes = await _db.Queryable().Where(it => it.route_id == bom.route_id).ToListAsync();
- if (routes?.Count > 0)
+ List subMoTasks = new();
+ foreach (var item in subTaskList)
{
- var processIds = routes.Select(x => x.process_id).ToList();
- if (processIds?.Count > 0)
+ PrdMoTask subMoTask = new();
+ subMoTask.schedule_type = 2;
+ subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
+ subMoTask.parent_id = moTask.id;
+ subMoTask.mo_id = input.mo_id;
+ //subMoTask.bom_id = input.bom_id;
+ subMoTask.workline_id = input.workline_id;
+ subMoTask.material_id = item.material_id;
+ subMoTask.workroute_id = item.route_id;
+ subMoTask.scheduled_qty = item.output_qty * moTask.scheduled_qty;
+ subMoTask.process_task_qty = item.output_qty * moTask.scheduled_qty;
+ subMoTask.estimated_start_date = input.estimated_start_date;
+ subMoTask.estimated_end_date = input.estimated_end_date;
+ subMoTask.create_id = _userManager.UserId;
+ subMoTask.create_time = DateTime.Now;
+ subMoTasks.Add(subMoTask);
+ }
+ //根据生产任务编号生成子任务编号
+ if (moTask.mo_task_code!.IsNotEmptyOrNull())
+ {
+ for (int i = 1; i <= subMoTasks.Count; i++)
{
- var bomOutputs = await _db.Queryable().Where(it => processIds.Contains(it.process_id)).ToListAsync();
- if (bomOutputs?.Count > 0)
- {
- List subMoTasks = new();
- foreach (var item in bomOutputs)
- {
- var material = await _db.Queryable().FirstAsync(it => it.id == item.material_id);
- PrdMoTask subMoTask = new();
- subMoTask.id = SnowflakeIdHelper.NextId();
- subMoTask.schedule_type = 2;
- subMoTask.parent_id = moTask.id;
- subMoTask.bom_id = input.bom_id;
- subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
- subMoTask.workline_id = input.workline_id;
- subMoTask.material_id = item.material_id;
- subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
- subMoTask.estimated_start_date = input.estimated_start_date;
- subMoTask.estimated_end_date = input.estimated_end_date;
- subMoTask.create_id = _userManager.UserId;
- subMoTask.create_time = DateTime.Now;
- subMoTasks.Add(subMoTask);
- }
- //根据生产任务编号生成子任务编号
- if (moTask.mo_task_code!.IsNotEmptyOrNull())
- {
- for (int i = 1; i <= subMoTasks.Count; i++)
- {
- string n = i.ToString();
- subMoTasks[i - 1].mo_task_code = $"{moTask.mo_task_code}-{n.PadLeft(2, '0')}";
- }
- }
- row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
- }
+ string n = i.ToString();
+ subMoTasks[i - 1].mo_task_code = $"{moTask.mo_task_code}-{n.PadLeft(2, '0')}";
}
}
+ row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
}
+ #region 注释代码
+ //var bom = await _db.Queryable().FirstAsync(it => it.id == input.bom_id);
+ //if (bom != null && bom.route_id.IsNotEmptyOrNull())
+ //{
+ // var mbomProcesses = await _db.Queryable().Where(it => it.mbom_id == bom.id).ToListAsync();
+ // var routes = await _db.Queryable().Where(it => it.route_id == bom.route_id).ToListAsync();
+ // if (routes?.Count > 0)
+ // {
+ // var processIds = routes.Select(x => x.process_id).ToList();
+ // if (processIds?.Count > 0)
+ // {
+ // var bomOutputs = await _db.Queryable().Where(it => processIds.Contains(it.process_id)).ToListAsync();
+ // if (bomOutputs?.Count > 0)
+ // {
+ // List subMoTasks = new();
+ // foreach (var item in bomOutputs)
+ // {
+ // var material = await _db.Queryable().FirstAsync(it => it.id == item.material_id);
+ // PrdMoTask subMoTask = new();
+ // subMoTask.id = SnowflakeIdHelper.NextId();
+ // subMoTask.schedule_type = 2;
+ // subMoTask.parent_id = moTask.id;
+ // subMoTask.bom_id = input.bom_id;
+ // subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
+ // subMoTask.workline_id = input.workline_id;
+ // subMoTask.material_id = item.material_id;
+ // subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
+ // subMoTask.estimated_start_date = input.estimated_start_date;
+ // subMoTask.estimated_end_date = input.estimated_end_date;
+ // subMoTask.create_id = _userManager.UserId;
+ // subMoTask.create_time = DateTime.Now;
+ // subMoTasks.Add(subMoTask);
+ // }
+ // }
+ // }
+ // }
+ //}
+ #endregion
+
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
@@ -1142,7 +1195,7 @@ namespace Tnb.ProductionMgr
.Where((a, b, c) => a.id == input.bom_id && input.ids.Contains(b.process_id))
.Select((a, b, c) => new
{
- material_id = a.material_id,
+ material_id = c.material_id,
num = c.num,
})
.ToListAsync();
@@ -1151,35 +1204,37 @@ namespace Tnb.ProductionMgr
{
var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList();
- var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
- List subMoList = new();
- var outputMaterials = await _db.Queryable().Where(it => ids.Contains(it.id)).ToListAsync();
- foreach (var om in outputMaterials)
+ if (ids?.Count > 0)
{
- PrdMo subMo = new();
- subMo.material_id = om.id;
- subMo.material_code = om.code;
- subMo.plan_qty = dicOutMaterialNum.ContainsKey(om.id) ? dicOutMaterialNum[om.id] * curMo.plan_qty : 0;
- subMo.mo_type = curMo.mo_type;
- subMo.parent_id = curMo.id;
- subMo.plan_start_date = curMo.plan_start_date;
- subMo.plan_end_date = curMo.plan_end_date;
- subMo.create_id = _userManager.UserId;
- subMo.create_time = DateTime.Now;
- subMo.mo_status = DictConst.WaitProductId;
- subMoList.Add(subMo);
+ var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
+ List subMoList = new();
+ var outputMaterials = await _db.Queryable().Where(it => ids.Contains(it.id)).ToListAsync();
+ foreach (var om in outputMaterials)
+ {
+ PrdMo subMo = new();
+ subMo.material_id = om.id;
+ subMo.material_code = om.code;
+ subMo.plan_qty = dicOutMaterialNum.ContainsKey(om.id) ? dicOutMaterialNum[om.id] * curMo.plan_qty : 0;
+ subMo.mo_type = curMo.mo_type;
+ subMo.parent_id = curMo.id;
+ subMo.plan_start_date = curMo.plan_start_date;
+ subMo.plan_end_date = curMo.plan_end_date;
+ subMo.create_id = _userManager.UserId;
+ subMo.create_time = DateTime.Now;
+ subMo.mo_status = DictConst.WaitProductId;
+ subMoList.Add(subMo);
+ }
+ //生成子工单编码
+ for (int i = 0; i < subMoList.Count; i++)
+ {
+ var num = (i + 1).ToString().PadLeft(2, '0');
+ subMoList[i].mo_code = $"{curMo.mo_code}-{num}";
+ }
+ var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
+ if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
}
- //生成子工单编码
- for (int i = 0; i < subMoList.Count; i++)
- {
- var num = (i + 1).ToString().PadLeft(2, '0');
- subMoList[i].mo_code = $"{curMo.mo_code}-{num}";
- }
- var row = await _db.Insertable(subMoList).ExecuteCommandAsync();
- if (row < 1) throw Oops.Oh(ErrorCode.COM1000);
+
}
-
-
}
@@ -1208,7 +1263,6 @@ namespace Tnb.ProductionMgr
properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
dicProperties[name] = properies;
}
- //var properies = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Select(p => p.Name).ToArray();
foreach (var pn in properies)
{
if (dictionary.ContainsKey(pn))
@@ -1218,10 +1272,6 @@ namespace Tnb.ProductionMgr
}
return instance;
}
-
-
-
-
private async Task GetList(VisualDevModelListQueryInput input)
{
var db = _repository.AsSugarClient();
From 60e23211be7efed13a4ca484ba0cfefc880db580 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Thu, 25 May 2023 17:22:37 +0800
Subject: [PATCH 06/15] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E9=99=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Entity/EqpEquipFile.cs | 57 +++++++++++++++
.../Entity/EqpSpotInsRecordD.cs | 5 --
.../IEqpEquipFileService.cs | 15 ++++
EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs | 73 +++++++++++++++++++
EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj | 1 +
5 files changed, 146 insertions(+), 5 deletions(-)
create mode 100644 EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
create mode 100644 EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
create mode 100644 EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
new file mode 100644
index 00000000..b2919f9b
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
@@ -0,0 +1,57 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.EquipMgr.Entities;
+
+///
+/// 设备附件表
+///
+[SugarTable("eqp_equip_file")]
+public partial class EqpEquipFile : BaseEntity
+{
+ public EqpEquipFile()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 设备id
+ ///
+ public string equip_id { get; set; } = string.Empty;
+
+ ///
+ /// 附件
+ ///
+ public string attachment { get; set; } = string.Empty;
+
+ ///
+ /// 文件名
+ ///
+ public string file_name { get; set; } = string.Empty;
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
index 61c0ae8c..076469c0 100644
--- a/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
+++ b/EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpSpotInsRecordD.cs
@@ -109,9 +109,4 @@ public partial class EqpSpotInsRecordD : BaseEntity
///
public string? is_pass { get; set; }
- ///
- /// 所属组织
- ///
- public string? org_id { get; set; }
-
}
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
new file mode 100644
index 00000000..258e6439
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
@@ -0,0 +1,15 @@
+using Microsoft.AspNetCore.Http;
+using Tnb.EquipMgr.Entities.Dto;
+
+namespace Tnb.EquipMgr.Interfaces
+{
+ public interface IEqpEquipFileService
+ {
+ ///
+ /// 上传附件
+ ///
+ ///
+ ///
+ public Task Upload(string equip_id,IFormFile file);
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
new file mode 100644
index 00000000..b664448f
--- /dev/null
+++ b/EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
@@ -0,0 +1,73 @@
+using JNPF.Common.Core.Manager;
+using JNPF.Common.Dtos.VisualDev;
+using JNPF.Common.Enums;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.FriendlyException;
+using JNPF.Logging;
+using JNPF.Systems.Common;
+using JNPF.Systems.Interfaces.Common;
+using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys;
+using JNPF.VisualDev.Interfaces;
+using Microsoft.AspNetCore.Http;
+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
+{
+ ///
+ /// 设备保养计划执行管理
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ public class EqpEquipFileService : IEqpEquipFileService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarRepository _repository;
+ private readonly IUserManager _userManager;
+ private readonly FileService _fileService;
+
+ public EqpEquipFileService(ISqlSugarRepository repository,
+ FileService fileService,
+ IUserManager userManager)
+ {
+ _repository = repository;
+ _userManager = userManager;
+ _fileService = fileService;
+ }
+
+ [HttpPost]
+ public async Task Upload([FromForm]string equip_id,[FromForm]IFormFile file)
+ {
+ string msg = "";
+ try
+ {
+ var attachment = await _fileService.Uploader("annexpic", file);
+
+ EqpEquipFile eqpEquipFile = new EqpEquipFile()
+ {
+ file_name = file.FileName,
+ equip_id = equip_id,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now,
+ attachment = JsonConvert.SerializeObject(attachment)
+ };
+
+ await _repository.InsertAsync(eqpEquipFile);
+ msg = "上传成功";
+ }
+ catch (Exception e)
+ {
+ msg = "上传失败";
+ Log.Error(e.Message);
+ throw Oops.Oh(ErrorCode.D8001);
+ }
+
+ return msg;
+ }
+ }
+}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj
index 520c0756..872b640f 100644
--- a/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj
+++ b/EquipMgr/Tnb.EquipMgr/Tnb.EquipMgr.csproj
@@ -10,6 +10,7 @@
+
From 7dcb35b4552222bdb6da8b22acd6726d61215c6c Mon Sep 17 00:00:00 2001
From: "DEVICE8\\12494"
Date: Thu, 25 May 2023 22:51:56 +0800
Subject: [PATCH 07/15] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=8F=90=E6=8A=A5?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Dto/PrdManage/PrdMoTaskOutput.cs | 8 +
.../Dto/PrdManage/PrdMotreeOutput.cs | 4 +
.../Entity/PrdMoTask.cs | 5 +-
.../Entity/PrdMoTask.part.cs | 39 ++++
.../Entity/PrdMoTaskDefect.cs | 2 +
.../Entity/PrdMoTaskDefectRecord.cs | 4 +
.../Entity/PrdReportRecord.cs | 9 +-
.../IProductionReportRecordService.cs | 12 ++
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 185 +++++-------------
.../Tnb.ProductionMgr/PrdTaskManageService.cs | 72 +++++++
.../ProductionReportRecordService.cs | 72 +++++++
11 files changed, 272 insertions(+), 140 deletions(-)
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs
create mode 100644 ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs
index 0eb46fc1..c0a9d030 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskOutput.cs
@@ -75,6 +75,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
/// 预计完工时间
///
public DateTime? estimated_end_date { get; set; }
+ ///
+ /// 工序编码
+ ///
+ public string process_code { get; set; }
+ ///
+ /// 工序名称
+ ///
+ public string process_name { get; set;}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs
index 166af51e..141c0095 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMotreeOutput.cs
@@ -33,6 +33,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
/// 物料名称
///
public string material_name { get; set; }
+ ///
+ /// 物料规格型号
+ ///
+ public string material_standard { get; set; }
///
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
index e53d8c16..663cdb9d 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
@@ -168,5 +168,8 @@ public partial class PrdMoTask : BaseEntity
/// 工序任务量
///
public int? process_task_qty { get; set; }
-
+ ///
+ /// 工序id
+ ///
+ public string process_id { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs
index 33fa02c4..4fef7dff 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs
@@ -31,5 +31,44 @@ namespace Tnb.ProductionMgr.Entities
///
[SugarColumn(IsIgnore = true)]
public int? mold_cavity_qty { get; set; }
+
+ ///
+ /// 任务计划数
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int? icmo_qty { get; set; }
+ ///
+ /// 已报工数量
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int? reported_work_qty { get; set; }
+ ///
+ /// 提报数
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int? reported_qty { get; set; }
+ ///
+ /// 生产数量
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public int? prd_qty { get; set; }
+ ///
+ /// 设备编码
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string eqp_code { get; set; }
+ ///
+ /// 物料编码
+ [SugarColumn(IsIgnore = true)]
+ public string material_code { get; set; }
+ ///
+ /// 物料名称
+ [SugarColumn(IsIgnore = true)]
+ public string material_name { get; set; }
+ ///
+ /// 物料属性
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string material_property { get; set; }
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs
index d5d476f6..89a77326 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs
@@ -53,4 +53,6 @@ public partial class PrdMoTaskDefect : BaseEntity
///
public int scrap_qty { get; set; }
+ public int mo_task_type { get; set; }
+
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs
index 254eea97..eaa4c58c 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs
@@ -78,5 +78,9 @@ public partial class PrdMoTaskDefectRecord : BaseEntity
/// 任务单编号
///
public string? mo_task_code { get; set; }
+ ///
+ /// 任务类型
+ ///
+ public int mo_task_type { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs
index 4113a839..ba5bdc0b 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs
@@ -53,5 +53,12 @@ public partial class PrdReportRecord : BaseEntity
/// 任务单号
///
public string? mo_task_code { get; set; }
-
+ ///
+ /// 任务单状态
+ ///
+ public string status { get; set; }
+ ///
+ /// 任务类型
+ ///
+ public int mo_task_type { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs
new file mode 100644
index 00000000..b02102ed
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IProductionReportRecordService.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.ProductionMgr.Interfaces
+{
+ public interface IProductionReportRecordService
+ {
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index e685cf04..b552c4bf 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -111,7 +111,7 @@ namespace Tnb.ProductionMgr
.Where((a, b, c) => a.material_id == materialId)
.Select((a, b, c) => new Tnb.ProductionMgr.Entities.Dto.MoldListOutput
{
- mold_id = a.id,
+ mold_id = b.id,
mold_code = b.mold_code,
mold_name = b.mold_name,
mold_type_code = b.mold_type_code,
@@ -217,71 +217,6 @@ namespace Tnb.ProductionMgr
return data;
}
///
- /// 根据任务单号获取提报记录明细
- ///
- /// 任务单号
- ///
- /// returns:
- ///
{
- ///
icmo_qty:任务计划数量
- ///
reported_work_qty:已报工数量
- ///
reported_qty:报工数量
- ///
prd_qty:生产数量
- ///
}
- ///
- [HttpGet("{mo_task_code}")]
- public async Task GetPrdReportByIcmoCode(string mo_task_code)
- {
- var db = _repository.AsSugarClient();
- var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code);
- var eqpCode = "";
- var moldCode = "";
- var materialCode = "";
- var materialName = "";
- var materialProp = "";
- if (prdTask != null)
- {
- var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id);
- var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id);
- var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id);
- eqpCode = eqp != null ? eqp.code : "";
- moldCode = mold != null ? mold.mold_code : "";
- materialCode = material != null ? material.code : "";
- materialName = material != null ? material.name : "";
- materialProp = material != null ? material.material_property : "";
- }
-
- var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code)
- .Select(it => new PrdReportOutput
- {
- icmo_qty = it.icmo_qty,
- reported_work_qty = it.reported_work_qty,
- eqp_code = eqpCode,
- mold_code = moldCode,
- material_code = materialCode,
- material_name = materialName,
- prd_qty = it.prd_qty,
- scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(x => x.scrap_qty),
- })
- .Mapper(it =>
- {
- it.icmo_qty = it.icmo_qty ?? (db.Queryable().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable().First(it => it.icmo_code == mo_task_code).scheduled_qty);
- it.reported_work_qty = it.reported_work_qty ?? 0;
- //it.reported_qty = it.reported_qty ?? 0;
- it.prd_qty = it.prd_qty ?? 0;
- it.scrap_qty = it.scrap_qty ?? 0;
- })
- .FirstAsync();
- res ??= new PrdReportOutput
- {
- icmo_qty = db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty,
- reported_work_qty = 0,
- prd_qty = 0,
- scrap_qty = 0,
- };
- return res;
- }
- ///
/// 获取自检报废批次记录
///
/// 任务单Id
@@ -343,7 +278,6 @@ namespace Tnb.ProductionMgr
[HttpGet("{moId}")]
public async Task GetPrdTaskInfoByMoId(string moId, int schedType = 1)
{
-
List result = new();
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
if (schedType == 1)
@@ -369,6 +303,8 @@ namespace Tnb.ProductionMgr
estimated_end_date = a.estimated_end_date,
plan_qty = b.plan_qty,
complete_qty = a.complete_qty,
+ process_code = SqlFunc.Subqueryable().Where(it => it.id == a.process_id).Select(it => it.process_code),
+ process_name = SqlFunc.Subqueryable().Where(it => it.id == a.process_id).Select(it => it.process_name),
})
.Mapper(it =>
{
@@ -381,7 +317,7 @@ namespace Tnb.ProductionMgr
result = await _db.Queryable().LeftJoin((a, b) => a.mo_id == b.id)
.LeftJoin((a, b, c) => a.material_id == c.id)
.LeftJoin((a, b, c, d) => a.workline_id == d.Id)
- .Where((a, b, c, d) => a.mo_id == moId && string.IsNullOrEmpty(a.parent_id))
+ .Where((a, b, c, d) => b.id == moId || b.parent_id == moId)
.Select((a, b, c, d) => new PrdMoTaskOutput
{
mo_task_code = a.mo_task_code,
@@ -505,8 +441,12 @@ namespace Tnb.ProductionMgr
node.material_id_id = materialId;
node.material_code = material?.code;
node.material_name = material?.name;
+ node.material_standard = material?.material_standard;
}
+ //
+ var scheldQtyCol = nameof(PrdMo.scheduled_qty);
+ node.scheduled_qty = _db.Queryable().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString();
var queryObj = new { parent_id = node.id };
input.superQueryJson = "";
input.queryJson = queryObj.ToJsonString();
@@ -527,7 +467,9 @@ namespace Tnb.ProductionMgr
subNode.material_id_id = materialId;
subNode.material_code = material?.code;
subNode.material_name = material?.name;
+ subNode.material_standard = material?.material_standard;
}
+ node.scheduled_qty = _db.Queryable().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString();
childNodes.Add(subNode);
}
trees.AddRange(childNodes);
@@ -696,6 +638,7 @@ namespace Tnb.ProductionMgr
moTask.id = SnowflakeIdHelper.NextId();
moTask.create_id = _userManager.UserId;
moTask.bom_id = input.bom_id;
+ moTask.workroute_id = (await _db.Queryable().FirstAsync(it => it.id == input.bom_id))?.route_id;
moTask.workline_id = input.workline_id;
moTask.create_time = DateTime.Now;
moTask.schedule_type = 2;
@@ -726,7 +669,7 @@ namespace Tnb.ProductionMgr
}
row = await _db.Insertable(moTask).ExecuteCommandAsync();
var material_h = await _db.Queryable().FirstAsync(it => it.id == moTask.material_id);
- //添加生产任务操作记录日志s
+ //添加生产任务操作记录日志
var taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
taskLog.mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!;
@@ -775,43 +718,41 @@ namespace Tnb.ProductionMgr
}
}
}
- //根据生产bomId 拆解生产子任务
- var outputList = new List();
var subTaskList = await _db.Queryable()
- .LeftJoin((a, b) => a.id == b.mbom_id)
- .LeftJoin((a, b, c) => a.route_id == c.id)
- .LeftJoin((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_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 && d.ordinal < SqlFunc.Subqueryable().Where(it => it.route_id == a.route_id).OrderByDesc(it => it.ordinal).Select(it => it.ordinal))
- .Select((a, b, c, d, e) => new SubBomListOutput
- {
- version = a.version,
- unit_id = a.unit_id,
- route_id = c.id,
- route_name = c.name,
- process_id = b.process_id,
- material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
- num = e.num,
- ordinal = d.ordinal,
- })
- .Mapper(it => it.output_qty = it.num.ParseToInt())
- .ToListAsync();
-
+ .LeftJoin((a, b) => a.id == b.mbom_id)
+ .LeftJoin((a, b, c) => a.route_id == c.id)
+ .LeftJoin((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_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)
+ .Select((a, b, c, d, e) => new SubBomListOutput
+ {
+ version = a.version,
+ unit_id = a.unit_id,
+ route_id = c.id,
+ process_id = b.process_id,
+ material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
+ num = e.num,
+ ordinal = d.ordinal,
+ })
+ .Mapper(it => it.output_qty = it.num.ParseToInt())
+ .ToListAsync();
if (subTaskList?.Count > 0)
{
List subMoTasks = new();
foreach (var item in subTaskList)
{
PrdMoTask subMoTask = new();
- subMoTask.schedule_type = 2;
- subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
- subMoTask.parent_id = moTask.id;
subMoTask.mo_id = input.mo_id;
- //subMoTask.bom_id = input.bom_id;
+ subMoTask.material_id = item.material_id;
+ subMoTask.schedule_type = 2;
+ subMoTask.parent_id = moTask.id;
+ subMoTask.bom_id = input.bom_id;
+ subMoTask.process_id = item.process_id;
+ subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
+ subMoTask.workroute_id = item.route_id;
subMoTask.workline_id = input.workline_id;
subMoTask.material_id = item.material_id;
- subMoTask.workroute_id = item.route_id;
- subMoTask.scheduled_qty = item.output_qty * moTask.scheduled_qty;
+ subMoTask.scheduled_qty = input.scheduled_qty;
subMoTask.process_task_qty = item.output_qty * moTask.scheduled_qty;
subMoTask.estimated_start_date = input.estimated_start_date;
subMoTask.estimated_end_date = input.estimated_end_date;
@@ -830,45 +771,6 @@ namespace Tnb.ProductionMgr
}
row = await _db.Insertable(subMoTasks).ExecuteCommandAsync();
}
- #region 注释代码
- //var bom = await _db.Queryable().FirstAsync(it => it.id == input.bom_id);
- //if (bom != null && bom.route_id.IsNotEmptyOrNull())
- //{
- // var mbomProcesses = await _db.Queryable().Where(it => it.mbom_id == bom.id).ToListAsync();
- // var routes = await _db.Queryable().Where(it => it.route_id == bom.route_id).ToListAsync();
- // if (routes?.Count > 0)
- // {
- // var processIds = routes.Select(x => x.process_id).ToList();
- // if (processIds?.Count > 0)
- // {
- // var bomOutputs = await _db.Queryable().Where(it => processIds.Contains(it.process_id)).ToListAsync();
- // if (bomOutputs?.Count > 0)
- // {
- // List subMoTasks = new();
- // foreach (var item in bomOutputs)
- // {
- // var material = await _db.Queryable().FirstAsync(it => it.id == item.material_id);
- // PrdMoTask subMoTask = new();
- // subMoTask.id = SnowflakeIdHelper.NextId();
- // subMoTask.schedule_type = 2;
- // subMoTask.parent_id = moTask.id;
- // subMoTask.bom_id = input.bom_id;
- // subMoTask.mo_task_status = DictConst.ToBeScheduledEncode;
- // subMoTask.workline_id = input.workline_id;
- // subMoTask.material_id = item.material_id;
- // subMoTask.process_task_qty = item.num.ParseToInt() * moTask.scheduled_qty;
- // subMoTask.estimated_start_date = input.estimated_start_date;
- // subMoTask.estimated_end_date = input.estimated_end_date;
- // subMoTask.create_id = _userManager.UserId;
- // subMoTask.create_time = DateTime.Now;
- // subMoTasks.Add(subMoTask);
- // }
- // }
- // }
- // }
- //}
- #endregion
-
await _db.Ado.CommitTranAsync();
}
catch (Exception ex)
@@ -1088,7 +990,13 @@ namespace Tnb.ProductionMgr
var record = prdTask.Adapt();
if (prdTask != null)
{
+ var material = (await db.Queryable().FirstAsync(it => it.id == prdTask.material_id));
record.id = SnowflakeIdHelper.NextId();
+ record.masterial_code = material?.code;
+ record.masterial_name = material?.name;
+ record.plan_start_date = prdTask.estimated_start_date;
+ record.plan_end_date = prdTask.estimated_end_date;
+ record.plan_qty = prdTask.plan_qty;
record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.code;
record.completed_qty = input.reported_qty;
row = await db.Insertable(record).ExecuteCommandAsync();
@@ -1202,11 +1110,12 @@ namespace Tnb.ProductionMgr
if (outMaterials?.Count > 0)
{
- var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
- var ids = outMaterials.Select(x => x.material_id).Except(mids).ToList();
+ //var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
+ var ids = outMaterials.Select(x => x.material_id).ToList();
+ await _db.Deleteable().Where(it => it.parent_id == input.mo_id).ExecuteCommandAsync();
if (ids?.Count > 0)
{
- var dicOutMaterialNum = outMaterials.ToDictionary(x => x.material_id, x => x.num.ParseToInt());
+ var dicOutMaterialNum = outMaterials.DistinctBy(x => x.material_id).ToDictionary(x => x.material_id, x => x.num.ParseToInt());
List subMoList = new();
var outputMaterials = await _db.Queryable().Where(it => ids.Contains(it.id)).ToListAsync();
foreach (var om in outputMaterials)
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
index f654c1eb..62830b07 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
@@ -21,6 +21,8 @@ using Tnb.ProductionMgr.Interfaces;
using Aspose.Cells.Drawing;
using Microsoft.AspNetCore.Mvc;
using DbModels;
+using JNPF.Common.Extension;
+using Tnb.ProductionMgr.Entities.Dto.PrdManage;
namespace Tnb.ProductionMgr
{
@@ -60,6 +62,12 @@ namespace Tnb.ProductionMgr
var data = await _runService.GetListResult(templateEntity, input);
if (data?.list?.Count > 0)
{
+ var statusField = "mo_task_status";
+ var scheduledTypeField = nameof(PrdMoTask.schedule_type);
+ data.list = data.list.Where(it => it.ContainsKey(statusField) &&
+ it[statusField].IsNotEmptyOrNull() && it[statusField].ToString() != "待下发" &&
+ it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1
+ ).ToList();
foreach (var row in data.list)
{
var dic = row.ToDictionary(x => x.Key, x => x.Value);
@@ -98,6 +106,70 @@ namespace Tnb.ProductionMgr
}
return data!;
}
+ ///
+ /// 根据任务单号获取提报记录明细
+ ///
+ /// 任务单号
+ ///
+ /// returns:
+ ///
{
+ ///
icmo_qty:任务计划数量
+ ///
reported_work_qty:已报工数量
+ ///
reported_qty:报工数量
+ ///
prd_qty:生产数量
+ ///
}
+ ///
+ [HttpGet]
+ public async Task GetPrdReportByIcmoCode([FromRoute] string mo_task_code)
+ {
+ var db = _repository.AsSugarClient();
+ var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code);
+ var eqpCode = "";
+ var moldCode = "";
+ var materialCode = "";
+ var materialName = "";
+ var materialProp = "";
+ if (prdTask != null)
+ {
+ var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id);
+ var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id);
+ var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id);
+ eqpCode = eqp != null ? eqp.code : "";
+ moldCode = mold != null ? mold.mold_code : "";
+ materialCode = material != null ? material.code : "";
+ materialName = material != null ? material.name : "";
+ materialProp = material != null ? material.material_property : "";
+
+ }
+ var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code)
+ .Select(it => new PrdReportOutput
+ {
+ icmo_qty = it.icmo_qty,
+ reported_work_qty = it.reported_work_qty,
+ reported_qty = it.reported_qty,
+ prd_qty = it.prd_qty,
+ scrap_qty = SqlFunc.Subqueryable().Where(pmtd => pmtd.mo_task_id == it.mo_task_id).Select(pmtd => pmtd.scrap_qty),
+ })
+ .Mapper(it =>
+ {
+ it.icmo_qty = it.icmo_qty ?? (db.Queryable().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable().First(it => it.icmo_code == mo_task_code).scheduled_qty);
+ it.reported_work_qty = it.reported_work_qty ?? 0;
+ it.reported_qty = it.reported_qty ?? 0;
+ it.prd_qty = it.prd_qty ?? 0;
+ it.scrap_qty = it.scrap_qty ?? 0;
+ })
+ .FirstAsync();
+ prdTask.eqp_code = eqpCode;
+ prdTask.mold_code = moldCode;
+ prdTask.material_code = materialCode;
+ prdTask.material_name = materialName;
+ prdTask.icmo_qty = res?.icmo_qty;
+ prdTask.reported_work_qty = res?.reported_work_qty ?? 0;
+ prdTask.reported_qty = res?.reported_qty ?? 0;
+ prdTask.prd_qty = res?.prd_qty ?? 0;
+
+ return prdTask;
+ }
//public async Task GetPrdMoTaskList()
//{
diff --git a/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
new file mode 100644
index 00000000..d63b715d
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr/ProductionReportRecordService.cs
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Aspose.Cells.Drawing;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.VisualDev;
+using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
+using JNPF.VisualDev.Entitys;
+using JNPF.VisualDev.Interfaces;
+using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Interfaces;
+
+namespace Tnb.ProductionMgr
+{
+ ///
+ /// 生产提报记录
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+ [OverideVisualDev(ModuleId)]
+ public class ProductionReportRecordService : IOverideVisualDevService, IProductionReportRecordService, IDynamicApiController, ITransient
+ {
+ private const string ModuleId = "25568191969061";
+ private readonly ISqlSugarRepository _repository;
+ private readonly ISqlSugarClient _db;
+ private readonly IRunService _runService;
+ private readonly IVisualDevService _visualDevService;
+ public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
+ public ProductionReportRecordService(ISqlSugarRepository repository, IRunService runService, IVisualDevService visualDevService)
+ {
+ _db = repository.AsSugarClient();
+ _runService = runService;
+ _visualDevService = visualDevService;
+ OverideFuncs.GetListAsync = GetList;
+ }
+
+
+ private async Task GetList(VisualDevModelListQueryInput input)
+ {
+
+ VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
+ var data = await _runService.GetListResult(templateEntity, input);
+ if (data?.list?.Count > 0)
+ {
+ foreach (var row in data.list)
+ {
+ var dic = row.ToDictionary(x => x.Key, x => x.Value);
+ var pkName = "material_id_id";
+ if (dic.ContainsKey(pkName))
+ {
+ var materialId = dic[pkName]?.ToString();
+ var material = await _db.Queryable().FirstAsync(it => it.id == materialId);
+ //if (material != null)
+ //{
+ // row.Add("material_name", material.name);
+ // row.Add($"material_attribute", material.attribute);
+
+ //}
+ }
+ }
+ }
+ return data!;
+ }
+ }
+}
From ed2b05b28977418904ba5d88458b1c4a7d4e8512 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Fri, 26 May 2023 16:27:44 +0800
Subject: [PATCH 08/15] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=8A=9F=E8=83=BD?=
=?UTF-8?q?=E4=B8=8D=E6=9B=B4=E6=96=B0=E5=90=8D=E7=A7=B0=E6=8E=92=E5=BA=8F?=
=?UTF-8?q?=E5=9B=BE=E6=A0=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
visualdev/Tnb.VisualDev/VisualDevService.cs | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/visualdev/Tnb.VisualDev/VisualDevService.cs b/visualdev/Tnb.VisualDev/VisualDevService.cs
index b58d68df..86b4fe92 100644
--- a/visualdev/Tnb.VisualDev/VisualDevService.cs
+++ b/visualdev/Tnb.VisualDev/VisualDevService.cs
@@ -595,9 +595,11 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
moduleModel.ModuleId = input.id;
moduleModel.ParentId = oldWebModule != null ? oldWebModule.ParentId : (input.pcModuleParentId.Equals(input.pcSystemId) ? "-1" : input.pcModuleParentId); // 父级菜单节点
moduleModel.Category = "Web";
- moduleModel.FullName = entity.FullName;
+ // moduleModel.FullName = entity.FullName; //modifyby zhoukeda 发布功能不更新名称排序图标
+ moduleModel.FullName = oldWebModule.FullName;
moduleModel.EnCode = entity.EnCode;
- moduleModel.Icon = "icon-ym icon-ym-webForm";
+ // moduleModel.Icon = "icon-ym icon-ym-webForm"; //modifyby zhoukeda 发布功能不更新名称排序图标
+ moduleModel.Icon = oldWebModule.Icon;
moduleModel.UrlAddress = oldWebModule != null ? oldWebModule.UrlAddress : "model/" + entity.EnCode;
moduleModel.Type = 3;
moduleModel.EnabledMark = 1;
@@ -605,7 +607,8 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
moduleModel.IsButtonAuthorize = 1;
moduleModel.IsFormAuthorize = 1;
moduleModel.IsDataAuthorize = 1;
- moduleModel.SortCode = 999;
+ // moduleModel.SortCode = 999; //modifyby zhoukeda 发布功能不更新名称排序图标
+ moduleModel.SortCode = oldWebModule.SortCode;
moduleModel.CreatorTime = DateTime.Now;
moduleModel.PropertyJson = (new { moduleId = input.id, iconBackgroundColor = string.Empty, isTree = 0, isAutoRelease = true }).ToJsonString();
moduleModel.SystemId = oldWebModule != null ? oldWebModule.SystemId : input.pcSystemId;
From a0d611931e41d31a5697c64f318956a4f25d2515 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Fri, 26 May 2023 16:51:36 +0800
Subject: [PATCH 09/15] =?UTF-8?q?=E6=94=B9bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
visualdev/Tnb.VisualDev/VisualDevService.cs | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/visualdev/Tnb.VisualDev/VisualDevService.cs b/visualdev/Tnb.VisualDev/VisualDevService.cs
index 86b4fe92..242d3198 100644
--- a/visualdev/Tnb.VisualDev/VisualDevService.cs
+++ b/visualdev/Tnb.VisualDev/VisualDevService.cs
@@ -595,11 +595,9 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
moduleModel.ModuleId = input.id;
moduleModel.ParentId = oldWebModule != null ? oldWebModule.ParentId : (input.pcModuleParentId.Equals(input.pcSystemId) ? "-1" : input.pcModuleParentId); // 父级菜单节点
moduleModel.Category = "Web";
- // moduleModel.FullName = entity.FullName; //modifyby zhoukeda 发布功能不更新名称排序图标
- moduleModel.FullName = oldWebModule.FullName;
+ moduleModel.FullName = oldWebModule!=null ? oldWebModule.FullName : entity.FullName; //modifyby zhoukeda 发布功能不更新名称排序图标
moduleModel.EnCode = entity.EnCode;
- // moduleModel.Icon = "icon-ym icon-ym-webForm"; //modifyby zhoukeda 发布功能不更新名称排序图标
- moduleModel.Icon = oldWebModule.Icon;
+ moduleModel.Icon = oldWebModule!=null ? oldWebModule.Icon : "icon-ym icon-ym-webForm"; //modifyby zhoukeda 发布功能不更新名称排序图标
moduleModel.UrlAddress = oldWebModule != null ? oldWebModule.UrlAddress : "model/" + entity.EnCode;
moduleModel.Type = 3;
moduleModel.EnabledMark = 1;
@@ -607,8 +605,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
moduleModel.IsButtonAuthorize = 1;
moduleModel.IsFormAuthorize = 1;
moduleModel.IsDataAuthorize = 1;
- // moduleModel.SortCode = 999; //modifyby zhoukeda 发布功能不更新名称排序图标
- moduleModel.SortCode = oldWebModule.SortCode;
+ moduleModel.SortCode = oldWebModule != null ? oldWebModule.SortCode : 999; //modifyby zhoukeda 发布功能不更新名称排序图标
moduleModel.CreatorTime = DateTime.Now;
moduleModel.PropertyJson = (new { moduleId = input.id, iconBackgroundColor = string.Empty, isTree = 0, isAutoRelease = true }).ToJsonString();
moduleModel.SystemId = oldWebModule != null ? oldWebModule.SystemId : input.pcSystemId;
From 26de55ce0aed30576c07b46bc07d1aafef445ff9 Mon Sep 17 00:00:00 2001
From: zhoukeda <1315948824@qq.com>
Date: Fri, 26 May 2023 17:30:49 +0800
Subject: [PATCH 10/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AEid?=
=?UTF-8?q?=E8=8E=B7=E5=8F=96=E8=AE=BE=E5=A4=87=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs | 11 +++++++++--
EquipMgr/Tnb.EquipMgr/EquipmentService.cs | 8 +++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs
index 26d6b24e..13e35519 100644
--- a/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs
+++ b/EquipMgr/Tnb.EquipMgr.Interfaces/IEquipmentService.cs
@@ -1,7 +1,14 @@
-namespace Tnb.EquipMgr.Interfaces
+using Tnb.EquipMgr.Entities;
+
+namespace Tnb.EquipMgr.Interfaces
{
public interface IEquipmentService
{
-
+ ///
+ /// 根据id查设备
+ ///
+ ///
+ ///
+ public Task GetEntityById(Dictionary dic);
}
}
\ No newline at end of file
diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs
index 03d1183f..c059dbda 100644
--- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs
+++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs
@@ -30,7 +30,6 @@ namespace Tnb.EquipMgr
public EquipmentService(ISqlSugarRepository repository)
{
_repository = repository;
- OverideFuncs.GetListAsync = GetList;
}
///
/// 在线开发-获取设备列表
@@ -63,5 +62,12 @@ namespace Tnb.EquipMgr
.ToPagedListAsync(input.currentPage, input.pageSize);
return pagedList;
}
+
+ [HttpPost]
+ public async Task GetEntityById(Dictionary dic)
+ {
+ string id = dic["id"];
+ return await _repository.GetSingleAsync(x => x.id == id);
+ }
}
}
\ No newline at end of file
From c6522831b46b6089f5d08b93acf618d872b40682 Mon Sep 17 00:00:00 2001
From: "DEVICE8\\12494"
Date: Sun, 28 May 2023 21:17:49 +0800
Subject: [PATCH 11/15] 1
---
.../Consts/DictConst.cs | 5 +-
BasicData/Tnb.BasicData/BasMbomService.cs | 24 +-
.../Dto/PrdManage/PackReportTreeOutput.cs | 157 +++++++++
.../Dto/PrdManage/PrdPackReportQueryInput.cs | 18 +
.../Dto/PrdManage/PrdReportOutput.cs | 2 +
.../Entity/PrdMoTask.part.cs | 15 +
.../Entity/PrdMoTaskDefectRecord.cs | 4 +-
.../Entity/PrdReportRecord.cs | 12 +-
.../IPrdPackReportService.cs | 15 +
.../PrdMoTaskIssueService.cs | 3 +
.../Tnb.ProductionMgr/PrdMoTaskService.cs | 329 ++++++++++--------
.../Tnb.ProductionMgr/PrdPackReportService.cs | 159 +++++++++
.../Tnb.ProductionMgr/PrdTaskManageService.cs | 17 +-
.../ProductionReportRecordService.cs | 50 +--
14 files changed, 621 insertions(+), 189 deletions(-)
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackReportTreeOutput.cs
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs
create mode 100644 ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdPackReportService.cs
create mode 100644 ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
index c2d54a15..f110eb49 100644
--- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
+++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs
@@ -19,7 +19,10 @@ public static class DictConst
/// 生产任务状态TypeId
///
public const string PrdTaskStatusTypeId = "25572555259157";
-
+ ///
+ /// 生产工单类型TypeId
+ ///
+ public const string PrdMoTypeTypeId = "25019155728149";
///
/// 工单状态-已排产
diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs
index b6bc02b4..f92b105c 100644
--- a/BasicData/Tnb.BasicData/BasMbomService.cs
+++ b/BasicData/Tnb.BasicData/BasMbomService.cs
@@ -177,29 +177,7 @@ namespace Tnb.BasicData
})
.Mapper(it => it.output_qty = it.num.ParseToInt())
.ToListAsync();
- #region 注释代码
- //var result = await _db.Queryable()
- // .LeftJoin((a, b) => a.route_id == b.id)
- // .LeftJoin((a, b, c) => b.id == c.route_id)
- // .LeftJoin((a, b, c, d) => c.process_id == d.process_id)
- // .LeftJoin((a, b, c, d, e) => e.mbom_id == a.id && e.mbom_process_id == d.id)
- // .Where((a, b, c, d, e) => a.id == bomId && a.material_id != e.material_id && !string.IsNullOrEmpty(e.material_id))
-
- // .Select((a, b, c, d, e) => new SubBomListOutput
- // {
- // version = a.version,
- // unit_id = a.unit_id,
- // route_name = b.name,
- // process_id = c.process_id,
- // material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id),
- // material_code = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.code),
- // material_name = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.name),
- // material_standard = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.material_standard),
- // num = e.num,
- // })
- // .Mapper(it => it.output_qty = it.num.ParseToInt())
- // .ToListAsync();
- #endregion
+
return result;
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackReportTreeOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackReportTreeOutput.cs
new file mode 100644
index 00000000..0cd3de9f
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackReportTreeOutput.cs
@@ -0,0 +1,157 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.Common.Security;
+
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ ///
+ /// 组装、包装,生产任务管理树形输出类
+ ///
+ public class PackReportTreeOutput : TreeModel
+ {
+ ///
+ /// 生产任务编号
+ ///
+ public string? mo_task_code { get; set; }
+
+ ///
+ /// 工单Id
+ ///
+ public string? mo_id { get; set; }
+
+ ///
+ /// 物料Id
+ ///
+ public string? material_id { get; set; }
+ ///
+ /// 产线id
+ ///
+ public string? workline_id { get; set; }
+
+ ///
+ /// 工位id
+ ///
+ public string? workstation_id { get; set; }
+
+ ///
+ /// 工艺路线id
+ ///
+ public string? workroute_id { get; set; }
+
+ ///
+ /// 生产bom id
+ ///
+ public string? bom_id { get; set; }
+
+ ///
+ /// 任务单状态
+ ///
+ public string? mo_task_status { get; set; }
+
+ ///
+ /// 计划数量
+ ///
+ public int? plan_qty { get; set; }
+
+ ///
+ /// 已投入数量
+ ///
+ public int? input_qty { get; set; }
+
+ ///
+ /// 已完工数量
+ ///
+ public int? complete_qty { get; set; }
+
+ ///
+ /// 报废数量
+ ///
+ public int? scrap_qty { get; set; }
+
+ ///
+ /// 已排产数量
+ ///
+ public int? scheduled_qty { get; set; }
+
+ ///
+ /// 排产类型:1、注塑、挤出2、组装、包装
+ ///
+ public int? schedule_type { get; set; }
+
+ ///
+ /// 计划开始时间
+ ///
+ public string plan_start_date { get; set; }
+
+ ///
+ /// 计划结束时间
+ ///
+ public string plan_end_date { get; set; }
+
+ ///
+ /// 实际开工日期
+ ///
+ public DateTime? act_start_date { get; set; }
+
+ ///
+ /// 实际完工日期
+ ///
+ public DateTime? act_end_date { get; set; }
+
+ ///
+ /// 创建人
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改人
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 扩展字段
+ ///
+ public string? extras { get; set; }
+
+ ///
+ /// 生产顺序
+ ///
+ public int? prd_order { get; set; }
+
+ ///
+ /// 预计开始时间
+ ///
+ public DateTime? estimated_start_date { get; set; }
+
+ ///
+ /// 预计结束时间
+ ///
+ public DateTime? estimated_end_date { get; set; }
+ ///
+ /// 父任务Id
+ ///
+ public string? parent_id { get; set; }
+
+ ///
+ /// 工序任务量
+ ///
+ public int? process_task_qty { get; set; }
+ ///
+ /// 工序id
+ ///
+ public string process_id { get; set; }
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs
new file mode 100644
index 00000000..5d32519b
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdPackReportQueryInput.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using JNPF.Common.Filter;
+using Microsoft.AspNetCore.Mvc.RazorPages;
+
+namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
+{
+ public class PrdPackReportQueryInput : PageInputBase
+ {
+ ///
+ /// 生产任务编号
+ ///
+ public string mo_task_code { get; set; }
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs
index 2de1be86..779e1b82 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs
@@ -46,5 +46,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
/// 物料属性
///
public string material_property { get; set; }
+
+
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs
index 4fef7dff..77b52b81 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.part.cs
@@ -70,5 +70,20 @@ namespace Tnb.ProductionMgr.Entities
///
[SugarColumn(IsIgnore = true)]
public string material_property { get; set; }
+ ///
+ /// 工序名称
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string process_name { get; set; }
+ ///
+ /// 工序编码
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string process_code { get; set; }
+ ///
+ /// 产线编码
+ ///
+ [SugarColumn(IsIgnore = true)]
+ public string workline_code { get; set; }
}
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs
index eaa4c58c..6d06db85 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs
@@ -52,7 +52,7 @@ public partial class PrdMoTaskDefectRecord : BaseEntity
///
/// 报废数量
///
- public int? scrap_qty { get; set; }
+ public int scrap_qty { get; set; }
///
/// 生产任务单状态
@@ -81,6 +81,6 @@ public partial class PrdMoTaskDefectRecord : BaseEntity
///
/// 任务类型
///
- public int mo_task_type { get; set; }
+ public string mo_task_type { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs
index ba5bdc0b..7ed330d8 100644
--- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs
+++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs
@@ -47,7 +47,7 @@ public partial class PrdReportRecord : BaseEntity
///
/// 完成数量
///
- public int? completed_qty { get; set; }
+ public int completed_qty { get; set; }
///
/// 任务单号
@@ -60,5 +60,13 @@ public partial class PrdReportRecord : BaseEntity
///
/// 任务类型
///
- public int mo_task_type { get; set; }
+ public string mo_task_type { get; set; }
+ ///
+ /// 生产任务id
+ ///
+ public string mo_task_id { get; set; }
+ ///
+ /// 已报工数量
+ ///
+ public int reported_work_qty { get; set; }
}
diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdPackReportService.cs
new file mode 100644
index 00000000..c901ed4b
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdPackReportService.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.ProductionMgr.Interfaces
+{
+ ///
+ /// 组装、包装 生产提报接口
+ ///
+ public interface IPrdPackReportService
+ {
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
index eb9b1f2e..28190f8d 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
@@ -19,6 +19,7 @@ using Tnb.ProductionMgr.Entities;
using Tnb.ProductionMgr.Interfaces;
using Aspose.Cells.Drawing;
using Microsoft.AspNetCore.Mvc;
+using JNPF.Common.Extension;
namespace Tnb.ProductionMgr
{
@@ -52,6 +53,8 @@ namespace Tnb.ProductionMgr
var data = await _runService.GetListResult(templateEntity, input);
if (data?.list?.Count > 0)
{
+ var scheduledTypeField = nameof(PrdMoTask.schedule_type);
+ data.list = data.list.Where(it => it[scheduledTypeField].IsNotEmptyOrNull() && it[scheduledTypeField].ParseToInt() == 1).ToList();
foreach (var row in data.list)
{
var dic = row.ToDictionary(x => x.Key, x => x.Value);
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
index b552c4bf..34116c7c 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
@@ -589,22 +589,22 @@ namespace Tnb.ProductionMgr
await db.Insertable(taskLog).ExecuteCommandAsync();
//将生产任务插入到自检报废记录表
- var sacipRecord = new PrdMoTaskDefectRecord();
- sacipRecord.id = SnowflakeIdHelper.NextId();
- sacipRecord.material_code = material?.code!;
- sacipRecord.material_name = material?.name!;
- sacipRecord.eqp_code = (await db.Queryable().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
- sacipRecord.mold_name = (await db.Queryable().FirstAsync(it => it.id == moTask.mold_id))?.mold_name!;
- sacipRecord.estimated_start_date = moTask.plan_start_date;
- sacipRecord.estimated_end_date = moTask.plan_end_date;
- sacipRecord.plan_qty = moTask.plan_qty;
- sacipRecord.scrap_qty = moTask.scrap_qty;
- sacipRecord.status = moTask.mo_task_status;
- sacipRecord.create_id = _userManager.UserId;
- sacipRecord.create_time = DateTime.Now;
- sacipRecord.mo_task_id = moTask.id;
- sacipRecord.mo_task_code = moTask.mo_task_code;
- await db.Insertable(sacipRecord).ExecuteCommandAsync();
+ //var sacipRecord = new PrdMoTaskDefectRecord();
+ //sacipRecord.id = SnowflakeIdHelper.NextId();
+ //sacipRecord.material_code = material?.code!;
+ //sacipRecord.material_name = material?.name!;
+ //sacipRecord.eqp_code = (await db.Queryable().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
+ //sacipRecord.mold_name = (await db.Queryable().FirstAsync(it => it.id == moTask.mold_id))?.mold_name!;
+ //sacipRecord.estimated_start_date = moTask.plan_start_date;
+ //sacipRecord.estimated_end_date = moTask.plan_end_date;
+ //sacipRecord.plan_qty = moTask.plan_qty;
+ //sacipRecord.scrap_qty = moTask.scrap_qty;
+ //sacipRecord.status = moTask.mo_task_status;
+ //sacipRecord.create_id = _userManager.UserId;
+ //sacipRecord.create_time = DateTime.Now;
+ //sacipRecord.mo_task_id = moTask.id;
+ //sacipRecord.mo_task_code = moTask.mo_task_code;
+ //await db.Insertable(sacipRecord).ExecuteCommandAsync();
await db.Ado.CommitTranAsync();
}
@@ -804,102 +804,164 @@ namespace Tnb.ProductionMgr
{
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
}
- string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
+ var taskList = await _db.Queryable().Where(it => input.TaskIds.Contains(it.id) && it.mo_task_status == DictConst.ToBeScheduledEncode).ToListAsync();
+ if (taskList?.Count > 0)
{
- PrdTaskBehavior.Release => DictConst.ToBeStartedEnCode,
- PrdTaskBehavior.Start => DictConst.InProgressEnCode,
- PrdTaskBehavior.Closed => DictConst.ClosedEnCode,
- PrdTaskBehavior.Compled => DictConst.ComplatedEnCode,
- _ => throw new NotImplementedException(),
- };
- PrdTaskBehavior behavior = input.Behavior.ToEnum();
- var status = SetTaskStatus(behavior);
- var db = _repository.AsSugarClient();
- var list = await db.Queryable().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
- if (behavior == PrdTaskBehavior.Compled)
- {
-
- if (list?.Count > 0)
+ string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
{
- var schedQtySum = list.Sum(x => x.scheduled_qty);
- var planQtySum = list.Sum(x => x.plan_qty);
- if (schedQtySum < planQtySum)
+ PrdTaskBehavior.Release => DictConst.ToBeStartedEnCode,
+ PrdTaskBehavior.Start => DictConst.InProgressEnCode,
+ PrdTaskBehavior.Closed => DictConst.ClosedEnCode,
+ PrdTaskBehavior.Compled => DictConst.ComplatedEnCode,
+ _ => throw new NotImplementedException(),
+ };
+ PrdTaskBehavior behavior = input.Behavior.ToEnum();
+ var status = SetTaskStatus(behavior);
+ var db = _repository.AsSugarClient();
+ var list = await db.Queryable().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
+ if (behavior == PrdTaskBehavior.Compled)
+ {
+ if (list?.Count > 0)
{
- throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
- }
- }
- }
- row = await db.Updateable()
- .SetColumns(it => new PrdMoTask { mo_task_status = status })
- .Where(it => input.TaskIds.Contains(it.id))
- .ExecuteCommandAsync();
- if (row > 0)
- {
- //更新子任务
- var subMoTaskList = await db.Queryable().Where(it => input.TaskIds.Contains(it.parent_id)).ToListAsync();
- if (subMoTaskList?.Count > 0)
- {
- var subTaskIds = subMoTaskList.Select(it => it.id).ToList();
- row = await db.Updateable()
- .SetColumns(it => new PrdMoTask { mo_task_status = status })
- .Where(it => subTaskIds.Contains(it.id))
- .ExecuteCommandAsync();
- }
- }
- //插入操作记录日志
- var prdMOTasks = await _db.Queryable().Where(it => input.TaskIds.Contains(it.id) && string.IsNullOrEmpty(it.parent_id)).ToListAsync();
- if (prdMOTasks?.Count > 0)
- {
- List taskLogEntities = new();
- foreach (var taskId in input.TaskIds)
- {
- var taskLog = await db.Queryable().FirstAsync(it => it.mo_task_id == taskId);
- if (taskLog is null)
- {
- var taskItem = list?.Find(x => x.id == taskId);
- taskLog = new PrdTaskLog();
- taskLog.id = SnowflakeIdHelper.NextId();
- if (taskItem != null)
+ var schedQtySum = list.Sum(x => x.scheduled_qty);
+ var planQtySum = list.Sum(x => x.plan_qty);
+ if (schedQtySum < planQtySum)
{
- if (taskItem.mo_id!.IsNotEmptyOrNull())
- {
- taskLog.mo_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code!;
- }
- if (taskItem.eqp_id!.IsNotEmptyOrNull())
- {
- taskLog.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.eqp_id))?.code!;
- }
- if (taskItem.mold_id!.IsNotEmptyOrNull())
- {
- taskLog.mold_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code!;
- }
- if (taskItem.material_id!.IsNotEmptyOrNull())
- {
- var material = await db.Queryable().FirstAsync(it => it.id == taskItem.material_id);
- taskLog.item_code = material?.code!;
- taskLog.item_standard = material?.material_standard!;
- }
- taskLog.operator_name = _userManager.RealName;
- taskLog.status = status;
- taskLog.create_id = _userManager.UserId;
- taskLog.create_time = DateTime.Now;
- taskLog.mo_task_id = taskItem.id;
+ throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
}
- taskLogEntities.Add(taskLog);
}
- else
+ }
+
+ var taskReportLogs = new List();
+ var prdTaskList = await db.Queryable().Where(it => input.TaskIds.Contains(it.id)).ToListAsync();
+ if (prdTaskList?.Count > 0)
+ {
+ prdTaskList.ForEach(x => x.mo_task_status = status);
+ row = await db.Updateable(prdTaskList).ExecuteCommandAsync();
+ if (row > 0)
{
- var records = await db.Queryable().Where(it => it.mo_task_id == taskLog.mo_task_id).ToListAsync();
- if (records != null && !records.Select(x => x.status).Contains(status))
+ taskReportLogs.AddRange(prdTaskList);
+ }
+ }
+ if (row > 0)
+ {
+ //更新子任务
+ var subMoTaskList = await db.Queryable().Where(it => input.TaskIds.Contains(it.parent_id)).ToListAsync();
+ if (subMoTaskList?.Count > 0)
+ {
+ var subTaskIds = subMoTaskList.Select(it => it.id).ToList();
+ row = await db.Updateable()
+ .SetColumns(it => new PrdMoTask { mo_task_status = status })
+ .Where(it => subTaskIds.Contains(it.id))
+ .ExecuteCommandAsync();
+ if (row > 0)
{
+ taskReportLogs.AddRange(subMoTaskList);
+ }
+ }
+ }
+ //插入操作记录日志
+ var prdMOTasks = await _db.Queryable().Where(it => input.TaskIds.Contains(it.id) && string.IsNullOrEmpty(it.parent_id)).ToListAsync();
+ if (prdMOTasks?.Count > 0)
+ {
+ List taskLogEntities = new();
+ foreach (var taskId in input.TaskIds)
+ {
+ var taskLog = await db.Queryable().FirstAsync(it => it.mo_task_id == taskId);
+ if (taskLog is null)
+ {
+ var taskItem = list?.Find(x => x.id == taskId);
+ taskLog = new PrdTaskLog();
taskLog.id = SnowflakeIdHelper.NextId();
- taskLog.status = status;
+ if (taskItem != null)
+ {
+ if (taskItem.mo_id!.IsNotEmptyOrNull())
+ {
+ taskLog.mo_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code!;
+ }
+ if (taskItem.eqp_id!.IsNotEmptyOrNull())
+ {
+ taskLog.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.eqp_id))?.code!;
+ }
+ if (taskItem.mold_id!.IsNotEmptyOrNull())
+ {
+ taskLog.mold_code = (await db.Queryable().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code!;
+ }
+ if (taskItem.material_id!.IsNotEmptyOrNull())
+ {
+ var material = await db.Queryable().FirstAsync(it => it.id == taskItem.material_id);
+ taskLog.item_code = material?.code!;
+ taskLog.item_standard = material?.material_standard!;
+ }
+ taskLog.operator_name = _userManager.RealName;
+ taskLog.status = status;
+ taskLog.create_id = _userManager.UserId;
+ taskLog.create_time = DateTime.Now;
+ taskLog.mo_task_id = taskItem.id;
+ }
taskLogEntities.Add(taskLog);
}
+ else
+ {
+ var records = await db.Queryable().Where(it => it.mo_task_id == taskLog.mo_task_id).ToListAsync();
+ if (records != null && !records.Select(x => x.status).Contains(status))
+ {
+ taskLog.id = SnowflakeIdHelper.NextId();
+ taskLog.status = status;
+ taskLogEntities.Add(taskLog);
+ }
+ }
}
+ row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
+
+ List prdReportLogs = new();
+ List prdTaskDefectLogs = new();
+ if (taskReportLogs?.Count > 0)
+ {
+ foreach (var taskInfo in taskReportLogs)
+ {
+ //组装生产提报对象
+ var material = (await db.Queryable().FirstAsync(it => it.id == taskInfo.material_id));
+ var mo = await db.Queryable().FirstAsync(it => it.id == taskInfo.mo_id);
+ var record = taskInfo.Adapt();
+ record.masterial_code = material?.code;
+ 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.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskInfo.eqp_id))?.code;
+ record.mo_task_type = mo?.mo_type;
+ record.status = taskInfo.mo_task_status;
+ record.mo_task_id = taskInfo.id;
+ //record.completed_qty = (await db.Queryable().Where(it => it.mo_task_code == taskInfo.mo_task_code).SumAsync(it => it.reported_work_qty)).Value;
+ prdReportLogs.Add(record);
+
+ //组装自检报废对象
+ var sacipRecord = new PrdMoTaskDefectRecord();
+ sacipRecord.material_code = material?.code!;
+ sacipRecord.material_name = material?.name!;
+ sacipRecord.eqp_code = (await db.Queryable().FirstAsync(it => it.id == taskInfo.eqp_id))?.code!;
+ sacipRecord.mold_name = (await db.Queryable().FirstAsync(it => it.id == taskInfo.mold_id))?.mold_name!;
+ sacipRecord.estimated_start_date = taskInfo.estimated_start_date;
+ sacipRecord.estimated_end_date = taskInfo.estimated_end_date;
+ sacipRecord.plan_qty = taskInfo.plan_qty;
+ sacipRecord.scrap_qty = taskInfo.scrap_qty.HasValue ? taskInfo.scrap_qty.Value : 0;
+ sacipRecord.status = taskInfo.mo_task_status;
+ sacipRecord.create_id = _userManager.UserId;
+ sacipRecord.create_time = DateTime.Now;
+ sacipRecord.mo_task_id = taskInfo.id;
+ sacipRecord.mo_task_code = taskInfo.mo_task_code;
+ sacipRecord.mo_task_type = mo?.mo_type;
+ sacipRecord.status = taskInfo.mo_task_status;
+ prdTaskDefectLogs.Add(sacipRecord);
+ }
+ }
+ row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
+ row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
}
- row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
}
+ else
+ throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
return (row > 0);
}
@@ -968,38 +1030,31 @@ namespace Tnb.ProductionMgr
{
var row = -1;
var db = _repository.AsSugarClient();
- var report = await db.Queryable().FirstAsync(it => it.mo_task_code == input.mo_task_code);
+ var report = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
- if (report is not null)
- {
- report.mo_task_code = input.mo_task_code;
- report.mo_task_id = input.mo_task_id;
- report.reported_work_qty += input.reported_qty;
- report.prd_qty += input.reported_qty;
-
- }
- else
+ //if (report is not null)
+ //{
+ // report.mo_task_code = input.mo_task_code;
+ // report.mo_task_id = input.mo_task_id;
+ // report.reported_work_qty += input.reported_qty;
+ // report.prd_qty += input.reported_qty;
+ //}
+ //else
{
report = input.Adapt();
report.id = SnowflakeIdHelper.NextId();
- report.reported_work_qty = input.reported_qty;
- report.prd_qty = input.reported_qty;
+ report.reported_qty = input.reported_qty;
+ report.create_id = _userManager.UserId;
+ report.create_time = DateTime.Now;
+
}
- row = await db.Storageable(report).ExecuteCommandAsync();
- var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == input.mo_task_code);
- var record = prdTask.Adapt();
- if (prdTask != null)
+ row = await db.Insertable(report).ExecuteCommandAsync();
+ var master = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
+ if (master != null)
{
- var material = (await db.Queryable().FirstAsync(it => it.id == prdTask.material_id));
- record.id = SnowflakeIdHelper.NextId();
- record.masterial_code = material?.code;
- record.masterial_name = material?.name;
- record.plan_start_date = prdTask.estimated_start_date;
- record.plan_end_date = prdTask.estimated_end_date;
- record.plan_qty = prdTask.plan_qty;
- record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.code;
- record.completed_qty = input.reported_qty;
- row = await db.Insertable(record).ExecuteCommandAsync();
+ master.reported_work_qty += input.reported_qty;
+ master.completed_qty += input.reported_qty;
+ await db.Updateable(master).ExecuteCommandAsync();
}
return row > 0;
}
@@ -1060,6 +1115,18 @@ namespace Tnb.ProductionMgr
{
await db.Updateable().SetColumns(it => new PrdMoTask { scrap_qty = scrapQty.Value }).Where(it => it.id == input.mo_task_id).ExecuteCommandAsync();
}
+ var defectRecord = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
+ if (defectRecord != null)
+ {
+ defectRecord.scrap_qty += input.scrap_qty;
+ await db.Updateable(defectRecord).ExecuteCommandAsync();
+ }
+ var reportMaster = await db.Queryable().FirstAsync(it => it.mo_task_id == input.mo_task_id);
+ if (reportMaster != null)
+ {
+ reportMaster.completed_qty += input.scrap_qty;
+ await db.Updateable(reportMaster).ExecuteCommandAsync();
+ }
});
return result.IsSuccess;
@@ -1110,7 +1177,6 @@ namespace Tnb.ProductionMgr
if (outMaterials?.Count > 0)
{
- //var mids = await _db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.material_id).ToListAsync();
var ids = outMaterials.Select(x => x.material_id).ToList();
await _db.Deleteable().Where(it => it.parent_id == input.mo_id).ExecuteCommandAsync();
if (ids?.Count > 0)
@@ -1149,19 +1215,6 @@ namespace Tnb.ProductionMgr
#endregion
- private static dynamic DictionaryToObject(IDictionary dictionary)
- {
- var expandoObj = new ExpandoObject();
- var expandoObjCollection = (ICollection>)expandoObj;
-
- foreach (var keyValuePair in dictionary)
- {
- expandoObjCollection.Add(keyValuePair);
- }
- dynamic eoDynamic = expandoObj;
- return eoDynamic;
- }
-
private static Dictionary dicProperties = new Dictionary(StringComparer.OrdinalIgnoreCase);
private static T DictionaryToObject(IDictionary dictionary) where T : class, new()
{
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
new file mode 100644
index 00000000..a2e25156
--- /dev/null
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
@@ -0,0 +1,159 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Aspose.Cells.Drawing;
+using JNPF.Common.Extension;
+using JNPF.Common.Filter;
+using JNPF.Common.Security;
+using JNPF.DependencyInjection;
+using JNPF.DynamicApiController;
+using JNPF.Systems.Entitys.Permission;
+using JNPF.Systems.Interfaces.System;
+using Mapster;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.CodeAnalysis.Operations;
+using NPOI.POIFS.Properties;
+using Spire.Pdf.Widget;
+using SqlSugar;
+using Tnb.BasicData;
+using Tnb.BasicData.Entities;
+using Tnb.ProductionMgr.Entities;
+using Tnb.ProductionMgr.Entities.Dto.PrdManage;
+using Tnb.ProductionMgr.Interfaces;
+
+namespace Tnb.ProductionMgr
+{
+ ///
+ /// 组装、包装生产提报服务
+ ///
+ [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
+ [Route("api/[area]/[controller]/[action]")]
+
+ public class PrdPackReportService : IPrdPackReportService, IDynamicApiController, ITransient
+ {
+ private readonly ISqlSugarClient _db;
+ private readonly IDictionaryDataService _dictionaryDataService;
+ private static Dictionary> _dicWorkLine = new Dictionary>();
+ public PrdPackReportService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService)
+ {
+ _db = repository.AsSugarClient();
+ _dictionaryDataService = dictionaryDataService;
+ }
+ ///
+ /// 获取组装包装生产任务记录,树形结构
+ ///
+ ///
+ [HttpPost]
+ public async Task GetList(PrdPackReportQueryInput input)
+ {
+ if (input == null) throw new ArgumentNullException("input");
+ List trees = new();
+ var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
+ if (_dicWorkLine.Count < 1)
+ {
+ 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)
+ .Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
+ .Select((a, b, c) => new PrdMoTask
+ {
+ id = a.id,
+ mo_task_code = a.mo_task_code,
+ workline_id = a.workline_id,
+ process_id = a.process_id,
+ plan_start_date = a.estimated_start_date,
+ plan_end_date = a.estimated_end_date,
+ plan_qty = c.plan_qty,
+ complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty),
+ mo_task_status = a.mo_task_status,
+
+ })
+ .ToPagedListAsync(input.currentPage, input.pageSize);
+ _db.ThenMapper(items.list, it =>
+ {
+ it.mo_task_status = it.mo_task_status.IsNotEmptyOrNull() && dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
+ });
+
+ if (items != null && items.list != null && items.list.Any())
+ {
+ foreach (var item in items.list)
+ {
+ var node = item.Adapt();
+ node.parentId = "0";
+ if (item.workline_id.IsNotEmptyOrNull())
+ {
+ var workLine = _dicWorkLine.ContainsKey(item.workline_id) ? (Tuple)_dicWorkLine[item.workline_id] : null;
+ if (workLine != null)
+ {
+ node.workline_id = $"{workLine.Item1}/{workLine.Item2}";
+ }
+ }
+ node.plan_start_date = item.estimated_start_date.HasValue ? item.estimated_start_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
+ node.plan_end_date = item.estimated_end_date.HasValue ? item.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
+ await GetChild(item.id, trees, dic);
+ trees.Add(node);
+ }
+ }
+ var treeList = trees.ToTree();
+ SqlSugarPagedList pagedList = new()
+ {
+ list = treeList,
+ pagination = new Pagination
+ {
+ CurrentPage = input.currentPage,
+ PageSize = input.pageSize,
+ Total = treeList.Count
+ }
+ };
+ return PageResult.SqlSugarPageResult(pagedList);
+ }
+
+ private async Task GetChild(string parentId, List nodes, Dictionary dic)
+ {
+ var items = await _db.Queryable().LeftJoin((a, b) => a.process_id == b.id).LeftJoin((a, b, c) => a.mo_id == c.id)
+ .Where(a => a.parent_id == parentId && a.mo_task_status != "ToBeScheduled")
+ .Select((a, b, c) => new PrdMoTask
+ {
+ id = a.id,
+ mo_task_code = a.mo_task_code,
+ workline_id = a.workline_id,
+ process_id = a.process_id,
+ process_code =b.process_code,
+ process_name = b.process_name,
+ plan_start_date = a.estimated_start_date,
+ plan_end_date = a.estimated_end_date,
+ plan_qty = c.plan_qty,
+ complete_qty = SqlFunc.Subqueryable().Where(it => it.mo_task_code == a.mo_task_code).Sum(it => it.reported_work_qty),
+ mo_task_status = a.mo_task_status,
+
+ }).ToListAsync();
+ _db.ThenMapper(items, it =>
+ {
+ it.mo_task_status = it.mo_task_status.IsNotEmptyOrNull() && dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString() : "";
+ });
+
+ if (items?.Count > 0)
+ {
+ var nsChild = items.Adapt>();
+ for (int i = 0; i < nsChild.Count; i++)
+ {
+ 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") : "";
+ }
+
+ nodes.AddRange(nsChild);
+ foreach (var item in items)
+ {
+ await GetChild(item.id, nodes, dic);
+ }
+ }
+ }
+ }
+}
diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
index 62830b07..3571b851 100644
--- a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
+++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
@@ -23,6 +23,9 @@ using Microsoft.AspNetCore.Mvc;
using DbModels;
using JNPF.Common.Extension;
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
+using NPOI.OpenXmlFormats;
+using JNPF.Systems.Entitys.Permission;
+using Tnb.BasicData;
namespace Tnb.ProductionMgr
{
@@ -131,6 +134,7 @@ namespace Tnb.ProductionMgr
var materialProp = "";
if (prdTask != null)
{
+ var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id);
var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id);
var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id);
@@ -139,6 +143,12 @@ namespace Tnb.ProductionMgr
materialCode = material != null ? material.code : "";
materialName = material != null ? material.name : "";
materialProp = material != null ? material.material_property : "";
+ prdTask.workline_code = (await db.Queryable().Where(it => it.Id == prdTask.workline_id && it.Category == "workline").FirstAsync())?.EnCode;
+ prdTask.process_code = (await db.Queryable().Where(it => it.id == prdTask.process_id).FirstAsync())?.process_code;
+ if (dic.ContainsKey(prdTask.mo_task_status))
+ {
+ prdTask.mo_task_status = dic[prdTask.mo_task_status]?.ToString();
+ }
}
var res = await db.Queryable