From 26fb50b5a684e252d80fc453a57b34a8934d9f23 Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 1 Dec 2023 20:08:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=90=E7=BB=B4=E5=85=AC=E5=8F=B8=E7=AC=AC?= =?UTF-8?q?=E4=BA=8C=E7=89=88=E5=AF=BC=E5=87=BA=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maintenance/vo/MaintenanceExportVO.java | 26 ++--- .../inspect/task/vo/InspectTaskExportVO.java | 24 ++--- .../inspect/task/controller/TaskController.java | 9 ++ .../inspect/task/service/impl/TaskServiceImpl.java | 90 ++++++++++------- .../controller/OperMaintenanceTaskController.java | 12 +++ .../impl/OperMaintenanceTaskServiceImpl.java | 49 +++++++--- .../impl/StandardTicketInfoServiceImpl.java | 16 ++-- .../controller/WorkTicketInfoController.java | 12 +++ .../service/impl/WorkTicketInfoServiceImpl.java | 106 ++++++++++++--------- .../ticket/workTicket/vo/WorkTicketExportVO.java | 4 +- 10 files changed, 213 insertions(+), 135 deletions(-) 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 index d951e7f..9e5f9f9 100644 --- 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 @@ -13,41 +13,41 @@ import org.springframework.format.annotation.DateTimeFormat; @Data public class MaintenanceExportVO { - @ExcelProperty(value = "序号", index = 0) - @ColumnWidth(value = 20) - @ApiModelProperty(value = "序号") - private Integer number; +// @ExcelProperty(value = "序号", index = 0) +// @ColumnWidth(value = 20) +// @ApiModelProperty(value = "序号") +// private Integer number; - @ExcelProperty(value = "单位", index = 1) + @ExcelProperty(value = "单位", index = 0) @ColumnWidth(value = 20) @ApiModelProperty(value = "单位") private String company; - @ExcelProperty(value = "维护类型", index = 2) + @ExcelProperty(value = "维护类型", index =1) @ColumnWidth(value = 20) @ApiModelProperty(value = "维护类型") private String typeCode; - @ExcelProperty(value = "维护设备", index = 3) + @ExcelProperty(value = "维护设备", index = 2) @ColumnWidth(value = 20) @ApiModelProperty(value = "维护设备") private String refLibraryId; @ApiModelProperty("维护内容") - @ExcelProperty(value = "维护内容", index = 4) + @ExcelProperty(value = "维护内容", index = 3) @ColumnWidth(value = 20) private String title; - @ExcelProperty(value = "计划执行时间", index = 5) + @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 = 6) + @ExcelProperty(value = "实际执行时间", index = 5) @ColumnWidth(value = 20) @ApiModelProperty("实际执行时间") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @@ -55,14 +55,14 @@ public class MaintenanceExportVO { private String executeTime; - @ExcelProperty(value = "执行人", index = 7) + @ExcelProperty(value = "执行人", index = 6) @ColumnWidth(value = 20) @ApiModelProperty(value = "执行人") private String disposer; - @ExcelProperty(value = "执行情况", index = 8) + @ExcelProperty(value = "操作规范", index = 7) @ColumnWidth(value = 20) - @ApiModelProperty(value = "执行情况") + @ApiModelProperty(value = "操作规范") private String principal; } 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 index f74f883..09ebb52 100644 --- 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 @@ -13,44 +13,40 @@ import org.springframework.format.annotation.DateTimeFormat; @Data public class InspectTaskExportVO { - @ExcelProperty(value = "序号", index = 0) - @ColumnWidth(value = 20) - @ApiModelProperty(value = "序号") - private Integer number; - @ExcelProperty(value = "单位", index = 1) + @ExcelProperty(value = "单位", index = 0) @ColumnWidth(value = 20) @ApiModelProperty(value = "单位") private String company; - @ExcelProperty(value = "巡检名称", index = 2) + @ExcelProperty(value = "巡检名称", index = 1) @ColumnWidth(value = 20) @ApiModelProperty(value = "巡检名称") private String planName; - @ExcelProperty(value = "计划开始时间", index = 3) + @ExcelProperty(value = "计划开始时间", index = 2) @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) + @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 planEndTime; - @ExcelProperty(value = "实际开始时间", index = 5) + @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 startTime; - @ExcelProperty(value = "实际结束时间", index = 6) + @ExcelProperty(value = "实际结束时间", index = 5) @ColumnWidth(value = 20) @ApiModelProperty("实际结束时间") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @@ -58,21 +54,21 @@ public class InspectTaskExportVO { private String endTime; @ApiModelProperty("巡检时长(分钟)") - @ExcelProperty(value = "巡检时长(分钟)", index = 7) + @ExcelProperty(value = "巡检时长(分钟)", index = 6) @ColumnWidth(value = 20) private Long inspectTime; @ApiModelProperty("巡检人") - @ExcelProperty(value = "巡检人", index = 8) + @ExcelProperty(value = "巡检人", index = 7) @ColumnWidth(value = 20) private String userName; @ApiModelProperty("巡检情况") - @ExcelProperty(value = "巡检情况", index = 9) + @ExcelProperty(value = "巡检情况", index = 8) @ColumnWidth(value = 20) private String content; @ApiModelProperty("巡检状态") - @ExcelProperty(value = "巡检状态", index = 10) + @ExcelProperty(value = "巡检状态", index = 9) @ColumnWidth(value = 20) private String status; 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 7bb2da4..3c9b55d 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 @@ -45,11 +45,14 @@ import org.springblade.resource.vo.PushInfoVO; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.ObjectUtils; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.temporal.TemporalAdjusters; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -152,6 +155,12 @@ public class TaskController extends BladeController { @ApiOperation(value = "巡检任务导出", notes = "传入计划id") public void exportTaskList(HttpServletResponse response,@RequestBody TaskDTO task) { try { + if(ObjectUtils.isEmpty(task.getStartTime())&&ObjectUtils.isEmpty(task.getEndTime())){ + LocalDateTime date = LocalDateTime.now(); + LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0); + task.setStartTime(firstDay); + task.setEndTime(date); + } response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("UTF-8"); // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 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 9bd4771..16b509d 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 @@ -1025,48 +1025,64 @@ public class TaskServiceImpl extends BaseServiceImpl imp 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++) { + list=taskEntities.parallelStream().map(taskVo -> { 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("")); + try { + 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("")); } - } - 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)); - } + 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("正常"); + 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("正常"); + } + if(ObjectUtil.isNotEmpty(taskVo.getId())) { + List taskUserList = taskUserService.list(Wrappers.lambdaQuery().eq(TaskUserEntity::getTaskId, taskVo.getId())); + if (CollectionUtil.isNotEmpty(taskUserList)) { + // 获取巡检任务人员名称 + String userNames = taskUserList.stream().filter(Func::isNotEmpty).map(TaskUserEntity::getUserId).filter(Func::isNotEmpty) + .map(userId -> { + User user = UserCache.getUser(userId); + if (ObjectUtil.isEmpty(user)) { + return ""; + } + return user.getName(); + }).collect(Collectors.joining(",")); + resEntity.setUserName(userNames); + } + } + resEntity.setStatus(Optional.ofNullable(DictCache.getValue(TaskContants.TASK_STATUS, taskVo.getStatus())).orElse("")); + return resEntity; + }catch (Exception e){ + log.error("巡检导出失败---》param"+taskVo+"报错信息:"+e.getStackTrace()); + return resEntity; } - resEntity.setUserName(Optional.ofNullable( taskVo.getUserNames()).orElse("")); - resEntity.setStatus(Optional.ofNullable(DictCache.getValue(TaskContants.TASK_STATUS, taskVo.getStatus())).orElse("")); - list.add(resEntity); - } + }).collect(Collectors.toList()); } return list; } 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 a994ce7..0f9c89f 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 @@ -34,6 +34,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.vo.ComleteTask; +import org.springframework.util.ObjectUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -41,6 +42,9 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAdjusters; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -130,6 +134,14 @@ public class OperMaintenanceTaskController extends BladeController { = "日常维护记录导出") public void exportMaintenance(HttpServletResponse response,@RequestBody OperMaintenanceTaskDTO req) { try { + if(ObjectUtils.isEmpty(req.getStartTime())&&ObjectUtils.isEmpty(req.getEndTime())){ + LocalDateTime date = LocalDateTime.now(); + String nowDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0); + String firstDate = firstDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + req.setStartTime(firstDate); + req.setEndTime(nowDate); + } response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("UTF-8"); // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 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 a4bd954..6d7b1fc 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 @@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Lists; +import com.hnac.hzims.equipment.entity.EmInfoEntity; +import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.operational.defect.constants.DefectConstant; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; import com.hnac.hzims.operational.defect.mapper.OperPhenomenonMapper; @@ -75,7 +77,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl 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++) { + list = maintenanceTaskEntities.parallelStream().map(maintenanceTaskVO -> { MaintenanceExportVO resEntity=new MaintenanceExportVO(); - OperMaintenanceTaskVO maintenanceTaskVO = operMaintenanceTaskVOS.get(i); - resEntity.setNumber(i+1); + try { if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getCreateDept())){ R dept = sysClient.getDept(maintenanceTaskVO.getCreateDept()); if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){ @@ -472,18 +472,41 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl{ + List disposerList = Arrays.stream(s.split(",")).collect(Collectors.toList()); + return disposerList.stream().map(d ->{ + User user = UserCache.getUser(Long.parseLong(d)); + return Optional.ofNullable(user).map(User::getName).orElse(""); + }).collect(Collectors.joining(",")); + }).orElse(""); + if (StringUtil.isNotBlank(disposerName)) { + resEntity.setDisposer(disposerName); + } + } +// resEntity.setDisposer(Optional.ofNullable(maintenanceTaskVO.getDisposerName()).orElse("")); + resEntity.setPrincipal(Optional.ofNullable(maintenanceTaskVO.getWorkStandards()).orElse("")); + return resEntity; + }catch (Exception e){ + log.error("日常维护导出失败---》param"+maintenanceTaskVO+"报错信息:"+e.getStackTrace()); + return resEntity; + } + }).collect(Collectors.toList()); } return list; } 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 6e34475..f3b6699 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 @@ -12,7 +12,6 @@ import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; import com.hnac.hzims.ticket.allTicket.vo.DoublePassVO; -import com.hnac.hzims.ticket.allTicket.vo.TicketInfoEvaluateVO; import com.hnac.hzims.ticket.allTicket.vo.TicketInfoStatisticVO; import com.hnac.hzims.ticket.areamonthly.feign.TicketFeignClient; import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketVo; @@ -847,16 +846,15 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl> ticketList = ticketFeignClient.list(ticketInfoEvaluateEntity); - if (ticketList.isSuccess() && CollectionUtil.isNotEmpty(ticketList.getData())) { - exportVO.setIsEvaluate(ticketList.getData().get(0).getStatus() == 1 ? "合格" : "不合格"); + if (1==standardTicketInfoEntity.getIsEvaluate() ) { + TicketInfoEvaluateEntity evaluateEntity = ticketInfoEvaluateService.getOne(new LambdaQueryWrapper() {{ + eq(TicketInfoEvaluateEntity::getTicketId, standardTicketInfoEntity.getId()); + }}.last(" limit 1")); + if ( ObjectUtil.isNotEmpty(evaluateEntity)) { + exportVO.setIsEvaluate(evaluateEntity.getStatus() == 1 ? "合格" : "不合格"); } } - } - }catch (Exception e){ + }}catch (Exception e){ log.error("转换失败----》"+e.toString()+standardTicketInfoEntity.toString()); System.out.println("转换失败----》"+e.toString()+standardTicketInfoEntity.toString()); } 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 f8a2d3a..1a99ef6 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 @@ -35,6 +35,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.SpringUtil; import org.springblade.core.tool.utils.StringUtil; import org.springblade.system.user.feign.IUserClient; +import org.springframework.util.ObjectUtils; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -42,6 +43,9 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.net.URLEncoder; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.TemporalAdjusters; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -134,6 +138,14 @@ public class WorkTicketInfoController { = "工作票导出") public void exportWorkTicket(HttpServletResponse response,@RequestBody WorkTicketInfoDto req) { try { + if(ObjectUtils.isEmpty(req.getStartTime())&&ObjectUtils.isEmpty(req.getEndTime())){ + LocalDateTime date = LocalDateTime.now(); + String nowDate = date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0); + String firstDate = firstDay.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + req.setStartTime(firstDate); + req.setEndTime(nowDate); + } response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("UTF-8"); // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 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 fca6fb7..09bb28e 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 @@ -22,7 +22,6 @@ import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; import com.hnac.hzims.operational.maintenance.feign.ITaskClient; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; -import com.hnac.hzims.ticket.allTicket.vo.TicketInfoEvaluateVO; import com.hnac.hzims.ticket.areamonthly.feign.TicketFeignClient; import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo; import com.hnac.hzims.ticket.areamonthly.vo.StandardWorkVo; @@ -116,10 +115,14 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.ge(Func.isNotEmpty(business.getStartTime()), "works.create_time", business.getStartTime()); queryWrapper.le(Func.isNotEmpty(business.getEndTime()), "works.create_time", business.getEndTime()); - queryWrapper.in(Func.isNotEmpty(business.getDeptIds()), "works.create_dept",Func.toLongList(",",business.getDeptIds())); + queryWrapper.in(Func.isNotEmpty(business.getDeptIds()), "works.create_dept", Func.toLongList(",", business.getDeptIds())); queryWrapper.like(Func.isNotEmpty(business.getCode()), "works.code", business.getCode()); queryWrapper.eq(Func.isNotEmpty(business.getType()), "works.type", business.getType()); queryWrapper.eq(Func.isNotEmpty(business.getStatus()), "eva.status", business.getStatus()); - IPage pages = this.baseMapper.pageCondition(page,queryWrapper); + IPage pages = this.baseMapper.pageCondition(page, queryWrapper); pages.setRecords(WorkTicketInfoWrapper.build().listVO(pages.getRecords())); return pages; } @Override public List exportWorkTicket(WorkTicketInfoDto req) { + LambdaQueryWrapper lqw = this.getQueryWrapper(req); if (ObjectUtil.isNotEmpty(req.getCreateDept())) { lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept()); @@ -1251,53 +1256,60 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl list = new ArrayList<>(); if (CollectionUtils.isNotEmpty(res)) { // List workTicketInfoVOS = WorkTicketInfoWrapper.build().listVO(res); - list= res.parallelStream().map(workTicketInfoVO -> { - WorkTicketExportVO resEntity = new WorkTicketExportVO(); + list = res.parallelStream().map(workTicketInfoVO -> { + try { + WorkTicketExportVO resEntity = new WorkTicketExportVO(); // 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("")); - if (ObjectUtil.isNotEmpty(workTicketInfoVO.getSigner())) { - User user = UserCache.getUser(workTicketInfoVO.getSigner()); - if (ObjectUtil.isNotEmpty(user)) { - resEntity.setSigner(user.getName()); + 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("")); + if (ObjectUtil.isNotEmpty(workTicketInfoVO.getSigner())) { + User user = UserCache.getUser(workTicketInfoVO.getSigner()); + if (ObjectUtil.isNotEmpty(user)) { + resEntity.setSigner(user.getName()); + } } - } - //负责人-线上和线下 - if (Func.isEmpty(workTicketInfoVO.getPrincipal())) { - resEntity.setPrincipal(workTicketInfoVO.getPrincipalManual()); - } else { - User principal = UserCache.getUser(workTicketInfoVO.getPrincipal()); - if (ObjectUtil.isNotEmpty(principal)) { - resEntity.setPrincipal(principal.getName()); + //负责人-线上和线下 + if (Func.isEmpty(workTicketInfoVO.getPrincipal())) { + resEntity.setPrincipal(workTicketInfoVO.getPrincipalManual()); + } else { + User principal = UserCache.getUser(workTicketInfoVO.getPrincipal()); + if (ObjectUtil.isNotEmpty(principal)) { + resEntity.setPrincipal(principal.getName()); + } } - } - if (ObjectUtil.isNotEmpty(workTicketInfoVO.getLicensor())) { - User user = UserCache.getUser(workTicketInfoVO.getLicensor()); - if (ObjectUtil.isNotEmpty(user)) { - resEntity.setLicensor(user.getName()); + if (ObjectUtil.isNotEmpty(workTicketInfoVO.getLicensor())) { + User user = UserCache.getUser(workTicketInfoVO.getLicensor()); + if (ObjectUtil.isNotEmpty(user)) { + resEntity.setLicensor(user.getName()); + } } - } - workTicketInfoVO.setClassGroupMembersName(workTicketInfoVO.getClassGroupMembers()); - if(Func.isNotEmpty(workTicketInfoVO.getClassGroupMembersManual())){ - workTicketInfoVO.setClassGroupMembersName(workTicketInfoVO.getClassGroupMembersManual()); - } - 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("")); - } - resEntity.setIsEvaluate("未评价"); - if (workTicketInfoVO.getIsEvaluate() == 1) { - TicketInfoEvaluateEntity ticketInfoEvaluateEntity = new TicketInfoEvaluateEntity(); - ticketInfoEvaluateEntity.setTicketId(workTicketInfoVO.getId()); - R> ticketList = ticketFeignClient.list(ticketInfoEvaluateEntity); - if (ticketList.isSuccess() && CollectionUtil.isNotEmpty(ticketList.getData())) { - resEntity.setIsEvaluate(ticketList.getData().get(0).getStatus() == 1 ? "合格" : "不合格"); + workTicketInfoVO.setClassGroupMembersName(workTicketInfoVO.getClassGroupMembers()); + if (Func.isNotEmpty(workTicketInfoVO.getClassGroupMembersManual())) { + workTicketInfoVO.setClassGroupMembersName(workTicketInfoVO.getClassGroupMembersManual()); + } + 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.getPlanEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse("")); + } + resEntity.setIsEvaluate("未评价"); + if (ObjectUtil.isNotEmpty(workTicketInfoVO.getIsEvaluate())&&1==workTicketInfoVO.getIsEvaluate()) { + TicketInfoEvaluateEntity ticketInfoEvaluateEntity = new TicketInfoEvaluateEntity(); + TicketInfoEvaluateEntity evaluateEntity = ticketInfoEvaluateService.getOne(new LambdaQueryWrapper() {{ + eq(TicketInfoEvaluateEntity::getTicketId, workTicketInfoVO.getId()); + }}.last(" limit 1")); + if ( ObjectUtil.isNotEmpty(evaluateEntity)) { + resEntity.setIsEvaluate(evaluateEntity.getStatus() == 1 ? "合格" : "不合格"); + } } + return resEntity; + } catch (Exception e) { + System.out.println(e); + log.error("数据转换失败,参数:"+workTicketInfoVO+"报错信息:"+e); + return new WorkTicketExportVO(); } - return resEntity; }).collect(Collectors.toList()); } 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 index f1720d6..9975380 100644 --- 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 @@ -71,9 +71,9 @@ public class WorkTicketExportVO { @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private String createTime; - @ExcelProperty(value = "工作票结束时间", index = 9) + @ExcelProperty(value = "计划结束时间", index = 9) @ColumnWidth(value = 20) - @ApiModelProperty("工作票结束时间") + @ApiModelProperty("计划结束时间") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private String confirmWorkTime;