diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index 922b8e48..1ec40090 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -24,7 +24,7 @@ public static class DictConst /// /// 工单状态-已排产 /// - public const string AlreadyId = "25019252113685"; + public const string AlreadyId = "26033187948309"; /// /// 工单状态-待排产 /// diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasDefectType.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasDefectType.cs new file mode 100644 index 00000000..d79d2ff6 --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasDefectType.cs @@ -0,0 +1,83 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace Tnb.BasicData.Entities +{ + /// + ///次品分类 + /// + [SugarTable("bas_defect_type")] + public partial class BasDefectType + { + public BasDefectType(){ + + + } + /// + /// Desc:次品类名称 + /// Default:NULL::character varying + /// Nullable:True + /// + public string defect_type_name {get;set;} + + /// + /// Desc:次品类代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string defect_type_code {get;set;} + + /// + /// Desc:编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} + + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time {get;set;} + + /// + /// Desc:创建用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string create_id {get;set;} + + /// + /// Desc:修改用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string modify_id {get;set;} + + /// + /// Desc:所属组织 + /// Default:NULL::character varying + /// Nullable:True + /// + public string org_id {get;set;} + + /// + /// Desc:是否启用 + /// Default: + /// Nullable:False + /// + public short enabled {get;set;} + + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipmentListOutput.cs b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipmentListOutput.cs index 402f06b7..570e8faa 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipmentListOutput.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/Dto/EquipmentListOutput.cs @@ -15,11 +15,11 @@ namespace Tnb.EquipMgr.Entities.Dto public string eqp_code { get; set; } public string eqp_name { get; set; } public string eqp_type_code { get; set; } - public string accept_status { get; set; } - public string supplier_code { get; set; } + //public string accept_status { get; set; } + //public string supplier_code { get; set; } public string accept_date { get; set; } public string install_date { get; set; } - public string use_department_code { get; set; } + //public string use_department_code { get; set; } public string remark { get; set; } } } diff --git a/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipType.cs b/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipType.cs new file mode 100644 index 00000000..a4d3aed7 --- /dev/null +++ b/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipType.cs @@ -0,0 +1,111 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace Tnb.EquipMgr.Entities +{ + /// + ///设备类型 + /// + [SugarTable("eqp_equip_type")] + public partial class EqpEquipType + { + public EqpEquipType(){ + + + } + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} + + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time {get;set;} + + /// + /// Desc:名称 + /// Default: + /// Nullable:False + /// + public string name {get;set;} + + /// + /// Desc:编码 + /// Default: + /// Nullable:False + /// + public string code {get;set;} + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} + + /// + /// Desc:是否是特种设备0否1是 + /// Default: + /// Nullable:False + /// + public int is_special_equipment {get;set;} + + /// + /// Desc:排序 + /// Default: + /// Nullable:False + /// + public int ordinal {get;set;} + + /// + /// Desc:状态0 禁用 1 启用 + /// Default: + /// Nullable:False + /// + public int status {get;set;} + + /// + /// Desc:是否是实验设备0否1是 + /// Default: + /// Nullable:False + /// + public int is_lab {get;set;} + + /// + /// Desc:创建用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string create_id {get;set;} + + /// + /// Desc:修改用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string modify_id {get;set;} + + /// + /// Desc:备注 + /// Default:NULL::character varying + /// Nullable:True + /// + public string remark {get;set;} + + /// + /// Desc:所属组织 + /// Default:NULL::character varying + /// Nullable:True + /// + public string org_id {get;set;} + + } +} diff --git a/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipment.cs b/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipment.cs index 6a33cb63..2ddb8e7c 100644 --- a/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipment.cs +++ b/EquipMgr/Tnb.EquipMgr.Entities/EqpEquipment.cs @@ -11,222 +11,255 @@ namespace Tnb.EquipMgr.Entities [SugarTable("eqp_equipment")] public partial class EqpEquipment { - public EqpEquipment() - { + public EqpEquipment(){ - } - /// - /// Desc:自增ID - /// Default: - /// Nullable:False - /// - [SugarColumn(IsPrimaryKey = true)] - public string id { get; set; } + } + /// + /// Desc:吨位 + /// Default: + /// Nullable:True + /// + public double tonnage {get;set;} - /// - /// Desc:设备代码 - /// Default: - /// Nullable:False - /// - public string eqp_code { get; set; } + /// + /// Desc:编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} - /// - /// Desc:设备名称 - /// Default: - /// Nullable:False - /// - public string eqp_name { get; set; } + /// + /// Desc:设备代码 + /// Default: + /// Nullable:False + /// + public string code {get;set;} - /// - /// Desc:设备类型代码 - /// Default: - /// Nullable:False - /// - public string eqp_type_code { get; set; } - /// - /// 设备机台号 - /// - public string eqp_machine_num { get; set; } + /// + /// Desc:设备名称 + /// Default: + /// Nullable:False + /// + public string name {get;set;} - /// - /// Desc:验收状态(合格:Qualified/不合格:Unqualified) - /// Default: - /// Nullable:False - /// - public string accept_status { get; set; } + /// + /// Desc:设备类型id + /// Default: + /// Nullable:False + /// + public string equip_type_id {get;set;} - /// - /// Desc:使用部门代码 - /// Default: - /// Nullable:False - /// - public string use_department_code { get; set; } + /// + /// Desc:使用日期 + /// Default: + /// Nullable:True + /// + public DateTime? use_date {get;set;} - /// - /// Desc:安装日期 - /// Default: - /// Nullable:False - /// - public string install_date { get; set; } + /// + /// Desc:验收日期 + /// Default: + /// Nullable:True + /// + public DateTime? accept_date {get;set;} - /// - /// Desc:创建时间 - /// Default: - /// Nullable:True - /// - public DateTime? create_time { get; set; } + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} - /// - /// Desc:修改时间 - /// Default: - /// Nullable:True - /// - public DateTime? modify_time { get; set; } + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time {get;set;} - /// - /// Desc:扩展字段 - /// Default: - /// Nullable:True - /// - public string extras { get; set; } + /// + /// Desc:扩展字段 + /// Default: + /// Nullable:True + /// + public string extras {get;set;} - /// - /// Desc:模具Id - /// Default: - /// Nullable:True - /// - public string mold_id { get; set; } + /// + /// Desc:是否成套设备 + /// Default: + /// Nullable:False + /// + public string is_complete_set {get;set;} - /// - /// Desc:所属组织ID - /// Default:NULL::character varying - /// Nullable:True - /// - public string org_id { get; set; } + /// + /// Desc:所属组织 + /// Default:NULL::character varying + /// Nullable:True + /// + public string org_id {get;set;} - /// - /// Desc:设备类型ID,EQP_EQUIPMENTTYPE.ID - /// Default:NULL::character varying - /// Nullable:True - /// - public string eqp_type_id { get; set; } + /// + /// Desc:设备生产日期 + /// Default:NULL::character varying + /// Nullable:True + /// + public string product_date {get;set;} - /// - /// Desc:设备生产日期 - /// Default:NULL::character varying - /// Nullable:True - /// - public string product_date { get; set; } + /// + /// Desc:设备生产厂家 + /// Default:NULL::character varying + /// Nullable:True + /// + public string manufacturer {get;set;} - /// - /// Desc:设备生产厂家 - /// Default:NULL::character varying - /// Nullable:True - /// - public string supplier_code { get; set; } + /// + /// Desc:使用部门id + /// Default:NULL::character varying + /// Nullable:True + /// + public string use_department_id {get;set;} - /// - /// Desc:正式使用日期 - /// Default:NULL::character varying - /// Nullable:True - /// - public string use_date { get; set; } + /// + /// Desc:安装日期 + /// Default:NULL::character varying + /// Nullable:True + /// + public string install_date {get;set;} - /// - /// Desc:验收日期 - /// Default:NULL::character varying - /// Nullable:True - /// - public string accept_date { get; set; } + /// + /// Desc:管理部门id + /// Default:NULL::character varying + /// Nullable:True + /// + public string manage_department_id {get;set;} - /// - /// Desc:管理部门 - /// Default:NULL::character varying - /// Nullable:True - /// - public string manage_department_code { get; set; } + /// + /// Desc:设备生命周期 + /// Default:NULL::character varying + /// Nullable:True + /// + public string life {get;set;} - /// - /// Desc:工段(车间)代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string segment_code { get; set; } + /// + /// Desc:技改编码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string techno_logy_code {get;set;} - /// - /// Desc:工位代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string station_code { get; set; } + /// + /// Desc:备注 + /// Default:NULL::character varying + /// Nullable:True + /// + public string remark {get;set;} - /// - /// Desc:质检代码,良率计算 - /// Default:NULL::character varying - /// Nullable:True - /// - public string quality_station_code { get; set; } + /// + /// Desc:时间戳 + /// Default:NULL::character varying + /// Nullable:True + /// + public string timestamp {get;set;} - /// - /// Desc:生产节拍 - /// Default:NULL::character varying - /// Nullable:True - /// - public string process_time { get; set; } + /// + /// Desc:创建用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string create_id {get;set;} - /// - /// Desc:时间单位: 秒:s 分钟:m 小时:h - /// Default:NULL::character varying - /// Nullable:True - /// - public string time_unit { get; set; } + /// + /// Desc:修改用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string modify_id {get;set;} - /// - /// Desc:设备当前状态,状态代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string current_status { get; set; } + /// + /// Desc:供应商id + /// Default:NULL::character varying + /// Nullable:True + /// + public string supplier_id {get;set;} - /// - /// Desc:技术性能 - /// Default:NULL::character varying - /// Nullable:True - /// - public string techno_logy { get; set; } + /// + /// Desc:出厂编码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string factory_code {get;set;} - /// - /// Desc:备注 - /// Default:NULL::character varying - /// Nullable:True - /// - public string remark { get; set; } + /// + /// Desc:合同/采购单号 + /// Default:NULL::character varying + /// Nullable:True + /// + public string contract_no {get;set;} - /// - /// Desc:时间戳 - /// Default:NULL::character varying - /// Nullable:True - /// - public string timestamp { get; set; } + /// + /// Desc:维保电话 + /// Default:NULL::character varying + /// Nullable:True + /// + public string maintenance_phone {get;set;} - /// - /// Desc:创建用户 - /// Default:NULL::character varying - /// Nullable:True - /// - public string create_id { get; set; } + /// + /// Desc:规格型号 + /// Default:NULL::character varying + /// Nullable:True + /// + public string specification {get;set;} - /// - /// Desc:修改用户 - /// Default:NULL::character varying - /// Nullable:True - /// - public string modify_id { get; set; } - /// - /// 吨位 - /// - public double tonnage { get; set; } + /// + /// Desc:安装地点 + /// Default:NULL::character varying + /// Nullable:True + /// + public string installation_location {get;set;} + + /// + /// Desc:DCS-ID + /// Default:NULL::character varying + /// Nullable:True + /// + public string dcs_id {get;set;} + + /// + /// Desc:技术参数 + /// Default:NULL::character varying + /// Nullable:True + /// + public string technology_parameter {get;set;} + + /// + /// Desc:状态 + /// Default:NULL::character varying + /// Nullable:True + /// + public string status {get;set;} + + /// + /// Desc:维保单位 + /// Default:NULL::character varying + /// Nullable:True + /// + public string maintenance_unit {get;set;} + + /// + /// Desc:模具Id + /// Default: + /// Nullable:True + /// + public string mold_id {get;set;} + + /// + /// Desc:设备机台号 + /// Default: + /// Nullable:True + /// + public string eqp_machine_num {get;set;} } } diff --git a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs index 2f8880d1..03d1183f 100644 --- a/EquipMgr/Tnb.EquipMgr/EquipmentService.cs +++ b/EquipMgr/Tnb.EquipMgr/EquipmentService.cs @@ -46,21 +46,20 @@ namespace Tnb.EquipMgr }; var pagedList = await _repository.AsQueryable() - .Where(it => it.station_code == input.station_code || string.IsNullOrEmpty(input.station_code)) + //.Where(it => it.station_code == input.station_code || string.IsNullOrEmpty(input.station_code)) .Select(it => new EquipmentListOutput { id = it.id, - eqp_code = it.eqp_code, - eqp_name = it.eqp_name, - eqp_type_code = it.eqp_type_code, - accept_status = it.accept_status, - supplier_code = it.supplier_code, - accept_date = it.accept_date, + eqp_code = it.code, + eqp_name = it.name, + eqp_type_code = SqlFunc.Subqueryable().Where(x=>x.id == it.equip_type_id).Select(x=>x.code), + //accept_status = it.accept_status, + //supplier_code = it.supplier_code, install_date = it.install_date, - use_department_code = it.use_department_code, + //use_department_code = it.use_department_code, remark = it.remark, }) - .Mapper(it => it.accept_status = dic.ContainsKey(it.accept_status) ? dic[it.accept_status] : "") + //.Mapper(it => it.accept_status = dic.ContainsKey(it.accept_status) ? dic[it.accept_status] : "") .ToPagedListAsync(input.currentPage, input.pageSize); return pagedList; } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/IcmoUpInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/IcmoUpInput.cs index e02720a3..b6648b96 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/IcmoUpInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/IcmoUpInput.cs @@ -26,14 +26,14 @@ namespace Tnb.ProductionMgr.Entities.Dto /// /// 模具Id /// - public string mold_id { get; set; } - /// - /// 设备Id - /// - public string eqp_id { get; set; } + //public string mold_id { get; set; } + ///// + ///// 设备Id + ///// + //public string eqp_id { get; set; } /// /// 生产任务单数量 /// - public int scheduled_qty { get; set; } + //public int scheduled_qty { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs index bbf68e2c..5e689dd0 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/MoldListOutput.cs @@ -10,12 +10,32 @@ namespace Tnb.ProductionMgr.Entities.Dto /// /// 模具列表输出参数 /// - public class MoldListOutput : Molds + public class MoldListOutput { /// - /// 产品 名称 + /// 模具名称 /// - public string item_name { get; set; } + public string mold_name { get; set; } + /// + /// 物料名称 + /// + public string material_name { get; set; } + /// + /// 物料编号 + /// + public string material_code { get; set; } + /// + /// 模具编号 + /// + public string mold_code { get; set; } + /// + /// 模具型号 + /// + public string mold_type_code { get; set; } + /// + /// 型腔数 + /// + public int? cavity_qty { get; set; } public string mold_id { get; set;} } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs new file mode 100644 index 00000000..64b545c6 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdMoTaskDefectOutput.cs @@ -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 +{ + /// + /// 提报记录统计明细 + /// + public class PrdMoTaskDefectOutput + { + /// + /// Desc:任务单号 + /// Default: + /// Nullable:True + /// + public string mo_task_code { get; set; } + public List batchItems { get; set; } + } + + public class BatchItem + { + public string batch { get; set; } + + public string create_time { get; set; } + /// + /// 报废数量 + /// + public int scrap_qty { get; set; } + + /// + ///次品分类数组 + /// + public List categoryItems { get; set; } + } + + public class CategoryItem + { + /// + /// 次品分类名称 + /// + public string name { get; set; } + /// + /// 次品分类数量 + /// + public int qty { get; set; } + + /// + /// 次品项数组 + /// + public List defectItems { get; set; } + } + + public class DefectItem + { + /// + /// 次品分类名称 + /// + public string name { get; set; } + /// + /// 次品分类数量 + /// + public int qty { get; set; } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs index ed41e45d..a2a6b049 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportCrInput.cs @@ -86,7 +86,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// Default: /// Nullable:True /// - public string icmo_code { get; set; } + public string mo_task_code { get; set; } + /// + /// renwu di + /// + public string mo_task_id { get; set; } /// /// Desc:生产任务量 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs index 9c5f2f6c..2de1be86 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdReportOutput.cs @@ -26,5 +26,25 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public int? prd_qty { get; set; } public int? scrap_qty { get; set; } + /// + /// 模具编码 + /// + public string mold_code { get; set; } + /// + /// 设备编码 + /// + public string eqp_code { get; set; } + /// + /// 物料编码 + /// + public string material_code { get; set; } + /// + /// 物料名称 + /// + public string material_name { get; set; } + /// + /// 物料属性 + /// + public string material_property { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs index 9e9848e2..5c43f44b 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/ProductionSchedulingCrInput.cs @@ -17,11 +17,11 @@ namespace Tnb.ProductionMgr.Entities.Dto public string id { get; set; } /// - /// Desc:工单类型 1、注塑/挤出工单 2、组装/包装工单 + /// Desc:排产类型 1、注塑/挤出工单 2、组装/包装工单 /// Default: /// Nullable:True /// - public int? mo_type { get; set; } + public int? schedule_type { get; set; } /// /// Desc:计划开始时间 @@ -37,27 +37,21 @@ namespace Tnb.ProductionMgr.Entities.Dto /// public DateTime? plan_end_date { get; set; } - /// - /// Desc:预计开始时间 - /// Default: - /// Nullable:True - /// - public DateTime? estimated_start_date { get; set; } + ///// + ///// Desc:预计开始时间 + ///// Default: + ///// Nullable:True + ///// + //public DateTime? estimated_start_date { get; set; } - /// - /// Desc:预计结束时间 - /// Default: - /// Nullable:True - /// - public DateTime? estimated_end_date { get; set; } + ///// + ///// Desc:预计结束时间 + ///// Default: + ///// Nullable:True + ///// + //public DateTime? estimated_end_date { get; set; } - /// - /// Desc:生产任务单状态 - /// Default: - /// Nullable:True - /// - public string status { get; set; } /// /// Desc:工单Id @@ -66,48 +60,18 @@ namespace Tnb.ProductionMgr.Entities.Dto /// public string mo_id { get; set; } - /// - /// Desc:工单代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string mo_code { get; set; } - /// /// Desc:模具Id /// Default:NULL::character varying /// Nullable:True /// public string mold_id { get; set; } - /// - /// 模具编号 - /// - public string mold_code { get; set; } - - /// - /// Desc:模具名称 - /// Default:NULL::character varying - /// Nullable:True - /// - public string mold_name { get; set; } - /// /// Desc:设备Id /// Default:NULL::character varying /// Nullable:True /// public string eqp_id { get; set; } - /// - /// 设备编号 - /// - public string eqp_code { get; set; } - - /// - /// Desc:设备名称 - /// Default:NULL::character varying - /// Nullable:True - /// - public string eqp_name { get; set; } /// /// Desc:产线编号 @@ -116,62 +80,20 @@ namespace Tnb.ProductionMgr.Entities.Dto /// public string line_id { get; set; } - /// - /// Desc:产线名称 - /// Default:NULL::character varying - /// Nullable:True - /// - public string line_name { get; set; } /// - /// Desc:产品Id + /// Desc:物料Id /// Default:NULL::character varying /// Nullable:True /// - public string item_id { get; set; } - /// - /// 产品编号 - /// - public string item_code { get; set; } - - /// - /// Desc:产品名称 - /// Default:NULL::character varying - /// Nullable:True - /// - public string item_name { get; set; } - /// - /// 产品规格型号 - /// - public string item_standard { get; set; } - - /// - /// Desc:创建用户 - /// Default:NULL::character varying - /// Nullable:True - /// - public string create_id { get; set; } - - /// - /// Desc:修改用户 - /// Default:NULL::character varying - /// Nullable:True - /// - public string modify_id { get; set; } + public string material_id { get; set; } /// /// Desc:生产车间 /// Default:NULL::character varying /// Nullable:True /// - public string workshop { get; set; } - - /// - /// Desc:模穴数 - /// Default: - /// Nullable:True - /// - public int? mold_cavity_qty { get; set; } + public string workshop_id { get; set; } /// /// Desc:计划生产数量 @@ -180,24 +102,10 @@ namespace Tnb.ProductionMgr.Entities.Dto /// public int? plan_qty { get; set; } - /// - /// Desc:吨位 - /// Default: - /// Nullable:True - /// - public decimal? tonnage { get; set; } /// /// 已排产数量 /// public int scheduled_qty { get; set; } - /// - /// 设备型号 - /// - public string eqp_type_code { get; set; } - - - - } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedInput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedInput.cs index 60b0998e..08ff439a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedInput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedInput.cs @@ -16,7 +16,11 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage /// Default: /// Nullable:True /// - public string icmo_code { get; set; } + //public string mo_task_code { get; set; } + /// + /// 生产任务单Id + /// + public string mo_task_id { get; set; } /// /// Desc:报废数量 /// Default: @@ -39,14 +43,35 @@ namespace Tnb.ProductionMgr.Entities.Dto.PrdManage public class SelfTestScrappedInputItem { - public string defective_category { get; set; } + /// + /// 次品分类Id + /// + public string category_id { get; set; } /// /// Desc:分类数量 /// Default: /// Nullable:True /// - public int? category_qty { get; set; } - public List items { get; set; } + //public int? category_qty { get; set; } + public List items { get; set; } + } + + public class defectItem + { + + /// + /// Desc:次品项 + /// Default: + /// Nullable:True + /// + public string defective_item { get; set; } + + /// + /// Desc:次品项数量 + /// Default: + /// Nullable:True + /// + public int defective_item_qty { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedOutput.cs deleted file mode 100644 index b4f12c3e..00000000 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/SelfTestScrappedOutput.cs +++ /dev/null @@ -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 -{ - /// - /// 提报记录统计明细 - /// - public class SelfTestScrappedOutput - { - /// - /// Desc:任务单号 - /// Default: - /// Nullable:True - /// - public string icmo_code { get; set; } - /// - /// Desc:报废数量 - /// Default: - /// Nullable:True - /// - public int scrap_qty { get; set; } - /// - /// 自检报废集合 - /// - public List categoryItems { get; set; } - - } - - public class SelfTestScrappedOutputItem - { - public string defective_category { get; set; } - - /// - /// Desc:分类数量 - /// Default: - /// Nullable:True - /// - public int? category_qty { get; set; } - public List items { get; set; } - - } -} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs index fd38e4d5..923f7cc9 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/Molds.cs @@ -120,11 +120,7 @@ namespace Tnb.ProductionMgr.Entities /// Default:NULL::character varying /// Nullable:True /// - public string item_id { get; set; } - /// - /// 产品code - /// - public string item_code { get; set; } + public string material_id { get; set; } /// /// Desc:设备Id diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs index 30defb57..98d1f3b9 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMo.cs @@ -11,323 +11,297 @@ namespace Tnb.ProductionMgr.Entities [SugarTable("prd_mo")] public partial class PrdMo { - public PrdMo() - { + public PrdMo(){ - } - /// - /// Desc:Id - /// Default: - /// Nullable:False - /// - [SugarColumn(IsPrimaryKey = true)] - public string id { get; set; } + } + /// + /// Desc:编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} - /// - /// Desc:工单代码 - /// Default: - /// Nullable:False - /// - public string mo_code { get; set; } + /// + /// Desc:工单代码 + /// Default: + /// Nullable:False + /// + public string mo_code {get;set;} - /// - /// 产品ID - /// - public string item_id { get; set; } + /// + /// Desc:工单类型:1-正常工单、2-返工工单、3-试制工单 + /// Default: + /// Nullable:False + /// + public string mo_type {get;set;} + /// + /// Desc:生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停 + /// Default: + /// Nullable:False + /// + public string mo_status {get;set;} + /// + /// Desc:生产数量 + /// Default: + /// Nullable:False + /// + public decimal plan_qty {get;set;} - /// - /// Desc:产品代码, BAS_MATERIA.MATERIALCODE BAS_ITEM.ITEMCODE - /// Default: - /// Nullable:False - /// - public string item_code { get; set; } + /// + /// Desc:已投入数量 + /// Default: + /// Nullable:True + /// + public decimal? input_qty {get;set;} - /// - /// Desc:工单类型:1-正常工单、2-返工工单、3-试制工单 - /// Default: - /// Nullable:False - /// - public string mo_type { get; set; } + /// + /// Desc:已完工数量 + /// Default: + /// Nullable:True + /// + public decimal? complete_qty {get;set;} - /// - /// Desc:生产状态 Initial: 初始, Confirm:确认 Release: 下发, Open: 生产中, Close: 关单, Pending: 暂停 - /// Default: - /// Nullable:False - /// - public string mo_status { get; set; } + /// + /// Desc:报废数量 + /// Default: + /// Nullable:True + /// + public decimal? scrap_qty {get;set;} - /// - /// Desc:生产数量 - /// Default: - /// Nullable:False - /// - public decimal plan_qty { get; set; } + /// + /// Desc:计划开始时间 + /// Default: + /// Nullable:False + /// + public DateTime plan_start_date {get;set;} - /// - /// Desc:已投入数量 - /// Default: - /// Nullable:True - /// - public int input_qty { get; set; } + /// + /// Desc:计划结束时间 + /// Default: + /// Nullable:False + /// + public DateTime plan_end_date {get;set;} - /// - /// Desc:已完工数量 - /// Default: - /// Nullable:True - /// - public decimal? complete_qty { get; set; } + /// + /// Desc:实际开工日期 + /// Default: + /// Nullable:True + /// + public DateTime? act_start_date {get;set;} - /// - /// Desc:报废数量 - /// Default: - /// Nullable:True - /// - public decimal? scrap_qty { get; set; } + /// + /// Desc:实际完工日期 + /// Default: + /// Nullable:True + /// + public DateTime? act_end_date {get;set;} - /// - /// Desc:计划开始时间 - /// Default: - /// Nullable:False - /// - public DateTime plan_start_date { get; set; } + /// + /// Desc:订单行号 + /// Default: + /// Nullable:True + /// + public int? order_seq {get;set;} - /// - /// Desc:计划结束时间 - /// Default: - /// Nullable:False - /// - public DateTime plan_end_date { get; set; } + /// + /// Desc:关联比例 + /// Default: + /// Nullable:True + /// + public decimal? relation_ratio {get;set;} - /// - /// Desc:实际开工日期 - /// Default: - /// Nullable:True - /// - public DateTime? act_start_date { get; set; } + /// + /// Desc:下发日期 + /// Default: + /// Nullable:True + /// + public DateTime? mo_down_date {get;set;} - /// - /// Desc:实际完工日期 - /// Default: - /// Nullable:True - /// - public DateTime? act_end_date { get; set; } + /// + /// Desc:物料编号 + /// Default: + /// Nullable:False + /// + public string material_code {get;set;} - /// - /// Desc:订单行号 - /// Default: - /// Nullable:True - /// - public int? order_seq { get; set; } + /// + /// Desc:排程开始时间 + /// Default: + /// Nullable:True + /// + public DateTime? seduling_start_date {get;set;} - /// - /// Desc:关联比例 - /// Default: - /// Nullable:True - /// - public decimal? relation_ratio { get; set; } + /// + /// Desc:排程结束时间 + /// Default: + /// Nullable:True + /// + public DateTime? seduling_end_date {get;set;} - /// - /// Desc:下发日期 - /// Default: - /// Nullable:True - /// - public DateTime? mo_down_date { get; set; } + /// + /// Desc:是否生派工单 + /// Default: + /// Nullable:True + /// + public int? is_create_dispatch {get;set;} - /// - /// Desc:排程开始时间 - /// Default: - /// Nullable:True - /// - public DateTime? seduling_start_date { get; set; } + /// + /// Desc:子工单序号(1开始,最大+1,不强制连续) + /// Default: + /// Nullable:True + /// + public int? seq {get;set;} - /// - /// Desc:排程结束时间 - /// Default: - /// Nullable:True - /// - public DateTime? seduling_end_date { get; set; } + /// + /// Desc:是否合并 + /// Default: + /// Nullable:True + /// + public int? is_merge {get;set;} - /// - /// Desc:是否生派工单 - /// Default: - /// Nullable:True - /// - public int? is_create_dispatch { get; set; } + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} - /// - /// Desc:子工单序号(1开始,最大+1,不强制连续) - /// Default: - /// Nullable:True - /// - public int? seq { get; set; } + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time {get;set;} - /// - /// Desc:租户ID - /// Default:NULL::character varying - /// Nullable:True - /// - public string tenant_id { get; set; } + /// + /// Desc:扩展字段 + /// Default: + /// Nullable:True + /// + public string extras {get;set;} - /// - /// Desc:ismerge - /// Default: - /// Nullable:True - /// - public int? is_merge { get; set; } + /// + /// Desc:所属组织 + /// Default:NULL::character varying + /// Nullable:True + /// + public string org_id {get;set;} - /// - /// Desc:创建时间 - /// Default: - /// Nullable:True - /// - public DateTime? create_time { get; set; } + /// + /// Desc:生产部门ID + /// Default:NULL::character varying + /// Nullable:True + /// + public string dept_id {get;set;} - /// - /// Desc:修改时间 - /// Default: - /// Nullable:True - /// - public DateTime? modify_time { get; set; } + /// + /// Desc:客户代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string customer_code {get;set;} - /// - /// Desc:扩展字段 - /// Default: - /// Nullable:True - /// - public string extras { get; set; } + /// + /// Desc:订单号 + /// Default:NULL::character varying + /// Nullable:True + /// + public string order_no {get;set;} - /// - /// Desc:所属组织ID - /// Default:NULL::character varying - /// Nullable:True - /// - public string org_id { get; set; } + /// + /// Desc:BOM版本 + /// Default:NULL::character varying + /// Nullable:True + /// + public string bom_version {get;set;} - /// - /// Desc:产品附属信息 - /// Default:NULL::character varying - /// Nullable:True - /// - public string item_attribute { get; set; } + /// + /// Desc:下发人员ID + /// Default:NULL::character varying + /// Nullable:True + /// + public string mo_down_user_id {get;set;} - /// - /// Desc:生产部门ID - /// Default:NULL::character varying - /// Nullable:True - /// - public string dept_id { get; set; } + /// + /// Desc:下发人员名称 + /// Default:NULL::character varying + /// Nullable:True + /// + public string mo_down_user_name {get;set;} - /// - /// Desc:客户代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string customer_code { get; set; } + /// + /// Desc:备注 + /// Default:NULL::character varying + /// Nullable:True + /// + public string remark {get;set;} - /// - /// Desc:订单号 - /// Default:NULL::character varying - /// Nullable:True - /// - public string order_no { get; set; } + /// + /// Desc:工作中心代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string work_center_code {get;set;} - /// - /// Desc:BOM版本 - /// Default:NULL::character varying - /// Nullable:True - /// - public string bom_version { get; set; } + /// + /// Desc:主工单代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string parent_mo_code {get;set;} - /// - /// Desc:下发人员ID - /// Default:NULL::character varying - /// Nullable:True - /// - public string mo_down_user_id { get; set; } + /// + /// Desc:数据来源 10-计划,20-插入,30-导入 + /// Default:NULL::character varying + /// Nullable:True + /// + public string data_sources {get;set;} - /// - /// Desc:下发人员名称 - /// Default:NULL::character varying - /// Nullable:True - /// - public string mo_down_user_name { get; set; } + /// + /// Desc:产线代码 + /// Default:NULL::character varying + /// Nullable:True + /// + public string production_linecode {get;set;} - /// - /// Desc:备注 - /// Default:NULL::character varying - /// Nullable:True - /// - public string remark { get; set; } + /// + /// Desc:组合工单 + /// Default:NULL::character varying + /// Nullable:True + /// + public string combine_mo_code {get;set;} - /// - /// Desc:工作中心代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string work_center_code { get; set; } + /// + /// Desc:时间戳 + /// Default:NULL::character varying + /// Nullable:True + /// + public string time_stamp {get;set;} - /// - /// Desc:主工单代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string parent_mo_code { get; set; } + /// + /// Desc:创建用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string create_id {get;set;} - /// - /// Desc:数据来源 10-计划,20-插入,30-导入 - /// Default:NULL::character varying - /// Nullable:True - /// - public string data_sources { get; set; } + /// + /// Desc:修改用户 + /// Default:NULL::character varying + /// Nullable:True + /// + public string modify_id {get;set;} - /// - /// Desc:产线代码 - /// Default:NULL::character varying - /// Nullable:True - /// - public string production_linecode { get; set; } - - /// - /// Desc:组合工单 - /// Default:NULL::character varying - /// Nullable:True - /// - public string combine_mo_code { get; set; } - - /// - /// Desc:时间戳 - /// Default:NULL::character varying - /// Nullable:True - /// - public string time_stamp { get; set; } - - /// - /// Desc:创建用户 - /// Default:NULL::character varying - /// Nullable:True - /// - public string create_id { get; set; } - - /// - /// Desc:修改用户 - /// Default:NULL::character varying - /// Nullable:True - /// - public string modify_id { get; set; } - - /// - /// Desc:工单组号 - /// Default:NULL::character varying - /// Nullable:True - /// - public string mo_task_no { get; set; } - /// - /// 生产任务状态 - /// - public string icmo_status { get; set; } + /// + /// Desc:物料ID + /// Default:NULL::character varying + /// Nullable:True + /// + public string material_id {get;set;} } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs new file mode 100644 index 00000000..f848f220 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -0,0 +1,203 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace DbModels +{ + /// + ///生产任务信息 + /// + [SugarTable("prd_mo_task")] + public partial class PrdMoTask + { + public PrdMoTask(){ + + + } + /// + /// Desc:排产类型:1、注塑、挤出2、组装、包装 + /// Default: + /// Nullable:True + /// + public int? schedule_type {get;set;} + + /// + /// Desc:计划开始时间 + /// Default: + /// Nullable:True + /// + public DateTime? plan_start_date {get;set;} + + /// + /// Desc:计划结束时间 + /// Default: + /// Nullable:True + /// + public DateTime? plan_end_date {get;set;} + + /// + /// Desc:实际开工日期 + /// Default: + /// Nullable:True + /// + public DateTime? act_start_date {get;set;} + + /// + /// Desc:实际完工日期 + /// Default: + /// Nullable:True + /// + public DateTime? act_end_date {get;set;} + + /// + /// Desc:创建人 + /// Default: + /// Nullable:True + /// + public string create_id {get;set;} + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} + + /// + /// Desc:修改人 + /// Default: + /// Nullable:True + /// + public string modify_id {get;set;} + + /// + /// Desc:修改时间 + /// Default: + /// Nullable:True + /// + public DateTime? modify_time {get;set;} + + /// + /// Desc:扩展字段 + /// Default: + /// Nullable:True + /// + public string extras {get;set;} + + /// + /// Desc:编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} + + /// + /// Desc:生产任务编号 + /// Default: + /// Nullable:True + /// + public string mo_task_code {get;set;} + + /// + /// Desc:工单Id + /// Default:NULL::character varying + /// Nullable:True + /// + public string mo_id {get;set;} + + + /// + /// Desc:物料Id + /// Default:NULL::character varying + /// Nullable:True + /// + public string material_id {get;set;} + + /// + /// Desc:模具Id + /// Default:NULL::character varying + /// Nullable:True + /// + public string mold_id {get;set;} + + /// + /// Desc:设备Id + /// Default:NULL::character varying + /// Nullable:True + /// + public string eqp_id {get;set;} + + /// + /// Desc:产线id + /// Default:NULL::character varying + /// Nullable:True + /// + public string workline_id {get;set;} + + /// + /// Desc:工位id + /// Default: + /// Nullable:True + /// + public string workstation_id {get;set;} + + /// + /// Desc:工艺路线id + /// Default: + /// Nullable:True + /// + public string workroute_id {get;set;} + + /// + /// Desc:生产bom id + /// Default: + /// Nullable:True + /// + public string bom_id {get;set;} + + /// + /// Desc:任务单状态 + /// Default: + /// Nullable:True + /// + public string mo_task_status {get;set;} + + /// + /// Desc:计划数量 + /// Default: + /// Nullable:True + /// + public int plan_qty {get;set;} + + /// + /// Desc:已投入数量 + /// Default: + /// Nullable:True + /// + public int input_qty {get;set;} + + /// + /// Desc:已完工数量 + /// Default: + /// Nullable:True + /// + public decimal? complete_qty {get;set;} + + /// + /// Desc:报废数量 + /// Default: + /// Nullable:True + /// + public int scrap_qty {get;set;} + + /// + /// Desc:已排产数量 + /// Default: + /// Nullable:True + /// + public int scheduled_qty {get;set;} + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs new file mode 100644 index 00000000..8ae2744d --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefect.cs @@ -0,0 +1,74 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities +{ + /// + ///TODO + /// + [SugarTable("prd_mo_task_defect")] + public partial class PrdMoTaskDefect + { + public PrdMoTaskDefect() + { + + + } + /// + /// Desc:次品分类id + /// Default: + /// Nullable:True + /// + public string defective_cagetory_id { get; set; } + + /// + /// Desc:次品项 + /// Default: + /// Nullable:True + /// + public string defective_item { get; set; } + + /// + /// Desc:次品项数量 + /// Default: + /// Nullable:True + /// + public int defective_item_qty { get; set; } + + /// + /// Desc:编号 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey = true)] + public string id { get; set; } + + /// + /// Desc:创建用户 + /// Default: + /// Nullable:True + /// + public string create_id { get; set; } + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time { get; set; } + + /// + /// Desc:任务单id + /// Default: + /// Nullable:True + /// + public string mo_task_id { get; set; } + /// + /// 批次 + /// + public string batch { get; set; } + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs new file mode 100644 index 00000000..a348b39d --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTaskDefectRecord.cs @@ -0,0 +1,118 @@ +using System; +using System.Linq; +using System.Text; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities +{ + /// + /// + /// + [SugarTable("prd_mo_task_defect_record")] + public partial class PrdMoTaskDefectRecord + { + public PrdMoTaskDefectRecord(){ + + + } + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} + + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + public string eqp_code {get;set;} + + /// + /// Desc:模具名称 + /// Default: + /// Nullable:True + /// + public string mold_name {get;set;} + + /// + /// Desc:预计开始时间 + /// Default: + /// Nullable:True + /// + public DateTime? estimated_start_date {get;set;} + + /// + /// Desc:预计结束时间 + /// Default: + /// Nullable:True + /// + public DateTime? estimated_end_date {get;set;} + + /// + /// Desc:计划生产数量 + /// Default: + /// Nullable:True + /// + public int? plan_qty {get;set;} + + /// + /// Desc:生产任务单状态 + /// Default: + /// Nullable:True + /// + public string status {get;set;} + + /// + /// Desc:创建人Id + /// Default: + /// Nullable:True + /// + public string create_id {get;set;} + + /// + /// Desc:创建时间 + /// Default: + /// Nullable:True + /// + public DateTime? create_time {get;set;} + + /// + /// Desc:报废数量 + /// Default: + /// Nullable:True + /// + public int? scrap_qty {get;set;} + + /// + /// Desc:物料名称 + /// Default: + /// Nullable:True + /// + public string material_name {get;set;} + + /// + /// Desc:任务单Id + /// Default: + /// Nullable:True + /// + public string mo_task_id {get;set;} + + /// + /// Desc:物料编码 + /// Default: + /// Nullable:True + /// + public string material_code {get;set;} + + /// + /// Desc:任务单编号 + /// Default: + /// Nullable:True + /// + public string mo_task_code {get;set;} + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs index 398e3f35..cc7acfb7 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReport.cs @@ -16,7 +16,7 @@ namespace Tnb.ProductionMgr.Entities } /// - /// Desc:主键 + /// Desc:编号 /// Default: /// Nullable:False /// @@ -51,6 +51,13 @@ namespace Tnb.ProductionMgr.Entities /// public string extras {get;set;} + /// + /// Desc:生产任务Id + /// Default:NULL::character varying + /// Nullable:True + /// + public string mo_task_id {get;set;} + /// /// Desc:备注 /// Default:NULL::character varying @@ -72,19 +79,12 @@ namespace Tnb.ProductionMgr.Entities /// public string modify_id {get;set;} - /// - /// Desc:生产任务Id - /// Default:NULL::character varying - /// Nullable:True - /// - public string icmo_id {get;set;} - /// /// Desc:生产数量 /// Default: /// Nullable:True /// - public int prd_qty {get;set;} + public int? prd_qty {get;set;} /// /// Desc:已报工数量 @@ -98,14 +98,14 @@ namespace Tnb.ProductionMgr.Entities /// Default: /// Nullable:True /// - //public int? reported_qty {get;set;} + public int? reported_qty {get;set;} /// /// Desc:生产任务编码 /// Default: /// Nullable:True /// - public string icmo_code {get;set;} + public string mo_task_code {get;set;} /// /// Desc:生产任务量 diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs index 23fcffd4..6c221dca 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdReportRecord.cs @@ -11,71 +11,73 @@ namespace Tnb.ProductionMgr.Entities [SugarTable("prd_report_record")] public partial class PrdReportRecord { - public PrdReportRecord() - { + public PrdReportRecord(){ - } - /// - /// Desc:主键 - /// Default: - /// Nullable:False - /// - [SugarColumn(IsPrimaryKey = true)] - public string id { get; set; } + } + /// + /// Desc:主键 + /// Default: + /// Nullable:False + /// + [SugarColumn(IsPrimaryKey=true)] + public string id {get;set;} - /// - /// Desc:产品编码 - /// Default: - /// Nullable:True - /// - public string item_code { get; set; } + /// + /// Desc:设备编码 + /// Default: + /// Nullable:True + /// + public string eqp_code {get;set;} - /// - /// Desc:产品名称 - /// Default: - /// Nullable:True - /// - public string item_name { get; set; } + /// + /// Desc:产品编码 + /// Default: + /// Nullable:True + /// + public string masterial_code {get;set;} - /// - /// Desc:设备编码 - /// Default: - /// Nullable:True - /// - public string eqp_code { get; set; } + /// + /// Desc:产品名称 + /// Default: + /// Nullable:True + /// + public string masterial_name {get;set;} - /// - /// Desc:计划开始时间 - /// Default: - /// Nullable:True - /// - public DateTime? plan_start_date { get; set; } + /// + /// Desc:计划生产数量 + /// Default: + /// Nullable:True + /// + public int? plan_qty {get;set;} - /// - /// Desc:计划结束时间 - /// Default: - /// Nullable:True - /// - public DateTime? plan_end_date { get; set; } + /// + /// Desc:完成数量 + /// Default: + /// Nullable:True + /// + public int? completed_qty {get;set;} - /// - /// Desc:计划生产数量 - /// Default: - /// Nullable:True - /// - public int? plan_qty { get; set; } + /// + /// Desc:计划开始时间 + /// Default: + /// Nullable:True + /// + public DateTime? plan_start_date {get;set;} - /// - /// Desc:完成数量 - /// Default: - /// Nullable:True - /// - public int? completed_qty { get; set; } - /// - /// 任务单号 - /// - public string icmo_code { get; } + /// + /// Desc:计划结束时间 + /// Default: + /// Nullable:True + /// + public DateTime? plan_end_date {get;set;} + + /// + /// Desc:任务单号 + /// Default: + /// Nullable:True + /// + public string mo_task_code {get;set;} } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdSelfTestScrappedRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdSelfTestScrappedRecord.cs index 717f83f7..ede80cf2 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdSelfTestScrappedRecord.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdSelfTestScrappedRecord.cs @@ -103,7 +103,7 @@ namespace Tnb.ProductionMgr.Entities /// /// 任务单号 /// - public string icmo_code { get; } + public string icmo_code { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs new file mode 100644 index 00000000..fc17ada1 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdMoTaskService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Interfaces +{ + /// + /// 生产任务 + /// + public interface IPrdMoTaskService + { + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdTaskManageService.cs new file mode 100644 index 00000000..8d5fbe98 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/IPrdTaskManageService.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Interfaces +{ + public interface IPrdTaskManageService + { + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs b/ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs new file mode 100644 index 00000000..2f1bfc5e --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Interfaces/Interface1.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.ProductionMgr.Interfaces +{ + /// + /// 生产任务单下发接口 + /// + public interface IPrdMoTaskIssueService + { + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 9f249502..6311fe63 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -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 _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 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 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().FirstAsync(it => it.id == materialId); + if (material != null) + { + row.Add("material_name", material.name); + row.Add($"material_attribute", material.attribute); + + } + } + } + } + return data!; + } #region Get - /// - /// 根据产品ID获取模具列表 - /// - /// 产品ID - /// - /// - ///
return results: - ///
[ - ///
{ - ///
mold_code:模具编号 - ///
mold_name:模具名称 - ///
item_name:产品名称 - ///
item_code:产品编号 - ///
cavity_qty:模穴数 - ///
} - ///
] - ///
- [HttpGet("{itemId}")] - public async Task GetMoldListByItemId(string itemId) - { - var db = _repository.AsSugarClient(); - var list = await db.Queryable().InnerJoin((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; - - } - /// - /// 根据模具Id获取设备列表 - /// - /// - /// - [HttpGet("{moldId}")] - public async Task GetEquipmentListByMoldId(string moldId) - { - var items = await _repository.AsSugarClient().Queryable() - .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().Where(x => x.eqp_id == it.id).Count(), - estimated_end_date = SqlFunc.Subqueryable().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; - - } /// - /// 工单调整-生产任务重新排序 - /// - /// 设备ID - /// 排序后生产任务列表 - /// - /// returns: - ///
[ - ///
{ - ///
no:生产序号 - ///
mo_id:工单编号 - ///
group_flag:同组标识 - ///
plan_qty:计划生产数量 - ///
comple_qty:完成数量 - ///
item_name:产品名称 - ///
mold_code:模具编号 - ///
} - ///
] - ///
- [HttpGet("{eqpId}")] - public async Task PrdTaskSort(string eqpId) - { - var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); - var list = await _repository.AsSugarClient().Queryable() - .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; - } - /// - /// 查看生产任务操作记录 - /// - /// 任务ID - /// - [HttpGet("{taskId}")] - public async Task GetMoOperRecord(string taskId) - { - var list = await _repository.AsSugarClient().Queryable().Where(it => it.id == taskId).ToListAsync(); - var data = list.Adapt>(); - var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); - _repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : ""); - return data; - } - /// - /// 根据任务单号获取提报记录明细 - /// - /// 任务单号 - /// - /// returns: - ///
{ - ///
icmo_qty:任务计划数量 - ///
reported_work_qty:已报工数量 - ///
reported_qty:报工数量 - ///
prd_qty:生产数量 - ///
} - ///
- [HttpGet("{icmoCode}")] - public async Task GetPrdReportByIcmoCode(string icmoCode) - { - var db = _repository.AsSugarClient(); - var res = await db.Queryable().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().Select(x => x.scrap_qty), - }) - .Mapper(it => - { - it.icmo_qty = it.icmo_qty ?? (db.Queryable().First(it => it.icmo_code == icmoCode)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable().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().First(it => it.icmo_code == icmoCode)?.scheduled_qty, - reported_work_qty = 0, - //reported_qty = 0, - prd_qty = 0, - scrap_qty = 0, - }; - return res; - } - /// - /// 获取提报生产记录 + /// 获取自建报废记录 /// /// /// @@ -240,20 +110,19 @@ namespace Tnb.ProductionMgr public async Task GetReportRecord(string icmoCode) { var db = _repository.AsSugarClient(); - var output = new SelfTestScrappedOutput(); - output.icmo_code = icmoCode; - var scrap = (await db.Queryable().FirstAsync(it => it.icmo_code == icmoCode)); - output.scrap_qty = scrap != null ? scrap.scrap_qty : 0; - output.categoryItems = new List(); - var categorys = await db.Queryable().Where(it => it.icmo_code == icmoCode).ToListAsync(); - foreach (var category in categorys) - { - var categoryItem = category.Adapt(); - categoryItem.items = new List(); - var items = await db.Queryable().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().FirstAsync(it => it.icmo_code == icmoCode)); + //output.items = new List(); + //var categorys = await db.Queryable().Where(it => it.icmo_code == icmoCode).ToListAsync(); + //foreach (var category in categorys) + //{ + // var categoryItem = category.Adapt(); + // categoryItem.items = new List(); + // var items = await db.Queryable().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 getMoStatus(MoBehavior behavior) + string getMoStatus(MoBehavior behavior) { - Tuple 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(); - var multi = getMoStatus(behavior); - + var status = getMoStatus(behavior); var row = await db.Updateable() - .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); } /// @@ -321,7 +188,7 @@ namespace Tnb.ProductionMgr { (bool executeRes, string errMsg) multi = (true, ""); var list = await _repository.AsSugarClient().Queryable() - .InnerJoin((a, b) => a.item_code == b.item_id) + .InnerJoin((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(); } - /// - /// 生产工单-生产排产 - /// - /// - ///
{ - ///
Id:生产任务主键Id - ///
MoType:工单类型 1、注塑/挤出 2、组装/包装 - ///
MoId:工单Id - ///
ItemId:产品编号 - ///
ItemName:产品名称 - ///
MoldId:模具Id - ///
MoldName:模具名称 - ///
EqpId:设备Id - ///
EqpName:设备名称 - ///
LineId:产线编号 - ///
LineName:产线名称 - ///
} - /// - /// - - [HttpPost] - public async Task ProductionScheduling(ProductionSchedulingCrInput input) - { - var row = -1; - if (input.mo_type.HasValue && input.mo_type.Value == 1) - { - input.id ??= SnowflakeIdHelper.NextId(); - var entity = input.Adapt(); - 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 entities = new(); - List icmoEntities = new(); - //根据工单Id查询同组工单号,进行同组工单排产处理 - var combineMoCodes = await db.Queryable().Where(it => it.id == input.mo_id).Select(it => it.combine_mo_code).Distinct().ToListAsync(); - if (combineMoCodes?.Count > 0) - { - entities = await db.Queryable().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>(); - 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().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().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(); - 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().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().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().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().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; - } - /// - /// 生产任务下发,开始 、结束、完成 - /// - /// 输入参数 - /// - /// - /// - [HttpPost] - public async Task 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(); - var status = SetTaskStatus(behavior); - var db = _repository.AsSugarClient(); - if (behavior == PrdTaskBehavior.Compled) - { - var list = await db.Queryable().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() - .SetColumns(it => new PrdTask { status = status }) - .Where(it => input.TaskIds.Contains(it.id)) - .ExecuteCommandAsync(); - return (row > 0); - } - - /// - /// 生产任务单修改 - /// - /// 生产任务单修改输入参数 - /// - /// - [HttpPost] - public async Task 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().FirstAsync(it => it.id == input.icmo_id); - switch (input.category) - { - case 1: //设备 - var eqpItem = await db.Queryable().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().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().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); - } - /// - /// 生产提报 - /// - /// - /// - /// input: - ///
{ - ///
icmo_id:生产任务ID - ///
icmo_code:任务单号 - ///
prd_qty:生产数量 - ///
reported_work_qty:已报工数量 - ///
reported_qty:提报数量 - ///
icmo_qty:生产任务量 - ///
} - ///
- [HttpPost] - public async Task PrdReport(PrdReportCrInput input) - { - var row = -1; - var db = _repository.AsSugarClient(); - var report = await db.Queryable().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(); - 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().FirstAsync(it => it.icmo_code == input.icmo_code); - var record = prdTask.Adapt(); - if (prdTask != null) - { - record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.eqp_code; - record.completed_qty = input.reported_qty; - row = await db.Insertable(record).ExecuteCommandAsync(); - } - return row > 0; - } - /// - /// 自检报废提交 - /// - /// 自检报废输入参数 - /// true/false - /// - /// input: - ///
{ - ///
"icmo_code": 任务单号, - ///
"scrap_qty": 报废数量, - ///
"remark": 备注, - ///
"categoryItems": [ - ///
{ - ///
"defective_category":次品分类, - ///
"category_qty": 分类数量, - ///
"items": [ - ///
{ - ///
"defective_item": 次品项, - ///
"defective_item_qty": 次品项数量 - ///
} - ///
] - ///
} - ///
] - ///
} - ///
- [HttpPost] - public async Task SelfTestScrapped(SelfTestScrappedInput input) - { - var db = _repository.AsSugarClient(); - var prdScrapped = await db.Queryable().FirstAsync(it => it.icmo_code == input.icmo_code); - if (prdScrapped is null) - { - prdScrapped = input.Adapt(); - 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(); - foreach (var categoryItem in input.categoryItems) - { - categorys = await db.Queryable().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().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(); - 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(); - if (categoryItem.items?.Count > 0) - { - foreach (var item in categoryItem.items) - { - var defectiveItem = item.Adapt(); - 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().SumAsync(it => it.defective_item_qty); - //prdScrapped.scrap_qty = scrapQty; - var report = await db.Queryable().FirstAsync(it => it.icmo_code == input.icmo_code); - if (report != null) - { - report.prd_qty += input.scrap_qty; - await db.Updateable(report).ExecuteCommandAsync(); - } - await db.Storageable(prdScrapped).ExecuteCommandAsync(); - var prdTask = await db.Queryable().FirstAsync(it => it.icmo_code == input.icmo_code); - var record = prdTask.Adapt(); - if (prdTask != null) - { - record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.eqp_code; - record.scrap_qty = input.scrap_qty; - await db.Insertable(record).ExecuteCommandAsync(); - } - }); - return result.IsSuccess; - } - #endregion - - - /// - /// 删除 - /// - /// - /// - - 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().FirstAsync(it => it.id == id); - row = await db.Deleteable().Where(it => it.id == id).ExecuteCommandAsync(); - if (row > 0) - { - var prdMo = await db.Queryable().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); - - } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs new file mode 100644 index 00000000..c7f02960 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskIssueService.cs @@ -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 _repository; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + public PrdMoTaskIssueService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService + ) + { + _repository = repository; + _runService = runService; + _visualDevService = visualDevService; + OverideFuncs.GetListAsync = GetList; + + } + + private async Task 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().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().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().FirstAsync(it => it.id == eqpId); + if (eqp != null) + { + row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + row["eqpid"] = eqp.id; + } + } + } + } + return data!; + } + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs new file mode 100644 index 00000000..4e3657b8 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -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 _repository; + private readonly IUserManager _userManager; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private static Dictionary _dicDefect = new Dictionary(); + + + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public PrdMoTaskService( + ISqlSugarRepository 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 + + + + /// + /// 根据产品ID获取模具列表 + /// + /// 产品ID + /// + /// + ///
return results: + ///
[ + ///
{ + ///
mold_code:模具编号 + ///
mold_name:模具名称 + ///
item_name:产品名称 + ///
item_code:产品编号 + ///
cavity_qty:模穴数 + ///
} + ///
] + ///
+ + + [HttpGet("{materialId}")] + public async Task GetMoldListByItemId(string materialId) + { + var db = _repository.AsSugarClient(); + var list = await db.Queryable().InnerJoin((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; + + } + /// + /// 根据模具Id获取设备列表 + /// + /// + /// + [HttpGet("{moldId}")] + public async Task GetEquipmentListByMoldId(string moldId) + { + var items = await _repository.AsSugarClient().Queryable() + .Where(it => it.mold_id == moldId) + .Select(it => new EquipmentListOutput + { + eqp_id = it.id, + eqp_code = it.code, + eqp_type_code = SqlFunc.Subqueryable().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().Where(x => x.eqp_id == it.id).Count(), + estimated_end_date = SqlFunc.Subqueryable().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; + + } + + /// + /// 工单调整-生产任务重新排序 + /// + /// 设备ID + /// 排序后生产任务列表 + /// + /// returns: + ///
[ + ///
{ + ///
no:生产序号 + ///
mo_id:工单编号 + ///
group_flag:同组标识 + ///
plan_qty:计划生产数量 + ///
comple_qty:完成数量 + ///
item_name:产品名称 + ///
mold_code:模具编号 + ///
} + ///
] + ///
+ [HttpGet("{eqpId}")] + public async Task PrdTaskSort(string eqpId) + { + var taskStatusDic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + var list = await _repository.AsSugarClient().Queryable() + .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; + } + /// + /// 查看生产任务操作记录 + /// + /// 任务ID + /// + [HttpGet("{taskId}")] + public async Task GetMoOperRecord(string taskId) + { + var list = await _repository.AsSugarClient().Queryable().Where(it => it.id == taskId).ToListAsync(); + var data = list.Adapt>(); + var dic = await _dictionaryDataService.GetDicByTypeId(DictConst.PrdTaskStatusTypeId); + _repository.AsSugarClient().ThenMapper(data, x => x.statusName = dic.ContainsKey(x.status) ? dic[x.status].ToString() : ""); + return data; + } + /// + /// 根据任务单号获取提报记录明细 + /// + /// 任务单号 + /// + /// returns: + ///
{ + ///
icmo_qty:任务计划数量 + ///
reported_work_qty:已报工数量 + ///
reported_qty:报工数量 + ///
prd_qty:生产数量 + ///
} + ///
+ [HttpGet("{mo_task_code}")] + public async Task GetPrdReportByIcmoCode(string mo_task_code) + { + var db = _repository.AsSugarClient(); + var prdTask = await db.Queryable().FirstAsync(it => it.mo_task_code == mo_task_code); + var eqpCode = ""; + var moldCode = ""; + var materialCode = ""; + var materialName = ""; + var materialProp = ""; + if (prdTask != null) + { + var eqp = await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id); + var mold = await db.Queryable().FirstAsync(it => it.id == prdTask.mold_id); + var material = await db.Queryable().FirstAsync(it => it.id == prdTask.material_id); + eqpCode = eqp != null ? eqp.code : ""; + moldCode = mold != null ? mold.mold_code : ""; + materialCode = material != null ? material.code : ""; + materialName = material != null ? material.name : ""; + materialProp = material != null ? material.material_property : ""; + } + + + var res = await db.Queryable().Where(it => it.mo_task_code == mo_task_code) + .Select(it => new PrdReportOutput + { + icmo_qty = it.icmo_qty, + reported_work_qty = it.reported_work_qty, + //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().Select(x => x.scrap_qty), + }) + .Mapper(it => + { + it.icmo_qty = it.icmo_qty ?? (db.Queryable().First(it => it.icmo_code == mo_task_code)?.scheduled_qty < 1 ? 0 : it.icmo_qty ?? db.Queryable().First(it => it.icmo_code == mo_task_code).scheduled_qty); + it.reported_work_qty = it.reported_work_qty ?? 0; + //it.reported_qty = it.reported_qty ?? 0; + it.prd_qty = it.prd_qty ?? 0; + it.scrap_qty = it.scrap_qty ?? 0; + }) + .FirstAsync(); + res ??= new PrdReportOutput + { + icmo_qty = db.Queryable().First(it => it.mo_task_code == mo_task_code)?.scheduled_qty, + reported_work_qty = 0, + //reported_qty = 0, + prd_qty = 0, + scrap_qty = 0, + }; + return res; + } + /// + /// 获取自检报废批次记录 + /// + /// 任务单Id + /// + [HttpGet("{moTaskId}")] + public async Task GetScarpStatRecord(string moTaskId) + { + var output = new PrdMoTaskDefectOutput(); + var db = _repository.AsSugarClient(); + if (_dicDefect.Count < 1) + { + _dicDefect = await db.Queryable().ToDictionaryAsync(x => x.id, x => x.defect_type_name); + } + output.mo_task_code = (await db.Queryable().FirstAsync(it => it.id == moTaskId))?.mo_task_code; + var defects = await db.Queryable().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 + + /// + /// 生产工单-生产排产 + /// + /// + ///
{ + ///
Id:生产任务主键Id + ///
MoType:工单类型 1、注塑/挤出 2、组装/包装 + ///
MoId:工单Id + ///
ItemId:产品编号 + ///
ItemName:产品名称 + ///
MoldId:模具Id + ///
MoldName:模具名称 + ///
EqpId:设备Id + ///
EqpName:设备名称 + ///
LineId:产线编号 + ///
LineName:产线名称 + ///
} + /// + /// + [HttpPost] + public async Task ProductionScheduling(ProductionSchedulingCrInput input) + { + var db = _repository.AsSugarClient(); + var row = -1; + if (input.schedule_type.HasValue && input.schedule_type.Value == 1) + { + var moTask = input.Adapt(); + 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().FirstAsync(it => it.id == input.mo_id); + var moCode = mo?.mo_code; + var taskCode = await db.Queryable().Where(it => !string.IsNullOrEmpty(it.mo_task_code) && it.mo_task_code.Contains(moCode)).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().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().FirstAsync(it => it.id == moTask.material_id))?.code; + sacipRecord.material_name = (await db.Queryable().FirstAsync(it => it.id == moTask.material_id))?.name; + sacipRecord.eqp_code = (await db.Queryable().FirstAsync(it => it.id == moTask.eqp_id))?.code; + sacipRecord.mold_name = (await db.Queryable().FirstAsync(it => it.id == moTask.mold_id))?.mold_name; + sacipRecord.estimated_start_date = moTask.plan_start_date; + sacipRecord.estimated_end_date = moTask.plan_end_date; + sacipRecord.plan_qty = moTask.plan_qty; + sacipRecord.scrap_qty = moTask.scrap_qty; + sacipRecord.status = moTask.mo_task_status; + sacipRecord.create_id = _userManager.UserId; + sacipRecord.create_time = DateTime.Now; + sacipRecord.mo_task_id = moTask.id; + sacipRecord.mo_task_code = moTask.mo_task_code; + await db.Insertable(sacipRecord).ExecuteCommandAsync(); + await db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + await db.Ado.RollbackTranAsync(); + } + } + return row > 0; + } + /// + /// 生产任务下发,开始 、结束、完成 + /// + /// 输入参数 + /// + /// + /// + [HttpPost] + public async Task 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(); + var status = SetTaskStatus(behavior); + var db = _repository.AsSugarClient(); + if (behavior == PrdTaskBehavior.Compled) + { + var list = await db.Queryable().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() + .SetColumns(it => new PrdMoTask { mo_task_status = status }) + .Where(it => input.TaskIds.Contains(it.id)) + .ExecuteCommandAsync(); + return (row > 0); + } + + /// + /// 生产任务单修改 + /// + /// 生产任务单修改输入参数 + /// + /// + [HttpPost] + public async Task 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().FirstAsync(it => it.id == input.icmo_id); + switch (input.category) + { + case 1: //设备 + + if (icmoItem != null) + { + var eqpItem = await db.Queryable().FirstAsync(it => it.id == icmoItem.eqp_id); + icmoItem.eqp_id = eqpItem.id; + icmoItem.eqp_type_code = db.Queryable().First(it => it.id == eqpItem.equip_type_id)?.code; + //if (input.scheduled_qty > icmoItem.plan_qty) + //{ + // throw new AppFriendlyException("任务单数量不能大于计划数量", 500); + //} + //row = await db.Updateable().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().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); + } + /// + /// 生产提报 + /// + /// + /// + /// input: + ///
{ + ///
icmo_id:生产任务ID + ///
icmo_code:任务单号 + ///
prd_qty:生产数量 + ///
reported_work_qty:已报工数量 + ///
reported_qty:提报数量 + ///
icmo_qty:生产任务量 + ///
} + ///
+ [HttpPost] + public async Task PrdReport(PrdReportCrInput input) + { + var row = -1; + var db = _repository.AsSugarClient(); + var report = await db.Queryable().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(); + 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().FirstAsync(it => it.mo_task_code == input.mo_task_code); + var record = prdTask.Adapt(); + if (prdTask != null) + { + record.id =SnowflakeIdHelper.NextId(); + record.eqp_code = (await db.Queryable().FirstAsync(it => it.id == prdTask.eqp_id))?.code; + record.completed_qty = input.reported_qty; + row = await db.Insertable(record).ExecuteCommandAsync(); + } + return row > 0; + } + /// + /// 自检报废提交 + /// + /// 自检报废输入参数 + /// true/false + /// + /// input: + ///
{ + ///
"icmo_code": 任务单号, + ///
"scrap_qty": 报废数量, + ///
"remark": 备注, + ///
"categoryItems": [ + ///
{ + ///
"defective_category":次品分类, + ///
"category_qty": 分类数量, + ///
"items": [ + ///
{ + ///
"defective_item": 次品项, + ///
"defective_item_qty": 次品项数量 + ///
} + ///
] + ///
} + ///
] + ///
} + ///
+ [HttpPost] + public async Task SelfTestScrapped(SelfTestScrappedInput input) + { + var db = _repository.AsSugarClient(); + var result = await db.Ado.UseTranAsync(async () => + { + List 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().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().SetColumns(it => new PrdMoTask { scrap_qty = scrapQty.Value }).Where(it => it.id == input.mo_task_id).ExecuteCommandAsync(); + } + + }); + return result.IsSuccess; + } + + #endregion + + + private async Task 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().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().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().FirstAsync(it => it.id == eqpId); + if (eqp != null) + { + row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + } + } + } + } + return data!; + } + + /// + /// 删除 + /// + /// + /// + 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().FirstAsync(it => it.id == id); + row = await db.Deleteable().Where(it => it.id == id).ExecuteCommandAsync(); + if (row > 0) + { + var prdMo = await db.Queryable().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); + + } + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs new file mode 100644 index 00000000..9183256f --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/PrdTaskManageService.cs @@ -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 _repository; + private readonly IUserManager _userManager; + private readonly IDictionaryDataService _dictionaryDataService; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + public PrdTaskManageService( + ISqlSugarRepository 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 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().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().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().FirstAsync(it => it.id == eqpId); + if (eqp != null) + { + row["eqp_id"] = $"{eqp.code}/{eqp.name}"; + } + } + + } + } + return data!; + } + + //public async Task GetPrdMoTaskList() + //{ + // var db= _repository.AsSugarClient(); + //} + } +} diff --git a/system/Tnb.Systems/Permission/DepartmentService.cs b/system/Tnb.Systems/Permission/DepartmentService.cs index 3dc97348..fc612ac7 100644 --- a/system/Tnb.Systems/Permission/DepartmentService.cs +++ b/system/Tnb.Systems/Permission/DepartmentService.cs @@ -455,17 +455,17 @@ public class DepartmentService : IDepartmentService, IDynamicApiController, ITra var eqpList = (jsonObj.Value("roweqp")); var eqpIds = eqpList.Select(x => x.Value("id")).ToList(); - isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync(); - //工位与设备解绑操作 - var eqpEntities = await _repository.AsSugarClient().Queryable().Where(it => it.station_code == input.enCode).ToListAsync(); - if (eqpEntities?.Count > 0) - { - var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList(); - if (unbindEqpIds?.Count > 0) - { - isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync(); - } - } + //isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = input.enCode }).Where(it => eqpIds.Contains(it.id)).ExecuteCommandAsync(); + ////工位与设备解绑操作 + //var eqpEntities = await _repository.AsSugarClient().Queryable().Where(it => it.station_code == input.enCode).ToListAsync(); + //if (eqpEntities?.Count > 0) + //{ + // var unbindEqpIds = eqpEntities.Select(x => x.id).Except(eqpIds).ToList(); + // if (unbindEqpIds?.Count > 0) + // { + // isOK = await _repository.AsSugarClient().Updateable().SetColumns(it => new EqpEquipment { station_code = "" }).Where(it => unbindEqpIds.Contains(it.id)).ExecuteCommandAsync(); + // } + //} } var processVal = jsonObj.GetValue("rowprocess"); if (processVal is not null) diff --git a/visualdev/Tnb.VisualDev/RunService.cs b/visualdev/Tnb.VisualDev/RunService.cs index 1105f96e..fd1b9b98 100644 --- a/visualdev/Tnb.VisualDev/RunService.cs +++ b/visualdev/Tnb.VisualDev/RunService.cs @@ -2481,8 +2481,8 @@ public class RunService : IRunService, ITransient { foreach (KeyValuePair item in keywordJsonDic) { - var model = columnDesign.searchList.Find(it => it.__vModel__.Equals(item.Key)); - switch (model.jnpfKey) + var model = columnDesign.searchList?.Find(it => it.__vModel__.Equals(item.Key)); + switch (model?.jnpfKey) { case JnpfKeyConst.DATE: {