| | |
| | | taskUserDetail.setRemarks(taskDaliyMongo.getRemarks()); |
| | | } |
| | | taskUserDetail.setTaskUserName(userRepository.findById(taskDaliyMongo.getUserId()).get().getNickName()); |
| | | taskUserDetail.setTitle(userRepository.findById(taskDaliyMongo.getUserId()).get().getNickName() + "提交了任务日报,消耗了" + taskDaliyMongo.getConsumedHours() + "个小时"); |
| | | taskUserDetail.setTitle(userRepository.findById(taskDaliyMongo.getUserId()).get().getNickName() + "提交了任务日报,消耗了" + new BigDecimal(taskDaliyMongo.getConsumedHours()).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue() + "个小时"); |
| | | taskUserDetail.setFillDate(new SimpleDateFormat("yyyy-MM-dd").format(taskDaliyMongo.getFillDate())); |
| | | taskUserDetail.setColor(color); |
| | | taskUserDetail.setAlreadyConsumeHours(entry.getValue().stream().collect(Collectors.summingDouble(TaskDaliyMongo::getConsumedHours))); |
| | |
| | | } |
| | | |
| | | @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"); |
| | | // |
| | | // // 将工作簿写入响应的输出流 |
| | | // workbook.write(response.getOutputStream()); |
| | | // 隐藏工作表 |
| | | workbook.setSheetHidden(workbook.getSheetIndex(dataSheet), true); |
| | | workbook.setSheetHidden(workbook.getSheetIndex(statusSheet), true); |
| | | workbook.setSheetHidden(workbook.getSheetIndex(prioritySheet), true); |
| | | |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("测试.xlsx", "UTF-8")); |
| | | response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("员工任务分配信息导入表.xlsx", "UTF-8")); |
| | | response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"); |
| | | |
| | | // 将工作簿写入响应的输出流 |
| | |
| | | workbook.close(); |
| | | |
| | | workbook.close(); |
| | | // return true; |
| | | // }catch (Exception e) { |
| | | // return false; |
| | | // } |
| | | // try { |
| | | // Workbook workbook = new XSSFWorkbook(); |
| | | // Sheet sheet1 = workbook.createSheet("任务分配信息"); |
| | | // Sheet sheet2 = workbook.createSheet("员工信息"); |
| | | // Sheet sheet3 = workbook.createSheet("任务状态信息"); |
| | | // Sheet sheet4 = workbook.createSheet("优先度信息"); |
| | | // |
| | | // // 在任务分配信息中创建下拉框 |
| | | // XSSFDataValidationHelper dvHelper = new XSSFDataValidationHelper((XSSFSheet) sheet1); |
| | | // DataValidationConstraint dvConstraint = dvHelper.createFormulaListConstraint("员工信息!$B$2:$B$100"); |
| | | // DataValidationConstraint dvConstraint1 = dvHelper.createFormulaListConstraint("任务状态信息!$B$2:$B$100"); |
| | | // DataValidationConstraint dvConstraint2 = dvHelper.createFormulaListConstraint("优先度信息!$B$2:$B$100"); |
| | | // |
| | | // // 下拉 |
| | | // CellRangeAddressList addressList1 = new CellRangeAddressList(1, 100, 4, 4); // 所属用户列 |
| | | // CellRangeAddressList addressList2 = new CellRangeAddressList(1, 100, 5, 5); // 任务状态列 |
| | | // CellRangeAddressList addressList3 = new CellRangeAddressList(1, 100, 7, 7); // 优先度列 |
| | | // DataValidation validation = dvHelper.createValidation(dvConstraint, addressList1); |
| | | // DataValidation validation1 = dvHelper.createValidation(dvConstraint1, addressList2); |
| | | // DataValidation validation2 = dvHelper.createValidation(dvConstraint2, addressList3); |
| | | // |
| | | // // 在任务分配信息中添加字段名 |
| | | // Row headerRow1 = sheet1.createRow(0); |
| | | // headerRow1.createCell(0).setCellValue("名称"); |
| | | // headerRow1.createCell(1).setCellValue("任务开始时间"); |
| | | // headerRow1.createCell(2).setCellValue("任务结束时间"); |
| | | // headerRow1.createCell(3).setCellValue("任务工时"); |
| | | // headerRow1.createCell(4).setCellValue("所属员工"); |
| | | //// headerRow1.createCell(5).setCellValue("绩效工时"); |
| | | //// headerRow1.createCell(5).setCellValue("任务进度"); |
| | | // headerRow1.createCell(5).setCellValue("任务状态"); |
| | | // headerRow1.createCell(6).setCellValue("消耗工时"); |
| | | // headerRow1.createCell(7).setCellValue("优先度"); |
| | | // |
| | | // // 在员工信息中添加数据 |
| | | // Row headerRow2 = sheet2.createRow(0); |
| | | // headerRow2.createCell(0).setCellValue("员工姓名"); |
| | | // headerRow2.createCell(1).setCellValue("员工ID"); |
| | | // |
| | | // // 查询数据 |
| | | // List<User> userList = userRepository.findAllByEnabled(true); |
| | | // for (int i = 0; i < userList.size(); i++) { |
| | | // User user = userList.get(i); |
| | | // // 创建数据行 |
| | | // Row row = sheet2.createRow(i + 1); |
| | | // row.createCell(0).setCellValue(user.getNickName()); |
| | | // row.createCell(1).setCellValue(user.getId()); |
| | | // } |
| | | // |
| | | // // 在任务状态信息中添加数据 |
| | | // Row headerRow3 = sheet3.createRow(0); |
| | | // headerRow3.createCell(0).setCellValue("状态名称"); |
| | | // headerRow3.createCell(1).setCellValue("状态代号"); |
| | | // |
| | | // String[][] statuses = { |
| | | // {"未开始", "task_status_not_started"}, |
| | | // {"进行中", "task_status_in_hand"}, |
| | | // {"待测试", "task_status_test"}, |
| | | // {"已暂停", "task_status_stop"}, |
| | | // {"已完成", "task_status_completed"}, |
| | | // {"未承认", "task_status_unrecognized"} |
| | | // }; |
| | | // |
| | | // for (int i = 0; i < statuses.length; i++) { |
| | | // //创建数据行 |
| | | // Row row = sheet3.createRow(i + 1); |
| | | // row.createCell(0).setCellValue(statuses[i][0]); |
| | | // row.createCell(1).setCellValue(statuses[i][1]); |
| | | // } |
| | | // |
| | | // // 在优先度中添加数据 |
| | | // Row headerRow4 = sheet4.createRow(0); |
| | | // headerRow4.createCell(0).setCellValue("优先度名称"); |
| | | // headerRow4.createCell(1).setCellValue("优先度代号"); |
| | | // |
| | | // String[][] yStatuses = { |
| | | // {"低", "priority_low"}, |
| | | // {"中", "priority_middle"}, |
| | | // {"高", "priority_high"} |
| | | // }; |
| | | // |
| | | // for (int i = 0; i < yStatuses.length; i++) { |
| | | // //创建数据行 |
| | | // Row row = sheet4.createRow(i + 1); |
| | | // row.createCell(0).setCellValue(yStatuses[i][0]); |
| | | // row.createCell(1).setCellValue(yStatuses[i][1]); |
| | | // } |
| | | // |
| | | // sheet1.addValidationData(validation); |
| | | // sheet1.addValidationData(validation1); |
| | | // sheet1.addValidationData(validation2); |
| | | //// FileOutputStream fileOut = new FileOutputStream("D:\\11.13测试.xlsx"); |
| | | //// workbook.write(fileOut); |
| | | //// fileOut.close(); |
| | | //// workbook.close(); |
| | | // |
| | | // return true; |
| | | // } catch (Exception e) { |
| | | // return false; |
| | | // } |
| | | |
| | | } |
| | | |
| | | public void addSubTaskUserList(TaskMongo taskMongo, List<Long> containUserList, List<String> taskIds) { |
| | |
| | | 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) { |