ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TLocationController.java
@@ -5,6 +5,8 @@ import cn.afterturn.easypoi.excel.ExcelImportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.ImportParams; import cn.hutool.json.JSON; import cn.hutool.json.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.Log; @@ -333,7 +335,7 @@ @PostMapping("/importLocation") public R<String> importLocation(@RequestPart("file") MultipartFile file) { ImportParams params = new ImportParams(); params.setTitleRows(2); // 标题行数 // params.setTitleRows(1); // 标题行数 params.setHeadRows(1); //表头行数 InputStream inputStream = null; // List<CustomerImportFailedData> failedData = new ArrayList<>(); @@ -363,9 +365,11 @@ // 查询所有用户 List<SysUser> users = sysUserService.selectAllList(); // 查询所有部门 List<TDept> deptList = deptService.list(); List<TProjectDept> deptList = projectDeptService.list(); // 查询所有保洁员 List<TCleaner> cleaners = cleanerService.list(); JSONObject result = new JSONObject(); for (TLocationImportExcel locationExcel : locationExcelList) { System.err.println(locationExcel); @@ -377,28 +381,43 @@ location.setLocationType(tLocationType.getId()); } location.setLocationAddress(locationExcel.getLocationAddress()); String[] addressLonLat = locationExcel.getLocationAddressLonLat().split("/"); String[] addressLonLat = locationExcel.getLocationAddressLonLat().split(","); location.setLocationLon(addressLonLat[0]); location.setLocationLat(addressLonLat[1]); location.setLocationAddressEnd(locationExcel.getLocationAddressEnd()); String[] addressEndLonLat = locationExcel.getLocationAddressEndLonLat().split("/"); String[] addressEndLonLat = locationExcel.getLocationAddressEndLonLat().split(","); location.setLocationLonEnd(addressEndLonLat[0]); location.setLocationLatEnd(addressEndLonLat[1]); TDept tDept = deptList.stream().filter(dept -> dept.getCode().equals(locationExcel.getDeptCode())).findFirst().orElse(null); if(Objects.nonNull(tDept)){ location.setProjectId(tDept.getId()); TProjectDept projectDept = deptList.stream().filter(dept -> dept.getCode().equals(locationExcel.getDeptCode())).findFirst().orElse(null); if(Objects.nonNull(projectDept)){ location.setProjectId(projectDept.getId()); }else { result.append("路段名:[", locationExcel.getLocationName()+"]未查询到部门"); continue; } SysUser sysUser = users.stream().filter(user -> user.getNickName().equals(locationExcel.getNickName())).findFirst().orElse(null); if(Objects.nonNull(sysUser)){ location.setLocationLeader(String.valueOf(sysUser.getUserId())); }else { result.append("路段名:[", locationExcel.getLocationName()+"]未查询到点位负责人"); continue; } cleaners.stream().filter(cleaner -> cleaner.getCleanerCode().equals(locationExcel.getCleanerCodeClear()) TCleaner tCleaner = cleaners.stream().filter(cleaner -> cleaner.getCleanerCode().equals(locationExcel.getCleanerCodeClear()) && cleaner.getDeptCode().equals(locationExcel.getDeptCodeClear()) && cleaner.getProjectCode().equals(locationExcel.getProjectCodeClear())).findFirst().orElse(null); location.setLocationCleaner(locationExcel.getProjectCodeClear()); && cleaner.getProjectCode().equals(locationExcel.getProjectCodeClear()) && cleaner.getCleanerName().equals(locationExcel.getCleanerName())).findFirst().orElse(null); if(Objects.nonNull(tCleaner)){ location.setLocationCleaner(tCleaner.getId()); }else { result.append("路段名:[", locationExcel.getLocationName()+"]未查询到保洁员"); continue; } locationService.save(location); } if(!result.isEmpty()){ return R.ok(result.toString()); } return R.ok(); } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/WorkbenchesController.java
@@ -204,6 +204,10 @@ } query.setProjectId(projectIds); } // 巡检员数 Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),deptType); map.put("totalEmployeeNum", totalEmployeeNum); }else { // 公司人员 // 查询自己的任务列表 @@ -218,6 +222,9 @@ query.setProjectId(projectIds); } } // 巡检员数 Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),1); map.put("totalEmployeeNum", totalEmployeeNum+1); } // 查询片区 @@ -283,6 +290,16 @@ list.addAll(taskList); } list = list.stream().distinct().collect(Collectors.toList()); // 巡检员数 if(CollectionUtils.isEmpty(query.getProjectId())){ Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),deptType); Integer totalEmployeeNum1 = sysUserService.selectUserCount(query.getProjectId(),1); map.put("totalEmployeeNum", totalEmployeeNum+totalEmployeeNum1); }else { Integer totalEmployeeNum = sysUserService.selectUserCount(query.getProjectId(),1); map.put("totalEmployeeNum", totalEmployeeNum); } } // 查询任务相关数据 @@ -294,11 +311,11 @@ map.put("waitTaskNum", list.stream().filter(tTask -> tTask.getStatus() == 1).count()); // 总计员工数 Integer totalEmployeeNum = sysUserService.selectUserCount(null,deptType); if (deptType != 1) { totalEmployeeNum = totalEmployeeNum + 1; } map.put("totalEmployeeNum", totalEmployeeNum); // Integer totalEmployeeNum = sysUserService.selectUserCount(null,deptType); // if (deptType != 1) { // totalEmployeeNum = totalEmployeeNum + 1; // } // map.put("totalEmployeeNum", totalEmployeeNum); // 今日请假员工数量 List<TLeave> leaves = leaveService.list(Wrappers.lambdaQuery(TLeave.class) @@ -499,6 +516,22 @@ && task.getStatus() != 3 && task.getStatus() != 4).collect(Collectors.toList()); if(CollectionUtils.isEmpty(tasks)){ taskSituationVO.setPassRate(BigDecimal.ZERO); for (long i = 0; i <= daysBetween; i++) { TaskSituationDayVO taskSituationDayVO = new TaskSituationDayVO(); if(i == 0){ format = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); }else { format = DateUtils.stringToLocalDate(format).plusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); } taskSituationDayVO.setTaskTime(format); // 任务数 taskSituationDayVO.setTaskNum(0); // 完成数 taskSituationDayVO.setCompletedNum(0); taskSituationDayVO.setCompleteRate(BigDecimal.ZERO); taskSituationDayVOList.add(taskSituationDayVO); } taskSituationVO.setTaskSituationDayVO(taskSituationDayVOList); return R.ok(taskSituationVO); } List<String> taskIds = tasks.stream().map(TTask::getId).collect(Collectors.toList()); @@ -541,7 +574,7 @@ if(tTasks.isEmpty()){ taskSituationDayVO.setCompleteRate(BigDecimal.ZERO); }else { taskSituationDayVO.setCompleteRate(new BigDecimal(qualifiedWarnChild).divide(new BigDecimal(tTasks.size()), 2, RoundingMode.HALF_DOWN)); taskSituationDayVO.setCompleteRate(new BigDecimal(qualifiedWarnChild).divide(new BigDecimal(taskSituationDayVO.getCompletedNum()), 2, RoundingMode.HALF_DOWN)); } taskSituationDayVOList.add(taskSituationDayVO); } ruoyi-system/src/main/java/com/ruoyi/system/importExcel/TLocationImportExcel.java
@@ -10,39 +10,39 @@ @ApiModel(value = "点位导入excel") public class TLocationImportExcel implements Serializable { @Excel(name = "项目部编号") @Excel(name = "项目部编号",width = 20) private String deptCode; @Excel(name = "项目部名称") @Excel(name = "项目部名称",width = 20) private String deptName; @Excel(name = "基层管理员部门编号") @Excel(name = "基层管理员部门编号",width = 20) private String deptNumber; @Excel(name = "基层管理员项目部编号") @Excel(name = "基层管理员项目部编号",width = 20) private String projectDeptNumber; @Excel(name = "基层管理员姓名 巡检员") @Excel(name = "基层管理员姓名 巡检员",width = 20) private String nickName; @Excel(name = "保洁员部门编号") private String projectCodeClear; @Excel(name = "保洁员项目部编号") @Excel(name = "保洁员部门编号",width = 20) private String deptCodeClear; @Excel(name = "保洁员片区编号") @Excel(name = "保洁员项目部编号",width = 20) private String projectCodeClear; @Excel(name = "保洁员片区编号",width = 20) private String cleanerCodeClear; @Excel(name = "保洁员(驾驶员)") @Excel(name = "保洁员(驾驶员)",width = 20) private String cleanerName; @Excel(name = "路段总号") @Excel(name = "路段总号",width = 20) private String locationCode; @Excel(name = "个人编号") @Excel(name = "个人编号",width = 20) private String cleanerCode; @Excel(name = "点位类型") @Excel(name = "点位类型",width = 20) private String locationType; @Excel(name = "路段名(村名)") @Excel(name = "路段名(村名)",width = 20) private String locationName; @Excel(name = "起点") @Excel(name = "起点",width = 20) private String locationAddress; @Excel(name = "终点") @Excel(name = "终点",width = 20) private String locationAddressEnd; @Excel(name = "起点(经纬度)") @Excel(name = "起点(经纬度)",width = 20) private String locationAddressLonLat; @Excel(name = "终点(经纬度)") @Excel(name = "终点(经纬度)",width = 20) private String locationAddressEndLonLat; }