Browse Source

TimeType控制字段添加 无考勤无法填报
日报导出修改 企业微信同步
任务模板添加操作日志
八爪鱼TimeType控制字段添加

yurk 2 years ago
parent
commit
a031f200aa

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -10,6 +10,7 @@ import com.management.platform.mapper.*;
 import com.management.platform.service.*;
 import com.management.platform.service.impl.ExcelExportServiceImpl;
 import com.management.platform.service.impl.ReportServiceImpl;
+import com.management.platform.service.impl.TaskServiceImpl;
 import com.management.platform.service.impl.UserServiceImpl;
 import com.management.platform.util.*;
 import com.qq.weixin.mp.aes.AesException;
@@ -419,6 +420,7 @@ public class WeiXinCorpController {
                     ExcelExportServiceImpl.corpwxJobCenter.put(jobId, result);
                     ReportServiceImpl.corpwxJobCenter.put(jobId, result);
                     UserServiceImpl.corpwxJobCenter.put(jobId, result);
+                    TaskServiceImpl.corpwxJobCenter.put(jobId, result);
                 }
             }
         } catch (Exception e) {

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

@@ -478,6 +478,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         try {
             User targetUser = userMapper.selectById(request.getHeader("Token"));
             Integer companyId =targetUser.getCompanyId();
+            List<User> allUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
             Map<String, Object> resultMap = new HashMap<>();
             //当前用户管理部门
             List<Integer> deptIds=null;
@@ -523,9 +524,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             BigDecimal totalCostMoney = new BigDecimal(0);
             List<User> userList = new ArrayList<>();
             for (Map<String, Object> map : list) {
-                if (tempMap.containsKey(map.get("user"))) {
+                if (tempMap.containsKey(map.get("id"))) {
                     //这个名字已经装进数组中了
-                    List<Map<String, Object>> tempList = tempMap.get(map.get("user"));
+                    List<Map<String, Object>> tempList = tempMap.get(map.get("id"));
                     Map<String, Object> dataMap = new HashMap<>();
                     dataMap.put("project", map.get("project"));
                     BigDecimal money = (BigDecimal) map.getOrDefault("money", 0);
@@ -553,14 +554,15 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                         dataMap.put("time", time);
                         tempList.add(dataMap);
                     }
-                    tempMap.put((String) map.get("user"), tempList);
+                    tempMap.put((String) map.get("id"), tempList);
                 }
             }
             Map<String, Object> finalMap = new HashMap<>();
             List<Map<String, Object>> finalList = new ArrayList<>();
             for (String key : tempMap.keySet()) {
                 Map<String, Object> map = new HashMap<>();
-                map.put("name", key);
+                String name = allUserList.stream().filter(ul -> ul.getId().equals(key)).findFirst().get().getName();
+                map.put("name", name);
                 map.put("project", tempMap.get(key));
                 map.put("type","userName");
                 finalList.add(map);
@@ -601,6 +603,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             User targetUser = userMapper.selectById(request.getHeader("Token"));
             Integer companyId =targetUser.getCompanyId();
             WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
+            List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
             //当前用户管理部门
             List<Integer> deptIds=null;
             List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
@@ -644,14 +647,10 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             List<String> names = new ArrayList<>();
             BigDecimal totalCostMoney = new BigDecimal(0);
             for (Map<String, Object> map : list) {
-                if (tempMap.containsKey(((wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1)?("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUseid"))+"$"):map.get("user")))) {
+                if (tempMap.containsKey(map.get("id"))) {
                     //这个名字已经装进数组中了
                     List<Map<String, Object>> tempList;
-                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                         tempList = tempMap.get(("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$"));
-                    }else {
-                         tempList = tempMap.get(map.get("user"));
-                    }
+                    tempList = tempMap.get(map.get("id"));
                     Map<String, Object> dataMap = new HashMap<>();
                     dataMap.put("project", map.get("project"));
                     BigDecimal money = (BigDecimal) map.getOrDefault("money", 0);
@@ -661,11 +660,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                     dataMap.put("time", time);
                     tempList.add(dataMap);
                 } else {
-                    if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
-                        names.add("$userName="+(map.get("corpwxUserId")==null?"":map.get("corpwxUserId"))+"$");
-                    }else {
-                        names.add((String)map.get("user"));
-                    }
+                    names.add((String)map.get("id"));
                     //这个名字尚未装进数组中
                     List<Map<String, Object>> tempList = new ArrayList<>();
                     if (map.containsKey("project")) {
@@ -678,7 +673,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                         dataMap.put("time", time);
                         tempList.add(dataMap);
                     }
-                    tempMap.put((String) map.get("user"), tempList);
+                    tempMap.put((String) map.get("id"), tempList);
                 }
             }
 //            Map<String, Object> finalMap = new HashMap<>();
@@ -702,11 +697,15 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
             double totalCostTime = 0;
             for (String key : names) {
-                Map<String, Object> map = new HashMap<>();
-                map.put("name", key);
-                map.put("project", tempMap.get(key));
                 List<String> nameList = new ArrayList<String>();
-                nameList.add(key);//姓名
+                String name;
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    String corpwxUserId = userList.stream().filter(ul -> ul.getId().equals(key)).findFirst().get().getCorpwxUserid();
+                    name ="$userName="+corpwxUserId==null?"":corpwxUserId+"$";
+                }else {
+                     name = userList.stream().filter(ul -> ul.getId().equals(key)).findFirst().get().getName();
+                }
+                nameList.add(name);//姓名
                 nameList.add("");//空着
                 List<Map<String, Object>> tempList = tempMap.get(key);
                 //统计个人的时间和成本
@@ -746,7 +745,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
             List<String> sumRow = new ArrayList<String>();
             //sumRow.add("合计");
             //sumRow.add("合计");
