diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsExportVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsExportVO.java new file mode 100644 index 0000000..c547c00 --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsExportVO.java @@ -0,0 +1,98 @@ +package com.hnac.hzims.operational.defect.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 模型VO + * + * @author Chill + */ +@Data +public class OperDefectStatisticsExportVO { + + private static final long serialVersionUID = 8239436726489738763L; + @ExcelProperty(value = "序号", index = 0) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "序号") + private Integer number; + + @ExcelProperty(value = "单位", index = 1) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "机构名称") + private String deptName; + + @ExcelProperty(value = "缺陷编码", index = 2) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "缺陷编码") + private String defectCode; + + + @ExcelProperty(value = "记录人", index = 3) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "缺陷发现人") + private String finderName; + + + @ApiModelProperty("记录时间") + @ExcelProperty(value = "记录时间", index = 4) + @ColumnWidth(value = 20) + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + private Date findTime; + + + @ExcelProperty(value = "缺陷描述", index = 5) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "现象描述") + private String descripiton; + + + @ExcelProperty(value = "缺陷等级", index = 6) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "缺陷等级, 字段key: defectLevel") + private String defectLevel; + + @ExcelProperty(value = "处理时间", index = 7) + @ColumnWidth(value = 20) + @DateTimeFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @JsonFormat( + pattern = "yyyy-MM-dd HH:mm:ss" + ) + @ApiModelProperty(value = "处理时间") + private Date actStartTime; + + @ExcelProperty(value = "处理人", index = 8) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "消缺处理人") + private String planHandler; + + +// @ExcelIgnore +// @ApiModelProperty(value = "消缺处理人") +// private String planHandlerId; + + @ExcelProperty(value = "处理结果", index = 9) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "处理描述") + private String disposeDesc; + + + @ExcelProperty(value = "关联工作票编码", index = 10) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "操作票") + private String ticketId; + +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/vo/MaintenanceExportVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/vo/MaintenanceExportVO.java new file mode 100644 index 0000000..d951e7f --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/vo/MaintenanceExportVO.java @@ -0,0 +1,68 @@ +package com.hnac.hzims.operational.maintenance.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @author hx + */ +@Data +public class MaintenanceExportVO { + + @ExcelProperty(value = "序号", index = 0) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "序号") + private Integer number; + + @ExcelProperty(value = "单位", index = 1) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "单位") + private String company; + + + @ExcelProperty(value = "维护类型", index = 2) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "维护类型") + private String typeCode; + + + @ExcelProperty(value = "维护设备", index = 3) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "维护设备") + private String refLibraryId; + + @ApiModelProperty("维护内容") + @ExcelProperty(value = "维护内容", index = 4) + @ColumnWidth(value = 20) + private String title; + + @ExcelProperty(value = "计划执行时间", index = 5) + @ColumnWidth(value = 20) + @ApiModelProperty("计划执行时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String planEndTime; + + @ExcelProperty(value = "实际执行时间", index = 6) + @ColumnWidth(value = 20) + @ApiModelProperty("实际执行时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String executeTime; + + + @ExcelProperty(value = "执行人", index = 7) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "执行人") + private String disposer; + + + @ExcelProperty(value = "执行情况", index = 8) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "执行情况") + private String principal; +} diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/TaskContants.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/TaskContants.java index 8dbc67e..68efead 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/TaskContants.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/TaskContants.java @@ -13,7 +13,8 @@ public interface TaskContants { // 巡检任务派发 String INSPECT_TASK_DISTRIBUTE = "taskJobDistribute"; - + String INSPECT_DATE_PATTERN = "yyyy年MM月dd日 HH时mm分"; + String TASK_STATUS = "taskStatus"; // 日常维护任务派发 String MAINTENANCE_TASK_DISTRIBUTE = "maintenanceTaskDistribute"; diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/vo/InspectTaskExportVO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/vo/InspectTaskExportVO.java new file mode 100644 index 0000000..f74f883 --- /dev/null +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/vo/InspectTaskExportVO.java @@ -0,0 +1,79 @@ +package com.hnac.hzinfo.inspect.task.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @author hx + */ +@Data +public class InspectTaskExportVO { + + @ExcelProperty(value = "序号", index = 0) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "序号") + private Integer number; + + @ExcelProperty(value = "单位", index = 1) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "单位") + private String company; + + + @ExcelProperty(value = "巡检名称", index = 2) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "巡检名称") + private String planName; + + + @ExcelProperty(value = "计划开始时间", index = 3) + @ColumnWidth(value = 20) + @ApiModelProperty("计划开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String planStartTime; + + @ExcelProperty(value = "计划结束时间", index = 4) + @ColumnWidth(value = 20) + @ApiModelProperty("计划结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String planEndTime; + @ExcelProperty(value = "实际开始时间", index = 5) + @ColumnWidth(value = 20) + @ApiModelProperty("实际开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String startTime; + + @ExcelProperty(value = "实际结束时间", index = 6) + @ColumnWidth(value = 20) + @ApiModelProperty("实际结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String endTime; + + @ApiModelProperty("巡检时长(分钟)") + @ExcelProperty(value = "巡检时长(分钟)", index = 7) + @ColumnWidth(value = 20) + private Long inspectTime; + + @ApiModelProperty("巡检人") + @ExcelProperty(value = "巡检人", index = 8) + @ColumnWidth(value = 20) + private String userName; + + @ApiModelProperty("巡检情况") + @ExcelProperty(value = "巡检情况", index = 9) + @ColumnWidth(value = 20) + private String content; + @ApiModelProperty("巡检状态") + @ExcelProperty(value = "巡检状态", index = 10) + @ColumnWidth(value = 20) + private String status; + +} diff --git a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java index a6d0812..320d3e0 100644 --- a/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java +++ b/hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java @@ -13,6 +13,7 @@ public interface TicketConstants { String APP_NAME = "hzims-ticket"; String TICKET_DATE_PATTERN = "yyyy年MM月dd日 HH时mm分"; + String TICKET_TYPE = "ticketType"; Integer MATTER_FINISH_STATUS = 2; diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java index 3309ca8..7bb2da4 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java @@ -1,5 +1,6 @@ package com.hnac.hzinfo.inspect.task.controller; +import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -23,6 +24,7 @@ import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity; import com.hnac.hzinfo.inspect.task.service.IEventService; import com.hnac.hzinfo.inspect.task.service.ITaskService; import com.hnac.hzinfo.inspect.task.service.ITaskUserService; +import com.hnac.hzinfo.inspect.task.vo.InspectTaskExportVO; import com.hnac.hzinfo.inspect.task.vo.TaskListQuery; import com.hnac.hzinfo.inspect.task.vo.TaskObjectVO; import com.hnac.hzinfo.inspect.task.vo.TaskVo; @@ -143,6 +145,41 @@ public class TaskController extends BladeController { return R.data(bladePage); } + /** + * 巡检任务导出 + */ + @PostMapping("/exportTaskList") + @ApiOperation(value = "巡检任务导出", notes = "传入计划id") + public void exportTaskList(HttpServletResponse response,@RequestBody TaskDTO task) { + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("巡检任务报表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + List list = taskService.exportTaskList(task); + if(list!=null && list.size()>0){ + System.out.println("---------------- size = " + list.size()); + // 这里需要设置不关闭流 + EasyExcel.write(response.getOutputStream(), InspectTaskExportVO.class).autoCloseStream(Boolean.FALSE).sheet("巡检任务报表") + .doWrite(list); + } + } catch (Exception e) { + System.out.println("exportExcel = " + e.toString()); + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + Map map = new HashMap<>(); + map.put("isSuccess", "false"); + map.put("msg", "巡检任务报表" + e.getMessage()); + try { + response.getWriter().println(JSONUtils.toJSONString(map)); + } catch (IOException e3) { + throw new ServiceException( "发生异常 :" + e.toString()); + } + } + } @GetMapping("/mainQueryPage") @ApiOperation(value = "首页当班任务统计中巡检任务查询", notes = "首页当班任务统计中巡检任务查询") public R> mainQueryPage(TaskListQuery task, Query query) { diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java index 7f62c5a..4c336f0 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java @@ -190,4 +190,6 @@ public interface ITaskService extends BaseService { BladePage selectPage(Page pageInfo, TaskListQuery task); List getTaskListStatistics(String startTime, String endTime,Long deptId); + + List exportTaskList(TaskDTO task); } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java index 61b1c82..9bd4771 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java @@ -529,14 +529,24 @@ public class TaskServiceImpl extends BaseServiceImpl imp query.setCurrent(taskDTO.getCurrent()); TaskEntity request = BeanUtil.copy(taskDTO,TaskEntity.class); LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(TaskEntity.class,request); - queryWrapper.ge(Func.isNotEmpty(taskDTO.getPlanStartTime()),TaskEntity::getPlanStartTime,taskDTO.getPlanStartTime()); - queryWrapper.le(Func.isNotEmpty(taskDTO.getPlanStartTimeEnd()),TaskEntity::getPlanStartTime,taskDTO.getPlanStartTimeEnd()); - queryWrapper.eq(Func.isNotEmpty(taskDTO.getCreateDept()),TaskEntity::getCreateDept,taskDTO.getCreateDept()); - queryWrapper.eq(Func.isNotEmpty(taskDTO.getStatus()),TaskEntity::getStatus,taskDTO.getStatus()); - queryWrapper.in(Func.isNotEmpty(taskDTO.getIds()),TaskEntity::getId,taskDTO.getIds()); - queryWrapper.orderByDesc(TaskEntity::getCreateTime); + getQueryWrapper(taskDTO, queryWrapper); IPage page = this.page(Condition.getPage(query), queryWrapper); List records = page.getRecords(); + List taskVos = getTaskVos(records); + page.setRecords(taskVos); + return page; + } + + private void getQueryWrapper(TaskDTO taskDTO, LambdaQueryWrapper queryWrapper) { + queryWrapper.ge(Func.isNotEmpty(taskDTO.getPlanStartTime()),TaskEntity::getPlanStartTime, taskDTO.getPlanStartTime()); + queryWrapper.le(Func.isNotEmpty(taskDTO.getPlanStartTimeEnd()),TaskEntity::getPlanStartTime, taskDTO.getPlanStartTimeEnd()); + queryWrapper.eq(Func.isNotEmpty(taskDTO.getCreateDept()),TaskEntity::getCreateDept, taskDTO.getCreateDept()); + queryWrapper.eq(Func.isNotEmpty(taskDTO.getStatus()),TaskEntity::getStatus, taskDTO.getStatus()); + queryWrapper.in(Func.isNotEmpty(taskDTO.getIds()),TaskEntity::getId, taskDTO.getIds()); + queryWrapper.orderByDesc(TaskEntity::getCreateTime); + } + + private List getTaskVos(List records) { List taskVos = records.stream().map(task -> { TaskVo taskVo = BeanUtil.copy(task, TaskVo.class); // 补充巡检任务人员 @@ -562,8 +572,7 @@ public class TaskServiceImpl extends BaseServiceImpl imp } return taskVo; }).collect(Collectors.toList()); - page.setRecords(taskVos); - return page; + return taskVos; } @Override @@ -1008,6 +1017,60 @@ public class TaskServiceImpl extends BaseServiceImpl imp return res; } + @Override + public List exportTaskList(TaskDTO task) { + TaskEntity request = BeanUtil.copy(task,TaskEntity.class); + LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(TaskEntity.class,request); + getQueryWrapper(task, queryWrapper); + List taskEntities = super.baseMapper.selectList(queryWrapper); + List list=new ArrayList<>(); + if (CollectionUtils.isNotEmpty(taskEntities)){ + List taskVos = getTaskVos(taskEntities); + for (int i = 0; i < taskVos.size(); i++) { + InspectTaskExportVO resEntity=new InspectTaskExportVO(); + TaskVo taskVo = taskVos.get(i); + resEntity.setNumber(i+1); + if (ObjectUtil.isNotEmpty(taskVo.getCreateDept())){ + R dept = sysClient.getDept(taskVo.getCreateDept()); + if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){ + resEntity.setCompany(Optional.ofNullable(dept.getData().getDeptName()).orElse("")); + } + } + resEntity.setPlanName(Optional.ofNullable( taskVo.getPlanName().toString()).orElse("")); + if (ObjectUtil.isNotEmpty(taskVo.getPlanStartTime())){ + resEntity.setPlanStartTime(Optional.ofNullable(DateUtil.format(taskVo.getPlanStartTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse("")); + } + if (ObjectUtil.isNotEmpty(taskVo.getPlanEndTime())){ + resEntity.setPlanEndTime(Optional.ofNullable(DateUtil.format(taskVo.getPlanEndTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse("")); + } + if (ObjectUtil.isNotEmpty(taskVo.getStartTime())){ + resEntity.setStartTime(Optional.ofNullable(DateUtil.format(taskVo.getStartTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse("")); + } + if (ObjectUtil.isNotEmpty(taskVo.getEndTime())){ + resEntity.setEndTime(Optional.ofNullable(DateUtil.format(taskVo.getEndTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse("")); + } + + if (ObjectUtil.isNotEmpty(taskVo.getStartTime())&&ObjectUtil.isNotEmpty(taskVo.getEndTime())) { + long l = DateUtil.between(taskVo.getStartTime(), taskVo.getEndTime()).toMinutes(); + resEntity.setInspectTime(Optional.ofNullable(l).orElse(0L)); + } + + LambdaQueryWrapper queryWrapper2 = Wrappers.lambdaQuery().eq(EventEntity::getTaskId,taskVo.getId()).orderByDesc(EventEntity::getCreateTime); + List eventEntities = eventService.list(queryWrapper2 ); + List collect = eventEntities.stream().map(EventEntity::getIsProblem).collect(Collectors.toList()); + if (collect.contains("1")) { + resEntity.setContent("不正常"); + }else { + resEntity.setContent("正常"); + } + resEntity.setUserName(Optional.ofNullable( taskVo.getUserNames()).orElse("")); + resEntity.setStatus(Optional.ofNullable(DictCache.getValue(TaskContants.TASK_STATUS, taskVo.getStatus())).orElse("")); + list.add(resEntity); + } + } + return list; + } + /** * 巡检任务分页 * diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java index 1c6a0ac..3d9f70c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.defect.controller; +import com.alibaba.druid.support.json.JSONUtils; +import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -9,6 +11,7 @@ import com.hnac.hzims.common.logs.enums.OperatorType; import com.hnac.hzims.operational.defect.dto.OperDefectStatisticsDTO; import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService; +import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsExportVO; import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsVO; import com.hnac.hzims.operational.defect.vo.StatistictCountVo; import com.hnac.hzims.operational.defect.wrapper.OperDefectStatisticsWrapper; @@ -19,6 +22,7 @@ import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -28,7 +32,12 @@ import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -89,6 +98,50 @@ public class OperDefectStatisticsController extends BladeController { } /** + * 分页 代码自定义代号 + */ + @ApiLog + @PostMapping("/exportDefectList") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "缺陷数据导出", notes = "传入statistics") + @ApiImplicitParams({ + }) + @OperationAnnotation(moduleName = "缺陷数据导出",title = "缺陷数据导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action + = "缺陷数据导出") + public void exportDefectList(HttpServletResponse response,@RequestBody OperDefectStatisticsVO entity) { + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("缺陷统计报表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + LambdaQueryWrapper queryWrapper = statisticsService.getQueryWrapper(entity); + List list = statisticsService.list(queryWrapper); + List defectStatisticsExportVO = statisticsService.getDefectStatisticsExportVO(list); + if(defectStatisticsExportVO!=null && defectStatisticsExportVO.size()>0){ + System.out.println("---------------- size = " + defectStatisticsExportVO.size()); + // 这里需要设置不关闭流 + EasyExcel.write(response.getOutputStream(), OperDefectStatisticsExportVO.class).autoCloseStream(Boolean.FALSE).sheet("缺陷统计报表") + .doWrite(defectStatisticsExportVO); + } + } catch (Exception e) { + System.out.println("exportExcel = " + e.toString()); + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + Map map = new HashMap<>(); + map.put("isSuccess", "false"); + map.put("msg", "缺陷统计报表详细信息导出失败" + e.getMessage()); + try { + response.getWriter().println(JSONUtils.toJSONString(map)); + } catch (IOException e3) { + throw new ServiceException( "发生异常 :" + e.toString()); + } + } + } + + /** * 获取设备缺陷统计数据 */ @ApiLog diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java index 6effa45..6b54a54 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java @@ -3,6 +3,7 @@ package com.hnac.hzims.operational.defect.service; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.operational.defect.dto.OperDefectStatisticsDTO; import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; +import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsExportVO; import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsVO; import com.hnac.hzims.operational.defect.vo.StatistictCountVo; import org.springblade.core.mp.base.BaseService; @@ -31,5 +32,5 @@ public interface IOperDefectStatisticsService extends BaseService defectStatistictCount(); - + List getDefectStatisticsExportVO(List list); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java index c48bfbf..8f07eea 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java @@ -1,22 +1,26 @@ package com.hnac.hzims.operational.defect.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.hnac.hzims.operational.defect.constants.DefectConstant; import com.hnac.hzims.operational.defect.dto.OperDefectStatisticsDTO; import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; import com.hnac.hzims.operational.defect.mapper.OperDefectStatisticsMapper; import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService; +import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsExportVO; import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsVO; import com.hnac.hzims.operational.defect.vo.StatistictCount; import com.hnac.hzims.operational.defect.vo.StatistictCountVo; -import com.hnac.hzims.operational.report.service.IDeptService; -import org.apache.commons.lang3.math.NumberUtils; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.support.Condition; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; +import org.springblade.system.user.entity.User; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -34,7 +38,8 @@ public class OperDefectStatisticsServiceImpl extends BaseServiceImpl getDefectStatisticsExportVO(List list) { + List res=new ArrayList<>(); + if(list!=null && list.size()>0){ + for (int i = 0; i < list.size(); i++) { + OperDefectStatisticsExportVO operDefectStatisticsExportVO = new OperDefectStatisticsExportVO(); + operDefectStatisticsExportVO.setNumber(i+1); + OperDefectStatisticsEntity entity = list.get(i); + Long createDept = entity.getCreateDept(); + R dept = sysClient.getDept(createDept); + if (dept.isSuccess()&& ObjectUtils.isNotEmpty(dept.getData())){ + operDefectStatisticsExportVO.setDeptName(dept.getData().getDeptName()); + } + operDefectStatisticsExportVO.setDefectCode(entity.getDefectCode()); + if (ObjectUtils.isNotEmpty(entity.getFinder())) { + R finderUser = userClient.userInfoById(entity.getFinder()); + if (finderUser.isSuccess() && ObjectUtils.isNotEmpty(finderUser.getData())) { + operDefectStatisticsExportVO.setFinderName(finderUser.getData().getName()); + } + } + if (StringUtils.isNotBlank(entity.getPlanHandler())) { + R planHandlerUser = userClient.userInfoById(Long.valueOf(entity.getPlanHandler())); + if (planHandlerUser.isSuccess() && ObjectUtils.isNotEmpty(planHandlerUser.getData())) { + operDefectStatisticsExportVO.setPlanHandler(planHandlerUser.getData().getName()); + } + } + if (ObjectUtils.isNotEmpty(entity.getFindTime())) { + operDefectStatisticsExportVO.setFindTime(entity.getFindTime()); + } + if (StringUtils.isNotBlank(entity.getDescripiton())) { + operDefectStatisticsExportVO.setDescripiton(entity.getDescripiton()); + } + if (StringUtils.isNotBlank(entity.getDefectLevel())) { + String level = DictCache.getValue("defectLevel",entity.getDefectLevel()); + operDefectStatisticsExportVO.setDefectLevel(level); + } + if (ObjectUtils.isNotEmpty(entity.getActStartTime())) { + operDefectStatisticsExportVO.setActStartTime(entity.getActStartTime()); + } + if (StringUtils.isNotBlank(entity.getDisposeDesc())) { + operDefectStatisticsExportVO.setDisposeDesc(entity.getDisposeDesc()); + } + if (StringUtils.isNotBlank(entity.getTicketId())) { + operDefectStatisticsExportVO.setTicketId(entity.getTicketId()); + } + res.add(operDefectStatisticsExportVO); + } + } + return res; + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java index 0f53e7e..a994ce7 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.maintenance.controller; +import com.alibaba.druid.support.json.JSONUtils; import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; @@ -15,6 +16,7 @@ import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskCreateTask; import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskPushMsg; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; +import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.vo.VoteChartVo; import io.swagger.annotations.Api; @@ -40,6 +42,7 @@ import javax.validation.Valid; import java.io.IOException; import java.net.URLEncoder; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -117,7 +120,44 @@ public class OperMaintenanceTaskController extends BladeController { public R> list(@RequestBody OperMaintenanceTaskDTO req) { return taskService.list(req); } - + @ApiLog + @PostMapping("/exportMaintenance") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "日常维护记录导出") + @ApiImplicitParams({ + }) + @OperationAnnotation(moduleName = "日常维护记录导出",title = "日常维护记录导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action + = "日常维护记录导出") + public void exportMaintenance(HttpServletResponse response,@RequestBody OperMaintenanceTaskDTO req) { + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("日常维护记录统计报表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + List list = taskService.exportMaintenance(req); + if(list!=null && list.size()>0){ + System.out.println("---------------- size = " + list.size()); + // 这里需要设置不关闭流 + EasyExcel.write(response.getOutputStream(), MaintenanceExportVO.class).autoCloseStream(Boolean.FALSE).sheet("日常维护记录统计") + .doWrite(list); + } + } catch (Exception e) { + System.out.println("exportExcel = " + e.toString()); + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + Map map = new HashMap<>(); + map.put("isSuccess", "false"); + map.put("msg", "日常维护记录统计报表导出失败" + e.getMessage()); + try { + response.getWriter().println(JSONUtils.toJSONString(map)); + } catch (IOException e3) { + throw new ServiceException( "发生异常 :" + e.toString()); + } + } + } @GetMapping("/testCreateTask") @ApiOperationSupport(order = 60) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java index d4f10e1..145bcb4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; +import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; @@ -97,4 +98,6 @@ public interface IOperMaintenanceTaskService extends BaseService getMaintenanceListStatistics(String startTime, String endTime,Long deptId); + + List exportMaintenance(OperMaintenanceTaskDTO req); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java index dab8118..3f8609a 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java @@ -18,6 +18,7 @@ import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceTaskMapper; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; +import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO; import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO; import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenanceTaskWrapper; import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; @@ -25,6 +26,7 @@ import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; +import com.hnac.hzims.ticket.constants.TicketConstants; import com.hnac.hzims.vo.SafeCheckStatisticVO; import com.hnac.hzims.vo.VoteChartVo; import lombok.RequiredArgsConstructor; @@ -95,6 +97,13 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl queryWrapper = getQueryWrapper(req); + IPage pages = super.page(Condition.getPage(query), queryWrapper); + pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords())); + return R.data(pages); + } + + private static Wrapper getQueryWrapper(OperMaintenanceTaskDTO req) { Wrapper queryWrapper = new LambdaQueryWrapper() {{ orderByDesc(OperMaintenanceTaskEntity::getDisposeTime); if (StringUtil.isNotBlank(req.getTaskIds())) { @@ -141,10 +150,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl exportMaintenance(OperMaintenanceTaskDTO req) { + Wrapper queryWrapper = getQueryWrapper(req); + List maintenanceTaskEntities = super.baseMapper.selectList(queryWrapper); + List list=new ArrayList<>(); + if (CollectionUtil.isNotEmpty(maintenanceTaskEntities)){ + List operMaintenanceTaskVOS = OperMaintenanceTaskWrapper.build().listVO(maintenanceTaskEntities); + for (int i = 0; i < operMaintenanceTaskVOS.size(); i++) { + MaintenanceExportVO resEntity=new MaintenanceExportVO(); + OperMaintenanceTaskVO maintenanceTaskVO = operMaintenanceTaskVOS.get(i); + resEntity.setNumber(i+1); + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getCreateDept())){ + R dept = sysClient.getDept(maintenanceTaskVO.getCreateDept()); + if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){ + resEntity.setCompany(Optional.ofNullable(dept.getData().getDeptName()).orElse("")); + } + } + resEntity.setTypeCode(Optional.ofNullable(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, maintenanceTaskVO.getTypeCode())).orElse("")); + resEntity.setRefLibraryId(Optional.ofNullable( maintenanceTaskVO.getRefLibraryId().toString()).orElse("")); + resEntity.setTitle(Optional.ofNullable( maintenanceTaskVO.getTitle()).orElse("")); + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getPlanEndTime())) { + resEntity.setPlanEndTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getPlanEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + } + if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getExecuteTime())) { + resEntity.setExecuteTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getExecuteTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + } + resEntity.setDisposer(Optional.ofNullable(maintenanceTaskVO.getDisposerName()).orElse("")); + resEntity.setPrincipal(Optional.ofNullable(maintenanceTaskVO.getContent()).orElse("")); + list.add(resEntity); + } + } + return list; + } + private VoteChartVo getVoteChartVo(List list) { VoteChartVo voteChartVo = new VoteChartVo(); List finishIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() == 3).map(s -> s.getId()).collect(Collectors.toList()); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java index ee74cae..c646aa8 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java @@ -1,5 +1,7 @@ package com.hnac.hzims.ticket.standardTicket.controller; +import com.alibaba.druid.support.json.JSONUtils; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -7,20 +9,22 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; -import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo; import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto; import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; import com.hnac.hzims.ticket.standardTicket.vo.OperateVo; +import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketExportVO; import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -33,6 +37,9 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -86,6 +93,45 @@ public class StandardTicketInfoController extends BladeController { return standardTicketInfoService.queryList(req, query); } + @ApiLog + @PostMapping("/exportStandardTicket") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "操作票导出") + @ApiImplicitParams({ + }) + @OperationAnnotation(moduleName = "操作票导出",title = "操作票导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action + = "操作票导出") + public void exportStandardTicket(HttpServletResponse response,@RequestBody StandardTicketInfoDto req) { + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("操作票统计报表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + List list = standardTicketInfoService.exportStandardTicket(req); + if(list!=null && list.size()>0){ + System.out.println("---------------- size = " + list.size()); + // 这里需要设置不关闭流 + EasyExcel.write(response.getOutputStream(), StandardTicketExportVO.class).autoCloseStream(Boolean.FALSE).sheet("操作票统计报表") + .doWrite(list); + } + } catch (Exception e) { + System.out.println("exportExcel = " + e.toString()); + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + Map map = new HashMap<>(); + map.put("isSuccess", "false"); + map.put("msg", "操作票统计报表导出失败" + e.getMessage()); + try { + response.getWriter().println(JSONUtils.toJSONString(map)); + } catch (IOException e3) { + throw new ServiceException( "发生异常 :" + e.toString()); + } + } + } + @PostMapping("/list") @ApiOperationSupport(order = 60) @ApiOperation(value = "分页") diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java index 39a9da9..6c98ccd 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java @@ -9,10 +9,10 @@ import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo; import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto; import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity; import com.hnac.hzims.ticket.standardTicket.vo.OperateVo; +import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketExportVO; import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; -import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo; -import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountQueryVo; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; +import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo; import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.BladePage; @@ -141,4 +141,6 @@ public interface IStandardTicketInfoService extends BaseService listByOperationTicketWithKeyword(Page entityPage, StandardTicketCountQueryVo ticketCountQueryVo); IPage operate(IPage page,OperateVo operate); + + List exportStandardTicket(StandardTicketInfoDto entity); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java index 0abc4f7..9456767 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java @@ -1,7 +1,6 @@ package com.hnac.hzims.ticket.standardTicket.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; -import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -9,7 +8,6 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; @@ -26,10 +24,7 @@ import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketMeasureEntity; import com.hnac.hzims.ticket.standardTicket.mapper.StandardTicketInfoMapper; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService; import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketMeasureService; -import com.hnac.hzims.ticket.standardTicket.vo.OperateTicketStatisticVO; -import com.hnac.hzims.ticket.standardTicket.vo.OperateVo; -import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; -import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketMeasureVO; +import com.hnac.hzims.ticket.standardTicket.vo.*; import com.hnac.hzims.ticket.standardTicket.wrapper.StandardTicketInfoWrapper; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; @@ -52,7 +47,10 @@ import org.springblade.core.mp.support.Query; import org.springblade.core.secure.BladeUser; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; +import org.springblade.core.tool.utils.CollectionUtil; +import org.springblade.core.tool.utils.DateUtil; +import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.vo.ComleteTask; import org.springblade.system.cache.DictCache; @@ -796,4 +794,40 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl exportStandardTicket(StandardTicketInfoDto entity) { + LambdaQueryWrapper queryWrapper = this.getQueryWrapper(entity); + queryWrapper.eq(Func.isNotEmpty(entity.getCreateDept()), StandardTicketInfoEntity::getCreateDept, entity.getCreateDept()); + queryWrapper.orderByDesc(StandardTicketInfoEntity::getCreateTime); + //操作票已完成的数量 + if (StringUtils.isNoneBlank(entity.getFlowTaskName())) { + queryWrapper.eq(StandardTicketInfoEntity::getFlowTaskName, entity.getFlowTaskName()); + } + List standardTicketInfoEntities = super.baseMapper.selectList(queryWrapper); + List list=new ArrayList<>(); + if (CollectionUtils.isNotEmpty(standardTicketInfoEntities)){ + List standardTicketInfoVOS = StandardTicketInfoWrapper.build().listVO(standardTicketInfoEntities); + for (int i = 0; i < standardTicketInfoVOS.size(); i++) { + StandardTicketExportVO exportVO=new StandardTicketExportVO(); + StandardTicketInfoVO standardTicketInfoEntity = standardTicketInfoVOS.get(i); + exportVO.setNumber(i+1); + exportVO.setCompany( Optional.ofNullable(standardTicketInfoEntity.getCompany()).orElse(null)); + exportVO.setTicketType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE,standardTicketInfoEntity.getTicketType())).orElse(null)); + exportVO.setCode(Optional.ofNullable(standardTicketInfoEntity.getCode()).orElse(null)); + exportVO.setTitle(Optional.ofNullable(standardTicketInfoEntity.getTitle()).orElse(null)); + exportVO.setIssueOrderPerson(Optional.ofNullable(standardTicketInfoEntity.getIssueOrderPersonName()).orElse(null)); + exportVO.setAccessOrderPerson(Optional.ofNullable(standardTicketInfoEntity.getAccessOrderPersonName()).orElse(null)); + exportVO.setGuardian(Optional.ofNullable(standardTicketInfoEntity.getGuardianName()).orElse(null)); + exportVO.setPrincipal(Optional.ofNullable(standardTicketInfoEntity.getPrincipalName()).orElse(null)); + exportVO.setStartTime(Optional.ofNullable(DateUtil.format(standardTicketInfoEntity.getStartTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + exportVO.setEndTime(Optional.ofNullable(DateUtil.format(standardTicketInfoEntity.getEndTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + if (ObjectUtils.isNotEmpty(standardTicketInfoEntity.getIsEvaluate())){ + exportVO.setIsEvaluate(standardTicketInfoEntity.getIsEvaluate()==0?"不合格":"合格"); + } + list.add(exportVO); + } + } + return list; + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/StandardTicketExportVO.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/StandardTicketExportVO.java new file mode 100644 index 0000000..9969053 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/StandardTicketExportVO.java @@ -0,0 +1,86 @@ +package com.hnac.hzims.ticket.standardTicket.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @author hx + */ +@Data +public class StandardTicketExportVO { + private static final long serialVersionUID = 8239436726489738763L; + @ExcelProperty(value = "序号", index = 0) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "序号") + private Integer number; + + @ExcelProperty(value = "单位", index = 1) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "单位") + private String company; + + + @ExcelProperty(value = "票类", index = 2) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "票据类型") + private String ticketType; + + + @ExcelProperty(value = "操作票编号", index = 3) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "操作票编号") + private String code; + + @ApiModelProperty("操作票任务") + @ExcelProperty(value = "操作票任务", index = 4) + @ColumnWidth(value = 20) + private String title; + + + @ExcelProperty(value = "发令人", index = 5) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "发令人") + private String issueOrderPerson; + + + @ExcelProperty(value = "受令人", index = 6) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "受令人") + private String accessOrderPerson; + + @ExcelProperty(value = "监护人", index = 7) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "监护人") + private String guardian; + + @ExcelProperty(value = "值班负责人", index = 8) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "值班负责人") + private String principal; + + + + @ExcelProperty(value = "操作开始时间", index = 9) + @ColumnWidth(value = 20) + @ApiModelProperty("操作开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String startTime; + + @ExcelProperty(value = "操作结束时间", index = 10) + @ColumnWidth(value = 20) + @ApiModelProperty("操作结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String endTime; + + + @ExcelProperty(value = "评价", index = 11) + @ColumnWidth(value = 20) + @ApiModelProperty("是否评价") + private String isEvaluate; +} diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java index ac39c3d..8b728ee 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java @@ -1,6 +1,8 @@ package com.hnac.hzims.ticket.workTicket.controller; +import com.alibaba.druid.support.json.JSONUtils; +import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; @@ -9,35 +11,38 @@ import com.hnac.hzims.common.invalid.ObjectRequiredInvalid; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.OperatorType; -import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardWorkVo; import com.hnac.hzims.ticket.constants.DictConstants; -import com.hnac.hzims.ticket.standardTicket.vo.OperateVo; -import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO; import com.hnac.hzims.ticket.workTicket.dto.TicketAccessTaskDto; import com.hnac.hzims.ticket.workTicket.dto.WorkInfoFlowDto; import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketExportVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketInfoVO; import com.hnac.hzims.ticket.workTicket.vo.WorkVO; import io.swagger.annotations.*; import lombok.AllArgsConstructor; import org.springblade.core.log.annotation.ApiLog; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.*; +import org.springblade.core.tool.utils.SpringUtil; +import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.feign.IUserClient; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -119,6 +124,45 @@ public class WorkTicketInfoController { public void exportWorkTicketInfoPdf(@RequestParam Long id, HttpServletResponse response) { workTicketInfoService.exportWorkTicketInfoPdf(id, response); } + @ApiLog + @PostMapping("/exportWorkTicket") + @ApiOperationSupport(order = 2) + @ApiOperation(value = "工作票导出") + @ApiImplicitParams({ + }) + @OperationAnnotation(moduleName = "工作票导出",title = "工作票导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action + = "工作票导出") + public void exportWorkTicket(HttpServletResponse response,@RequestBody WorkTicketInfoDto req) { + try { + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("UTF-8"); + // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 + String fileName = URLEncoder.encode("工作票统计报表", "UTF-8"); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + List list = workTicketInfoService.exportWorkTicket(req); + if(list!=null && list.size()>0){ + System.out.println("---------------- size = " + list.size()); + // 这里需要设置不关闭流 + EasyExcel.write(response.getOutputStream(), WorkTicketExportVO.class).autoCloseStream(Boolean.FALSE).sheet("工作票统计报表") + .doWrite(list); + } + } catch (Exception e) { + System.out.println("exportExcel = " + e.toString()); + // 重置response + response.reset(); + response.setContentType("application/json"); + response.setCharacterEncoding("utf-8"); + Map map = new HashMap<>(); + map.put("isSuccess", "false"); + map.put("msg", "工作票统计报表导出失败" + e.getMessage()); + try { + response.getWriter().println(JSONUtils.toJSONString(map)); + } catch (IOException e3) { + throw new ServiceException( "发生异常 :" + e.toString()); + } + } + } + @GetMapping(value = "/exportWorkTicketTemplate") @ApiOperationSupport(order = 80) diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java index a1c924b..54bf7f9 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java @@ -10,6 +10,7 @@ import com.hnac.hzims.ticket.workTicket.dto.TicketAccessTaskDto; import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO; +import com.hnac.hzims.ticket.workTicket.vo.WorkTicketExportVO; import com.hnac.hzims.ticket.workTicket.vo.WorkTicketInfoVO; import com.hnac.hzims.ticket.workTicket.vo.WorkVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; @@ -182,4 +183,6 @@ public interface IWorkTicketInfoService extends BaseService work(IPage page, WorkVO work); + + List exportWorkTicket(WorkTicketInfoDto req); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java index cbf588a..96626f6 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java @@ -60,6 +60,7 @@ import org.springblade.core.tool.utils.*; import org.springblade.flow.core.entity.BladeFlow; import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.vo.ComleteTask; +import org.springblade.system.cache.DictCache; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -1225,4 +1226,44 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl exportWorkTicket(WorkTicketInfoDto req) { + LambdaQueryWrapper lqw = this.getQueryWrapper(req); + if (ObjectUtil.isNotEmpty(req.getCreateDept())) { + lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept()); + } + //已完成的工作票 + if (StringUtils.isNotEmpty(req.getFlowTaskName())) { + lqw.eq(WorkTicketInfoEntity::getFlowTaskName, req.getFlowTaskName()); + } + lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime); + List res = super.baseMapper.selectList(lqw); + List list=new ArrayList<>(); + if (CollectionUtils.isNotEmpty(res)){ + List workTicketInfoVOS = WorkTicketInfoWrapper.build().listVO(res); + for (int i = 0; i < workTicketInfoVOS.size(); i++) { + WorkTicketExportVO resEntity=new WorkTicketExportVO(); + WorkTicketInfoVO workTicketInfoVO = workTicketInfoVOS.get(i); + resEntity.setNumber(i+1); + resEntity.setCompany( Optional.ofNullable(workTicketInfoVO.getCompany()).orElse("")); + resEntity.setType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE, workTicketInfoVO.getType())).orElse("")); + resEntity.setCode(Optional.ofNullable(workTicketInfoVO.getCode()).orElse("")); + resEntity.setWorkContent(Optional.ofNullable(workTicketInfoVO.getWorkContent()).orElse("")); + resEntity.setSigner(Optional.ofNullable(workTicketInfoVO.getSignerName()).orElse("")); + resEntity.setPrincipal(Optional.ofNullable(workTicketInfoVO.getPrincipalName()).orElse("")); + resEntity.setLicensor(Optional.ofNullable(workTicketInfoVO.getLicensorName()).orElse("")); + resEntity.setClassGroupMembers(Optional.ofNullable(workTicketInfoVO.getClassGroupMembersName()).orElse(workTicketInfoVO.getClassGroupMembersManual()==null?"":workTicketInfoVO.getClassGroupMembersManual())); + resEntity.setCreateTime(Optional.ofNullable(DateUtil.format(workTicketInfoVO.getCreateTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + if (ObjectUtil.isNotEmpty(workTicketInfoVO.getConfirmWorkTime())){ + resEntity.setConfirmWorkTime(Optional.ofNullable(DateUtil.format(workTicketInfoVO.getConfirmWorkTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + } + if (ObjectUtils.isNotEmpty(workTicketInfoVO.getIsEvaluate())){ + resEntity.setIsEvaluate(workTicketInfoVO.getIsEvaluate()==0?"不合格":"合格"); + } + list.add(resEntity); + } + } + return list; + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketExportVO.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketExportVO.java new file mode 100644 index 0000000..1af5e15 --- /dev/null +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketExportVO.java @@ -0,0 +1,86 @@ +package com.hnac.hzims.ticket.workTicket.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * @author hx + */ +@Data +public class WorkTicketExportVO { + + @ExcelProperty(value = "序号", index = 0) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "序号") + private Integer number; + + @ExcelProperty(value = "单位", index = 1) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "单位") + private String company; + + + @ExcelProperty(value = "票类", index = 2) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "票据类型") + private String type; + + + @ExcelProperty(value = "工作票编号", index = 3) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "工作票编号") + private String code; + + @ApiModelProperty("工作票任务") + @ExcelProperty(value = "工作票任务", index = 4) + @ColumnWidth(value = 20) + private String workContent; + + + @ExcelProperty(value = "签发人", index = 5) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "签发人") + private String signer; + + + @ExcelProperty(value = "工作负责人", index = 6) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "工作负责人") + private String principal; + + @ExcelProperty(value = "工作许可人", index = 7) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "工作许可人") + private String licensor; + + @ExcelProperty(value = "工作班成员", index = 8) + @ColumnWidth(value = 20) + @ApiModelProperty(value = "工作班成员") + private String classGroupMembers; + + + + @ExcelProperty(value = "工作票开始时间", index = 9) + @ColumnWidth(value = 20) + @ApiModelProperty("工作票开始时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String createTime; + + @ExcelProperty(value = "工作票结束时间", index = 10) + @ColumnWidth(value = 20) + @ApiModelProperty("工作票结束时间") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String confirmWorkTime; + + + @ExcelProperty(value = "评价", index = 11) + @ColumnWidth(value = 20) + @ApiModelProperty("是否评价") + private String isEvaluate; +}