Min 1 year ago
parent
commit
9cb08444bf

+ 18 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -1451,5 +1451,23 @@ public class ProjectController {
     public HttpRespMsg userProjectProcessList(Integer deptId,String userId,Integer projectId,Integer pageIndex,Integer pageSize){
         return projectService.userProjectProcessList(deptId,userId,projectId,pageIndex,pageSize);
     }
+
+    //依斯倍定制 导出员工项目进度表
+    @RequestMapping("/exportUserProjectProcessList")
+    public HttpRespMsg exportUserProjectProcessList(Integer deptId,String userId,Integer projectId){
+        return projectService.exportUserProjectProcessList(deptId,userId,projectId);
+    }
+
+    //依斯倍定制 分组耗用进度表
+    @RequestMapping("/groupExpendProcessList")
+    public HttpRespMsg groupExpendProcessList(String startDate,String endDate,Integer pageIndex,Integer pageSize){
+        return projectService.groupExpendProcessList(startDate,endDate,pageIndex,pageSize);
+    }
+
+    //依斯倍定制 导出分组耗用进度表
+    @RequestMapping("/exportGroupExpendProcessList")
+    public HttpRespMsg exportGroupExpendProcessList(String startDate,String endDate){
+        return projectService.exportGroupExpendProcessList(startDate,endDate);
+    }
 }
 

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -172,4 +172,8 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map<String, Object>> userProjectProcessList(Integer deptId, String userId, Integer projectId, Integer companyId,@Param("list") List<Integer> deptIds, Integer start, Integer size);
 
     Long userProjectProcessCount(Integer deptId, String userId, Integer projectId, Integer companyId,@Param("list") List<Integer> deptIds);
+
+    List<Map<String, Object>> groupExpendProcessList(String userId, Integer companyId,@Param("list") List<Integer> deptIds, Integer start, Integer size);
+
+    Long groupExpendProcessListCount(String userId, Integer companyId,@Param("list") List<Integer> deptIds);
 }

+ 1 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ExcelExportService.java

@@ -11,6 +11,7 @@ public interface ExcelExportService {
     public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportGeneralExcelByTitleAndList2(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception;
     public HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception;
+    public HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo,String title) throws Exception;
     void testAdd(String jobId);
 
     HttpRespMsg exportGeneralExcelForExpense(WxCorpInfo wxCorpInfo, String fileName, List<List<String>> allList, List<Map> mapList, String path) throws Exception;

+ 6 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java

@@ -274,4 +274,10 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getMembProjectCateRatio(String startDate, String endDate, Integer onlyShowWarning);
 
     HttpRespMsg userProjectProcessList(Integer deptId, String userId, Integer projectId, Integer pageIndex, Integer pageSize);
+
+    HttpRespMsg exportUserProjectProcessList(Integer deptId, String userId, Integer projectId);
+
+    HttpRespMsg groupExpendProcessList(String startDate, String endDate, Integer pageIndex, Integer pageSize);
+
+    HttpRespMsg exportGroupExpendProcessList(String startDate, String endDate);
 }

+ 45 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -267,6 +267,51 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return httpRespMsg;
     }
 
+    public  HttpRespMsg exportTranForwx(WxCorpInfo wxCorpInfo,String title) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        if (title.contains("/")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("/", "@");
+        }
+        if (title.contains("\\")) {
+            //文件名不能含有路径,得替换掉
+            title = title.replace("\\", "@");
+        }
+        String fileUrlSuffix = title + ".xlsx";
+        if(wxCorpInfo != null && wxCorpInfo.getSaasSyncContact() == 1){
+            String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+            String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+            int i = 0;
+            String syncTranslationResult = null;
+            /**
+             * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
+             * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+             */
+            while (i < 10) {
+                Thread.sleep(300);
+                CorpwxJobResult corpwxJobResult = corpwxJobCenter.get(jobId);
+                if (corpwxJobResult != null) {
+                    if (corpwxJobResult.getErrCode() == 0) {
+                        syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        corpwxJobCenter.remove(jobId);
+                    } else {
+                        httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                        return httpRespMsg;
+                    }
+                    break;
+                }
+                i++;
+            }
+            if (syncTranslationResult != null) {
+                httpRespMsg.data = syncTranslationResult;
+            } else {
+                //httpRespMsg.setError("处理超时...");
+                httpRespMsg.setError(MessageUtils.message("request.outTime"));
+            }
+        }
+        return httpRespMsg;
+    }
+
     @Override
     public void testAdd(String jobId) {
         CorpwxJobResult corpwxJobResult = new CorpwxJobResult();

+ 252 - 5
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -32,11 +32,13 @@ import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 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.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -12176,4 +12178,249 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         msg.setData(resultMap);
         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;
+    }
 }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/BeiSenUtils.java

