|
@@ -32,11 +32,13 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
-import org.apache.poi.ss.usermodel.CellType;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
|
+import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFCell;
|
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFRow;
|
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFSheet;
|
|
|
|
+import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
|
|
|
+import org.apache.poi.xssf.usermodel.*;
|
|
import org.assertj.core.util.Lists;
|
|
import org.assertj.core.util.Lists;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -12176,4 +12178,249 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
msg.setData(resultMap);
|
|
msg.setData(resultMap);
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg exportUserProjectProcessList(Integer deptId, String userId, Integer projectId) {
|
|
|
|
+ HttpRespMsg httpRespMsg=new HttpRespMsg();
|
|
|
|
+ HttpRespMsg resultMsg = userProjectProcessList(deptId, userId, projectId, null, null);
|
|
|
|
+ Map<String, Object> msgData = (Map<String, Object>) resultMsg.getData();
|
|
|
|
+ List<Map<String, Object>> mapList = (List<Map<String, Object>>) msgData.get("record");
|
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
|
|
|
|
+ Company company = companyMapper.selectById(companyId);
|
|
|
|
+ //1.创建一个workbook,对应一个excel文件
|
|
|
|
+ SXSSFWorkbook workBook = new SXSSFWorkbook();
|
|
|
|
+ //2.在workbook中添加一个sheet,对应Excel中的sheet
|
|
|
|
+ SXSSFSheet sheet = workBook.createSheet("员工项目进度表");
|
|
|
|
+ //设置每一列的列宽
|
|
|
|
+ sheet.setColumnWidth(0,256*15);
|
|
|
|
+ sheet.setColumnWidth(1,256*15);
|
|
|
|
+ //3.设置样式以及字体样式
|
|
|
|
+ //设置冻结
|
|
|
|
+ sheet.createFreezePane(0, 2);
|
|
|
|
+ sheet.setDefaultColumnWidth(16);
|
|
|
|
+ //设置字体样式
|
|
|
|
+ Font headFont = workBook.createFont();
|
|
|
|
+ headFont.setBold(true);
|
|
|
|
+ headFont.setFontHeightInPoints((short) 10);
|
|
|
|
+ headFont.setFontName("黑体");
|
|
|
|
+
|
|
|
|
+ Font titleFont = workBook.createFont();
|
|
|
|
+ titleFont.setBold(true);
|
|
|
|
+ titleFont.setFontHeightInPoints((short) 10);
|
|
|
|
+ titleFont.setFontName("黑体");
|
|
|
|
+
|
|
|
|
+ Font font = workBook.createFont();
|
|
|
|
+ font.setFontHeightInPoints((short) 10);
|
|
|
|
+ font.setFontName("宋体");
|
|
|
|
+
|
|
|
|
+ //设置单元格样式
|
|
|
|
+ XSSFCellStyle headStyle = (XSSFCellStyle) workBook.createCellStyle();
|
|
|
|
+ headStyle.setFont(headFont);
|
|
|
|
+ headStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ headStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
|
+ headStyle.setWrapText(true);
|
|
|
|
+ headStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
|
+ headStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
|
+ headStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
|
+ headStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
|
+
|
|
|
|
+ String color = "c0c0c0"; //此处得到的color为16进制的字符串
|
|
|
|
+ //转为RGB码
|
|
|
|
+ int r = Integer.parseInt((color.substring(0,2)),16); //转为16进制
|
|
|
|
+ int g = Integer.parseInt((color.substring(2,4)),16);
|
|
|
|
+ int b = Integer.parseInt((color.substring(4,6)),16);
|
|
|
|
+
|
|
|
|
+ //设置自定义颜色
|
|
|
|
+ XSSFColor xssfColor = new XSSFColor();
|
|
|
|
+ byte[] colorRgb = { (short)9, (byte) r, (byte) g, (byte) b };
|
|
|
|
+ xssfColor.setRGB(colorRgb);
|
|
|
|
+
|
|
|
|
+ headStyle.setFillForegroundColor(IndexedColors.GREY_25_PERCENT.index);
|
|
|
|
+ headStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);// 填充模式(和背景颜色成对使用)
|
|
|
|
+ /*headStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());*/ //设置自带的颜色
|
|
|
|
+
|
|
|
|
+ CellStyle titleStyle = workBook.createCellStyle();
|
|
|
|
+ titleStyle.setFont(titleFont);
|
|
|
|
+ titleStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ titleStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
|
+ titleStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); //填充单元格
|
|
|
|
+ titleStyle.setFillForegroundColor((short)9); //填色
|
|
|
|
+ titleStyle.setWrapText(true);
|
|
|
|
+ titleStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
|
+ titleStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
|
+ titleStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
|
+ titleStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
|
+
|
|
|
|
+ CellStyle cellStyle = workBook.createCellStyle();
|
|
|
|
+ cellStyle.setFont(font);
|
|
|
|
+ cellStyle.setAlignment(HorizontalAlignment.CENTER);
|
|
|
|
+ cellStyle.setVerticalAlignment(org.apache.poi.ss.usermodel.VerticalAlignment.CENTER);
|
|
|
|
+ cellStyle.setWrapText(true);
|
|
|
|
+ cellStyle.setBorderBottom(BorderStyle.THIN); //下边框
|
|
|
|
+ cellStyle.setBorderLeft(BorderStyle.THIN);//左边框
|
|
|
|
+ cellStyle.setBorderTop(BorderStyle.THIN);//上边框
|
|
|
|
+ cellStyle.setBorderRight(BorderStyle.THIN);//右边框
|
|
|
|
+ //行号
|
|
|
|
+ int rowNum = 0;
|
|
|
|
+ //第一行
|
|
|
|
+ SXSSFRow row0 = sheet.createRow(rowNum++);
|
|
|
|
+ row0.setHeight((short)500);
|
|
|
|
+ List<String> row_first =new ArrayList<>();
|
|
|
|
+ row_first.add("部门");
|
|
|
|
+ row_first.add("员工");
|
|
|
|
+ row_first.add("项目");
|
|
|
|
+ row_first.add("");
|
|
|
|
+ row_first.add("");
|
|
|
|
+ for (int i = 0; i < row_first.size(); i++) {
|
|
|
|
+ SXSSFCell tempCell = row0.createCell(i);
|
|
|
|
+ tempCell.setCellValue(row_first.get(i));
|
|
|
|
+ tempCell.setCellStyle(headStyle);
|
|
|
|
+ }
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,0,2,4));
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,0,0));
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(0,1,1,1));
|
|
|
|
+ //第二行
|
|
|
|
+ SXSSFRow row1 = sheet.createRow(rowNum++);
|
|
|
|
+ row1.setHeight((short)500);
|
|
|
|
+ List<String> row_second =new ArrayList<>();
|
|
|
|
+ row_second.add("");
|
|
|
|
+ row_second.add("");
|
|
|
|
+ row_second.add("项目名称");
|
|
|
|
+ row_second.add("项目编号");
|
|
|
|
+ row_second.add("剩余工时");
|
|
|
|
+ for (int i = 0; i < row_second.size(); i++) {
|
|
|
|
+ SXSSFCell tempCell = row1.createCell(i);
|
|
|
|
+ tempCell.setCellValue(row_second.get(i));
|
|
|
|
+ tempCell.setCellStyle(headStyle);
|
|
|
|
+ }
|
|
|
|
+ List<String> list=new ArrayList<>();
|
|
|
|
+ Map<String, List<Map<String, Object>>> listMapGroupList = mapList.stream().collect(Collectors.groupingBy(m -> String.valueOf(m.get("departmentName"))));
|
|
|
|
+ List<String> departmentNameList = mapList.stream().map(m -> String.valueOf(m.get("departmentName"))).distinct().collect(Collectors.toList());
|
|
|
|
+ //根据每个部门下数据长度合并部门名称列
|
|
|
|
+ int deptIndex=rowNum;
|
|
|
|
+ for (String deptName : departmentNameList) {
|
|
|
|
+ List<Map<String, Object>> maps = listMapGroupList.get(deptName);
|
|
|
|
+ //再根据每个部门下员工数据长度合并人员名称列
|
|
|
|
+ Map<String, List<Map<String, Object>>> listMapGroupList2 = maps.stream().collect(Collectors.groupingBy(m -> String.valueOf(m.get("jobNumber"))));
|
|
|
|
+ List<String> userNameList = maps.stream().map(m -> String.valueOf(m.get("jobNumber"))).distinct().collect(Collectors.toList());
|
|
|
|
+ if(maps.size()>1){
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(deptIndex,deptIndex+maps.size()-1,0,0));
|
|
|
|
+ int userIndex=deptIndex;
|
|
|
|
+ for (String userName : userNameList) {
|
|
|
|
+ List<Map<String, Object>> mapList1 = listMapGroupList2.get(userName);
|
|
|
|
+ if(mapList1.size()>1){
|
|
|
|
+ sheet.addMergedRegion(new CellRangeAddress(userIndex,userIndex+mapList1.size()-1,1,1));
|
|
|
|
+ }
|
|
|
|
+ userIndex+=mapList1.size();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ deptIndex+=maps.size();
|
|
|
|
+ for (int i = 0; i < maps.size(); i++) {
|
|
|
|
+ list.add("$departmentName="+String.valueOf(maps.get(i).get("corpwxDeptId"))+"$");
|
|
|
|
+ list.add("$userName="+maps.get(i).get("corpwxUserId")+"$");
|
|
|
|
+ list.add(String.valueOf(maps.get(i).get("projectName")));
|
|
|
|
+ list.add(String.valueOf(maps.get(i).get("projectCode")));
|
|
|
|
+ list.add(String.valueOf(maps.get(i).get("residueTime")));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ int k=0;
|
|
|
|
+ for(int i = 0;i<mapList.size();i++){
|
|
|
|
+ SXSSFRow tempRow = sheet.createRow(rowNum++);
|
|
|
|
+ tempRow.setHeight((short)500);
|
|
|
|
+ for(int j=0;j<5;j++){
|
|
|
|
+ SXSSFCell tempCell = tempRow.createCell(j);
|
|
|
|
+ String cellValue = "";
|
|
|
|
+ tempCell.setCellStyle(cellStyle);
|
|
|
|
+ if(k>=list.size()){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ cellValue=list.get(k);
|
|
|
|
+ tempCell.setCellValue(cellValue);
|
|
|
|
+ k++;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //导出excel
|
|
|
|
+ String result="系统提示:Excel文件导出成功!";
|
|
|
|
+ String title= "员工项目进度表_"+company.getCompanyName()+System.currentTimeMillis();
|
|
|
|
+ String fileName= title+".xlsx";
|
|
|
|
+ try {
|
|
|
|
+ File dir = null;
|
|
|
|
+ dir = new File(path);
|
|
|
|
+ if (!dir.exists()) {
|
|
|
|
+ dir.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ FileOutputStream os = new FileOutputStream(path+fileName);//保存到本地
|
|
|
|
+ workBook.write(os);
|
|
|
|
+ os.flush();
|
|
|
|
+ os.close();
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ return excelExportService.exportTranForwx(wxCorpInfo, title);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ httpRespMsg.data ="/upload/"+fileName;
|
|
|
|
+ return httpRespMsg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg groupExpendProcessList(String startDate, String endDate, Integer pageIndex, Integer pageSize) {
|
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
|
+ boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "全部分组耗用进度表");
|
|
|
|
+ boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责部门分组耗用进度表");
|
|
|
|
+ List<Department> allDeptList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
|
|
|
|
+ List<Map<String,Object>> resultList;
|
|
|
|
+ Long total;
|
|
|
|
+ Integer size=null;
|
|
|
|
+ Integer start=null;
|
|
|
|
+ if(pageIndex!=null&&pageSize!=null){
|
|
|
|
+ size=pageSize;
|
|
|
|
+ start=(pageIndex-1)*size;
|
|
|
|
+ }
|
|
|
|
+ //是否具有查看全部数据的权限
|
|
|
|
+ if(!viewAll){
|
|
|
|
+ if(!incharger){
|
|
|
|
+ //只能查看本人的数据
|
|
|
|
+ resultList=projectMapper.groupExpendProcessList(user.getId(),companyId,null,start,size);
|
|
|
|
+ total=projectMapper.groupExpendProcessListCount(user.getId(),companyId,null);
|
|
|
|
+ }else {
|
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getManagerId, user.getId()));
|
|
|
|
+ List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
|
|
|
|
+ List<Integer> deptIds=new ArrayList<>();
|
|
|
|
+ List<Integer> theCollect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
|
+ theCollect.add(-1);
|
|
|
|
+ List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
|
+ otherCollect.add(-1);
|
|
|
|
+ theCollect.addAll(otherCollect);
|
|
|
|
+ for (Integer integer : theCollect) {
|
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
|
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
|
+ }
|
|
|
|
+ resultList=projectMapper.groupExpendProcessList(null,companyId,deptIds,start,size);
|
|
|
|
+ total=projectMapper.groupExpendProcessListCount(null,companyId,deptIds);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ resultList=projectMapper.groupExpendProcessList(null,companyId,null,start,size);
|
|
|
|
+ total=projectMapper.groupExpendProcessListCount(null,companyId,null);
|
|
|
|
+ }
|
|
|
|
+ Map<String,Object> resultMap=new HashMap<>();
|
|
|
|
+ resultMap.put("record",resultList);
|
|
|
|
+ resultMap.put("total",total);
|
|
|
|
+ msg.setData(resultMap);
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg exportGroupExpendProcessList(String startDate, String endDate) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
}
|
|
}
|