浏览代码

相关人员 部门导出修改

yurk 2 年之前
父节点
当前提交
31fe38ebac

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

@@ -8,6 +8,6 @@ import java.util.List;
 public interface ExcelExportService {
     public void testRead(String jobId);
     public HttpRespMsg exportGeneralExcelByTitleAndList(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;
     void testAdd(String jobId);
 }

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java

@@ -657,7 +657,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                     tempList.add(dataMap);
                 } else {
                     if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                        names.add("$userName="+(String)map.get("corpwxUseid")+"$");
+                        names.add(map.get("corpwxUseid")==null?"":("$userName="+map.get("corpwxUseid")+"$"));
                     }else {
                         names.add((String)map.get("user"));
                     }
@@ -758,6 +758,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                 e.printStackTrace();
             }
         } catch (NullPointerException e) {
+            e.printStackTrace();
             //httpRespMsg.setError("验证失败");
             httpRespMsg.setError(MessageUtils.message("access.verificationError"));
             return httpRespMsg;
@@ -1164,7 +1165,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             for (DepartmentMasterVO departmentMasterVO : costList) {
                 List<String> item=new ArrayList<>();
                 if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                    item.add("$userName="+(departmentMasterVO.getCorpwxDeptid()==null?"":departmentMasterVO.getCorpwxDeptid())+"$");
+                    item.add("$departmentName="+(departmentMasterVO.getCorpwxDeptid()==null?"":departmentMasterVO.getCorpwxDeptid())+"$");
                 }else {
                     item.add(departmentMasterVO.getDepartmentName());
                 }

+ 47 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExcelExportServiceImpl.java

@@ -7,11 +7,18 @@ import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.BorderStyle;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.FillPatternType;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.util.HashMap;
 import java.util.List;
 
@@ -52,8 +59,6 @@ public class ExcelExportServiceImpl implements ExcelExportService {
     }
 
     public HttpRespMsg exportGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo, String title, List<List<String>> list, String downloadPath) throws Exception {
-        String result = "系统提示:Excel文件导出成功!";
-        String fileName = title + ".xls";
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         String resp = ExcelUtil.exportGeneralExcelByTitleAndList(title, list, downloadPath);
         String fileUrlSuffix = title + ".xls";
@@ -92,6 +97,46 @@ public class ExcelExportServiceImpl implements ExcelExportService {
         return httpRespMsg;
     }
 
+
+    public  HttpRespMsg exportMultiSheetGeneralExcelByTitleAndList(WxCorpInfo wxCorpInfo,String title, List<List<String>>[] multiSheetList, String downloadPath,String[] sheetsName) throws Exception {
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(title,multiSheetList, downloadPath,sheetsName);
+        String fileUrlSuffix = title + ".xls";
+        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("处理超时...");
+            }
+        }else {
+            httpRespMsg.data = resp;
+        }
+        return httpRespMsg;
+    }
+
     @Override
     public void testAdd(String jobId) {
         CorpwxJobResult corpwxJobResult = new CorpwxJobResult();

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

@@ -893,7 +893,7 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
                             BigDecimal field2 = userFinance.getCustomField2() == null? new BigDecimal(0):userFinance.getCustomField2().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
                             BigDecimal field3 = userFinance.getCustomField3() == null? new BigDecimal(0):userFinance.getCustomField3().multiply(new BigDecimal(workingTime)).divide(userTime.get(creatorId).workingTime, 4, BigDecimal.ROUND_HALF_UP);
                             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                                membRowData.add(us.getCorpwxUserid()==null?"":us.getCorpwxUserid());
+                                membRowData.add("$userName="+(us.getCorpwxUserid()==null?"":us.getCorpwxUserid())+"$");
                             }else {
                                 membRowData.add(us.getName());
                             }

