From ca725130e1e6985256902ef1c3d2a9af80d5064f Mon Sep 17 00:00:00 2001 From: "qianhao.xu" Date: Tue, 10 Dec 2024 14:34:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MES/Device/DeviceAccountController.cs | 236 ++++++ .../MES/Device/DeviceFormConfigController.cs | 111 +++ .../MES/Device/DeviceInspectController.cs | 177 ++++ .../DeviceMaintenanceRecordController.cs | 109 +++ .../DevicePointInspectionPlanController.cs | 110 +++ .../MES/Device/DeviceRepairController.cs | 109 +++ .../DeviceRouteInspectionPlanController.cs | 109 +++ .../MES/Device/DeviceTaskExecuteController.cs | 357 ++++++++ .../DeviceTaskExecuteResultController.cs | 110 +++ .../MES/Device/DeviceTypeController.cs | 107 +++ DOAN.Model/MES/Device/DeviceAccount.cs | 103 +++ DOAN.Model/MES/Device/DeviceFormConfig.cs | 62 ++ DOAN.Model/MES/Device/DeviceInspect.cs | 73 ++ .../MES/Device/DeviceMaintenanceRecord.cs | 69 ++ .../MES/Device/DevicePointInspectionPlan.cs | 68 ++ .../MES/Device/DeviceRelAccountInspect.cs | 57 ++ DOAN.Model/MES/Device/DeviceRelPpAt.cs | 57 ++ DOAN.Model/MES/Device/DeviceRelRpAt.cs | 57 ++ DOAN.Model/MES/Device/DeviceRepair.cs | 85 ++ .../MES/Device/DeviceRouteInspectionPlan.cs | 102 +++ DOAN.Model/MES/Device/DeviceTaskExecute.cs | 92 ++ .../MES/Device/DeviceTaskExecuteResult.cs | 136 +++ DOAN.Model/MES/Device/DeviceType.cs | 67 ++ DOAN.Model/MES/Device/Dto/DeviceAccountDto.cs | 127 +++ DOAN.Model/MES/Device/Dto/DeviceDefaultDto.cs | 59 ++ .../MES/Device/Dto/DeviceFormConfigDto.cs | 42 + DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs | 74 ++ .../Device/Dto/DeviceMaintenanceRecordDto.cs | 41 + .../Dto/DevicePointInspectionPlanDto.cs | 46 + DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs | 78 ++ .../Dto/DeviceRouteInspectionPlanDto.cs | 61 ++ .../MES/Device/Dto/DeviceStatusAnalysisDto.cs | 101 +++ .../Dto/DeviceStatusAnalysisResultDto.cs | 218 +++++ .../MES/Device/Dto/DeviceTaskExecuteDto.cs | 160 ++++ .../Device/Dto/DeviceTaskExecuteResultDto.cs | 98 +++ DOAN.Model/MES/Device/Dto/DeviceTypeDto.cs | 48 ++ DOAN.Model/TreeDto.cs | 21 + .../MES/Device/DeviceAccountService.cs | 690 +++++++++++++++ .../MES/Device/DeviceDataAnalysisService.cs | 614 ++++++++++++++ .../MES/Device/DeviceFormConfigService.cs | 85 ++ .../MES/Device/DeviceInspectService.cs | 192 +++++ .../Device/DeviceMaintenanceRecordService.cs | 89 ++ .../DevicePointInspectionPlanService.cs | 93 ++ .../MES/Device/DeviceRepairService.cs | 138 +++ .../DeviceRouteInspectionPlanService.cs | 136 +++ .../Device/DeviceTaskExecuteResultService.cs | 99 +++ .../MES/Device/DeviceTaskExecuteService.cs | 802 ++++++++++++++++++ DOAN.Service/MES/Device/DeviceTypeService.cs | 96 +++ .../Device/IService/IDeviceAccountService.cs | 43 + .../IService/IDeviceDataAnalysisServcie.cs | 28 + .../IService/IDeviceFormConfigService.cs | 23 + .../Device/IService/IDeviceInspectService.cs | 31 + .../IDeviceMaintenanceRecordService.cs | 23 + .../IDevicePointInspectionPlanService.cs | 23 + .../Device/IService/IDeviceRepairService.cs | 23 + .../IDeviceRouteInspectionPlanService.cs | 23 + .../IDeviceTaskExecuteResultService.cs | 24 + .../IService/IDeviceTaskExecuteService.cs | 55 ++ .../MES/Device/IService/IDeviceTypeService.cs | 26 + .../WebExtensions/EntityExtension.cs | 22 + 60 files changed, 7115 insertions(+) create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceAccountController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceFormConfigController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceInspectController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceMaintenanceRecordController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DevicePointInspectionPlanController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRepairController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRouteInspectionPlanController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteResultController.cs create mode 100644 DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTypeController.cs create mode 100644 DOAN.Model/MES/Device/DeviceAccount.cs create mode 100644 DOAN.Model/MES/Device/DeviceFormConfig.cs create mode 100644 DOAN.Model/MES/Device/DeviceInspect.cs create mode 100644 DOAN.Model/MES/Device/DeviceMaintenanceRecord.cs create mode 100644 DOAN.Model/MES/Device/DevicePointInspectionPlan.cs create mode 100644 DOAN.Model/MES/Device/DeviceRelAccountInspect.cs create mode 100644 DOAN.Model/MES/Device/DeviceRelPpAt.cs create mode 100644 DOAN.Model/MES/Device/DeviceRelRpAt.cs create mode 100644 DOAN.Model/MES/Device/DeviceRepair.cs create mode 100644 DOAN.Model/MES/Device/DeviceRouteInspectionPlan.cs create mode 100644 DOAN.Model/MES/Device/DeviceTaskExecute.cs create mode 100644 DOAN.Model/MES/Device/DeviceTaskExecuteResult.cs create mode 100644 DOAN.Model/MES/Device/DeviceType.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceAccountDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceDefaultDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisResultDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceTaskExecuteDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceTaskExecuteResultDto.cs create mode 100644 DOAN.Model/MES/Device/Dto/DeviceTypeDto.cs create mode 100644 DOAN.Model/TreeDto.cs create mode 100644 DOAN.Service/MES/Device/DeviceAccountService.cs create mode 100644 DOAN.Service/MES/Device/DeviceDataAnalysisService.cs create mode 100644 DOAN.Service/MES/Device/DeviceFormConfigService.cs create mode 100644 DOAN.Service/MES/Device/DeviceInspectService.cs create mode 100644 DOAN.Service/MES/Device/DeviceMaintenanceRecordService.cs create mode 100644 DOAN.Service/MES/Device/DevicePointInspectionPlanService.cs create mode 100644 DOAN.Service/MES/Device/DeviceRepairService.cs create mode 100644 DOAN.Service/MES/Device/DeviceRouteInspectionPlanService.cs create mode 100644 DOAN.Service/MES/Device/DeviceTaskExecuteResultService.cs create mode 100644 DOAN.Service/MES/Device/DeviceTaskExecuteService.cs create mode 100644 DOAN.Service/MES/Device/DeviceTypeService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceAccountService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceDataAnalysisServcie.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceFormConfigService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceInspectService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceMaintenanceRecordService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDevicePointInspectionPlanService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceRepairService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceRouteInspectionPlanService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceTaskExecuteResultService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceTaskExecuteService.cs create mode 100644 DOAN.Service/MES/Device/IService/IDeviceTypeService.cs diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceAccountController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceAccountController.cs new file mode 100644 index 0000000..82b8e20 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceAccountController.cs @@ -0,0 +1,236 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Model.Dto; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; + +//创建时间:2024-05-20 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 设备台账 + /// + [Verify] + [Route("mes/deviceManagement/DeviceAccount")] + public class DeviceAccountController : BaseController + { + /// + /// 设备台账接口 + /// + private readonly IDeviceAccountService _DeviceAccountService; + + public DeviceAccountController(IDeviceAccountService DeviceAccountService) + { + _DeviceAccountService = DeviceAccountService; + } + + /// + /// 查询设备台账列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:list")] + public IActionResult QueryDeviceAccount([FromQuery] DeviceAccountQueryDto parm) + { + var response = _DeviceAccountService.GetList(parm); + return SUCCESS(response); + } + + + + + + /// + /// 查询绑定或者未绑定巡检任务的设备台账 + /// + /// + /// + [HttpGet("list_route_inspect")] + [AllowAnonymous] + public IActionResult QueryDeviceAccount_Route([FromQuery] DeviceAccountQueryDto2 parm) + { + var response = _DeviceAccountService.GetList_Route(parm); + return SUCCESS(response); + } + + + /// + /// 查询设备台账详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:query")] + public IActionResult GetDeviceAccount(int Id) + { + var response = _DeviceAccountService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加设备台账 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:add")] + [Log(Title = "设备台账", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceAccount([FromBody] DeviceAccountDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceAccountService.AddDeviceAccount(modal); + + return SUCCESS(response); + } + + /// + /// 更新设备台账 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:edit")] + [Log(Title = "设备台账", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceAccount([FromBody] DeviceAccountDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceAccountService.UpdateDeviceAccount(modal); + + return ToResponse(response); + } + + /// + /// 删除设备台账 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:delete")] + [Log(Title = "设备台账", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceAccount(string ids) + { + string[] idsArr = ids.Split(','); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceAccountService.Delete(idsArr); + + return ToResponse(response); + } + + /// + /// 获取设备下拉选择树 + /// + /// + /// + [HttpGet("getSelectTree")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceaccount:list")] + public IActionResult GetSelectTree([FromQuery] DeviceAccountQueryDto parm) + { + try + { + var response = _DeviceAccountService.GetSelectTree(parm); + return SUCCESS(response); + } + catch (Exception ex) + { + return ToResponse(ApiResult.Error(500, ex.Message)); + } + + } + + + /// + /// 添加绑定关系 巡检计划和设备台账 + /// + /// + /// + [HttpPost("AddRelation")] + [AllowAnonymous] + public IActionResult AddRelation([FromBody] DeviceAccount_routeinspect_Dto parm) + { + if (parm == null || parm.FkDeviceAccountIdList == null) + { + SUCCESS(null); + } + var response = _DeviceAccountService.AddRelation(parm, HttpContext.GetName()); + return SUCCESS(response); + } + + + /// + /// 删除关系 + /// + /// + /// + /// + [HttpGet("remove_relation")] + public IActionResult Remove_relation(string FkRouteInspectionPlanId,int FkDeviceAccountId) + { + var response = _DeviceAccountService.Remove_relation(FkRouteInspectionPlanId, FkDeviceAccountId); + return SUCCESS(response); + } + + /// + /// 查询绑定或者未绑定点检任务的设备台账 + /// + /// + /// + [HttpGet("list_point_inspect")] + [AllowAnonymous] + public IActionResult QueryDeviceAccount_point([FromQuery] DeviceAccountQueryDto3 parm) + { + var response = _DeviceAccountService.GetList_Point(parm); + return SUCCESS(response); + } + + + + + /// + /// 添加绑定关系 点检计划和设备台账 + /// + /// + /// + [HttpPost("AddRelation_point_account")] + [AllowAnonymous] + public IActionResult AddRelationPointAccount([FromBody] DeviceAccount_pointinspect_Dto parm) + { + if (parm == null || parm.FkDeviceAccountIdList == null) + { + SUCCESS(null); + } + var response = _DeviceAccountService.AddRelationPointAccount(parm, HttpContext.GetName()); + return SUCCESS(response); + } + + + /// + /// 删除关系 + /// + /// + /// + /// + [HttpGet("remove_relation_point_account")] + public IActionResult RemoveRelationPointAccount(string FkPointInspectionPlanId, int FkDeviceAccountId) + { + var response = _DeviceAccountService.RemoveRelationPointAccount(FkPointInspectionPlanId, FkDeviceAccountId); + return SUCCESS(response); + } + + + /// + /// 获取设备状态 设备看板用 + /// + /// 设备类型id + /// + [HttpGet("getDeviceStatusBoardData")] + public IActionResult GetDeviceStatus(int devicetype_id) + { + DeviceStatusAnalysisDto response= _DeviceAccountService.GetDeviceStatus(devicetype_id); + return SUCCESS(response); + } + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceFormConfigController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceFormConfigController.cs new file mode 100644 index 0000000..51a7226 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceFormConfigController.cs @@ -0,0 +1,111 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Model.Dto; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; + +using DOAN.Model.MES.dev; + +//创建时间:2024-05-22 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 设备检查项表单配置表 + /// + [Verify] + [Route("mes/deviceManagement/DeviceFormConfig")] + public class DeviceFormConfigController : BaseController + { + /// + /// 设备检查项表单配置表接口 + /// + private readonly IDeviceFormConfigService _DeviceFormConfigService; + + public DeviceFormConfigController(IDeviceFormConfigService DeviceFormConfigService) + { + _DeviceFormConfigService = DeviceFormConfigService; + } + + /// + /// 查询设备检查项表单配置表列表 + /// + /// + /// + [HttpGet("list")] + [ActionPermissionFilter(Permission = "business:deviceformconfig:list")] + public IActionResult QueryDeviceFormConfig([FromQuery] DeviceFormConfigQueryDto parm) + { + var response = _DeviceFormConfigService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询设备检查项表单配置表详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:deviceformconfig:query")] + public IActionResult GetDeviceFormConfig(string Id) + { + var response = _DeviceFormConfigService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加设备检查项表单配置表 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:deviceformconfig:add")] + [Log(Title = "设备检查项表单配置表", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceFormConfig([FromBody] DeviceFormConfigDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceFormConfigService.AddDeviceFormConfig(modal); + + return SUCCESS(response); + } + + /// + /// 更新设备检查项表单配置表 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:deviceformconfig:edit")] + [Log(Title = "设备检查项表单配置表", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceFormConfig([FromBody] DeviceFormConfigDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceFormConfigService.UpdateDeviceFormConfig(modal); + + return ToResponse(response); + } + + /// + /// 删除设备检查项表单配置表 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:deviceformconfig:delete")] + [Log(Title = "设备检查项表单配置表", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceFormConfig(string ids) + { + + string[] strIds = ids.Split(",", (char)StringSplitOptions.RemoveEmptyEntries); + if (strIds.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceFormConfigService.Delete(strIds); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceInspectController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceInspectController.cs new file mode 100644 index 0000000..e647f76 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceInspectController.cs @@ -0,0 +1,177 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Model.Dto; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; + +using DOAN.Model.MES.dev; +using Org.BouncyCastle.Crypto; +using Aliyun.OSS; + +//创建时间:2024-05-21 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 设备检查项 + /// + [Verify] + [Route("mes/deviceManagement/DeviceInspect")] + public class DeviceInspectController : BaseController + { + /// + /// 设备检查项接口 + /// + private readonly IDeviceInspectService _DeviceInspectService; + + public DeviceInspectController(IDeviceInspectService DeviceInspectService) + { + _DeviceInspectService = DeviceInspectService; + } + + /// + /// 查询设备检查项列表 + /// + /// + /// + [HttpGet("list")] + + public IActionResult QueryDeviceInspect([FromQuery] DeviceInspectQueryDto parm) + { + var response = _DeviceInspectService.GetList(parm); + return SUCCESS(response); + } + + /// + /// 设备绑定模块 查询未绑定且状态为1 的设备检查项 Isbind=1 获取已经绑定 Isbind=0 获取未绑定 + /// + /// + /// + [HttpGet("list2")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceinspect:list")] + public IActionResult QueryDeviceInspect2([FromQuery] DeviceInspectQueryDto2 parm) + { + var response = _DeviceInspectService.GetList2(parm); + return SUCCESS(response); + } + + /// + /// 查询设备检查项详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceinspect:query")] + public IActionResult GetDeviceInspect(int Id) + { + var response = _DeviceInspectService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加设备检查项 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "deviceManagement:deviceinspect:add")] + [Log(Title = "设备检查项", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceInspect([FromBody] DeviceInspectDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceInspectService.AddDeviceInspect(modal); + + return SUCCESS(response); + } + + /// + /// 更新设备检查项 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "deviceManagement:deviceinspect:edit")] + [Log(Title = "设备检查项", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceInspect([FromBody] DeviceInspectDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceInspectService.UpdateDeviceInspect(modal); + + return ToResponse(response); + } + + /// + /// 删除设备检查项 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "deviceManagement:deviceinspect:delete")] + [Log(Title = "设备检查项", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceInspect(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceInspectService.Delete(idsArr); + + return ToResponse(response); + } + + + /// + /// 增加设备和设备检查项绑定关系 + /// + /// + /// + [HttpPost("addbind")] + public IActionResult AddBindrelative([FromBody] DeviceInspectQueryDto3 parm) + { + if (parm == null) + { + return SUCCESS(null); + } + var response = _DeviceInspectService.AddBindrelative(parm,HttpContext.GetName()); + + return SUCCESS(response); + + } + + /// + /// 删除设备和设备检查项绑定关系 + /// + /// + /// + /// + [HttpGet("removebind")] + public IActionResult RemoveBindrelative(int account_id, int inspect_id) + { + if (inspect_id <= 0 || account_id <= 0) + { + return SUCCESS(null); + } + var response = _DeviceInspectService.RemoveBindrelative(account_id, inspect_id); + + return SUCCESS(response); + } + + /// + /// 排关系 + /// + /// + /// + [HttpPost("sort")] + public IActionResult SortBindrelative([FromBody] List parm) + { + if (parm == null) + { + return SUCCESS(null); + } + + var modal = parm.ToUpdate(HttpContext); + var response = _DeviceInspectService.SortBindrelative(parm); + + return SUCCESS(response); + } + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceMaintenanceRecordController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceMaintenanceRecordController.cs new file mode 100644 index 0000000..6819c71 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceMaintenanceRecordController.cs @@ -0,0 +1,109 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; + +//创建时间:2024-05-27 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 维修记录 + /// + [Verify] + [Route("mes/deviceManagement/DeviceMaintenanceRecord")] + public class DeviceMaintenanceRecordController : BaseController + { + /// + /// 维修记录接口 + /// + private readonly IDeviceMaintenanceRecordService _DeviceMaintenanceRecordService; + + public DeviceMaintenanceRecordController(IDeviceMaintenanceRecordService DeviceMaintenanceRecordService) + { + _DeviceMaintenanceRecordService = DeviceMaintenanceRecordService; + } + + /// + /// 查询维修记录列表 + /// + /// + /// + [HttpGet("list")] + // [ActionPermissionFilter(Permission = "business:devicemaintenancerecord:list")] + public IActionResult QueryDeviceMaintenanceRecord([FromQuery] DeviceMaintenanceRecordQueryDto parm) + { + var response = _DeviceMaintenanceRecordService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询维修记录详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:devicemaintenancerecord:query")] + public IActionResult GetDeviceMaintenanceRecord(string Id) + { + var response = _DeviceMaintenanceRecordService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加维修记录 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "business:devicemaintenancerecord:add")] + [Log(Title = "维修记录", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceMaintenanceRecord([FromBody] DeviceMaintenanceRecordDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceMaintenanceRecordService.AddDeviceMaintenanceRecord(modal); + + return SUCCESS(response); + } + + /// + /// 更新维修记录 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "business:devicemaintenancerecord:edit")] + [Log(Title = "维修记录", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceMaintenanceRecord([FromBody] DeviceMaintenanceRecordDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceMaintenanceRecordService.UpdateDeviceMaintenanceRecord(modal); + + return ToResponse(response); + } + + /// + /// 删除维修记录 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:devicemaintenancerecord:delete")] + [Log(Title = "维修记录", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceMaintenanceRecord(string ids) + { + string[] idsArr = ids.Split(','); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceMaintenanceRecordService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DevicePointInspectionPlanController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DevicePointInspectionPlanController.cs new file mode 100644 index 0000000..b420410 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DevicePointInspectionPlanController.cs @@ -0,0 +1,110 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; + +//创建时间:2024-05-27 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 点检任务 + /// + [Verify] + [Route("mes/deviceManagement/DevicePointInspectionPlan")] + public class DevicePointInspectionPlanController : BaseController + { + /// + /// 点检任务接口 + /// + private readonly IDevicePointInspectionPlanService _DevicePointInspectionPlanService; + + public DevicePointInspectionPlanController(IDevicePointInspectionPlanService DevicePointInspectionPlanService) + { + _DevicePointInspectionPlanService = DevicePointInspectionPlanService; + } + + /// + /// 查询点检任务列表 + /// + /// + /// + [HttpGet("list")] + + public IActionResult QueryDevicePointInspectionPlan([FromQuery] DevicePointInspectionPlanQueryDto parm) + { + var response = _DevicePointInspectionPlanService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询点检任务详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicepointinspectionplan:query")] + public IActionResult GetDevicePointInspectionPlan(string Id) + { + var response = _DevicePointInspectionPlanService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加点检任务 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "deviceManagement:devicepointinspectionplan:add")] + [Log(Title = "点检任务", BusinessType = BusinessType.INSERT)] + public IActionResult AddDevicePointInspectionPlan([FromBody] DevicePointInspectionPlanDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DevicePointInspectionPlanService.AddDevicePointInspectionPlan(modal); + + return SUCCESS(response); + } + + /// + /// 更新点检任务 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "deviceManagement:devicepointinspectionplan:edit")] + [Log(Title = "点检任务", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDevicePointInspectionPlan([FromBody] DevicePointInspectionPlanDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DevicePointInspectionPlanService.UpdateDevicePointInspectionPlan(modal); + + return ToResponse(response); + } + + /// + /// 删除点检任务 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicepointinspectionplan:delete")] + [Log(Title = "点检任务", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDevicePointInspectionPlan(string ids) + { + string[] idsArr = ids.Split(','); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DevicePointInspectionPlanService.Delete(idsArr); + + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRepairController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRepairController.cs new file mode 100644 index 0000000..a2de5db --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRepairController.cs @@ -0,0 +1,109 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; + +//创建时间:2024-05-28 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 报修单 + /// + [Verify] + [Route("business/DeviceRepair")] + public class DeviceRepairController : BaseController + { + /// + /// 报修单接口 + /// + private readonly IDeviceRepairService _DeviceRepairService; + + public DeviceRepairController(IDeviceRepairService DeviceRepairService) + { + _DeviceRepairService = DeviceRepairService; + } + + /// + /// 查询报修单列表 + /// + /// + /// + [HttpPost("list")] + + public IActionResult QueryDeviceRepair([FromBody] DeviceRepairQueryDto parm) + { + var response = _DeviceRepairService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询报修单详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicerepair:query")] + public IActionResult GetDeviceRepair(string Id) + { + var response = _DeviceRepairService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加报修单 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "deviceManagement:devicerepair:add")] + [Log(Title = "报修单", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceRepair([FromBody] DeviceRepairDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceRepairService.AddDeviceRepair(modal); + + return SUCCESS(response); + } + + /// + /// 更新报修单 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "deviceManagement:devicerepair:edit")] + [Log(Title = "报修单", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceRepair([FromBody] DeviceRepairDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceRepairService.UpdateDeviceRepair(modal); + + return ToResponse(response); + } + + /// + /// 删除报修单 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicerepair:delete")] + [Log(Title = "报修单", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceRepair(string ids) + { + string[] idsArr = ids.Split(','); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceRepairService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRouteInspectionPlanController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRouteInspectionPlanController.cs new file mode 100644 index 0000000..6a6fece --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceRouteInspectionPlanController.cs @@ -0,0 +1,109 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; + +//创建时间:2024-05-27 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 巡检计划 + /// + [Verify] + [Route("mes/deviceManagement/DeviceRouteInspectionPlan")] + public class DeviceRouteInspectionPlanController : BaseController + { + /// + /// 巡检计划接口 + /// + private readonly IDeviceRouteInspectionPlanService _DeviceRouteInspectionPlanService; + + public DeviceRouteInspectionPlanController(IDeviceRouteInspectionPlanService DeviceRouteInspectionPlanService) + { + _DeviceRouteInspectionPlanService = DeviceRouteInspectionPlanService; + } + + /// + /// 查询巡检计划列表 + /// + /// + /// + [HttpGet("list")] + + public IActionResult QueryDeviceRouteInspectionPlan([FromQuery] DeviceRouteInspectionPlanQueryDto parm) + { + var response = _DeviceRouteInspectionPlanService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询巡检计划详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicerouteinspectionplan:query")] + public IActionResult GetDeviceRouteInspectionPlan(string Id) + { + var response = _DeviceRouteInspectionPlanService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加巡检计划 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "deviceManagement:devicerouteinspectionplan:add")] + [Log(Title = "巡检计划", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceRouteInspectionPlan([FromBody] DeviceRouteInspectionPlanDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceRouteInspectionPlanService.AddDeviceRouteInspectionPlan(modal); + + return SUCCESS(response); + } + + /// + /// 更新巡检计划 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "deviceManagement:devicerouteinspectionplan:edit")] + [Log(Title = "巡检计划", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceRouteInspectionPlan([FromBody] DeviceRouteInspectionPlanDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceRouteInspectionPlanService.UpdateDeviceRouteInspectionPlan(modal); + + return ToResponse(response); + } + + /// + /// 删除巡检计划 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicerouteinspectionplan:delete")] + [Log(Title = "巡检计划", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceRouteInspectionPlan(string ids) + { + string[] idsArr = ids.Split(','); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceRouteInspectionPlanService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteController.cs new file mode 100644 index 0000000..03c4d9e --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteController.cs @@ -0,0 +1,357 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Model.Dto; + +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev.Dto; +using DOAN.Admin.WebApi.Filters; +using MiniExcelLibs; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using Org.BouncyCastle.Crypto; + +//创建时间:2024-05-31 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 任务执行 + /// + [Verify] + [Route("mes/deviceManagement/DeviceTaskExecute")] + public class DeviceTaskExecuteController : BaseController + { + /// + /// 任务执行接口 + /// + private readonly IDeviceTaskExecuteService _DeviceTaskExecuteService; + + public DeviceTaskExecuteController(IDeviceTaskExecuteService DeviceTaskExecuteService) + { + _DeviceTaskExecuteService = DeviceTaskExecuteService; + } + + /// + /// 查询任务执行列表 + /// + /// + /// + [HttpPost("list")] + + public IActionResult QueryDeviceTaskExecute([FromBody] DeviceTaskExecuteQueryDto parm) + { + var response = _DeviceTaskExecuteService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询任务执行详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:query")] + public IActionResult GetDeviceTaskExecute(string Id) + { + var response = _DeviceTaskExecuteService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加任务执行 + /// + /// + [HttpPost] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:add")] + [Log(Title = "任务执行", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceTaskExecute([FromBody] DeviceTaskExecuteDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext).ToUpdate(HttpContext); + + var response = _DeviceTaskExecuteService.AddDeviceTaskExecute(modal); + + return SUCCESS(response); + } + + /// + /// 更新任务执行 + /// + /// + [HttpPut] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:edit")] + [Log(Title = "任务执行", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceTaskExecute([FromBody] DeviceTaskExecuteDto parm) + { + + Console.WriteLine(HttpContext.User?.Identity?.Name); + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceTaskExecuteService.UpdateDeviceTaskExecute(modal); + + return ToResponse(response); + } + + /// + /// 更改任务状态 + /// + /// + /// + [HttpGet("update_task_status")] + public IActionResult Update_task_status([FromQuery]DeviceTaskExecuteQueryDto2 parm) + { + if(parm == null) + { + return SUCCESS(null); + } + parm.ToUpdate(); + var response = _DeviceTaskExecuteService.Update_task_status(parm); + + return ToResponse(response); + + } + + /// + /// 删除任务执行 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:delete")] + [Log(Title = "任务执行", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceTaskExecute(string ids) + { + + if(string.IsNullOrEmpty(ids)) + { + return SUCCESS(null); + } + string[] idsArr = ids.Split(","); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceTaskExecuteService.Delete(idsArr); + + return ToResponse(response); + } + + /// + /// 导出任务执行 + /// + /// + [Log(Title = "任务执行", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [HttpGet("export")] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:export")] + public IActionResult Export([FromQuery] DeviceTaskExecuteQueryDto parm) + { + parm.PageNum = 1; + parm.PageSize = 100000; + var list = _DeviceTaskExecuteService.GetList(parm).Result; + if (list == null || list.Count <= 0) + { + return ToResponse(ResultCode.FAIL, "没有要导出的数据"); + } + var result = ExportExcelMini(list, "任务执行", "任务执行"); + return ExportExcel(result.Item2, result.Item1); + } + + /// + /// 清空任务执行 + /// + /// + [Log(Title = "任务执行", BusinessType = BusinessType.CLEAN)] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:delete")] + [HttpDelete("clean")] + public IActionResult Clear() + { + if (!HttpContextExtension.IsAdmin(HttpContext)) + { + return ToResponse(ResultCode.FAIL, "操作失败"); + } + return SUCCESS(_DeviceTaskExecuteService.TruncateDeviceTaskExecute()); + } + + /// + /// 导入 + /// + /// + /// + [HttpPost("importData")] + [Log(Title = "任务执行导入", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false)] + [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecute:import")] + public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile) + { + List list = new(); + using (var stream = formFile.OpenReadStream()) + { + list = stream.Query(startCell: "A1").ToList(); + } + + return SUCCESS(_DeviceTaskExecuteService.ImportDeviceTaskExecute(list.Adapt>())); + } + + /// + /// 任务执行导入模板下载 + /// + /// + [HttpGet("importTemplate")] + [Log(Title = "任务执行模板", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [AllowAnonymous] + public IActionResult ImportTemplateExcel() + { + var result = DownloadImportTemplate(new List() { }, "DeviceTaskExecute"); + return ExportExcel(result.Item2, result.Item1); + } + + /// + /// 立刻派发任务 + /// + /// + /// + + [HttpGet("dispatch/{id}")] + [Log(Title = "任务立刻执行")] + [AllowAnonymous] + public IActionResult ExecutionTask_point(string id) + { + if(string.IsNullOrEmpty(id)) + { + return SUCCESS(null); + } + var response = _DeviceTaskExecuteService.ExecutionTask_point(id); + + return SUCCESS(response); + + } + + + /// + /// 获取任务执行绑定的巡检任务和点检任务绑定的设备 + /// + /// device_task_execute表的主键 + /// + [HttpGet("get_bind_device/{id}")] + public IActionResult AchieveTaskbindDevice(string id) + { + + if (string.IsNullOrEmpty(id)) + { + return SUCCESS(null); + } + var response = _DeviceTaskExecuteService.AchieveTaskbindDevice(id); + + return SUCCESS(response); + } + + /// + /// 获取设备绑定的检查项 + /// + /// device_rel_account_inspect表的fk_account_id 属性 + /// + [HttpGet("get_bind_inspect")] + public IActionResult AchieveDevicebindInspect(int? fk_account_id,string fkPlanId,int planType) + { + if (fk_account_id == null) + { + return SUCCESS(null); + } + var response = _DeviceTaskExecuteService.AchieveDevicebindInspect(fk_account_id ?? 0, fkPlanId, planType); + + return SUCCESS(response); + } + /// + /// 获取检查项绑定的检查表单 + /// + /// device_form_config表的fk_device_inspect_id字段 + /// + [HttpGet("bind_form/{fk_device_inspect_id}")] + public IActionResult AchieveInspectbindForm(int? fk_device_inspect_id) + { + if (fk_device_inspect_id==null) + { + return SUCCESS(null); + } + + var response = _DeviceTaskExecuteService.AchieveInspectbindForm(fk_device_inspect_id??0); + + return SUCCESS(response); + + } + + /// + /// 获取表单结果 + /// + /// + [HttpPost("get_form_result")] + public IActionResult AchieveFormResult([FromBody] DeviceTaskExecuteResult1QueryDto_TaskExecute query) + { + if(query==null) + { + return SUCCESS(null); + } + if(query.PlanType!=1&&query.PlanType!=2) + { + + return ToResponse(ResultCode.CUSTOM_ERROR, "数据不合法:只能是1或者2"); + } + + var response = _DeviceTaskExecuteService.AchieveFormResult2(query); + + return SUCCESS(response); + + } + /// + /// 修改表单结果 + /// + /// + /// + [HttpPost("update_form_result")] + [AllowAnonymous] + public IActionResult UpdateFormResult([FromBody] DeviceTaskExecuteResultDto result) + { + if(result==null) + { + return SUCCESS(null); + } + result.ToUpdate_nickName(HttpContext); + int res=_DeviceTaskExecuteService.UpdateFormResult(result); + return SUCCESS(res); + } + + + /// + /// 增加任务开始时间 + /// + /// + /// + [HttpGet("add_task_start")] + public IActionResult AddTaskStartTime(string Id) + { + if(string.IsNullOrEmpty(Id)) + { + return SUCCESS(null); + } + + int res = _DeviceTaskExecuteService.AddDeviceTaskExecute(Id,HttpContext.GetNickName()); + return SUCCESS(res); + + } + + /// + /// 增加任务结束时间 + /// + /// + /// + [HttpGet("add_task_finally")] + public IActionResult AddTaskFinallyTime(string Id) + { + if (string.IsNullOrEmpty(Id)) + { + return SUCCESS(null); + } + + int res = _DeviceTaskExecuteService.AddTaskFinallyTime(Id); + return SUCCESS(res); + + } + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteResultController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteResultController.cs new file mode 100644 index 0000000..7f91399 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTaskExecuteResultController.cs @@ -0,0 +1,110 @@ +using Microsoft.AspNetCore.Mvc; + + +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using DOAN.Service.MES.dev.IService; +using DOAN.Admin.WebApi.Filters; +using DOAN.Service.MES.dev; + +//创建时间:2024-06-11 +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 巡检/点检任务结果表 + /// + [Verify] + [Route("mes/deviceManagement/DeviceTaskExecuteResult")] + public class DeviceTaskExecuteResultController : BaseController + { + /// + /// 巡检/点检任务结果表接口 + /// + private readonly IDeviceTaskExecuteResultService _DeviceTaskExecuteResultService; + + public DeviceTaskExecuteResultController(IDeviceTaskExecuteResultService DeviceTaskExecuteResult1Service) + { + _DeviceTaskExecuteResultService = DeviceTaskExecuteResult1Service; + } + + /// + /// 查询巡检/点检任务结果表列表 + /// + /// + /// + [HttpGet("list")] + public IActionResult QueryDeviceTaskExecuteResult1([FromQuery] DeviceTaskExecuteResultQueryDto parm) + { + var response = _DeviceTaskExecuteResultService.GetList(parm); + return SUCCESS(response); + } + + + /// + /// 查询巡检/点检任务结果表详情 + /// + /// + /// + [HttpGet("{Id}")] + // [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecuteresult1:query")] + public IActionResult GetDeviceTaskExecuteResult1(string Id) + { + var response = _DeviceTaskExecuteResultService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加巡检/点检任务结果表 + /// + /// + [HttpPost] + // [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecuteresult1:add")] + [Log(Title = "巡检/点检任务结果表", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceTaskExecuteResult1([FromBody] DeviceTaskExecuteResultDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceTaskExecuteResultService.AddDeviceTaskExecuteResult(modal); + + return SUCCESS(response); + } + + /// + /// 更新巡检/点检任务结果表 + /// + /// + [HttpPut] + // [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecuteresult1:edit")] + [Log(Title = "巡检/点检任务结果表", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceTaskExecuteResult1([FromBody] DeviceTaskExecuteResultDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceTaskExecuteResultService.UpdateDeviceTaskExecuteResult(modal); + + return ToResponse(response); + } + + /// + /// 删除巡检/点检任务结果表 + /// + /// + [HttpDelete("{ids}")] + // [ActionPermissionFilter(Permission = "deviceManagement:devicetaskexecuteresult1:delete")] + [Log(Title = "巡检/点检任务结果表", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceTaskExecuteResult1(string ids) + { + int[] idsArr = Tools.SpitIntArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceTaskExecuteResultService.Delete(idsArr); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTypeController.cs b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTypeController.cs new file mode 100644 index 0000000..90d7c22 --- /dev/null +++ b/DOAN.Admin.WebApi/Controllers/MES/Device/DeviceTypeController.cs @@ -0,0 +1,107 @@ +using Microsoft.AspNetCore.Mvc; +using DOAN.Admin.WebApi.Filters; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using DOAN.Service.MES.dev.IService; + +namespace DOAN.Admin.WebApi.Controllers +{ + /// + /// 1.设备类型 + /// + + [Route("mes/deviceManagement/DeviceType")] + public class DeviceTypeController : BaseController + { + /// + /// 1.设备类型接口 + /// + private readonly IDeviceTypeService _DeviceTypeService; + + public DeviceTypeController(IDeviceTypeService DeviceTypeService) + { + _DeviceTypeService = DeviceTypeService; + } + + /// + /// 查询1.设备类型列表 + /// + /// + /// + [HttpGet("list")] + + public IActionResult QueryDeviceType([FromQuery] DeviceTypeQueryDto parm) + { + var response = _DeviceTypeService.GetList(parm); + return SUCCESS(response); + } + + + + /// + /// 查询1.设备类型详情 + /// + /// + /// + [HttpGet("{Id}")] + [ActionPermissionFilter(Permission = "business:devicetype:query")] + public IActionResult GetDeviceType(int Id) + { + var response = _DeviceTypeService.GetInfo(Id); + + var info = response.Adapt(); + return SUCCESS(info); + } + + /// + /// 添加1.设备类型 + /// + /// + [HttpPost("insert")] + + [Log(Title = "1.设备类型", BusinessType = BusinessType.INSERT)] + public IActionResult AddDeviceType([FromBody] DeviceTypeDto parm) + { + var modal = parm.Adapt().ToCreate(HttpContext); + + var response = _DeviceTypeService.AddDeviceType(modal); + + return SUCCESS(response); + } + + /// + /// 更新1.设备类型 + /// + /// + [HttpPost("update")] + [Log(Title = "1.设备类型", BusinessType = BusinessType.UPDATE)] + public IActionResult UpdateDeviceType([FromBody] DeviceTypeDto parm) + { + var modal = parm.Adapt().ToUpdate(HttpContext); + var response = _DeviceTypeService.UpdateDeviceType(modal); + + return ToResponse(response); + } + + /// + /// 删除1.设备类型 + /// + /// + [HttpGet("delete/{id}")] + + [Log(Title = "1.设备类型", BusinessType = BusinessType.DELETE)] + public IActionResult DeleteDeviceType(long id) + { + + if (id <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + + var response = _DeviceTypeService.Delete(id); + + return ToResponse(response); + } + + + + + } +} \ No newline at end of file diff --git a/DOAN.Model/MES/Device/DeviceAccount.cs b/DOAN.Model/MES/Device/DeviceAccount.cs new file mode 100644 index 0000000..8968617 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceAccount.cs @@ -0,0 +1,103 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 设备台账 + /// + [SugarTable("device_account")] + public class DeviceAccount + { + /// + /// 设备台账id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 设备类型 + /// + [SugarColumn(ColumnName = "fk_device_type")] + public int FkDeviceType { get; set; } + + /// + /// 设备名称 + /// + [SugarColumn(ColumnName = "device_name")] + public string DeviceName { get; set; } + + /// + /// 设备编号(二维码) + /// + [SugarColumn(ColumnName = "device_code")] + public string DeviceCode { get; set; } + + /// + /// 所属车间 + /// + public string Workshop { get; set; } + + /// + /// 所属产线 + /// + public string Workline { get; set; } + + /// + /// 设备状态 + /// + public int? Status { get; set; } + + /// + /// 设备图片 + /// + [SugarColumn(ColumnName = "device_image")] + public string DeviceImage { get; set; } + + /// + /// 设备文件 + /// + [SugarColumn(ColumnName = "device_file")] + public string DeviceFile { get; set; } + + /// + /// 设备规格 + /// + [SugarColumn(ColumnName = "device_specification")] + public string DeviceSpecification { get; set; } + + /// + /// 设备负责人 + /// + [SugarColumn(ColumnName = "responsible_person")] + public string ResponsiblePerson { get; set; } + + /// + /// 备注 + /// + public string Remark { 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/DOAN.Model/MES/Device/DeviceFormConfig.cs b/DOAN.Model/MES/Device/DeviceFormConfig.cs new file mode 100644 index 0000000..533cb1b --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceFormConfig.cs @@ -0,0 +1,62 @@ +namespace DOAN.Model.MES.dev +{ + /// + /// 设备检查项表单配置表 + /// + [SugarTable("device_form_config")] + public class DeviceFormConfig + { + /// + /// id 雪花 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 设备检查项id + /// + [SugarColumn(ColumnName = "fk_device_inspect_id")] + public int FkDeviceInspectId { get; set; } + + /// + /// 表单类型 + /// + public int? Type { get; set; } + + /// + /// 表单选项内容 + /// + public string Content { get; set; } + + /// + /// 表单标题 + /// + [SugarColumn(ColumnName = "title")] + public string Title { 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/DOAN.Model/MES/Device/DeviceInspect.cs b/DOAN.Model/MES/Device/DeviceInspect.cs new file mode 100644 index 0000000..85f24a8 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceInspect.cs @@ -0,0 +1,73 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 设备检查项 + /// + [SugarTable("device_inspect")] + public class DeviceInspect + { + /// + /// id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + + /// + /// 图片 + /// + public string Image { get; set; } + + /// + /// 备注 + /// + public string Remark { get; set; } + + /// + /// 检查项状态 + /// + public int? Status { get; set; } + + /// + /// 描述 + /// + public string Descride { get; set; } + + /// + /// 检查项名称 + /// + public string Name { get; set; } + + /// + /// 1:检查 2:保养 + /// + [SugarColumn(ColumnName = "type")] + public int Type { 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/DOAN.Model/MES/Device/DeviceMaintenanceRecord.cs b/DOAN.Model/MES/Device/DeviceMaintenanceRecord.cs new file mode 100644 index 0000000..9a1bf5c --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceMaintenanceRecord.cs @@ -0,0 +1,69 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 维修记录 + /// + [SugarTable("device_maintenance_record")] + public class DeviceMaintenanceRecord + { + /// + /// id雪花 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 维修单id + /// + [SugarColumn(ColumnName = "fk_repair_id")] + public string FkRepairId { get; set; } + + /// + /// 维修人 + /// + [SugarColumn(ColumnName = "maintanance_person")] + public string MaintanancePerson { get; set; } + + /// + /// 手机号 + /// + public string Phone { get; set; } + + /// + /// 维修结果 + /// + public int? Result { get; set; } + + /// + /// 维修时间 + /// + [SugarColumn(ColumnName = "maintenance_time")] + public DateTime? MaintenanceTime { 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/DOAN.Model/MES/Device/DevicePointInspectionPlan.cs b/DOAN.Model/MES/Device/DevicePointInspectionPlan.cs new file mode 100644 index 0000000..9772ab4 --- /dev/null +++ b/DOAN.Model/MES/Device/DevicePointInspectionPlan.cs @@ -0,0 +1,68 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 点检任务 + /// + [SugarTable("device_point_inspection_plan")] + public class DevicePointInspectionPlan + { + /// + /// id(雪花) + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 点检检名称 + /// + public string Name { get; set; } + + /// + /// 执行人 + /// + [SugarColumn(ColumnName = "fk_person_id")] + public string FkPersonId { get; set; } + + /// + /// 点检状态 + /// + public int? Status { get; set; } + + /// + /// 类型(内部) 1是检查 2是保养 + /// + [SugarColumn(ColumnName = "inner_type")] + public int? InnerType { get; set; } + + /// + /// 备注 + /// + public string Remark { 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/DOAN.Model/MES/Device/DeviceRelAccountInspect.cs b/DOAN.Model/MES/Device/DeviceRelAccountInspect.cs new file mode 100644 index 0000000..0767284 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceRelAccountInspect.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev +{ + /// + /// 设备检查项与设备台账关联表 + /// + [SugarTable("device_rel_account_inspect")] + public class DeviceRelAccountInspect + { + /// + /// 设备检项id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_inspect_id")] + public int? FkInspectId { get; set; } + + /// + /// 设备台账id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_account_id")] + public int? FkAccountId { get; set; } + + /// + /// 序号 + /// + public int? Sort { 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/DOAN.Model/MES/Device/DeviceRelPpAt.cs b/DOAN.Model/MES/Device/DeviceRelPpAt.cs new file mode 100644 index 0000000..a849a4b --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceRelPpAt.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev +{ + /// + /// 点检计划与设备关联表 + /// + [SugarTable("device_rel_pp_at")] + public class DeviceRelPpAt + { + /// + /// 点检计划 id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_point_inspection_plan_id")] + public string FkPointInspectionPlanId { get; set; } + + /// + /// 设备台账id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_device_account_id")] + public int FkDeviceAccountId { get; set; } + + /// + /// 巡检设备顺序 + /// + public int? Sort { 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; } + + } +} diff --git a/DOAN.Model/MES/Device/DeviceRelRpAt.cs b/DOAN.Model/MES/Device/DeviceRelRpAt.cs new file mode 100644 index 0000000..fe9f851 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceRelRpAt.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev +{ + /// + /// 巡检计划与设备关联表 + /// + [SugarTable("device_rel_rp_at")] + public class DeviceRelRpAt + { + /// + /// 巡检计划 id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_route_inspection_plan_id")] + public string FkRouteInspectionPlanId { get; set; } + + /// + /// 设备台账id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "fk_device_account_id")] + public int FkDeviceAccountId { get; set; } + + /// + /// 巡检设备顺序 + /// + public int? Sort { 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/DOAN.Model/MES/Device/DeviceRepair.cs b/DOAN.Model/MES/Device/DeviceRepair.cs new file mode 100644 index 0000000..629743a --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceRepair.cs @@ -0,0 +1,85 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 报修单 + /// + [SugarTable("device_repair")] + public class DeviceRepair + { + /// + /// 雪花id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 维修单号(年月日001) + /// + [SugarColumn(ColumnName = "repair_order")] + public string RepairOrder { get; set; } + + /// + /// 设备id + /// + [SugarColumn(ColumnName = "fk_device_id")] + public int FkDeviceId { get; set; } + + /// + /// 报修类型 + /// + public string Type { get; set; } + + /// + /// 报修人 + /// + [SugarColumn(ColumnName = "repair_peron")] + public string RepairPeron { get; set; } + + /// + /// 手机号 + /// + public string Phone { get; set; } + + /// + /// 故障描述 + /// + [SugarColumn(ColumnName = "fault_description")] + public string FaultDescription { get; set; } + + /// + /// 拍照文件路径 + /// + public string File { get; set; } + + /// + /// 状态(启用,停用 维修中) + /// + public int? Status { 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/DOAN.Model/MES/Device/DeviceRouteInspectionPlan.cs b/DOAN.Model/MES/Device/DeviceRouteInspectionPlan.cs new file mode 100644 index 0000000..676daa9 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceRouteInspectionPlan.cs @@ -0,0 +1,102 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 巡检计划 + /// + [SugarTable("device_route_inspection_plan")] + public class DeviceRouteInspectionPlan + { + /// + /// id(雪花) + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 巡检名称 + /// + public string Name { get; set; } + + + + /// + /// 巡检状态 + /// + public int? Status { get; set; } + + /// + /// 类型(内部) 1是检查 2是保养 + /// + [SugarColumn(ColumnName = "inner_type")] + public int? InnerType { get; set; } + + /// + /// 生命周期开始 + /// + [SugarColumn(ColumnName = "life_cycle_start")] + public DateTime? LifeCycleStart { get; set; } + + /// + /// 生命周期结束 + /// + [SugarColumn(ColumnName = "life_cycle_end")] + public DateTime? LifeCycleEnd { get; set; } + + /// + /// 执行周期类型(1 按天,2按周 3按月) + /// + [SugarColumn(ColumnName = "excute_cycle_type")] + public int? ExcuteCycleType { get; set; } + + /// + /// 每第几天 + /// + [SugarColumn(ColumnName = "day_num")] + public int? DayNum { get; set; } + + /// + /// 每周几 + /// + [SugarColumn(ColumnName = "week_list")] + public string WeekList { get; set; } + + /// + /// 每月几 + /// + [SugarColumn(ColumnName = "month_day_list")] + public string MonthDayList { get; set; } + + + + /// + /// 备注 + /// + public string Remark { 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/DOAN.Model/MES/Device/DeviceTaskExecute.cs b/DOAN.Model/MES/Device/DeviceTaskExecute.cs new file mode 100644 index 0000000..2a261dc --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceTaskExecute.cs @@ -0,0 +1,92 @@ + +namespace DOAN.Model.MES.dev +{ + /// + /// 任务执行 + /// + [SugarTable("device_task_execute")] + public class DeviceTaskExecute + { + /// + /// 主键 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 任务名称 + /// + [SugarColumn(ColumnName = "task_name")] + public string TaskName { get; set; } + + /// + /// 计划id + /// + [SugarColumn(ColumnName = "plan_id")] + public string PlanId { get; set; } + + /// + /// 执行人 + /// + [SugarColumn(ColumnName = "person")] + public string Person { get; set; } + + /// + /// 任务类型(1是巡检,2是点检) + /// + public int Type { get; set; } + + /// + /// 任务派发时间 + /// + [SugarColumn(ColumnName = "distributed_time")] + public DateTime? DistributedTime { get; set; } + + /// + /// 任务执行——开始时间 + /// + [SugarColumn(ColumnName = "start_time")] + public DateTime? StartTime { get; set; } + + /// + /// 任务执行——结束时间 + /// + [SugarColumn(ColumnName = "end_time")] + public DateTime? EndTime { get; set; } + + /// + /// 状态 + /// + public int? Status { get; set; } + + /// + /// 备注 + /// + public string Remark { 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/DOAN.Model/MES/Device/DeviceTaskExecuteResult.cs b/DOAN.Model/MES/Device/DeviceTaskExecuteResult.cs new file mode 100644 index 0000000..b145c38 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceTaskExecuteResult.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev +{ + /// + /// 巡检/点检任务结果表 + /// + [SugarTable("device_task_execute_result1")] + public class DeviceTaskExecuteResult + { + /// + /// id 雪花 + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = false)] + public string Id { get; set; } + + /// + /// 任务id + /// + [SugarColumn(ColumnName = "fk_task_id")] + public string FkTaskId { get; set; } + + /// + /// 计划类型(1是巡检,2是点检) + /// + [SugarColumn(ColumnName = "plan_type")] + public int? PlanType { get; set; } + + /// + /// 计划id + /// + [SugarColumn(ColumnName = "fk_plan_id")] + public string FkPlanId { get; set; } + + /// + /// 巡检计划名称 + /// + [SugarColumn(ColumnName = "plan_name")] + public string PlanName { get; set; } + + + /// + /// 类型(内部) 1是检查 2是保养 + /// + [SugarColumn(ColumnName = "inner_type")] + public int? InnerType { get; set; } + + /// + /// 执行周期类型(1 按天,2按周 3按月) + /// + [SugarColumn(ColumnName = "excute_cycle_type")] + public int? ExcuteCycleType { get; set; } + + /// + /// 设备id + /// + [SugarColumn(ColumnName = "fk_device_id")] + public int? FkDeviceId { get; set; } + + /// + /// 设备名称 + /// + [SugarColumn(ColumnName = "device_name")] + public string DeviceName { get; set; } + + /// + /// 设备检查项id + /// + [SugarColumn(ColumnName = "fk_inspect_id")] + public int? FkInspectId { get; set; } + + /// + /// 检查项名称 + /// + [SugarColumn(ColumnName = "inspect_name")] + public string InspectName { get; set; } + + /// + /// 表单类型 + /// + [SugarColumn(ColumnName = "form_type")] + public int? FormType { get; set; } + + /// + /// 表单标题 + /// + [SugarColumn(ColumnName = "form_title")] + public string FormTitle { get; set; } + + /// + /// 表单名称 + /// + [SugarColumn(ColumnName = "form_name")] + public string FormName { get; set; } + + + /// + /// 巡检人 + /// + public string Person { get; set; } + + /// + /// 备注 + /// + public string Remark { 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; } + + } +} diff --git a/DOAN.Model/MES/Device/DeviceType.cs b/DOAN.Model/MES/Device/DeviceType.cs new file mode 100644 index 0000000..6bc0747 --- /dev/null +++ b/DOAN.Model/MES/Device/DeviceType.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev +{ + /// + /// 1.设备类型 + /// + [SugarTable("device_type")] + public class DeviceType + { + /// + /// id + /// + [SugarColumn(IsPrimaryKey = true, IsIdentity = true)] + public int Id { get; set; } + + /// + /// 父id + /// + [SugarColumn(ColumnName = "parent_id")] + public int ParentId { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 是否启用 + /// + public int? Status { get; set; } + + /// + /// 备注 + /// + public string Remark { 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/DOAN.Model/MES/Device/Dto/DeviceAccountDto.cs b/DOAN.Model/MES/Device/Dto/DeviceAccountDto.cs new file mode 100644 index 0000000..1430488 --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceAccountDto.cs @@ -0,0 +1,127 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 设备台账查询对象 + /// + public class DeviceAccountQueryDto : PagerInfo + { + /// + /// 设备类型 + /// + public int FkDeviceType { get; set; } + public string DeviceName { get; set; } + public string DeviceSpecification { get; set; } + public int? Status { get; set; } + } + public class DeviceAccount_routeinspect_Dto + { + /// + /// 设备巡检id + /// + public string FkRouteInspectionPlanId { get; set; } + /// + /// 设备台账id + /// + public int[] FkDeviceAccountIdList { get; set; } + + } + + public class DeviceAccount_pointinspect_Dto + { + /// + /// 设备点检id + /// + public string FkPointInspectionPlanId { get; set; } + /// + /// 设备台账id + /// + public int[] FkDeviceAccountIdList { get; set; } + + } + + + /// + /// 适配设备巡检项 + /// + public class DeviceAccountQueryDto2 : PagerInfo + { + /// + /// 设备类型 + /// + public int FkDeviceType { get; set; } + public string DeviceName { get; set; } + public string DeviceSpecification { get; set; } + + /// + /// 巡检id + /// + public string fkRouteInspectionPlanId { get; set; } + + /// + /// 是否绑定标志位:1 绑定 0 未绑定 + /// + public int Flag { get; set; } + } + /// + /// 适配设备点检项 + /// + public class DeviceAccountQueryDto3 : PagerInfo + { + /// + /// 设备类型 + /// + public int FkDeviceType { get; set; } + public string DeviceName { get; set; } + public string DeviceSpecification { get; set; } + + /// + /// 点检id + /// + public string fkPointInspectionPlanId { get; set; } + + /// + /// 是否绑定标志位:1 绑定 0 未绑定 + /// + public int Flag { get; set; } + } + + /// + /// 设备台账输入输出对象 + /// + public class DeviceAccountDto + { + public int Id { get; set; } + public int FkDeviceType { get; set; } + + public string DeviceName { get; set; } + + public string DeviceCode { get; set; } + + public string Workshop { get; set; } + + public string Workline { get; set; } + + public int? Status { get; set; } + + public string DeviceImage { get; set; } + + public string DeviceFile { get; set; } + + public string DeviceSpecification { get; set; } + + public string ResponsiblePerson { get; set; } + + public string Remark { 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/DOAN.Model/MES/Device/Dto/DeviceDefaultDto.cs b/DOAN.Model/MES/Device/Dto/DeviceDefaultDto.cs new file mode 100644 index 0000000..7e2553f --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceDefaultDto.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev.Dto +{ + public class DeviceDefaultDto + { + /// + /// 设备类型id + /// + public int? DevicetTypeId { get; set; } + + /// + /// 设备名称 + /// + public string DeviceName { get; set; } + + /// + /// 设备代码 + /// + public string DeviceCode { get; set; } + + /// + /// 搜索时间 + /// + public DateTime[] searchTime { get; set; } + + /// + /// 1-发布时间与开始时间 2-开始时间与结束时间 + /// + public int searchType { get; set; } + + + } + + /// + /// 人员响应 + /// + public class PersonnelResponseDto + { + public string TaskName { get; set; } + public string Id { get; set; } + /// + /// 接受响应时间戳 + /// + public TimeSpan Accept_response { get; set; } + /// + /// 处理响应时间戳 + /// + public TimeSpan Action_response { get; set; } + + } + + + +} diff --git a/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs b/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs new file mode 100644 index 0000000..3f4bc93 --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceFormConfigDto.cs @@ -0,0 +1,42 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto + +{ + /// + /// 设备检查项表单配置表查询对象 + /// + public class DeviceFormConfigQueryDto : PagerInfo + { + public int FkDeviceInspectId { get; set; } + } + + /// + /// 设备检查项表单配置表输入输出对象 + /// + public class DeviceFormConfigDto + { + [Required(ErrorMessage = "id 雪花不能为空")] + public string Id { get; set; } + + public int FkDeviceInspectId { get; set; } + + public int? Type { get; set; } + + public string Content { get; set; } + + + public string Title { 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/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs b/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs new file mode 100644 index 0000000..4025e9b --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceInspectDto.cs @@ -0,0 +1,74 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto + +{ + /// + /// 设备检查项查询对象 + /// + public class DeviceInspectQueryDto : PagerInfo + { + + public string Name { get; set; } + + public int Status { get; set; } + + public int Type { get; set; } + } + public class DeviceInspectQueryDto2 : PagerInfo + { + /// + /// 设备台账ID + /// + public int FkAccountId { get; set; } + /// + /// 检查项名称 + /// + public string Name { get; set; } + + /// + /// 绑定/未绑定 + /// + public int Isbind { get; set; } + + public int Type { get; set; } + + } + public class DeviceInspectQueryDto3 + { + public int account_id { get; set; } + public List inspect_ids { get; set; } + } + + + /// + /// 设备检查项输入输出对象 + /// + public class DeviceInspectDto + { + [Required(ErrorMessage = "id不能为空")] + public int Id { get; set; } + public string Image { get; set; } + + public int? Type { get; set; } + + public string Remark { get; set; } + + public int Status { get; set; } + + public string Descride { get; set; } + + public string Name { 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/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs b/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs new file mode 100644 index 0000000..5f34f0a --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceMaintenanceRecordDto.cs @@ -0,0 +1,41 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 维修记录查询对象 + /// + public class DeviceMaintenanceRecordQueryDto : PagerInfo + { + } + + /// + /// 维修记录输入输出对象 + /// + public class DeviceMaintenanceRecordDto + { + [Required(ErrorMessage = "id不能为空")] + public string Id { get; set; } + + public string FkRepairId { get; set; } + + public string MaintanancePerson { get; set; } + + public string Phone { get; set; } + + public int? Result { get; set; } + + public DateTime? MaintenanceTime { 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/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs b/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs new file mode 100644 index 0000000..943d5dd --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DevicePointInspectionPlanDto.cs @@ -0,0 +1,46 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 点检任务查询对象 + /// + public class DevicePointInspectionPlanQueryDto : PagerInfo + { + public string Name { get; set; } + public int? Status { get; set; } + public DateTime? Starttime { get; set; } + public DateTime? Endtime { get; set; } + public int? InnerType { get; set; } + } + + /// + /// 点检任务输入输出对象 + /// + public class DevicePointInspectionPlanDto + { + [Required(ErrorMessage = "id不能为空")] + public string Id { get; set; } + + public string Name { get; set; } + + public string FkPersonId { get; set; } + + public int? Status { get; set; } + + public int? InnerType { get; set; } + + public string Remark { 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/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs b/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs new file mode 100644 index 0000000..8f04500 --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceRepairDto.cs @@ -0,0 +1,78 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 报修单查询对象 + /// + public class DeviceRepairQueryDto : PagerInfo + { + public string RepairOrder { get; set; } + public int FkDeviceId { get; set; } + public string RepairPeron { get; set; } + public string Phone { get; set; } + public string Type { get; set; } + public int? Status { get; set; } + + /// + /// 时间范围 + /// + public DateTime[] TimeRange { get; set; } + } + + public class DeviceRepair_chart + { + public string Id { get; set; } + public string Type { get; set; } + public string TypeName { get; set; } + public DateTime CreatedTime { get; set; } + /// + /// 累加值 + /// + public int AccValue_SameType { get; set; } + + public int Status { get; set; } + + + } + + /// + /// 报修单输入输出对象 + /// + public class DeviceRepairDto + { + [Required(ErrorMessage = "雪花id不能为空")] + public string Id { get; set; } + + public string RepairOrder { get; set; } + + public string FkDeviceId { get; set; } + + public string DeviceName { get; set; } + + public string DeviceCode { get; set; } + + public string Type { get; set; } + + public string RepairPeron { get; set; } + + public string Phone { get; set; } + + public string FaultDescription { get; set; } + + public string File { get; set; } + + public int? Status { 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/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs b/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs new file mode 100644 index 0000000..d09f75d --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceRouteInspectionPlanDto.cs @@ -0,0 +1,61 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 巡检计划查询对象 + /// + public class DeviceRouteInspectionPlanQueryDto : PagerInfo + { + public string Name { get; set; } + public DateTime? LifeCycleStart { get; set; } + + public DateTime? LifeCycleEnd { get; set; } + public int? ExcuteCycleType { get; set; } + public int? InnerType { get; set; } + } + + /// + /// 巡检计划输入输出对象 + /// + public class DeviceRouteInspectionPlanDto + { + [Required(ErrorMessage = "id不能为空")] + public string Id { get; set; } + + public string Name { get; set; } + + public string FkPersonId { get; set; } + + public int? Status { get; set; } + + + public int? InnerType { get; set; } + + public DateTime? LifeCycleStart { get; set; } + + public DateTime? LifeCycleEnd { get; set; } + + public int? ExcuteCycleType { get; set; } + + public int? DayNum { get; set; } + + public string WeekList { get; set; } + + public string MonthDayList { get; set; } + + + public string Remark { 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/DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisDto.cs b/DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisDto.cs new file mode 100644 index 0000000..5f4b23a --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisDto.cs @@ -0,0 +1,101 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 设备状态分析 + /// + public class DeviceStatusAnalysisDto + { + /// + /// 设备总数:存在设备 + /// + public int AllTotal { get; set; } + + /// + /// 正常设备总数 + /// + public int NormalTotal { get; set; } + + /// + /// 未点/巡总数 + /// + public int UnmaintainedTotal { get; set; } + + /// + /// 报修中总数 + /// + public int DamageTotal { get; set; } + + /// + /// 停用总数 + /// + public int NoUseTotal { get; set; } + + + /// + /// 设备详情 + /// + public List LineDetailList { get; set; } + + } + /// + /// 设备详情 + /// + public class LineDetail + { + /// + /// 车间 + /// + public string Workshop { get; set; } + + /// + /// 产线 + /// + public string Workline { get; set; } + + /// + /// 总计 + /// + public int Total { get; set; } + + /// + /// 设备信息 + /// + public List Children { get; set; } + } + /// + /// 设备信息 + /// + public class DeviceInfo + { + /// + /// 设备id + /// + public int Id { get; set; } + + /// + /// 设备名称 + /// + public string DeviceName { get; set; } + + /// + /// 设备code + /// + public string DeviceCode { get; set; } + + + /// + /// 设备状态 :1(正常)2(未维护) 3(报修中)4(停用中) + /// + public int DeviceStatus { get; set; } + + } + + + +} diff --git a/DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisResultDto.cs b/DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisResultDto.cs new file mode 100644 index 0000000..48fd50a --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceStatusAnalysisResultDto.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev.Dto +{ + public class DeviceStatusAnalysisResultDto + { + + /// + /// 横坐标数据 + /// + public string name { get; set; } + /// + /// 值 + /// + public int value { get; set; } + } + /// + /// 设备故障饼图返回结果 + /// + public class DeviceFaultBarResultDto + { + public string[] XData { get; set; } + + public List SeriesData { get; set; } + + + } + /// + /// 设备折线饼图返回结果 + /// + public class DeviceFaultLineResultDto + { + public string[] XData { get; set; } + + public List SeriesData { get; set; } + + + } + /// + /// 设备维修柱状图返回结果 + /// + public class DeviceRepairBarResultDto + { + public string[] XData { get; set; } + + public List SeriesData { get; set; } + + + } + + /// + /// 点、巡检 任务 结果 + /// + public class TaskLineResultDto + { + public string[] XData { get; set; } + + public List SeriesData { get; set; } + + public string msg { get; set; } + } + + /// + /// 人员响应请求 + /// + public class PersonnelResponseResultDto + { + /// + /// 总数 + /// + public int TaskTotal { get; set; } + /// + /// 与上周对比 总数 + /// + public double lastTotalPer { get; set; } + /// + /// 最大 + /// + public TimeSpan TaskMax { get; set; } + /// + /// 与上周对比 最大 + /// + public double lastMaxPer { get; set; } + + /// + /// 最小 + /// + public TimeSpan TaskMin { get; set; } + + /// + /// 与上周对比 最小 + /// + public double lastMinPer { get; set; } + + /// + /// 任务平均 + /// + public TimeSpan TaskAvg { get; set; } + + /// + /// 与上周对比 任务平均 + /// + public double lastAvgPer { get; set; } + + + public string[] XData { get; set; } + + public PersonnelResponse_Series SeriesData { get; set; } + } + + public class FullScreenTotal + { + /// + /// 设备可用数量 + /// + public int UseDeviceTotal { get; set; } + /// + /// 设备停机中 + /// + public int UnUseDeviceTotal { get; set; } + + /// + /// 累计任务数 + /// + public int TaskTotal { get; set; } + + /// + /// 累计任务完成数 + /// + public int FinishTaskTotal { get; set; } + + /// + /// 累计报修数 + /// + public int RepairTotal { get; set; } + + /// + /// 累计维护数 + /// + public int FinishRepairTotal { get; set; } + } + + public class PersonnelResponse_Series + { + public string Name { get; set; } + public string Type { get; set; } = "line"; + public bool showBackground { get; set; } = true; + public MarkPoint_ markPoint { get; set; } + public MarkPoint_ markLine { get; set; } + public double[] Data { get; set; } + } + + public class MarkPoint_ + { + public TypeName[] data { get; set; } + + } + public class TypeName + { + public string Type { get; set; } + public string Name { get; set; } + } + + public class SeriesData_Item { + public string Name { get; set; } + public string Stack { get; set ; } = "Total"; + public string Type { get; set; } = "bar"; + public Semphasis_ Semphasis { get; set; } = new Semphasis_(); + public int[] Data { get; set; } + + } + public class SeriesData_Item_line2 + { + public string Name { get; set; } + + public string Type { get; set; } = "bar"; + public bool ShowBackground { get; set; } = true; + public int[] Data { get; set; } + + } + public class SeriesData_Item_line3 + { + public string Name { get; set; } = "点检数/巡检数"; + + public string Type { get; set; } = "line"; + public bool showBackground { get; set; } = true; + public int[] Data { get; set; } + + } + public class SeriesData_Item_line + { + public string Name { get; set; } + public string Type { get; set; } = "line"; + public int[] Data { get; set; } + public bool Smooth { get; set; } = true; + + public AreaStyle_ areaStyle { get; set; } = new AreaStyle_(); + public Label_line Label { get; set; }= new Label_line(); + + } + public class Semphasis_ { + public string Focus { get; set; } = "series"; + + + } + + public class Label_line { + public bool Show { get; set; } = true; + public string Position { get; set; } = "top"; + + } + + public class AreaStyle_ { } +} diff --git a/DOAN.Model/MES/Device/Dto/DeviceTaskExecuteDto.cs b/DOAN.Model/MES/Device/Dto/DeviceTaskExecuteDto.cs new file mode 100644 index 0000000..11be306 --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceTaskExecuteDto.cs @@ -0,0 +1,160 @@ +using System.ComponentModel.DataAnnotations; +using MiniExcelLibs.Attributes; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 任务执行查询对象 + /// + public class DeviceTaskExecuteQueryDto : PagerInfo + { + /// + /// 任务名称 + /// + public string TaskName { get; set; } + + /// + /// 时间范围 + /// + public DateTime[] TimeRange { get; set; } + + /// + /// 任务类型 + /// + public int Type { get; set; } + + /// + /// 状态 + /// + public int Status { get; set; } + } + + public class DeviceTaskExecuteQueryDto2 + { + public string Id { get; set; } + public int Status { get; set; } + public string UpdatedBy { get; set; } + + public DateTime UpdatedTime { get; set; } + } + + /// + /// 查询表单结果 + /// + public class DeviceTaskExecuteResult1QueryDto_TaskExecute + { + /// + /// 任务id + /// + public string FkTaskId { get; set; } + + /// + /// 类型 (巡检、点检) + /// + public int? PlanType { get; set; } + + /// + /// 巡检计划或者点检计划id + /// + public string FkPlanId { get; set; } + + /// + /// 设备id + /// + public int? FkDeviceId { get; set; } + + /// + /// 检查项id + /// + public int FkInspectId { get; set; } + } + + /// + /// 生成表单结果 + /// + public class DeviceTaskExecuteResult1_result + { + /// + /// 主键 + /// + public string Id { get; set; } + + /// + /// 表单标题 + /// + public string Title { get; set; } + + public int? Type { get; set; } + + public string Value { get; set; } + + public string[] Children { get; set; } + } + + /// + /// 任务执行输入输出对象 + /// + public class DeviceTaskExecuteDto + { + [Required(ErrorMessage = "主键不能为空")] + [ExcelColumn(Name = "主键")] + [ExcelColumnName("主键")] + public string Id { get; set; } + + [ExcelColumn(Name = "任务名称")] + [ExcelColumnName("任务名称")] + public string TaskName { get; set; } + + [ExcelColumn(Name = "任务id")] + [ExcelColumnName("任务id")] + public string PlanId { get; set; } + + [Required(ErrorMessage = "任务类型(1是巡检,2是点检)不能为空")] + [ExcelColumn(Name = "任务类型(1是巡检,2是点检)")] + [ExcelColumnName("任务类型(1是巡检,2是点检)")] + public int Type { get; set; } + + [ExcelColumn(Name = "任务派发时间", Format = "yyyy-MM-dd HH:mm:ss")] + [ExcelColumnName("任务派发时间")] + public DateTime? DistributedTime { get; set; } + + [ExcelColumn(Name = "任务执行——开始时间", Format = "yyyy-MM-dd HH:mm:ss")] + [ExcelColumnName("任务执行——开始时间")] + public DateTime? StartTime { get; set; } + + [ExcelColumn(Name = "任务执行——结束时间", Format = "yyyy-MM-dd HH:mm:ss")] + [ExcelColumnName("任务执行——结束时间")] + public DateTime? EndTime { get; set; } + + //耗时 + public double ConsumeTime { get; set; } + + [ExcelColumn(Name = "状态")] + [ExcelColumnName("状态")] + public int? Status { get; set; } + + [ExcelColumn(Name = "执行人")] + [ExcelColumnName("执行人")] + public string Person { get; set; } + + [ExcelColumn(Name = "备注")] + [ExcelColumnName("备注")] + public string Remark { get; set; } + + [ExcelColumn(Name = "创建人")] + [ExcelColumnName("创建人")] + public string CreatedBy { get; set; } + + [ExcelColumn(Name = "创建时间", Format = "yyyy-MM-dd HH:mm:ss")] + [ExcelColumnName("创建时间")] + public DateTime? CreatedTime { get; set; } + + [ExcelColumn(Name = "更新人")] + [ExcelColumnName("更新人")] + public string UpdatedBy { get; set; } + + [ExcelColumn(Name = "更新时间", Format = "yyyy-MM-dd HH:mm:ss")] + [ExcelColumnName("更新时间")] + public DateTime? UpdatedTime { get; set; } + } +} diff --git a/DOAN.Model/MES/Device/Dto/DeviceTaskExecuteResultDto.cs b/DOAN.Model/MES/Device/Dto/DeviceTaskExecuteResultDto.cs new file mode 100644 index 0000000..b93fe6d --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceTaskExecuteResultDto.cs @@ -0,0 +1,98 @@ +using System.ComponentModel.DataAnnotations; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 巡检/点检任务结果表查询对象 + /// + //public class DeviceTaskExecuteResultQueryDto : PagerInfo + //{ + // public int? TaskType { get; set; } + // public string RouteInspectionPlanName { get; set; } + + // public string DeviceName { get; set; } + + // public string InspectName { get; set; } + //} + + public class DeviceTaskExecuteResultQueryDto : PagerInfo + { + public int? PlanType { get; set; } + public string PlanName { get; set; } + + public string DeviceName { get; set; } + + public DateTime Starttime { get; set; } + public DateTime Endtime { get; set; } + } + + + + /// + /// 巡检/点检任务结果表输入输出对象 + /// + public class DeviceTaskExecuteResultDto + { + + //public string taskExecute_id { get; set; } + [Required(ErrorMessage = "id 雪花不能为空")] + public string Id { get; set; } + + /// + /// 任务id + /// + public string FkTaskId { get; set; } + + public int? PlanType { get; set; } + + [Required(ErrorMessage = "计划id不能为空")] + public string FkPlanId { get; set; } + + public string PlanName { get; set; } + + + + /// + /// 类型(内部) 1是检查 2是保养 + /// + + public int? InnerType { get; set; } + + /// + /// 执行周期类型(1 按天,2按周 3按月) + /// + + public int? ExcuteCycleType { get; set; } + + public int? FkDeviceId { get; set; } + + public string DeviceName { get; set; } + + public int? FkInspectId { get; set; } + + public string InspectName { get; set; } + + public string FkFormId { get; set; } + + public int? FormType { get; set; } + + public string FormTitle { get; set; } + + public string FormName { get; set; } + + public string Person { get; set; } + + public string Remark { 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/DOAN.Model/MES/Device/Dto/DeviceTypeDto.cs b/DOAN.Model/MES/Device/Dto/DeviceTypeDto.cs new file mode 100644 index 0000000..e63a705 --- /dev/null +++ b/DOAN.Model/MES/Device/Dto/DeviceTypeDto.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DOAN.Model.MES.dev.Dto +{ + /// + /// 1.设备类型查询对象 + /// + public class DeviceTypeQueryDto : PagerInfo + { + public string Name { get; set; } + public int? Status { get; set; } + } + + /// + /// 1.设备类型输入输出对象 + /// + public class DeviceTypeDto + { + + public int Id { get; set; } + + [Required(ErrorMessage = "父id不能为空")] + public int ParentId { get; set; } + + public string Name { get; set; } + + public int? Status { get; set; } + + public string Remark { get; set; } + + public string CreatedBy { get; set; } + + public DateTime? CreatedTime { get; set; } + + public string UpdatedBy { get; set; } + + public DateTime? UpdatedTime { get; set; } + + + + } +} + diff --git a/DOAN.Model/TreeDto.cs b/DOAN.Model/TreeDto.cs new file mode 100644 index 0000000..ca506ff --- /dev/null +++ b/DOAN.Model/TreeDto.cs @@ -0,0 +1,21 @@ +namespace DOAN.Model +{ + + public class SelectTreeDto + { + /// + /// 生成树参数 + /// + public string Id { get; set; } + public string ParentId { get; set; } + /// + /// 树展示与反馈参数 + /// + public string Label { get; set; } + public string Value { get; set; } + /// + /// 子节点(预设) + /// + public List Children { get; set; } + } +} diff --git a/DOAN.Service/MES/Device/DeviceAccountService.cs b/DOAN.Service/MES/Device/DeviceAccountService.cs new file mode 100644 index 0000000..b9dcd75 --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceAccountService.cs @@ -0,0 +1,690 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; + +using DOAN.Repository; + +using System.Linq; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; +using System.ComponentModel; +using System.Diagnostics; + +namespace DOAN.Service.MES.dev +{ + /// + /// 设备台账Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceAccountService), ServiceLifetime = LifeTime.Transient)] + public class DeviceAccountService : BaseService, IDeviceAccountService + { + /// + /// 查询设备台账列表 + /// + /// + /// + public PagedInfo GetList(DeviceAccountQueryDto parm) + { + // 全部设备parm.FkDeviceType == 1 + // 提取parentId + DeviceType typeItem = Context.Queryable() + .Where(it => it.Id == parm.FkDeviceType) + .Where(it => it.Status == 1) + .First(); + int[] typeIds = []; + // 二级菜单 + if (typeItem != null && typeItem.ParentId == 1) + { + typeIds = Context.Queryable() + .Where(it => it.ParentId == parm.FkDeviceType) + .Where(it => it.Status == 1) + .Select(it => it.Id) + .ToArray(); + } + + // 非全部设备 + + + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.DeviceName), it => it.DeviceName.Contains(parm.DeviceName)) + .AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), it => it.DeviceSpecification.Contains(parm.DeviceSpecification)) + .AndIF(parm.Status > -1, it => it.Status == parm.Status) + .AndIF(typeItem != null && typeItem.ParentId > 1, it => it.FkDeviceType == parm.FkDeviceType) + .AndIF(typeItem != null && typeItem.ParentId == 1, it => typeIds.Contains(it.FkDeviceType)) + ; + + var response = Queryable() + .Where(predicate.ToExpression()) + .OrderByDescending(it => it.UpdatedTime) + .OrderByDescending(it => it.CreatedTime) + .ToPage(parm); + + return response; + } + /// + /// 通常在数据库层面执行联表查询(JOIN)会比在程序层面逐一查询左表和右表更快一些。 + /// + /// + /// + public PagedInfo GetList_Route2(DeviceAccountQueryDto2 parm) + { + + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.DeviceName), (a, r) => a.DeviceName.Contains(parm.DeviceName)) + .AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), (a, r) => a.DeviceSpecification.Contains(parm.DeviceSpecification)) + .And((a, r) => a.Status == 1) + .AndIF(parm.FkDeviceType > 0, (a, r) => a.FkDeviceType == parm.FkDeviceType) + .And((a, r) => r.FkRouteInspectionPlanId == parm.fkRouteInspectionPlanId) + ; + + + var temp = Context.Queryable() + .LeftJoin((a, r) => a.Id == r.FkDeviceAccountId) + .Where(predicate.ToExpression()).Select((a, r) => a); + + + if (parm.Flag == 0) + { + int[] exist = temp.Select(a => a.Id).ToArray(); + temp = Context.Queryable().Where(it => !exist.Contains(it.Id)).Distinct(); + } + + + var reponse = temp + .ToPage(parm); + + return reponse; + + } + public PagedInfo GetList_Route(DeviceAccountQueryDto2 parm) + { + + //未绑定 + if (parm.Flag == 0) + { + int[] account_array = Context + .Queryable() + .LeftJoin((a, r) => a.Id == r.FkDeviceAccountId) + .Where((a, r) => r.FkRouteInspectionPlanId == parm.fkRouteInspectionPlanId) + .Select((a, r) => a.Id) + .ToArray(); + + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.DeviceName), (a) => a.DeviceName.Contains(parm.DeviceName)) + .AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), (a) => a.DeviceSpecification.Contains(parm.DeviceSpecification)) + .And((a) => a.Status == 1) + .AndIF(parm.FkDeviceType > 0, (a) => a.FkDeviceType == parm.FkDeviceType) + ; + + + return Context.Queryable() + .Where(it => !account_array.Contains(it.Id)) + .Where(predicate.ToExpression()) + .ToPage(parm) + ; + + + } + else if (parm.Flag == 1) + { + // 获取绑定的account + return Context.Queryable() + .LeftJoin((a, r) => a.Id == r.FkDeviceAccountId) + .Where((a, r) => r.FkRouteInspectionPlanId == parm.fkRouteInspectionPlanId) + .ToPage(parm); + } + return null; + + } + + + public PagedInfo GetList_Point2(DeviceAccountQueryDto3 parm) + { + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.DeviceName), (a, r) => a.DeviceName.Contains(parm.DeviceName)) + .AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), (a, r) => a.DeviceSpecification.Contains(parm.DeviceSpecification)) + .And((a, r) => a.Status == 1) + .AndIF(parm.FkDeviceType > 0, (a, r) => a.FkDeviceType == parm.FkDeviceType) + .And((a, r) => r.FkPointInspectionPlanId == parm.fkPointInspectionPlanId) + ; + + + var temp = Context.Queryable() + .LeftJoin((a, r) => a.Id == r.FkDeviceAccountId) + .Where(predicate.ToExpression()).Select((a, r) => a); + + + if (parm.Flag == 0) + { + int[] exist = temp.Select(a => a.Id).ToArray(); + temp = Context.Queryable().Where(it => !exist.Contains(it.Id)).Distinct(); + } + + + var reponse = temp + .ToPage(parm); + + return reponse; + } + public PagedInfo GetList_Point(DeviceAccountQueryDto3 parm) + { + + //未绑定 + if (parm.Flag == 0) + { + int[] account_array = Context + .Queryable() + .LeftJoin((a, r) => a.Id == r.FkDeviceAccountId) + .Where((a, r) => r.FkPointInspectionPlanId == parm.fkPointInspectionPlanId) + .Select((a, r) => a.Id) + .ToArray(); + + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.DeviceName), (a) => a.DeviceName.Contains(parm.DeviceName)) + .AndIF(!string.IsNullOrEmpty(parm.DeviceSpecification), (a) => a.DeviceSpecification.Contains(parm.DeviceSpecification)) + .And((a) => a.Status == 1) + .AndIF(parm.FkDeviceType > 0, (a) => a.FkDeviceType == parm.FkDeviceType) + ; + + + return Context.Queryable() + .Where(it => !account_array.Contains(it.Id)) + .Where(predicate.ToExpression()) + .ToPage(parm) + ; + + + } + else if (parm.Flag == 1) + { + // 获取绑定的account + return Context.Queryable() + .LeftJoin((a, r) => a.Id == r.FkDeviceAccountId) + .Where((a, r) => r.FkPointInspectionPlanId == parm.fkPointInspectionPlanId) + .ToPage(parm); + } + return null; + + } + + + /// + /// 获取详情 + /// + /// + /// + public DeviceAccount GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加设备台账 + /// + /// + /// + public DeviceAccount AddDeviceAccount(DeviceAccount model) + { + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改设备台账 + /// + /// + /// + public int UpdateDeviceAccount(DeviceAccount model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceAccount() + //{ + // FkDeviceType = model.FkDeviceType, + // DeviceName = model.DeviceName, + // DeviceCode = model.DeviceCode, + // Workshop = model.Workshop, + // Workline = model.Workline, + // Status = model.Status, + // DeviceImage = model.DeviceImage, + // DeviceFile = model.DeviceFile, + // DeviceSpecification = model.DeviceSpecification, + // ResponsiblePerson = model.ResponsiblePerson, + // Remark = model.Remark, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + + /// + /// 获取树节点 + /// + /// + /// + /// + public List GetSelectTree2(DeviceAccountQueryDto parm) + { + try + { + var predicate = Expressionable.Create() + .And(it => it.Status == 1); + + List accountList = Queryable() + .Where(predicate.ToExpression()) + .OrderByDescending(it => it.UpdatedTime) + .OrderByDescending(it => it.CreatedTime) + .Select(it => new SelectTreeDto + { + Id = null, + ParentId = it.FkDeviceType.ToString(), + Label = (it.DeviceName + '-' + it.DeviceCode), + Value = it.FkDeviceType.ToString() + }) + .ToList(); + int[] fkDeviceTypeIds = accountList.Select(it => int.Parse(it.Value)).ToArray(); + + + List deviceTypeList = Context.Queryable() + .Where(it => fkDeviceTypeIds.Contains(it.Id)) + .Select(it => new SelectTreeDto + { + Id = it.Id.ToString(), + ParentId = it.ParentId.ToString(), + Label = it.Name, + Value = it.Name + }).ToList(); + List list = deviceTypeList.Concat(accountList).ToList(); + return list; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + + } + + /// + /// 获取树节点 + /// + /// + /// + /// + public List GetSelectTree(DeviceAccountQueryDto parm) + { + // 获取 类型父子节点 + List deviceTypeList = Context.Queryable() + .Where(it => it.Status == 1) + .OrderBy(it => it.Id) + .Select(it => new SelectTreeDto + { + Id =(it.Id * 10000).ToString(), + ParentId = (it.ParentId*10000).ToString(), + Label = it.Name, + Value = it.Name + }) + .ToList(); + // 获取 类型表 绑定的设备 父子节点 + + List accountList = Context.Queryable().Where(it => it.Status == 1).OrderBy(it => it.Id) + .Select(it => new SelectTreeDto + { + // Id = it.Id.ToString() + it.FkDeviceType.ToString(),//解决合并后id重复 + Id = it.Id.ToString(),//解决合并后id重复 + ParentId = (it.FkDeviceType*10000).ToString(), + Label = it.DeviceCode + "||" +it.DeviceName , + Value = it.Id.ToString() + }).ToList(); + + return deviceTypeList.Concat(accountList).OrderBy(it => int.Parse(it.Id)).ToList(); + + + + + } + + /// + /// 添加绑定关系 巡检计划和设备台账 + /// + /// + /// + /// + public int AddRelation(DeviceAccount_routeinspect_Dto parm, string CreatedBy) + { + List DeviceRelRpAt_list = new List(); + + + if (parm.FkDeviceAccountIdList.Length > 0) + { + foreach (var id in parm.FkDeviceAccountIdList) + { + DeviceRelRpAt rel = new DeviceRelRpAt(); + rel.FkRouteInspectionPlanId = parm.FkRouteInspectionPlanId; + rel.FkDeviceAccountId = id; + rel.CreatedBy = CreatedBy; + rel.CreatedTime = DateTime.Now; + DeviceRelRpAt_list.Add(rel); + } + } + int result = Context.Insertable(DeviceRelRpAt_list).ExecuteCommand(); + return result; + + } + + + + /// + /// 移除关系 + /// + /// + /// + /// + public int Remove_relation(string FkRouteInspectionPlanId, int FkDeviceAccountId) + { + return Context.Deleteable() + .Where(it => it.FkRouteInspectionPlanId == FkRouteInspectionPlanId) + .Where(it => it.FkDeviceAccountId == FkDeviceAccountId) + + .ExecuteCommand(); + } + + #region 点检和设备绑定关系 + + + /// + /// 添加绑定关系 巡检计划和设备台账 + /// + /// + /// + /// + + public int AddRelationPointAccount(DeviceAccount_pointinspect_Dto parm, string CreatedBy) + { + List DeviceRelRpAt_list = new List(); + + + if (parm.FkDeviceAccountIdList.Length > 0) + { + foreach (var id in parm.FkDeviceAccountIdList) + { + DeviceRelPpAt rel = new DeviceRelPpAt(); + rel.FkPointInspectionPlanId = parm.FkPointInspectionPlanId; + rel.FkDeviceAccountId = id; + rel.CreatedBy = CreatedBy; + rel.CreatedTime = DateTime.Now; + DeviceRelRpAt_list.Add(rel); + } + } + int result = Context.Insertable(DeviceRelRpAt_list).ExecuteCommand(); + return result; + + } + + + + /// + /// 移除关系 + /// + /// + /// + /// + public int RemoveRelationPointAccount(string FkPointInspectionPlanId, int FkDeviceAccountId) + { + return Context.Deleteable() + .Where(it => it.FkPointInspectionPlanId == FkPointInspectionPlanId) + .Where(it => it.FkDeviceAccountId == FkDeviceAccountId) + .ExecuteCommand(); + } + + + #endregion + + + + /// + /// 设备状态 + /// + /// 设备类型id + /// + public DeviceStatusAnalysisDto GetDeviceStatus(int devicetype_id) + { + + DeviceStatusAnalysisDto analysis = new DeviceStatusAnalysisDto(); + + // 设备总数 + int AllTotal = 0; + //正常设备数 + int NormalTotal = 0; + // 未巡点总数 + int UnmaintainedTotal = 0; + // 报修中总数 + int DamageTotal = 0; + // 停用总数 + int NoUseTotal = 0; + + Stopwatch stopwatch = new Stopwatch(); + + // 开始计时 + stopwatch.Start(); + + // 1 获取设备类型下面所有的线 + + List All_device_type = null; + + All_device_type = FindAllLeafNodes(devicetype_id); + + List LineDetailList = new List(); + // 停止计时 + stopwatch.Stop(); + + // 输出执行时间 + Console.WriteLine("代码段执行时间: {0} 秒", stopwatch.ElapsedMilliseconds / 1000); + // 2 获取每个线下的所有设备 + if (All_device_type.Count > 0) + { + List all_deviceTyepe_s = Context.Queryable().ToList(); + List all_account_s = Context.Queryable().ToList(); + List all_deviceRepair_s = Context.Queryable().ToList(); + var query_point = Context.Queryable() + .LeftJoin((e, p) => e.PlanId == p.Id) + .LeftJoin((e, p, r) => p.Id == r.FkPointInspectionPlanId) + .Where((e, p, r) => e.Status == 0 || e.Status == 1 || e.Status == 3) + .Select((e, p, r) => new + { + FkDeviceAccountId = r.FkDeviceAccountId, + + }).ToList(); + var query_route = Context.Queryable() + .LeftJoin((e, p) => e.PlanId == p.Id) + .LeftJoin((e, p, r) => p.Id == r.FkPointInspectionPlanId) + .Where((e, p, r) => e.Status == 0 || e.Status == 1 || e.Status == 3) + .Select((e, p, r) => new + { + FkDeviceAccountId = r.FkDeviceAccountId, + + }).ToList(); + + foreach (DeviceType type in All_device_type) + { + LineDetail lineDetail = new LineDetail(); + lineDetail.Workshop = all_deviceTyepe_s.Where(n => n.Id == type.ParentId).Select(n => n.Name).First(); + lineDetail.Workline = type.Name; + + + List accounts = all_account_s.Where(it => it.FkDeviceType == type.Id).ToList(); + + + lineDetail.Total = accounts.Count; + AllTotal = AllTotal + lineDetail.Total; + List Children = new List(); + if (accounts.Count > 0) + { + + // 3 获取每个设备所有状态 + foreach (var item in accounts) + { + DeviceInfo deviceInfo = new DeviceInfo(); + deviceInfo.Id = item.Id; + deviceInfo.DeviceName = item.DeviceName; + deviceInfo.DeviceCode = item.DeviceCode; + + + //0.4断是否停止中 + if (item.Status == 0) + { + NoUseTotal++; + deviceInfo.DeviceStatus = 4; + + Children.Add(deviceInfo); + continue; + } + + //0.3 判断是否报修中 + bool isExist = all_deviceRepair_s + .Where(it => it.FkDeviceId == item.Id) + .Where(it => it.Status == 0 || it.Status == 1 || it.Status == 3).Any(); + if (isExist) + { + DamageTotal++; + deviceInfo.DeviceStatus = 3; + + Children.Add(deviceInfo); + continue; + } + + + + + //var query = from person in people + // join address in addresses on person.Id equals address.PersonId into addressGroup + // from addressItem in addressGroup.DefaultIfEmpty() + // join phoneNumber in phoneNumbers on person.Id equals phoneNumber.PersonId into phoneGroup + // from phoneNumberItem in phoneGroup.DefaultIfEmpty() + // select new + // { + // PersonName = person.Name, + // Address = addressItem?.AddressLine ?? "No address available", + // PhoneNumber = phoneNumberItem?.Number ?? "No phone number available" + // }; + + + + //处理点检 + int isExist_point = query_point + .Where(it => it.FkDeviceAccountId == item.Id).Count(); + // UnmaintainedTotal = UnmaintainedTotal + isExist_point; + if (isExist_point > 0) + { + + deviceInfo.DeviceStatus = 2; + UnmaintainedTotal++; + Children.Add(deviceInfo); + continue; + + } + + + //处理巡检 + int isExist_route = query_route.Where(it => it.FkDeviceAccountId == item.Id).Count(); + + + if (isExist_route > 0) + { + deviceInfo.DeviceStatus = 2; + UnmaintainedTotal++; + Children.Add(deviceInfo); + continue; + } + deviceInfo.DeviceStatus = 1; + NormalTotal++; + Children.Add(deviceInfo); + + } + + } + + lineDetail.Children = Children; + LineDetailList.Add(lineDetail); + + } + + + } + analysis.AllTotal = AllTotal; + analysis.UnmaintainedTotal = UnmaintainedTotal; + analysis.LineDetailList = LineDetailList; + analysis.DamageTotal = DamageTotal; + analysis.NormalTotal = NormalTotal; + analysis.NoUseTotal = NoUseTotal; + + return analysis; + + } + /// + /// 查找指定节点的所有最终子节点 + /// + /// + /// + + public List FindAllLeafNodes(int targetId) + { + List list_device_types = Context.Queryable().ToList(); + List childIds = new List { targetId }; + List result = new List(); + + while (childIds.Any()) + { + int parentId = childIds.First(); + childIds.RemoveAt(0); + + List children = list_device_types.Where(n => n.ParentId == parentId).Select(n => n.Id).ToList(); + if (children.Any()) + { + childIds.AddRange(children); + } + else + { + result.Add(list_device_types.First(n => n.Id == parentId)); + } + } + + return result; + } + + /// + /// 用于在父子节点对象中,根据输入的节点 ID 找到最终的父节点: + /// + /// + /// + public DeviceType FindFinalParentNode(int nodeId) + { + DeviceType currentNode = Context.Queryable().Where(n => n.Id == nodeId).First(); + + if (currentNode == null) + { + return null; + } + + DeviceType parentNode = Context.Queryable().Where(n => n.Id == currentNode.ParentId).First(); + + while (parentNode != null) + { + currentNode = parentNode; + parentNode = Context.Queryable().Where(n => n.Id == currentNode.ParentId).First(); + } + + return currentNode; + } + } + + + +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceDataAnalysisService.cs b/DOAN.Service/MES/Device/DeviceDataAnalysisService.cs new file mode 100644 index 0000000..fcb563b --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceDataAnalysisService.cs @@ -0,0 +1,614 @@ +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using Microsoft.AspNetCore.Components.Forms; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.System; +using DOAN.Service.MES.dev.IService; + +namespace DOAN.Service.MES.dev +{ + /// + /// 设备数据分析 + /// + [AppService(ServiceType = typeof(IDeviceDataAnalysisServcie), ServiceLifetime = LifeTime.Transient)] + public class DeviceDataAnalysisService : BaseService, IDeviceDataAnalysisServcie + { + public static List FindAllLeafNodes(List nodeList, int targetId) + { + List childIds = new List { targetId }; + List result = new List(); + + while (childIds.Any()) + { + int parentId = childIds.First(); + childIds.RemoveAt(0); + + List children = nodeList.Where(n => n.ParentId == parentId).Select(n => n.Id).ToList(); + if (children.Any()) + { + childIds.AddRange(children); + } + else + { + result.Add(nodeList.First(n => n.Id == parentId)); + } + } + + return result; + } + /// + /// 故障类型 pie + /// + /// + /// + public List DefaultTypePie(DeviceDefaultDto devicedefault) + { + List resultList = new List(); + int[] all_device_type_array = null; + if (devicedefault.DevicetTypeId > 0) + { + List all_device_type_list = FindAllLeafNodes(Context.Queryable().ToList(), devicedefault.DevicetTypeId ?? 0); + all_device_type_array = all_device_type_list.Select(it => it.Id).ToArray(); + } + var predicate = Expressionable.Create() + .AndIF(all_device_type_array != null && all_device_type_array.Length > 0, (r, a, d) => all_device_type_array.Contains(a.FkDeviceType)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceName), (r, a, d) => a.DeviceName.Contains(devicedefault.DeviceName)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceCode), (r, a, d) => a.DeviceCode.Contains(devicedefault.DeviceCode)) + .AndIF(devicedefault.searchTime[0] > new DateTime(1991, 1, 1), (r, a, d) => r.CreatedTime >= devicedefault.searchTime[0]) + .AndIF(devicedefault.searchTime[1] > new DateTime(1991, 1, 1), (r, a, d) => r.CreatedTime <= devicedefault.searchTime[1]) + .And((r, a, d) => d.DictType == "mes_device_fault_type") + ; + + List deviceRepair_list = Context.Queryable() + .LeftJoin((r, a) => r.FkDeviceId == a.Id) + .LeftJoin((r, a, d) => r.Type == d.DictValue) + .Where(predicate.ToExpression()) + + .Select((r, a, d) => new DeviceRepair_chart + { + Type = r.Type, + TypeName = d.DictLabel, + }).ToList(); + + if (deviceRepair_list.Count > 0) + { + var TypeGroups = deviceRepair_list.GroupBy(it => it.TypeName); + + foreach (var group in TypeGroups) + { + DeviceStatusAnalysisResultDto result = new DeviceStatusAnalysisResultDto(); + result.name = group.Key; + result.value = group.Count(); + resultList.Add(result); + } + + } + + + + return resultList; + } + + /// + /// 每日故障数量统计 + /// + /// + /// + public DeviceFaultBarResultDto FaultTypeBar(DeviceDefaultDto devicedefault) + { + DeviceFaultBarResultDto result = new DeviceFaultBarResultDto(); + int[] all_device_type_array = null; + if (devicedefault.DevicetTypeId > 0) + { + List all_device_type_list = FindAllLeafNodes(Context.Queryable().ToList(), devicedefault.DevicetTypeId ?? 0); + all_device_type_array = all_device_type_list.Select(it => it.Id).ToArray(); + } + var predicate = Expressionable.Create() + .AndIF(all_device_type_array != null && all_device_type_array.Length > 0, (r, a, d) => all_device_type_array.Contains(a.FkDeviceType)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceName), (r, a, d) => a.DeviceName.Contains(devicedefault.DeviceName)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceCode), (r, a, d) => a.DeviceCode.Contains(devicedefault.DeviceCode)) + .AndIF(devicedefault.searchTime[0] > new DateTime(1991, 1, 1), (r, a, d) => r.CreatedTime >= devicedefault.searchTime[0]) + .AndIF(devicedefault.searchTime[1] > new DateTime(1991, 1, 1), (r, a, d) => r.CreatedTime <= devicedefault.searchTime[1]) + .And((r, a, d) => d.DictType == "mes_device_fault_type") + ; + + List deviceRepair_list = Context.Queryable() + .LeftJoin((r, a) => r.FkDeviceId == a.Id) + .LeftJoin((r, a, d) => r.Type == d.DictValue) + .Where(predicate.ToExpression()) + .Select((r, a, d) => new DeviceRepair_chart + { + Type = r.Type, + TypeName = d.DictLabel, + CreatedTime = (DateTime)r.CreatedTime + }).ToList(); + + //获取所有故障类型 + List all_fault_type = Context.Queryable().Where(it => it.DictType == "mes_device_fault_type").ToList(); + + // 先按照天进行上卷聚合,然后按照故障种类进行上卷聚合 + var first_groups = deviceRepair_list.GroupBy(it => it.CreatedTime.Date); + + string[] Xdata = new string[first_groups.Count()]; + int index = 0; + foreach (var group in first_groups) + { + Xdata[index] = group.Key.ToString("yyyy-MM-dd"); + index++; + } + List SeriesData = new List(); + foreach (SysDictData dict in all_fault_type) + { + SeriesData_Item seriesData_Item = new SeriesData_Item(); + seriesData_Item.Name = dict.DictLabel; + //这种故障在每天的值 + + int[] values = new int[first_groups.Count()]; + int index2 = 0; + foreach (var group in first_groups) + { + + //凌晨 + DateTime startOfDay = group.Key; + //午夜(23:59:59) + DateTime endOfDay = group.Key.AddDays(1).AddSeconds(-1); + + values[index2] = deviceRepair_list + .Where(it => it.CreatedTime >= startOfDay && it.CreatedTime <= endOfDay) + .Where(it => it.Type == dict.DictValue).Count(); + index2++; + } + seriesData_Item.Data = values; + SeriesData.Add(seriesData_Item); + + } + result.XData = Xdata; + result.SeriesData = SeriesData; + + return result; + + + } + + + /// + /// 获取设备故障类别累计次数折线图 + /// + /// + /// + public DeviceFaultLineResultDto FaultTypeLine(DeviceDefaultDto devicedefault) + { + DeviceFaultLineResultDto result = new DeviceFaultLineResultDto(); + int[] all_device_type_array = null; + if (devicedefault.DevicetTypeId > 0) + { + List all_device_type_list = FindAllLeafNodes(Context.Queryable().ToList(), devicedefault.DevicetTypeId ?? 0); + all_device_type_array = all_device_type_list.Select(it => it.Id).ToArray(); + } + var predicate = Expressionable.Create() + .AndIF(all_device_type_array != null && all_device_type_array.Length > 0, (r, a, d) => all_device_type_array.Contains(a.FkDeviceType)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceName), (r, a, d) => a.DeviceName.Contains(devicedefault.DeviceName)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceCode), (r, a, d) => a.DeviceCode.Contains(devicedefault.DeviceCode)) + .AndIF(devicedefault.searchTime[0] > new DateTime(1991, 1, 1), (r, a, d) => r.CreatedTime >= devicedefault.searchTime[0]) + .AndIF(devicedefault.searchTime[1] > new DateTime(1991, 1, 1), (r, a, d) => r.CreatedTime <= devicedefault.searchTime[1]) + .And((r, a, d) => d.DictType == "mes_device_fault_type") + ; + + List deviceRepair_list = Context.Queryable() + .LeftJoin((r, a) => r.FkDeviceId == a.Id) + .LeftJoin((r, a, d) => r.Type == d.DictValue) + .Where(predicate.ToExpression()) + .Select((r, a, d) => new DeviceRepair_chart + { + Id = r.Id, + Type = r.Type, + TypeName = d.DictLabel, + CreatedTime = (DateTime)r.CreatedTime + }) + .ToList(); + + + foreach (var repair in deviceRepair_list) + { + repair.AccValue_SameType = Context.Queryable().Where(it => it.Type == repair.Type) + .Where(it => it.CreatedTime <= repair.CreatedTime).Count(); + } + + + + //获取所有故障类型 + List all_fault_type = Context.Queryable().Where(it => it.DictType == "mes_device_fault_type").ToList(); + + // 先按照天进行上卷聚合,然后按照故障种类进行上卷聚合 + var first_groups = deviceRepair_list.GroupBy(it => it.CreatedTime.Date); + + string[] Xdata = new string[first_groups.Count()]; + int index = 0; + foreach (var group in first_groups) + { + Xdata[index] = group.Key.ToString("yyyy-MM-dd"); + index++; + } + //处理纵坐标 + List SeriesData = new List(); + + foreach (SysDictData dict in all_fault_type) + { + SeriesData_Item_line seriesData_Item = new SeriesData_Item_line(); + seriesData_Item.Name = dict.DictLabel; + seriesData_Item.Type = "line"; + + + int[] values = new int[first_groups.Count()]; + int index2 = 0; + foreach (var group in first_groups) + { + + //凌晨 + DateTime startOfDay = group.Key; + //午夜(23:59:59) + DateTime endOfDay = group.Key.AddDays(1).AddSeconds(-1); + + values[index2] = deviceRepair_list + .Where(it => it.CreatedTime <= endOfDay) + .Where(it => it.Type == dict.DictValue) + .Sum(it => it.AccValue_SameType); + index2++; + } + seriesData_Item.Data = values; + SeriesData.Add(seriesData_Item); + } + result.XData = Xdata; + result.SeriesData = SeriesData; + + return result; + } + + /// + /// 获取每日设备故障总数与维修完成数柱状图 + /// + /// + /// + public DeviceRepairBarResultDto FaultTypeBarByDay(DeviceDefaultDto devicedefault) + { + DeviceRepairBarResultDto result = new DeviceRepairBarResultDto(); + int[] all_device_type_array = null; + if (devicedefault.DevicetTypeId > 0) + { + List all_device_type_list = FindAllLeafNodes(Context.Queryable().ToList(), devicedefault.DevicetTypeId ?? 0); + all_device_type_array = all_device_type_list.Select(it => it.Id).ToArray(); + } + var predicate = Expressionable.Create() + .AndIF(all_device_type_array != null && all_device_type_array.Length > 0, (r, a) => all_device_type_array.Contains(a.FkDeviceType)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceName), (r, a) => a.DeviceName.Contains(devicedefault.DeviceName)) + .AndIF(!string.IsNullOrEmpty(devicedefault.DeviceCode), (r, a) => a.DeviceCode.Contains(devicedefault.DeviceCode)) + .AndIF(devicedefault.searchTime[0] > new DateTime(1991, 1, 1), (r, a) => r.CreatedTime >= devicedefault.searchTime[0]) + .AndIF(devicedefault.searchTime[1] > new DateTime(1991, 1, 1), (r, a) => r.CreatedTime <= devicedefault.searchTime[1]) + ; + + List deviceRepair_list = Context.Queryable() + .LeftJoin((r, a) => r.FkDeviceId == a.Id) + .Where(predicate.ToExpression()) + .Select((r, a) => new DeviceRepair_chart + { + Id = r.Id, + Type = r.Type, + Status = r.Status ?? 0, + CreatedTime = (DateTime)r.CreatedTime + }) + .ToList(); + + // 先按照天进行上卷聚合 + var first_groups = deviceRepair_list.GroupBy(it => it.CreatedTime.Date); + + string[] Xdata = new string[first_groups.Count()]; + int index = 0; + foreach (var group in first_groups) + { + Xdata[index] = group.Key.ToString("yyyy-MM-dd"); + index++; + } + result.XData = Xdata; + List SeriesData = new List(); + SeriesData_Item_line2 faultAll = new SeriesData_Item_line2(); + faultAll.Name = "报修数"; + + + int[] Data1 = new int[first_groups.Count()]; + int index1 = 0; + foreach (var group in first_groups) + { + Data1[index1] = group.Count(); + index1++; + + + } + faultAll.Data = Data1; + SeriesData.Add(faultAll); + + + + SeriesData_Item_line2 repair_success_all = new SeriesData_Item_line2(); + repair_success_all.Name = "维修数"; + + List deviceRepair_list_success = Context.Queryable() + .LeftJoin((r, a) => r.FkDeviceId == a.Id) + .Where(predicate.ToExpression()) + .Where((r, a) => r.Status == 2) + .Select((r, a) => new DeviceRepair_chart + { + Id = r.Id, + Type = r.Type, + Status = r.Status ?? 0, + CreatedTime = (DateTime)r.CreatedTime + }) + .ToList(); + + // 先按照天进行上卷聚合 + var first_groups_success = deviceRepair_list.GroupBy(it => it.CreatedTime.Date); + int[] Data2 = new int[first_groups_success.Count()]; + int index2 = 0; + foreach (var group in first_groups_success) + { + Data2[index2] = group.Count(); + index2++; + + + } + repair_success_all.Data = Data2; + + + SeriesData.Add(repair_success_all); + result.SeriesData = SeriesData; + + return result; + } + + + + /// + /// 获取每日点检巡检总数折线图 + /// + /// + /// + public TaskLineResultDto TaskLinebyDay(DeviceDefaultDto devicedefault) + { + TaskLineResultDto taskLine = new TaskLineResultDto(); + var predicate = Expressionable.Create() + .AndIF(devicedefault.searchTime[0] > new DateTime(1991, 1, 1), (r) => r.CreatedTime >= devicedefault.searchTime[0]) + .AndIF(devicedefault.searchTime[1] > new DateTime(1991, 1, 1), (r) => r.CreatedTime <= devicedefault.searchTime[1]) + .ToExpression(); + List InitDataCollection = Context.Queryable().Where(predicate).ToList(); + List SeriesData = new List(); + var SecondDataCollection = InitDataCollection.GroupBy(it => ((DateTime)it.CreatedTime).Date); + + string[] Xdata = new string[SecondDataCollection.Count()]; + int index = 0; + foreach (var group in SecondDataCollection) + { + Xdata[index] = group.Key.ToString("yyyy-MM-dd"); + index++; + } + taskLine.XData = Xdata; + SeriesData_Item_line3 line3 = new SeriesData_Item_line3(); + int[] Data = new int[SecondDataCollection.Count()]; + int index2 = 0; + foreach (var group in SecondDataCollection) + { + + Data[index2] = group.Count(); + + index2++; + } + line3.Data = Data; + SeriesData.Add(line3); + taskLine.SeriesData = SeriesData; + + + + return taskLine; + } + private PersonnelResponseResultDto dataAnalysis(DeviceDefaultDto devicedefault) + { + PersonnelResponseResultDto personnelResponseResultDto = new PersonnelResponseResultDto(); + personnelResponseResultDto.XData = []; + personnelResponseResultDto.SeriesData = null; + // 任务接受响应系列 + PersonnelResponse_Series task_accept_series = new PersonnelResponse_Series(); + + var predicate = Expressionable.Create() + .AndIF(devicedefault.searchTime[0] > new DateTime(1991, 1, 1), (r) => r.CreatedTime >= devicedefault.searchTime[0]) + .AndIF(devicedefault.searchTime[1] > new DateTime(1991, 1, 1), (r) => r.CreatedTime <= devicedefault.searchTime[1]) + .And(it => it.DistributedTime != DateTime.MinValue) + .And(it => it.StartTime != DateTime.MinValue) + .And(it => it.EndTime != DateTime.MinValue) + .ToExpression(); + + List InitDataCollection = Context + .Queryable() + .Where(predicate) + .ToList(); + if (InitDataCollection.Count == 0) + { + personnelResponseResultDto.TaskTotal = 0; + personnelResponseResultDto.TaskMax = new TimeSpan(0); + personnelResponseResultDto.TaskMin = new TimeSpan(0); + personnelResponseResultDto.TaskAvg = new TimeSpan(0); + return personnelResponseResultDto; + } + + personnelResponseResultDto.TaskTotal = InitDataCollection.Count; + PersonnelResponseDto[] SecondDataCollection = new PersonnelResponseDto[InitDataCollection.Count]; + + string[] XData = new string[InitDataCollection.Count]; + double[] resultDate = new double[InitDataCollection.Count]; + if (InitDataCollection.Count > 0) + { + int index = 0; + foreach (var item in InitDataCollection) + { + XData[index] = item.TaskName; + PersonnelResponseDto temp = new PersonnelResponseDto(); + temp.Id = item.Id; + temp.TaskName = item.TaskName; + + temp.Accept_response = (item.StartTime ?? DateTime.Now) - (item.DistributedTime ?? DateTime.Now); + temp.Action_response = (item.EndTime ?? DateTime.Now) - (item.StartTime ?? DateTime.Now); + + SecondDataCollection[index] = temp; + index++; + } + + } + + + #region 固定配置 + + MarkPoint_ markPoint_ = new MarkPoint_(); + TypeName[] data = new TypeName[2]; + TypeName item1 = new TypeName(); + item1.Type = "max"; + item1.Name = "最大值"; + data[0] = item1; + TypeName item2 = new TypeName(); + item2.Type = "min"; + item2.Name = "最小值"; + data[1] = item2; + markPoint_.data = data; + task_accept_series.markPoint = markPoint_; + MarkPoint_ markLine = new MarkPoint_(); + TypeName[] data2 = new TypeName[1]; + TypeName item3 = new TypeName(); + item3.Type = "average"; + item3.Name = "平均值"; + data2[0] = item3; + markLine.data = data2; + task_accept_series.markLine = markLine; + #endregion + if (devicedefault.searchType == 1) + { + task_accept_series.Name = "人员接受任务响应时间"; + personnelResponseResultDto.TaskMax = SecondDataCollection.Max(it => it.Accept_response); + personnelResponseResultDto.TaskMin = SecondDataCollection.Min(it => it.Accept_response); + personnelResponseResultDto.TaskAvg = CalculateAverageTimeSpan(SecondDataCollection.Select(it => it.Action_response).ToArray()); + personnelResponseResultDto.SeriesData = task_accept_series; + resultDate = SecondDataCollection.Select(it => Math.Round(it.Accept_response.TotalMinutes, 2)).ToArray(); + } + else if (devicedefault.searchType == 2) + { + task_accept_series.Name = "人员处理任务响应时间"; + personnelResponseResultDto.TaskMax = SecondDataCollection.Max(it => it.Action_response); + personnelResponseResultDto.TaskMin = SecondDataCollection.Min(it => it.Action_response); + personnelResponseResultDto.TaskAvg = CalculateAverageTimeSpan(SecondDataCollection.Select(it => it.Action_response).ToArray()); + personnelResponseResultDto.SeriesData = task_accept_series; + resultDate = SecondDataCollection.Select(it => Math.Round(it.Action_response.TotalMinutes, 2)).ToArray(); + } + personnelResponseResultDto.XData = XData; + personnelResponseResultDto.SeriesData.Data = resultDate; + return personnelResponseResultDto; + + } + /// + /// 获取人员响应折线图 + /// + /// + /// + public PersonnelResponseResultDto PersonResponse(DeviceDefaultDto devicedefault) + { + PersonnelResponseResultDto crount = dataAnalysis(devicedefault); + DeviceDefaultDto devicedefault_last = new DeviceDefaultDto(); + devicedefault_last.searchType = devicedefault.searchType; + DateTime lastMondayMidnight, lastSundayMidnight; + GetLastWeekBoundaries(devicedefault.searchTime[0], out lastMondayMidnight, out lastSundayMidnight); + devicedefault_last.searchTime = new DateTime[2] { lastMondayMidnight, lastSundayMidnight }; + PersonnelResponseResultDto last = dataAnalysis(devicedefault_last); + crount.lastTotalPer = CalculatePercentageIncrease(crount.TaskTotal, last.TaskTotal); + crount.lastMaxPer = CalculatePercentageIncrease(crount.TaskMax, last.TaskMax); + crount.lastMinPer = CalculatePercentageIncrease(crount.TaskMin, last.TaskMin); + crount.lastAvgPer = CalculatePercentageIncrease(crount.TaskAvg, last.TaskAvg); + + + return crount; + } + private static double CalculatePercentageIncrease(int number1, int number2) + { + if (number2 == 0) + { + return 100; + } + + return ((double)(number1 - number2) / number2) * 100; + } + private static double CalculatePercentageIncrease(TimeSpan timeSpan1, TimeSpan timeSpan2) + { + double totalSeconds1 = timeSpan1.TotalSeconds; + double totalSeconds2 = timeSpan2.TotalSeconds; + + if (totalSeconds2 == 0) + { + return 100; + } + + return ((totalSeconds1 - totalSeconds2) / totalSeconds2) * 100; + } + public static TimeSpan CalculateAverageTimeSpan(TimeSpan[] timeSpans) + { + // 将 TimeSpan 数组中的每个 TimeSpan 值转换为总秒数 + double totalSeconds = timeSpans.Sum(ts => ts.TotalSeconds); + + // 计算平均总秒数 + double averageSeconds = totalSeconds / timeSpans.Length; + + // 将平均总秒数转换为 TimeSpan 格式 + TimeSpan averageTimeSpan = TimeSpan.FromSeconds(averageSeconds); + + return averageTimeSpan; + } + public static void GetLastWeekBoundaries(DateTime inputDateTime, out DateTime lastMondayMidnight, out DateTime lastSundayMidnight) + { + DayOfWeek currentDayOfWeek = inputDateTime.DayOfWeek; + int daysToSubtract = (int)currentDayOfWeek + 6; // 6 days to subtract to get to last Monday + + lastMondayMidnight = inputDateTime.Date.AddDays(-daysToSubtract).AddDays(-7).Date; // Last Monday midnight + lastSundayMidnight = lastMondayMidnight.AddDays(6).AddHours(23).AddMinutes(59).AddSeconds(59); // Last Sunday midnight + } + + /// + /// 获取大屏总数 + /// + /// + /// + public FullScreenTotal GetAllTotal() + { + FullScreenTotal screenTotal = new FullScreenTotal(); + //设备可用数 + screenTotal.UseDeviceTotal = Context.Queryable().Where(it => it.Status == 1).Count(); + + + //设备停机数 + screenTotal.UnUseDeviceTotal = Context.Queryable().Where(it => it.Status == 0).Count(); + + // 累计任务数 + screenTotal.TaskTotal = Context.Queryable().Count(); + + //累计任务完成数 + screenTotal.FinishTaskTotal= Context.Queryable().Where(it => it.Status == 2).Count(); + + //累计报修数 + screenTotal.RepairTotal = Context.Queryable().Count(); + + //累计维护数 + screenTotal.FinishRepairTotal = Context.Queryable().Where(it=>it.Status==2).Count(); + + return screenTotal; + + + } + } +} diff --git a/DOAN.Service/MES/Device/DeviceFormConfigService.cs b/DOAN.Service/MES/Device/DeviceFormConfigService.cs new file mode 100644 index 0000000..82fa73d --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceFormConfigService.cs @@ -0,0 +1,85 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Model.Dto; + +using DOAN.Repository; + +using System.Linq; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; + +namespace DOAN.Service.MES.dev +{ + /// + /// 设备检查项表单配置表Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceFormConfigService), ServiceLifetime = LifeTime.Transient)] + public class DeviceFormConfigService : BaseService, IDeviceFormConfigService + { + /// + /// 查询设备检查项表单配置表列表 + /// + /// + /// + public PagedInfo GetList(DeviceFormConfigQueryDto parm) + { + var predicate = Expressionable.Create().And(it => it.FkDeviceInspectId == parm.FkDeviceInspectId); + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DeviceFormConfig GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加设备检查项表单配置表 + /// + /// + /// + public DeviceFormConfig AddDeviceFormConfig(DeviceFormConfig model) + { + model.Id= SnowFlakeSingle.Instance.NextId().ToString(); + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改设备检查项表单配置表 + /// + /// + /// + public int UpdateDeviceFormConfig(DeviceFormConfig model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceFormConfig() + //{ + // Type = model.Type, + // Content = model.Content, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceInspectService.cs b/DOAN.Service/MES/Device/DeviceInspectService.cs new file mode 100644 index 0000000..3fba469 --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceInspectService.cs @@ -0,0 +1,192 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; + + +using DOAN.Repository; + +using System.Linq; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; + +namespace DOAN.Service.MES.dev +{ + /// + /// 设备检查项Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceInspectService), ServiceLifetime = LifeTime.Transient)] + public class DeviceInspectService : BaseService, IDeviceInspectService + { + /// + /// 查询设备检查项列表 + /// + /// + /// + public PagedInfo GetList(DeviceInspectQueryDto parm) + { + var predicate = Expressionable.Create(); + + predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name)) + .AndIF(parm.Status >= 0, it => it.Status == parm.Status) + .AndIF(parm.Type >= 0, it => it.Type == parm.Type) + ; + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + /// + /// 设备绑定模块 查询未绑定且状态为1 的设备检查项 + /// + /// + /// + public PagedInfo GetList2(DeviceInspectQueryDto2 parm) + { + // 获取未绑定 + if (parm.Isbind == 0) + { + int[] binded = Context.Queryable() + .Where(it => it.FkAccountId == parm.FkAccountId) + + .Select(it => it.FkInspectId.Value).ToArray(); + + var exp = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.Name),it=>it.Name.Contains(parm.Name)) + .AndIF(parm.Type > 0,it=>it.Type==parm.Type) + .And(it=>it.Status==1); + return Context.Queryable() + .Where(it => !binded.Contains(it.Id)) + .Where(exp.ToExpression()) + .ToPage(parm); + + + } + else if (parm.Isbind == 1) + { + + var exp = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.Name), (r, i) => i.Name.Contains(parm.Name)) + .AndIF(parm.Type > 0, (r, i) => i.Type == parm.Type) + .And((r, i) => i.Status == 1); + // 获取绑定 + return Context.Queryable() + .RightJoin((r, i) => r.FkInspectId == i.Id) + .Where((r, i) => r.FkAccountId == parm.FkAccountId) + .Where(exp.ToExpression()) + .OrderBy((r, i) => r.Sort) + .Select((r, i) => i).ToPage(parm); + } + return null; + + + + + } + + /// + /// 获取详情 + /// + /// + /// + public DeviceInspect GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加设备检查项 + /// + /// + /// + public DeviceInspect AddDeviceInspect(DeviceInspect model) + { + + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改设备检查项 + /// + /// + /// + public int UpdateDeviceInspect(DeviceInspect model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceInspect() + //{ + // Image = model.Image, + // Sort = model.Sort, + // Type = model.Type, + // Remark = model.Remark, + // Status = model.Status, + // Name = model.Name, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + /// + /// 增加绑定关系 + /// + /// + /// + public int AddBindrelative(DeviceInspectQueryDto3 parm, string name) + { + int result = 0; + List rel_account_inspect_list = new List(); + + if (parm.inspect_ids != null && parm.inspect_ids.Count() > 0) + { + foreach (var id in parm.inspect_ids) + { + DeviceRelAccountInspect inspect = new DeviceRelAccountInspect(); + inspect.FkAccountId = parm.account_id; + inspect.FkInspectId = id; + inspect.CreatedBy = name; + inspect.CreatedTime = DateTime.Now; + inspect.Sort = 1; + rel_account_inspect_list.Add(inspect); + } + + result = Context.Insertable(rel_account_inspect_list).ExecuteCommand(); + + } + + return result; + } + /// + /// 删除绑定接口 + /// + /// + /// + /// + + public int RemoveBindrelative(int account_id, int inspect_id) + { + return Context.Deleteable().Where(it => it.FkAccountId == account_id).Where(it => it.FkInspectId == inspect_id).ExecuteCommand(); + } + + + public int SortBindrelative(List parm) + { + return Context.Updateable(parm).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand(); + } + + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceMaintenanceRecordService.cs b/DOAN.Service/MES/Device/DeviceMaintenanceRecordService.cs new file mode 100644 index 0000000..19a5d4f --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceMaintenanceRecordService.cs @@ -0,0 +1,89 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Repository; + +using System.Linq; + +using Aliyun.OSS; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; + +namespace DOAN.Service.MES.dev +{ + /// + /// 维修记录Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceMaintenanceRecordService), ServiceLifetime = LifeTime.Transient)] + public class DeviceMaintenanceRecordService : BaseService, IDeviceMaintenanceRecordService + { + /// + /// 查询维修记录列表 + /// + /// + /// + public PagedInfo GetList(DeviceMaintenanceRecordQueryDto parm) + { + var predicate = Expressionable.Create(); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DeviceMaintenanceRecord GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加维修记录 + /// + /// + /// + public DeviceMaintenanceRecord AddDeviceMaintenanceRecord(DeviceMaintenanceRecord model) + { + model.Id = SnowFlakeSingle.Instance.NextId().ToString(); + return Context.Insertable(model).ExecuteReturnEntity(); + } + + + /// + /// 修改维修记录 + /// + /// + /// + public int UpdateDeviceMaintenanceRecord(DeviceMaintenanceRecord model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceMaintenanceRecord() + //{ + // MaintanancePerson = model.MaintanancePerson, + // Phone = model.Phone, + // Result = model.Result, + // MaintenanceTime = model.MaintenanceTime, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DevicePointInspectionPlanService.cs b/DOAN.Service/MES/Device/DevicePointInspectionPlanService.cs new file mode 100644 index 0000000..50b6d1a --- /dev/null +++ b/DOAN.Service/MES/Device/DevicePointInspectionPlanService.cs @@ -0,0 +1,93 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Repository; + +using System.Linq; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; +using System.Xml.Linq; + +namespace DOAN.Service.MES.dev +{ + /// + /// 点检任务Service业务层处理 + /// + [AppService(ServiceType = typeof(IDevicePointInspectionPlanService), ServiceLifetime = LifeTime.Transient)] + public class DevicePointInspectionPlanService : BaseService, IDevicePointInspectionPlanService + { + /// + /// 查询点检任务列表 + /// + /// + /// + public PagedInfo GetList(DevicePointInspectionPlanQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name)) + .AndIF(parm.Status > -1, it => it.Status == parm.Status) + .AndIF(parm.Starttime != null, it => it.CreatedTime >= parm.Starttime) + .AndIF(parm.Endtime != null, it => it.CreatedTime <= parm.Endtime) + .AndIF(parm.InnerType > -1, it => it.InnerType == parm.InnerType); + + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DevicePointInspectionPlan GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加点检任务 + /// + /// + /// + public DevicePointInspectionPlan AddDevicePointInspectionPlan(DevicePointInspectionPlan model) + { + model.Id = SnowFlakeSingle.Instance.NextId().ToString(); + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改点检任务 + /// + /// + /// + public int UpdateDevicePointInspectionPlan(DevicePointInspectionPlan model) + { + //var response = Update(w => w.Id == model.Id, it => new DevicePointInspectionPlan() + //{ + // Name = model.Name, + // Status = model.Status, + // Type = model.Type, + // Remark = model.Remark, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceRepairService.cs b/DOAN.Service/MES/Device/DeviceRepairService.cs new file mode 100644 index 0000000..c5d5cde --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceRepairService.cs @@ -0,0 +1,138 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Repository; + +using System.Linq; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; + +namespace DOAN.Service.MES.dev +{ + /// + /// 报修单Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceRepairService), ServiceLifetime = LifeTime.Transient)] + public class DeviceRepairService : BaseService, IDeviceRepairService + { + /// + /// 查询报修单列表 + /// + /// + /// + public PagedInfo GetList(DeviceRepairQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(!string.IsNullOrEmpty(parm.RepairOrder), dr => dr.RepairOrder.Contains(parm.RepairOrder)) + .AndIF(!string.IsNullOrEmpty(parm.RepairPeron), dr => dr.RepairPeron.Contains(parm.RepairPeron)) + .AndIF(!string.IsNullOrEmpty(parm.Phone), dr => dr.Phone.Contains(parm.Phone)) + .AndIF(parm.FkDeviceId > 0, dr => dr.FkDeviceId == parm.FkDeviceId) + .AndIF(!string.IsNullOrEmpty(parm.Type), dr => dr.Type == parm.Type) + .AndIF(parm.Status > -1, dr => dr.Status == parm.Status) + .AndIF(parm.TimeRange != null && (parm.TimeRange[0] > new DateTime(1990, 1, 1)), dr => dr.CreatedTime >= parm.TimeRange[0]) + .AndIF(parm.TimeRange != null && (parm.TimeRange[1] > new DateTime(1990, 1, 1)), dr => dr.CreatedTime <= parm.TimeRange[1]) + ; + + var response = Queryable() + .LeftJoin((dr, da) => dr.FkDeviceId == da.Id) + .Where(predicate.ToExpression()) + .Select() + .ToPage(parm); + //.ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DeviceRepair GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加报修单 + /// + /// + /// + public DeviceRepair AddDeviceRepair(DeviceRepair model) + { + model.Id = SnowFlakeSingle.Instance.NextId().ToString(); + model.RepairOrder = GetNextRepairNo(); + model.Status = 1; + return Context.Insertable(model).ExecuteReturnEntity(); + } + + + /// + /// 生成维修单编号 + /// + /// + public string GetNextRepairNo() + { + string split = "-"; + string titleStr = "MR"; + string timeStr = DateTime.Now.ToString("yyyyMMdd"); + var predicate = Expressionable.Create() + .And(it => it.RepairOrder.Contains(timeStr)); + var lastDeviceRepair = Queryable() + .Where(predicate.ToExpression()) + .OrderByDescending(it => it.Id) + .First(); + if (lastDeviceRepair != null && lastDeviceRepair.RepairOrder != null) + { + if (int.TryParse(lastDeviceRepair.RepairOrder.Split(split)[2], out int lastNum)) + { + return titleStr + split + timeStr + split + (lastNum + 1).ToString("000"); + } + else + { + return titleStr + split + timeStr + split + "001"; + } + + } + else + { + return titleStr + split + timeStr + split + "001"; + } + + } + + /// + /// 修改报修单 + /// + /// + /// + public int UpdateDeviceRepair(DeviceRepair model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceRepair() + //{ + // RepairOrder = model.RepairOrder, + // Type = model.Type, + // RepairPeron = model.RepairPeron, + // Phone = model.Phone, + // FaultDescription = model.FaultDescription, + // File = model.File, + // Status = model.Status, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceRouteInspectionPlanService.cs b/DOAN.Service/MES/Device/DeviceRouteInspectionPlanService.cs new file mode 100644 index 0000000..10a1686 --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceRouteInspectionPlanService.cs @@ -0,0 +1,136 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Repository; + +using System.Linq; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Service.MES.dev.IService; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace DOAN.Service.MES.dev +{ + /// + /// 巡检计划Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceRouteInspectionPlanService), ServiceLifetime = LifeTime.Transient)] + public class DeviceRouteInspectionPlanService : BaseService, IDeviceRouteInspectionPlanService + { + /// + /// 查询巡检计划列表 + /// + /// + /// + public PagedInfo GetList(DeviceRouteInspectionPlanQueryDto parm) + { + var predicate = Expressionable.Create(); + + predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name.Contains(parm.Name)) + .AndIF(parm.LifeCycleStart != null, it => it.LifeCycleStart >= parm.LifeCycleStart) + .AndIF(parm.LifeCycleEnd != null, it => it.LifeCycleEnd <= parm.LifeCycleEnd) + .AndIF(parm.ExcuteCycleType > 0, it => it.ExcuteCycleType == parm.ExcuteCycleType) + .AndIF(parm.InnerType>-1, it => it.InnerType == parm.InnerType); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DeviceRouteInspectionPlan GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加巡检计划 + /// + /// + /// + public DeviceRouteInspectionPlan AddDeviceRouteInspectionPlan(DeviceRouteInspectionPlan model) + { + model.Id = SnowFlakeSingle.Instance.NextId().ToString(); + + switch (model.ExcuteCycleType) + { + case 1: + model.WeekList = ""; + model.MonthDayList = ""; + break; + case 2: + model.DayNum = null; + model.MonthDayList = ""; + break; + case 3: + model.DayNum = null; + model.WeekList = ""; + break; + + } + + + + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改巡检计划 + /// + /// + /// + public int UpdateDeviceRouteInspectionPlan(DeviceRouteInspectionPlan model) + { + switch (model.ExcuteCycleType) + { + // 每日 + case 1: + model.WeekList = ""; + model.MonthDayList = ""; + break; + //每周 + case 2: + model.DayNum = null; + model.MonthDayList = ""; + break; + //每月 + case 3: + model.WeekList = ""; + model.DayNum = null; + break; + } + var response = Update(w => w.Id == model.Id, it => new DeviceRouteInspectionPlan() + { + Name = model.Name, + Status = model.Status, + InnerType = model.InnerType, + LifeCycleStart = model.LifeCycleStart, + LifeCycleEnd = model.LifeCycleEnd, + ExcuteCycleType = model.ExcuteCycleType, + DayNum = model.DayNum, + WeekList = model.WeekList, + MonthDayList = model.MonthDayList, + Remark = model.Remark, + + UpdatedBy = model.UpdatedBy, + UpdatedTime = model.UpdatedTime, + }); + return response; + // return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceTaskExecuteResultService.cs b/DOAN.Service/MES/Device/DeviceTaskExecuteResultService.cs new file mode 100644 index 0000000..4c12754 --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceTaskExecuteResultService.cs @@ -0,0 +1,99 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; + +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using DOAN.Service.MES.dev.IService; +using DOAN.Repository; + +using System.Linq; +using static System.Runtime.InteropServices.JavaScript.JSType; + +namespace DOAN.Service.MES.dev +{ + /// + /// 巡检/点检任务结果表Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceTaskExecuteResultService), ServiceLifetime = LifeTime.Transient)] + public class DeviceTaskExecuteResultService : BaseService, IDeviceTaskExecuteResultService + { + /// + /// 查询巡检/点检任务结果表列表 + /// + /// + /// + public PagedInfo GetList(DeviceTaskExecuteResultQueryDto parm) + { + var predicate = Expressionable.Create() + .AndIF(parm.PlanType>0,it=>it.PlanType==parm.PlanType) + .AndIF(!string.IsNullOrEmpty(parm.PlanName),it=>it.PlanName.Contains(parm.PlanName)) + .AndIF(!string.IsNullOrEmpty(parm.DeviceName),it=>it.DeviceName.Contains(parm.DeviceName)) + .AndIF(parm.Starttime> DateTime.MinValue, it=>it.UpdatedTime>= parm.Starttime) + .AndIF(parm.Endtime> DateTime.MinValue, it=>it.UpdatedTime <= parm.Endtime) + ; + + var response = Queryable() + .Where(predicate.ToExpression()) + .OrderByDescending(it=>it.Id) + .ToPage(parm); + + return response; + } + + + /// + /// 获取详情 + /// + /// + /// + public DeviceTaskExecuteResult GetInfo(string Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加巡检/点检任务结果表 + /// + /// + /// + public DeviceTaskExecuteResult AddDeviceTaskExecuteResult(DeviceTaskExecuteResult model) + { + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改巡检/点检任务结果表 + /// + /// + /// + public int UpdateDeviceTaskExecuteResult(DeviceTaskExecuteResult model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceTaskExecuteResult1() + //{ + // PlanType = model.PlanType, + // PlanName = model.PlanName, + // DeviceName = model.DeviceName, + // InspectName = model.InspectName, + // FormType = model.FormType, + // FormTitle = model.FormTitle, + // FormName = model.FormName, + // Person = model.Person, + // Remark = model.Remark, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + } +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs b/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs new file mode 100644 index 0000000..9feb8fb --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceTaskExecuteService.cs @@ -0,0 +1,802 @@ +using System; +using System.Linq; +using DOAN.Model; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using DOAN.Repository; +using DOAN.Service.MES.dev.IService; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using JinianNet.JNTemplate; +using JinianNet.JNTemplate.Nodes; +using Mapster; +using Microsoft.AspNetCore.Authentication; +using Newtonsoft.Json.Linq; +using SqlSugar; +using SqlSugar.IOC; + +namespace DOAN.Service.MES.dev +{ + /// + /// 任务执行Service业务层处理 + /// + [AppService( + ServiceType = typeof(IDeviceTaskExecuteService), + ServiceLifetime = LifeTime.Transient + )] + public class DeviceTaskExecuteService + : BaseService, + IDeviceTaskExecuteService + { + /// + /// 查询任务执行列表 + /// + /// + /// + public PagedInfo GetList(DeviceTaskExecuteQueryDto parm) + { + var predicate = Expressionable + .Create() + .AndIF( + !string.IsNullOrEmpty(parm.TaskName), + it => it.TaskName.Contains(parm.TaskName) + ) + .AndIF( + parm.TimeRange != null && (parm.TimeRange[0] > new DateTime(1990, 1, 1)), + it => it.CreatedTime >= parm.TimeRange[0] + ) + .AndIF( + parm.TimeRange != null && (parm.TimeRange[1] > new DateTime(1990, 1, 1)), + it => it.CreatedTime <= parm.TimeRange[1] + ) + .AndIF(parm.Type > -1, it => it.Type == parm.Type) + .AndIF(parm.Status > -1, it => it.Status == parm.Status); + + var response = Queryable() + .OrderByDescending(x => x.Id) + .Where(predicate.ToExpression()) + .ToPage(parm); + + foreach (DeviceTaskExecuteDto item in response.Result) + { + if (item.StartTime > DateTime.MinValue && item.EndTime > DateTime.MinValue) + { + TimeSpan timeDifference = item.EndTime.Value - item.StartTime.Value; + + double minutes = timeDifference.TotalMinutes; + double roundedMinutes = Math.Round(minutes, 1); + item.ConsumeTime = roundedMinutes; + } + } + + return response; + } + + /// + /// 获取详情 + /// + /// + /// + public DeviceTaskExecute GetInfo(string Id) + { + var response = Queryable().Where(x => x.Id == Id).First(); + + return response; + } + + /// + /// 添加任务执行 + /// + /// + /// + public DeviceTaskExecute AddDeviceTaskExecute(DeviceTaskExecute model) + { + model.Id = SnowFlakeSingle.Instance.NextId().ToString(); + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改任务执行 + /// + /// + /// + public int UpdateDeviceTaskExecute(DeviceTaskExecute model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceTaskExecute() + //{ + // TaskName = model.TaskName, + // Type = model.Type, + // DistributedTime = model.DistributedTime, + // StartTime = model.StartTime, + // EndTime = model.EndTime, + // Status = model.Status, + // Remark = model.Remark, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + return Update(model, true); + } + + public int Update_task_status(DeviceTaskExecuteQueryDto2 parm) + { + var response = Update( + w => w.Id == parm.Id, + it => new DeviceTaskExecute() + { + Status = parm.Status, + + UpdatedBy = parm.UpdatedBy, + UpdatedTime = parm.UpdatedTime, + } + ); + return response; + } + + /// + /// 清空任务执行 + /// + /// + public bool TruncateDeviceTaskExecute() + { + var newTableName = $"device_task_execute_{DateTime.Now:yyyyMMdd}"; + if (Queryable().Any() && !Context.DbMaintenance.IsAnyTable(newTableName)) + { + Context.DbMaintenance.BackupTable("device_task_execute", newTableName); + } + + return Truncate(); + } + + /// + /// 导入任务执行 + /// + /// + public (string, object, object) ImportDeviceTaskExecute(List list) + { + var x = Context + .Storageable(list) + .SplitInsert(it => !it.Any()) + .SplitError(x => x.Item.Type.IsEmpty(), "任务类型(1是巡检,2是点检)不能为空") + //.WhereColumns(it => it.UserName)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2}) + .ToStorage(); + var result = x.AsInsertable.ExecuteCommand(); //插入可插入部分; + + string msg = + $"插入{x.InsertList.Count} 更新{x.UpdateList.Count} 错误数据{x.ErrorList.Count} 不计算数据{x.IgnoreList.Count} 删除数据{x.DeleteList.Count} 总共{x.TotalList.Count}"; + Console.WriteLine(msg); + + //输出错误信息 + foreach (var item in x.ErrorList) + { + Console.WriteLine("错误" + item.StorageMessage); + } + foreach (var item in x.IgnoreList) + { + Console.WriteLine("忽略" + item.StorageMessage); + } + + return (msg, x.ErrorList, x.IgnoreList); + } + + /// + /// 任务计划调度 扫描每日巡检任务 + /// + /// + public int ScanEveryTask() + { + int result = 0; + List InitDataList = DbScoped.SugarScope.CopyNew() + .Queryable() + .Where(it => it.Status == 1) + .Where(it => it.LifeCycleStart <= DateTime.Now) + .Where(it => it.LifeCycleEnd >= DateTime.Now) + .ToList(); + // 今日时间 + DateTime CurrentTime = new DateTime( + DateTime.Now.Year, + DateTime.Now.Month, + DateTime.Now.Day, + 0, + 0, + 0 + ); + + //1. 扫描巡检 + List deviceRouteInspectionPlan_execute_List = + new List(); + #region 1.1 每日类型处理 + + List RouteInspectionPlan_day_List = InitDataList + .Where(it => it.ExcuteCycleType == 1) + .ToList(); + + Console.WriteLine("每日类型处理" + RouteInspectionPlan_day_List.Count); + if (RouteInspectionPlan_day_List != null && RouteInspectionPlan_day_List.Count > 0) + { + foreach (var item in RouteInspectionPlan_day_List) + { + //开始日期 + DateTime start_cal = (DateTime)item.CreatedTime; + start_cal = new DateTime( + start_cal.Year, + start_cal.Month, + start_cal.Day, + 0, + 0, + 0 + ); + //循环周期 + int cycle_period = (int)item.DayNum; + + + DateTime date = start_cal; + do + { + date = date.AddDays(cycle_period); + if (date == CurrentTime) + { + //今日要执行任务 + deviceRouteInspectionPlan_execute_List.Add(item); + break; + } + } while (date <= CurrentTime); + } + } + #endregion + + #region 1.2 每周类型处理 + + + List DeviceRouteInspectionPlan_week_list = InitDataList + .Where(it => it.ExcuteCycleType == 2) + .ToList(); + + Console.WriteLine("每周类型处理" + DeviceRouteInspectionPlan_week_list.Count); + int dayofweek = (int)CurrentTime.DayOfWeek; + if (CurrentTime.DayOfWeek == DayOfWeek.Sunday) + { + dayofweek = 7; + } + if ( + DeviceRouteInspectionPlan_week_list != null + && DeviceRouteInspectionPlan_week_list.Count > 0 + ) + { + foreach (var item in DeviceRouteInspectionPlan_week_list) + { + string[] cycle_period = item.WeekList.Split(","); + if (cycle_period.Length > 0) + { + for (int i = 0; i < cycle_period.Length; i++) + { + try + { + Console.WriteLine("cycle_period[i]=" + cycle_period[i]); + if (dayofweek == Convert.ToInt32(cycle_period[i])) + { + deviceRouteInspectionPlan_execute_List.Add( + (DeviceRouteInspectionPlan)item + ); + break; + } + } + catch (FormatException ex) + { + Console.WriteLine("An error occurred: " + ex.Message); + continue; + } + } + } + } + } + #endregion + + #region 1.3 每月类型处理 + + List DeviceRouteInspectionPlan_month_list = InitDataList + .Where(it => it.ExcuteCycleType == 3) + .ToList(); + + Console.WriteLine("每月类型处理" + DeviceRouteInspectionPlan_month_list.Count); + if ( + DeviceRouteInspectionPlan_month_list != null + && DeviceRouteInspectionPlan_month_list.Count > 0 + ) + { + foreach (var item in DeviceRouteInspectionPlan_month_list) + { + try + { + if (CurrentTime.Day == Convert.ToInt32(item.MonthDayList)) + { + deviceRouteInspectionPlan_execute_List.Add( + (DeviceRouteInspectionPlan)item + ); + continue; + } + } + catch (FormatException ex) + { + Console.WriteLine("An error occurred: " + ex.Message); + continue; + } + } + } + + #endregion + + + // 插入数据库 + List executes = new List(); + if (deviceRouteInspectionPlan_execute_List.Count > 0) + { + foreach (var item in deviceRouteInspectionPlan_execute_List) + { + DeviceTaskExecute taskExecute = new DeviceTaskExecute(); + taskExecute.Id = SnowFlakeSingle.Instance.NextId().ToString(); + taskExecute.TaskName = item.Name; + taskExecute.PlanId = item.Id; + taskExecute.Type = 1; + taskExecute.DistributedTime = DateTime.Now; + taskExecute.Status = 0; + taskExecute.CreatedTime = DateTime.Now; + executes.Add(taskExecute); + } + + if (executes.Count > 0) + { + result = Context.Insertable(executes).ExecuteCommand(); + } + } + + return result; + } + + /// + /// 派发点检任务 + /// + /// + /// + public int ExecutionTask_point(string id) + { + DevicePointInspectionPlan point = Context + .Queryable() + .Where(it => it.Id == id) + .First(); + + DeviceTaskExecute taskExecute = new DeviceTaskExecute(); + taskExecute.Id = SnowFlakeSingle.Instance.NextId().ToString(); + taskExecute.TaskName = point.Name; + taskExecute.PlanId = point.Id; + taskExecute.Type = 2; + taskExecute.DistributedTime = DateTime.Now; + taskExecute.Status = 0; + taskExecute.CreatedTime = DateTime.Now; + + return Context.Insertable(taskExecute).ExecuteCommand(); + } + + /// + /// 获取任务执行绑定的巡检任务和点检任务绑定的设备 + /// + public List AchieveTaskbindDevice(string id) + { + List resul = null; + DeviceTaskExecute executeTask = Context + .Queryable() + .Where(it => it.Id == id) + .First(); + if (executeTask != null) + { + // 类型为巡检 + if (executeTask.Type == 1) + { + resul = Context + .Queryable() + .LeftJoin((r, a) => r.FkDeviceAccountId == a.Id) + .Where(r => r.FkRouteInspectionPlanId == executeTask.PlanId) + .Select((r, a) => a) + .ToList(); + } + // 类型为点检 + else if (executeTask.Type == 2) + { + resul = Context + .Queryable() + .LeftJoin((p, a) => p.FkDeviceAccountId == a.Id) + .Where(p => p.FkPointInspectionPlanId == executeTask.PlanId) + .Select((p, a) => a) + .ToList(); + } + } + + return resul; + } + + /// + /// 获取设备绑定的检查项 + /// + /// 设备id + /// 计划id + /// 计划类型 + /// + public List AchieveDevicebindInspect(int fk_device_id, string fkPlanId, int planType) + { + + // 判断是保养/检查吗 + int check_type = 1; + if(planType == 1) + { + check_type= Context.Queryable().Where(it => it.Id == fkPlanId) + .Where(it => it.InnerType == planType).Select(it => it.InnerType.Value).First(); + + }else if (planType == 2) + { + check_type = Context.Queryable().Where(it => it.Id == fkPlanId) + .Where(it => it.InnerType == planType).Select(it => it.InnerType.Value).First(); + + } + + + + List resul = null; + + resul = Context + .Queryable() + .LeftJoin((r, i) => r.FkInspectId == i.Id) + .Where(r => r.FkAccountId == fk_device_id) + .Where((r,i)=>i.Type==check_type) + .Select((r, i) => i) + .ToList(); + + return resul; + } + + /// + /// 获取检查项绑定的检查表单 + /// + public List AchieveInspectbindForm(int fk_device_inspect_id) + { + List result = null; + result = Context + .Queryable() + .Where(it => it.FkDeviceInspectId == fk_device_inspect_id) + .ToList(); + return result; + } + + /// + /// 获取表单结果 + /// + /// + public List AchieveFormResult( + DeviceTaskExecuteResult1QueryDto_TaskExecute query + ) + { + List final_result_list = + new List(); + + List resultList = Context + .Queryable() + .Where(it => it.PlanType == query.PlanType) + .Where(it => it.FkPlanId == query.FkPlanId) + .Where(it => it.FkDeviceId == query.FkDeviceId) + .Where(it => it.FkInspectId == query.FkInspectId) + .ToList(); + + if (resultList.Count == 0) + { + //初始化结果表 + List configlist = Context + .Queryable() + .Where(it => it.FkDeviceInspectId == query.FkInspectId) + .ToList(); + + if (configlist.Count > 0) + { + List addResultList = + new List(); + string PlanName = Context + .Queryable() + .Where(it => it.Id == query.FkPlanId) + .First() + ?.Name; + string DeviceName = Context + .Queryable() + .Where(it => it.Id == query.FkDeviceId) + .First() + ?.DeviceName; + string InspectName = Context + .Queryable() + .Where(it => it.Id == query.FkInspectId) + .First() + ?.Name; + + foreach (DeviceFormConfig config in configlist) + { + DeviceTaskExecuteResult result1 = new DeviceTaskExecuteResult(); + + result1.Id = SnowFlakeSingle.Instance.NextId().ToString(); + result1.PlanType = query.PlanType; + result1.FkPlanId = query.FkPlanId; + result1.PlanName = PlanName; + result1.FkDeviceId = query.FkDeviceId; + result1.DeviceName = DeviceName; + result1.FkInspectId = query.FkInspectId; + result1.InspectName = InspectName; + result1.FormType = config.Type; + result1.FormTitle = config.Title; + result1.FormName = config.Content; + + addResultList.Add(result1); + //生成返回结果 + } + + Context.Insertable(addResultList).ExecuteCommand(); + // 处理初始化返回 + if (addResultList.Count > 0) + { + // 1 取出所有的类别 + int?[] FormTypeArray = addResultList + .Select(it => it.FormType) + .Distinct() + .ToArray(); + //2. 分别处理类别 + for (int i = 0; i < FormTypeArray.Length; i++) + { + var temp = addResultList + .Where(it => it.FormType == FormTypeArray[i]) + .ToList(); + DeviceTaskExecuteResult1_result item = + new DeviceTaskExecuteResult1_result(); + + item.Id = temp[0].Id; + item.Title = temp[0].FormTitle; + item.Type = temp[0].FormType; + item.Value = ""; + item.Children = addResultList + .Where(it => it.FormType == FormTypeArray[i]) + .Select(it => it.FormName) + .Distinct() + .ToArray(); + item.Value = item.Children[0]; + final_result_list.Add(item); + } + } + } + } + else if (resultList.Count > 0) + { + // 直接从结果表中获取 + + if (resultList.Count > 0) + { + // 1 取出所有的类别 + int?[] FormTypeArray = resultList + .Select(it => it.FormType) + .Distinct() + .ToArray(); + //2. 分别处理类别 + for (int i = 0; i < FormTypeArray.Length; i++) + { + var temp = resultList.Where(it => it.FormType == FormTypeArray[i]).ToList(); + DeviceTaskExecuteResult1_result item = + new DeviceTaskExecuteResult1_result(); + + item.Id = temp[0].Id; + item.Title = temp[0].FormTitle; + item.Type = temp[0].FormType; + item.Value = ""; + item.Children = resultList + .Where(it => it.FormType == FormTypeArray[i]) + .Select(it => it.FormName) + .Distinct() + .ToArray(); + List FormResultArray = resultList + .Where(it => it.FormType == FormTypeArray[i]) + .ToList(); + + if (FormResultArray.Count == 1) + { + item.Value = FormResultArray[0].FormName; + } + else if (FormResultArray.Count > 1) + { + string[] str = new string[FormResultArray.Count]; + for (int ii = 0; ii < str.Length; ii++) + { + str[i] = FormResultArray[ii].FormName; + } + item.Value = string.Join(", ", str).ToString(); + } + else + { + item.Value = item.Children[0]; + } + final_result_list.Add(item); + } + } + } + return final_result_list; + } + + /// + /// 获取表单结果2 + /// 结果表只存选中的结果,多选也只有一个结果 + /// + /// + public List AchieveFormResult2( + DeviceTaskExecuteResult1QueryDto_TaskExecute query + ) + { + List final_result_list = + new List(); + + // 获取 设备检查项 所有表单类型 + List all_config_list = Context + .Queryable() + .Where(it => it.FkDeviceInspectId == query.FkInspectId) + .ToList(); + + int?[] config_type = all_config_list.Select(it => it.Type).Distinct().ToArray(); + DevicePointInspectionPlan handle_point_plan = Context + .Queryable() + .Where(it => it.Id == query.FkPlanId) + .First(); + DeviceRouteInspectionPlan handle_rounte_plan = Context + .Queryable() + .Where(it => it.Id == query.FkPlanId) + .First(); + DeviceAccount deviceAccount = Context + .Queryable() + .Where(it => it.Id == query.FkDeviceId) + .First(); + DeviceInspect inspect = Context + .Queryable() + .Where(it => it.Id == query.FkInspectId) + .First(); + if (config_type.Length > 0) + { + for (int i = 0; i < config_type.Length; i++) + { + //在结果表里查看是否有结果 + DeviceTaskExecuteResult executeResult = Context + .Queryable() + .Where(it => it.FkTaskId == query.FkTaskId) + .Where(it => it.PlanType == query.PlanType) + .Where(it => it.FkPlanId == query.FkPlanId) + .Where(it => it.FkDeviceId == query.FkDeviceId) + .Where(it => it.FkInspectId == query.FkInspectId) + .Where(it => it.FormType == config_type[i]) + .First(); + + if (executeResult != null) + { + DeviceTaskExecuteResult1_result item = + new() + { + Id = executeResult.Id, + Title = executeResult.FormTitle, + Value = executeResult.FormName, + Type = executeResult.FormType, + Children = all_config_list + .Where(it => it.Type == config_type[i]) + .Select(it => it.Content) + .ToArray() + }; + final_result_list.Add(item); + } + else + { + DeviceTaskExecuteResult insertData = + new() + { + Id = SnowFlakeSingle.Instance.NextId().ToString(), + FkTaskId = query.FkTaskId, + PlanType = query.PlanType, + FkPlanId = query.FkPlanId + }; + //点检 + if (query.PlanType == 2) + { + insertData.FkPlanId = query.FkPlanId; + insertData.PlanName = handle_point_plan?.Name; + insertData.InnerType = handle_point_plan?.InnerType; + } + else if (query.PlanType == 1) + { + //巡检 + insertData.FkPlanId = query.FkPlanId; + insertData.PlanName = handle_rounte_plan?.Name; + insertData.ExcuteCycleType = handle_rounte_plan?.ExcuteCycleType; + + insertData.InnerType = handle_rounte_plan?.InnerType; + } + + insertData.FkDeviceId = query.FkDeviceId; + insertData.DeviceName = deviceAccount.DeviceName; + insertData.FkInspectId = query.FkInspectId; + insertData.InspectName = inspect.Name; + insertData.FormType = config_type[i]; + insertData.FormTitle = all_config_list + .Where(it => it.Type == config_type[i]) + .Select(it => it.Title) + .First(); + + Context.Insertable(insertData).ExecuteReturnIdentity(); + DeviceTaskExecuteResult1_result item = + new() + { + Id = insertData.Id, + Title = insertData.FormTitle, + Value = "", + Type = insertData.FormType, + Children = all_config_list + .Where(it => it.Type == config_type[i]) + .Select(it => it.Content) + .ToArray() + }; + final_result_list.Add(item); + } + } + } + + return final_result_list; + } + + /// + /// 更新结果表单 + /// + /// + /// + public int UpdateFormResult(DeviceTaskExecuteResultDto result) + { + //if (!string.IsNullOrEmpty(result.taskExecute_id)) + // Context.Updateable().Where(it => it.Id == result.taskExecute_id).SetColumns(it => it.Person == result.UpdatedBy).ExecuteCommand(); + + result.Person = result.UpdatedBy; + DeviceTaskExecuteResult item = result.Adapt(); + + return Context + .Updateable(item) + .IgnoreColumns(true) + .EnableDiffLogEvent("更新结果表单") + .ExecuteCommand(); + } + + /// + /// 增加任务开始时间 + /// + /// + /// + public int AddDeviceTaskExecute(string Id, string name) + { + DateTime dateTime = DateTime.Now; + return Context + .Updateable() + .Where(it => it.Id == Id) + .Where(it => it.StartTime == null) + .SetColumns(it => it.StartTime == dateTime) + .SetColumns(it => it.Person == name) + .ExecuteCommand(); + } + + /// + /// 增加任务完成时间 + /// + /// + /// + public int AddTaskFinallyTime(string Id) + { + DateTime dateTime = DateTime.Now; + return Context + .Updateable() + .Where(it => it.Id == Id) + .SetColumns(it => it.EndTime == dateTime) + .ExecuteCommand(); + } + } +} diff --git a/DOAN.Service/MES/Device/DeviceTypeService.cs b/DOAN.Service/MES/Device/DeviceTypeService.cs new file mode 100644 index 0000000..2e009a8 --- /dev/null +++ b/DOAN.Service/MES/Device/DeviceTypeService.cs @@ -0,0 +1,96 @@ +using System; +using SqlSugar; +using Infrastructure.Attribute; +using Infrastructure.Extensions; +using DOAN.Model; +using DOAN.Model.Dto; +using DOAN.Repository; +using System.Linq; +using DOAN.Service.MES.dev.IService; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using Mapster; +using System.Xml.Linq; +using DOAN.Model.System.Vo; + +namespace DOAN.Service.MES.dev +{ + /// + /// 1.设备类型Service业务层处理 + /// + [AppService(ServiceType = typeof(IDeviceTypeService), ServiceLifetime = LifeTime.Transient)] + public class DeviceTypeService : BaseService, IDeviceTypeService + { + + /// + /// 查询1.设备类型列表 + /// + /// + /// + public List GetList(DeviceTypeQueryDto parm) + { + var predicate = Expressionable.Create(); + predicate.AndIF(!string.IsNullOrEmpty(parm.Name), it => it.Name == parm.Name) + .AndIF(parm.Status >= 0, it => it.Status == parm.Status); + + var response = Queryable() + .Where(predicate.ToExpression()) + .ToList(); + + return response.Adapt>(); + } + + + + + /// + /// 获取详情 + /// + /// + /// + public DeviceType GetInfo(int Id) + { + var response = Queryable() + .Where(x => x.Id == Id) + .First(); + + return response; + } + + /// + /// 添加1.设备类型 + /// + /// + /// + public DeviceType AddDeviceType(DeviceType model) + { + + return Context.Insertable(model).ExecuteReturnEntity(); + } + + /// + /// 修改1.设备类型 + /// + /// + /// + public int UpdateDeviceType(DeviceType model) + { + //var response = Update(w => w.Id == model.Id, it => new DeviceType() + //{ + // Name = model.Name, + // Status = model.Status, + // Remark = model.Remark, + // CreatedBy = model.CreatedBy, + // CreatedTime = model.CreatedTime, + // UpdatedBy = model.UpdatedBy, + // UpdatedTime = model.UpdatedTime, + //}); + //return response; + + + return Update(model, true); + } + + } + +} \ No newline at end of file diff --git a/DOAN.Service/MES/Device/IService/IDeviceAccountService.cs b/DOAN.Service/MES/Device/IService/IDeviceAccountService.cs new file mode 100644 index 0000000..51eaa54 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceAccountService.cs @@ -0,0 +1,43 @@ +using System; +using DOAN.Model; +using DOAN.Model.Dto; +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using Aliyun.OSS; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 设备台账service接口 + /// + public interface IDeviceAccountService : IBaseService + { + PagedInfo GetList(DeviceAccountQueryDto parm); + + PagedInfo GetList_Route(DeviceAccountQueryDto2 parm); + + + + DeviceAccount GetInfo(int Id); + + DeviceAccount AddDeviceAccount(DeviceAccount parm); + + int UpdateDeviceAccount(DeviceAccount parm); + List GetSelectTree(DeviceAccountQueryDto parm); + + int AddRelation(DeviceAccount_routeinspect_Dto parm, string CreatedBy); + + int Remove_relation(string FkRouteInspectionPlanId, int FkDeviceAccountId); + + + PagedInfo GetList_Point(DeviceAccountQueryDto3 parm); + + + int AddRelationPointAccount(DeviceAccount_pointinspect_Dto parm, string CreatedBy); + + int RemoveRelationPointAccount(string FkPointInspectionPlanId, int FkDeviceAccountId); + + DeviceStatusAnalysisDto GetDeviceStatus(int devicetype_id); + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceDataAnalysisServcie.cs b/DOAN.Service/MES/Device/IService/IDeviceDataAnalysisServcie.cs new file mode 100644 index 0000000..36fb237 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceDataAnalysisServcie.cs @@ -0,0 +1,28 @@ +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using DOAN.Model.MES.dev.Dto; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 设备数据分析 + /// + public interface IDeviceDataAnalysisServcie + { + List DefaultTypePie(DeviceDefaultDto devicedefault); + DeviceFaultBarResultDto FaultTypeBar(DeviceDefaultDto devicedefault); + DeviceFaultLineResultDto FaultTypeLine(DeviceDefaultDto devicedefault); + + DeviceRepairBarResultDto FaultTypeBarByDay(DeviceDefaultDto devicedefault); + + TaskLineResultDto TaskLinebyDay(DeviceDefaultDto devicedefault); + PersonnelResponseResultDto PersonResponse(DeviceDefaultDto devicedefault); + FullScreenTotal GetAllTotal(); + + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceFormConfigService.cs b/DOAN.Service/MES/Device/IService/IDeviceFormConfigService.cs new file mode 100644 index 0000000..f664a7f --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceFormConfigService.cs @@ -0,0 +1,23 @@ +using System; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using System.Collections.Generic; +using DOAN.Model; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 设备检查项表单配置表service接口 + /// + public interface IDeviceFormConfigService : IBaseService + { + PagedInfo GetList(DeviceFormConfigQueryDto parm); + + DeviceFormConfig GetInfo(string Id); + + DeviceFormConfig AddDeviceFormConfig(DeviceFormConfig parm); + + int UpdateDeviceFormConfig(DeviceFormConfig parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceInspectService.cs b/DOAN.Service/MES/Device/IService/IDeviceInspectService.cs new file mode 100644 index 0000000..f582fb4 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceInspectService.cs @@ -0,0 +1,31 @@ +using System; +using DOAN.Model; + +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using Microsoft.AspNetCore.Mvc; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 设备检查项service接口 + /// + public interface IDeviceInspectService : IBaseService + { + PagedInfo GetList(DeviceInspectQueryDto parm); + + PagedInfo GetList2(DeviceInspectQueryDto2 parm); + + DeviceInspect GetInfo(int Id); + + DeviceInspect AddDeviceInspect(DeviceInspect parm); + + int UpdateDeviceInspect(DeviceInspect parm); + + int AddBindrelative(DeviceInspectQueryDto3 parm,string name); + int RemoveBindrelative(int account_id, int inspect_id); + int SortBindrelative(List parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceMaintenanceRecordService.cs b/DOAN.Service/MES/Device/IService/IDeviceMaintenanceRecordService.cs new file mode 100644 index 0000000..cb21621 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceMaintenanceRecordService.cs @@ -0,0 +1,23 @@ +using System; +using DOAN.Model; +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 维修记录service接口 + /// + public interface IDeviceMaintenanceRecordService : IBaseService + { + PagedInfo GetList(DeviceMaintenanceRecordQueryDto parm); + + DeviceMaintenanceRecord GetInfo(string Id); + + DeviceMaintenanceRecord AddDeviceMaintenanceRecord(DeviceMaintenanceRecord parm); + + int UpdateDeviceMaintenanceRecord(DeviceMaintenanceRecord parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDevicePointInspectionPlanService.cs b/DOAN.Service/MES/Device/IService/IDevicePointInspectionPlanService.cs new file mode 100644 index 0000000..a49b956 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDevicePointInspectionPlanService.cs @@ -0,0 +1,23 @@ +using System; +using DOAN.Model; +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 点检任务service接口 + /// + public interface IDevicePointInspectionPlanService : IBaseService + { + PagedInfo GetList(DevicePointInspectionPlanQueryDto parm); + + DevicePointInspectionPlan GetInfo(string Id); + + DevicePointInspectionPlan AddDevicePointInspectionPlan(DevicePointInspectionPlan parm); + + int UpdateDevicePointInspectionPlan(DevicePointInspectionPlan parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceRepairService.cs b/DOAN.Service/MES/Device/IService/IDeviceRepairService.cs new file mode 100644 index 0000000..054f088 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceRepairService.cs @@ -0,0 +1,23 @@ +using System; +using DOAN.Model; +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 报修单service接口 + /// + public interface IDeviceRepairService : IBaseService + { + PagedInfo GetList(DeviceRepairQueryDto parm); + + DeviceRepair GetInfo(string Id); + + DeviceRepair AddDeviceRepair(DeviceRepair parm); + + int UpdateDeviceRepair(DeviceRepair parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceRouteInspectionPlanService.cs b/DOAN.Service/MES/Device/IService/IDeviceRouteInspectionPlanService.cs new file mode 100644 index 0000000..46fb4ce --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceRouteInspectionPlanService.cs @@ -0,0 +1,23 @@ +using System; +using DOAN.Model; +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 巡检计划service接口 + /// + public interface IDeviceRouteInspectionPlanService : IBaseService + { + PagedInfo GetList(DeviceRouteInspectionPlanQueryDto parm); + + DeviceRouteInspectionPlan GetInfo(string Id); + + DeviceRouteInspectionPlan AddDeviceRouteInspectionPlan(DeviceRouteInspectionPlan parm); + + int UpdateDeviceRouteInspectionPlan(DeviceRouteInspectionPlan parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceTaskExecuteResultService.cs b/DOAN.Service/MES/Device/IService/IDeviceTaskExecuteResultService.cs new file mode 100644 index 0000000..0114323 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceTaskExecuteResultService.cs @@ -0,0 +1,24 @@ +using System; +using DOAN.Model; +using DOAN.Model.Dto; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; +using System.Collections.Generic; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 巡检/点检任务结果表service接口 + /// + public interface IDeviceTaskExecuteResultService : IBaseService + { + PagedInfo GetList(DeviceTaskExecuteResultQueryDto parm); + + DeviceTaskExecuteResult GetInfo(string Id); + + DeviceTaskExecuteResult AddDeviceTaskExecuteResult(DeviceTaskExecuteResult parm); + + int UpdateDeviceTaskExecuteResult(DeviceTaskExecuteResult parm); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceTaskExecuteService.cs b/DOAN.Service/MES/Device/IService/IDeviceTaskExecuteService.cs new file mode 100644 index 0000000..b041621 --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceTaskExecuteService.cs @@ -0,0 +1,55 @@ +using System; +using DOAN.Model; + +using System.Collections.Generic; +using DOAN.Model.MES.dev; +using DOAN.Model.MES.dev.Dto; +using Microsoft.AspNetCore.Mvc; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 任务执行service接口 + /// + public interface IDeviceTaskExecuteService : IBaseService + { + PagedInfo GetList(DeviceTaskExecuteQueryDto parm); + + DeviceTaskExecute GetInfo(string Id); + + DeviceTaskExecute AddDeviceTaskExecute(DeviceTaskExecute parm); + + int UpdateDeviceTaskExecute(DeviceTaskExecute parm); + int Update_task_status(DeviceTaskExecuteQueryDto2 parm); + + + bool TruncateDeviceTaskExecute(); + + (string, object, object) ImportDeviceTaskExecute(List list); + + int ScanEveryTask(); + + int ExecutionTask_point(string id); + + + List AchieveTaskbindDevice(string id); + + List AchieveDevicebindInspect(int fk_device_id, string fkPlanId, int planType); + + List AchieveInspectbindForm(int fk_device_inspect_id); + + + List AchieveFormResult2(DeviceTaskExecuteResult1QueryDto_TaskExecute query); + + int UpdateFormResult(DeviceTaskExecuteResultDto result); + + int AddDeviceTaskExecute(string Id,string name); + /// + /// 增加任务完成时间 + /// + /// + /// + int AddTaskFinallyTime(string Id); + + } +} diff --git a/DOAN.Service/MES/Device/IService/IDeviceTypeService.cs b/DOAN.Service/MES/Device/IService/IDeviceTypeService.cs new file mode 100644 index 0000000..75db0ea --- /dev/null +++ b/DOAN.Service/MES/Device/IService/IDeviceTypeService.cs @@ -0,0 +1,26 @@ +using System; +using DOAN.Model; +using DOAN.Model.Dto; + +using System.Collections.Generic; +using DOAN.Model.MES.dev.Dto; +using DOAN.Model.MES.dev; + +namespace DOAN.Service.MES.dev.IService +{ + /// + /// 1.设备类型service接口 + /// + public interface IDeviceTypeService : IBaseService + { + List GetList(DeviceTypeQueryDto parm); + + DeviceType GetInfo(int Id); + + DeviceType AddDeviceType(DeviceType parm); + + int UpdateDeviceType(DeviceType parm); + + } +} + diff --git a/Infrastructure/WebExtensions/EntityExtension.cs b/Infrastructure/WebExtensions/EntityExtension.cs index 5a15216..555e478 100644 --- a/Infrastructure/WebExtensions/EntityExtension.cs +++ b/Infrastructure/WebExtensions/EntityExtension.cs @@ -37,6 +37,28 @@ namespace Infrastructure return source; } + /// + /// 用昵称更新 + /// + /// + /// + /// + /// + public static TSource ToUpdate_nickName(this TSource source, HttpContext? context = null) + { + var types = source?.GetType(); + if (types == null || context == null) return source; + BindingFlags flag = BindingFlags.Public | BindingFlags.IgnoreCase | BindingFlags.Instance; + + types.GetProperty("UpdateTime", flag)?.SetValue(source, DateTime.Now, null); + types.GetProperty("UpdatedTime", flag)?.SetValue(source, DateTime.Now, null); + types.GetProperty("Update_time", flag)?.SetValue(source, DateTime.Now, null); + types.GetProperty("UpdateBy", flag)?.SetValue(source, context.GetNickName(), null); + types.GetProperty("UpdatedBy", flag)?.SetValue(source, context.GetNickName(), null); + types.GetProperty("Update_by", flag)?.SetValue(source, context.GetNickName(), null); + + return source; + } } }