@@ -78,10 +78,10 @@ public class BeiSenUtils {
         requestMap.put("startTime",startTime+"T00:00:00");
         requestMap.put("stopTime",stopTime+"T23:59:59");
         System.out.println("--------headers请求头数据-------"+headers);
-        System.out.println("--------requestMap请求参数-------"+requestMap);
         if(!StringUtils.isEmpty(scrollId)){
             requestMap.put("scrollId",scrollId);
         }
+        System.out.println("--------requestMap请求参数-------"+requestMap);
         HttpEntity<JSONObject> entity = new HttpEntity<>(requestMap, headers);
         ResponseEntity<String> ResponseEntity = restTemplate.postForEntity(url, entity, String.class);
         if (ResponseEntity.getStatusCode() == HttpStatus.OK) {

+ 39 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml

@@ -1836,4 +1836,43 @@
         ) as total
     </select>
 
+    <select id="groupExpendProcessList" resultType="java.util.Map">
+        select d.department_name,tg.name as groupName,IFNULL(SUM(te.plan_hours),0) as planHour,
+        IFNULL(IFNULL((select SUM(working_time) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+            create_date between #{startDate} and #{endDate}
+        </if> ),0)-IFNULL((select SUM(overtime_hours) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        create_date between #{startDate} and #{endDate}
+        </if>),0),0) as normalHour,
+        IFNULL((select SUM(overtime_hours) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        create_date between #{startDate} and #{endDate}
+        </if>),0) as overHour,
+        IFNULL((select SUM(working_time) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        create_date between #{startDate} and #{endDate}
+        </if>),0) as realHour,
+        IFNULL((select SUM(cost) from report where task_id=te.task_id <if test="startDate!=null and endDate!=null">
+        create_date between #{startDate} and #{endDate}
+        </if>),0) as realCost
+        from task_executor te
+        left join  user u on u.id=te.executor_id
+        left join task t on t.id=te.task_id
+        left join task_group tg on tg.id=t.group_id
+        left join department d on d.department_id=u.department_id
+        where u.company_id=#{companyId} and te.project_id is not null and d.department_name in ('4','12','14')
+        and tg.name in ('生产部电气','生产部车间','工程部现场安装施工','工程部配合调试','研发部工艺设计','研发部结构设计','研发部BIM设计','研发部电气设计','研发部工艺调试验收','研发部电气调试验收')
+        <if test="userId!=null and userId!=''">
+            te.executor_id=#{userId}
+        </if>
+        <if test="list!=null and list.size()>0">
+            and d.department_id in
+            <foreach collection="list" open="(" close=")" item="item" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        group by t.group_id
+        order by d.department_id
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>
+    </select>
+
 </mapper>

+ 1 - 1
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -5767,8 +5767,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             //判断是否需要合并
             if(mapList.size()>1){
                 sheet.addMergedRegion(new CellRangeAddress(startIndex,startIndex+mapList.size()-1,0,0));
-                startIndex+=mapList.size();
             }
+            startIndex+=mapList.size();
             for (int j = 0; j < mapList.size(); j++) {
                 if(j==0){
                     list.add(String.valueOf(mapList.get(j).get("productName")));