Merge branch 'dev' of ssh://git.tuotong-tech.com:9105/tnb/tnb.server into dev
This commit is contained in:
@@ -19,7 +19,10 @@ public static class DictConst
|
||||
/// 生产任务状态TypeId
|
||||
/// </summary>
|
||||
public const string PrdTaskStatusTypeId = "25572555259157";
|
||||
|
||||
/// <summary>
|
||||
/// 生产工单类型TypeId
|
||||
/// </summary>
|
||||
public const string PrdMoTypeTypeId = "25019155728149";
|
||||
|
||||
/// <summary>
|
||||
/// 工单状态-已排产
|
||||
@@ -87,10 +90,6 @@ public static class DictConst
|
||||
/// 模具保养状态-待保养编码
|
||||
/// </summary>
|
||||
public const string MoldMaintainStatusDBYCode = "UnMaintain";
|
||||
/// <summary>
|
||||
/// 模具保养状态TypeId
|
||||
/// </summary>
|
||||
public const string MoldMaintainStatusTypeId = "26171564065301";
|
||||
|
||||
|
||||
|
||||
@@ -111,6 +110,10 @@ public static class DictConst
|
||||
/// </summary>
|
||||
public const string MaintainStatusTypeId = "26171564065301";
|
||||
/// <summary>
|
||||
/// 模具保养状态TypeId
|
||||
/// </summary>
|
||||
public const string MoldMaintainStatusTypeId = "26149299883285";
|
||||
/// <summary>
|
||||
/// 保养状态待保养Code
|
||||
/// </summary>
|
||||
public const string UnMaintainStatusCode = "UnMaintain";
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// <summary>
|
||||
/// 物料型号
|
||||
/// </summary>
|
||||
public string material_category_code { get; set; }
|
||||
public string material_standard { get; set; }
|
||||
/// <summary>
|
||||
///输出数量
|
||||
/// </summary>
|
||||
@@ -35,5 +35,34 @@ namespace Tnb.BasicData.Entities.Dto
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public string num { get; set;}
|
||||
/// <summary>
|
||||
/// 单位id
|
||||
/// </summary>
|
||||
public string unit_id { get; set; }
|
||||
/// <summary>
|
||||
/// bomid
|
||||
/// </summary>
|
||||
public string bom_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工艺路线id
|
||||
/// </summary>
|
||||
public string route_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
/// <summary>
|
||||
/// bom版本
|
||||
/// </summary>
|
||||
public string version { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线名称
|
||||
/// </summary>
|
||||
public string route_name { get; set; }
|
||||
/// <summary>
|
||||
/// 工序排序序号
|
||||
/// </summary>
|
||||
public long? ordinal { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,35 +133,54 @@ namespace Tnb.BasicData
|
||||
/// <summary>
|
||||
/// 根据bomid获取对应的子bom列表
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <param name="bomId">bomId</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>{
|
||||
/// <br/> version:bom版本
|
||||
/// <br/> unit_id:单位id
|
||||
/// <br/> route_name:工艺路线名称
|
||||
/// <br/> process_id:工序id
|
||||
/// <br/> material_id:物料id
|
||||
/// <br/> material_code:物料编码
|
||||
/// <br/> material_name:物料名称
|
||||
/// <br/> material_category_code:类别code
|
||||
/// <br/> output_qty:输出参数
|
||||
/// <br/>}
|
||||
/// </remarks>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetSubMoListByBomId([FromRoute] string bomId)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(bomId)) throw new ArgumentException($"parameter {nameof(bomId)} not be null or empty");
|
||||
var result = await _db.Queryable<BasMbom>().LeftJoin<BasRouteD>((a, b) => a.route_id == b.route_id)
|
||||
.LeftJoin<BasProcess>((a, b, c) => b.process_id == c.id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d) => c.id == d.process_id)
|
||||
.LeftJoin<BasMaterial>((a, b, c, d, e) => d.material_id == e.id)
|
||||
.LeftJoin<BasMaterialCategory>((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<BasMbom>()
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||
.Where((a, b, c, d, e) => a.id == bomId)
|
||||
.Select((a, b, c, d, e) => new SubBomListOutput
|
||||
{
|
||||
version = a.version,
|
||||
unit_id = a.unit_id,
|
||||
route_name = c.name,
|
||||
process_id = b.process_id,
|
||||
material_id = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.id),
|
||||
material_code = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.code),
|
||||
material_name = SqlFunc.Subqueryable<BasMaterial>().Where(it => it.id == e.material_id).Select(it => it.name),
|
||||
material_standard = SqlFunc.Subqueryable<BasMaterial>().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();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据物料id获取生产bom
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Consts
|
||||
{
|
||||
public class MoldPlanMaintainStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具保养计划状态-已完成CODE
|
||||
/// </summary>
|
||||
public const string MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE = "Completed";
|
||||
}
|
||||
}
|
||||
16
EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs
Normal file
16
EquipMgr/Tnb.EquipMgr.Entities/Consts/MoldUseStatus.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Consts
|
||||
{
|
||||
public class MoldUseStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具使用状态在库状态ID
|
||||
/// </summary>
|
||||
public const string MOLDUSESTATUSZKID = "26149307089941";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class MaintainRecordRepeatInput
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
public string repeat_result { get; set; }
|
||||
|
||||
public string repeat_remark { get; set; }
|
||||
|
||||
public List<Dictionary<string,string>> details { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class MaintainRecordRepeatOutput
|
||||
{
|
||||
public EqpMaintainRecordH model { get; set; }
|
||||
|
||||
public List<EqpMaintainRecordD> details { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具保养计划执行查询输出参数
|
||||
/// </summary>
|
||||
public class MoldMaintainPlanRunQueryOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 保养开始时间
|
||||
/// </summary>
|
||||
public string? start_time { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编码
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 保养完成打磨次
|
||||
/// </summary>
|
||||
public int? maintain_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 模具状态
|
||||
/// </summary>
|
||||
public string mold_status { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 设备名称
|
||||
/// </summary>
|
||||
public string eqp_name { get; set; }
|
||||
/// <summary>
|
||||
/// 保养人
|
||||
/// </summary>
|
||||
public string operator_name { get; set; }
|
||||
/// <summary>
|
||||
/// 保养项信息
|
||||
/// </summary>
|
||||
public List<CheckItemInfo> check_items { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class CheckItemInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目组id
|
||||
/// </summary>
|
||||
public string item_group_id { get; set; }
|
||||
/// <summary>
|
||||
/// 项目组名称
|
||||
/// </summary>
|
||||
public string item_group_name { get; set; }
|
||||
/// <summary>
|
||||
/// 保养项id
|
||||
/// </summary>
|
||||
public string item_id { get; set; }
|
||||
/// <summary>
|
||||
/// 保养项名称
|
||||
/// </summary>
|
||||
public string item_name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,17 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
/// 执行计划id
|
||||
/// </summary>
|
||||
public string plan_id { get; set; }
|
||||
/// <summary>
|
||||
/// 保养项Ids
|
||||
/// </summary>
|
||||
public List<string>itemIds { get; set; }
|
||||
/// <summary>
|
||||
/// 保养项状态 0,未完成 1,已完成
|
||||
/// </summary>
|
||||
public int? status { get; set; }
|
||||
/// <summary>
|
||||
/// 模具id
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class RepairApplyDetailOutput
|
||||
{
|
||||
public EqpRepairApply eqpRepairApply { get; set; }
|
||||
public EqpRepairOutApply eqpRepairOutApply { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Tnb.EquipMgr.Entities.Dto
|
||||
{
|
||||
public class RepairApplyOutRegisterInput
|
||||
{
|
||||
public string id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际维修供应商id
|
||||
/// </summary>
|
||||
public string? real_supplier_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public string? attachment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 费用
|
||||
/// </summary>
|
||||
public decimal? cost { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修复时间
|
||||
/// </summary>
|
||||
public DateTime? repair_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维修耗时
|
||||
/// </summary>
|
||||
public decimal? repair_take_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维修备注
|
||||
/// </summary>
|
||||
public string? repair_remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报修申请id
|
||||
/// </summary>
|
||||
public string repair_apply_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -40,9 +40,9 @@ namespace Tnb.EquipMgr.Entities.Dto
|
||||
public string? repair_description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// 维修图片
|
||||
/// </summary>
|
||||
public string? attachment { get; set; }
|
||||
public string? repair_img { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否外修
|
||||
|
||||
57
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
Normal file
57
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipFile.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备附件表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_equip_file")]
|
||||
public partial class EqpEquipFile : BaseEntity<string>
|
||||
{
|
||||
public EqpEquipFile()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public string attachment { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名
|
||||
/// </summary>
|
||||
public string file_name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
82
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipScrap.cs
Normal file
82
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpEquipScrap.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备报废表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_equip_scrap")]
|
||||
public partial class EqpEquipScrap : BaseEntity<string>
|
||||
{
|
||||
public EqpEquipScrap()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 报废时间
|
||||
/// </summary>
|
||||
public DateTime scrap_time { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 负责人id
|
||||
/// </summary>
|
||||
public string charger_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 负责人姓名
|
||||
/// </summary>
|
||||
public string charger_name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 负责人电话
|
||||
/// </summary>
|
||||
public string? charger_phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public string? attachment { get; set; }
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using SqlSugar;
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 保养项目
|
||||
/// 设备保养项目
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_item")]
|
||||
public partial class EqpMaintainItem : BaseEntity<string>
|
||||
@@ -34,25 +34,20 @@ public partial class EqpMaintainItem : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型
|
||||
/// </summary>
|
||||
public string? equip_type_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目编码
|
||||
/// </summary>
|
||||
public string? item_code { get; set; }
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 项目名称
|
||||
/// </summary>
|
||||
public string? item_name { get; set; }
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养类型
|
||||
/// </summary>
|
||||
public int? maintain_type { get; set; }
|
||||
public string maintain_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养内容
|
||||
@@ -74,76 +69,6 @@ public partial class EqpMaintainItem : BaseEntity<string>
|
||||
/// </summary>
|
||||
public int? ordinal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public int? enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend01 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend02 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend03 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend04 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend05 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend06 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend07 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend08 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend09 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO
|
||||
/// </summary>
|
||||
public string? extend10 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// </summary>
|
||||
public string? delete_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除时间
|
||||
/// </summary>
|
||||
public DateTime? delete_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除标志
|
||||
/// </summary>
|
||||
public short? deleted { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
|
||||
92
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
Normal file
92
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordD.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养执行记录子表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_record_d")]
|
||||
public partial class EqpMaintainRecordD : BaseEntity<string>
|
||||
{
|
||||
public EqpMaintainRecordD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备保养执行记录id
|
||||
/// </summary>
|
||||
public string maintain_record_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养检项id
|
||||
/// </summary>
|
||||
public string maintain_item_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string? name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结果 1 通过 2 不通过
|
||||
/// </summary>
|
||||
public string? result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public long ordinal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养设备模板id
|
||||
/// </summary>
|
||||
public string? maintain_tem_equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否通过
|
||||
/// </summary>
|
||||
public string? is_pass { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养项描述
|
||||
/// </summary>
|
||||
public string? descrip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养类型
|
||||
/// </summary>
|
||||
public string maintain_type { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 保养内容
|
||||
/// </summary>
|
||||
public string? maintain_content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保养结果描述
|
||||
/// </summary>
|
||||
public string? maintain_descrip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核 1 通过 2 不通过
|
||||
/// </summary>
|
||||
public string? repeat_result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核结果描述
|
||||
/// </summary>
|
||||
public string? repeat_descrip { get; set; }
|
||||
|
||||
}
|
||||
167
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
Normal file
167
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainRecordH.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养执行记录主表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_record_h")]
|
||||
public partial class EqpMaintainRecordH : BaseEntity<string>
|
||||
{
|
||||
public EqpMaintainRecordH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养设备模板id
|
||||
/// </summary>
|
||||
public string maintain_tem_equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 结果1 合格2不合格
|
||||
/// </summary>
|
||||
public string? result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 点巡检结果备注
|
||||
/// </summary>
|
||||
public string? result_remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行时间
|
||||
/// </summary>
|
||||
public DateTime? execute_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 状态 1待执行 2 待复核 3 已完成
|
||||
/// </summary>
|
||||
public string? status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行人id
|
||||
/// </summary>
|
||||
public string? execute_user_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型id
|
||||
/// </summary>
|
||||
public string? equip_type_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不合格推送
|
||||
/// </summary>
|
||||
public int? is_send { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送时间
|
||||
/// </summary>
|
||||
public DateTime? send_date_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送人id
|
||||
/// </summary>
|
||||
public string? send_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string? code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行通知提前量
|
||||
/// </summary>
|
||||
public int? plan_run_notice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行通知提前量单位 1 小时 2 天 3 周
|
||||
/// </summary>
|
||||
public string? plan_run_notice_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行滞后推送时间
|
||||
/// </summary>
|
||||
public int? plan_delay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行滞后推送时间单位 1 小时 2 天 3 周
|
||||
/// </summary>
|
||||
public string? plan_delay_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核岗位id
|
||||
/// </summary>
|
||||
public string? repeat_post_info_user_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 责任岗位id
|
||||
/// </summary>
|
||||
public string? send_post_info_user_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否复核
|
||||
/// </summary>
|
||||
public string? is_repeat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核时间
|
||||
/// </summary>
|
||||
public DateTime? repeat_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核备注
|
||||
/// </summary>
|
||||
public string? repeat_remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核人id
|
||||
/// </summary>
|
||||
public string? repeat_user_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仅用于关联表字段查询用不存储数据
|
||||
/// </summary>
|
||||
public string? query_info { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public string? attachment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核结果
|
||||
/// </summary>
|
||||
public string? repeat_result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
27
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
Normal file
27
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemD.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养模板子表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_tem_d")]
|
||||
public partial class EqpMaintainTemD : BaseEntity<string>
|
||||
{
|
||||
public EqpMaintainTemD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备保养模板主表id
|
||||
/// </summary>
|
||||
public string maintain_tem_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养项id
|
||||
/// </summary>
|
||||
public string maintain_item_id { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养设备模板子表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_tem_equip_d")]
|
||||
public partial class EqpMaintainTemEquipD : BaseEntity<string>
|
||||
{
|
||||
public EqpMaintainTemEquipD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备保养设备模板主表id
|
||||
/// </summary>
|
||||
public string maintain_tem_equip_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养项id
|
||||
/// </summary>
|
||||
public string maintain_item_id { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
137
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
Normal file
137
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemEquipH.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养设备模板主表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_tem_equip_h")]
|
||||
public partial class EqpMaintainTemEquipH : BaseEntity<string>
|
||||
{
|
||||
public EqpMaintainTemEquipH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime create_time { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养模板表id
|
||||
/// </summary>
|
||||
public string? maintain_tem_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备id
|
||||
/// </summary>
|
||||
public string? equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int ordinal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 周期
|
||||
/// </summary>
|
||||
public int plan_cycle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周期方式 1 单次 2 循环
|
||||
/// </summary>
|
||||
public string? plan_cycle_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行通知提前量
|
||||
/// </summary>
|
||||
public int? plan_run_notice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行通知提前量单位 1 小时 2 天 3 周
|
||||
/// </summary>
|
||||
public string? plan_run_notice_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行滞后推送时间
|
||||
/// </summary>
|
||||
public int? plan_delay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行滞后推送时间单位 1 小时 2 天 3 周
|
||||
/// </summary>
|
||||
public string? plan_delay_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用时间
|
||||
/// </summary>
|
||||
public DateTime start_time { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public string is_start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否复核
|
||||
/// </summary>
|
||||
public string is_repeat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核岗位id
|
||||
/// </summary>
|
||||
public string repeat_post_info_user_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 不合格推送 0 不推送 1 推送
|
||||
/// </summary>
|
||||
public int is_send { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送人id
|
||||
/// </summary>
|
||||
public string? send_post_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 责任岗位id
|
||||
/// </summary>
|
||||
public string send_post_info_user_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
132
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
Normal file
132
EquipMgr/Tnb.EquipMgr.Entities/Entity/EqpMaintainTemH.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.EquipMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 设备保养模板主表
|
||||
/// </summary>
|
||||
[SugarTable("eqp_maintain_tem_h")]
|
||||
public partial class EqpMaintainTemH : BaseEntity<string>
|
||||
{
|
||||
public EqpMaintainTemH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备类型id
|
||||
/// </summary>
|
||||
public string? equip_type_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 编码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 周期
|
||||
/// </summary>
|
||||
public int plan_cycle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 周期方式 1 单次 2 循环
|
||||
/// </summary>
|
||||
public string plan_cycle_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行通知提前量
|
||||
/// </summary>
|
||||
public int? plan_run_notice { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划执行通知提前量单位 1 小时 2 天 3 周
|
||||
/// </summary>
|
||||
public string? plan_run_notice_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行滞后推送时间
|
||||
/// </summary>
|
||||
public int? plan_delay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行滞后推送时间单位 1 小时 2 天 3 周
|
||||
/// </summary>
|
||||
public string? plan_delay_unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用时间
|
||||
/// </summary>
|
||||
public DateTime start_time { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public int is_start { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否复核
|
||||
/// </summary>
|
||||
public int is_repeat { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 复核岗位id
|
||||
/// </summary>
|
||||
public string repeat_post_info_user_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int? ordinal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 不合格推送 0 不推送 1 推送
|
||||
/// </summary>
|
||||
public int is_send { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送人id
|
||||
/// </summary>
|
||||
public string? send_post_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 责任岗位id
|
||||
/// </summary>
|
||||
public string send_post_info_user_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public partial class EqpRepairApply : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
public string? equip_id { get; set; }
|
||||
public string equip_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请用户ID
|
||||
@@ -149,4 +149,9 @@ public partial class EqpRepairApply : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? attachment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 维修图片
|
||||
/// </summary>
|
||||
public string? repair_img { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -114,4 +114,26 @@ public partial class EqpRepairOutApply : BaseEntity<string>
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 附件
|
||||
/// </summary>
|
||||
public string? attachment { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际维修供应商
|
||||
/// </summary>
|
||||
public string? real_supplier_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "f_flowid")]
|
||||
public string? flow_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "f_flowtaskid")]
|
||||
public string? flow_task_id { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public partial class EqpSpotInsItem : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 单位id
|
||||
/// </summary>
|
||||
public string unit_id { get; set; } = string.Empty;
|
||||
public string? unit_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 点巡检方法
|
||||
|
||||
@@ -72,7 +72,7 @@ public partial class EqpSpotInsRecordD : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 单位id
|
||||
/// </summary>
|
||||
public string unit_id { get; set; } = string.Empty;
|
||||
public string? unit_id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 点巡检方法
|
||||
|
||||
@@ -63,5 +63,9 @@ public partial class ToolMoldMaintainItem : BaseEntity<string>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
/// <summary>
|
||||
/// 保养项完成状态 0,未完成,1,已完成
|
||||
/// </summary>
|
||||
public int? status { get; set; }
|
||||
|
||||
}
|
||||
|
||||
15
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
Normal file
15
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipFileService.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEqpEquipFileService
|
||||
{
|
||||
/// <summary>
|
||||
/// 上传附件
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> Upload(string equip_id,IFormFile file);
|
||||
}
|
||||
}
|
||||
13
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipScrapService.cs
Normal file
13
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpEquipScrapService.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Tnb.EquipMgr.Entities;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEqpEquipScrapService
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备报废
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Task<string> Scrap(EqpEquipScrap eqpEquipScrap);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using JNPF.Common.Dtos.VisualDev;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEqpMaintainRecordService
|
||||
{
|
||||
/// <summary>
|
||||
/// 执行设备保养计划
|
||||
/// </summary>
|
||||
/// <param name="pageInput"></param>
|
||||
/// <returns></returns>
|
||||
public Task<dynamic> ExecuteMaintain(SpotInsRecordExecuteInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备保养计划复核信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<MaintainRecordRepeatOutput> GetMaintainRecordRepeatInfo(Dictionary<string, string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 复核备保养计划
|
||||
/// </summary>
|
||||
/// <param name="pageInput"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> RepeatMaintain(MaintainRecordRepeatInput input);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEqpMaintainTemEquipService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 停止计划
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task Stop(Dictionary<string, string> parameters);
|
||||
}
|
||||
}
|
||||
12
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
Normal file
12
EquipMgr/Tnb.EquipMgr.Interfaces/IEqpMaintainTemService.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEqpMaintainTemService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据模板id发布到设备
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
public Task<string> Publish(SpotInsTemPublishInput input);
|
||||
}
|
||||
}
|
||||
@@ -48,5 +48,10 @@ namespace Tnb.EquipMgr.Interfaces
|
||||
/// <param name="dic"></param>
|
||||
public Task<string> Register(RepairApplyRegisterInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取维修详细
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
public Task<RepairApplyDetailOutput> GetRepairApplyDetail(Dictionary<string, string> dic);
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,23 @@ namespace Tnb.EquipMgr.Interfaces
|
||||
public interface IEqpRepairOutApplyService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 获取外修申请信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
public Task<EqpRepairOutApply> GetInfo(Dictionary<string,string> dic);
|
||||
|
||||
/// <summary>
|
||||
/// 外修申请
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
public Task<string> OutApply(RepairOutApplyInput input);
|
||||
|
||||
/// <summary>
|
||||
/// 外修登记
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
public Task<string> Register(RepairApplyOutRegisterInput input);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,6 @@ namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEquSpotInsTemEquipService
|
||||
{
|
||||
// /// <summary>
|
||||
// /// 获取数
|
||||
// /// </summary>
|
||||
// /// <param name="dic"></param>
|
||||
// /// <returns></returns>
|
||||
// public Task<dynamic> GetTree();
|
||||
|
||||
/// <summary>
|
||||
/// 停止计划
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
using Tnb.EquipMgr.Entities;
|
||||
|
||||
namespace Tnb.EquipMgr.Interfaces
|
||||
{
|
||||
public interface IEquipmentService
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 根据id查设备
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
public Task<EqpEquipment> GetEntityById(Dictionary<string, string> dic);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// </summary>
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
public Task<List<EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput);
|
||||
public Task<List<Entities.Dto.EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput);
|
||||
/// <summary>
|
||||
/// 增加模具设备绑定
|
||||
/// </summary>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ProductionMgr\Tnb.ProductionMgr.Entities\Tnb.ProductionMgr.Entities.csproj" />
|
||||
<ProjectReference Include="..\Tnb.EquipMgr.Entities\Tnb.EquipMgr.Entities.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
73
EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
Normal file
73
EquipMgr/Tnb.EquipMgr/EqpEquipFileService.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养计划执行管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpEquipFileService : IEqpEquipFileService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpEquipFile> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly FileService _fileService;
|
||||
|
||||
public EqpEquipFileService(ISqlSugarRepository<EqpEquipFile> repository,
|
||||
FileService fileService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_fileService = fileService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs
Normal file
58
EquipMgr/Tnb.EquipMgr/EqpEquipScrapService.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
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.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养计划执行管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpEquipScrapService : IEqpEquipScrapService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpEquipScrap> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpEquipScrapService(ISqlSugarRepository<EqpEquipScrap> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
// OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> Scrap(EqpEquipScrap eqpEquipScrap)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
eqpEquipScrap.create_id = _userManager.UserId;
|
||||
eqpEquipScrap.create_time = DateTime.Now;
|
||||
|
||||
await _repository.InsertAsync(eqpEquipScrap);
|
||||
|
||||
await db.Updateable<EqpEquipment>().SetColumns(x => x.life == EquipmentLife.SCRAP)
|
||||
.Where(x => x.id == eqpEquipScrap.equip_id).ExecuteCommandAsync();
|
||||
});
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
|
||||
return result.IsSuccess ? "报废成功" : result.ErrorMessage;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
52
EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
Normal file
52
EquipMgr/Tnb.EquipMgr/EqpMaintainTemEquipService.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养设备模板
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class EqpMaintainTemEquipService : IEqpMaintainTemEquipService, IDynamicApiController, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpMaintainTemEquipH> _repository;
|
||||
|
||||
public EqpMaintainTemEquipService(ISqlSugarRepository<EqpMaintainTemEquipH> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public async Task Stop(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
await _repository.UpdateAsync(x => new EqpMaintainTemEquipH()
|
||||
{
|
||||
is_start = "0"
|
||||
}, x => x.id == id);
|
||||
List<string> ids = await _repository.AsSugarClient().Queryable<EqpMaintainRecordH>()
|
||||
.Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED)
|
||||
.Select(x => x.id).ToListAsync();
|
||||
await _repository.AsSugarClient().Deleteable<EqpMaintainRecordH>()
|
||||
.Where(x => x.maintain_tem_equip_id == id && x.status == SpotInsRecordExecutionStatus.TOBEEXECUTED).ExecuteCommandAsync();
|
||||
|
||||
await _repository.AsSugarClient().Deleteable<EqpMaintainRecordD>()
|
||||
.Where(x => ids.Contains(x.maintain_record_id)).ExecuteCommandAsync();
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
}
|
||||
}
|
||||
}
|
||||
119
EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
Normal file
119
EquipMgr/Tnb.EquipMgr/EqpMaintainTemService.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养检模板管理
|
||||
/// </summary>
|
||||
[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<EqpMaintainTemH> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpMaintainTemService(ISqlSugarRepository<EqpMaintainTemH> repository,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据模板id发布到设备
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
[HttpPost]
|
||||
public async Task<string> Publish(SpotInsTemPublishInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
EqpMaintainTemH eqpMaintainTemH = await _repository.GetSingleAsync(x => x.id == input.id);
|
||||
List<EqpMaintainTemD> eqpMaintainTemDs = await db.Queryable<EqpMaintainTemD>().Where(x=>x.maintain_tem_id==input.id).ToListAsync();
|
||||
|
||||
if (input.equipIds != null && input.equipIds.Length > 0)
|
||||
{
|
||||
List<EqpMaintainTemEquipH> insertEqpMaintainTemEquipHs = new List<EqpMaintainTemEquipH>();
|
||||
List<EqpMaintainTemEquipD> insertEqpMaintainTemEquipDs = new List<EqpMaintainTemEquipD>();
|
||||
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<EqpMaintainTemEquipH>().Where(x => x.maintain_tem_id == input.id && x.equip_id == equipId).FirstAsync();
|
||||
await db.Deleteable<EqpMaintainTemEquipH>().Where(x => x.maintain_tem_id == input.id && x.equip_id==equipId).ExecuteCommandAsync();
|
||||
if(oldMaintainTemEquipH!=null)
|
||||
await db.Deleteable<EqpMaintainTemEquipD>().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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,12 +107,27 @@ namespace Tnb.EquipMgr
|
||||
is_halt = input.is_halt,
|
||||
halt_take_time = input.halt_take_time,
|
||||
repair_description = input.repair_description,
|
||||
attachment = input.attachment,
|
||||
repair_img = input.repair_img,
|
||||
is_out_apply = input.is_out_apply,
|
||||
status = status,
|
||||
}, x => x.id == input.id);
|
||||
|
||||
return "登记成功";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<RepairApplyDetailOutput> GetRepairApplyDetail(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
|
||||
EqpRepairApply eqpRepairApply = await _repository.GetSingleAsync(x => x.id == id);
|
||||
EqpRepairOutApply eqpRepairOutApply = await _repository.AsSugarClient().Queryable<EqpRepairOutApply>().FirstAsync(x=>x.repair_apply_id==id);
|
||||
|
||||
return new RepairApplyDetailOutput()
|
||||
{
|
||||
eqpRepairApply = eqpRepairApply,
|
||||
eqpRepairOutApply = eqpRepairOutApply,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
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 JNPF.WorkFlow.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
@@ -21,62 +25,158 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
private readonly ISqlSugarRepository<EqpRepairOutApply> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly FlowTaskService _flowTaskService;
|
||||
/// <summary>
|
||||
/// flow_templatejson 表的id
|
||||
/// </summary>
|
||||
private const string flowId = "26414803850262";
|
||||
|
||||
public EqpRepairOutApplyService(ISqlSugarRepository<EqpRepairOutApply> repository,
|
||||
FlowTaskService flowTaskService,
|
||||
IUserManager userManager)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_flowTaskService = flowTaskService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<EqpRepairOutApply> GetInfo(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
EqpRepairApply eqpRepairApply = await _repository.AsSugarClient().Queryable<EqpRepairApply>().SingleAsync(x => x.id == id);
|
||||
return await _repository.GetSingleAsync(x => x.repair_apply_id==eqpRepairApply.id);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<string> OutApply(RepairOutApplyInput input)
|
||||
{
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
string id = string.IsNullOrEmpty(input.id) ? SnowflakeIdHelper.NextId() : input.id;
|
||||
DbResult<bool> 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
|
||||
{
|
||||
await _repository.UpdateAsync(x=>new EqpRepairOutApply
|
||||
{
|
||||
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,
|
||||
},x=>x.id==input.id);
|
||||
// await _repository.UpdateAsync(x=>new EqpRepairOutApply
|
||||
// {
|
||||
// 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,
|
||||
// },x=>x.id==input.id);
|
||||
}
|
||||
|
||||
await db.Updateable<EqpRepairApply>()
|
||||
.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)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input.id))
|
||||
{
|
||||
_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},
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _repository.GetSingleAsync(x=>x.id==input.id);
|
||||
_flowTaskService.Update("",new FlowTaskSubmitModel()
|
||||
{
|
||||
flowId = flowId,
|
||||
parentId = "0",
|
||||
id = entity.flow_task_id,
|
||||
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<string> Register(RepairApplyOutRegisterInput input)
|
||||
{
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> 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<EqpRepairApply>().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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
146
EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs
Normal file
146
EquipMgr/Tnb.EquipMgr/EquMaintainRecordService.cs
Normal file
@@ -0,0 +1,146 @@
|
||||
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.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备保养计划执行管理
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class EqpMaintainRecordService : IOverideVisualDevService, IEqpMaintainRecordService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "26304609081109";
|
||||
private readonly ISqlSugarRepository<EqpMaintainRecordH> _repository;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public EqpMaintainRecordService(ISqlSugarRepository<EqpMaintainRecordH> repository,
|
||||
IRunService runService,
|
||||
IUserManager userManager,
|
||||
IVisualDevService visualDevService)
|
||||
{
|
||||
_repository = repository;
|
||||
_visualDevService = visualDevService;
|
||||
_runService = runService;
|
||||
_userManager = userManager;
|
||||
// OverideFuncs.UpdateAsync = ExecuteSpotIns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行设备保养计划
|
||||
/// </summary>
|
||||
/// <param name="pageInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ExecuteMaintain(SpotInsRecordExecuteInput input)
|
||||
{
|
||||
DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
{
|
||||
EqpMaintainRecordH eqpSpotInsRecordH = _repository.GetSingle(x=>x.id==input.id);
|
||||
string status = "";
|
||||
if (eqpSpotInsRecordH.is_repeat == "1")
|
||||
{
|
||||
status = SpotInsRecordExecutionStatus.TOBECHECK;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SpotInsRecordExecutionStatus.COMPLETED;
|
||||
}
|
||||
await _repository.UpdateAsync(x => new EqpMaintainRecordH()
|
||||
{
|
||||
result = input.result,
|
||||
attachment = input.attachment,
|
||||
result_remark = input.result_remark,
|
||||
status = status,
|
||||
execute_time = DateTime.Now,
|
||||
execute_user_id = _userManager.UserId
|
||||
}, x => x.id == input.id);
|
||||
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
await _repository.AsSugarClient().Updateable<EqpMaintainRecordD>()
|
||||
.SetColumns(x=>x.result==item["result"])
|
||||
.SetColumns(x=>x.maintain_descrip==item["maintain_descrip"])
|
||||
.Where(x=>x.id==item["id"])
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "执行成功" : result.ErrorMessage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备保养计划复核信息
|
||||
/// </summary>
|
||||
/// <param name="dic"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<MaintainRecordRepeatOutput> GetMaintainRecordRepeatInfo(Dictionary<string, string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
EqpMaintainRecordH eqpSpotInsRecordH = await _repository.GetSingleAsync(x => x.id == id);
|
||||
List<EqpMaintainRecordD> eqpSpotInsRecordDs = await _repository.AsSugarClient().Queryable<EqpMaintainRecordD>()
|
||||
.Where(x => x.maintain_record_id == id).ToListAsync();
|
||||
MaintainRecordRepeatOutput output = new MaintainRecordRepeatOutput()
|
||||
{
|
||||
model = eqpSpotInsRecordH,
|
||||
details = eqpSpotInsRecordDs,
|
||||
};
|
||||
return output;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 复核设备保养计划
|
||||
/// </summary>
|
||||
/// <param name="pageInput"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<string> RepeatMaintain(MaintainRecordRepeatInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
DbResult<bool> result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
|
||||
foreach (var item in input.details)
|
||||
{
|
||||
await db.Updateable<EqpMaintainRecordD>()
|
||||
.SetColumns(x => x.repeat_descrip == item["repeat_descrip"])
|
||||
.SetColumns(x => x.repeat_result == item["repeat_result"])
|
||||
.Where(x => x.id == item["id"]).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
await _repository.UpdateAsync(x => new EqpMaintainRecordH()
|
||||
{
|
||||
repeat_result = input.repeat_result,
|
||||
repeat_remark = input.repeat_remark,
|
||||
repeat_user_id = _userManager.UserId,
|
||||
repeat_time = DateTime.Now,
|
||||
status = SpotInsRecordExecutionStatus.COMPLETED
|
||||
}, x => x.id == input.id);
|
||||
});
|
||||
|
||||
if(!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1008);
|
||||
return result.IsSuccess ? "复核成功" : result.ErrorMessage;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -11,7 +11,7 @@ using Tnb.EquipMgr.Entities;
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备管理
|
||||
/// 点巡检设备模板
|
||||
/// </summary>
|
||||
[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<dynamic> GetTree()
|
||||
// {
|
||||
// List<EqpEquipment> eqpEquipments =
|
||||
// var data = _repository.AsSugarClient().Queryable<EqpEquipType>()
|
||||
// .Where(x => x.status == 1)
|
||||
// .Select((x) => new TreeModel
|
||||
// {
|
||||
// id = x.id,
|
||||
// parentId = "-1",
|
||||
// hasChildren = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Any(),
|
||||
// isLeaf = false,
|
||||
// num = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Count(),
|
||||
// children = SqlFunc.Subqueryable<EqpEquipment>().Where(y=>y.eqp_type_id==x.id).Select(y=>new TreeModel()
|
||||
// {
|
||||
//
|
||||
// }).ToList(model => ),
|
||||
// });
|
||||
// return new { list = 1 };
|
||||
// }
|
||||
|
||||
[HttpPost]
|
||||
public async Task Stop(Dictionary<string, string> parameters)
|
||||
{
|
||||
string id = parameters["id"];
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace Tnb.EquipMgr
|
||||
public EquipmentService(ISqlSugarRepository<EqpEquipment> repository)
|
||||
{
|
||||
_repository = repository;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
/// <summary>
|
||||
/// 在线开发-获取设备列表
|
||||
@@ -63,5 +62,12 @@ namespace Tnb.EquipMgr
|
||||
.ToPagedListAsync(input.currentPage, input.pageSize);
|
||||
return pagedList;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<EqpEquipment> GetEntityById(Dictionary<string,string> dic)
|
||||
{
|
||||
string id = dic["id"];
|
||||
return await _repository.GetSingleAsync(x => x.id == id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,9 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BasicData\Tnb.BasicData.Interfaces\Tnb.BasicData.Interfaces.csproj" />
|
||||
<ProjectReference Include="..\..\system\Tnb.Systems\Tnb.Systems.csproj" />
|
||||
<ProjectReference Include="..\..\visualdev\Tnb.VisualDev.Engine\Tnb.VisualDev.Engine.csproj" />
|
||||
<ProjectReference Include="..\..\workflow\Tnb.WorkFlow\Tnb.WorkFlow.csproj" />
|
||||
<ProjectReference Include="..\Tnb.EquipMgr.Interfaces\Tnb.EquipMgr.Interfaces.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -141,27 +141,29 @@ namespace Tnb.EquipMgr
|
||||
await _db.Ado.BeginTranAsync();
|
||||
|
||||
var maintainRules = await _db.Queryable<ToolMoldMaintainRule>().Where(it => input.ruleIds.Contains(it.id)).ToListAsync();
|
||||
if (maintainRules?.Count > 0)
|
||||
var ruleMoldRelations = await _db.Queryable<ToolMoldMaintainRuleRelation>().Where(it => input.ruleIds.Contains(it.rule_id)).ToListAsync();
|
||||
if (ruleMoldRelations?.Count > 0)
|
||||
{
|
||||
List<ToolMoldMaintainPlan> maintainPlans = new();
|
||||
List<ToolMoldMaintainPlanRelation> maintainPlanRelations = new();
|
||||
foreach (var maintainRule in maintainRules)
|
||||
foreach (var mrr in ruleMoldRelations)
|
||||
{
|
||||
if (maintainRule.cycle.HasValue && maintainRule.cycle.Value > 0)
|
||||
var rule = await _db.Queryable<ToolMoldMaintainRule>().FirstAsync(it => it.id == mrr.rule_id);
|
||||
if (rule != null && rule.cycle.HasValue && rule.cycle.Value > 0)
|
||||
{
|
||||
ToolMoldMaintainPlan maintainPlan = new();
|
||||
maintainPlan.plan_code = $"JHDM{DateTime.Now:yyyyMMddmmss}";
|
||||
maintainPlan.mode = maintainRule.mode;
|
||||
maintainPlan.mode = rule.mode;
|
||||
maintainPlan.status = DictConst.UnMaintainStatusCode;
|
||||
maintainPlan.plan_start_date = DateTime.Now;
|
||||
maintainPlan.plan_end_date = DateTime.Now.AddDays(maintainRule.cycle.Value);
|
||||
maintainPlan.plan_end_date = DateTime.Now.AddDays(rule.cycle.Value);
|
||||
maintainPlan.create_id = _userManager.UserId;
|
||||
maintainPlan.create_time = DateTime.Now;
|
||||
maintainPlans.Add(maintainPlan);
|
||||
|
||||
ToolMoldMaintainPlanRelation maintainPlanReation = new();
|
||||
maintainPlanReation.maintain_plan_id = maintainPlan.id;
|
||||
maintainPlanReation.mold_id = (await _db.Queryable<ToolMoldMaintainRuleRelation>().FirstAsync(it => it.rule_id == maintainRule.id))?.mold_id!;
|
||||
maintainPlanReation.mold_id = mrr.mold_id;
|
||||
maintainPlanRelations.Add(maintainPlanReation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.FriendlyException;
|
||||
@@ -14,13 +15,18 @@ using JNPF.Logging;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using StackExchange.Profiling.Internal;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.EquipMgr.Entities.Consts;
|
||||
using Tnb.EquipMgr.Entities.Dto;
|
||||
using Tnb.EquipMgr.Interfaces;
|
||||
|
||||
namespace Tnb.EquipMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 模具维修任务执行
|
||||
/// </summary>
|
||||
[ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
|
||||
@@ -37,9 +43,8 @@ namespace Tnb.EquipMgr
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据计划id,获取相关联模具、设备、保养项目组、保养项,信息
|
||||
/// 根据计划id,获取相关联模具、设备、信息
|
||||
/// </summary>
|
||||
/// <param name="planId"></param>
|
||||
/// <returns></returns>
|
||||
@@ -47,7 +52,16 @@ namespace Tnb.EquipMgr
|
||||
public async Task<dynamic> GetMaintainInfoFromByPlanId([FromRoute] string planId)
|
||||
{
|
||||
dynamic info = new ExpandoObject();
|
||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>().FirstAsync(it => it.id == planId);
|
||||
var planMoldRelation = await _db.Queryable<ToolMoldMaintainPlanRelation>()
|
||||
.LeftJoin<ToolMoldMaintainPlan>((a, b) => a.maintain_plan_id == b.id)//ToolMoldMaintainPlan
|
||||
.LeftJoin<ToolMoldMaintainRunRecord>((a, b, c) => b.plan_code == c.plan_code)
|
||||
.Where(a => a.maintain_plan_id == planId)
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
mold_id = a.mold_id,
|
||||
plan_start_time = c.plan_start_time,
|
||||
})
|
||||
.FirstAsync();
|
||||
if (planMoldRelation != null)
|
||||
{
|
||||
var mold = await _db.Queryable<ToolMolds>().FirstAsync(it => it.id == planMoldRelation.mold_id);
|
||||
@@ -55,6 +69,9 @@ namespace Tnb.EquipMgr
|
||||
{
|
||||
info.mold_code = mold.mold_code;
|
||||
info.mold_name = mold.mold_name;
|
||||
info.mold_status = (await _dictionaryDataService.GetInfo(mold.mold_status))?.FullName;
|
||||
info.maintain_qty = mold.maintain_qty;
|
||||
info.plan_start_time = planMoldRelation.plan_start_time;
|
||||
var moldEqpRelation = await _db.Queryable<ToolMoldsEquipment>().FirstAsync(it => it.mold_id == mold.id);
|
||||
if (moldEqpRelation != null)
|
||||
{
|
||||
@@ -62,28 +79,41 @@ namespace Tnb.EquipMgr
|
||||
info.eqp_code = eqp.code;
|
||||
info.eqp_name = eqp.name;
|
||||
}
|
||||
var itemGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == mold.id);
|
||||
if (itemGroupRelation != null)
|
||||
{
|
||||
var itemGroup = await _db.Queryable<ToolMoldMaintainGroup>().FirstAsync(it => it.id == itemGroupRelation.item_group_id);
|
||||
if (itemGroup != null)
|
||||
{
|
||||
info.item_group_name = itemGroup.name;
|
||||
}
|
||||
var itemRelation = await _db.Queryable<ToolMoldMaintainGroupItem>().FirstAsync(it => it.item_group_id == itemGroupRelation.item_group_id);
|
||||
if (itemRelation != null)
|
||||
{
|
||||
var checkItem = await _db.Queryable<ToolMoldMaintainItem>().FirstAsync(it => it.id == itemRelation.item_id);
|
||||
if (checkItem != null)
|
||||
{
|
||||
info.item_name = checkItem.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据模具ID获取,保养组及项目信息
|
||||
/// </summary>
|
||||
/// <param name="moldId">模具ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetCheckItemAndGrpByMoldId([FromRoute] string moldId)
|
||||
{
|
||||
if (moldId.IsNullOrEmpty()) throw new ArgumentException($"parameter {nameof(moldId)} not be null or empty");
|
||||
|
||||
var itemGroupRelation = await _db.Queryable<ToolMoldMaintainGroupRelation>().FirstAsync(it => it.mold_id == moldId);
|
||||
if (itemGroupRelation != null)
|
||||
{
|
||||
var checkItems = await _db.Queryable<ToolMoldMaintainGroup, ToolMoldMaintainGroupItem, ToolMoldMaintainItem>((a, b, c) => new JoinQueryInfos
|
||||
(
|
||||
JoinType.Left, a.id == b.item_group_id,
|
||||
JoinType.Left, b.item_id == c.id
|
||||
))
|
||||
.Where(a => a.id == itemGroupRelation.item_group_id)
|
||||
.Select((a, b, c) => new
|
||||
{
|
||||
item_group_id = a.id,
|
||||
item_group_name = a.name,
|
||||
item_id = c.id,
|
||||
item_name = c.name,
|
||||
}).ToListAsync();
|
||||
return checkItems;
|
||||
}
|
||||
return Enumerable.Empty<dynamic>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 模具保养计划执行-开始模具保养
|
||||
@@ -148,6 +178,14 @@ namespace Tnb.EquipMgr
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task MaintainItemFinish(MoldMaintainRunUpInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
if (input.itemIds == null || input.itemIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.itemIds)} not be null or empty");
|
||||
var row = await _db.Updateable<ToolMoldMaintainItem>().SetColumns(it => new ToolMoldMaintainItem { status = input.status }).Where(it => input.itemIds.Contains(it.id)).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
/// <summary>
|
||||
/// 模具保养计划执行-保养完成
|
||||
/// </summary>
|
||||
@@ -156,7 +194,34 @@ namespace Tnb.EquipMgr
|
||||
[HttpPost]
|
||||
public async Task MaintainFinish(MoldMaintainRunUpInput input)
|
||||
{
|
||||
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
var grpIds = await _db.Queryable<ToolMoldMaintainGroupRelation>()
|
||||
.LeftJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.Where(a => a.mold_id == input.mold_id)
|
||||
.Select((a, b) => a.item_group_id)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
var itemIds = await _db.Queryable<ToolMoldMaintainGroupItem>().Where(it => grpIds.Contains(it.item_group_id)).Select(it => it.item_id).ToListAsync();
|
||||
if (itemIds?.Count > 0)
|
||||
{
|
||||
var items = await _db.Queryable<ToolMoldMaintainItem>().Where(it => itemIds.Contains(it.id) && it.status.HasValue && it.status.Value == 1).ToListAsync();
|
||||
if (items?.Count < itemIds.Count)
|
||||
{
|
||||
throw new AppFriendlyException("当前模具有未完成的保养项目", 500);
|
||||
}
|
||||
var row = await _db.Updateable<ToolMolds>().SetColumns(it => new ToolMolds { mold_status = MoldUseStatus.MOLDUSESTATUSZKID }).Where(it => it.id == input.mold_id).ExecuteCommandAsync();
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
var allMoldStatus = await _db.Queryable<ToolMoldMaintainPlanRelation>().InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.Where((a, b) => a.maintain_plan_id == input.plan_id)
|
||||
.Select((a, b) => b.mold_status)
|
||||
.ToListAsync();
|
||||
if (allMoldStatus?.Count > 0 && allMoldStatus.All(x => x == MoldUseStatus.MOLDUSESTATUSZKID))
|
||||
{
|
||||
row = await _db.Updateable<ToolMoldMaintainPlan>().SetColumns(it => new ToolMoldMaintainPlan { status = MoldPlanMaintainStatus.MOLDPLAN_MAINTAIN_STATUS_COMPLETED_CODE }).Where(it => it.id == input.plan_id).ExecuteCommandAsync();
|
||||
}
|
||||
if (row < 1) throw Oops.Oh(ErrorCode.COM1001);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{ /// <summary>
|
||||
@@ -67,7 +68,7 @@ namespace Tnb.EquipMgr
|
||||
/// <param name="mold"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<List<EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput)
|
||||
public async Task<List<Tnb.EquipMgr.Entities.Dto.EquipmentListOutput>> GetEquipmentLists(ToolMoldInput ToolMoldInput)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<EqpEquipment, ToolMoldsEquipment>((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,
|
||||
|
||||
@@ -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<dynamic> Child { get; set; }
|
||||
public bool HasChild { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class GenSubMoCrInput
|
||||
{
|
||||
public string bom_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
/// <summary>
|
||||
/// 子物料ids
|
||||
/// 工序ids
|
||||
/// </summary>
|
||||
public List<string> ids { get; set; }
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装,生产任务管理树形输出类
|
||||
/// </summary>
|
||||
public class PackReportTreeOutput : TreeModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务编号
|
||||
/// </summary>
|
||||
public string? mo_task_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单Id
|
||||
/// </summary>
|
||||
public string? mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料Id
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产线id
|
||||
/// </summary>
|
||||
public string? workline_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工位id
|
||||
/// </summary>
|
||||
public string? workstation_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工艺路线id
|
||||
/// </summary>
|
||||
public string? workroute_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产bom id
|
||||
/// </summary>
|
||||
public string? bom_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单状态
|
||||
/// </summary>
|
||||
public string? mo_task_status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划数量
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已投入数量
|
||||
/// </summary>
|
||||
public int? input_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已完工数量
|
||||
/// </summary>
|
||||
public int? complete_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int? scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int? scheduled_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排产类型:1、注塑、挤出2、组装、包装
|
||||
/// </summary>
|
||||
public int? schedule_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始时间
|
||||
/// </summary>
|
||||
public string plan_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划结束时间
|
||||
/// </summary>
|
||||
public string plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际开工日期
|
||||
/// </summary>
|
||||
public DateTime? act_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际完工日期
|
||||
/// </summary>
|
||||
public DateTime? act_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改人
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展字段
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产顺序
|
||||
/// </summary>
|
||||
public int? prd_order { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预计开始时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 预计结束时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 父任务Id
|
||||
/// </summary>
|
||||
public string? parent_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序任务量
|
||||
/// </summary>
|
||||
public int? process_task_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 排产数量
|
||||
/// </summary>
|
||||
public string scheduled_qty { get; set; }
|
||||
public int scheduled_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计开始时间
|
||||
|
||||
@@ -21,6 +21,10 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public string material_id { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string material_code { get; set; }
|
||||
|
||||
@@ -75,6 +75,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 预计完工时间
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
public string process_code { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
public string process_name { get; set;}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,12 @@ using JNPF.Common.Security;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
public class PrdMotreeOutput : TreeModel
|
||||
public class PrdMoTreeOutput : TreeModel
|
||||
{
|
||||
|
||||
//public Dictionary<string, object> row { get; set; }
|
||||
|
||||
#region 注释代码
|
||||
public string? org_id { get; set; }
|
||||
/// <summary>
|
||||
/// 工单id
|
||||
@@ -25,6 +29,14 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料规格型号
|
||||
/// </summary>
|
||||
public string material_standard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||
@@ -39,37 +51,37 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 计划生产数量
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
public string plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已投入数量
|
||||
/// </summary>
|
||||
public int? input_qty { get; set; }
|
||||
public string input_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已完工数量
|
||||
/// </summary>
|
||||
public int? complete_qty { get; set; }
|
||||
public string complete_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int? scrap_qty { get; set; }
|
||||
public string scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划开始时间
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date { get; set; }
|
||||
public string plan_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计划结束时间
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date { get; set; }
|
||||
public string plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否生派工单
|
||||
/// </summary>
|
||||
public int? is_create_dispatch { get; set; }
|
||||
public string is_create_dispatch { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -80,7 +92,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 是否合并
|
||||
/// </summary>
|
||||
public int? is_merge { get; set; }
|
||||
public string is_merge { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 组合工单
|
||||
@@ -100,7 +112,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
public string create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
@@ -110,19 +122,20 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
public string modify_time { get; set; }
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
public string? material_id_id { get; set; }
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int? scheduled_qty { get; set; }
|
||||
public string scheduled_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 父工单id
|
||||
/// </summary>
|
||||
public string parent_id { get; set; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产任务编号
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -46,5 +46,7 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// 物料属性
|
||||
/// </summary>
|
||||
public string material_property { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,5 +168,8 @@ public partial class PrdMoTask : BaseEntity<string>
|
||||
/// 工序任务量
|
||||
/// </summary>
|
||||
public int? process_task_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工序id
|
||||
/// </summary>
|
||||
public string process_id { get; set; }
|
||||
}
|
||||
|
||||
@@ -31,5 +31,59 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? mold_cavity_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务计划数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? icmo_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 已报工数量
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? reported_work_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 提报数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? reported_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 生产数量
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int? prd_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料属性
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string material_property { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string process_name { get; set; }
|
||||
/// <summary>
|
||||
/// 工序编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string process_code { get; set; }
|
||||
/// <summary>
|
||||
/// 产线编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string workline_code { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,5 +48,11 @@ public partial class PrdMoTaskDefect : BaseEntity<string>
|
||||
/// 批次
|
||||
/// </summary>
|
||||
public string? batch { get; set; }
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int scrap_qty { get; set; }
|
||||
|
||||
public int mo_task_type { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public partial class PrdMoTaskDefectRecord : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int? scrap_qty { get; set; }
|
||||
public int scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 生产任务单状态
|
||||
@@ -78,5 +78,9 @@ public partial class PrdMoTaskDefectRecord : BaseEntity<string>
|
||||
/// 任务单编号
|
||||
/// </summary>
|
||||
public string? mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public string mo_task_type { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -47,11 +47,26 @@ public partial class PrdReportRecord : BaseEntity<string>
|
||||
/// <summary>
|
||||
/// 完成数量
|
||||
/// </summary>
|
||||
public int? completed_qty { get; set; }
|
||||
public int completed_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单号
|
||||
/// </summary>
|
||||
public string? mo_task_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务单状态
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
/// <summary>
|
||||
/// 任务类型
|
||||
/// </summary>
|
||||
public string mo_task_type { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务id
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// 已报工数量
|
||||
/// </summary>
|
||||
public int reported_work_qty { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.ProductionMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装 生产提报接口
|
||||
/// </summary>
|
||||
public interface IPrdPackReportService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -225,6 +225,7 @@ namespace Tnb.ProductionMgr
|
||||
|
||||
await _maintainTaskService.Create(maintaindTask);
|
||||
}
|
||||
|
||||
}
|
||||
else throw Oops.Oh(ErrorCode.COM1001);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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<PrdTask> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
@@ -98,14 +104,14 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet("{materialId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string materialId)
|
||||
{
|
||||
var result = new List<MoldListOutput>();
|
||||
var result = new List<Tnb.ProductionMgr.Entities.Dto.MoldListOutput>();
|
||||
result = await _db.Queryable<ToolMoldsMaterial>()
|
||||
.InnerJoin<ToolMolds>((a, b) => a.mold_id == b.id)
|
||||
.InnerJoin<BasMaterial>((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_id = b.id,
|
||||
mold_code = b.mold_code,
|
||||
mold_name = b.mold_name,
|
||||
mold_type_code = b.mold_type_code,
|
||||
@@ -125,7 +131,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var items = await _db.Queryable<ToolMoldsEquipment>().InnerJoin<EqpEquipment>((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,
|
||||
@@ -211,71 +217,6 @@ namespace Tnb.ProductionMgr
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据任务单号获取提报记录明细
|
||||
/// </summary>
|
||||
/// <param name="icmoCode">任务单号</param>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
///<br/> {
|
||||
///<br/> icmo_qty:任务计划数量
|
||||
///<br/> reported_work_qty:已报工数量
|
||||
///<br/> reported_qty:报工数量
|
||||
///<br/> prd_qty:生产数量
|
||||
///<br/> }
|
||||
/// </remarks>
|
||||
[HttpGet("{mo_task_code}")]
|
||||
public async Task<dynamic> GetPrdReportByIcmoCode(string mo_task_code)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var prdTask = await db.Queryable<PrdMoTask>().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<EqpEquipment>().FirstAsync(it => it.id == prdTask.eqp_id);
|
||||
var mold = await db.Queryable<ToolMolds>().FirstAsync(it => it.id == prdTask.mold_id);
|
||||
var material = await db.Queryable<BasMaterial>().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<PrdReport>().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<PrdScrapped>().Select(x => x.scrap_qty),
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
it.icmo_qty = it.icmo_qty ?? (db.Queryable<PrdTask>().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable<PrdTask>().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<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty,
|
||||
reported_work_qty = 0,
|
||||
prd_qty = 0,
|
||||
//scrap_qty = 0,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取自检报废批次记录
|
||||
/// </summary>
|
||||
/// <param name="moTaskId">任务单Id</param>
|
||||
@@ -337,7 +278,6 @@ namespace Tnb.ProductionMgr
|
||||
[HttpGet("{moId}")]
|
||||
public async Task<dynamic> GetPrdTaskInfoByMoId(string moId, int schedType = 1)
|
||||
{
|
||||
|
||||
List<PrdMoTaskOutput> result = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
if (schedType == 1)
|
||||
@@ -363,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<BasProcess>().Where(it => it.id == a.process_id).Select(it => it.process_code),
|
||||
process_name = SqlFunc.Subqueryable<BasProcess>().Where(it => it.id == a.process_id).Select(it => it.process_name),
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
@@ -375,7 +317,7 @@ namespace Tnb.ProductionMgr
|
||||
result = await _db.Queryable<PrdMoTask>().LeftJoin<PrdMo>((a, b) => a.mo_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => a.material_id == c.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c, d) => a.workline_id == d.Id)
|
||||
.Where((a, b, c, d) => a.mo_id == moId)
|
||||
.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,
|
||||
@@ -408,28 +350,29 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> GetPackScheldToBeIssueList([FromQuery] PackScheldToBeIssueListInput input)
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var result = await _db.Queryable<PrdMoTask>().Where(it => it.schedule_type == 2)
|
||||
.LeftJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<OrganizeEntity>((a, b, c) => a.workline_id == c.Id)
|
||||
.LeftJoin<PrdMo>((a, b, c, d) => a.mo_id == d.id)
|
||||
.LeftJoin<BasMbom>((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<PrdMoTask>()
|
||||
.LeftJoin<OrganizeEntity>((a, b) => a.workline_id == b.Id)
|
||||
.LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.LeftJoin<BasMbom>((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<BasMaterial>().Where(it => it.id == a.material_id).Select(it => it.code),
|
||||
material_name = SqlFunc.Subqueryable<BasMaterial>().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<PrdMoTask>().Where(it => it.mo_id == a.mo_id).Sum(it => it.scheduled_qty),
|
||||
plan_qty = SqlFunc.Subqueryable<PrdMo>().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();
|
||||
@@ -461,8 +404,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<BasMbom>().Where(it => it.material_id == a.material_id).Select(it => it.version)
|
||||
})
|
||||
.Mapper(it => it.mo_task_status = dic.ContainsKey(it.mo_task_status) ? dic[it.mo_task_status].ToString()! : "")
|
||||
.OrderBy(a => a.mo_task_code, OrderByType.Asc)
|
||||
.ToListAsync();
|
||||
return result;
|
||||
}
|
||||
@@ -471,29 +416,80 @@ namespace Tnb.ProductionMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetUnSchedulingList()
|
||||
public async Task<dynamic> GetUnSchedulingList([FromQuery] VisualDevModelListQueryInput input)
|
||||
{
|
||||
List<PrdMotreeOutput> trees = new();
|
||||
var list = await _db.Queryable<PrdMo>().Where(it => string.IsNullOrEmpty(it.parent_id) && it.mo_status == DictConst.ScheduledId).ToListAsync();
|
||||
foreach (var item in list)
|
||||
List<PrdMoTreeOutput> 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<PrdMotreeOutput>();
|
||||
node.mo_id = item.id;
|
||||
node.id = SnowflakeIdHelper.NextId();
|
||||
node.parentId = "0";
|
||||
var items = await _db.Queryable<PrdMo>().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<List<PrdMotreeOutput>>();
|
||||
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<PrdMoTreeOutput>(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<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
node.material_id_id = materialId;
|
||||
node.material_code = material?.code;
|
||||
node.material_name = material?.name;
|
||||
node.material_standard = material?.material_standard;
|
||||
}
|
||||
trees.AddRange(childNodes);
|
||||
//
|
||||
var scheldQtyCol = nameof(PrdMo.scheduled_qty);
|
||||
|
||||
node.scheduled_qty = _db.Queryable<PrdMoTask>().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();
|
||||
var subData = await _runService.GetListResult(templateEntity, input);
|
||||
if (subData?.list?.Count > 0)
|
||||
{
|
||||
var childNodes = new List<PrdMoTreeOutput>();
|
||||
foreach (var item in subData.list)
|
||||
{
|
||||
dic = item.ToDictionary(x => x.Key, x => x.Value);
|
||||
PrdMoTreeOutput subNode = DictionaryToObject<PrdMoTreeOutput>(item);
|
||||
subNode.parentId = node.id;
|
||||
subNode.mo_id = subNode.id;
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
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<PrdMoTask>().Where(it => it.mo_id == dic["id"].ToString()).Sum(it => it.scheduled_qty)?.ToString();
|
||||
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<PrdMoTreeOutput> pagedList = new()
|
||||
{
|
||||
list = treeList,
|
||||
pagination = new Pagination
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = treeList.Count
|
||||
}
|
||||
};
|
||||
return PageResult<PrdMoTreeOutput>.SqlSugarPageResult(pagedList);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -593,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<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
|
||||
sacipRecord.mold_name = (await db.Queryable<ToolMolds>().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<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code!;
|
||||
//sacipRecord.mold_name = (await db.Queryable<ToolMolds>().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();
|
||||
}
|
||||
@@ -641,18 +637,22 @@ namespace Tnb.ProductionMgr
|
||||
var moTask = input.Adapt<PrdMoTask>();
|
||||
moTask.id = SnowflakeIdHelper.NextId();
|
||||
moTask.create_id = _userManager.UserId;
|
||||
moTask.bom_id = input.bom_id;
|
||||
moTask.workroute_id = (await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id))?.route_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<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
var moCode = mo?.mo_code;
|
||||
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
|
||||
var taskCode = await _db.Queryable<PrdMoTask>().Where(it => string.IsNullOrEmpty(it.parent_id) && !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode))
|
||||
.OrderByDescending(it => it.mo_task_code)
|
||||
.Select(it => it.mo_task_code)
|
||||
.FirstAsync();
|
||||
if (taskCode!.IsNullOrEmpty())
|
||||
if (taskCode is null || taskCode.IsNullOrEmpty())
|
||||
{
|
||||
moTask.mo_task_code = $"{moCode}-01";
|
||||
}
|
||||
@@ -669,7 +669,7 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
row = await _db.Insertable(moTask).ExecuteCommandAsync();
|
||||
var material_h = await _db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id);
|
||||
//添加生产任务操作记录日志s
|
||||
//添加生产任务操作记录日志
|
||||
var taskLog = new PrdTaskLog();
|
||||
taskLog.id = SnowflakeIdHelper.NextId();
|
||||
taskLog.mo_code = (await _db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id))?.mo_code!;
|
||||
@@ -718,58 +718,64 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
//根据生产bomId 拆解生产子任务
|
||||
var outputList = new List<PackingSchedulingListOutput>();
|
||||
var bom = await _db.Queryable<BasMbom>().FirstAsync(it => it.id == input.bom_id);
|
||||
if (bom != null && bom.route_id.IsNotEmptyOrNull())
|
||||
var subTaskList = await _db.Queryable<BasMbom>()
|
||||
.LeftJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.LeftJoin<BasRouteH>((a, b, c) => a.route_id == c.id)
|
||||
.LeftJoin<BasRouteD>((a, b, c, d) => b.process_id == d.process_id && c.id == d.route_id)
|
||||
.LeftJoin<BasMbomOutput>((a, b, c, d, e) => a.id == e.mbom_id && e.mbom_process_id == b.id)
|
||||
.Where((a, b, c, d, e) => a.id == input.bom_id)
|
||||
.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<BasMaterial>().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<BasRouteD>().Where(it => it.route_id == bom.route_id).ToListAsync();
|
||||
if (routes?.Count > 0)
|
||||
List<PrdMoTask> subMoTasks = new();
|
||||
foreach (var item in subTaskList)
|
||||
{
|
||||
var processIds = routes.Select(x => x.process_id).ToList();
|
||||
if (processIds?.Count > 0)
|
||||
PrdMoTask subMoTask = new();
|
||||
subMoTask.mo_id = input.mo_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.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;
|
||||
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<BasMbomOutput>().Where(it => processIds.Contains(it.process_id)).ToListAsync();
|
||||
if (bomOutputs?.Count > 0)
|
||||
{
|
||||
List<PrdMoTask> subMoTasks = new();
|
||||
foreach (var item in bomOutputs)
|
||||
{
|
||||
var material = await _db.Queryable<BasMaterial>().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();
|
||||
}
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("组装包装排产时报错", ex);
|
||||
JNPF.Logging.Log.Error("组装包装排产时报错", ex);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
}
|
||||
return row > 0;
|
||||
@@ -798,102 +804,185 @@ 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<PrdMoTask>().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<PrdTaskBehavior>();
|
||||
var status = SetTaskStatus(behavior);
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<PrdMoTask>().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<PrdTaskBehavior>();
|
||||
var status = SetTaskStatus(behavior);
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<PrdMoTask>().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<PrdMoTask>()
|
||||
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||
.Where(it => input.TaskIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
//更新子任务
|
||||
var subMoTaskList = await db.Queryable<PrdMoTask>().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<PrdMoTask>()
|
||||
.SetColumns(it => new PrdMoTask { mo_task_status = status })
|
||||
.Where(it => subTaskIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
//插入操作记录日志
|
||||
var prdMOTasks = await _db.Queryable<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && string.IsNullOrEmpty(it.parent_id)).ToListAsync();
|
||||
if (prdMOTasks?.Count > 0)
|
||||
{
|
||||
List<PrdTaskLog> taskLogEntities = new();
|
||||
foreach (var taskId in input.TaskIds)
|
||||
{
|
||||
var taskLog = await db.Queryable<PrdTaskLog>().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<PrdMo>().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code!;
|
||||
}
|
||||
if (taskItem.eqp_id!.IsNotEmptyOrNull())
|
||||
{
|
||||
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskItem.eqp_id))?.code!;
|
||||
}
|
||||
if (taskItem.mold_id!.IsNotEmptyOrNull())
|
||||
{
|
||||
taskLog.mold_code = (await db.Queryable<ToolMolds>().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code!;
|
||||
}
|
||||
if (taskItem.material_id!.IsNotEmptyOrNull())
|
||||
{
|
||||
var material = await db.Queryable<BasMaterial>().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<PrdMoTask>();
|
||||
var prdTaskList = await db.Queryable<PrdMoTask>().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<PrdTaskLog>().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<PrdMoTask>().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<PrdMoTask>()
|
||||
.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<PrdMoTask>().Where(it => input.TaskIds.Contains(it.id) && string.IsNullOrEmpty(it.parent_id)).ToListAsync();
|
||||
if (prdMOTasks?.Count > 0)
|
||||
{
|
||||
List<PrdTaskLog> taskLogEntities = new();
|
||||
foreach (var taskId in input.TaskIds)
|
||||
{
|
||||
var taskLog = await db.Queryable<PrdTaskLog>().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<PrdMo>().FirstAsync(it => it.id == taskItem.mo_id))?.mo_code!;
|
||||
}
|
||||
if (taskItem.eqp_id!.IsNotEmptyOrNull())
|
||||
{
|
||||
taskLog.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskItem.eqp_id))?.code!;
|
||||
}
|
||||
if (taskItem.mold_id!.IsNotEmptyOrNull())
|
||||
{
|
||||
taskLog.mold_code = (await db.Queryable<ToolMolds>().FirstAsync(it => it.id == taskItem.mold_id))?.mold_code!;
|
||||
}
|
||||
if (taskItem.material_id!.IsNotEmptyOrNull())
|
||||
{
|
||||
var material = await db.Queryable<BasMaterial>().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<PrdTaskLog>().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);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (taskLogEntities?.Count > 0)
|
||||
{
|
||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
List<PrdReportRecord> prdReportLogs = new();
|
||||
List<PrdMoTaskDefectRecord> prdTaskDefectLogs = new();
|
||||
if (taskReportLogs?.Count > 0)
|
||||
{
|
||||
foreach (var taskInfo in taskReportLogs)
|
||||
{
|
||||
//组装生产提报对象
|
||||
var material = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == taskInfo.material_id));
|
||||
var mo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == taskInfo.mo_id);
|
||||
var record = taskInfo.Adapt<PrdReportRecord>();
|
||||
record.id = SnowflakeIdHelper.NextId();
|
||||
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<EqpEquipment>().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<PrdReport>().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.id = SnowflakeIdHelper.NextId();
|
||||
sacipRecord.material_code = material?.code!;
|
||||
sacipRecord.material_name = material?.name!;
|
||||
sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == taskInfo.eqp_id))?.code!;
|
||||
sacipRecord.mold_name = (await db.Queryable<ToolMolds>().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);
|
||||
}
|
||||
}
|
||||
var reportTaskIds = prdReportLogs.Select(it => it.mo_task_id).ToList();
|
||||
if (reportTaskIds?.Count > 0)
|
||||
{
|
||||
var items = await db.Queryable<PrdReportRecord>().Where(it => reportTaskIds.Contains(it.mo_task_id)).ToListAsync();
|
||||
if (items == null || items.Count < 1)
|
||||
{
|
||||
row = await db.Insertable(prdReportLogs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
var defectTaskIds = prdTaskDefectLogs.Select(it => it.mo_task_id).ToList();
|
||||
if (defectTaskIds?.Count > 0)
|
||||
{
|
||||
var items = await db.Queryable<PrdMoTaskDefectRecord>().Where(it => defectTaskIds.Contains(it.mo_task_id)).ToListAsync();
|
||||
if (items == null || items.Count < 1)
|
||||
{
|
||||
row = await db.Insertable(prdTaskDefectLogs).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
row = await db.Insertable(taskLogEntities).ExecuteCommandAsync();
|
||||
}
|
||||
//else
|
||||
// throw new AppFriendlyException("只有待下发状态的任务才可下发", 500);
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
@@ -962,32 +1051,31 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_code == input.mo_task_code);
|
||||
var report = await db.Queryable<PrdReport>().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<PrdReport>();
|
||||
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<PrdMoTask>().FirstAsync(it => it.mo_task_code == input.mo_task_code);
|
||||
var record = prdTask.Adapt<PrdReportRecord>();
|
||||
if (prdTask != null)
|
||||
row = await db.Insertable(report).ExecuteCommandAsync();
|
||||
var master = await db.Queryable<PrdReportRecord>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
if (master != null)
|
||||
{
|
||||
record.id = SnowflakeIdHelper.NextId();
|
||||
record.eqp_code = (await db.Queryable<EqpEquipment>().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;
|
||||
}
|
||||
@@ -1037,7 +1125,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);
|
||||
}
|
||||
}
|
||||
@@ -1048,6 +1136,18 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
await db.Updateable<PrdMoTask>().SetColumns(it => new PrdMoTask { scrap_qty = scrapQty.Value }).Where(it => it.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
var defectRecord = await db.Queryable<PrdMoTaskDefectRecord>().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<PrdReportRecord>().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;
|
||||
@@ -1084,46 +1184,77 @@ 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<PrdMo>().FirstAsync(it => it.id == input.mo_id);
|
||||
if (curMo == null) throw new ArgumentNullException("创建子工单时的父工单不能为null");
|
||||
List<PrdMo> subMoList = new();
|
||||
var outputMaterials = await _db.Queryable<BasMaterial>().LeftJoin<BasMbomOutput>((a, b) => a.id == b.material_id)
|
||||
.Where((a, b) => input.ids.Contains(a.id))
|
||||
.Select((a, b) => new
|
||||
{
|
||||
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);
|
||||
}
|
||||
//生成子工单编码
|
||||
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);
|
||||
|
||||
|
||||
var outMaterials = await _db.Queryable<BasMbom>().InnerJoin<BasMbomProcess>((a, b) => a.id == b.mbom_id)
|
||||
.InnerJoin<BasMbomOutput>((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 = c.material_id,
|
||||
num = c.num,
|
||||
})
|
||||
.ToListAsync();
|
||||
|
||||
if (outMaterials?.Count > 0)
|
||||
{
|
||||
var ids = outMaterials.Select(x => x.material_id).ToList();
|
||||
await _db.Deleteable<PrdMo>().Where(it => it.parent_id == input.mo_id).ExecuteCommandAsync();
|
||||
if (ids?.Count > 0)
|
||||
{
|
||||
var dicOutMaterialNum = outMaterials.DistinctBy(x => x.material_id).ToDictionary(x => x.material_id, x => x.num.ParseToInt());
|
||||
List<PrdMo> subMoList = new();
|
||||
var outputMaterials = await _db.Queryable<BasMaterial>().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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private static Dictionary<string, string[]> dicProperties = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
|
||||
private static T DictionaryToObject<T>(IDictionary<String, Object> 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;
|
||||
}
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
159
ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
Normal file
159
ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 组装、包装生产提报服务
|
||||
/// </summary>
|
||||
[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<string, Tuple<string, string>> _dicWorkLine = new Dictionary<string, Tuple<string, string>>();
|
||||
public PrdPackReportService(ISqlSugarRepository<PrdMoTask> repository, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取组装包装生产任务记录,树形结构
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> GetList(PrdPackReportQueryInput input)
|
||||
{
|
||||
if (input == null) throw new ArgumentNullException("input");
|
||||
List<PackReportTreeOutput> trees = new();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
if (_dicWorkLine.Count < 1)
|
||||
{
|
||||
var list = await _db.Queryable<OrganizeEntity>().Where(it => it.Category == "workline").ToListAsync();
|
||||
_dicWorkLine = list.ToDictionary(x => x.Id, x => Tuple.Create<string, string>(x.EnCode, x.FullName));
|
||||
}
|
||||
|
||||
var items = await _db.Queryable<PrdMoTask>().LeftJoin<BasProcess>((a, b) => a.process_id == b.id).LeftJoin<PrdMo>((a, b, c) => a.mo_id == c.id)
|
||||
.WhereIF(!string.IsNullOrEmpty(input.mo_task_code), a => a.mo_task_code == input.mo_task_code.Trim())
|
||||
.Where(a => string.IsNullOrEmpty(a.parent_id) && a.schedule_type == 2 && a.mo_task_status != "ToBeScheduled")
|
||||
.Select((a, b, c) => new PrdMoTask
|
||||
{
|
||||
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<PrdReport>().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<PackReportTreeOutput>();
|
||||
node.parentId = "0";
|
||||
if (item.workline_id.IsNotEmptyOrNull())
|
||||
{
|
||||
var workLine = _dicWorkLine.ContainsKey(item.workline_id) ? (Tuple<string, string>)_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<PackReportTreeOutput> pagedList = new()
|
||||
{
|
||||
list = treeList,
|
||||
pagination = new Pagination
|
||||
{
|
||||
CurrentPage = input.currentPage,
|
||||
PageSize = input.pageSize,
|
||||
Total = treeList.Count
|
||||
}
|
||||
};
|
||||
return PageResult<PackReportTreeOutput>.SqlSugarPageResult(pagedList);
|
||||
}
|
||||
|
||||
private async Task GetChild(string parentId, List<PackReportTreeOutput> nodes, Dictionary<string, object> dic)
|
||||
{
|
||||
var items = await _db.Queryable<PrdMoTask>().LeftJoin<BasProcess>((a, b) => a.process_id == b.id).LeftJoin<PrdMo>((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<PrdReport>().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<List<PackReportTreeOutput>>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,11 @@ using Tnb.ProductionMgr.Interfaces;
|
||||
using Aspose.Cells.Drawing;
|
||||
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
|
||||
{
|
||||
@@ -60,6 +65,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 +109,80 @@ namespace Tnb.ProductionMgr
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据任务单号获取提报记录明细
|
||||
/// </summary>
|
||||
/// <param name="icmoCode">任务单号</param>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
///<br/> {
|
||||
///<br/> icmo_qty:任务计划数量
|
||||
///<br/> reported_work_qty:已报工数量
|
||||
///<br/> reported_qty:报工数量
|
||||
///<br/> prd_qty:生产数量
|
||||
///<br/> }
|
||||
/// </remarks>
|
||||
[HttpGet]
|
||||
public async Task<dynamic> GetPrdReportByIcmoCode([FromRoute] string mo_task_code)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var prdTask = await db.Queryable<PrdMoTask>().FirstAsync(it => it.mo_task_code == mo_task_code);
|
||||
var eqpCode = "";
|
||||
var moldCode = "";
|
||||
var materialCode = "";
|
||||
var materialName = "";
|
||||
var materialProp = "";
|
||||
if (prdTask != null)
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == prdTask.eqp_id);
|
||||
var mold = await db.Queryable<ToolMolds>().FirstAsync(it => it.id == prdTask.mold_id);
|
||||
var material = await db.Queryable<BasMaterial>().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 : "";
|
||||
prdTask.workline_code = (await db.Queryable<OrganizeEntity>().Where(it => it.Id == prdTask.workline_id && it.Category == "workline").FirstAsync())?.EnCode;
|
||||
prdTask.process_code = (await db.Queryable<BasProcess>().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<PrdReport>().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<PrdMoTaskDefect>().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<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty < 1 ? 0 :
|
||||
(it.icmo_qty ?? db.Queryable<PrdMoTask>().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty ?? 0));
|
||||
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;
|
||||
prdTask.scrap_qty = res?.scrap_qty ?? 0;
|
||||
|
||||
return prdTask;
|
||||
}
|
||||
|
||||
//public async Task<dynamic> GetPrdMoTaskList()
|
||||
//{
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
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;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using Tnb.BasicData;
|
||||
using JNPF.Common.Extension;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// 生产提报记录
|
||||
/// </summary>
|
||||
[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<PrdMoTask> _repository;
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public ProductionReportRecordService(ISqlSugarRepository<PrdMoTask> repository, IRunService runService, IVisualDevService visualDevService, IDictionaryDataService dictionaryDataService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
}
|
||||
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
//if (data?.list?.Count > 0)
|
||||
//{
|
||||
// var dicMoTaskStatus = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
// foreach (var row in data.list)
|
||||
// {
|
||||
// var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
// //if (dic.ContainsKey(nameof(PrdReportRecord.status)))
|
||||
// //{
|
||||
// // var statusCode = dic[nameof(PrdReportRecord.status)].ToString();
|
||||
// // row[nameof(PrdReportRecord.status)] = dicMoTaskStatus[statusCode];
|
||||
// //}
|
||||
// if (dic.ContainsKey(nameof(PrdReportRecord.mo_task_type)))
|
||||
// {
|
||||
// var moTypeId = dic[nameof(PrdReportRecord.mo_task_type)].ToString();
|
||||
// if (moTypeId.IsNotEmptyOrNull())
|
||||
// {
|
||||
// row[nameof(PrdReportRecord.mo_task_type)] = (await _dictionaryDataService.GetInfo(moTypeId)).FullName;
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
return data!;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +194,18 @@ public class UserManager : IUserManager, IScoped
|
||||
/// </summary>
|
||||
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 从字典中获取值,不存在则返回字典<typeparamref name="TValue"/>类型的默认值.
|
||||
/// </summary>
|
||||
@@ -55,4 +57,31 @@ public static class DictionaryExtensions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, string[]> dicProperties = new Dictionary<string, string[]>(StringComparer.OrdinalIgnoreCase);
|
||||
/// <summary>
|
||||
/// 字典转换成指定类型实例
|
||||
/// added by ly on 20230524
|
||||
/// </summary>
|
||||
/// <typeparam name="T">转换的目标类型</typeparam>
|
||||
/// <param name="dictionary">被转换的字典</param>
|
||||
/// <returns>转换后的目标类型对象实例</returns>
|
||||
public static T ToObject<T>(this Dictionary<String, Object> 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;
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,22 @@ namespace JNPF.Common.Extension
|
||||
}
|
||||
setAction(instance, value);
|
||||
}
|
||||
|
||||
public static void PropertySetValue<T>(this T instance, string propertyName, object value)
|
||||
{
|
||||
if (!PropertySet<T>.ValueFactories2.TryGetValue(propertyName, out Action<T, object> setAction))
|
||||
{
|
||||
setAction = PropertySet<T>.CreateSetPropertyValueAction2(propertyName);
|
||||
PropertySet<T>.ValueFactories2.Add(propertyName, setAction);
|
||||
}
|
||||
setAction(instance, value);
|
||||
}
|
||||
}
|
||||
|
||||
public class PropertySet<T>
|
||||
{
|
||||
public static Dictionary<string, Action<object, object>> ValueFactories = new Dictionary<string, Action<object, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
public static Dictionary<string, Action<T, object>> ValueFactories2 = new Dictionary<string, Action<T, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public static Action<object, object> CreateSetPropertyValueAction(string propertyName)
|
||||
{
|
||||
@@ -35,5 +46,17 @@ namespace JNPF.Common.Extension
|
||||
return Expression.Lambda<Action<object, object>>(setPropertyValue, target, propertyValue).Compile();
|
||||
}
|
||||
|
||||
public static Action<T, object> CreateSetPropertyValueAction2(string propertyName)
|
||||
{
|
||||
var property = typeof(T).GetProperty(propertyName);
|
||||
var target = Expression.Parameter(typeof(T));
|
||||
var propExp = Expression.Property(target, propertyName);
|
||||
var propertyValue = Expression.Parameter(typeof(object));
|
||||
var castPropertyValue = Expression.Convert(propertyValue, property!.PropertyType);
|
||||
var assignExp = Expression.Assign(propExp, castPropertyValue);
|
||||
|
||||
return Expression.Lambda<Action<T, object>>(assignExp, new[] { target,propertyValue }).Compile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ public static class TreeHelper
|
||||
return resData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 私有成员
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成设备保养计划
|
||||
/// </summary>
|
||||
public class GenerateMaintainPlanTimeWorker : ISpareTimeWorker
|
||||
{
|
||||
private ISqlSugarRepository<EqpMaintainTemEquipH> _repository => App.GetService<ISqlSugarRepository<EqpMaintainTemEquipH>>();
|
||||
// public GenerateSpotInspectionPlanTimeWorker(ISqlSugarRepository<EqpMaintainTemEquipH> repository)
|
||||
// {
|
||||
// _repository = repository;
|
||||
// }
|
||||
|
||||
[SpareTime("0 0 0 * * ?", "生成设备保养计划", ExecuteType = SpareTimeExecuteTypes.Serial,StartNow = false)]
|
||||
public void GenerateSpotInspectionPlan(SpareTimer timer, long count)
|
||||
{
|
||||
Log.Information("----------------------开始生成设备保养计划----------------------");
|
||||
|
||||
try
|
||||
{
|
||||
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByOne = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "1");
|
||||
List<EqpMaintainTemEquipH> eqpSpotInsTemEquipHsByCirculate = _repository.GetList(x => x.is_start=="1" && x.plan_cycle_unit == "2");
|
||||
List<EqpMaintainRecordH> tobeCreateList = new List<EqpMaintainRecordH>();
|
||||
List<EqpMaintainTemEquipH> tobeCreateTemplets = new List<EqpMaintainTemEquipH>();
|
||||
var db = _repository.AsSugarClient();
|
||||
|
||||
foreach (var item in eqpSpotInsTemEquipHsByOne)
|
||||
{
|
||||
if (item.start_time.AddDays((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<EqpEquipment> equipments = db.Queryable<EqpEquipment>().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<string> templetIDs = tobeCreateList.Select(x => x.maintain_tem_equip_id).ToList();
|
||||
List<EqpMaintainTemEquipD> spotInsTemEquipDs = db.Queryable<EqpMaintainTemEquipD>().Where(x => templetIDs.Contains(x.maintain_tem_equip_id)).ToList();
|
||||
List<string> spotInsItemIDs = spotInsTemEquipDs.Select(x => x.maintain_item_id).ToList();
|
||||
List<EqpMaintainItem> spotCheckItems = db.Queryable<EqpMaintainItem>().Where(x => spotInsItemIDs.Contains(x.id)).ToList();
|
||||
|
||||
|
||||
foreach (var tobeCreatePlan in tobeCreateList)
|
||||
{
|
||||
List<EqpMaintainRecordD> spotInsRecordDs = new List<EqpMaintainRecordD>();
|
||||
List<string> spotInsItems = spotInsTemEquipDs
|
||||
.Where(x => x.maintain_tem_equip_id == tobeCreatePlan.maintain_tem_equip_id)
|
||||
.Select(x => x.maintain_item_id).ToList();
|
||||
List<EqpMaintainItem> 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<EqpMaintainRecordH>(tobeCreateList).ExecuteCommand();
|
||||
}
|
||||
|
||||
if (spotInsRecordDs != null && spotInsRecordDs.Count > 0)
|
||||
{
|
||||
db.Insertable<EqpMaintainRecordD>(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("----------------------结束生成设备保养计划----------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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("----------------------开始生成点巡检计划----------------------");
|
||||
|
||||
@@ -3288,7 +3288,11 @@ public class RunService : IRunService, ITransient
|
||||
default:
|
||||
{
|
||||
var itemValue = item.Value.ToString().Contains("[") ? item.Value.ToJsonString() : item.Value.ToString();
|
||||
|
||||
JArray jarr = null;
|
||||
if (itemValue!.Contains("["))
|
||||
{
|
||||
jarr = JArray.Parse(itemValue);
|
||||
}
|
||||
if (model.searchType == 1)
|
||||
{
|
||||
conModels.Add(new ConditionalCollections()
|
||||
@@ -3306,9 +3310,17 @@ public class RunService : IRunService, ITransient
|
||||
}
|
||||
else
|
||||
{
|
||||
conModels.Add(new ConditionalCollections()
|
||||
if (jarr?.Children() != null && jarr?.Children().ToList().Count > 1)
|
||||
{
|
||||
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
||||
var values = string.Join(",", jarr.ToList().Select(t => t.Value<string>()));
|
||||
conModels.Add(new ConditionalModel { FieldName = item.Key, ConditionalType = ConditionalType.In, FieldValue = values });
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
conModels.Add(new ConditionalCollections()
|
||||
{
|
||||
ConditionalList = new List<KeyValuePair<WhereType, ConditionalModel>>()
|
||||
{
|
||||
new KeyValuePair<WhereType, ConditionalModel>(WhereType.And, new ConditionalModel
|
||||
{
|
||||
@@ -3317,7 +3329,8 @@ public class RunService : IRunService, ITransient
|
||||
FieldValue = itemValue
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -723,9 +723,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;
|
||||
moduleModel.FullName = oldWebModule!=null ? oldWebModule.FullName : entity.FullName; //modifyby zhoukeda 发布功能不更新名称排序图标
|
||||
moduleModel.EnCode = entity.EnCode;
|
||||
moduleModel.Icon = "icon-ym icon-ym-webForm";
|
||||
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;
|
||||
@@ -733,7 +733,7 @@ public class VisualDevService : IVisualDevService, IDynamicApiController, ITrans
|
||||
moduleModel.IsButtonAuthorize = 1;
|
||||
moduleModel.IsFormAuthorize = 1;
|
||||
moduleModel.IsDataAuthorize = 1;
|
||||
moduleModel.SortCode = 999;
|
||||
moduleModel.SortCode = oldWebModule != null ? oldWebModule.SortCode : 999; //modifyby zhoukeda 发布功能不更新名称排序图标
|
||||
moduleModel.CreatorTime = DateTime.Now;
|
||||
moduleModel.PropertyJson = (new { moduleId = input.id, iconBackgroundColor = string.Empty, isTree = 0 }).ToJsonString();
|
||||
moduleModel.SystemId = oldWebModule != null ? oldWebModule.SystemId : input.pcSystemId;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user