生产管理模块代码调整
This commit is contained in:
@@ -26,14 +26,14 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 模具Id
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
/// <summary>
|
||||
/// 设备Id
|
||||
/// </summary>
|
||||
public string eqp_id { get; set; }
|
||||
//public string mold_id { get; set; }
|
||||
///// <summary>
|
||||
///// 设备Id
|
||||
///// </summary>
|
||||
//public string eqp_id { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务单数量
|
||||
/// </summary>
|
||||
public int scheduled_qty { get; set; }
|
||||
//public int scheduled_qty { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,12 +10,32 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 模具列表输出参数
|
||||
/// </summary>
|
||||
public class MoldListOutput : Molds
|
||||
public class MoldListOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品 名称
|
||||
/// 模具名称
|
||||
/// </summary>
|
||||
public string item_name { get; set; }
|
||||
public string mold_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 模具型号
|
||||
/// </summary>
|
||||
public string mold_type_code { get; set; }
|
||||
/// <summary>
|
||||
/// 型腔数
|
||||
/// </summary>
|
||||
public int? cavity_qty { get; set; }
|
||||
public string mold_id { get; set;}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DbModels;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 提报记录统计明细
|
||||
/// </summary>
|
||||
public class PrdMoTaskDefectOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:任务单号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_code { get; set; }
|
||||
public List<BatchItem> batchItems { get; set; }
|
||||
}
|
||||
|
||||
public class BatchItem
|
||||
{
|
||||
public string batch { get; set; }
|
||||
|
||||
public string create_time { get; set; }
|
||||
/// <summary>
|
||||
/// 报废数量
|
||||
/// </summary>
|
||||
public int scrap_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///次品分类数组
|
||||
/// </summary>
|
||||
public List<CategoryItem> categoryItems { get; set; }
|
||||
}
|
||||
|
||||
public class CategoryItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 次品分类名称
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
/// 次品分类数量
|
||||
/// </summary>
|
||||
public int qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 次品项数组
|
||||
/// </summary>
|
||||
public List<DefectItem> defectItems { get; set; }
|
||||
}
|
||||
|
||||
public class DefectItem
|
||||
{
|
||||
/// <summary>
|
||||
/// 次品分类名称
|
||||
/// </summary>
|
||||
public string name { get; set; }
|
||||
/// <summary>
|
||||
/// 次品分类数量
|
||||
/// </summary>
|
||||
public int qty { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string icmo_code { get; set; }
|
||||
public string mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// renwu di
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务量
|
||||
|
||||
@@ -26,5 +26,25 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
public int? prd_qty { get; set; }
|
||||
|
||||
public int? scrap_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编码
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编码
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料编码
|
||||
/// </summary>
|
||||
public string material_code { get; set; }
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
public string material_name { get; set; }
|
||||
/// <summary>
|
||||
/// 物料属性
|
||||
/// </summary>
|
||||
public string material_property { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,11 +17,11 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
public string id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单类型 1、注塑/挤出工单 2、组装/包装工单
|
||||
/// Desc:排产类型 1、注塑/挤出工单 2、组装/包装工单
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? mo_type { get; set; }
|
||||
public int? schedule_type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
@@ -37,27 +37,21 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date { get; set; }
|
||||
///// <summary>
|
||||
///// Desc:预计开始时间
|
||||
///// Default:
|
||||
///// Nullable:True
|
||||
///// </summary>
|
||||
//public DateTime? estimated_start_date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date { get; set; }
|
||||
///// <summary>
|
||||
///// Desc:预计结束时间
|
||||
///// Default:
|
||||
///// Nullable:True
|
||||
///// </summary>
|
||||
//public DateTime? estimated_end_date { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务单状态
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单Id
|
||||
@@ -66,48 +60,18 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// </summary>
|
||||
public string mo_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_id { get; set; }
|
||||
/// <summary>
|
||||
/// 模具编号
|
||||
/// </summary>
|
||||
public string mold_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_id { get; set; }
|
||||
/// <summary>
|
||||
/// 设备编号
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产线编号
|
||||
@@ -116,62 +80,20 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// </summary>
|
||||
public string line_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产线名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string line_name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品Id
|
||||
/// Desc:物料Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产品编号
|
||||
/// </summary>
|
||||
public string item_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_name { get; set; }
|
||||
/// <summary>
|
||||
/// 产品规格型号
|
||||
/// </summary>
|
||||
public string item_standard { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
public string material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产车间
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string workshop { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模穴数
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? mold_cavity_qty { get; set; }
|
||||
public string workshop_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划生产数量
|
||||
@@ -180,24 +102,10 @@ namespace Tnb.ProductionMgr.Entities.Dto
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:吨位
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? tonnage { get; set; }
|
||||
/// <summary>
|
||||
/// 已排产数量
|
||||
/// </summary>
|
||||
public int scheduled_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 设备型号
|
||||
/// </summary>
|
||||
public string eqp_type_code { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string icmo_code { get; set; }
|
||||
//public string mo_task_code { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务单Id
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:报废数量
|
||||
/// Default:
|
||||
@@ -39,14 +43,35 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
|
||||
public class SelfTestScrappedInputItem
|
||||
{
|
||||
public string defective_category { get; set; }
|
||||
/// <summary>
|
||||
/// 次品分类Id
|
||||
/// </summary>
|
||||
public string category_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:分类数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? category_qty { get; set; }
|
||||
public List<SelfTestScrappedItem> items { get; set; }
|
||||
//public int? category_qty { get; set; }
|
||||
public List<defectItem> items { get; set; }
|
||||
}
|
||||
|
||||
public class defectItem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Desc:次品项
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string defective_item { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:次品项数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int defective_item_qty { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DbModels;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Dto.PrdManage
|
||||
{
|
||||
/// <summary>
|
||||
/// 提报记录统计明细
|
||||
/// </summary>
|
||||
public class SelfTestScrappedOutput
|
||||
{
|
||||
/// <summary>
|
||||
/// Desc:任务单号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string icmo_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:报废数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int scrap_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 自检报废集合
|
||||
/// </summary>
|
||||
public List<SelfTestScrappedOutputItem> categoryItems { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class SelfTestScrappedOutputItem
|
||||
{
|
||||
public string defective_category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:分类数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? category_qty { get; set; }
|
||||
public List<PrdScrappedDefectiveItem> items { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -120,11 +120,7 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_id { get; set; }
|
||||
/// <summary>
|
||||
/// 产品code
|
||||
/// </summary>
|
||||
public string item_code { get; set; }
|
||||
public string material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备Id
|
||||
|
||||
@@ -11,323 +11,297 @@ namespace Tnb.ProductionMgr.Entities
|
||||
[SugarTable("prd_mo")]
|
||||
public partial class PrdMo
|
||||
{
|
||||
public PrdMo()
|
||||
{
|
||||
public PrdMo(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:Id
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string id { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true)]
|
||||
public string id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mo_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:工单代码
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mo_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// 产品ID
|
||||
/// </summary>
|
||||
public string item_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mo_type {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mo_status {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产数量
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public decimal plan_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品代码, BAS_MATERIA.MATERIALCODE BAS_ITEM.ITEMCODE
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string item_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:已投入数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? input_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单类型:1-正常工单、2-返工工单、3-试制工单
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mo_type { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:已完工数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? complete_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string mo_status { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:报废数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? scrap_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产数量
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public decimal plan_qty { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public DateTime plan_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已投入数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int input_qty { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:计划结束时间
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public DateTime plan_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已完工数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? complete_qty { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:实际开工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:报废数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? scrap_qty { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:实际完工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public DateTime plan_start_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:订单行号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? order_seq {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划结束时间
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public DateTime plan_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:关联比例
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? relation_ratio {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际开工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_start_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:下发日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? mo_down_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际完工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:物料编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
public string material_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:订单行号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? order_seq { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:排程开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? seduling_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:关联比例
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? relation_ratio { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:排程结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? seduling_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:下发日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? mo_down_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:是否生派工单
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? is_create_dispatch {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:排程开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? seduling_start_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:子工单序号(1开始,最大+1,不强制连续)
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? seq {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:排程结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? seduling_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:是否合并
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? is_merge {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:是否生派工单
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? is_create_dispatch { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:子工单序号(1开始,最大+1,不强制连续)
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? seq { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:租户ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string tenant_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:ismerge
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? is_merge { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:所属组织
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string org_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:生产部门ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string dept_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:客户代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string customer_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:订单号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string order_no {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:所属组织ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string org_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:BOM版本
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string bom_version {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品附属信息
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_attribute { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:下发人员ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_down_user_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产部门ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string dept_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:下发人员名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_down_user_name {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:客户代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string customer_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string remark {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:订单号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string order_no { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:工作中心代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string work_center_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:BOM版本
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string bom_version { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:主工单代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string parent_mo_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:下发人员ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_down_user_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:数据来源 10-计划,20-插入,30-导入
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string data_sources {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:下发人员名称
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_down_user_name { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:产线代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string production_linecode {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string remark { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:组合工单
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string combine_mo_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工作中心代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string work_center_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:时间戳
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string time_stamp {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:主工单代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string parent_mo_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:数据来源 10-计划,20-插入,30-导入
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string data_sources { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产线代码
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string production_linecode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:组合工单
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string combine_mo_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:时间戳
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string time_stamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改用户
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单组号
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_no { get; set; }
|
||||
/// <summary>
|
||||
/// 生产任务状态
|
||||
/// </summary>
|
||||
public string icmo_status { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:物料ID
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_id {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
203
ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
Normal file
203
ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs
Normal file
@@ -0,0 +1,203 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DbModels
|
||||
{
|
||||
///<summary>
|
||||
///生产任务信息
|
||||
///</summary>
|
||||
[SugarTable("prd_mo_task")]
|
||||
public partial class PrdMoTask
|
||||
{
|
||||
public PrdMoTask(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:排产类型:1、注塑、挤出2、组装、包装
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? schedule_type {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际开工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:实际完工日期
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? act_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建人
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改人
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string modify_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:修改时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? modify_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:扩展字段
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string extras {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true)]
|
||||
public string id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务编号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工单Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_id {get;set;}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产线id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string workline_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工位id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string workstation_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:工艺路线id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string workroute_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产bom id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string bom_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:任务单状态
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_status {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int plan_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已投入数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int input_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已完工数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? complete_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:报废数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int scrap_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已排产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int scheduled_qty {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities
|
||||
{
|
||||
///<summary>
|
||||
///TODO
|
||||
///</summary>
|
||||
[SugarTable("prd_mo_task_defect")]
|
||||
public partial class PrdMoTaskDefect
|
||||
{
|
||||
public PrdMoTaskDefect()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:次品分类id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string defective_cagetory_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:次品项
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string defective_item { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:次品项数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int defective_item_qty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建用户
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Desc:任务单id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_id { get; set; }
|
||||
/// <summary>
|
||||
/// 批次
|
||||
/// </summary>
|
||||
public string batch { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities
|
||||
{
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarTable("prd_mo_task_defect_record")]
|
||||
public partial class PrdMoTaskDefectRecord
|
||||
{
|
||||
public PrdMoTaskDefectRecord(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:主键
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true)]
|
||||
public string id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:模具名称
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mold_name {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:预计结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? estimated_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划生产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? plan_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务单状态
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string status {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建人Id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string create_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:创建时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? create_time {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:报废数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? scrap_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料名称
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_name {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:任务单Id
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:物料编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string material_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:任务单编号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_code {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ namespace Tnb.ProductionMgr.Entities
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:主键
|
||||
/// Desc:编号
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
@@ -51,6 +51,13 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// </summary>
|
||||
public string extras {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:备注
|
||||
/// Default:NULL::character varying
|
||||
@@ -72,19 +79,12 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// </summary>
|
||||
public string modify_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务Id
|
||||
/// Default:NULL::character varying
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string icmo_id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int prd_qty {get;set;}
|
||||
public int? prd_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:已报工数量
|
||||
@@ -98,14 +98,14 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
//public int? reported_qty {get;set;}
|
||||
public int? reported_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string icmo_code {get;set;}
|
||||
public string mo_task_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:生产任务量
|
||||
|
||||
@@ -11,71 +11,73 @@ namespace Tnb.ProductionMgr.Entities
|
||||
[SugarTable("prd_report_record")]
|
||||
public partial class PrdReportRecord
|
||||
{
|
||||
public PrdReportRecord()
|
||||
{
|
||||
public PrdReportRecord(){
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:主键
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string id { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:主键
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey=true)]
|
||||
public string id {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:设备编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:产品名称
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string item_name { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:产品编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string masterial_code {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:设备编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string eqp_code { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:产品名称
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string masterial_name {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:计划生产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? plan_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:完成数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? completed_qty {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:计划生产数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? plan_qty { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:计划开始时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_start_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:完成数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? completed_qty { get; set; }
|
||||
/// <summary>
|
||||
/// 任务单号
|
||||
/// </summary>
|
||||
public string icmo_code { get; }
|
||||
/// <summary>
|
||||
/// Desc:计划结束时间
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public DateTime? plan_end_date {get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Desc:任务单号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string mo_task_code {get;set;}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Tnb.ProductionMgr.Entities
|
||||
/// <summary>
|
||||
/// 任务单号
|
||||
/// </summary>
|
||||
public string icmo_code { get; }
|
||||
public string icmo_code { 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 IPrdMoTaskService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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 IPrdTaskManageService
|
||||
{
|
||||
}
|
||||
}
|
||||
15
ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs
Normal file
15
ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs
Normal file
@@ -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 IPrdMoTaskIssueService
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,9 @@ using JNPF.FriendlyException;
|
||||
using JNPF.Logging;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
@@ -41,11 +43,13 @@ namespace Tnb.ProductionMgr
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class PrdMoService : IOverideVisualDevService, IPrdMoService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "25567924238373";
|
||||
private const string ModuleId = "25018860321301";
|
||||
private readonly ISqlSugarRepository<PrdMo> _repository;
|
||||
private readonly IDataBaseManager _dataBaseManager;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
|
||||
@@ -53,186 +57,52 @@ namespace Tnb.ProductionMgr
|
||||
ISqlSugarRepository<PrdMo> repository,
|
||||
IDataBaseManager dataBaseManager,
|
||||
IUserManager userManager,
|
||||
IDictionaryDataService dictionaryDataService
|
||||
IDictionaryDataService dictionaryDataService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_dataBaseManager = dataBaseManager;
|
||||
_userManager = userManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
OverideFuncs.DeleteAsync = Delete;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
var pkName = "material_id_id";
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
if (material != null)
|
||||
{
|
||||
row.Add("material_name", material.name);
|
||||
row.Add($"material_attribute", material.attribute);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
|
||||
#region Get
|
||||
|
||||
/// <summary>
|
||||
/// 根据产品ID获取模具列表
|
||||
/// </summary>
|
||||
/// <param name="itemId">产品ID</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// <br/>return results:
|
||||
/// <br/>[
|
||||
/// <br/> {
|
||||
/// <br/> mold_code:模具编号
|
||||
/// <br/> mold_name:模具名称
|
||||
/// <br/> item_name:产品名称
|
||||
/// <br/> item_code:产品编号
|
||||
/// <br/> cavity_qty:模穴数
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
[HttpGet("{itemId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string itemId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<Molds>().InnerJoin<BasMaterial>((a, b) => a.item_id == b.id)
|
||||
.Where((a, b) => a.item_id == itemId)
|
||||
.Select((a, b) => new MoldListOutput
|
||||
{
|
||||
mold_id = a.id,
|
||||
mold_code = a.mold_code,
|
||||
mold_name = a.mold_name,
|
||||
item_name = b.name,
|
||||
cavity_qty = a.cavity_qty,
|
||||
item_code = b.code,
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据模具Id获取设备列表
|
||||
/// </summary>
|
||||
/// <param name="moldId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{moldId}")]
|
||||
public async Task<dynamic> GetEquipmentListByMoldId(string moldId)
|
||||
{
|
||||
var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
|
||||
.Where(it => it.mold_id == moldId)
|
||||
.Select(it => new EquipmentListOutput
|
||||
{
|
||||
eqp_id = it.id,
|
||||
eqp_code = it.eqp_code,
|
||||
eqp_type_code = it.eqp_type_code,
|
||||
eqp_machine_num = it.eqp_machine_num,
|
||||
tonnage = it.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).Count(),
|
||||
estimated_end_date = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).OrderByDesc(o => o.estimated_end_date).Select(x => x.estimated_end_date)
|
||||
})
|
||||
.Mapper(x =>
|
||||
{
|
||||
x.first_date = x.estimated_end_date.HasValue ? x.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
})
|
||||
.ToListAsync();
|
||||
return items;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单调整-生产任务重新排序
|
||||
/// </summary>
|
||||
/// <param name="eqpId">设备ID</param>
|
||||
/// <returns>排序后生产任务列表</returns>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>[
|
||||
/// <br/> {
|
||||
/// <br/> no:生产序号
|
||||
/// <br/> mo_id:工单编号
|
||||
/// <br/> group_flag:同组标识
|
||||
/// <br/> plan_qty:计划生产数量
|
||||
/// <br/> comple_qty:完成数量
|
||||
/// <br/> item_name:产品名称
|
||||
/// <br/> mold_code:模具编号
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
[HttpGet("{eqpId}")]
|
||||
public async Task<dynamic> PrdTaskSort(string eqpId)
|
||||
{
|
||||
var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTask>()
|
||||
.Where(it => it.eqp_id == eqpId)
|
||||
.OrderBy(o => o.estimated_start_date)
|
||||
.ToListAsync();
|
||||
var data = list.Select((x, idx) => new PrdTaskSortOutput
|
||||
{
|
||||
no = idx + 1,
|
||||
mo_id = x.mo_id,
|
||||
status = taskStatusDic.ContainsKey(x.status) ? taskStatusDic[x.status].ToString() : "",
|
||||
group_flag = x.group_flag,
|
||||
plan_qty = x.plan_qty,
|
||||
comple_qty = x.comple_qty,
|
||||
item_name = x.item_name,
|
||||
mold_code = x.mold_code,
|
||||
})
|
||||
.ToList();
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 查看生产任务操作记录
|
||||
/// </summary>
|
||||
/// <param name="taskId">任务ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{taskId}")]
|
||||
public async Task<dynamic> GetMoOperRecord(string taskId)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTaskLog>().Where(it => it.id == taskId).ToListAsync();
|
||||
var data = list.Adapt<List<PrdTaskOperOutput>>();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
_repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : "");
|
||||
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("{icmoCode}")]
|
||||
public async Task<dynamic> GetPrdReportByIcmoCode(string icmoCode)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var res = await db.Queryable<PrdReport>().Where(it => it.icmo_code == icmoCode).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<PrdScrapped>().Select(x => x.scrap_qty),
|
||||
})
|
||||
.Mapper(it =>
|
||||
{
|
||||
it.icmo_qty = it.icmo_qty ?? (db.Queryable<PrdTask>().First(it => it.icmo_code == icmoCode)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable<PrdTask>().First(it => it.icmo_code == icmoCode).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<PrdTask>().First(it => it.icmo_code == icmoCode)?.scheduled_qty,
|
||||
reported_work_qty = 0,
|
||||
//reported_qty = 0,
|
||||
prd_qty = 0,
|
||||
scrap_qty = 0,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取提报生产记录
|
||||
/// 获取自建报废记录
|
||||
/// </summary>
|
||||
/// <param name="icmoCode"></param>
|
||||
/// <returns></returns>
|
||||
@@ -240,20 +110,19 @@ namespace Tnb.ProductionMgr
|
||||
public async Task<dynamic> GetReportRecord(string icmoCode)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var output = new SelfTestScrappedOutput();
|
||||
output.icmo_code = icmoCode;
|
||||
var scrap = (await db.Queryable<PrdScrapped>().FirstAsync(it => it.icmo_code == icmoCode));
|
||||
output.scrap_qty = scrap != null ? scrap.scrap_qty : 0;
|
||||
output.categoryItems = new List<SelfTestScrappedOutputItem>();
|
||||
var categorys = await db.Queryable<PrdScrappedDefectiveCagetory>().Where(it => it.icmo_code == icmoCode).ToListAsync();
|
||||
foreach (var category in categorys)
|
||||
{
|
||||
var categoryItem = category.Adapt<SelfTestScrappedOutputItem>();
|
||||
categoryItem.items = new List<PrdScrappedDefectiveItem>();
|
||||
var items = await db.Queryable<PrdScrappedDefectiveItem>().Where(it => it.defective_cagetory_id == category.id).ToListAsync();
|
||||
categoryItem.items.AddRange(items);
|
||||
output.categoryItems.Add(categoryItem);
|
||||
}
|
||||
var output = new PrdMoTaskDefectOutput();
|
||||
//output.mo_task_code = icmoCode;
|
||||
//var scrap = (await db.Queryable<PrdScrapped>().FirstAsync(it => it.icmo_code == icmoCode));
|
||||
//output.items = new List<CategoryItem>();
|
||||
//var categorys = await db.Queryable<PrdScrappedDefectiveCagetory>().Where(it => it.icmo_code == icmoCode).ToListAsync();
|
||||
//foreach (var category in categorys)
|
||||
//{
|
||||
// var categoryItem = category.Adapt<SelfTestScrappedOutputItem>();
|
||||
// categoryItem.items = new List<PrdScrappedDefectiveItem>();
|
||||
// var items = await db.Queryable<PrdScrappedDefectiveItem>().Where(it => it.defective_cagetory_id == category.id).ToListAsync();
|
||||
// categoryItem.items.AddRange(items);
|
||||
// output.categoryItems.Add(categoryItem);
|
||||
//}
|
||||
return output;
|
||||
}
|
||||
|
||||
@@ -287,28 +156,26 @@ namespace Tnb.ProductionMgr
|
||||
input.WorkOrderIds = input.WorkOrderIds.Concat(moIds).ToList();
|
||||
}
|
||||
|
||||
|
||||
Tuple<string, string> getMoStatus(MoBehavior behavior)
|
||||
string getMoStatus(MoBehavior behavior)
|
||||
{
|
||||
Tuple<string, string> multi = null;
|
||||
string status = "";
|
||||
switch (behavior)
|
||||
{
|
||||
case MoBehavior.Release:
|
||||
multi = Tuple.Create(DictConst.IssueId, DictConst.ToBeScheduledEncode);
|
||||
status = DictConst.IssueId;
|
||||
break;
|
||||
case MoBehavior.Closed:
|
||||
multi = Tuple.Create(DictConst.MoCloseId, DictConst.ClosedEnCode);
|
||||
status = DictConst.MoCloseId;
|
||||
break;
|
||||
}
|
||||
return multi!;
|
||||
return status!;
|
||||
}
|
||||
var behavior = input.Behavior.ToEnum<MoBehavior>();
|
||||
var multi = getMoStatus(behavior);
|
||||
|
||||
var status = getMoStatus(behavior);
|
||||
var row = await db.Updateable<PrdMo>()
|
||||
.SetColumns(it => new PrdMo { mo_status = multi.Item1, icmo_status = multi.Item2 })
|
||||
.Where(it => input.WorkOrderIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
.SetColumns(it => new PrdMo { mo_status = status })
|
||||
.Where(it => input.WorkOrderIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
}
|
||||
/// <summary>
|
||||
@@ -321,7 +188,7 @@ namespace Tnb.ProductionMgr
|
||||
{
|
||||
(bool executeRes, string errMsg) multi = (true, "");
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdMo>()
|
||||
.InnerJoin<Molds>((a, b) => a.item_code == b.item_id)
|
||||
.InnerJoin<Molds>((a, b) => a.material_id == b.material_id)
|
||||
.Where((a, b) => input.WorkOrderIds.Contains(a.id))
|
||||
.Select((a, b) => new
|
||||
{
|
||||
@@ -375,494 +242,7 @@ namespace Tnb.ProductionMgr
|
||||
.ExecuteCommandHasChangeAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产工单-生产排产
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
///<br/>{
|
||||
///<br/> Id:生产任务主键Id
|
||||
///<br/> MoType:工单类型 1、注塑/挤出 2、组装/包装
|
||||
///<br/> MoId:工单Id
|
||||
///<br/> ItemId:产品编号
|
||||
///<br/> ItemName:产品名称
|
||||
///<br/> MoldId:模具Id
|
||||
///<br/> MoldName:模具名称
|
||||
///<br/> EqpId:设备Id
|
||||
///<br/> EqpName:设备名称
|
||||
///<br/> LineId:产线编号
|
||||
///<br/> LineName:产线名称
|
||||
///<br/>}
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ProductionScheduling(ProductionSchedulingCrInput input)
|
||||
{
|
||||
var row = -1;
|
||||
if (input.mo_type.HasValue && input.mo_type.Value == 1)
|
||||
{
|
||||
input.id ??= SnowflakeIdHelper.NextId();
|
||||
var entity = input.Adapt<PrdTask>();
|
||||
entity.status = DictConst.ToBeStartedEnCode; //任务单状态默认,待排产
|
||||
entity.create_id = _userManager.UserId;
|
||||
entity.create_time = DateTime.Now;
|
||||
entity.prd_task_id = input.id;
|
||||
|
||||
var db = _repository.AsSugarClient();
|
||||
try
|
||||
{
|
||||
List<PrdMo> entities = new();
|
||||
List<PrdTask> icmoEntities = new();
|
||||
//根据工单Id查询同组工单号,进行同组工单排产处理
|
||||
var combineMoCodes = await db.Queryable<PrdMo>().Where(it => it.id == input.mo_id).Select(it => it.combine_mo_code).Distinct().ToListAsync();
|
||||
if (combineMoCodes?.Count > 0)
|
||||
{
|
||||
entities = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
||||
}
|
||||
|
||||
await db.Ado.BeginTranAsync();
|
||||
//同组工单排产
|
||||
if (entities.Count > 0)
|
||||
{
|
||||
icmoEntities = entities.Select(x => new PrdTask
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId(),
|
||||
item_id = x.id,
|
||||
item_code = x.item_code,
|
||||
mo_type = input.mo_type,
|
||||
plan_start_date = x.plan_start_date,
|
||||
plan_end_date = x.plan_end_date,
|
||||
}).ToList();
|
||||
icmoEntities.ForEach(x =>
|
||||
{
|
||||
x.status = DictConst.ToBeStartedEnCode; //任务单状态默认,待排产
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.prd_task_id = x.id;
|
||||
});
|
||||
row = await db.Insertable(icmoEntities).ExecuteCommandAsync();
|
||||
var icmoRecords = icmoEntities.Adapt<List<PrdTaskLog>>();
|
||||
icmoRecords.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.status ??= DictConst.ToBeStartedEnCode;
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.operator_name = _userManager.RealName;
|
||||
});
|
||||
var icmoIds = icmoRecords.Select(it => it.task_id).Distinct().ToList();
|
||||
var statusMany = icmoRecords.Select(it => it.status).Distinct().ToList();
|
||||
//任务状态变更时插入操作记录
|
||||
var logEntities = await db.Queryable<PrdTaskLog>().Where(it => icmoIds.Contains(it.task_id)).ToListAsync();
|
||||
if (logEntities?.Count > 0)
|
||||
{
|
||||
var dbTaskStatusList = logEntities.Select(x => x.status).Distinct().ToList();
|
||||
var ultimatelyStatus = statusMany.Except(dbTaskStatusList).ToList();
|
||||
icmoRecords = icmoRecords.Where(x => ultimatelyStatus.Contains(x.status)).ToList();
|
||||
}
|
||||
if (icmoRecords.Count > 0)
|
||||
{
|
||||
row = await db.Insertable(icmoRecords).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!input.mo_code.IsNullOrEmpty())
|
||||
{
|
||||
var icmoCode = await db.Queryable<PrdTask>().Where(it => !string.IsNullOrEmpty(it.icmo_code) && it.icmo_code.Contains(input.mo_code)).OrderByDescending(it => it.icmo_code).Select(it => it.icmo_code).FirstAsync();
|
||||
if (icmoCode.IsNullOrEmpty())
|
||||
{
|
||||
entity.icmo_code = $"{input.mo_code}-01";
|
||||
}
|
||||
else
|
||||
{
|
||||
var pos = icmoCode.IndexOf("-", StringComparison.Ordinal);
|
||||
if (pos > -1)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var num = icmoCode.AsSpan().Slice(pos + 1).ToString().ParseToInt();
|
||||
var code = icmoCode.AsSpan().Slice(pos + 1).ToString();
|
||||
var n = (num + 1).ToString().PadLeft(2, '0');
|
||||
entity.icmo_code = sb.Append(code).Append(n).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
row = await db.Storageable(entity).ExecuteCommandAsync();
|
||||
var taskLogEntity = input.Adapt<PrdTaskLog>();
|
||||
taskLogEntity.id ??= SnowflakeIdHelper.NextId();
|
||||
taskLogEntity.task_id = input.id;
|
||||
taskLogEntity.status ??= "ToBeStarted";
|
||||
taskLogEntity.create_id = _userManager.UserId;
|
||||
taskLogEntity.create_time = DateTime.Now;
|
||||
taskLogEntity.operator_name = _userManager.RealName;
|
||||
|
||||
//任务状态变更时插入操作记录
|
||||
if (!db.Queryable<PrdTaskLog>().Where(it => it.task_id == input.id && it.status == taskLogEntity.status).Any())
|
||||
{
|
||||
row = await db.Insertable(taskLogEntity).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
if (row > 0)
|
||||
{
|
||||
if (icmoEntities?.Count > 0 && combineMoCodes?.FirstOrDefault() is not null)
|
||||
{
|
||||
var moList = await db.Queryable<PrdMo>().Where(it => combineMoCodes.Contains(it.combine_mo_code)).ToListAsync();
|
||||
var combinePlanQty = icmoEntities?.Sum(x => x.plan_qty); //合并工单后的计划数量
|
||||
var combineScheduledQty = icmoEntities?.Sum(x => x.scheduled_qty); //合并后的已排产数量
|
||||
if (combineScheduledQty < combinePlanQty)
|
||||
{
|
||||
icmoEntities!.ForEach(x =>
|
||||
{
|
||||
var item = moList.Find(xx => xx.id == x.mo_id);
|
||||
if (item != null)
|
||||
{
|
||||
item.input_qty += x.scheduled_qty;
|
||||
item.mo_status = DictConst.WaitProductId;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
//如果已排产数量大于计划数量,修改工单状态为,待开工
|
||||
if (combineScheduledQty >= combinePlanQty)
|
||||
{
|
||||
icmoEntities!.ForEach(x =>
|
||||
{
|
||||
var item = moList.Find(xx => xx.id == x.mo_id);
|
||||
if (item != null)
|
||||
{
|
||||
item.input_qty += x.scheduled_qty;
|
||||
item.mo_status = DictConst.AlreadyId;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
row = await db.Updateable(moList).ExecuteCommandAsync();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
var obj = (await db.Queryable<PrdMo>().FirstAsync(it => it.id == input.mo_id));
|
||||
obj.input_qty += entity.scheduled_qty;
|
||||
string moStatus = "", icmoStatus = "";
|
||||
|
||||
//判断,已排产数量>=计划数量时将状态改为 已排产
|
||||
if (obj.input_qty >= obj.plan_qty)
|
||||
{
|
||||
moStatus = DictConst.AlreadyId;
|
||||
icmoStatus = DictConst.ToBeStartedEnCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
//修改工单状态为待排产,同事修改已排产数量
|
||||
moStatus = DictConst.WaitProductId;
|
||||
icmoStatus = DictConst.ToBeScheduledEncode;
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo
|
||||
{
|
||||
mo_status = moStatus,
|
||||
icmo_status = icmoStatus,
|
||||
input_qty = obj.input_qty
|
||||
})
|
||||
.Where(it => it.id == entity.mo_id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
JNPF.Logging.Log.Error("生产任务发布时发生错误", ex);
|
||||
await db.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生产任务下发,开始 、结束、完成
|
||||
/// </summary>
|
||||
/// <param name="input">输入参数</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdTaskRelease(PrdTaskReleaseUpInput input)
|
||||
{
|
||||
var row = -1;
|
||||
if (input is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
if (input.TaskIds is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input.TaskIds));
|
||||
}
|
||||
if (input.Behavior.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
|
||||
}
|
||||
string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
|
||||
{
|
||||
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();
|
||||
if (behavior == PrdTaskBehavior.Compled)
|
||||
{
|
||||
var list = await db.Queryable<PrdTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
var schedQtySum = list.Sum(x => x.scheduled_qty);
|
||||
var planQtySum = list.Sum(x => x.plan_qty);
|
||||
if (schedQtySum < planQtySum)
|
||||
{
|
||||
throw new AppFriendlyException("任务数量必须大于等于生产计划数量,才可完成", 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
row = await db.Updateable<PrdTask>()
|
||||
.SetColumns(it => new PrdTask { status = status })
|
||||
.Where(it => input.TaskIds.Contains(it.id))
|
||||
.ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产任务单修改
|
||||
/// </summary>
|
||||
/// <param name="input">生产任务单修改输入参数</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> IcmoModify(IcmoUpInput input)
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
if (input.icmo_id.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullException(nameof(input.icmo_id));
|
||||
var icmoItem = await db.Queryable<PrdTask>().FirstAsync(it => it.id == input.icmo_id);
|
||||
switch (input.category)
|
||||
{
|
||||
case 1: //设备
|
||||
var eqpItem = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == input.eqp_id);
|
||||
icmoItem.eqp_id = eqpItem.id;
|
||||
icmoItem.eqp_type_code = eqpItem.eqp_type_code;
|
||||
if (input.scheduled_qty > icmoItem.plan_qty)
|
||||
{
|
||||
throw new AppFriendlyException("任务单数量不能大于计划数量", 500);
|
||||
}
|
||||
row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo { input_qty = input.scheduled_qty }).Where(it => it.id == input.mo_id).ExecuteCommandAsync();
|
||||
break;
|
||||
case 2: //模具
|
||||
var moldItem = await db.Queryable<Molds>().FirstAsync(it => it.id == input.mold_id);
|
||||
icmoItem.mold_id = moldItem.id;
|
||||
icmoItem.mold_code = moldItem.mold_code;
|
||||
icmoItem.mold_name = moldItem.mold_name;
|
||||
icmoItem.mold_cavity_qty = moldItem.cavity_qty;
|
||||
break;
|
||||
}
|
||||
row = await db.Updateable(icmoItem).ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 生产提报
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <remarks>
|
||||
/// input:
|
||||
/// <br/>{
|
||||
/// <br/> icmo_id:生产任务ID
|
||||
/// <br/> icmo_code:任务单号
|
||||
/// <br/> prd_qty:生产数量
|
||||
/// <br/> reported_work_qty:已报工数量
|
||||
/// <br/> reported_qty:提报数量
|
||||
/// <br/> icmo_qty:生产任务量
|
||||
/// <br/>}
|
||||
/// </remarks>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdReport(PrdReportCrInput input)
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.icmo_code == input.icmo_code);
|
||||
if (report is not null)
|
||||
{
|
||||
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;
|
||||
}
|
||||
row = await db.Storageable(report).ExecuteCommandAsync();
|
||||
var prdTask = await db.Queryable<PrdTask>().FirstAsync(it => it.icmo_code == input.icmo_code);
|
||||
var record = prdTask.Adapt<PrdReportRecord>();
|
||||
if (prdTask != null)
|
||||
{
|
||||
record.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == prdTask.eqp_id))?.eqp_code;
|
||||
record.completed_qty = input.reported_qty;
|
||||
row = await db.Insertable(record).ExecuteCommandAsync();
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 自检报废提交
|
||||
/// </summary>
|
||||
/// <param name="input">自检报废输入参数</param>
|
||||
/// <returns>true/false</returns>
|
||||
/// <remarks>
|
||||
/// input:
|
||||
///<br/>{
|
||||
///<br/> "icmo_code": 任务单号,
|
||||
///<br/> "scrap_qty": 报废数量,
|
||||
///<br/> "remark": 备注,
|
||||
///<br/> "categoryItems": [
|
||||
///<br/> {
|
||||
///<br/> "defective_category":次品分类,
|
||||
///<br/> "category_qty": 分类数量,
|
||||
///<br/> "items": [
|
||||
///<br/> {
|
||||
///<br/> "defective_item": 次品项,
|
||||
///<br/> "defective_item_qty": 次品项数量
|
||||
///<br/> }
|
||||
///<br/> ]
|
||||
///<br/> }
|
||||
///<br/> ]
|
||||
///<br/>}
|
||||
/// </remarks>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SelfTestScrapped(SelfTestScrappedInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var prdScrapped = await db.Queryable<PrdScrapped>().FirstAsync(it => it.icmo_code == input.icmo_code);
|
||||
if (prdScrapped is null)
|
||||
{
|
||||
prdScrapped = input.Adapt<PrdScrapped>();
|
||||
prdScrapped.id = SnowflakeIdHelper.NextId();
|
||||
prdScrapped.create_id = _userManager.UserId;
|
||||
prdScrapped.create_time = DateTime.Now;
|
||||
}
|
||||
|
||||
var result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var categorys = new List<PrdScrappedDefectiveCagetory>();
|
||||
foreach (var categoryItem in input.categoryItems)
|
||||
{
|
||||
categorys = await db.Queryable<PrdScrappedDefectiveCagetory>().Where(it => it.icmo_code == input.icmo_code).ToListAsync();
|
||||
if (categorys?.Count > 0)
|
||||
{
|
||||
foreach (var category in categorys)
|
||||
{
|
||||
var defectiveItems = categoryItem.items?.Select(x => x.defective_item).ToList();
|
||||
var list = await db.Queryable<PrdScrappedDefectiveItem>().Where(it => defectiveItems!.Contains(it.defective_item)).ToListAsync();
|
||||
category.category_qty = list?.Sum(it => it.defective_item_qty) + categoryItem.items.Sum(x => x.defective_item_qty);
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
if (categoryItem.items?.Count > 0)
|
||||
{
|
||||
foreach (var x in categoryItem.items)
|
||||
{
|
||||
var item = list.Find(f => f.defective_item == x.defective_item);
|
||||
if (item != null)
|
||||
{
|
||||
item.defective_item_qty += x.defective_item_qty;
|
||||
}
|
||||
}
|
||||
await db.Updateable(list).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
await db.Updateable(categorys).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var category = categoryItem.Adapt<PrdScrappedDefectiveCagetory>();
|
||||
category.id = SnowflakeIdHelper.NextId();
|
||||
category.icmo_code = input.icmo_code;
|
||||
category.create_id = _userManager.UserId;
|
||||
category.create_time = DateTime.Now;
|
||||
category.category_qty = categoryItem.items?.Sum(x => x.defective_item_qty);
|
||||
categorys!.Add(category);
|
||||
var items = new List<PrdScrappedDefectiveItem>();
|
||||
if (categoryItem.items?.Count > 0)
|
||||
{
|
||||
foreach (var item in categoryItem.items)
|
||||
{
|
||||
var defectiveItem = item.Adapt<PrdScrappedDefectiveItem>();
|
||||
defectiveItem.id = SnowflakeIdHelper.NextId();
|
||||
defectiveItem.defective_cagetory_id = category.id;
|
||||
items.Add(defectiveItem);
|
||||
}
|
||||
await db.Insertable(items).ExecuteCommandAsync();
|
||||
}
|
||||
await db.Insertable(category).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
//var scrapQty = await db.Queryable<PrdScrappedDefectiveItem>().SumAsync(it => it.defective_item_qty);
|
||||
//prdScrapped.scrap_qty = scrapQty;
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.icmo_code == input.icmo_code);
|
||||
if (report != null)
|
||||
{
|
||||
report.prd_qty += input.scrap_qty;
|
||||
await db.Updateable<PrdReport>(report).ExecuteCommandAsync();
|
||||
}
|
||||
await db.Storageable(prdScrapped).ExecuteCommandAsync();
|
||||
var prdTask = await db.Queryable<PrdTask>().FirstAsync(it => it.icmo_code == input.icmo_code);
|
||||
var record = prdTask.Adapt<PrdSelfTestScrappedRecord>();
|
||||
if (prdTask != null)
|
||||
{
|
||||
record.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == prdTask.eqp_id))?.eqp_code;
|
||||
record.scrap_qty = input.scrap_qty;
|
||||
await db.Insertable(record).ExecuteCommandAsync();
|
||||
}
|
||||
});
|
||||
return result.IsSuccess;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
private async Task Delete(string id)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var row = -1;
|
||||
var prdTask = await db.Queryable<PrdTask>().FirstAsync(it => it.id == id);
|
||||
row = await db.Deleteable<PrdTask>().Where(it => it.id == id).ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
var prdMo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == prdTask.mo_id);
|
||||
if (prdMo is not null)
|
||||
{
|
||||
prdMo.input_qty += prdTask.scheduled_qty;
|
||||
prdMo.icmo_status = DictConst.ToBeScheduledEncode;
|
||||
row = await db.Updateable(prdMo).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
return row > 0;
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1002);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
96
ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
Normal file
96
ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using NPOI.Util;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class PrdMoTaskIssueService : IOverideVisualDevService, IPrdMoTaskIssueService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "25904314968613";
|
||||
private readonly ISqlSugarRepository<PrdTask> _repository;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
public PrdMoTaskIssueService(
|
||||
ISqlSugarRepository<PrdTask> repository,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
|
||||
}
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
var pkName = "material_id";
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
if (material != null)
|
||||
{
|
||||
row["material_id"] = $"{material.code}/{material.name}";
|
||||
row["materialid"] = material.id;
|
||||
}
|
||||
}
|
||||
//模具
|
||||
if (dic.ContainsKey("mold_id"))
|
||||
{
|
||||
var moldId = dic["mold_id"]?.ToString();
|
||||
var mold = await db.Queryable<Molds>().FirstAsync(it => it.id == moldId);
|
||||
if (mold != null)
|
||||
{
|
||||
row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
|
||||
row["moldid"] = mold.id;
|
||||
}
|
||||
}
|
||||
//设备
|
||||
if (dic.ContainsKey("eqp_id"))
|
||||
{
|
||||
var eqpId = dic["eqp_id"]?.ToString();
|
||||
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||
if (eqp != null)
|
||||
{
|
||||
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
||||
row["eqpid"] = eqp.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
}
|
||||
}
|
||||
687
ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
Normal file
687
ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs
Normal file
@@ -0,0 +1,687 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Aspose.Cells.Drawing;
|
||||
using DbModels;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.BasicData;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities.Dto.PrdManage;
|
||||
using Tnb.ProductionMgr.Entities.Dto;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
using Tnb.ProductionMgr.Entities.Enums;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using Aop.Api.Domain;
|
||||
using Senparc.Weixin.MP.AdvancedAPIs.Card;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
|
||||
public class PrdMoTaskService : IOverideVisualDevService, IPrdMoTaskService, IDynamicApiController, ITransient
|
||||
{
|
||||
private const string ModuleId = "25567924238373";
|
||||
private readonly ISqlSugarRepository<PrdTask> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private static Dictionary<string, object> _dicDefect = new Dictionary<string, object>();
|
||||
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public PrdMoTaskService(
|
||||
ISqlSugarRepository<PrdTask> repository,
|
||||
IUserManager userManager,
|
||||
IDictionaryDataService dictionaryDataService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.DeleteAsync = Delete;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#region Get
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据产品ID获取模具列表
|
||||
/// </summary>
|
||||
/// <param name="itemId">产品ID</param>
|
||||
/// <returns></returns>
|
||||
/// <remarks>
|
||||
/// <br/>return results:
|
||||
/// <br/>[
|
||||
/// <br/> {
|
||||
/// <br/> mold_code:模具编号
|
||||
/// <br/> mold_name:模具名称
|
||||
/// <br/> item_name:产品名称
|
||||
/// <br/> item_code:产品编号
|
||||
/// <br/> cavity_qty:模穴数
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
|
||||
|
||||
[HttpGet("{materialId}")]
|
||||
public async Task<dynamic> GetMoldListByItemId(string materialId)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var list = await db.Queryable<Molds>().InnerJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.Where((a, b) => a.material_id == materialId)
|
||||
.Select((a, b) => new MoldListOutput
|
||||
{
|
||||
mold_id = a.id,
|
||||
mold_code = a.mold_code,
|
||||
mold_name = a.mold_name,
|
||||
material_name = b.name,
|
||||
cavity_qty = a.cavity_qty,
|
||||
})
|
||||
.ToListAsync();
|
||||
return list;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据模具Id获取设备列表
|
||||
/// </summary>
|
||||
/// <param name="moldId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{moldId}")]
|
||||
public async Task<dynamic> GetEquipmentListByMoldId(string moldId)
|
||||
{
|
||||
var items = await _repository.AsSugarClient().Queryable<EqpEquipment>()
|
||||
.Where(it => it.mold_id == moldId)
|
||||
.Select(it => new EquipmentListOutput
|
||||
{
|
||||
eqp_id = it.id,
|
||||
eqp_code = it.code,
|
||||
eqp_type_code = SqlFunc.Subqueryable<EqpEquipType>().Where(iit => iit.id == it.equip_type_id).Select(iit => iit.code),
|
||||
eqp_machine_num = it.eqp_machine_num,
|
||||
tonnage = it.tonnage,
|
||||
task_list_qty = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).Count(),
|
||||
estimated_end_date = SqlFunc.Subqueryable<PrdTask>().Where(x => x.eqp_id == it.id).OrderByDesc(o => o.plan_end_date).Select(x => x.plan_end_date)
|
||||
})
|
||||
.Mapper(x =>
|
||||
{
|
||||
x.first_date = x.estimated_end_date.HasValue ? x.estimated_end_date.Value.ToString("yyyy-MM-dd HH:mm:ss") : "";
|
||||
})
|
||||
.ToListAsync();
|
||||
return items;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 工单调整-生产任务重新排序
|
||||
/// </summary>
|
||||
/// <param name="eqpId">设备ID</param>
|
||||
/// <returns>排序后生产任务列表</returns>
|
||||
/// <remarks>
|
||||
/// returns:
|
||||
/// <br/>[
|
||||
/// <br/> {
|
||||
/// <br/> no:生产序号
|
||||
/// <br/> mo_id:工单编号
|
||||
/// <br/> group_flag:同组标识
|
||||
/// <br/> plan_qty:计划生产数量
|
||||
/// <br/> comple_qty:完成数量
|
||||
/// <br/> item_name:产品名称
|
||||
/// <br/> mold_code:模具编号
|
||||
/// <br/> }
|
||||
/// <br/>]
|
||||
/// </remarks>
|
||||
[HttpGet("{eqpId}")]
|
||||
public async Task<dynamic> PrdTaskSort(string eqpId)
|
||||
{
|
||||
var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTask>()
|
||||
.Where(it => it.eqp_id == eqpId)
|
||||
.OrderBy(o => o.estimated_start_date)
|
||||
.ToListAsync();
|
||||
var data = list.Select((x, idx) => new PrdTaskSortOutput
|
||||
{
|
||||
no = idx + 1,
|
||||
mo_id = x.mo_id,
|
||||
status = taskStatusDic.ContainsKey(x.status) ? taskStatusDic[x.status].ToString() : "",
|
||||
group_flag = x.group_flag,
|
||||
plan_qty = x.plan_qty,
|
||||
comple_qty = x.comple_qty,
|
||||
item_name = x.item_name,
|
||||
mold_code = x.mold_code,
|
||||
})
|
||||
.ToList();
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 查看生产任务操作记录
|
||||
/// </summary>
|
||||
/// <param name="taskId">任务ID</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{taskId}")]
|
||||
public async Task<dynamic> GetMoOperRecord(string taskId)
|
||||
{
|
||||
var list = await _repository.AsSugarClient().Queryable<PrdTaskLog>().Where(it => it.id == taskId).ToListAsync();
|
||||
var data = list.Adapt<List<PrdTaskOperOutput>>();
|
||||
var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId);
|
||||
_repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : "");
|
||||
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<Molds>().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,
|
||||
//reported_qty = it.reported_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,
|
||||
//reported_qty = 0,
|
||||
prd_qty = 0,
|
||||
scrap_qty = 0,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取自检报废批次记录
|
||||
/// </summary>
|
||||
/// <param name="moTaskId">任务单Id</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("{moTaskId}")]
|
||||
public async Task<dynamic> GetScarpStatRecord(string moTaskId)
|
||||
{
|
||||
var output = new PrdMoTaskDefectOutput();
|
||||
var db = _repository.AsSugarClient();
|
||||
if (_dicDefect.Count < 1)
|
||||
{
|
||||
_dicDefect = await db.Queryable<BasDefectType>().ToDictionaryAsync(x => x.id, x => x.defect_type_name);
|
||||
}
|
||||
output.mo_task_code = (await db.Queryable<PrdMoTask>().FirstAsync(it => it.id == moTaskId))?.mo_task_code;
|
||||
var defects = await db.Queryable<PrdMoTaskDefect>().Where(it => it.mo_task_id == moTaskId).ToListAsync();
|
||||
if (defects?.Count > 0)
|
||||
{
|
||||
output.batchItems = defects.GroupBy(g => new { g.batch }).Select(t => new BatchItem
|
||||
{
|
||||
scrap_qty = t.Sum(d => d.defective_item_qty),
|
||||
batch = t.Key.batch,
|
||||
create_time =t.Key.batch.ParseToDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
|
||||
categoryItems = t.GroupBy(g => g.defective_cagetory_id).Select(c => new CategoryItem
|
||||
{
|
||||
name = _dicDefect[c.Key]?.ToString(),
|
||||
qty = c.Sum(d => d.defective_item_qty),
|
||||
defectItems = c.Select(d => new DefectItem
|
||||
{
|
||||
name = d.defective_item,
|
||||
qty = d.defective_item_qty,
|
||||
}).ToList(),
|
||||
}).ToList(),
|
||||
}).ToList();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region Post
|
||||
|
||||
/// <summary>
|
||||
/// 生产工单-生产排产
|
||||
/// </summary>
|
||||
/// <param name="input">
|
||||
///<br/>{
|
||||
///<br/> Id:生产任务主键Id
|
||||
///<br/> MoType:工单类型 1、注塑/挤出 2、组装/包装
|
||||
///<br/> MoId:工单Id
|
||||
///<br/> ItemId:产品编号
|
||||
///<br/> ItemName:产品名称
|
||||
///<br/> MoldId:模具Id
|
||||
///<br/> MoldName:模具名称
|
||||
///<br/> EqpId:设备Id
|
||||
///<br/> EqpName:设备名称
|
||||
///<br/> LineId:产线编号
|
||||
///<br/> LineName:产线名称
|
||||
///<br/>}
|
||||
/// </param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> ProductionScheduling(ProductionSchedulingCrInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var row = -1;
|
||||
if (input.schedule_type.HasValue && input.schedule_type.Value == 1)
|
||||
{
|
||||
var moTask = input.Adapt<PrdMoTask>();
|
||||
moTask.id = SnowflakeIdHelper.NextId();
|
||||
moTask.create_id = _userManager.UserId;
|
||||
moTask.create_time = DateTime.Now;
|
||||
moTask.mo_task_status = DictConst.ToBeScheduledEncode;
|
||||
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)).OrderByDescending(it => it.mo_task_code).Select(it => it.mo_task_code).FirstAsync();
|
||||
if (taskCode.IsNullOrEmpty())
|
||||
{
|
||||
moTask.mo_task_code = $"{moCode}-01";
|
||||
}
|
||||
else
|
||||
{
|
||||
var pos = taskCode.IndexOf("-", StringComparison.Ordinal);
|
||||
if (pos > -1)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var num = taskCode.AsSpan().Slice(pos + 1).ToString().ParseToInt();
|
||||
var code = taskCode.AsSpan().Slice(pos + 1).ToString();
|
||||
var n = (num + 1).ToString().PadLeft(2, '0');
|
||||
moTask.mo_task_code = sb.Append(code).Append("-").Append(n).ToString();
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
await db.Ado.BeginTranAsync();
|
||||
row = await db.Insertable(moTask).ExecuteCommandAsync();
|
||||
|
||||
//根据工单号获取当前工单包含的已排产数
|
||||
var schedQty = db.Queryable<PrdMoTask>().Where(it => it.mo_id == input.mo_id)?.Sum(d => d.scheduled_qty);
|
||||
//判断如果当前 工单的已排产数大于工单计划数量则更新工单状态为 已排产
|
||||
if (schedQty >= mo.plan_qty)
|
||||
{
|
||||
mo.mo_status = DictConst.AlreadyId;
|
||||
row = await db.Updateable(mo).ExecuteCommandAsync();
|
||||
}
|
||||
//将生产任务插入到自检报废记录表
|
||||
var sacipRecord = new PrdMoTaskDefectRecord();
|
||||
sacipRecord.id = SnowflakeIdHelper.NextId();
|
||||
sacipRecord.material_code = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id))?.code;
|
||||
sacipRecord.material_name = (await db.Queryable<BasMaterial>().FirstAsync(it => it.id == moTask.material_id))?.name;
|
||||
sacipRecord.eqp_code = (await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == moTask.eqp_id))?.code;
|
||||
sacipRecord.mold_name = (await db.Queryable<Molds>().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();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await db.Ado.RollbackTranAsync();
|
||||
}
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 生产任务下发,开始 、结束、完成
|
||||
/// </summary>
|
||||
/// <param name="input">输入参数</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdTaskRelease(PrdTaskReleaseUpInput input)
|
||||
{
|
||||
var row = -1;
|
||||
if (input is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
}
|
||||
if (input.TaskIds is null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(input.TaskIds));
|
||||
}
|
||||
if (input.Behavior.IsNullOrWhiteSpace())
|
||||
{
|
||||
throw new ArgumentException($"{nameof(input.Behavior)} not be null or empty");
|
||||
}
|
||||
string SetTaskStatus(PrdTaskBehavior behavior) => behavior switch
|
||||
{
|
||||
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();
|
||||
if (behavior == PrdTaskBehavior.Compled)
|
||||
{
|
||||
var list = await db.Queryable<PrdTask>().Where(it => input.TaskIds.Contains(it.id)).Select(it => it).ToListAsync();
|
||||
if (list?.Count > 0)
|
||||
{
|
||||
var schedQtySum = list.Sum(x => x.scheduled_qty);
|
||||
var planQtySum = list.Sum(x => x.plan_qty);
|
||||
if (schedQtySum < planQtySum)
|
||||
{
|
||||
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();
|
||||
return (row > 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生产任务单修改
|
||||
/// </summary>
|
||||
/// <param name="input">生产任务单修改输入参数</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="AppFriendlyException"></exception>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> IcmoModify(IcmoUpInput input)
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
if (input.icmo_id.IsNullOrWhiteSpace())
|
||||
throw new ArgumentNullException(nameof(input.icmo_id));
|
||||
var icmoItem = await db.Queryable<PrdTask>().FirstAsync(it => it.id == input.icmo_id);
|
||||
switch (input.category)
|
||||
{
|
||||
case 1: //设备
|
||||
|
||||
if (icmoItem != null)
|
||||
{
|
||||
var eqpItem = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == icmoItem.eqp_id);
|
||||
icmoItem.eqp_id = eqpItem.id;
|
||||
icmoItem.eqp_type_code = db.Queryable<EqpEquipType>().First(it => it.id == eqpItem.equip_type_id)?.code;
|
||||
//if (input.scheduled_qty > icmoItem.plan_qty)
|
||||
//{
|
||||
// throw new AppFriendlyException("任务单数量不能大于计划数量", 500);
|
||||
//}
|
||||
//row = await db.Updateable<PrdMo>().SetColumns(it => new PrdMo { input_qty = input.scheduled_qty }).Where(it => it.id == input.mo_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: //模具
|
||||
if (icmoItem != null)
|
||||
{
|
||||
var moldItem = await db.Queryable<Molds>().FirstAsync(it => it.id == icmoItem.mold_id);
|
||||
icmoItem.mold_id = moldItem.id;
|
||||
icmoItem.mold_code = moldItem.mold_code;
|
||||
icmoItem.mold_name = moldItem.mold_name;
|
||||
icmoItem.mold_cavity_qty = moldItem.cavity_qty;
|
||||
}
|
||||
break;
|
||||
}
|
||||
row = await db.Updateable(icmoItem).ExecuteCommandAsync();
|
||||
return (row > 0);
|
||||
}
|
||||
/// <summary>
|
||||
/// 生产提报
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <remarks>
|
||||
/// input:
|
||||
/// <br/>{
|
||||
/// <br/> icmo_id:生产任务ID
|
||||
/// <br/> icmo_code:任务单号
|
||||
/// <br/> prd_qty:生产数量
|
||||
/// <br/> reported_work_qty:已报工数量
|
||||
/// <br/> reported_qty:提报数量
|
||||
/// <br/> icmo_qty:生产任务量
|
||||
/// <br/>}
|
||||
/// </remarks>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdReport(PrdReportCrInput input)
|
||||
{
|
||||
var row = -1;
|
||||
var db = _repository.AsSugarClient();
|
||||
var report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_code == input.mo_task_code);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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();
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
/// <summary>
|
||||
/// 自检报废提交
|
||||
/// </summary>
|
||||
/// <param name="input">自检报废输入参数</param>
|
||||
/// <returns>true/false</returns>
|
||||
/// <remarks>
|
||||
/// input:
|
||||
///<br/>{
|
||||
///<br/> "icmo_code": 任务单号,
|
||||
///<br/> "scrap_qty": 报废数量,
|
||||
///<br/> "remark": 备注,
|
||||
///<br/> "categoryItems": [
|
||||
///<br/> {
|
||||
///<br/> "defective_category":次品分类,
|
||||
///<br/> "category_qty": 分类数量,
|
||||
///<br/> "items": [
|
||||
///<br/> {
|
||||
///<br/> "defective_item": 次品项,
|
||||
///<br/> "defective_item_qty": 次品项数量
|
||||
///<br/> }
|
||||
///<br/> ]
|
||||
///<br/> }
|
||||
///<br/> ]
|
||||
///<br/>}
|
||||
/// </remarks>
|
||||
[HttpPost]
|
||||
public async Task<dynamic> SelfTestScrapped(SelfTestScrappedInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
List<PrdMoTaskDefect> destDefects = new();
|
||||
var batch = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
|
||||
foreach (var categoryItem in input.categoryItems)
|
||||
{
|
||||
foreach (var dItem in categoryItem.items)
|
||||
{
|
||||
var defect = new PrdMoTaskDefect();
|
||||
defect.id = SnowflakeIdHelper.NextId();
|
||||
defect.mo_task_id = input.mo_task_id;
|
||||
defect.batch = batch;
|
||||
defect.defective_cagetory_id = categoryItem.category_id;
|
||||
defect.defective_item = dItem.defective_item;
|
||||
defect.defective_item_qty = dItem.defective_item_qty;
|
||||
defect.create_id = _userManager.UserId;
|
||||
|
||||
destDefects.Add(defect);
|
||||
}
|
||||
}
|
||||
await db.Insertable(destDefects).ExecuteCommandAsync();
|
||||
|
||||
var scrapQty = db.Queryable<PrdMoTaskDefect>().Where(it => it.mo_task_id == input.mo_task_id)?.Sum(d => d.defective_item_qty);
|
||||
if (scrapQty.HasValue && scrapQty.Value > 0)//更新生产任务表报废数量
|
||||
{
|
||||
await db.Updateable<PrdMoTask>().SetColumns(it => new PrdMoTask { scrap_qty = scrapQty.Value }).Where(it => it.id == input.mo_task_id).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
});
|
||||
return result.IsSuccess;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
var pkName = "material_id_id";
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
if (material != null)
|
||||
{
|
||||
row["material_id"] = $"{material.code}/{material.name}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//模具
|
||||
if (dic.ContainsKey("mold_id"))
|
||||
{
|
||||
var moldId = dic["mold_id"]?.ToString();
|
||||
var mold = await db.Queryable<Molds>().FirstAsync(it => it.id == moldId);
|
||||
if (mold != null)
|
||||
{
|
||||
row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
|
||||
}
|
||||
}
|
||||
//设备
|
||||
if (dic.ContainsKey("eqp_id"))
|
||||
{
|
||||
var eqpId = dic["eqp_id"]?.ToString();
|
||||
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||
if (eqp != null)
|
||||
{
|
||||
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
private async Task Delete(string id)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
var result = await db.Ado.UseTranAsync(async () =>
|
||||
{
|
||||
var row = -1;
|
||||
var prdTask = await db.Queryable<PrdTask>().FirstAsync(it => it.id == id);
|
||||
row = await db.Deleteable<PrdTask>().Where(it => it.id == id).ExecuteCommandAsync();
|
||||
if (row > 0)
|
||||
{
|
||||
var prdMo = await db.Queryable<PrdMo>().FirstAsync(it => it.id == prdTask.mo_id);
|
||||
if (prdMo is not null)
|
||||
{
|
||||
prdMo.input_qty += prdTask.scheduled_qty;
|
||||
//prdMo.icmo_status = DictConst.ToBeScheduledEncode;
|
||||
row = await db.Updateable(prdMo).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
return row > 0;
|
||||
});
|
||||
if (!result.IsSuccess) throw Oops.Oh(ErrorCode.COM1002);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
107
ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
Normal file
107
ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using COSXML.Model.Tag;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using JNPF.VisualDev.Entitys;
|
||||
using JNPF.VisualDev.Interfaces;
|
||||
using NPOI.Util;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.EquipMgr.Entities;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
using Tnb.ProductionMgr.Interfaces;
|
||||
using Aspose.Cells.Drawing;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using DbModels;
|
||||
|
||||
namespace Tnb.ProductionMgr
|
||||
{
|
||||
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)]
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
[OverideVisualDev(ModuleId)]
|
||||
public class PrdTaskManageService : IPrdTaskManageService, IOverideVisualDevService, IDynamicApiController, ITransient
|
||||
{
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
private const string ModuleId = "25617945906709";
|
||||
private readonly ISqlSugarRepository<PrdTask> _repository;
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IDictionaryDataService _dictionaryDataService;
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
public PrdTaskManageService(
|
||||
ISqlSugarRepository<PrdTask> repository,
|
||||
IUserManager userManager,
|
||||
IDictionaryDataService dictionaryDataService,
|
||||
IRunService runService,
|
||||
IVisualDevService visualDevService
|
||||
)
|
||||
{
|
||||
_repository = repository;
|
||||
_userManager = userManager;
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
_runService = runService;
|
||||
_visualDevService = visualDevService;
|
||||
OverideFuncs.GetListAsync = GetList;
|
||||
}
|
||||
|
||||
|
||||
private async Task<dynamic> GetList(VisualDevModelListQueryInput input)
|
||||
{
|
||||
var db = _repository.AsSugarClient();
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true);
|
||||
var data = await _runService.GetListResult(templateEntity, input);
|
||||
if (data?.list?.Count > 0)
|
||||
{
|
||||
foreach (var row in data.list)
|
||||
{
|
||||
var dic = row.ToDictionary(x => x.Key, x => x.Value);
|
||||
var pkName = "material_id";
|
||||
if (dic.ContainsKey(pkName))
|
||||
{
|
||||
var materialId = dic[pkName]?.ToString();
|
||||
var material = await db.Queryable<BasMaterial>().FirstAsync(it => it.id == materialId);
|
||||
if (material != null)
|
||||
{
|
||||
row[pkName] = $"{material.code}/{material.name}";
|
||||
}
|
||||
}
|
||||
//模具
|
||||
if (dic.ContainsKey("mold_id"))
|
||||
{
|
||||
var moldId = dic["mold_id"]?.ToString();
|
||||
var mold = await db.Queryable<Molds>().FirstAsync(it => it.id == moldId);
|
||||
if (mold != null)
|
||||
{
|
||||
row["mold_id"] = $"{mold.mold_code}/{mold.mold_name}";
|
||||
}
|
||||
}
|
||||
//设备
|
||||
if (dic.ContainsKey("eqp_id"))
|
||||
{
|
||||
var eqpId = dic["eqp_id"]?.ToString();
|
||||
var eqp = await db.Queryable<EqpEquipment>().FirstAsync(it => it.id == eqpId);
|
||||
if (eqp != null)
|
||||
{
|
||||
row["eqp_id"] = $"{eqp.code}/{eqp.name}";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return data!;
|
||||
}
|
||||
|
||||
//public async Task<dynamic> GetPrdMoTaskList()
|
||||
//{
|
||||
// var db= _repository.AsSugarClient();
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user