diff --git a/MDM/MDM.sql b/MDM/Assets/sql/MDM.sql similarity index 100% rename from MDM/MDM.sql rename to MDM/Assets/sql/MDM.sql diff --git a/MDM/Controllers/Plant/PlantPlcIoPointController.cs b/MDM/Controllers/Plant/PlantPlcIoPointController.cs new file mode 100644 index 0000000..44c566c --- /dev/null +++ b/MDM/Controllers/Plant/PlantPlcIoPointController.cs @@ -0,0 +1,117 @@ +using Infrastructure; +using Infrastructure.Attribute; +using Infrastructure.Controllers; +using Infrastructure.Enums; +using Infrastructure.Model; +using Mapster; +using MDM.Model.Plant; +using MDM.Model.Plant.Dto; +using MDM.Services.IPlantService; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using RIZO.Admin.WebApi.Filters; +using RIZO.Common; +using RIZO.ServiceCore.Middleware; + +//创建时间:2025-11-15 +namespace MDM.Controllers.Plant +{ + /// + /// PLC点位 + /// + [Verify] + [Route("MasterDataManagement/Plant/PlantPlcIoPoint")] + public class PlantPlcIoPointController : BaseController + { + /// + /// PLC点位接口 + /// + private readonly IPlantPlcIoPointService _PlantPlcIoPointService; + + public PlantPlcIoPointController(IPlantPlcIoPointService PlantPlcIoPointService) + { + _PlantPlcIoPointService = PlantPlcIoPointService; + } + + /// + /// 查询PLC点位列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:plantplciopoint:list")] + public IActionResult QueryPlantPlcIoPoint([FromQuery] PlantPlcIoPointQueryDto parm) + { + var response = _PlantPlcIoPointService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询PLC点位详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:plantplciopoint:query")] + public IActionResult GetPlantPlcIoPoint(int Id) + { + var response = _PlantPlcIoPointService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加PLC点位 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:plantplciopoint:add")] + [Log(Title = "PLC点位", BusinessType = BusinessType.INSERT)] + public IActionResult AddPlantPlcIoPoint([FromBody] PlantPlcIoPointDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _PlantPlcIoPointService.AddPlantPlcIoPoint(modal); + + return SUCCESS(response); + } + + /// + /// 更新PLC点位 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:plantplciopoint:edit")] + [Log(Title = "PLC点位", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdatePlantPlcIoPoint([FromBody] PlantPlcIoPointDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _PlantPlcIoPointService.UpdatePlantPlcIoPoint(modal); + + return ToResponse(response); + } + + /// + /// 删除PLC点位 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:plantplciopoint:delete")] + [Log(Title = "PLC点位", BusinessType = BusinessType.DELETE)] + public IActionResult DeletePlantPlcIoPoint(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _PlantPlcIoPointService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/MDM/Controllers/Process/ProcessOperationWorkstationMappingController.cs b/MDM/Controllers/Process/ProcessOperationWorkstationMappingController.cs new file mode 100644 index 0000000..2073ee1 --- /dev/null +++ b/MDM/Controllers/Process/ProcessOperationWorkstationMappingController.cs @@ -0,0 +1,118 @@ +using Microsoft.AspNetCore.Mvc; + +using RIZO.Admin.WebApi.Filters; +using Infrastructure.Controllers; +using RIZO.ServiceCore.Middleware; +using Mapster; +using Infrastructure.Enums; +using Infrastructure; +using Infrastructure.Attribute; +using RIZO.Common; +using Infrastructure.Model; +using MDM.Services.IProcessService; +using MDM.Model.Process.Dto; +using MDM.Model.Process; +using MDM.Services.Process; + +//创建时间:2025-11-22 +namespace MDM.Controllers.Process +{ + /// + /// 工序工站映射 + /// + [Verify] + [Route("MasterDataManagement/Process/ProcessOperationWorkstationMapping")] + public class ProcessOperationWorkstationMappingController : BaseController + { + /// + /// 接口 + /// + private readonly IProcessOperationWorkstationMappingService _ProcessOperationWorkstationMappingService; + + public ProcessOperationWorkstationMappingController(IProcessOperationWorkstationMappingService ProcessOperationWorkstationMappingService) + { + _ProcessOperationWorkstationMappingService = ProcessOperationWorkstationMappingService; + } + + /// + /// 查询列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:processoperationworkstationmapping:list")] + public IActionResult QueryProcessOperationWorkstationMapping([FromQuery] ProcessOperationWorkstationMappingQueryDto parm) + { + var response = _ProcessOperationWorkstationMappingService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:processoperationworkstationmapping:query")] + public IActionResult GetProcessOperationWorkstationMapping(int Id) + { + var response = _ProcessOperationWorkstationMappingService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:processoperationworkstationmapping:add")] + [Log(Title = "", BusinessType = BusinessType.INSERT)] + public IActionResult AddProcessOperationWorkstationMapping([FromBody] ProcessOperationWorkstationMappingDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _ProcessOperationWorkstationMappingService.AddProcessOperationWorkstationMapping(modal); + + return SUCCESS(response); + } + + /// + /// 更新 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:processoperationworkstationmapping:edit")] + [Log(Title = "", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateProcessOperationWorkstationMapping([FromBody] ProcessOperationWorkstationMappingDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _ProcessOperationWorkstationMappingService.UpdateProcessOperationWorkstationMapping(modal); + + return ToResponse(response); + } + + /// + /// 删除 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:processoperationworkstationmapping:delete")] + [Log(Title = "", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteProcessOperationWorkstationMapping(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _ProcessOperationWorkstationMappingService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/MDM/Controllers/Process/ProcessParameterController.cs b/MDM/Controllers/Process/ProcessParameterController.cs new file mode 100644 index 0000000..b3ab23e --- /dev/null +++ b/MDM/Controllers/Process/ProcessParameterController.cs @@ -0,0 +1,117 @@ +using Microsoft.AspNetCore.Mvc; + +using RIZO.Admin.WebApi.Filters; +using Infrastructure.Controllers; +using RIZO.ServiceCore.Middleware; +using Mapster; +using Infrastructure.Enums; +using Infrastructure; +using Infrastructure.Attribute; +using RIZO.Common; +using Infrastructure.Model; +using MDM.Services.IProcessService; +using MDM.Model.Process.Dto; +using MDM.Model.Process; + +//创建时间:2025-11-15 +namespace MDM.Controllers.Process +{ + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + [Verify] + [Route("MasterDataManagement/Process/ProcessParameter")] + public class ProcessParameterController : BaseController + { + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序)接口 + /// + private readonly IProcessParameterService _ProcessParameterService; + + public ProcessParameterController(IProcessParameterService ProcessParameterService) + { + _ProcessParameterService = ProcessParameterService; + } + + /// + /// 查询工艺参数表(如温度、压力、时间等,关联工艺路线与工序)列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:processparameter:list")] + public IActionResult QueryProcessParameter([FromQuery] ProcessParameterQueryDto parm) + { + var response = _ProcessParameterService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询工艺参数表(如温度、压力、时间等,关联工艺路线与工序)详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:processparameter:query")] + public IActionResult GetProcessParameter(int Id) + { + var response = _ProcessParameterService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:processparameter:add")] + [Log(Title = "工艺参数表(如温度、压力、时间等,关联工艺路线与工序)", BusinessType = BusinessType.INSERT)] + public IActionResult AddProcessParameter([FromBody] ProcessParameterDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _ProcessParameterService.AddProcessParameter(modal); + + return SUCCESS(response); + } + + /// + /// 更新工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:processparameter:edit")] + [Log(Title = "工艺参数表(如温度、压力、时间等,关联工艺路线与工序)", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateProcessParameter([FromBody] ProcessParameterDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _ProcessParameterService.UpdateProcessParameter(modal); + + return ToResponse(response); + } + + /// + /// 删除工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:processparameter:delete")] + [Log(Title = "工艺参数表(如温度、压力、时间等,关联工艺路线与工序)", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteProcessParameter(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _ProcessParameterService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/MDM/Host/StartupTaskService.cs b/MDM/Host/StartupTaskService.cs new file mode 100644 index 0000000..7282452 --- /dev/null +++ b/MDM/Host/StartupTaskService.cs @@ -0,0 +1,56 @@ +using MDM.Model.Plant; +using MDM.Services.Plant; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using SqlSugar.IOC; +using System; +using System.Threading; +using System.Threading.Tasks; +namespace MDM.Host +{ + /// + /// 应用程序启动时执行的任务服务 + /// + public class StartupTaskService : IHostedService + { + private readonly ILogger _logger; + private readonly PlcIoPointCacheService _cacheService; + + public StartupTaskService(ILogger logger, PlcIoPointCacheService cacheService) + { + _logger = logger; + _cacheService = cacheService; + } + + public Task StartAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("应用程序启动,正在执行初始化逻辑..."); + + // 在这里写你想要启动时立刻执行的逻辑 + ExecuteStartupLogic(); + + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("StartupTaskService 已停止"); + return Task.CompletedTask; + } + + private void ExecuteStartupLogic() + { + // 查询所有启用的点位数据(IsActive == 1) + var activePoints = DbScoped.SugarScope.CopyNew().Queryable() + .Where(p => p.IsActive == 1) + .ToList(); + + _logger.LogInformation($"✅ 从数据库加载到 {activePoints.Count} 条有效的 PlantPlcIoPoint 数据"); + + // 将数据存入缓存服务 + _cacheService.InitializeCache(activePoints); + + _logger.LogInformation("📦 PlantPlcIoPoint 数据已成功加载到内存缓存。"); + } + } +} diff --git a/MDM/Models/Plant/Dto/PlantPlcIoPointDto.cs b/MDM/Models/Plant/Dto/PlantPlcIoPointDto.cs new file mode 100644 index 0000000..e498133 --- /dev/null +++ b/MDM/Models/Plant/Dto/PlantPlcIoPointDto.cs @@ -0,0 +1,50 @@ +using System.ComponentModel.DataAnnotations; + +namespace MDM.Model.Plant.Dto +{ + /// + /// PLC点位查询对象 + /// + public class PlantPlcIoPointQueryDto : PagerInfo + { + public string FkWorkstationCode { get; set; } + + public string FkProcessParamCode { get; set; } + + public string FkDeviceCode { get; set; } + } + + /// + /// PLC点位输入输出对象 + /// + public class PlantPlcIoPointDto + { + [Required(ErrorMessage = "Id不能为空")] + public int Id { get; set; } + + public string FkWorkstationCode { get; set; } + + public string FkProcessParamCode { get; set; } + + public string FkDeviceCode { get; set; } + + public string PointType { get; set; } + + public string Address { get; set; } + + public int? IsActive { get; set; } + + public string Description { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + + + } +} \ No newline at end of file diff --git a/MDM/Models/Plant/PlantPlcIoPoint.cs b/MDM/Models/Plant/PlantPlcIoPoint.cs new file mode 100644 index 0000000..465ae09 --- /dev/null +++ b/MDM/Models/Plant/PlantPlcIoPoint.cs @@ -0,0 +1,80 @@ +namespace MDM.Model.Plant +{ + /// + /// PLC点位 + /// + [SugarTable("plant_plc_io_point")] + public class PlantPlcIoPoint + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 工站code + /// + [SugarColumn(ColumnName = "fk_workstation_code")] + public string FkWorkstationCode { get; set; } + + /// + /// 工艺参数code + /// + [SugarColumn(ColumnName = "fk_process_param_code")] + public string FkProcessParamCode { get; set; } + + /// + /// 设备id + /// + [SugarColumn(ColumnName = "fk_device_code")] + public string FkDeviceCode { get; set; } + + /// + /// 点位类型,如 AI(模拟输入)、DI等 + /// + [SugarColumn(ColumnName = "point_type")] + public string PointType { get; set; } + + /// + /// 点位地址,如 %IW64、DB1.DBW0 + /// + public string Address { get; set; } + + /// + /// 是否激活(1启用,0停用) + /// + [SugarColumn(ColumnName = "is_active")] + public int? IsActive { get; set; } + + /// + /// 描述 + /// + public string Description { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "created_by")] + public string CreatedBy { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "created_time")] + public DateTime? CreatedTime { get; set; } + + /// + /// 更改人 + /// + [SugarColumn(ColumnName = "updated_by")] + public string UpdatedBy { get; set; } + + /// + /// 更改时间 + /// + [SugarColumn(ColumnName = "updated_time")] + public DateTime? UpdatedTime { get; set; } + + } +} \ No newline at end of file diff --git a/MDM/Models/Process/Dto/ProcessOperationWorkstationMappingDto.cs b/MDM/Models/Process/Dto/ProcessOperationWorkstationMappingDto.cs new file mode 100644 index 0000000..47f4653 --- /dev/null +++ b/MDM/Models/Process/Dto/ProcessOperationWorkstationMappingDto.cs @@ -0,0 +1,61 @@ +using System.ComponentModel.DataAnnotations; + +namespace MDM.Model.Process.Dto +{ + /// + /// 查询对象 + /// + public class ProcessOperationWorkstationMappingQueryDto : PagerInfo + { + + public string? FkRoutingCode { get; set; } + + + public string? FkOperationCode { get; set; } + + public string? FkWorkstationCode { get; set; } + public string FkProductlinebodyCode { get; set; } + } + + /// + /// 输入输出对象 + /// + public class ProcessOperationWorkstationMappingDto + { + + public int Id { get; set; } + + [Required(ErrorMessage = "工艺路线不能为空")] + public string FkRoutingCode { get; set; } + + [Required(ErrorMessage = "线体不能为空")] + public string FkProductlinebodyCode { get; set; } + + [Required(ErrorMessage = "工序code不能为空")] + public string FkOperationCode { get; set; } + + [Required(ErrorMessage = "工位ID不能为空")] + public string FkWorkstationCode { get; set; } + + public string IsActive { get; set; } + + public int? Priority { get; set; } + + public decimal StandardTime { get; set; } + + public decimal SetupTime { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string CreatedBy { get; set; } + + public string Remark { get; set; } + + public DateTime? UpdatedTime { get; set; } + + public string UpdatedBy { get; set; } + + + + } +} \ No newline at end of file diff --git a/MDM/Models/Process/Dto/ProcessParameterDto.cs b/MDM/Models/Process/Dto/ProcessParameterDto.cs new file mode 100644 index 0000000..088d756 --- /dev/null +++ b/MDM/Models/Process/Dto/ProcessParameterDto.cs @@ -0,0 +1,77 @@ +using System.ComponentModel.DataAnnotations; + +namespace MDM.Model.Process.Dto +{ + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序)查询对象 + /// + public class ProcessParameterQueryDto : PagerInfo + { + + public string FkRoutingCode { get; set; } + + + public string FkOperationCode { get; set; } + + + public string ParameterCode { get; set; } + + public string ParameterName { get; set; } + } + + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序)输入输出对象 + /// + public class ProcessParameterDto + { + [Required(ErrorMessage = "工艺参数ID,主键不能为空")] + public int Id { get; set; } + + [Required(ErrorMessage = "所属工艺路线code不能为空")] + public string FkRoutingCode { get; set; } + + [Required(ErrorMessage = "所属工序code不能为空")] + public string FkOperationCode { get; set; } + + [Required(ErrorMessage = "参数名称,如:温度、压力、时间不能为空")] + public string ParameterCode { get; set; } + + public string ParameterName { get; set; } + + public string Description { get; set; } + + [Required(ErrorMessage = "数据类型:FLOAT, INT, STRING, BOOL, AI(模拟量输入)等不能为空")] + public string DataType { get; set; } + + public string Unit { get; set; } + + public decimal StandardValue { get; set; } + + public decimal MinValue { get; set; } + + public decimal MaxValue { get; set; } + + public string IsControlled { get; set; } + + public string IsMonitored { get; set; } + + public string ControlType { get; set; } + + public decimal DefaultValue { get; set; } + + public string IsRequired { get; set; } + + public int? Sequence { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + public string UpdatedBy { get; set; } + + + + } +} \ No newline at end of file diff --git a/MDM/Models/Process/ProcessOperationWorkstationMapping.cs b/MDM/Models/Process/ProcessOperationWorkstationMapping.cs new file mode 100644 index 0000000..ca50cf3 --- /dev/null +++ b/MDM/Models/Process/ProcessOperationWorkstationMapping.cs @@ -0,0 +1,96 @@ + +using System.ComponentModel.DataAnnotations; + +namespace MDM.Model.Process +{ + /// + /// + /// + [SugarTable("process_operation_workstation_mapping")] + public class ProcessOperationWorkstationMapping + { + /// + /// Id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 工序路线code + /// + [SugarColumn(ColumnName = "fk_routing_code")] + public string FkRoutingCode { get; set; } + + /// + /// 工序code + /// + [SugarColumn(ColumnName = "fk_operation_code")] + public string FkOperationCode { get; set; } + + + /// + /// 生产线体/工作中心code + /// + [SugarColumn(ColumnName = "fk_productlinebody_code")] + public string FkProductlinebodyCode { get; set; } + + /// + /// 工位ID + /// + [SugarColumn(ColumnName = "fk_workstation_code")] + public string FkWorkstationCode { get; set; } + + /// + /// 是否有效:1=有效,0=无效 + /// + [SugarColumn(ColumnName = "is_active")] + public string IsActive { get; set; } + + /// + /// 优先级(可选):如果某工位可执行多个工序,用来排序优先级 + /// + public int? Priority { get; set; } + + /// + /// 标准加工时间(分钟/小时,可选) + /// + [SugarColumn(ColumnName = "standard_time")] + public decimal StandardTime { get; set; } + + /// + /// 准备时间(如换模等,可选) + /// + [SugarColumn(ColumnName = "setup_time")] + public decimal SetupTime { get; set; } + + /// + /// CreatedTime + /// + [SugarColumn(ColumnName = "created_time")] + public DateTime? CreatedTime { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "created_by")] + public string CreatedBy { get; set; } + + /// + /// 备注信息 + /// + public string Remark { get; set; } + + /// + /// UpdatedTime + /// + [SugarColumn(ColumnName = "updated_time")] + public DateTime? UpdatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "updated_by")] + public string UpdatedBy { get; set; } + + } +} \ No newline at end of file diff --git a/MDM/Models/Process/ProcessOprerationTransitionDict.cs b/MDM/Models/Process/ProcessOprerationTransitionDict.cs index 8e0918d..700dc35 100644 --- a/MDM/Models/Process/ProcessOprerationTransitionDict.cs +++ b/MDM/Models/Process/ProcessOprerationTransitionDict.cs @@ -7,17 +7,7 @@ namespace MDM.Model.Process [SugarTable("process_opreration_transition_dict")] public class ProcessOprerationTransitionDict { - /// - /// 更新人 - /// - [SugarColumn(ColumnName = "uPDATED_BY")] - public string UpdatedBy { get; set; } - /// - /// 更新时间 - /// - [SugarColumn(ColumnName = "uPDATED_TIME")] - public DateTime? UpdatedTime { get; set; } /// /// id @@ -54,5 +44,17 @@ namespace MDM.Model.Process [SugarColumn(ColumnName = "cREATED_TIME")] public DateTime? CreatedTime { get; set; } + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "uPDATED_BY")] + public string UpdatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "uPDATED_TIME")] + public DateTime? UpdatedTime { get; set; } + } } \ No newline at end of file diff --git a/MDM/Models/Process/ProcessParameter.cs b/MDM/Models/Process/ProcessParameter.cs new file mode 100644 index 0000000..163fcde --- /dev/null +++ b/MDM/Models/Process/ProcessParameter.cs @@ -0,0 +1,134 @@ + +namespace MDM.Model.Process +{ + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + [SugarTable("process_parameter")] + public class ProcessParameter + { + /// + /// 工艺参数ID,主键 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 所属工艺路线code + /// + [SugarColumn(ColumnName = "fk_routing_code")] + public string FkRoutingCode { get; set; } + + /// + /// 所属工序code + /// + [SugarColumn(ColumnName = "fk_operation_code")] + public string FkOperationCode { get; set; } + + /// + /// 参数名称,如:温度、压力、时间 + /// + [SugarColumn(ColumnName = "parameter_code")] + public string ParameterCode { get; set; } + + /// + /// 显示名称(用于UI展示,可和name一样) + /// + [SugarColumn(ColumnName = "parameter_name")] + public string ParameterName { get; set; } + + /// + /// 参数描述,如:模具温度,用于热压工序 + /// + public string Description { get; set; } + + /// + /// 数据类型:FLOAT, INT, STRING, BOOL, AI(模拟量输入)等 + /// + [SugarColumn(ColumnName = "data_type")] + public string DataType { get; set; } + + /// + /// 单位,如:℃、MPa、秒、mm + /// + public string Unit { get; set; } + + /// + /// 标准/目标值(如目标温度 200.0 ℃) + /// + [SugarColumn(ColumnName = "standard_value")] + public decimal StandardValue { get; set; } + + /// + /// 最小允许值(用于报警/校验) + /// + [SugarColumn(ColumnName = "min_value")] + public decimal MinValue { get; set; } + + /// + /// 最大允许值(用于报警/校验) + /// + [SugarColumn(ColumnName = "max_value")] + public decimal MaxValue { get; set; } + + /// + /// 是否为控制参数:1=是(如PID控制),0=否(仅采集) + /// + [SugarColumn(ColumnName = "is_controlled")] + public string IsControlled { get; set; } + + /// + /// 是否为监控参数(是否采集/显示):1=是,0=否 + /// + [SugarColumn(ColumnName = "is_monitored")] + public string IsMonitored { get; set; } + + /// + /// 控制类型(如PID、ON/OFF、手动设定等,可选) + /// + [SugarColumn(ColumnName = "control_type")] + public string ControlType { get; set; } + + /// + /// 默认值(如未采集时使用) + /// + [SugarColumn(ColumnName = "default_value")] + public decimal DefaultValue { get; set; } + + /// + /// 是否必填/必采:1=是,0=否 + /// + [SugarColumn(ColumnName = "is_required")] + public string IsRequired { get; set; } + + /// + /// 参数排序(用于UI展示顺序) + /// + public int? Sequence { get; set; } + + /// + /// 创建时间 + /// + [SugarColumn(ColumnName = "created_time")] + public DateTime? CreatedTime { get; set; } + + /// + /// 创建人 + /// + [SugarColumn(ColumnName = "created_by")] + public string CreatedBy { get; set; } + + /// + /// 更新时间 + /// + [SugarColumn(ColumnName = "updated_time")] + public DateTime? UpdatedTime { get; set; } + + /// + /// 更新人 + /// + [SugarColumn(ColumnName = "updated_by")] + public string UpdatedBy { get; set; } + + } +} \ No newline at end of file diff --git a/MDM/Services/Plant/IService/IPlantPlcIoPointService.cs b/MDM/Services/Plant/IService/IPlantPlcIoPointService.cs new file mode 100644 index 0000000..6b33fb2 --- /dev/null +++ b/MDM/Services/Plant/IService/IPlantPlcIoPointService.cs @@ -0,0 +1,24 @@ + + +using MDM.Model; +using MDM.Model.Plant; +using MDM.Model.Plant.Dto; +using MDM.Service; + +namespace MDM.Services.IPlantService +{ + /// + /// PLC点位service接口 + /// + public interface IPlantPlcIoPointService : IBaseService + { + PagedInfo GetList(PlantPlcIoPointQueryDto parm); + + PlantPlcIoPoint GetInfo(int Id); + + PlantPlcIoPoint AddPlantPlcIoPoint(PlantPlcIoPoint parm); + + int UpdatePlantPlcIoPoint(PlantPlcIoPoint parm); + + } +} diff --git a/MDM/Services/Plant/PlantPlcIoPointService.cs b/MDM/Services/Plant/PlantPlcIoPointService.cs new file mode 100644 index 0000000..192abf3 --- /dev/null +++ b/MDM/Services/Plant/PlantPlcIoPointService.cs @@ -0,0 +1,116 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; + +using MDM.Services.IPlantService; + +using MDM.Service; +using MDM.Model; +using MDM.Model.Plant; +using MDM.Model.Plant.Dto; +using MDM.Repository; +using SqlSugar.IOC; + +namespace MDM.Services.Plant +{ + /// + /// PLC点位Service业务层处理 + /// + [AppService(ServiceType = typeof(IPlantPlcIoPointService), ServiceLifetime = LifeTime.Transient)] + public class PlantPlcIoPointService : BaseService, IPlantPlcIoPointService + { + private readonly PlcIoPointCacheService _cacheService; + + public PlantPlcIoPointService(PlcIoPointCacheService cacheService) + { + _cacheService = cacheService; + } + /// + /// 查询PLC点位列表 + /// + /// + /// + public PagedInfo GetList(PlantPlcIoPointQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.FkWorkstationCode), it => it.FkWorkstationCode.Contains(parm.FkWorkstationCode)) + .AndIF(!string.IsNullOrEmpty(parm.FkProcessParamCode), it => it.FkProcessParamCode.Contains(parm.FkProcessParamCode)) + .AndIF(!string.IsNullOrEmpty(parm.FkDeviceCode), it => it.FkDeviceCode.Contains(parm.FkDeviceCode)) + ; + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public PlantPlcIoPoint GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加PLC点位 + /// + /// + /// + public PlantPlcIoPoint AddPlantPlcIoPoint(PlantPlcIoPoint model) + { + PlantPlcIoPoint result = Context.Insertable(model).ExecuteReturnEntity(); + if (result != null) + { + var activePoints = Context.Queryable() + .Where(p => p.IsActive == 1) + .ToList(); + _cacheService.InitializeCache(activePoints); + } + return result; + + } + + /// + /// 修改PLC点位 + /// + /// + /// + public int UpdatePlantPlcIoPoint(PlantPlcIoPoint model) + { + //var response = Update(w => w.Id == model.Id, it => new PlantPlcIoPoint() + //{ + // FkWorkstationCode = model.FkWorkstationCode, + // FkProcessParamCode = model.FkProcessParamCode, + // FkDeviceCode = model.FkDeviceCode, + // PointType = model.PointType, + // Address = model.Address, + // IsActive = model.IsActive, + // Description = model.Description, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + int result= Update(model, true); + if (result != null) + { + var activePoints = Context.Queryable() + .Where(p => p.IsActive == 1) + .ToList(); + _cacheService.InitializeCache(activePoints); + } + return result; + } + + } +} \ No newline at end of file diff --git a/MDM/Services/PlcIoPointCacheService.cs b/MDM/Services/PlcIoPointCacheService.cs new file mode 100644 index 0000000..0165d6f --- /dev/null +++ b/MDM/Services/PlcIoPointCacheService.cs @@ -0,0 +1,65 @@ +using Infrastructure.Attribute; +using MDM.Model.Plant; +using MDM.Services.IPlantService; +using System.Collections.Concurrent; +using System.Collections.Generic; + +namespace MDM.Services.Plant +{ + + + /// + /// 用于缓存 PlantPlcIoPoint 数据的服务 + /// + + [AppService(ServiceType = typeof(PlcIoPointCacheService), ServiceLifetime = LifeTime.Singleton)] + public class PlcIoPointCacheService + { + // 使用线程安全的字典缓存所有点位,Key 是点位 ID + private readonly ConcurrentDictionary _pointsById = new(); + + /// + /// 初始化缓存(由 IHostedService 调用) + /// + /// 从数据库加载的点位集合 + public void InitializeCache(IEnumerable points) + { + if (points == null) return; + + // 清空旧数据 + _pointsById.Clear(); + + // 只缓存有效的点位(IsActive == 1) + foreach (var point in points.Where(p => p.IsActive == 1)) + { + if (point.Id > 0) + { + _pointsById[point.Id] = point; + } + } + } + + /// + /// 根据 ID 获取点位 + /// + /// 点位 ID + /// 点位对象,如果不存在返回 null + public PlantPlcIoPoint? GetPointById(int id) + { + _pointsById.TryGetValue(id, out var point); + return point; + } + + /// + /// 获取所有已缓存的点位 + /// + public IEnumerable GetAllCachedPoints() + { + return _pointsById.Values; + } + + // 可根据需要添加更多方法,如: + // - 按 工站 + 设备 分组查询 + // - 按 点位类型、工艺参数等过滤 + } +} diff --git a/MDM/Services/Process/IService/IProcessOperationWorkstationMappingService.cs b/MDM/Services/Process/IService/IProcessOperationWorkstationMappingService.cs new file mode 100644 index 0000000..d5d8119 --- /dev/null +++ b/MDM/Services/Process/IService/IProcessOperationWorkstationMappingService.cs @@ -0,0 +1,23 @@ + +using MDM.Model; +using MDM.Model.Process; +using MDM.Model.Process.Dto; +using MDM.Service; + +namespace MDM.Services.IProcessService +{ + /// + /// service接口 + /// + public interface IProcessOperationWorkstationMappingService : IBaseService + { + PagedInfo GetList(ProcessOperationWorkstationMappingQueryDto parm); + + ProcessOperationWorkstationMapping GetInfo(int Id); + + ProcessOperationWorkstationMapping AddProcessOperationWorkstationMapping(ProcessOperationWorkstationMapping parm); + + int UpdateProcessOperationWorkstationMapping(ProcessOperationWorkstationMapping parm); + + } +} diff --git a/MDM/Services/Process/IService/IProcessParameterService.cs b/MDM/Services/Process/IService/IProcessParameterService.cs new file mode 100644 index 0000000..95b40de --- /dev/null +++ b/MDM/Services/Process/IService/IProcessParameterService.cs @@ -0,0 +1,24 @@ + + +using MDM.Model; +using MDM.Model.Process; +using MDM.Model.Process.Dto; +using MDM.Service; + +namespace MDM.Services.IProcessService +{ + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序)service接口 + /// + public interface IProcessParameterService : IBaseService + { + PagedInfo GetList(ProcessParameterQueryDto parm); + + ProcessParameter GetInfo(int Id); + + ProcessParameter AddProcessParameter(ProcessParameter parm); + + int UpdateProcessParameter(ProcessParameter parm); + + } +} diff --git a/MDM/Services/Process/ProcessOperationWorkstationMappingService.cs b/MDM/Services/Process/ProcessOperationWorkstationMappingService.cs new file mode 100644 index 0000000..77b533a --- /dev/null +++ b/MDM/Services/Process/ProcessOperationWorkstationMappingService.cs @@ -0,0 +1,91 @@ + +using Infrastructure.Attribute; +using MDM.Model; +using MDM.Model.Process; +using MDM.Model.Process.Dto; +using MDM.Repository; +using MDM.Service; +using MDM.Services.IProcessService; +namespace MDM.Services.Process +{ + /// + /// Service业务层处理 + /// + [AppService(ServiceType = typeof(IProcessOperationWorkstationMappingService), ServiceLifetime = LifeTime.Transient)] + public class ProcessOperationWorkstationMappingService : BaseService, IProcessOperationWorkstationMappingService + { + /// + /// 查询列表 + /// + /// + /// + public PagedInfo GetList(ProcessOperationWorkstationMappingQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.FkRoutingCode), m => m.FkRoutingCode.Contains(parm.FkRoutingCode)) + .AndIF(!string.IsNullOrEmpty(parm.FkOperationCode), m => m.FkOperationCode.Contains(parm.FkOperationCode)) + .AndIF(!string.IsNullOrEmpty(parm.FkWorkstationCode), m => m.FkWorkstationCode.Contains(parm.FkWorkstationCode)) + .AndIF(!string.IsNullOrEmpty(parm.FkProductlinebodyCode), m => m.FkProductlinebodyCode.Contains(parm.FkProductlinebodyCode)) + + + ; + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public ProcessOperationWorkstationMapping GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加 + /// + /// + /// + public ProcessOperationWorkstationMapping AddProcessOperationWorkstationMapping(ProcessOperationWorkstationMapping model) + { + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改 + /// + /// + /// + public int UpdateProcessOperationWorkstationMapping(ProcessOperationWorkstationMapping model) + { + //var response = Update(w => w.Id == model.Id, it => new ProcessOperationWorkstationMapping() + //{ + // FkOperationCode = model.FkOperationCode, + // FkWorkstationCode = model.FkWorkstationCode, + // IsActive = model.IsActive, + // Priority = model.Priority, + // StandardTime = model.StandardTime, + // SetupTime = model.SetupTime, + // CreatedTime = model.CreatedTime, + // CreatedBy = model.CreatedBy, + // Remark = model.Remark, + // UpdatedTime = model.UpdatedTime, + // UpdatedBy = model.UpdatedBy, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/MDM/Services/Process/ProcessParameterService.cs b/MDM/Services/Process/ProcessParameterService.cs new file mode 100644 index 0000000..3a20dd3 --- /dev/null +++ b/MDM/Services/Process/ProcessParameterService.cs @@ -0,0 +1,100 @@ + +using Infrastructure.Attribute; +using MDM.Model; +using MDM.Model.Process; +using MDM.Model.Process.Dto; +using MDM.Repository; +using MDM.Service; +using MDM.Services.IProcessService; +namespace MDM.Services.Process +{ + /// + /// 工艺参数表(如温度、压力、时间等,关联工艺路线与工序)Service业务层处理 + /// + [AppService(ServiceType = typeof(IProcessParameterService), ServiceLifetime = LifeTime.Transient)] + public class ProcessParameterService : BaseService, IProcessParameterService + { + /// + /// 查询工艺参数表(如温度、压力、时间等,关联工艺路线与工序)列表 + /// + /// + /// + public PagedInfo GetList(ProcessParameterQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.FkRoutingCode), it => it.FkRoutingCode.Contains(parm.FkRoutingCode)) + .AndIF(!string.IsNullOrEmpty(parm.FkOperationCode), it => it.FkOperationCode.Contains(parm.FkOperationCode)) + .AndIF(!string.IsNullOrEmpty(parm.ParameterCode), it => it.ParameterCode.Contains(parm.ParameterCode)) + .AndIF(!string.IsNullOrEmpty(parm.ParameterName), it => it.ParameterName.Contains(parm.ParameterName)) + + + ; + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public ProcessParameter GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + /// + /// + public ProcessParameter AddProcessParameter(ProcessParameter model) + { + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改工艺参数表(如温度、压力、时间等,关联工艺路线与工序) + /// + /// + /// + public int UpdateProcessParameter(ProcessParameter model) + { + //var response = Update(w => w.Id == model.Id, it => new ProcessParameter() + //{ + // FkRoutingCode = model.FkRoutingCode, + // FkOperationCode = model.FkOperationCode, + // ParameterCode = model.ParameterCode, + // ParameterName = model.ParameterName, + // Description = model.Description, + // DataType = model.DataType, + // Unit = model.Unit, + // StandardValue = model.StandardValue, + // MinValue = model.MinValue, + // MaxValue = model.MaxValue, + // IsControlled = model.IsControlled, + // IsMonitored = model.IsMonitored, + // ControlType = model.ControlType, + // DefaultValue = model.DefaultValue, + // IsRequired = model.IsRequired, + // Sequence = model.Sequence, + // CreatedTime = model.CreatedTime, + // CreatedBy = model.CreatedBy, + // UpdatedTime = model.UpdatedTime, + // UpdatedBy = model.UpdatedBy, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/RIZO.Admin.WebApi/appsettings.Development.json b/RIZO.Admin.WebApi/appsettings.Development.json index 0ead192..ebfbf1f 100644 --- a/RIZO.Admin.WebApi/appsettings.Development.json +++ b/RIZO.Admin.WebApi/appsettings.Development.json @@ -1,7 +1,7 @@ { "dbConfigs": [ { - //"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=ay2509055-guiyang-fluorescence-lmes;Port=3308;", + //"Conn": "Data Source=139.224.232.211;User ID=root;Password=RIZOtech123;Initial Catalog=ay2509055-guiyang-fluorescence-lmes;Port=3308;", "Conn": "Data Source=192.168.1.48;User ID=root;Password=123456;Initial Catalog=ay2509055-guiyang-fluorescence-lmes;Port=3306;", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 @@ -12,7 +12,7 @@ //代码生成数据库配置 "CodeGenDbConfig": { //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 - //"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog={dbName};Port=3308;", + //"Conn": "Data Source=139.224.232.211;User ID=root;Password=RIZOtech123;Initial Catalog={dbName};Port=3308;", "Conn": "Data Source=192.168.1.48;User ID=root;Password=123456;Initial Catalog={dbName};Port=3306;", "DbType": 0, "IsAutoCloseConnection": true, diff --git a/RIZO.Admin.WebApi/appsettings.Production.json b/RIZO.Admin.WebApi/appsettings.Production.json index 4451d3e..e23491d 100644 --- a/RIZO.Admin.WebApi/appsettings.Production.json +++ b/RIZO.Admin.WebApi/appsettings.Production.json @@ -1,7 +1,7 @@ { "dbConfigs": [ { - //"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog=ay2509055-guiyang-fluoresence-lmes;Port=3306;SslMode=Required", + //"Conn": "Data Source=139.224.232.211;User ID=root;Password=RIZOtech123;Initial Catalog=ay2509055-guiyang-fluoresence-lmes;Port=3306;SslMode=Required", "Conn": "Data Source=192.168.1.48;User ID=root;Password=123456;Initial Catalog=ay2509055-guiyang-fluoresence-lmes;Port=3306;SslMode=Required", "DbType": 0, //数据库类型 MySql = 0, SqlServer = 1, Oracle = 3,PgSql = 4 "ConfigId": "0", //多租户唯一标识 @@ -12,7 +12,7 @@ //代码生成数据库配置 "CodeGenDbConfig": { //代码生成连接字符串,注意{dbName}为固定格式,不要填写数据库名 - //"Conn": "Data Source=139.224.232.211;User ID=root;Password=doantech123;Initial Catalog={dbName};", + //"Conn": "Data Source=139.224.232.211;User ID=root;Password=RIZOtech123;Initial Catalog={dbName};", "Conn": "Data Source=192.168.1.48;User ID=root;Password=123456;Initial Catalog={dbName};", "DbType": 1, "IsAutoCloseConnection": true,