| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.BaseModel; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.WebUtils; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.model.*; |
| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.poi.ss.usermodel.Workbook; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import oshi.driver.mac.net.NetStat; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletOutputStream; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | |
| | | progressListVOPageInfo.setRecords(records); |
| | | return R.ok(progressListVOPageInfo); |
| | | } |
| | | @ApiOperation(value = "任务进度导出") |
| | | @Log(title = "任务进度导出", businessType = BusinessType.EXPORT) |
| | | @PostMapping(value = "/taskProgressExport") |
| | | public void taskProgressExport(@RequestBody TaskProgressQuery query) { |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | if (StringUtils.hasLength(query.getDeptName())) { |
| | | List<String> projectIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() |
| | | .stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | List<String> deptIds = deptService.lambdaQuery().like(TDept::getDeptName, query.getDeptName()).list() |
| | | .stream().map(TDept::getId).collect(Collectors.toList()); |
| | | projectIds.addAll(deptIds); |
| | | if (projectIds.isEmpty()) { |
| | | projectIds.add("-1"); |
| | | } |
| | | // 用户ids |
| | | List<Long> collect = sysUsers.stream().filter(e -> e.getDeptType() == 1 && projectIds.contains(e.getDeptId())).map(SysUser::getUserId) |
| | | .collect(Collectors.toList()); |
| | | List<Long> collect1 = sysUsers.stream().filter(e -> e.getDeptType() == 2 && deptIds.contains(e.getDeptId())).map(SysUser::getUserId) |
| | | .collect(Collectors.toList()); |
| | | collect.addAll(collect1); |
| | | if (collect.isEmpty()) { |
| | | collect.add(0L); |
| | | } |
| | | query.setPatrolInspectorIds(collect); |
| | | |
| | | if (StringUtils.hasLength(query.getPhonenumber())) { |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | && projectIds.contains(sysUser.getDeptId()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (patrolInspectorIds.isEmpty()) { |
| | | patrolInspectorIds.add(0L); |
| | | } else { |
| | | patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())) { |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (patrolInspectorIds.isEmpty()) { |
| | | patrolInspectorIds.add(0L); |
| | | } |
| | | if (!query.getPatrolInspectorIds().isEmpty()) { |
| | | // 取交集 |
| | | patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | List<ProgressListVO> records = taskCleanerService.taskProgressExport(query); |
| | | List<TTemplate> templates = templateService.list(); |
| | | List<TTemplateDetail> templateDetails = templateDetailService.list(); |
| | | for (ProgressListVO record : records) { |
| | | SysUser sysUser1 = sysUsers.stream().filter(sysUser -> sysUser.getUserId().equals(record.getUserId())).findFirst().orElse(null); |
| | | if (sysUser1 != null) { |
| | | if (sysUser1.getDeptType() == 1) { |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser1.getDeptId()); |
| | | if (tProjectDept != null) { |
| | | if (!tProjectDept.getParentId().equals("0")) { |
| | | TProjectDept tProjectDept1 = projectDeptService.getById(tProjectDept.getParentId()); |
| | | if (tProjectDept1 != null) { |
| | | record.setDeptName(tProjectDept1.getProjectName() + ">" + tProjectDept.getProjectName()); |
| | | } |
| | | } else { |
| | | record.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | } |
| | | } else { |
| | | TDept tDept = deptService.getById(sysUser1.getDeptId()); |
| | | if (tDept != null) { |
| | | record.setDeptName(tDept.getDeptName()); |
| | | } |
| | | } |
| | | } |
| | | TTemplate tTemplate = templates.stream().filter(e -> e.getId().equals(record.getTemplateId())).findFirst().orElse(null); |
| | | // todo 应生成计划数 |
| | | record.setNum1(1); |
| | | LocalDateTime createTime = tTemplate.getCreateTime(); |
| | | // 转化为yyyy-MM-dd字符串 |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | stringBuilder.append(createTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))).append(" 至 "); |
| | | List<TTemplateDetail> tTemplateDetail = templateDetails.stream().filter(e -> e.getTemplateId().equals(record.getTemplateId())).collect(Collectors.toList()); |
| | | int temp = 0; |
| | | if (!tTemplateDetail.isEmpty()) { |
| | | for (TTemplateDetail templateDetail : tTemplateDetail) { |
| | | Integer cycle = templateDetail.getCycle(); |
| | | Integer cycleType = templateDetail.getCycleType(); |
| | | switch (cycleType) { |
| | | case 1: |
| | | temp = cycle; |
| | | break; |
| | | case 2: |
| | | temp = cycle * 7; |
| | | |
| | | break; |
| | | case 3: |
| | | temp = cycle * 30; |
| | | break; |
| | | case 4: |
| | | temp = cycle * 90; |
| | | break; |
| | | case 5: |
| | | temp = cycle * 365; |
| | | break; |
| | | } |
| | | } |
| | | LocalDateTime localDateTime = tTemplate.getCreateTime().plusDays(temp); |
| | | stringBuilder.append(localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | record.setTemplateDate(stringBuilder.toString()); |
| | | if (record.getNum2() != 0) { |
| | | record.setNum4(new BigDecimal((double) record.getNum2() / (double) record.getNum1() * 100).setScale(2, RoundingMode.HALF_DOWN)); |
| | | } else { |
| | | record.setNum4(new BigDecimal(0)); |
| | | } |
| | | } |
| | | String templateId = record.getTemplateId(); |
| | | Long count = leaveService.lambdaQuery() |
| | | .eq(TLeave::getTemplateId, templateId) |
| | | .eq(TLeave::getLeavePerson, record.getUserId()) |
| | | .eq(TLeave::getAuditStatus, 2).count(); |
| | | record.setNum5(count); |
| | | } |
| | | //1.获取excel模板 |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ProgressListVO.class, records); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("任务进度列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "任务报表") |
| | | @PostMapping(value = "/taskDetails") |
| | |
| | | } |
| | | return R.ok(res); |
| | | } |
| | | @ApiOperation(value = "任务报表导出") |
| | | @PostMapping(value = "/taskDetailsExport") |
| | | public void taskDetailsExport(@RequestBody TaskDetailsQuery query) { |
| | | List<TLocationType> locationTypeList = locationTypeService.list(); |
| | | List<TLocation> locations = locationService.list(); |
| | | LambdaQueryWrapper<TTask> tTaskLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(query.getStartTime()) && StringUtils.hasLength(query.getEndTime())) { |
| | | tTaskLambdaQueryWrapper.ge(TTask::getImplementTime, query.getStartTime()); |
| | | tTaskLambdaQueryWrapper.le(TTask::getImplementTime, query.getEndTime()); |
| | | } |
| | | List<ProjectDeptDetailsVO> res = new ArrayList<>(); |
| | | List<TTask> tasks = taskCleanerService.list(tTaskLambdaQueryWrapper); |
| | | List<TTaskDetail> taskDetails = taskDetailService.lambdaQuery().orderByDesc(BaseModel::getCreateTime).list(); |
| | | List<String> collect = tasks.stream().map(TTask::getProjectId).distinct().collect(Collectors.toList()); |
| | | List<TProjectDept> projectDepts = projectDeptService.list(); |
| | | List<String> strings = new ArrayList<>(); |
| | | |
| | | // 片区ids 反查项目部 |
| | | List<TProjectDept> list1 = projectDeptService.lambdaQuery().in(TProjectDept::getId, collect).list(); |
| | | for (TProjectDept tProjectDept : list1) { |
| | | TProjectDept tProjectDept1 = projectDepts.stream().filter(e -> e.getId().equals(tProjectDept.getParentId())).findFirst().orElse(null); |
| | | if (tProjectDept1 != null && !strings.contains(tProjectDept1.getId())) { |
| | | ProjectDeptDetailsVO projectDeptDetailsVO = new ProjectDeptDetailsVO(); |
| | | projectDeptDetailsVO.setProjectName(tProjectDept1.getProjectName()); |
| | | List<TProjectDept> collect1 = list1.stream().filter(e -> e.getParentId().equals(tProjectDept1.getId())).collect(Collectors.toList()); |
| | | List<ProjectDeptDetailsChildVO> projectDeptDetailsChildVOS = new ArrayList<>(); |
| | | for (TProjectDept projectDept : collect1) { |
| | | ProjectDeptDetailsChildVO projectDeptDetailsChildVO = new ProjectDeptDetailsChildVO(); |
| | | projectDeptDetailsChildVO.setProjectChildName(projectDept.getProjectName()); |
| | | projectDeptDetailsChildVO.setProjectId(projectDept.getId()); |
| | | projectDeptDetailsChildVOS.add(projectDeptDetailsChildVO); |
| | | } |
| | | projectDeptDetailsVO.setProjectChild(projectDeptDetailsChildVOS); |
| | | res.add(projectDeptDetailsVO); |
| | | strings.add(tProjectDept1.getId()); |
| | | } |
| | | } |
| | | List<LocationTypeListByProjectVO> locationTypeListByProjectVOS = new ArrayList<>(); |
| | | for (TLocationType tLocationType : locationTypeList) { |
| | | LocationTypeListByProjectVO locationTypeListByProjectVO = new LocationTypeListByProjectVO(); |
| | | locationTypeListByProjectVO.setLocationTypeName(tLocationType.getLocationName()); |
| | | locationTypeListByProjectVO.setLocationNum(0); |
| | | locationTypeListByProjectVO.setId(tLocationType.getId()); |
| | | locationTypeListByProjectVOS.add(locationTypeListByProjectVO); |
| | | } |
| | | for (ProjectDeptDetailsVO re : res) { |
| | | for (ProjectDeptDetailsChildVO projectDeptDetailsChildVO : re.getProjectChild()) { |
| | | int cleanerCount = cleanerService.lambdaQuery().eq(TCleaner::getProjectId, projectDeptDetailsChildVO.getProjectId()).list().size(); |
| | | projectDeptDetailsChildVO.setCleanerCount(cleanerCount); |
| | | List<LocationTypeListByProjectVO> locationTypeListByProjectVOS1 = new ArrayList<>(); |
| | | for (LocationTypeListByProjectVO locationTypeListByProjectVO : locationTypeListByProjectVOS) { |
| | | LocationTypeListByProjectVO temp = new LocationTypeListByProjectVO(); |
| | | BeanUtils.copyProperties(locationTypeListByProjectVO, temp); |
| | | List<String> locationIds = locations.stream().filter(e -> e.getLocationType().equals(locationTypeListByProjectVO.getId())).map(TLocation::getId).collect(Collectors.toList()); |
| | | if (locationIds.isEmpty()) { |
| | | locationTypeListByProjectVO.setLocationNum(0); |
| | | } else { |
| | | List<TTask> taskList = tasks.stream().filter(e -> e.getProjectId().equals(projectDeptDetailsChildVO.getProjectId()) |
| | | && locationIds.contains(e.getLocationId())).collect(Collectors.toList()); |
| | | Integer count = taskList.size(); |
| | | temp.setLocationNum(count); |
| | | int total = taskList.size(); |
| | | int num1 = 0; |
| | | int num2 = 0; |
| | | int num3 = 0; |
| | | int num4 = 0; |
| | | int num5 = 0; |
| | | int num6 = 0; |
| | | int num7 = 0; |
| | | for (TTask tTask : taskList) { |
| | | TTaskDetail tTaskDetail = taskDetails.stream().filter(e -> e.getTaskId().equals(tTask.getId()) && e.getClearStatus() != null).findFirst().orElse(null); |
| | | if (tTaskDetail!=null){ |
| | | switch (tTaskDetail.getClearStatus()) { |
| | | case 1: |
| | | num1++; |
| | | break; |
| | | case 2: |
| | | num2++; |
| | | break; |
| | | } |
| | | } |
| | | // 任务状态:1未执行、2超时、3待确认、4待整改、5整改完成、6已完成 |
| | | switch (tTask.getStatus()) { |
| | | case 1: |
| | | if (tTaskDetail == null) { |
| | | num3++; |
| | | } |
| | | break; |
| | | case 2: |
| | | num6++; |
| | | break; |
| | | case 3: |
| | | break; |
| | | case 4: |
| | | num4++; |
| | | break; |
| | | case 5: |
| | | num7++; |
| | | break; |
| | | case 6: |
| | | num5++; |
| | | break; |
| | | } |
| | | } |
| | | projectDeptDetailsChildVO.setTotal(total); |
| | | projectDeptDetailsChildVO.setNum1(num1); |
| | | projectDeptDetailsChildVO.setNum2(num2); |
| | | projectDeptDetailsChildVO.setNum3(num3); |
| | | projectDeptDetailsChildVO.setNum4(num4); |
| | | projectDeptDetailsChildVO.setNum5(num5); |
| | | projectDeptDetailsChildVO.setNum6(num6); |
| | | projectDeptDetailsChildVO.setNum7(num7); |
| | | } |
| | | locationTypeListByProjectVOS1.add(temp); |
| | | } |
| | | projectDeptDetailsChildVO.setLocationTypeList(locationTypeListByProjectVOS1); |
| | | projectDeptDetailsChildVO.setCleanerCount(0); |
| | | |
| | | } |
| | | |
| | | } |
| | | //1.获取excel模板 |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), ProjectDeptDetailsVO.class, res); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("任务记录列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "巡检人员报表") |
| | | @PostMapping(value = "/patrolInspectorList") |
| | |
| | | } |
| | | return R.ok(res); |
| | | } |
| | | @ApiOperation(value = "巡检人员报表导出") |
| | | @PostMapping(value = "/patrolInspectorListExport") |
| | | @Log(title = "巡检人员报表导出", businessType = BusinessType.EXPORT) |
| | | public void patrolInspectorListExport(@RequestBody PatrolInspectorQuery query) { |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | LambdaQueryWrapper<TLeave> tLeaveLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(query.getStartTime())){ |
| | | tLeaveLambdaQueryWrapper.ge(TLeave::getCreateTime, query.getStartTime()); |
| | | tLeaveLambdaQueryWrapper.le(TLeave::getCreateTime, query.getEndTime()); |
| | | } |
| | | tLeaveLambdaQueryWrapper.eq(TLeave::getAuditStatus,2); |
| | | List<TLeave> leaves = leaveService.list(tLeaveLambdaQueryWrapper); |
| | | if (StringUtils.hasLength(query.getDeptName())){ |
| | | List<String> projectIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() |
| | | .stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | List<String> deptIds = deptService.lambdaQuery().like(TDept::getDeptName, query.getDeptName()).list() |
| | | .stream().map(TDept::getId).collect(Collectors.toList()); |
| | | projectIds.addAll(deptIds); |
| | | if (projectIds.isEmpty()){ |
| | | projectIds.add("0"); |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | && projectIds.contains(sysUser.getDeptId()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (patrolInspectorIds.isEmpty()){ |
| | | patrolInspectorIds.add(0L); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (!query.getPatrolInspectorIds().isEmpty()){ |
| | | // 取交集 |
| | | patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | if (patrolInspectorIds.isEmpty()){ |
| | | patrolInspectorIds.add(0L); |
| | | } |
| | | } |
| | | List<PatrolInspectorVO> res = new ArrayList<>(); |
| | | LambdaQueryWrapper<TTask> tTaskLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | if (StringUtils.hasLength(query.getStartTime())){ |
| | | tTaskLambdaQueryWrapper.ge(TTask::getCreateTime, query.getStartTime()); |
| | | tTaskLambdaQueryWrapper.le(TTask::getCreateTime, query.getEndTime()); |
| | | } |
| | | if(query.getPatrolInspectorIds()!=null){ |
| | | tTaskLambdaQueryWrapper.in(TTask::getPatrolInspector, query.getPatrolInspectorIds()); |
| | | sysUsers = sysUsers.stream().filter(sysUser -> query.getPatrolInspectorIds().contains(sysUser.getUserId())).collect(Collectors.toList()); |
| | | } |
| | | List<TTask> tasks = taskCleanerService.list(tTaskLambdaQueryWrapper); |
| | | |
| | | for (SysUser sysUser : sysUsers) { |
| | | |
| | | PatrolInspectorVO patrolInspectorVO = new PatrolInspectorVO(); |
| | | |
| | | patrolInspectorVO.setNickName(sysUser.getNickName()); |
| | | patrolInspectorVO.setPhonenumber(sysUser.getPhonenumber()); |
| | | if (sysUser.getDeptType() == 1){ |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if (tProjectDept!=null&&!tProjectDept.getParentId().equals("0")){ |
| | | TProjectDept tProjectDept1 = projectDeptService.getById(tProjectDept.getParentId()); |
| | | if (tProjectDept1!=null) |
| | | patrolInspectorVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | }else{ |
| | | patrolInspectorVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | TDept tDept = deptService.getById(sysUser.getDeptId()); |
| | | if (tDept!=null) |
| | | patrolInspectorVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | // 查询巡检员任务ids |
| | | List<String> taskIds = tasks.stream().filter(e->e.getPatrolInspector().equals(sysUser.getUserId()+"")).map(TTask::getId).collect(Collectors.toList()); |
| | | List<TTaskDetail> list = taskDetailService.lambdaQuery() |
| | | .eq(TTaskDetail::getAuditStatus, 1) |
| | | .isNotNull(TTaskDetail::getClearStatus).orderByDesc(BaseModel::getCreateTime) |
| | | .in(!taskIds.isEmpty(), TTaskDetail::getTaskId,taskIds).groupBy(TTaskDetail::getTaskId).list(); |
| | | // 查询clearStatus为1的数量 |
| | | List<TTaskDetail> clearStatus1 = list.stream().filter(e -> e.getClearStatus().equals(1)).collect(Collectors.toList()); |
| | | List<TTaskDetail> clearStatus2 = list.stream().filter(e -> e.getClearStatus().equals(2)).collect(Collectors.toList()); |
| | | List<TTask> taskList = tasks.stream().filter(e -> e.getPatrolInspector().equals(sysUser.getUserId() + "")).collect(Collectors.toList()); |
| | | patrolInspectorVO.setTotal(taskList.size()); |
| | | patrolInspectorVO.setNum1(clearStatus1.size()); |
| | | patrolInspectorVO.setNum2(clearStatus2.size()); |
| | | patrolInspectorVO.setNum3(clearStatus1.size()+clearStatus2.size()!=0? |
| | | (new BigDecimal(clearStatus1.size()).add(new BigDecimal(clearStatus2.size()))) |
| | | .divide(new BigDecimal(clearStatus1.size()), 2, RoundingMode.HALF_DOWN) |
| | | .multiply(new BigDecimal(100)):BigDecimal.ZERO); |
| | | // 未执行 |
| | | List<TTask> status1 = taskList.stream().filter(e -> e.getStatus() == 1).collect(Collectors.toList()); |
| | | List<TTask> status2 = taskList.stream().filter(e -> e.getStatus() == 3).collect(Collectors.toList()); |
| | | List<TTask> status3 = taskList.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList()); |
| | | List<TTask> status4 = taskList.stream().filter(e -> e.getStatus() == 4).collect(Collectors.toList()); |
| | | List<TTask> status5 = taskList.stream().filter(e -> e.getStatus() == 5).collect(Collectors.toList()); |
| | | List<TTask> status6 = taskList.stream().filter(e -> e.getStatus() == 6).collect(Collectors.toList()); |
| | | patrolInspectorVO.setNum4(status1.size()); |
| | | patrolInspectorVO.setNum5(status2.size()); |
| | | patrolInspectorVO.setNum6(status3.size()); |
| | | patrolInspectorVO.setNum7(status4.size()); |
| | | patrolInspectorVO.setNum8(status5.size()); |
| | | patrolInspectorVO.setNum9(!status5.isEmpty()?new BigDecimal(status5.size()) |
| | | .divide(new BigDecimal(status4.size()).add(new BigDecimal(status5.size())),2,RoundingMode.HALF_DOWN) |
| | | .multiply(new BigDecimal(100)):BigDecimal.ZERO); |
| | | patrolInspectorVO.setNum10(status6.size()); |
| | | patrolInspectorVO.setNum11(!status6.isEmpty()?new BigDecimal(status6.size()).divide(new BigDecimal(taskList.size()),2,RoundingMode.HALF_DOWN):BigDecimal.ZERO); |
| | | List<TLeave> collect1 = leaves.stream().filter(e -> e.getLeavePerson().equals(sysUser.getUserId()+"")).collect(Collectors.toList()); |
| | | patrolInspectorVO.setNum12(collect1.size()); |
| | | res.add(patrolInspectorVO); |
| | | } |
| | | //1.获取excel模板 |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), PatrolInspectorVO.class, res); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("巡检人员列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @ApiOperation(value = "随机督察报表") |
| | | @PostMapping(value = "/inspectorList") |
| | |
| | | } |
| | | return R.ok(res); |
| | | } |
| | | @ApiOperation(value = "随机督察报表导出") |
| | | @PostMapping(value = "/inspectorListExport") |
| | | @Log(title = "随机督察报表导出", businessType = BusinessType.EXPORT) |
| | | public void inspectorListExport(@RequestBody InspectorQuery query) { |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | if (StringUtils.hasLength(query.getDeptName())){ |
| | | List<String> projectIds = projectDeptService.lambdaQuery().like(TProjectDept::getProjectName, query.getDeptName()).list() |
| | | .stream().map(TProjectDept::getId).collect(Collectors.toList()); |
| | | List<String> deptIds = deptService.lambdaQuery().like(TDept::getDeptName, query.getDeptName()).list() |
| | | .stream().map(TDept::getId).collect(Collectors.toList()); |
| | | projectIds.addAll(deptIds); |
| | | if (projectIds.isEmpty()){ |
| | | projectIds.add("-1"); |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | && projectIds.contains(sysUser.getDeptId()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (patrolInspectorIds.isEmpty()){ |
| | | patrolInspectorIds.add(0L); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | } |
| | | } |
| | | if (StringUtils.hasLength(query.getPhonenumber())){ |
| | | List<Long> patrolInspectorIds = sysUsers.stream().filter(sysUser -> |
| | | sysUser.getPhonenumber().equals(query.getPhonenumber()) |
| | | ).map(SysUser::getUserId).collect(Collectors.toList()); |
| | | if (!query.getPatrolInspectorIds().isEmpty()){ |
| | | // 取交集 |
| | | patrolInspectorIds = patrolInspectorIds.stream().filter(query.getPatrolInspectorIds()::contains).collect(Collectors.toList()); |
| | | } |
| | | query.setPatrolInspectorIds(patrolInspectorIds); |
| | | if (patrolInspectorIds.isEmpty()){ |
| | | patrolInspectorIds.add(0L); |
| | | } |
| | | } |
| | | LambdaQueryWrapper<TInspector> tTaskLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | tTaskLambdaQueryWrapper.eq(TInspector::getAuditStatus,1); |
| | | tTaskLambdaQueryWrapper.isNotNull(TInspector::getClearStatus); |
| | | if (StringUtils.hasLength(query.getStartTime())){ |
| | | tTaskLambdaQueryWrapper.ge(TInspector::getCreateTime, query.getStartTime()); |
| | | tTaskLambdaQueryWrapper.le(TInspector::getCreateTime, query.getEndTime()); |
| | | } |
| | | if(query.getPatrolInspectorIds()!=null){ |
| | | tTaskLambdaQueryWrapper.in(TInspector::getCommitPerson, query.getPatrolInspectorIds()); |
| | | sysUsers = sysUsers.stream().filter(sysUser -> query.getPatrolInspectorIds().contains(sysUser.getUserId())).collect(Collectors.toList()); |
| | | } |
| | | List<InspectorVO> res = new ArrayList<>(); |
| | | List<TInspector> inspectors = inspectorService.list(tTaskLambdaQueryWrapper); |
| | | for (SysUser sysUser : sysUsers) { |
| | | InspectorVO inspectorVO = new InspectorVO(); |
| | | inspectorVO.setNickName(sysUser.getNickName()); |
| | | inspectorVO.setPhonenumber(sysUser.getPhonenumber()); |
| | | if (sysUser.getDeptType() == 1){ |
| | | TProjectDept tProjectDept = projectDeptService.getById(sysUser.getDeptId()); |
| | | if (tProjectDept!=null&&!tProjectDept.getParentId().equals("0")){ |
| | | TProjectDept tProjectDept1 = projectDeptService.getById(tProjectDept.getParentId()); |
| | | if (tProjectDept1!=null) |
| | | inspectorVO.setDeptName(tProjectDept1.getProjectName()+">"+tProjectDept.getProjectName()); |
| | | }else{ |
| | | inspectorVO.setDeptName(tProjectDept.getProjectName()); |
| | | } |
| | | }else{ |
| | | TDept tDept = deptService.getById(sysUser.getDeptId()); |
| | | if (tDept!=null) |
| | | inspectorVO.setDeptName(tDept.getDeptName()); |
| | | } |
| | | inspectorVO.setTotal(inspectors.size()); |
| | | List<TInspector> status1 = inspectors.stream().filter(e -> e.getClearStatus() == 1).collect(Collectors.toList()); |
| | | List<TInspector> status2 = inspectors.stream().filter(e -> e.getClearStatus() == 2).collect(Collectors.toList()); |
| | | List<TInspector> status4 = inspectors.stream().filter(e -> e.getStatus() == 1).collect(Collectors.toList()); |
| | | List<TInspector> status5 = inspectors.stream().filter(e -> e.getStatus() == 2).collect(Collectors.toList()); |
| | | List<TInspector> status6 = inspectors.stream().filter(e -> e.getStatus() == 3).collect(Collectors.toList()); |
| | | |
| | | inspectorVO.setNum1(status1.size()); |
| | | inspectorVO.setNum2(status2.size()); |
| | | inspectorVO.setNum3(!status1.isEmpty()?new BigDecimal(status1.size()).divide(new BigDecimal(status2.size()+status1.size()),2,RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)):BigDecimal.ZERO); |
| | | inspectorVO.setNum4(status4.size()); |
| | | inspectorVO.setNum5(status5.size()); |
| | | inspectorVO.setNum6(status6.size()); |
| | | inspectorVO.setNum7(!status6.isEmpty()?new BigDecimal(status6.size()).divide(new BigDecimal(status5.size()+status6.size()),2,RoundingMode.HALF_DOWN).multiply(new BigDecimal(100)):new BigDecimal(0)); |
| | | res.add(inspectorVO); |
| | | } |
| | | //1.获取excel模板 |
| | | Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), InspectorVO.class, res); |
| | | HttpServletResponse response = WebUtils.response(); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | ServletOutputStream outputStream = null; |
| | | try { |
| | | String fileName = URLEncoder.encode("随机督察列表.xls", "utf-8"); |
| | | response.setHeader("Content-dispodition", "attachment;filename=" + fileName); |
| | | outputStream = response.getOutputStream(); |
| | | workbook.write(outputStream); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |