| | |
| | | |
| | | import cn.afterturn.easypoi.excel.ExcelExportUtil; |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | |
| | | import com.ruoyi.system.model.*; |
| | | import com.ruoyi.system.query.*; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.utils.ExcelPoiUtils; |
| | | import com.ruoyi.system.vo.system.*; |
| | | import com.ruoyi.web.util.OssUploadUtil; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | } |
| | | } |
| | | 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; |
| | | if(Objects.nonNull(tTemplate)){ |
| | | // todo 应生成计划数 |
| | | 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; |
| | | 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()); |
| | | } |
| | | 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)); |
| | | } |
| | | } |
| | | 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() |
| | |
| | | locationTypeListByProjectVOS1.add(temp); |
| | | } |
| | | projectDeptDetailsChildVO.setLocationTypeList(locationTypeListByProjectVOS1); |
| | | projectDeptDetailsChildVO.setCleanerCount(0); |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | @ApiOperation(value = "巡检人员报表") |
| | | @PostMapping(value = "/patrolInspectorList") |
| | | |
| | | public R<List<PatrolInspectorVO>> patrolInspectorList(@RequestBody PatrolInspectorQuery query) { |
| | | List<SysUser> sysUsers = sysUserService.selectAllList(); |
| | | LambdaQueryWrapper<TLeave> tLeaveLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "任务报表导出模板") |
| | | @PostMapping(value = "/exportExcel") |
| | | public void exportExcel(@RequestBody TaskDetailsQuery query,HttpServletResponse response) throws Exception{ |
| | | 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) { |
| | | List<ProjectDeptDetailsChildVO> projectChild = re.getProjectChild(); |
| | | for (ProjectDeptDetailsChildVO projectDeptDetailsChildVO : projectChild) { |
| | | int cleanerCount = cleanerService.lambdaQuery().eq(TCleaner::getProjectId, projectDeptDetailsChildVO.getProjectId()).list().size(); |
| | | projectDeptDetailsChildVO.setCleanerCount(cleanerCount); |
| | | for (LocationTypeListByProjectVO locationTypeListByProjectVO : locationTypeListByProjectVOS) { |
| | | 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(); |
| | | locationTypeListByProjectVO.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); |
| | | } |
| | | } |
| | | projectDeptDetailsChildVO.setLocationTypeList(locationTypeListByProjectVOS); |
| | | } |
| | | } |
| | | |
| | | Set<String> allTypeNames = new LinkedHashSet<>(); |
| | | for (ProjectDeptDetailsVO row : res) { |
| | | for (ProjectDeptDetailsChildVO lt : row.getProjectChild()) { |
| | | for (LocationTypeListByProjectVO locationTypeListByProjectVO : lt.getLocationTypeList()) { |
| | | allTypeNames.add(locationTypeListByProjectVO.getLocationTypeName()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<ExcelExportEntity> entityList = new ArrayList<>(); |
| | | ExcelExportEntity excelExportEntity = new ExcelExportEntity("项目", "projectName", 15); |
| | | excelExportEntity.setMergeVertical(true); |
| | | entityList.add(excelExportEntity); |
| | | entityList.add(new ExcelExportEntity("片区名称", "areaName",15)); |
| | | entityList.add(new ExcelExportEntity("巡检保洁员数", "inspectorCount",15)); |
| | | |
| | | // 动态添加作业类型分类 |
| | | List<String> list = new ArrayList<>(allTypeNames); |
| | | Collections.reverse(list); |
| | | for (String typeName : list) { |
| | | ExcelExportEntity excelExportEntity1 = new ExcelExportEntity(typeName, typeName, 15); |
| | | excelExportEntity1.setGroupName("作业类型分类"); |
| | | entityList.add(excelExportEntity1); |
| | | } |
| | | |
| | | ExcelExportEntity excelExportEntity8 = new ExcelExportEntity("整改完成任务", "total", 15); |
| | | excelExportEntity8.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity8); |
| | | ExcelExportEntity excelExportEntity7 = new ExcelExportEntity("超时未执行任务", "total", 15); |
| | | excelExportEntity7.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity7); |
| | | ExcelExportEntity excelExportEntity6 = new ExcelExportEntity("审核通过任务", "total", 15); |
| | | excelExportEntity6.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity6); |
| | | ExcelExportEntity excelExportEntity5 = new ExcelExportEntity("待整改任务", "total", 15); |
| | | excelExportEntity5.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity5); |
| | | ExcelExportEntity excelExportEntity4 = new ExcelExportEntity("未执行任务", "total", 15); |
| | | excelExportEntity4.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity4); |
| | | ExcelExportEntity excelExportEntity3 = new ExcelExportEntity("清洁不合格", "total", 15); |
| | | excelExportEntity3.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity3); |
| | | ExcelExportEntity excelExportEntity2 = new ExcelExportEntity("清洁合格", "total", 15); |
| | | excelExportEntity2.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity2); |
| | | ExcelExportEntity excelExportEntity1 = new ExcelExportEntity("总数", "total", 15); |
| | | excelExportEntity1.setGroupName("任务情况汇总"); |
| | | entityList.add(excelExportEntity1); |
| | | |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | for (ProjectDeptDetailsVO projectDeptDetailsVO : res) { |
| | | List<ProjectDeptDetailsChildVO> projectChild = projectDeptDetailsVO.getProjectChild(); |
| | | for (ProjectDeptDetailsChildVO row : projectChild) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("projectName", projectDeptDetailsVO.getProjectName()); |
| | | map.put("areaName", row.getProjectChildName()); |
| | | map.put("inspectorCount", row.getCleanerCount()); |
| | | // 动态作业类型 |
| | | for (LocationTypeListByProjectVO lt : row.getLocationTypeList()) { |
| | | map.put(lt.getLocationTypeName(), lt.getLocationNum()); |
| | | } |
| | | // 没有的类型补0 |
| | | for (String typeName : allTypeNames) { |
| | | map.putIfAbsent(typeName, 0); |
| | | } |
| | | map.put("total", row.getTotal()); |
| | | map.put("num1", row.getNum1()); |
| | | map.put("num2", row.getNum2()); |
| | | map.put("num3", row.getNum3()); |
| | | map.put("num4", row.getNum4()); |
| | | map.put("num5", row.getNum5()); |
| | | map.put("num6", row.getNum6()); |
| | | map.put("num7", row.getNum7()); |
| | | mapList.add(map); |
| | | } |
| | | } |
| | | |
| | | ExportParams params = new ExportParams("任务报表", "数据表"); |
| | | Workbook workbook = ExcelExportUtil.exportExcel(params, entityList, mapList); |
| | | |
| | | response.setHeader("content-type", "application/vnd.ms-excel"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("任务情况汇总.xlsx", "UTF-8")); |
| | | workbook.write(response.getOutputStream()); |
| | | workbook.close(); |
| | | |
| | | } |
| | | |
| | | } |
| | | |