From 895c450b9e7863cc3ca38468eaaecb467a6a23fc Mon Sep 17 00:00:00 2001 From: tyty Date: Fri, 18 Aug 2023 10:06:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A1=E6=A3=80-=E6=97=A5=E5=B8=B8-=E6=A3=80?= =?UTF-8?q?=E4=BF=AE-=E6=B6=88=E7=BC=BA=E7=BB=9F=E8=AE=A1=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hzims-service-api/common-api/pom.xml | 4 ++ .../main/java/com/hnac/hzims/vo/VoteChartVo.java | 39 ++++++++++++ .../defect/vo/OperDefectStatisticsVO.java | 11 +++- .../maintenance/dto/OperMaintenanceTaskDTO.java | 8 ++- .../operational/report/vo/CheckVoteChartVo.java | 45 +++++++++++++ .../com/hnac/hzinfo/inspect/task/dto/TaskDTO.java | 7 +++ .../inspect/task/controller/TaskController.java | 68 ++++++++++++++++---- .../hzinfo/inspect/task/service/ITaskService.java | 7 ++- .../inspect/task/service/impl/TaskServiceImpl.java | 65 ++++++++++++++++++- .../hnac/hzinfo/inspect/task/vo/TaskListQuery.java | 6 +- .../controller/OperAccessStatisticsController.java | 3 +- .../controller/OperAccessTaskController.java | 51 +++++++++++++++ .../access/dto/OperAccessStatisticsDTO.java | 3 +- .../access/mapper/OperAccessStatisticsMapper.xml | 6 ++ .../access/service/IOperAccessTaskService.java | 5 +- .../service/impl/OperAccessTaskServiceImpl.java | 64 +++++++++++++++++++ .../census/service/impl/TargetServiceImpl.java | 4 +- .../controller/OperDefectStatisticsController.java | 12 ++-- .../controller/OperPhenomenonController.java | 50 +++++++++++++++ .../defect/service/IOperPhenomenonService.java | 6 +- .../impl/OperDefectStatisticsServiceImpl.java | 3 + .../service/impl/OperPhenomenonServiceImpl.java | 72 +++++++++++++++++++-- .../controller/OperMaintenanceTaskController.java | 67 ++++++++++++++++---- .../service/IOperMaintenanceTaskService.java | 7 ++- .../impl/OperMaintenanceTaskServiceImpl.java | 73 +++++++++++++++++++++- 25 files changed, 630 insertions(+), 56 deletions(-) create mode 100644 hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CheckVoteChartVo.java diff --git a/hzims-service-api/common-api/pom.xml b/hzims-service-api/common-api/pom.xml index dad68bd..49c639e 100644 --- a/hzims-service-api/common-api/pom.xml +++ b/hzims-service-api/common-api/pom.xml @@ -22,6 +22,10 @@ + + com.alibaba + easyexcel + diff --git a/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java b/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java new file mode 100644 index 0000000..788f4cd --- /dev/null +++ b/hzims-service-api/common-api/src/main/java/com/hnac/hzims/vo/VoteChartVo.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.vo; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author hx + */ +@Data +@ApiModel("各个票种统计表") +public class VoteChartVo { + @ApiModelProperty(value = "站点名称") + @ExcelProperty(value = "站点名称", index = 0) + private String name; + + @ApiModelProperty(value = "总数量") + @ExcelProperty(value = "总数量", index = 1) + private int sumNum; + @ApiModelProperty(value = "总数量id") + @ExcelIgnore + private List sumIds; + @ApiModelProperty(value = "未完成数量") + @ExcelProperty(value = "未完成数量", index = 2) + private int undoneNum; + @ApiModelProperty(value = "未完成id") + @ExcelIgnore + private List undoneIds; + @ApiModelProperty(value = "完成数量") + @ExcelProperty(value = "完成数量", index = 3) + private int finishNum; + @ApiModelProperty(value = "完成id") + @ExcelIgnore + private List finishIds; +} diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsVO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsVO.java index e420e57..bb1120c 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsVO.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsVO.java @@ -1,13 +1,14 @@ package com.hnac.hzims.operational.defect.vo; import com.fasterxml.jackson.annotation.JsonFormat; +import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; -import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity; import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; +import java.util.List; /** * 模型VO @@ -22,7 +23,8 @@ public class OperDefectStatisticsVO extends OperDefectStatisticsEntity { @ApiModelProperty(value = "问题发现人名称") private String finderName; - + @ApiModelProperty(value = "现象Ids") + private List defectCodeList; @ApiModelProperty(value = "甄别人名称") private String discriminatorName; @@ -69,4 +71,9 @@ public class OperDefectStatisticsVO extends OperDefectStatisticsEntity { ) @ApiModelProperty(value = "定论时间范围-最晚") private Date createEndTime; + + @ApiModelProperty("当前页") + private Integer current; + @ApiModelProperty("每页的数量") + private Integer size; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java index bd32e77..5d82099 100644 --- a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/dto/OperMaintenanceTaskDTO.java @@ -1,6 +1,5 @@ package com.hnac.hzims.operational.maintenance.dto; -import com.baomidou.mybatisplus.annotation.TableField; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -24,6 +23,8 @@ public class OperMaintenanceTaskDTO extends OperMaintenanceTaskEntity { @ApiModelProperty("任务Id 多个按逗号分隔") private String taskIds; + @ApiModelProperty("任务Id 多个按逗号分隔") + private List taskList; @ApiModelProperty("任务Id 多个按逗号分隔") private List deptIds; @@ -33,4 +34,9 @@ public class OperMaintenanceTaskDTO extends OperMaintenanceTaskEntity { @ApiModelProperty("结束时间") private String endTime; + + @ApiModelProperty("当前页") + private Integer current; + @ApiModelProperty("每页的数量") + private Integer size; } diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CheckVoteChartVo.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CheckVoteChartVo.java new file mode 100644 index 0000000..0c4234b --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/report/vo/CheckVoteChartVo.java @@ -0,0 +1,45 @@ +package com.hnac.hzims.operational.report.vo; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * @author hx + */ +@Data +@ApiModel("缺陷统计表") +public class CheckVoteChartVo { + @ApiModelProperty(value = "站点名称") + @ExcelProperty(value = "站点名称", index = 0) + private String name; + + @ApiModelProperty(value = "现象数量") + @ExcelProperty(value = "现象数量", index = 1) + private int phenomenonNum; + @ApiModelProperty(value = "现象数量id") + @ExcelIgnore + private List phenomenonIds; + @ApiModelProperty(value = "缺陷数量") + @ExcelProperty(value = "缺陷数量", index = 2) + private int defectNum; + @ApiModelProperty(value = "缺陷code") + @ExcelIgnore + private List defectIds; + @ApiModelProperty(value = "处理数量") + @ExcelProperty(value = "处理数量", index = 3) + private int handleNum; + @ApiModelProperty(value = "处理code") + @ExcelIgnore + private List handleIds; + @ApiModelProperty(value = "定论数量") + @ExcelProperty(value = "定论数量", index = 4) + private int conclusionNum; + @ApiModelProperty(value = "定论code") + @ExcelIgnore + private List conclusionIds; +} diff --git a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/TaskDTO.java b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/TaskDTO.java index 2d6a4a2..fd8d81d 100644 --- a/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/TaskDTO.java +++ b/hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/dto/TaskDTO.java @@ -11,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.time.LocalDateTime; +import java.util.List; /** * @ClassName TaskDTO @@ -34,4 +35,10 @@ public class TaskDTO extends TaskEntity implements Serializable { @ApiModelProperty(value = "任务计划开始时间-止") private LocalDateTime planStartTimeEnd; + @ApiModelProperty(value = "id集合") + private List ids; + @ApiModelProperty("当前页") + private Integer current; + @ApiModelProperty("每页的数量") + private Integer size; } 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 90b5af1..aceb616 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,16 +1,15 @@ package com.hnac.hzinfo.inspect.task.controller; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.fasterxml.jackson.annotation.JsonRawValue; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.google.common.collect.Lists; 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.vo.VoteChartVo; import com.hnac.hzinfo.core.push.enums.PushAudienceType; import com.hnac.hzinfo.core.push.model.PushAudience; import com.hnac.hzinfo.core.push.model.PushInfo; @@ -31,14 +30,14 @@ import com.hnac.hzinfo.inspect.utils.Condition; import io.swagger.annotations.*; import lombok.AllArgsConstructor; import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.cache.utils.CacheUtil; +import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.support.BladePage; import org.springblade.core.mp.support.Query; import org.springblade.core.secure.annotation.PreAuth; import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.resource.feign.IPushClient; import org.springblade.resource.vo.PushInfoVO; import org.springblade.system.user.cache.UserCache; @@ -46,7 +45,13 @@ import org.springblade.system.user.entity.User; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** @@ -104,26 +109,29 @@ public class TaskController extends BladeController { return R.data(detail); } - @GetMapping("/listPage") + @PostMapping("/listPage") @ApiOperation(value = "巡检任务分页查询-站长级", notes = "传入task") @ApiOperationSupport(order = 1) - public R> listPage(TaskDTO taskDTO, Query query) { - return R.data(taskService.page(taskDTO,query)); + public R> listPage(@RequestBody TaskDTO taskDTO) { + return R.data(taskService.page(taskDTO)); } /** * PC端分页显示任务列表 */ - @GetMapping("/list") + @PostMapping("/list") @ApiOperation(value = "分页显示任务列表", notes = "传入task") @OperationAnnotation(moduleName = "巡检管理",title = "我的巡检任务",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, action = "分页显示任务列表") - public R> list(TaskListQuery task, Query query) { + public R> list(@RequestBody TaskListQuery task) { //CacheUtil.put("test#2","inspect","test","12"); // LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new TaskEntity(),task); // queryWrapper.orderByDesc(TaskEntity::getUpdateTime); // IPage pages = taskService.page(Condition.getPage(query), queryWrapper); + Query query = new Query(); + query.setSize(task.getSize()); + query.setCurrent(task.getCurrent()); IPage pages = Condition.getPage(query); if(!AuthUtil.isAdministrator()){ task.setCurUserId(AuthUtil.getUserId()); @@ -370,5 +378,43 @@ public class TaskController extends BladeController { return R.data(pageList); } + /** + * 巡检计划统计 + */ + @GetMapping("/getTaskListStatistics") + @ApiOperation(value = "巡检计划统计", notes = "传入计划id") + public R> getTaskListStatistics(String startTime,String endTime,Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + return R.fail("暂无权限查看,请稍后重试"); + } + List list=taskService.getTaskListStatistics(startTime,endTime,deptId); + return R.data(list); + } + /** + * 巡检计划统计 + */ + @GetMapping("/importTaskListStatistics") + @ApiOperation(value = "导出", notes = "传入计划id") + public void importTaskListStatistics(HttpServletResponse response, String startTime, String endTime,Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + throw new ServiceException ("暂无权限查看,请稍后重试"); + } + List list=taskService.getTaskListStatistics(startTime,endTime,deptId); + // 下载导出 + String filename = "(" + startTime+"-"+endTime + ")巡检统计表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), VoteChartVo.class).autoCloseStream(Boolean.TRUE).sheet(1,"巡检计划统计表") + .doWrite(list); + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } 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 e0f7ec3..7f62c5a 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 @@ -3,15 +3,14 @@ package com.hnac.hzinfo.inspect.task.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hnac.hzims.vo.SafeCheckStatisticVO; +import com.hnac.hzims.vo.VoteChartVo; import com.hnac.hzinfo.inspect.task.dto.TaskDTO; import com.hnac.hzinfo.inspect.task.entity.InspectionTaskSMS; import com.hnac.hzinfo.inspect.task.entity.TaskEntity; import com.hnac.hzinfo.inspect.task.vo.*; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.BladePage; -import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; -import org.springframework.web.bind.annotation.RequestParam; import java.util.List; import java.util.Map; @@ -65,7 +64,7 @@ public interface ITaskService extends BaseService { */ List getTaskById(Long id); - IPage page(TaskDTO taskDTO, Query query); + IPage page(TaskDTO taskDTO); /** * PC端任务列表 @@ -189,4 +188,6 @@ public interface ITaskService extends BaseService { * @return */ BladePage selectPage(Page pageInfo, TaskListQuery task); + + List getTaskListStatistics(String startTime, String endTime,Long deptId); } 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 3f7e0df..d7527c4 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 @@ -14,6 +14,7 @@ import com.hnac.hzims.safeproduct.Constants; import com.hnac.hzims.safeproduct.entity.ImsMonCameraInfoEntity; import com.hnac.hzims.safeproduct.feign.IImsMonCameraInfoClient; import com.hnac.hzims.vo.SafeCheckStatisticVO; +import com.hnac.hzims.vo.VoteChartVo; import com.hnac.hzinfo.inspect.ai.service.IRobotService; import com.hnac.hzinfo.inspect.obj.ObjContants; import com.hnac.hzinfo.inspect.obj.services.IObjectDangerService; @@ -44,6 +45,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.utils.*; import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; @@ -521,13 +523,17 @@ public class TaskServiceImpl extends BaseServiceImpl imp } @Override - public IPage page(TaskDTO taskDTO, Query query) { + public IPage page(TaskDTO taskDTO) { + Query query = new Query(); + query.setSize(taskDTO.getSize()); + 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); IPage page = this.page(Condition.getPage(query), queryWrapper); List records = page.getRecords(); @@ -954,6 +960,49 @@ public class TaskServiceImpl extends BaseServiceImpl imp } + @Override + public List getTaskListStatistics(String startTime, String endTime,Long deptId) { + List taskEntities=new ArrayList<>(); + R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); + List deptIds; + if (deptByCurrentUser.isSuccess() && CollectionUtil.isNotEmpty(deptByCurrentUser.getData())) { + deptIds = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList()); + } else { + throw new ServiceException("暂无机构权限"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtil.isNotEmpty(deptId)) { + if (deptIds.contains(deptId)) { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptId); + } else { + throw new ServiceException("暂无该机构权限"); + } + } else { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds); + } + queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME",startTime); + queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME",endTime); + taskEntities= baseMapper.selectList(queryWrapper); + List res=new ArrayList<>(); + if (CollectionUtil.isNotEmpty(taskEntities)) { + VoteChartVo all = getVoteChartVo(taskEntities); + all.setName("总计"); + res.add(all); + Map> collect = Optional.ofNullable(taskEntities).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(TaskEntity::getCreateDept)); + for (Map.Entry> longListEntry : collect.entrySet()) { + VoteChartVo voteChartVo = getVoteChartVo(longListEntry.getValue()); + R deptName = sysClient.getDeptName(longListEntry.getKey()); + voteChartVo.setName(deptName.isSuccess() ? deptName.getData() : ""); + res.add(voteChartVo); + } + }else { + VoteChartVo all = new VoteChartVo(); + all.setName("总计"); + res.add(all); + } + return res; + } + /** * 巡检任务分页 * @@ -1018,4 +1067,18 @@ public class TaskServiceImpl extends BaseServiceImpl imp } return null; } + + 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()); + List undoneIds =Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() != 3).map(s -> s.getId()).collect(Collectors.toList()); + voteChartVo.setSumNum(list.size()); + voteChartVo.setSumIds(list.stream().map(s -> s.getId()).collect(Collectors.toList())); + voteChartVo.setFinishNum(finishIds.size()); + voteChartVo.setFinishIds(finishIds); + voteChartVo.setUndoneNum(undoneIds.size()); + voteChartVo.setUndoneIds(undoneIds); + return voteChartVo; + } + } diff --git a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java index b36c94d..6343e9c 100644 --- a/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java +++ b/hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/vo/TaskListQuery.java @@ -8,7 +8,6 @@ import lombok.Setter; import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.YearMonth; @@ -130,4 +129,9 @@ public class TaskListQuery implements Serializable { * 创建机构 */ private Long createDept; + + @ApiModelProperty("当前页") + private Integer current; + @ApiModelProperty("每页的数量") + private Integer size; } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java index 0093523..cc71673 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessStatisticsController.java @@ -20,7 +20,6 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; /** @@ -87,7 +86,7 @@ public class OperAccessStatisticsController extends BladeController { @OperationAnnotation(moduleName = "检修管理",title = "检修记录",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE, action = "分页查询检修记录列表") - public R> list(OperAccessStatisticsDTO req, Query query) { + public R> list(@RequestBody OperAccessStatisticsDTO req, Query query) { return service.list(req, Condition.getPage(query)); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java index 1ac99e2..9e40bf2 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/controller/OperAccessTaskController.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.access.controller; +import com.alibaba.excel.EasyExcel; import com.baomidou.mybatisplus.core.metadata.IPage; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.logs.annotation.OperationAnnotation; @@ -10,18 +11,25 @@ import com.hnac.hzims.operational.access.dto.OperAccessTaskFlowDTO; import com.hnac.hzims.operational.access.service.IOperAccessTaskService; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.RepairBillVO; +import com.hnac.hzims.vo.VoteChartVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; 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.Query; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; 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.List; /** @@ -104,4 +112,47 @@ public class OperAccessTaskController extends BladeController { public R> getAccessTaskByEmCode(String emCode, String startTime, String endTime) { return R.data(service.getRepairBill(emCode, startTime, endTime)); } + + /** + * 检修计划统计 + */ + @GetMapping("/getAccessListStatistics") + @ApiOperation(value = "检修计划统计", notes = "传入时间") + public R> getAccessListStatistics(String startTime, String endTime,Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + return R.fail("暂无权限查看,请稍后重试"); + } + List list=service.getAccessListStatistics(startTime,endTime,deptId); + return R.data(list); + } + + /** + * 检修计划统计 + */ + @GetMapping("/importAccessListStatistics") + @ApiOperation(value = "导出", notes = "传入时间") + public void importAccessListStatistics(HttpServletResponse response, String startTime, String endTime,Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + throw new ServiceException("暂无权限查看,请稍后重试"); + } + List list=service.getAccessListStatistics(startTime,endTime,deptId); + // 下载导出 + String filename = "(" + startTime+"-"+endTime + ")检修计划统计表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), VoteChartVo.class).autoCloseStream(Boolean.TRUE).sheet(1,"检修计划统计表") + .doWrite(list); + response.getOutputStream().close(); + // 关闭 + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java index 62db8b3..bb9effb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/dto/OperAccessStatisticsDTO.java @@ -25,7 +25,8 @@ public class OperAccessStatisticsDTO extends OperAccessStatisticsEntity { @ApiModelProperty(value = "创建机构集合") private List deptIds; - + @ApiModelProperty(value = "id集合") + private List ids; /** * 月份 */ diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml index e390f35..994ab75 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/mapper/OperAccessStatisticsMapper.xml @@ -28,6 +28,12 @@ JOIN hzims_oper_access_task OT ON OS.`TASK_ID` = OT.`ID` WHERE OS.IS_DELETED = 0 + + and OS.id in + + #{item} + + and OT.`NAME` like concat('%',#{dto.taskName},'%') diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java index 54335f3..07012b4 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/IOperAccessTaskService.java @@ -2,14 +2,13 @@ package com.hnac.hzims.operational.access.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hnac.hzims.operational.access.dto.OperAccessStatisticsDTO; import com.hnac.hzims.operational.access.dto.OperAccessTaskDTO; import com.hnac.hzims.operational.access.entity.OperAccessTaskEntity; -import com.hnac.hzims.operational.access.vo.OperAccessStatisticsVO; import com.hnac.hzims.operational.access.vo.OperAccessTaskVO; import com.hnac.hzims.operational.access.vo.RepairBillVO; import com.hnac.hzims.operational.report.vo.AccessReportVO; import com.hnac.hzims.vo.SafeCheckStatisticVO; +import com.hnac.hzims.vo.VoteChartVo; import org.springblade.core.mp.base.BaseService; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; @@ -76,4 +75,6 @@ public interface IOperAccessTaskService extends BaseService selectPage(Page dbPage, OperAccessTaskEntity result); List getRepairBill(String emCode, String startTime, String endTime); + + List getAccessListStatistics(String startTime, String endTime,Long deptId); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java index 7b819ce..0aad039 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/access/service/impl/OperAccessTaskServiceImpl.java @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +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.equipment.entity.EmInfoEntity; @@ -39,6 +40,7 @@ import com.hnac.hzims.safeproduct.feign.IDangerSourceClient; import com.hnac.hzims.spare.entity.SpRecordEntity; import com.hnac.hzims.spare.feign.ISpareClient; import com.hnac.hzims.vo.SafeCheckStatisticVO; +import com.hnac.hzims.vo.VoteChartVo; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.RandomUtils; @@ -55,6 +57,8 @@ import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.vo.ComleteTask; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -86,6 +90,8 @@ public class OperAccessTaskServiceImpl extends BaseServiceImpl getAccessListStatistics(String startTime, String endTime,Long deptId) { + List operAccessTaskEntityList; + R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); + List deptIds; + if (deptByCurrentUser.isSuccess()&&CollectionUtil.isNotEmpty(deptByCurrentUser.getData())) { + deptIds = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList()); + }else { + throw new ServiceException("暂无机构权限"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtil.isNotEmpty(deptId)){ + if (deptIds.contains(deptId)) { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptId); + }else { + throw new ServiceException("暂无该机构权限"); + } + }else { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds); + } + + queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME",startTime); + queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME",endTime); + operAccessTaskEntityList= baseMapper.selectList(queryWrapper); + + List res=new ArrayList<>(); + if (CollectionUtil.isNotEmpty(operAccessTaskEntityList)) { + VoteChartVo all = getVoteChartVo(operAccessTaskEntityList); + all.setName("总计"); + res.add(all); + Map> collect = Optional.ofNullable(operAccessTaskEntityList).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(OperAccessTaskEntity::getCreateDept)); + for (Map.Entry> longListEntry : collect.entrySet()) { + VoteChartVo voteChartVo = getVoteChartVo(longListEntry.getValue()); + R deptName = sysClient.getDeptName(longListEntry.getKey()); + voteChartVo.setName(deptName.isSuccess() ? deptName.getData() : ""); + res.add(voteChartVo); + } + }else { + VoteChartVo all = new VoteChartVo(); + all.setName("总计"); + res.add(all); + } + return res; + } + + private VoteChartVo getVoteChartVo(List list) { + VoteChartVo voteChartVo = new VoteChartVo(); + List finishIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() == 4).map(s -> s.getId()).collect(Collectors.toList()); + List undoneIds =Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() != 4).map(s -> s.getId()).collect(Collectors.toList()); + voteChartVo.setSumNum(list.size()); + voteChartVo.setSumIds(list.stream().map(s -> s.getId()).collect(Collectors.toList())); + voteChartVo.setFinishNum(finishIds.size()); + voteChartVo.setFinishIds(finishIds); + voteChartVo.setUndoneNum(undoneIds.size()); + voteChartVo.setUndoneIds(undoneIds); + return voteChartVo; + } + /*** * 根据流程ID和处理人完成任务 * @param comleteTask diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java index 1693d5d..022e1eb 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/census/service/impl/TargetServiceImpl.java @@ -730,7 +730,9 @@ public class TargetServiceImpl implements TargetService { } // 查询日常维护任务 params.setDeptIds(areas.keySet().stream().map(Dept::getId).collect(Collectors.toList())); - return maintenanceTaskService.list(params,query); + params.setCurrent(query.getCurrent()); + params.setSize(query.getSize()); + return maintenanceTaskService.list(params); } /** 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 d8e798a..cd4e5b2 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 @@ -25,10 +25,7 @@ import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.system.entity.Dept; import org.springblade.system.feign.ISysClient; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.stream.Collectors; @@ -64,14 +61,17 @@ public class OperDefectStatisticsController extends BladeController { * 分页 代码自定义代号 */ @ApiLog - @GetMapping("/list") + @PostMapping("/list") @ApiOperationSupport(order = 2) @ApiOperation(value = "分页", notes = "传入statistics") @ApiImplicitParams({ }) @OperationAnnotation(moduleName = "缺陷管理",title = "缺陷记录",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action = "分页查询缺陷记录列表") - public R> list( OperDefectStatisticsVO entity, Query query) { + public R> list(@RequestBody OperDefectStatisticsVO entity) { + Query query=new Query(); + query.setCurrent(entity.getCurrent()); + query.setSize(entity.getSize()); LambdaQueryWrapper queryWrapper = statisticsService.getQueryWrapper(entity); IPage pages = statisticsService.page(Condition.getPage(query), queryWrapper); IPage vos = OperDefectStatisticsWrapper.build().pageVO(pages); diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java index 1abf0d9..11c37b0 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperPhenomenonController.java @@ -1,5 +1,6 @@ package com.hnac.hzims.operational.defect.controller; +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; @@ -12,6 +13,7 @@ import com.hnac.hzims.operational.defect.entity.OperAppearanceEntity; import com.hnac.hzims.operational.defect.service.IOperAppearanceService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.defect.vo.OperAppearanceVO; +import com.hnac.hzims.operational.report.vo.CheckVoteChartVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; @@ -19,14 +21,22 @@ 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.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.Func; +import org.springblade.core.tool.utils.ObjectUtil; import org.springblade.flow.core.entity.BladeFlow; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; +import java.util.List; + /** * 控制器 * @@ -131,4 +141,44 @@ public class OperPhenomenonController extends BladeController { public R getFdpTaskByDefectCode(@RequestParam("defectCode") String defectCode) { return R.data(phenomenonService.getFdpTaskByDefectCode(defectCode)); } + + /** + * 缺陷记录统计 + */ + @GetMapping("/getDefectListStatistics") + @ApiOperation(value = "缺陷记录统计", notes = "传入时间") + public R> getDefectListStatistics(String startTime, String endTime, Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + return R.fail("暂无权限查看,请稍后重试"); + } + List list=phenomenonService.getDefectListStatistics(startTime,endTime,deptId); + return R.data(list); + } + + /** + * 缺陷记录统计 + */ + @GetMapping("/importDefectListStatistics") + @ApiOperation(value = "导出", notes = "传入时间") + public void importDefectListStatistics(HttpServletResponse response, String startTime, String endTime, Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + throw new ServiceException ("暂无权限查看,请稍后重试"); + } + List list=phenomenonService.getDefectListStatistics(startTime,endTime,deptId); + // 下载导出 + String filename = "(" + startTime+"-"+endTime + ")缺陷统计表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), CheckVoteChartVo.class).autoCloseStream(Boolean.TRUE).sheet(1,"缺陷统计表") + .doWrite(list); + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperPhenomenonService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperPhenomenonService.java index 3b3f6d0..1f3bf57 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperPhenomenonService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperPhenomenonService.java @@ -4,14 +4,12 @@ import com.hnac.hzims.fdp.entity.FdpTaskEntity; import com.hnac.hzims.operational.defect.dto.OperMainDefectDTO; import com.hnac.hzims.operational.defect.dto.OperPhenomenonDTO; import com.hnac.hzims.operational.defect.entity.OperPhenomenonEntity; -import com.hnac.hzims.operational.defect.vo.OperPhenomenonVO; import com.hnac.hzims.operational.duty.vo.MainOperPhenomenonVo; +import com.hnac.hzims.operational.report.vo.CheckVoteChartVo; import com.hnac.hzims.operational.report.vo.DutyDefectVO; import org.springblade.core.mp.base.BaseService; -import org.springblade.core.tool.api.R; import org.springblade.flow.core.entity.BladeFlow; -import java.time.LocalDateTime; import java.util.List; import java.util.Map; @@ -95,4 +93,6 @@ public interface IOperPhenomenonService extends BaseService getDefectListStatistics(String startTime, String endTime, Long deptId); } 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 208566e..837e107 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 @@ -41,6 +41,9 @@ public class OperDefectStatisticsServiceImpl extends BaseServiceImpl getQueryWrapper(OperDefectStatisticsVO statistics) { LambdaQueryWrapper queryWrapper = Condition.getQueryWrapper(new OperDefectStatisticsEntity(),statistics); if(Func.isNotEmpty(statistics)) { + if (Func.isNotEmpty(statistics.getDefectCodeList())) { + queryWrapper.in(OperDefectStatisticsEntity::getDefectCode, statistics.getDefectCodeList()); + } if (statistics.getActStartTime() != null) { queryWrapper.ge(OperDefectStatisticsEntity::getActStartTime, statistics.getActStartTime()); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java index cf8acfa..f9f0ac1 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperPhenomenonServiceImpl.java @@ -3,12 +3,12 @@ package com.hnac.hzims.operational.defect.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.hnac.hzims.fdp.entity.FdpTaskEntity; import com.hnac.hzims.fdp.feign.IFdpTaskClient; import com.hnac.hzims.operational.defect.config.DefectConfiguration; import com.hnac.hzims.operational.defect.constants.DefectConstant; -import com.hnac.hzims.operational.defect.constants.RepairConstant; import com.hnac.hzims.operational.defect.dto.OperMainDefectDTO; import com.hnac.hzims.operational.defect.dto.OperPhenomenonDTO; import com.hnac.hzims.operational.defect.entity.OperDefectEntity; @@ -20,16 +20,13 @@ import com.hnac.hzims.operational.defect.service.IOperDefectService; import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService; import com.hnac.hzims.operational.defect.service.IOperPhenomenonService; import com.hnac.hzims.operational.defect.vo.OperPhenomenonVO; -import com.hnac.hzims.operational.defect.wrapper.OperPhenomenonWrapper; import com.hnac.hzims.operational.duty.vo.MainOperPhenomenonVo; +import com.hnac.hzims.operational.report.vo.CheckVoteChartVo; import com.hnac.hzims.operational.report.vo.DutyDefectVO; -import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity; import com.hnac.hzims.operational.util.GenerateCode; -import com.hnac.hzims.ticket.repair.entity.RepairEntity; import lombok.extern.slf4j.Slf4j; import org.springblade.core.log.exception.ServiceException; import org.springblade.core.mp.base.BaseServiceImpl; -import org.springblade.core.mp.support.Condition; import org.springblade.core.redis.lock.LockType; import org.springblade.core.redis.lock.RedisLock; import org.springblade.core.secure.utils.AuthUtil; @@ -43,6 +40,8 @@ import org.springblade.flow.core.utils.FlowUtil; import org.springblade.flow.core.utils.TaskUtil; import org.springblade.flow.core.vo.ComleteTask; import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -67,6 +66,8 @@ import java.util.stream.Collectors; public class OperPhenomenonServiceImpl extends BaseServiceImpl implements IOperPhenomenonService,GenerateCode{ @Autowired + private ISysClient sysClient; + @Autowired private IFlowClient flowClient; @Autowired @@ -582,4 +583,65 @@ public class OperPhenomenonServiceImpl extends BaseServiceImpl getDefectListStatistics(String startTime, String endTime, Long deptId) { + List operPhenomenonEntities; + R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); + List deptIds; + if (deptByCurrentUser.isSuccess() && CollectionUtil.isNotEmpty(deptByCurrentUser.getData())) { + deptIds = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList()); + } else { + throw new ServiceException("暂无机构权限"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtil.isNotEmpty(deptId)) { + if (deptIds.contains(deptId)) { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptId); + } else { + throw new ServiceException("暂无该机构权限"); + } + } else { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds); + } + queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME", startTime); + queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME", endTime); + operPhenomenonEntities = baseMapper.selectList(queryWrapper); + + List res = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(operPhenomenonEntities)) { + CheckVoteChartVo all = getCheckVoteChartVo(operPhenomenonEntities); + all.setName("总计"); + res.add(all); + Map> collect = Optional.ofNullable(operPhenomenonEntities).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(OperPhenomenonEntity::getCreateDept)); + for (Map.Entry> longListEntry : collect.entrySet()) { + CheckVoteChartVo chartVo= getCheckVoteChartVo(longListEntry.getValue()); + R deptName = sysClient.getDeptName(longListEntry.getKey()); + chartVo.setName(deptName.isSuccess() ? deptName.getData() : ""); + res.add(chartVo); + } + } else { + CheckVoteChartVo all = new CheckVoteChartVo(); + all.setName("总计"); + res.add(all); + } + return res; + } + + private CheckVoteChartVo getCheckVoteChartVo(List list) { + CheckVoteChartVo voteChartVo = new CheckVoteChartVo(); + List checkIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getIsDefect() !=null).filter(s -> s.getIsDefect() == 1).map(s -> s.getDefectCode()).collect(Collectors.toList()); + List handerIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getIsDefect() !=null).filter(s -> "1".equals(s.getHandleStatus())).map(s -> s.getDefectCode()).collect(Collectors.toList()); + List conclusionIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getIsDefect() !=null).filter(s -> "1".equals(s.getConclusionStatus())).map(s -> s.getDefectCode()).collect(Collectors.toList()); + voteChartVo.setPhenomenonNum(list.size()); + voteChartVo.setPhenomenonIds(list.stream().map(s -> s.getId()).collect(Collectors.toList())); + voteChartVo.setDefectNum(checkIds.size()); + voteChartVo.setDefectIds(checkIds); + voteChartVo.setHandleNum(handerIds.size()); + voteChartVo.setHandleIds(handerIds); + voteChartVo.setConclusionNum(conclusionIds.size()); + voteChartVo.setConclusionIds(conclusionIds); + return voteChartVo; + } + } 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 49ef934..0f53e7e 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,42 +1,44 @@ package com.hnac.hzims.operational.maintenance.controller; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.hnac.hzims.common.invalid.DictInvalid; 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.operational.maintenance.constants.MaintenanceConstant; import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO; 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.OperMaintenanceTaskVO; -import com.hnac.hzims.ticket.areamonthly.vo.AreaMonthlyVo; -import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; -import io.swagger.annotations.*; +import com.hnac.hzims.vo.VoteChartVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; 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.mp.support.Query; +import org.springblade.core.log.exception.ServiceException; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; 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.data.domain.Sort; -import org.springframework.data.web.SortDefault; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import springfox.documentation.annotations.ApiIgnore; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.net.URLEncoder; import java.util.Arrays; import java.util.List; import java.util.Map; @@ -105,15 +107,15 @@ public class OperMaintenanceTaskController extends BladeController { * 分页 */ @ApiLog - @GetMapping("/list") + @PostMapping("/list") @ApiOperationSupport(order = 50) @ApiOperation(value = "分页 查询参数:refLibraryId,processInstanceId,disposer,content,status") @ApiImplicitParams({ }) @OperationAnnotation(moduleName = "日常维护", title = "日常维护记录", operatorType = OperatorType.MOBILE, businessType = BusinessType.GENCODE, action = "分页查询日常维护记录列表") - public R> list(OperMaintenanceTaskDTO req, Query query) { - return taskService.list(req, query); + public R> list(@RequestBody OperMaintenanceTaskDTO req) { + return taskService.list(req); } @@ -161,6 +163,47 @@ public class OperMaintenanceTaskController extends BladeController { return taskService.deleteTaskBatch(taskIdList); } + /** + * 日常计划统计 + */ + @GetMapping("/getMaintenanceListStatistics") + @ApiOperation(value = "日常计划统计", notes = "传入时间") + public R> getMaintenanceListStatistics(String startTime, String endTime,Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + return R.fail("暂无权限查看,请稍后重试"); + } + List list=taskService.getMaintenanceListStatistics(startTime,endTime,deptId); + return R.data(list); + } + + /** + * 日常计划统计 + */ + @GetMapping("/importMaintenanceListStatistics") + @ApiOperation(value = "导出", notes = "传入时间") + public void importMaintenanceListStatistics(HttpServletResponse response, String startTime, String endTime,Long deptId) { + if(ObjectUtil.isEmpty(AuthUtil.getUser())||ObjectUtil.isEmpty(AuthUtil.getUser().getUserId())){ + throw new ServiceException("暂无权限查看,请稍后重试"); + } + List list=taskService.getMaintenanceListStatistics(startTime,endTime,deptId); + // 下载导出 + String filename = "(" + startTime+"-"+endTime + ")日常维护计划统计表"; + // 设置头信息 + response.setCharacterEncoding("UTF-8"); + response.setContentType("application/vnd.ms-excel"); + try { + //设置xlsx格式 + response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename + ".xlsx", "UTF-8")); + //创建一个输出流 + EasyExcel.write(response.getOutputStream(), VoteChartVo.class).autoCloseStream(Boolean.TRUE).sheet(1,"日常计划统计") + .doWrite(list); + response.getOutputStream().close(); + // 关闭 + response.getOutputStream().close(); + } catch (IOException e) { + e.printStackTrace(); + } + } } 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 c821f1c..d4f10e1 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 @@ -2,16 +2,16 @@ package com.hnac.hzims.operational.maintenance.service; import com.baomidou.mybatisplus.core.metadata.IPage; 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.OperMaintenanceTaskVO; -import com.hnac.hzims.operational.main.vo.RegularWorkVO; import com.hnac.hzims.operational.report.vo.MaintenanceReportVO; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo; import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo; import com.hnac.hzims.vo.SafeCheckStatisticVO; +import com.hnac.hzims.vo.VoteChartVo; import org.springblade.core.mp.base.BaseService; -import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springblade.flow.core.vo.ComleteTask; import org.springframework.web.bind.annotation.RequestParam; @@ -31,7 +31,7 @@ public interface IOperMaintenanceTaskService extends BaseService detail(@RequestParam Long id); - R> list(OperMaintenanceTaskDTO req, Query query); + R> list(OperMaintenanceTaskDTO req); String genTaskCode(Integer num); @@ -96,4 +96,5 @@ public interface IOperMaintenanceTaskService extends BaseService queryLogMaintenancePageList(Page pageParam, MaintenanceTaskWithAreaVo areaMonthlyVo); + List getMaintenanceListStatistics(String startTime, String endTime,Long deptId); } 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 87178e9..dab8118 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 @@ -4,6 +4,7 @@ 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; +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; @@ -25,6 +26,7 @@ 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.vo.SafeCheckStatisticVO; +import com.hnac.hzims.vo.VoteChartVo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringUtils; @@ -40,6 +42,8 @@ import org.springblade.flow.core.feign.IFlowClient; import org.springblade.flow.core.vo.ComleteTask; import org.springblade.flow.core.vo.EndVo; import org.springblade.system.cache.DictCache; +import org.springblade.system.entity.Dept; +import org.springblade.system.feign.ISysClient; import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.entity.User; import org.springblade.system.user.feign.IUserClient; @@ -70,6 +74,8 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl> list(OperMaintenanceTaskDTO req, Query query) { + public R> list(OperMaintenanceTaskDTO req) { + Query query=new Query(); + query.setSize(req.getSize()); + query.setCurrent(req.getCurrent()); Wrapper queryWrapper = new LambdaQueryWrapper() {{ orderByDesc(OperMaintenanceTaskEntity::getDisposeTime); if (StringUtil.isNotBlank(req.getTaskIds())) { in(OperMaintenanceTaskEntity::getId, Lists.newArrayList(req.getTaskIds().split(","))); } + if (CollectionUtil.isNotEmpty(req.getTaskList())) { + in(OperMaintenanceTaskEntity::getId, req.getTaskList()); + } if (req.getRefLibraryId() != null) { eq(OperMaintenanceTaskEntity::getRefLibraryId, req.getRefLibraryId()); } @@ -126,7 +138,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl getMaintenanceListStatistics(String startTime, String endTime,Long deptId) { + List maintenanceTaskEntities = new ArrayList<>(); + R> deptByCurrentUser = sysClient.getDeptByCurrentUser(); + List deptIds; + if (deptByCurrentUser.isSuccess() && CollectionUtil.isNotEmpty(deptByCurrentUser.getData())) { + deptIds = deptByCurrentUser.getData().stream().map(s -> s.getId()).collect(Collectors.toList()); + } else { + throw new ServiceException("暂无机构权限"); + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtil.isNotEmpty(deptId)) { + if (deptIds.contains(deptId)) { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptId); + } else { + throw new ServiceException("暂无该机构权限"); + } + } else { + queryWrapper.in(ObjectUtils.isNotNull(deptIds), "CREATE_DEPT", deptIds); + } + queryWrapper.ge(ObjectUtils.isNotNull(startTime), "CREATE_TIME", startTime); + queryWrapper.le(ObjectUtils.isNotNull(endTime), "CREATE_TIME", endTime); + maintenanceTaskEntities = baseMapper.selectList(queryWrapper); + + List res = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(maintenanceTaskEntities)) { + VoteChartVo all = getVoteChartVo(maintenanceTaskEntities); + all.setName("总计"); + res.add(all); + Map> collect = Optional.ofNullable(maintenanceTaskEntities).orElse(new ArrayList<>()).stream().collect(Collectors.groupingBy(OperMaintenanceTaskEntity::getCreateDept)); + for (Map.Entry> longListEntry : collect.entrySet()) { + VoteChartVo voteChartVo = getVoteChartVo(longListEntry.getValue()); + R deptName = sysClient.getDeptName(longListEntry.getKey()); + voteChartVo.setName(deptName.isSuccess() ? deptName.getData() : ""); + res.add(voteChartVo); + } + } else { + VoteChartVo all = new VoteChartVo(); + all.setName("总计"); + res.add(all); + } + return res; + } + + 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()); + List undoneIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() != 3).map(s -> s.getId()).collect(Collectors.toList()); + voteChartVo.setSumNum(list.size()); + voteChartVo.setSumIds(list.stream().map(s -> s.getId()).collect(Collectors.toList())); + voteChartVo.setFinishNum(finishIds.size()); + voteChartVo.setFinishIds(finishIds); + voteChartVo.setUndoneNum(undoneIds.size()); + voteChartVo.setUndoneIds(undoneIds); + return voteChartVo; + } }