diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/tabulate/vo/TabulateLevelVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/tabulate/vo/TabulateLevelVo.java new file mode 100644 index 0000000..80334fb --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/alarm/tabulate/vo/TabulateLevelVo.java @@ -0,0 +1,29 @@ +package com.hnac.hzims.alarm.tabulate.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author ysj + */ +@Data +public class TabulateLevelVo { + + @ApiModelProperty(value = "站点编码") + private String projectId; + + @ApiModelProperty(value = "开始时间") + private String startTime; + + @ApiModelProperty(value = "结束时间") + private String endTime; + + @ApiModelProperty(value = "") + private Integer dimension; + + @ApiModelProperty(value = "") + private String id; + + @ApiModelProperty(value = "") + private Integer soeType; +} \ No newline at end of file diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/constants/AccessConstants.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/constants/AccessConstants.java index d9de90b..1bc8278 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/constants/AccessConstants.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/constants/AccessConstants.java @@ -51,6 +51,14 @@ public interface AccessConstants { /**未完成**/ int ACCESS_TASK_STATUS_5 = 5; + + /** + * 检修计划流程状态:0-完成 1=未完成 + */ + String PROCESS_STEP_COMPLETE = "0"; + String PROCESS_STEP_INCOMPLETE = "1"; + + /** * 延期状态 */ diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java index f9f6054..cd0e6f8 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/entity/OperAccessTaskEntity.java @@ -30,102 +30,63 @@ public class OperAccessTaskEntity extends TenantEntity { private static final long serialVersionUID = 1L; - /** - * 设备编码 - */ + @ApiModelProperty("站点编码") + private String stationCode; + + @ApiModelProperty("站点名称") + private String stationName; + + @ApiModelProperty("设备名称") + private String emName; + @ApiModelProperty("设备编码") private String emCode; - /** - * 工作流实例 - */ @ApiModelProperty(value = "工作流实例") private String processInstanceId; - /** - * 任务编码 - */ @ApiModelProperty(value = "任务编码") private String code; - /** - * 任务名称 - */ @ApiModelProperty(value = "任务名称") private String name; - /** - * 操作规范 - */ @ApiModelProperty(value = "操作规范") private String workStandards; - /** - * 安全警告 - */ @ApiModelProperty(value = "安全警告") private String safeInfos; - /** - * 计划开始时间 - */ @ApiModelProperty(value = "计划开始时间") private Date planStartTime; - /** - * 计划结束时间 - */ @ApiModelProperty(value = "计划结束时间") private Date planEndTime; - /** - * 计划结束时间 - */ @ApiModelProperty(value = "计划工时") private Integer planHours; - /** - * 实际开始时间 - */ @ApiModelProperty(value = "实际开始时间") private Date actStartTime; - /** - * 实际结束时间 - */ @ApiModelProperty(value = "实际结束时间") private Date actEndTime; - /** - * 实际工时 - */ @ApiModelProperty(value = "实际工时") @JsonSerialize(nullsUsing = NullSerializer.class) private Integer actHours; - /** - * 任务执行人 - */ @ApiModelProperty(value = "任务执行人") @JsonSerialize(nullsUsing = NullSerializer.class) private Long handler; - /** - * 描述 - */ @ApiModelProperty(value = "描述") private String descripiton; - /** - * 计划ID - */ @ApiModelProperty("计划ID") @JsonSerialize(nullsUsing = NullSerializer.class) private Long planId; - /** - * 检修库ID - */ @ApiModelProperty("检修库ID") @JsonSerialize(nullsUsing = NullSerializer.class) private Long contentId; diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/AccessExportVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/AccessExportVo.java new file mode 100644 index 0000000..d8d9984 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/AccessExportVo.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.operational.access.vo; + +import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author ysj + */ +@Data +public class AccessExportVo { + + @ApiModelProperty(value = "计划名称") + private String planName; + + @ApiModelProperty(value = "计划名称") + private List tasks; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/AccessTaskExportVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/AccessTaskExportVo.java new file mode 100644 index 0000000..b8fecec --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/access/vo/AccessTaskExportVo.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.operational.access.vo; + +import com.hnac.hzims.operational.access.entity.OperAccessTaskDetailEntity; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * @author ysj + */ +@Data +public class AccessTaskExportVo { + + @ApiModelProperty(value = "任务ID") + private Long taskId; + + @ApiModelProperty(value = "设备名称") + private String emName; + + @ApiModelProperty(value = "计划开始时间") + private Date planStartTime; + + @ApiModelProperty(value = "计划结束时间") + private Date planEndTime; + + @ApiModelProperty(value = "计划工时") + private Integer planHours; + + @ApiModelProperty(value = "负责人id") + private Long headId; + + @ApiModelProperty(value = "负责人") + private String headName; + + @ApiModelProperty(value = "检修项目集合") + private List details; +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/controller/AlarmTabulateController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/controller/AlarmTabulateController.java index 23b5544..cbd4d56 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/controller/AlarmTabulateController.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/controller/AlarmTabulateController.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.alarm.tabulate.service.AlarmTabulateService; import com.hnac.hzims.alarm.tabulate.vo.TabulateEarlyVo; +import com.hnac.hzims.alarm.tabulate.vo.TabulateLevelVo; import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,4 +35,11 @@ public class AlarmTabulateController extends BladeController { public R> early(TabulateEarlyVo param, Query query) { return R.data(tabulateService.early(Condition.getPage(query), param)); } + + @GetMapping("/level") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "等级告警(设备实例)", notes = "等级告警(设备实例)") + public R> level(TabulateLevelVo param, Query query) { + return R.data(tabulateService.level(Condition.getPage(query), param)); + } } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/AlarmTabulateService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/AlarmTabulateService.java index 23790e0..72ba4bd 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/AlarmTabulateService.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/AlarmTabulateService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.alarm.tabulate.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.config.vo.AlarmHandleVo; import com.hnac.hzims.alarm.tabulate.vo.TabulateEarlyVo; +import com.hnac.hzims.alarm.tabulate.vo.TabulateLevelVo; import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO; import org.springblade.core.mp.support.Query; @@ -12,4 +13,6 @@ import org.springblade.core.mp.support.Query; public interface AlarmTabulateService { IPage early(IPage page, TabulateEarlyVo param); + + IPage level(IPage page, TabulateLevelVo param); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/impl/AlarmTabulateServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/impl/AlarmTabulateServiceImpl.java index dba391b..3ae0d59 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/impl/AlarmTabulateServiceImpl.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/tabulate/service/impl/AlarmTabulateServiceImpl.java @@ -3,8 +3,11 @@ package com.hnac.hzims.alarm.tabulate.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.alarm.tabulate.service.AlarmTabulateService; import com.hnac.hzims.alarm.tabulate.vo.TabulateEarlyVo; +import com.hnac.hzims.alarm.tabulate.vo.TabulateLevelVo; import com.hnac.hzinfo.sdk.core.response.HzPage; import com.hnac.hzinfo.sdk.core.response.Result; +import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; +import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; import com.hnac.hzinfo.sdk.v5.soe.SoeDataClient; import com.hnac.hzinfo.sdk.v5.soe.dto.StbAnalysisDTO; import com.hnac.hzinfo.sdk.v5.soe.vo.StbAnalysisVO; @@ -28,6 +31,8 @@ public class AlarmTabulateServiceImpl implements AlarmTabulateService { private final SoeDataClient soeDataClient; + private final DeviceDataClient deviceDataClient; + /** * 智能预警 * @param page @@ -56,4 +61,16 @@ public class AlarmTabulateServiceImpl implements AlarmTabulateService { page.setRecords(result.getData().getRecords()); return page; } + + /** + * 等级告警 + * @param page + * @param param + * @return + */ + @Override + public IPage level(IPage page, TabulateLevelVo param) { + deviceDataClient.getDeviceSoeData(param.getProjectId(),param.getDimension(),param.getId(),param.getSoeType(),param.getStartTime(),param.getEndTime()); + return null; + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java index f52d218..3f73b8b 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/AccessPlanV4Controller.java @@ -1,17 +1,22 @@ package com.hnac.hzims.operational.access.controller; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO; +import com.hnac.hzims.operational.access.dto.OperAccessPlanListDTO; import com.hnac.hzims.operational.access.service.AccessPlanV4Service; +import com.hnac.hzims.operational.access.vo.OperAccessPlanVO; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; /** @@ -26,14 +31,29 @@ public class AccessPlanV4Controller extends BladeController { private final AccessPlanV4Service service; - /** - * v4检修计划流程开启 - * @return - */ @PostMapping("/overhaul_start_v4") @ApiOperationSupport(order = 1) @ApiOperation(value = "v4检修计划流程开启") public R startV4(@RequestBody AccessPlanV4DTO entity) { return R.status(service.startProcessV4(entity)); } + + + @ApiLog + @GetMapping("/pages") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "检修计划分页查询") + public R> list(OperAccessPlanListDTO param, Query query) { + return R.data(service.pages(Condition.getPage(query),param)); + } + + + @ApiLog + @GetMapping("/export") + @ApiOperationSupport(order = 3) + @ApiOperation(value = "检修计划导出") + public void export(@RequestParam("id") Long id) { + service.export(id); + } + } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java index 6b40770..b9370a0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessPlanListDTO.java @@ -18,9 +18,12 @@ public class OperAccessPlanListDTO extends OperAccessPlanEntity { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "开始时间") - private String startDate; + private String startTime; @ApiModelProperty(value = "结束时间") - private String endDate; + private String endTime; + + @ApiModelProperty(value = "流程步骤 : 0-完成 1-未完成") + private String processStep; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskDetailMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskDetailMapper.java index f0b06b1..886a3eb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskDetailMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskDetailMapper.java @@ -17,4 +17,5 @@ import java.util.List; public interface OperAccessTaskDetailMapper extends BaseMapper { List selectByTaskId(@Param("taskId") Long taskId); + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java index 9cb87d3..2d2c6e5 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.java @@ -1,6 +1,7 @@ package com.hnac.hzims.operational.access.mapper; import com.baomidou.mybatisplus.annotation.SqlParser; +import com.hnac.hzims.operational.access.vo.AccessTaskExportVo; import com.hnac.hzims.operational.access.vo.RepairBillVO; import org.springblade.core.datascope.annotation.UserDataAuth; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -42,4 +43,6 @@ public interface OperAccessTaskMapper extends UserDataScopeBaseMapper selectAccessTask(@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("list")List list); List getRepairBill(@Param("deviceCodes") List deviceCodes,@Param("startTime") String startTime, @Param("endTime") String endTime); + + List accessTasks(@Param("planId") Long id); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml index 7810d05..226952a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessTaskMapper.xml @@ -5,20 +5,16 @@ - - - - @@ -31,6 +27,21 @@ + + + + + + + + + + + + + + + diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java index f95e019..b852aec 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/AccessPlanV4Service.java @@ -1,7 +1,15 @@ package com.hnac.hzims.operational.access.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; import com.hnac.hzims.operational.access.dto.AccessPlanV4DTO; +import com.hnac.hzims.operational.access.dto.OperAccessPlanListDTO; +import com.hnac.hzims.operational.access.entity.OperAccessPlanEntity; +import com.hnac.hzims.operational.access.vo.OperAccessPlanVO; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; + +import javax.servlet.http.HttpServletResponse; /** * @author ysj @@ -11,4 +19,8 @@ public interface AccessPlanV4Service{ boolean startProcessV4(AccessPlanV4DTO entity); boolean listener(ProcessWorkFlowResponse processWorkFlowResponse); + + IPage pages(IPage page, OperAccessPlanListDTO param); + + void export(Long id); } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java index 6c1c211..696eb63 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; +import com.hnac.hzims.operational.access.vo.AccessTaskExportVo; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.RepairBillVO; import com.hnac.hzims.operational.report.vo.AccessReportVO; @@ -78,4 +79,6 @@ public interface IOperAccessTaskService extends BaseService getRepairBill(String emCode, String startTime, String endTime); List getAccessListStatistics(String startTime, String endTime,Long deptId); + + List accessTasks(Long id); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java index 0d3bdbe..d168016 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/AccessPlanV4ServiceImpl.java @@ -3,16 +3,30 @@ package com.hnac.hzims.operational.access.service.impl; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.middle.process.to.ProcessWorkFlowResponse; +import com.hnac.hzims.operational.access.constants.AccessConstants; import com.hnac.hzims.operational.access.dto.*; import com.hnac.hzims.operational.access.entity.*; import com.hnac.hzims.operational.access.service.*; +import com.hnac.hzims.operational.access.vo.AccessExportVo; +import com.hnac.hzims.operational.access.vo.AccessTaskExportVo; +import com.hnac.hzims.operational.access.vo.OperAccessPlanVO; +import com.hnac.hzims.operational.access.wrapper.OperAccessPlanWrapper; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomUtils; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.util.CellRangeAddress; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; @@ -30,12 +44,21 @@ import org.springblade.system.user.feign.IUserClient; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; import java.text.DecimalFormat; import java.time.Duration; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.*; +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -48,6 +71,8 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ private final IOperAccessPlanService planService; + private final IOperAccessTaskService taskService; + private final IOperAccessMaterialService materialService; private final IOperAccessContentService contentService; @@ -222,6 +247,7 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ return true; } + /** * 开启检修任务 * @param entity @@ -296,4 +322,259 @@ public class AccessPlanV4ServiceImpl implements AccessPlanV4Service{ message.setUserIds(userId); messageClient.sendAppAndWsMsgByUsers(message); } + + /** + * 检修计划分页查询 + * @param page + * @param param + * @return + */ + @Override + public IPage pages(IPage page, OperAccessPlanListDTO param) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().orderByDesc(OperAccessPlanEntity::getCreateTime); + if(ObjectUtil.isNotEmpty(param.getStartTime())){ + queryWrapper.lambda().ge(OperAccessPlanEntity::getActStartTime,param.getStartTime()); + } + if(ObjectUtil.isNotEmpty(param.getEndTime())){ + queryWrapper.lambda().le(OperAccessPlanEntity::getActStartTime,param.getEndTime()); + } + + if(ObjectUtil.isNotEmpty(param.getName())){ + queryWrapper.lambda().like(OperAccessPlanEntity::getName,param.getName()); + } + if(ObjectUtil.isNotEmpty(param.getGradeCode())){ + String[] gradeCodes = param.getGradeCode().split(","); + queryWrapper.lambda().in(OperAccessPlanEntity::getGradeCode,Arrays.asList(gradeCodes)); + } + if(ObjectUtil.isNotEmpty(param.getProcessStep())){ + if(AccessConstants.PROCESS_STEP_COMPLETE.equals(param.getProcessStep())){ + queryWrapper.lambda().eq(OperAccessPlanEntity::getTaskName,"流程结束"); + }else if(AccessConstants.PROCESS_STEP_INCOMPLETE.equals(param.getProcessStep())){ + queryWrapper.lambda().ne(OperAccessPlanEntity::getTaskName,"流程结束"); + } + } + IPage pages = this.planService.page(page,queryWrapper); + pages.setRecords(OperAccessPlanWrapper.build().listVO(pages.getRecords())); + return pages; + } + + /** + * 检修任务导出 + * @param id + */ + @Override + public void export(Long id) { + ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + HttpServletResponse response = servletRequestAttributes.getResponse(); + // 查询检修计划内容 + AccessExportVo access = this.accessExport(id); + + // 创建Excel文件 + HSSFWorkbook hssWB = new HSSFWorkbook(); + // 添加sheet页 + HSSFSheet sheet = hssWB.createSheet(access.getPlanName()); + // 行高 + sheet.setDefaultRowHeight((short) (20 * 25)); + // 列宽 + sheet.setDefaultColumnWidth(20); + this.setFirstHeader(hssWB, sheet,access.getPlanName()); + // 第二行/三行 表头格式设置 + this.setWorkHeader(hssWB, sheet); + if (!CollectionUtil.isEmpty(access.getTasks())) { + // 数据填充 + this.setWorkData(hssWB, sheet, access.getTasks()); + } + // 下载导出 + String filename = access.getPlanName(); + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + ServletOutputStream outputStream; + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xls", "UTF-8")); + //创建一个输出流 + outputStream = response.getOutputStream(); + //写入数据 + hssWB.write(outputStream); + // 关闭 + outputStream.close(); + hssWB.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + + /** + * 查询检修任务导出数据 + * @param id + * @return + */ + private AccessExportVo accessExport(Long id) { + // 检修计划查询 + OperAccessPlanEntity plan = this.planService.getById(id); + AccessExportVo access = new AccessExportVo(); + access.setPlanName(plan.getName()); + access.setTasks(this.taskService.accessTasks(id)); + return access; + } + + /** + * 设置表头 + * @param hssWB + * @param sheet + */ + private void setFirstHeader(HSSFWorkbook hssWB, HSSFSheet sheet,String planName) { + // 第一行 + HSSFRow fisrtRow = sheet.createRow(0); + this.setTitileStyle(hssWB, fisrtRow, 7, true); + // 第一个单元格 + HSSFCell headCell = fisrtRow.getCell(0); + headCell.setCellValue(planName); + // 首行合并情况 + CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 7); + sheet.addMergedRegion(region1); + } + + /** + * 第一行条目名称设置 + * @param hssWB + * @param sheet + */ + private void setWorkHeader(HSSFWorkbook hssWB, HSSFSheet sheet) { + // 创建行 + HSSFRow row_1 = sheet.createRow(1); + this.setTitileStyle(hssWB, row_1, 7, true); + // 第一行 + HSSFCell header_row_1_cell_1 = row_1.getCell(0); + header_row_1_cell_1.setCellValue("序号"); + HSSFCell header_row_1_cell_2 = row_1.getCell(1); + header_row_1_cell_2.setCellValue("设备名称"); + HSSFCell header_row_1_cell_3 = row_1.getCell(2); + header_row_1_cell_3.setCellValue("计划开始时间"); + HSSFCell header_row_1_cell_4 = row_1.getCell(3); + header_row_1_cell_4.setCellValue("计划结束时间"); + HSSFCell header_row_1_cell_5 = row_1.getCell(4); + header_row_1_cell_5.setCellValue("计划工时"); + HSSFCell header_row_1_cell_6 = row_1.getCell(5); + header_row_1_cell_6.setCellValue("检修项目"); + HSSFCell header_row_1_cell_7 = row_1.getCell(6); + header_row_1_cell_7.setCellValue("检修内容"); + HSSFCell header_row_1_cell_8 = row_1.getCell(7); + header_row_1_cell_8.setCellValue("检修负责人"); + } + + /** + * 内容填充 + * @param hssWB + * @param sheet + * @param tasks + */ + private void setWorkData(HSSFWorkbook hssWB, HSSFSheet sheet, List tasks) { + int size = tasks.size(); + int row = 2; + for (int i = 0; i < size; i++) { + AccessTaskExportVo task = tasks.get(i); + List details = tasks.get(i).getDetails(); + int detail_size = details.size(); + for (int j = 0; j < detail_size ; j++){ + HSSFRow detail_row = sheet.createRow(row + j); + this.setTitileStyle(hssWB, detail_row, 7, false); + if(j == 0){ + // 序号 + HSSFCell header_row_cell_0 = detail_row.getCell(0); + header_row_cell_0.setCellValue(i + 1); + // 设备名称 + HSSFCell header_row_cell_1 = detail_row.getCell(1); + header_row_cell_1.setCellValue(task.getEmName()); + // 计划开始时间 + HSSFCell header_row_cell_2 = detail_row.getCell(2); + header_row_cell_2.setCellValue(DateUtil.format(task.getPlanStartTime(),DateUtil.PATTERN_DATETIME)); + // 计划结束时间 + HSSFCell header_row_cell_3 = detail_row.getCell(3); + header_row_cell_3.setCellValue(DateUtil.format(task.getPlanEndTime(),DateUtil.PATTERN_DATETIME)); + // 计划工时 + HSSFCell header_row_cell_4 = detail_row.getCell(4); + header_row_cell_4.setCellValue(task.getPlanHours()); + // 检修负责人 + HSSFCell header_row_cell_7 = detail_row.getCell(7); + header_row_cell_7.setCellValue(task.getHeadName()); + } + // 检修项目 + HSSFCell header_row_cell_5 = detail_row.getCell(5); + header_row_cell_5.setCellValue(details.get(j).getName()); + // 检修内容 + HSSFCell header_row_cell_6 = detail_row.getCell(6); + header_row_cell_6.setCellValue(details.get(j).getContent()); + } + CellRangeAddress header_region_0 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 0, (short) 0); + CellRangeAddress header_region_1 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 1, (short) 1); + CellRangeAddress header_region_2 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 2, (short) 2); + CellRangeAddress header_region_3 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 3, (short) 3); + CellRangeAddress header_region_4 = new CellRangeAddress((short) row,(short) row + detail_size - 1, (short) 4, (short) 4); + CellRangeAddress header_region_7 = new CellRangeAddress((short) row, (short) row + detail_size - 1, (short) 7, (short) 7); + sheet.addMergedRegion(header_region_0); + sheet.addMergedRegion(header_region_1); + sheet.addMergedRegion(header_region_2); + sheet.addMergedRegion(header_region_3); + sheet.addMergedRegion(header_region_4); + sheet.addMergedRegion(header_region_7); + // 累计合并结束行号 + row += detail_size; + } + } + + /** + * 设置Titile单元格样式 + * + * @param hssWB + * @param row + * @param len + */ + private void setTitileStyle(HSSFWorkbook hssWB, HSSFRow row, int len, boolean isHead) { + HSSFCellStyle cellStyle = getHeadStyle(hssWB, isHead); + for (int i = 0; i <= len; i++) { + HSSFCell hssfcell = row.createCell(i); + hssfcell.setCellStyle(cellStyle); + } + } + + /** + * 获取表头样式 + * + * @param hssWB + * @return + */ + private HSSFCellStyle getHeadStyle(HSSFWorkbook hssWB, boolean isHead) { + HSSFCellStyle headStyle = hssWB.createCellStyle(); + //边框 + headStyle.setBorderLeft(BorderStyle.THIN); + headStyle.setBorderRight(BorderStyle.THIN); + headStyle.setBorderTop(BorderStyle.THIN); + headStyle.setBorderBottom(BorderStyle.THIN); + //居中: + headStyle.setAlignment(HorizontalAlignment.CENTER); // 居中 + headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中 + //字体: + HSSFFont font = hssWB.createFont(); + font.setFontName("黑体"); + if (isHead) { + //设置字体大小 + font.setFontHeightInPoints((short) 12); + //背景颜色 + headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + headStyle.setFillForegroundColor(HSSFColor.SKY_BLUE.index); + } else { + //设置字体大小 + font.setFontHeightInPoints((short) 8); + //背景颜色 + headStyle.setFillPattern(FillPatternType.NO_FILL); + headStyle.setFillForegroundColor(HSSFColor.WHITE.index); + } + //字体格式 + headStyle.setFont(font); + return headStyle; + } } \ No newline at end of file diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java index bfb6c10..83ef3c1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessPlanServiceImpl.java @@ -438,11 +438,11 @@ public class OperAccessPlanServiceImpl extends BaseServiceImpl list) { VoteChartVo voteChartVo = new VoteChartVo(); List finishIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() == 4).map(s -> s.getId()).collect(Collectors.toList()); @@ -607,4 +609,22 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl accessTasks(Long id) { + List tasks = this.baseMapper.accessTasks(id); + return tasks.stream().peek(task -> { + log.error("access_task_headId : {}",task.getHeadId()); + R user = userClient.userInfoById(task.getHeadId()); + if(user.isSuccess() && ObjectUtil.isNotEmpty(user.getData())){ + task.setHeadName(user.getData().getName()); + } + }).collect(Collectors.toList()); + } + }