| | |
| | | } |
| | | |
| | | @Override |
| | | public void exportUser(HttpServletResponse response) throws IOException { |
| | | public void exportUser(HttpServletResponse response, String taskId) throws IOException { |
| | | // try{ |
| | | Workbook workbook = new XSSFWorkbook(); |
| | | |
| | | // 创建一个新的工作表来存储下拉列表的数据 |
| | | Sheet dataSheet = workbook.createSheet("员工详细信息"); |
| | | |
| | | Query query = new Query(Criteria.where("id").is(taskId)); |
| | | List<TaskMongo> taskMongos = mongoTemplate.find(query, TaskMongo.class); |
| | | // 查询数据 |
| | | List<User> userList = userRepository.findAllByEnabled(true); |
| | | // List<User> userList = userRepository.findAllByEnabled(true); |
| | | List<User> userList = new ArrayList<>(); |
| | | for (int i = 0; i < taskMongos.get(0).getContainUserList().size(); i++) { |
| | | User user = userRepository.getById(taskMongos.get(0).getContainUserList().get(i)); |
| | | userList.add(user); |
| | | } |
| | | |
| | | for (int i = 0; i < userList.size(); i++) { |
| | | User user = userList.get(i); |
| | | Row row = dataSheet.createRow(i); |
| | |
| | | DataValidationConstraint dvConstraintStatus = dvHelper.createFormulaListConstraint("状态详细信息!$A$1:$A$" + statuses.length); |
| | | DataValidationConstraint dvConstraintStatus1 = dvHelper.createFormulaListConstraint("优先度详细信息!$A$1:$A$" + priorities.length); |
| | | CellRangeAddressList addressListUser = new CellRangeAddressList(1, 100, 4, 4); // 所属员工列 |
| | | CellRangeAddressList addressListStatus = new CellRangeAddressList(1, 100, 6, 6); // 任务状态列 |
| | | CellRangeAddressList addressListStatus1 = new CellRangeAddressList(1, 100, 8, 8); // 优先度状态列 |
| | | CellRangeAddressList addressListStatus = new CellRangeAddressList(1, 100, 5, 5); // 任务状态列 |
| | | CellRangeAddressList addressListStatus1 = new CellRangeAddressList(1, 100, 6, 6); // 优先度状态列 |
| | | DataValidation validationUser = dvHelper.createValidation(dvConstraintUser, addressListUser); |
| | | DataValidation validationStatus = dvHelper.createValidation(dvConstraintStatus, addressListStatus); |
| | | DataValidation validationStatus1 = dvHelper.createValidation(dvConstraintStatus1, addressListStatus1); |
| | |
| | | headerRow1.createCell(2).setCellValue("任务结束时间"); |
| | | headerRow1.createCell(3).setCellValue("任务工时"); |
| | | headerRow1.createCell(4).setCellValue("所属员工"); |
| | | headerRow1.createCell(5).setCellValue("所属员工ID"); |
| | | headerRow1.createCell(6).setCellValue("任务状态"); |
| | | headerRow1.createCell(7).setCellValue("任务状态ID"); |
| | | // headerRow1.createCell(8).setCellValue("消耗工时"); |
| | | headerRow1.createCell(8).setCellValue("优先度"); |
| | | headerRow1.createCell(9).setCellValue("优先度ID"); |
| | | // headerRow1.createCell(5).setCellValue("所属员工ID"); |
| | | headerRow1.createCell(5).setCellValue("任务状态"); |
| | | // headerRow1.createCell(7).setCellValue("任务状态ID"); |
| | | headerRow1.createCell(6).setCellValue("优先度"); |
| | | // headerRow1.createCell(9).setCellValue("优先度ID"); |
| | | headerRow1.createCell(7).setCellValue("隔绝列1"); |
| | | headerRow1.createCell(8).setCellValue("隔绝列2"); |
| | | headerRow1.createCell(9).setCellValue("隔绝列3"); |
| | | headerRow1.createCell(10).setCellValue("隔绝列4"); |
| | | headerRow1.createCell(11).setCellValue("隔绝列5"); |
| | | headerRow1.createCell(12).setCellValue("隔绝列6"); |
| | | headerRow1.createCell(13).setCellValue("隔绝列7"); |
| | | headerRow1.createCell(14).setCellValue("隔绝列8"); |
| | | headerRow1.createCell(15).setCellValue("所属员工ID"); |
| | | headerRow1.createCell(16).setCellValue("任务状态ID"); |
| | | headerRow1.createCell(17).setCellValue("优先度ID"); |
| | | |
| | | |
| | | // 使用VLOOKUP函数来显示对应的ID |
| | | for (int i = 1; i <= 100; i++) { |
| | | Row row = mainSheet.createRow(i); |
| | | Cell cellUser = row.createCell(5); |
| | | Cell cellUser = row.createCell(15); |
| | | cellUser.setCellFormula("VLOOKUP(E" + (i + 1) + ", '员工详细信息'!$A$1:$B$" + userList.size() + ", 2, FALSE)"); |
| | | Cell cellStatus = row.createCell(7); |
| | | cellStatus.setCellFormula("VLOOKUP(G" + (i + 1) + ", '状态详细信息'!$A$1:$B$" + statuses.length + ", 2, FALSE)"); |
| | | Cell cellYstatus = row.createCell(9); |
| | | cellYstatus.setCellFormula("VLOOKUP(I" + (i + 1) + ", '优先度详细信息'!$A$1:$B$" + priorities.length + ", 2, FALSE)"); |
| | | Cell cellStatus = row.createCell(16); |
| | | cellStatus.setCellFormula("VLOOKUP(F" + (i + 1) + ", '状态详细信息'!$A$1:$B$" + statuses.length + ", 2, FALSE)"); |
| | | Cell cellYstatus = row.createCell(17); |
| | | cellYstatus.setCellFormula("VLOOKUP(G" + (i + 1) + ", '优先度详细信息'!$A$1:$B$" + priorities.length + ", 2, FALSE)"); |
| | | } |
| | | |
| | | mainSheet.setColumnWidth(5, 0); |
| | | mainSheet.setColumnWidth(7, 0); |
| | | mainSheet.setColumnWidth(8, 0); |
| | | mainSheet.setColumnWidth(9, 0); |
| | | mainSheet.setColumnWidth(10, 0); |
| | | mainSheet.setColumnWidth(11, 0); |
| | | mainSheet.setColumnWidth(12, 0); |
| | | mainSheet.setColumnWidth(13, 0); |
| | | mainSheet.setColumnWidth(14, 0); |
| | | mainSheet.setColumnWidth(15, 0); |
| | | mainSheet.setColumnWidth(16, 0); |
| | | mainSheet.setColumnWidth(17, 0); |
| | | |
| | | // response.setHeader("Content-Disposition", "attachment;filename=测试.xlsx"); |
| | | // response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.mainSheet;charset=utf-8"); |
| | |
| | | criteriaMongo = criteriaMongo.and("taskStatus").in(criteria.getTaskStatus()); |
| | | } |
| | | Query query = new Query(criteriaMongo); |
| | | Long totalCount = mongoTemplate.count(query, TaskUserMongo.class); |
| | | |
| | | //查询是拥有否有子级 |
| | | //查询是否拥有子级 |
| | | Query query1 = new Query(Criteria.where("pid").is(oldId)); |
| | | List<TaskMongo> taskUserMongosList = mongoTemplate.find(query1, TaskMongo.class); |
| | | |
| | |
| | | // Query queryObj = new Query(Criteria.where("id").is(criteria.getTaskId())); |
| | | // List<TaskMongo> queryObjs = mongoTemplate.find(queryObj, TaskMongo.class); |
| | | // 2.0 |
| | | // if (taskUserMongosList.size() <= 0 && queryObjs.get(0).getPid() == null) { |
| | | // if (taskUserMongosLis3t.size() <= 0 && queryObjs.get(0).getPid() == null) { |
| | | // List<TaskUserMongoDto> taskUserMongoDtoList1 = new ArrayList<TaskUserMongoDto>(); |
| | | // query.addCriteria(new Criteria("task._id").is(criteria.getTaskId())); |
| | | // List<TaskUserMongo> taskUserMongoDtoList = mongoTemplate.find(query, TaskUserMongo.class); |
| | |
| | | taskUserMongo.setTaskStatus(resources.getTaskStatus()); |
| | | |
| | | Double coefficientByUserId; |
| | | // if (resources.isOk()) { |
| | | // taskUserMongo.setTaskStatus("task_status_completed"); |
| | | // } else { |
| | | // taskUserMongo.setTaskStatus("task_status_in_hand"); |
| | | // } |
| | | |
| | | if (resources.isOk()) { |
| | | taskUserMongo.setTaskStatus("task_status_completed"); |
| | | } else { |
| | | taskUserMongo.setTaskStatus("task_status_in_hand"); |
| | | taskUserMongo.setTaskStatus("task_status_unrecognized"); |
| | | } |
| | | |
| | | if (resources.getUserId() == null) { |