+ 30 - 12
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -1809,9 +1809,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             data.add(task.get("project_name") == null?"":task.get("project_name").toString());
             data.add(task.get("name") != null?task.get("name").toString():"");
             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                if(task.get("executor_id")!=null){
-                    User us = userList.stream().filter(ul -> ul.getId().equals(task.get("executor_id"))).findFirst().get();
-                    data.add(us.getCorpwxUserid() == null?"":us.getCorpwxUserid());
+                Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(task.get("executor_id"))).findFirst();
+                if(first.isPresent()){
+                    data.add("$userName="+(first.get().getCorpwxUserid() == null?"":first.get().getCorpwxUserid())+"$");
                 }else {
                     data.add("");
                 }
@@ -2702,6 +2702,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         try {
             String token = request.getHeader("TOKEN");
             User user = userMapper.selectById(token);
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
             TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
             List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
             List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
@@ -2765,9 +2766,15 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 rowData.add((String)map.get("projectCode"));
                 rowData.add((String)map.get("projectName"));
                 rowData.add((String)map.get("degreeName"));
-                rowData.add((String)map.get("username"));
-                rowData.add(String.valueOf(StringUtils.isEmpty(map.get("jobNumber"))?"":map.get("jobNumber")));
-                rowData.add((String)map.get("departmentName"));
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    rowData.add("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
+                    rowData.add(String.valueOf(StringUtils.isEmpty(map.get("jobNumber"))?"":map.get("jobNumber")));
+                    rowData.add("$departmentName="+(map.get("corpwxDeptId")==null?"":map.get("corpwxDeptId"))+"$");
+                }else {
+                    rowData.add((String)map.get("username"));
+                    rowData.add(String.valueOf(StringUtils.isEmpty(map.get("jobNumber"))?"":map.get("jobNumber")));
+                    rowData.add((String)map.get("departmentName"));
+                }
                 rowData.add((String)map.get("createDate"));
                 rowData.add(((Double)map.get("workingTime")).toString());
                 rowData.add(((Double)map.get("overtimeHours")).toString());
@@ -2902,7 +2909,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             for (Map<String, Object> map : byMembList) {
                 List<String> rowData = new ArrayList<String>();
                 rowData.add(""+seq);
-                rowData.add((String)map.get("username"));
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    rowData.add("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
+                }else {
+                    rowData.add((String)map.get("username"));
+                }
                 rowData.add(((Double)map.get("workingTime")).toString());
                 rowData.add(((Double)map.get("overtimeHours")).toString());
                 if (hasViewSalary) {
@@ -2933,9 +2944,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             sheetNames[0] = MessageUtils.message("Statistics.OvertimeDet");
             sheetNames[1] = MessageUtils.message("Statistics.ByPro");
             sheetNames[2] = MessageUtils.message("Statistics.ByPeople");
-            String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(fileName , totalList, path, sheetNames);
-
-            httpRespMsg.data = resp;
+            try {
+                return excelExportService.exportMultiSheetGeneralExcelByTitleAndList(wxCorpInfo,fileName , totalList, path, sheetNames);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
         } catch (NullPointerException e) {
             //httpRespMsg.setError("验证失败"+e.getMessage());
             httpRespMsg.setError(MessageUtils.message("access.verificationErrorByParam",e.getMessage()));
@@ -4353,7 +4366,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             LocalDate end = projectVO.getPlanEndDate();
             rowData.add(end==null?"":sdf.format(end));
             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                rowData.add("$userName="+projectVO.getCreatorId()+"$");
+                Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(projectVO.getCreatorId())).findFirst();
+                if(first.isPresent()){
+                    rowData.add("$userName="+(first.get().getCorpwxUserid()==null?"":first.get().getCorpwxUserid())+"$");
+                }else {
+                    rowData.add("");
+                }
             }else {
                 rowData.add(projectVO.getCreatorName());
             }
@@ -4500,7 +4518,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             item.add((String) map.get("groupName")==null?"":(String)map.get("groupName"));
             if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
                 item.add((String) map.get("corpwxUserId")==null?"":("$userName="+(String)map.get("corpwxUserId")+"$"));
-                if(!map.get("participatorsCorp").equals("")){
+                if(map.get("participatorsCorp")!=null&&!map.get("participatorsCorp").equals("")){
                     String participatorsCorp = (String) map.get("participatorsCorp");
                     List<String> asList = Arrays.asList(participatorsCorp.split(","));
                     List<String> thisList=new ArrayList<>();

+ 50 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -183,6 +183,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     private DepartmentOtherManagerMapper departmentOtherManagerMapper;
     @Resource
     private ExcelExportService excelExportService;
+    @Resource
+    private CorpwxJobResultMapper corpwxJobResultMapper;
     @Autowired
     RestTemplate restTemplate;
 
@@ -3503,6 +3505,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             TimeType timeType = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", user.getCompanyId()));
             Company company = companyMapper.selectById(user.getCompanyId());
             Integer companyId = company.getId();
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
             //准备导出
             HSSFWorkbook workbook = new HSSFWorkbook();
@@ -3749,8 +3752,13 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 HSSFRow row = sheet.createRow(rowNum);
                 row.createCell(0).setCellValue(rowNum);
                 row.createCell(1).setCellValue((String) map.get("jobNumber"));
-                row.createCell(2).setCellValue((String) map.get("name"));
-                row.createCell(3).setCellValue((String) map.get("departmentName"));
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    row.createCell(2).setCellValue("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
+                    row.createCell(3).setCellValue("$departmentNmae="+(map.get("corpwxDeptId")==null?"":map.get("corpwxDeptId"))+"$");
+                }else {
+                    row.createCell(2).setCellValue((String) map.get("name"));
+                    row.createCell(3).setCellValue((String) map.get("departmentName"));
+                }
                 row.createCell(4).setCellValue((String) map.get("projectCode"));
                 row.createCell(5).setCellValue((String) map.get("project"));
                 row.createCell(6).setCellValue((String) map.get("categoryName"));
@@ -3884,8 +3892,43 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             workbook.write(fos);
             fos.flush();
             fos.close();
-            //返回生成的文件地址/upload文件夹下
-            httpRespMsg.data = "/upload/" + fileUrlSuffix;
+            if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                String mediaId = wxCorpInfoService.getTranslationMediaId(fileUrlSuffix);
+                String jobId = wxCorpInfoService.syncTranslation(wxCorpInfo.getCorpid(),mediaId,fileUrlSuffix, null);
+            /*if(jobId!=null&&!jobId.equals("")){
+                File file=new File(path + fileUrlSuffix);
+                if(file.exists()){
+                    file.delete();
+                }
+            }*/
+                int i = 0;
+                String syncTranslationResult = null;
+                /**
+                 * 异步上传转译文件的任务完成时会触发回调,在WeiXinCorpController中的commonDevCallbackPost实现了对回调的处理,存储到corpwxJobResult表中
+                 * 此处轮询查询本地数据库,检测到有任务的回调数据时继续执行查询操作
+                 */
+                while (i < 10) {
+                    Thread.sleep(300);
+                    CorpwxJobResult corpwxJobResult = corpwxJobResultMapper.selectById(jobId);
+                    if (corpwxJobResult != null) {
+                        if (corpwxJobResult.getErrCode() == 0) {
+                            syncTranslationResult = wxCorpInfoService.getSyncTranslationResult(jobId);
+                        } else {
+                            httpRespMsg.setError(corpwxJobResult.getErrMsg());
+                            return httpRespMsg;
+                        }
+                        break;
+                    }
+                    i++;
+                }
+                if (syncTranslationResult != null) {
+                    httpRespMsg.data = syncTranslationResult;
+                } else {
+                    httpRespMsg.setError("处理超时...");
+                }
+            }else {
+                httpRespMsg.data = "/upload/" + fileUrlSuffix;
+            }
         } catch (NullPointerException e) {
             //httpRespMsg.setError("验证失败或缺少数据");
             httpRespMsg.setError(MessageUtils.message("access.verErrorOrDataLack"));
@@ -3895,6 +3938,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             //httpRespMsg.setError("文件生成错误");
             httpRespMsg.setError(MessageUtils.message("file.generateError"));
             return httpRespMsg;
+        } catch (Exception e){
+            e.printStackTrace();
+            return httpRespMsg;
         }
         return httpRespMsg;
     }

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

@@ -653,8 +653,8 @@
     <!-- 获取某个员工的某时间段内的加班详情 -->
     <select id="getOvertimeDetail" resultType="java.util.Map">
         SELECT date_format(report.`create_date`, '%Y-%m-%d') AS createDate,
-        report.`creator_id` AS userId, user.`name` AS username,user.job_number as jobNumber, report.`working_time` AS workingTime,
-        IFNULL(report.`overtime_hours`, 0) AS overtimeHours,project.id as projectId,
+        report.`creator_id` AS userId, user.`name` AS username,user.corpwx_userid as corpwxUserId,user.job_number as jobNumber, report.`working_time` AS workingTime,
+        IFNULL(report.`overtime_hours`, 0) AS overtimeHours,project.id as projectId,user.corpwx_deptid as corpwxDeptId,
         project.project_name as projectName,project.project_code as projectCode,
         IFNULL(report.overtime_cost, 0) AS cost,
         IFNULL(report_extra_degree.name,'') as degreeName, department.department_name as departmentName FROM report LEFT JOIN user ON user.id = report.`creator_id`

+ 3 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -57,7 +57,7 @@
 
     <!--根据日期获取全部报告信息-->
     <select id="getAllReportByDate" resultType="java.util.Map">
-        SELECT a.id, c.name,c.job_number as jobNumber,c.corpwx_userid as corpwxUserId, b.project_name AS project,b.project_code as projectCode,b.category_name as categoryName, a.working_time AS duration, a.content, a.create_time   AS time,a.create_date as createDate,
+        SELECT a.id, c.name,c.job_number as jobNumber,c.corpwx_userid as corpwxUserId,c.corpwx_deptid as corpwxDeptId, b.project_name AS project,b.project_code as projectCode,b.category_name as categoryName, a.working_time AS duration, a.content, a.create_time   AS time,a.create_date as createDate,
         a.state, a.time_type as timeType, a.cost, a.report_time_type as reportTimeType,a.start_time as startTime,u.job_number as jobNumber,
         a.end_time  as endTime, d.name as subProjectName,d.code as subProjectCode,a.task_id as taskId, task.name as taskName, a.is_overtime as isOvertime,a.progress as progress,
         a.department_audit_state as departmentAuditState, a.stage, a.pic_str as picStr, multi_worktime as multiWorktime
@@ -132,7 +132,7 @@
     </select>
 
     <select id="getProjectMembReportByDate" resultType="java.util.Map">
-        SELECT a.id, c.name,c.job_number as jobNumber,c.corpwx_userid as corpwxUserId, b.project_name AS project, b.category_name as categoryName,a.working_time AS duration,
+        SELECT a.id, c.name,c.job_number as jobNumber,c.corpwx_userid as corpwxUserId,c.corpwx_deptid as corpwxDeptId, b.project_name AS project, b.category_name as categoryName,a.working_time AS duration,
         a.content, a.create_time AS time, a.create_date as createDate,
         a.state, a.time_type as timeType, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
         a.end_time as endTime, d.name as subProjectName,a.task_id as taskId, task.name as taskName, a.is_overtime as
@@ -185,7 +185,7 @@
     </select>
 
     <select id="getDeptMembReportByDate" resultType="java.util.Map">
-        SELECT a.id, c.name,c.job_number as jobNumber,c.corpwx_userid as corpwxUserId, b.project_name AS project, a.working_time AS duration, a.content, a.create_time AS time,a.create_date as createDate,
+        SELECT a.id, c.name,c.job_number as jobNumber,c.corpwx_userid as corpwxUserId,c.corpwx_deptid as corpwxDeptId, b.project_name AS project, a.working_time AS duration, a.content, a.create_time AS time,a.create_date as createDate,
         a.state, a.time_type as timeType, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
         a.end_time as endTime, d.name as subProjectName,a.task_id as taskId, task.name as taskName, a.is_overtime as isOvertime,a.progress as progress,
         a.department_audit_state as departmentAuditState,a.stage, a.pic_str as picStr, multi_worktime as multiWorktime