-            sumRow.add("entry.total");
+            sumRow.add(MessageUtils.message("entry.total"));
+            sumRow.add("");
             if(functionTimeList.size()>0){
                 sumRow.add(""+df.format(totalCostTime));
             }

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

@@ -3756,7 +3756,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 row.createCell(1).setCellValue((String) map.get("jobNumber"));
                 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"))+"$");
+                    row.createCell(3).setCellValue("$departmentName="+(map.get("corpwxDeptId")==null?"":map.get("corpwxDeptId"))+"$");
                 }else {
                     row.createCell(2).setCellValue((String) map.get("name"));
                     row.createCell(3).setCellValue((String) map.get("departmentName"));

+ 64 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/TaskServiceImpl.java

@@ -10,6 +10,7 @@ import com.management.platform.mapper.*;
 import com.management.platform.service.CompanyDingdingService;
 import com.management.platform.service.TaskExecutorService;
 import com.management.platform.service.TaskService;
+import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import org.apache.poi.hssf.usermodel.*;
@@ -43,6 +44,10 @@ import java.util.stream.Collectors;
 @Service
 @Transactional
 public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService {
+
+    //用于控制线程锁
+    public static HashMap<String, CorpwxJobResult> corpwxJobCenter = new HashMap();
+
     @Value(value = "${upload.path}")
     private String path;
     @Resource
@@ -67,6 +72,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
     private ParticipationMapper participationMapper;
     @Resource
     private ReportMapper reportMapper;
+    @Resource
+    private HttpServletRequest request;
+    @Resource
+    private WxCorpInfoService wxCorpInfoService;
 
     @Override
     public HttpRespMsg getExecutorPanel(Integer projectId) {
@@ -207,6 +216,9 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         List<TimeTask> list= taskMapper.getTaskWithWorktime(projectId, taskType);
         Project project = projectMapper.selectById(projectId);
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        WxCorpInfo wxCorpInfo = wxCorpInfoService.getOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
+        List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
         try {
             DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
             //准备导出
@@ -282,7 +294,16 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
                 HSSFRow row = sheet.createRow(rowNum);
                 row.createCell(0).setCellValue(task.getName());
                 row.createCell(1).setCellValue(project.getProjectName());
-                row.createCell(2).setCellValue(task.getExecutorName());
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    Optional<User> first = userList.stream().filter(ul -> ul.getId().equals(task.getExecutorId())).findFirst();
+                    if(first.isPresent()){
+                        row.createCell(2).setCellValue("$userName="+(first.get().getCorpwxUserid()==null?"":first.get().getCorpwxUserid())+"$");
+                    }else {
+                        row.createCell(2).setCellValue("");
+                    }
+                }else {
+                    row.createCell(2).setCellValue(task.getExecutorName());
+                }
                 row.createCell(3).setCellValue(dateTimeFormatter.format(task.getCreateDate()));
                 row.createCell(4).setCellValue(task.getEndDate() != null?dateTimeFormatter.format(task.getEndDate()):"");
                 row.createCell(5).setCellValue(task.getFinishDate() !=null?dateTimeFormatter.format(task.getFinishDate()):"");
@@ -303,8 +324,44 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             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 = 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 = "/upload/" + fileUrlSuffix;
+            }
         } catch (NullPointerException e) {
             e.printStackTrace();
             //httpRespMsg.setError("验证失败或缺少数据");
@@ -315,6 +372,10 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements Ta
             //httpRespMsg.setError("文件生成错误");
             httpRespMsg.setError(MessageUtils.message("file.generateError"));
             return httpRespMsg;
+        }catch (Exception e){
+            e.printStackTrace();
+            httpRespMsg.setError(MessageUtils.message("access.verErrorOrDataLack"));
+            return httpRespMsg;
         }
         return httpRespMsg;
     }

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

@@ -1768,6 +1768,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             User user = userMapper.selectById(userId);
             List<String> strings = ListUtil.convertLongIdsArrayToList(ids);
             List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
             List<User> userList = userMapper.selectList(new QueryWrapper<User>().in("id", strings));
             userList.forEach(u->{
                 Optional<Department> first = deptList.stream().filter(d -> d.getDepartmentId().equals(u.getDepartmentId())).findFirst();
@@ -1810,8 +1811,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             for (User item : userList) {
                 HSSFRow row = sheet.createRow(rowNum);
                 row.createCell(0).setCellValue(rowNum);
-                row.createCell(1).setCellValue(item.getName());
-                row.createCell(2).setCellValue(item.getDepartmentName());
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    row.createCell(1).setCellValue("$userName="+(item.getCorpwxUserid()==null?"":item.getCorpwxUserid())+"$");
+                    row.createCell(2).setCellValue("$departmentName="+(item.getCorpwxDeptid()==null?"":item.getCorpwxDeptid())+"$");
+                }else {
+                    row.createCell(1).setCellValue(item.getName());
+                    row.createCell(2).setCellValue(item.getDepartmentName());
+                }
                 rowNum++;
             }
             //生成Excel文件
@@ -1821,8 +1827,44 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             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 = 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 = "/upload/" + fileUrlSuffix;
+            }
         } catch (NullPointerException e) {
             //httpRespMsg.setError("验证失败或缺少数据");
             httpRespMsg.setError(MessageUtils.message("access.verErrorOrDataLack"));
@@ -1831,6 +1873,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             //httpRespMsg.setError("文件生成错误");
             httpRespMsg.setError(MessageUtils.message("file.generateError"));
             return httpRespMsg;
+        }catch (Exception e){
+            e.printStackTrace();
+            httpRespMsg.setError(MessageUtils.message("access.verErrorOrDataLack"));
+            return httpRespMsg;
         }
         return httpRespMsg;
     }