Browse Source

项目分组阶段工时表
费用报销推送企业微信消息

yurk 2 years ago
parent
commit
ae4eb36e77
18 changed files with 522 additions and 103 deletions
  1. 12 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java
  2. 12 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java
  3. 2 2
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java
  4. 7 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeType.java
  5. 6 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java
  6. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java
  7. 4 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java
  8. 2 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java
  9. 5 5
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DepartmentServiceImpl.java
  10. 61 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java
  11. 168 39
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  12. 75 2
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  13. 3 3
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/UserServiceImpl.java
  14. 3 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java
  15. 63 47
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java
  16. 76 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  17. 19 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml
  18. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeTypeMapper.xml

+ 12 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -672,7 +672,7 @@ public class ProjectController {
         List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", companyId));
         List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", companyId));
         List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
         List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
         List<ProjectKeyNodesSetting> projectKeyNodesSettings = projectKeyNodesSettingMapper.selectList(new QueryWrapper<ProjectKeyNodesSetting>().eq("company_id", companyId));
         List<ProjectKeyNodesSetting> projectKeyNodesSettings = projectKeyNodesSettingMapper.selectList(new QueryWrapper<ProjectKeyNodesSetting>().eq("company_id", companyId));
-        List<String> collect = providerCategoryList.stream().distinct().map(pc -> pc.getProviderCategoryName()).collect(Collectors.toList());
+        List<String> collect = providerCategoryList.stream().map(pc -> pc.getProviderCategoryName()).distinct().collect(Collectors.toList());
         TimeType timeType = timeTypeMapper.selectById(companyId);
         TimeType timeType = timeTypeMapper.selectById(companyId);
         if(timeType.getMainProjectState()==1){
         if(timeType.getMainProjectState()==1){
             //heads.add("主项目");
             //heads.add("主项目");
@@ -1121,5 +1121,16 @@ public class ProjectController {
         return projectService.exportDeptPartInProjects(month,departmentId,request);
         return projectService.exportDeptPartInProjects(month,departmentId,request);
     }
     }
 
 
+    //项目分组阶段工时表
+    @RequestMapping("/projectGroupAndCategoryWorkTime")
+    public HttpRespMsg projectGroupAndCategoryWorkTime(HttpServletRequest request,String startDate,String endDate,Integer projectId,Integer pageIndex,Integer pageSize){
+        return projectService.projectGroupAndCategoryWorkTime(request,startDate,endDate,projectId,pageIndex,pageSize);
+    }
+
+    @RequestMapping("/exportProjectGroupAndCategoryWorkTime")
+    public HttpRespMsg exportProjectGroupAndCategoryWorkTime(HttpServletRequest request,String startDate,String endDate,Integer projectId){
+        return projectService.exportProjectGroupAndCategoryWorkTime(request,startDate,endDate,projectId);
+    }
+
 }
 }
 
 

+ 12 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -16,11 +16,15 @@ import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import com.management.platform.util.MessageUtils;
 import com.management.platform.util.WorkDayCalculateUtils;
 import com.management.platform.util.WorkDayCalculateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.*;
+import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.client.DefaultResponseErrorHandler;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.text.DecimalFormat;
@@ -29,6 +33,7 @@ import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -1442,10 +1447,16 @@ public class ReportController {
         return reportService.getProcessErrorData();
         return reportService.getProcessErrorData();
     }
     }
 
 
-    //todo 获取成本数据 上传到 第三方
+    //todo 获取人员成本数据 上传到 第三方
     @RequestMapping("/uploadThirdReportData")
     @RequestMapping("/uploadThirdReportData")
     public HttpRespMsg uploadThirdReportData(String yearMonth){
     public HttpRespMsg uploadThirdReportData(String yearMonth){
         return reportService.uploadThirdReportData(yearMonth,request);
         return reportService.uploadThirdReportData(yearMonth,request);
     }
     }
+
+    //todo 获取项目成本数据 上传到 第三方
+    @RequestMapping("/pushReportDataToThird")
+    public HttpRespMsg pushReportDataToThird(String yearMonth){
+        return reportService.pushReportDataToThird(yearMonth,request);
+    }
 }
 }
 
 

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

@@ -844,9 +844,9 @@ public class TaskController {
         HttpRespMsg httpRespMsg=new HttpRespMsg();
         HttpRespMsg httpRespMsg=new HttpRespMsg();
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
         List<Project> projectList = projectService.list(new QueryWrapper<Project>().eq("company_id", companyId));
         List<Project> projectList = projectService.list(new QueryWrapper<Project>().eq("company_id", companyId));
-        List<Integer> collect = projectList.stream().distinct().map(Project::getId).collect(Collectors.toList());
+        List<Integer> collect = projectList.stream().map(Project::getId).distinct().collect(Collectors.toList());
         List<ProjectSeparate> projectSeparateList = projectSeparateMapper.selectList(new QueryWrapper<ProjectSeparate>().in("id", collect));
         List<ProjectSeparate> projectSeparateList = projectSeparateMapper.selectList(new QueryWrapper<ProjectSeparate>().in("id", collect));
-        List<String> nameList = projectSeparateList.stream().distinct().map(ProjectSeparate::getProjectCategorySub).collect(Collectors.toList());
+        List<String> nameList = projectSeparateList.stream().map(ProjectSeparate::getProjectCategorySub).distinct().collect(Collectors.toList());
         httpRespMsg.data=nameList;
         httpRespMsg.data=nameList;
         return httpRespMsg;
         return httpRespMsg;
     }
     }

+ 7 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/TimeType.java

@@ -17,7 +17,7 @@ import lombok.experimental.Accessors;
  * </p>
  * </p>
  *
  *
  * @author Seyason
  * @author Seyason
- * @since 2022-12-06
+ * @since 2022-12-07
  */
  */
 @Data
 @Data
 @EqualsAndHashCode(callSuper = false)
 @EqualsAndHashCode(callSuper = false)
@@ -401,6 +401,12 @@ public class TimeType extends Model<TimeType> {
     @TableField("push_report_data")
     @TableField("push_report_data")
     private Integer pushReportData;
     private Integer pushReportData;
 
 
+    /**
+     * 推送工时数据URL
+     */
+    @TableField("push_report_url")
+    private String pushReportUrl;
+
 
 
     @Override
     @Override
     protected Serializable pkVal() {
     protected Serializable pkVal() {

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

@@ -134,4 +134,10 @@ public interface ProjectMapper extends BaseMapper<Project> {
     long findCountWithEmpMonthHours(Integer companyId, String startDate, String endDate, Integer start, Integer size, String userId, List<Integer> branchDepartment, List<Integer> deptIds);
     long findCountWithEmpMonthHours(Integer companyId, String startDate, String endDate, Integer start, Integer size, String userId, List<Integer> branchDepartment, List<Integer> deptIds);
 
 
     List<Map<String,Object>> selectDeptPartInProjects(Integer size, Integer start, String startDate, String endDate,Integer companyId, List<Integer> branchDepartment, List<Integer> deptIds);
     List<Map<String,Object>> selectDeptPartInProjects(Integer size, Integer start, String startDate, String endDate,Integer companyId, List<Integer> branchDepartment, List<Integer> deptIds);
+
+    List<Map<String, Object>> getProjectGroupAndCategoryList(String startDate, String endDate, Integer projectId, Integer companyId, Integer start, Integer size, List<Integer> inchagerIds);
+
+    List<Map<String, Object>> getProjectGroupAndCategoryData(String startDate, String endDate, Integer projectId, Integer companyId, Integer start, Integer size, List<Integer> inchagerIds);
+
+    long getProjectGroupAndCategoryCount(String startDate, String endDate, Integer projectId, Integer companyId, Integer start, Integer size, List<Integer> inchagerIds);
 }
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -147,4 +147,6 @@ public interface ReportMapper extends BaseMapper<Report> {
     List<Map<String, Object>> getProcessErrorData();
     List<Map<String, Object>> getProcessErrorData();
 
 
     List<Map<String, Object>> getUploadThirdReportData(Integer companyId,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
     List<Map<String, Object>> getUploadThirdReportData(Integer companyId,@Param("startDate") LocalDate startDate, @Param("endDate") LocalDate endDate);
+
+    List<HashMap<String, Object>> geReportByProject(String startDate, Integer companyId, String endDate);
 }
 }

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

@@ -213,4 +213,8 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg exportReportTimelinessRateByQuarter(HttpServletRequest request, String year, Integer quarter);
     HttpRespMsg exportReportTimelinessRateByQuarter(HttpServletRequest request, String year, Integer quarter);
 
 
     HttpRespMsg getGanttDataNew(Integer type, String startDate, String endDate, String userId, Integer projectId, String groupName, Integer taskType, HttpServletRequest request);
     HttpRespMsg getGanttDataNew(Integer type, String startDate, String endDate, String userId, Integer projectId, String groupName, Integer taskType, HttpServletRequest request);
+
+    HttpRespMsg projectGroupAndCategoryWorkTime(HttpServletRequest request, String startDate, String endDate, Integer projectId,Integer pageIndex,Integer pageSize);
+
+    HttpRespMsg exportProjectGroupAndCategoryWorkTime(HttpServletRequest request, String startDate, String endDate, Integer projectId);
 }
 }

+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java

@@ -94,4 +94,6 @@ public interface ReportService extends IService<Report> {
     HttpRespMsg getProcessErrorData();
     HttpRespMsg getProcessErrorData();
 
 
     HttpRespMsg uploadThirdReportData(String yearMonth,HttpServletRequest request);
     HttpRespMsg uploadThirdReportData(String yearMonth,HttpServletRequest request);
+
+    HttpRespMsg pushReportDataToThird(String yearMonth,HttpServletRequest request);
 }
 }

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

@@ -450,7 +450,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                 if(functionDpartList.size()>0){
                 if(functionDpartList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                         List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
                         List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
-                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                         collect.addAll(otherCollect);
                         collect.addAll(otherCollect);
                         deptIds.addAll(collect);
                         deptIds.addAll(collect);
                     }
                     }
@@ -541,8 +541,8 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                 deptIds.add(-1);
                 deptIds.add(-1);
                 if(functionDpartList.size()>0){
                 if(functionDpartList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
-                        List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                         collect.addAll(otherCollect);
                         collect.addAll(otherCollect);
                         for (Integer integer : collect) {
                         for (Integer integer : collect) {
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -665,7 +665,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
                 if(functionDpartList.size()>0){
                 if(functionDpartList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                         List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
                         List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
-                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                         collect.addAll(otherCollect);
                         collect.addAll(otherCollect);
                         deptIds.addAll(collect);
                         deptIds.addAll(collect);
                         //获取子部门
                         //获取子部门
@@ -1006,7 +1006,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         List<Department> allMDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", curUser.getId()));
         List<Department> allMDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", curUser.getId()));
         //其他负责的部门
         //其他负责的部门
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", curUser.getId()));
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", curUser.getId()));
-        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
         for (Integer integer : otherCollect) {
         for (Integer integer : otherCollect) {
             Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
             Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
             if(first.isPresent()){
             if(first.isPresent()){

+ 61 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ExpenseSheetServiceImpl.java

@@ -4,13 +4,16 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.management.platform.constant.Constant;
 import com.management.platform.entity.*;
 import com.management.platform.entity.*;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.entity.vo.SysRichFunction;
 import com.management.platform.mapper.*;
 import com.management.platform.mapper.*;
 import com.management.platform.service.ExpenseItemService;
 import com.management.platform.service.ExpenseItemService;
 import com.management.platform.service.ExpenseSheetService;
 import com.management.platform.service.ExpenseSheetService;
+import com.management.platform.service.WxCorpInfoService;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import com.management.platform.util.MessageUtils;
@@ -65,6 +68,13 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
     private ExpenseTypeMapper expenseTypeMapper;
     private ExpenseTypeMapper expenseTypeMapper;
     @Resource
     @Resource
     private WxCorpInfoMapper wxCorpInfoMapper;
     private WxCorpInfoMapper wxCorpInfoMapper;
+    @Resource
+    private SysRoleMapper sysRoleMapper;
+    @Resource
+    private WxCorpInfoService wxCorpInfoService;
+    @Resource
+    private SysRoleFunctionMapper sysRoleFunctionMapper;
+    public static final String[] sheetTypes = {"一般费用","差旅费","外包费用"};
     @Override
     @Override
     public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
     public HttpRespMsg add(ExpenseSheet sheet, String items, String userId) {
         HttpRespMsg msg = new HttpRespMsg();
         HttpRespMsg msg = new HttpRespMsg();
@@ -92,6 +102,57 @@ public class ExpenseSheetServiceImpl extends ServiceImpl<ExpenseSheetMapper, Exp
         sheet.setCompanyId(user.getCompanyId());
         sheet.setCompanyId(user.getCompanyId());
         if (isNew) {
         if (isNew) {
             expenseSheetMapper.insert(sheet);
             expenseSheetMapper.insert(sheet);
+            WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+            if(wxCorpInfo!=null){
+                //获取具有费用报销审核权限的人员
+                SysFunction sysFunction = sysFunctionMapper.selectOne(new QueryWrapper<SysFunction>().eq("name", "费用审核"));
+                List<SysRoleFunction> sysRoleFunctions = sysRoleFunctionMapper.selectList(new QueryWrapper<SysRoleFunction>().eq("function_id", sysFunction.getId()));
+                List<Integer> roleIds = sysRoleFunctions.stream().map(sf -> sf.getRoleId()).distinct().collect(Collectors.toList());
+                List<Integer> targetRoleIds = sysRoleMapper.selectList(new QueryWrapper<SysRole>().eq("company_id", user.getCompanyId()).in("id", roleIds))
+                        .stream().map(sl -> sl.getId()).distinct().collect(Collectors.toList());
+                List<User> targetUserList = userMapper.selectList(new QueryWrapper<User>().in("role_id", targetRoleIds));
+                StringBuffer sb = new StringBuffer();
+                if(CollectionUtils.isNotEmpty(targetUserList)) {
+                    for (int i = 0; i < targetUserList.size(); i++) {
+                        if(targetUserList.get(i).getCorpwxUserid()==null){
+                            continue;
+                        }
+                        if (i == 0) {
+                            sb.append(targetUserList.get(i).getCorpwxUserid());
+                        } else {
+                            sb.append("|").append(targetUserList.get(i).getCorpwxUserid());
+                        }
+                    }
+                }
+                User targetUser = userMapper.selectById(sheet.getOwnerId());
+                //推送到企业微信
+                JSONObject json=new JSONObject();
+                JSONArray dataJson=new JSONArray();
+                JSONObject jsonObj=new JSONObject();
+                jsonObj.put("key", "报销人");
+                jsonObj.put("value",("$userName="+targetUser.getCorpwxUserid()+"$"));
+                JSONObject jsonObj1=new JSONObject();
+                jsonObj1.put("key", "填报日期");
+                jsonObj1.put("value",sheet.getCreateDate());
+                JSONObject jsonObj2=new JSONObject();
+                jsonObj2.put("key", "票据类型");
+                jsonObj2.put("value",sheetTypes[sheet.getType()]);
+                JSONObject jsonObj3=new JSONObject();
+                jsonObj3.put("key", "金额");
+                jsonObj3.put("value",sheet.getTotalAmount());
+                JSONObject jsonObj4=new JSONObject();
+                jsonObj4.put("key", "备注");
+                jsonObj4.put("value",sheet.getRemark()==null?"":sheet.getRemark());
+                dataJson.add(jsonObj);
+                dataJson.add(jsonObj1);
+                dataJson.add(jsonObj2);
+                dataJson.add(jsonObj3);
+                dataJson.add(jsonObj4);
+                json.put("template_id","tty9TkCAAALUiWvjdoDg_PZf48gwucZA");
+                json.put("url","https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww4e237fd6abb635af&redirect_uri=http://worktime.ttkuaiban.com/api/corpWXAuth&response_type=code&scope=snsapi_base&state=expense#wechat_redirect");
+                json.put("content_item",dataJson);
+                wxCorpInfoService.sendWXCorpTemplateMsg(wxCorpInfo,sb.toString(), json);
+            }
         } else {
         } else {
             expenseSheetMapper.updateById(sheet);
             expenseSheetMapper.updateById(sheet);
         }
         }

+ 168 - 39
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -248,8 +248,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id", companyId));
             List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id", companyId));
             List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
             List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
             List<Integer> deptIds=new ArrayList<>();
             List<Integer> deptIds=new ArrayList<>();
-            List<Integer> theCollect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-            List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+            List<Integer> theCollect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+            List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
             theCollect.addAll(otherCollect);
             theCollect.addAll(otherCollect);
             for (Integer integer : theCollect) {
             for (Integer integer : theCollect) {
                 List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                 List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -341,7 +341,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<ProjectMain> projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
             List<ProjectMain> projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
             List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
             List<ProjectLevel> projectLevelList = projectLevelMapper.selectList(new QueryWrapper<ProjectLevel>().eq("company_id", companyId));
             TimeType timeType = timeTypeMapper.selectById(companyId);
             TimeType timeType = timeTypeMapper.selectById(companyId);
-            List<Integer> projectIds = projectList.stream().distinct().map(pl -> pl.getId()).collect(Collectors.toList());
+            List<Integer> projectIds = projectList.stream().map(pl -> pl.getId()).distinct().collect(Collectors.toList());
             List<ProjectSeparate> projectSeparateList=new ArrayList<>();
             List<ProjectSeparate> projectSeparateList=new ArrayList<>();
             if(companyId==936){
             if(companyId==936){
                 if (projectIds.size() > 0) {
                 if (projectIds.size() > 0) {
@@ -445,7 +445,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 }
                 }
                 list.add(projectVO);
                 list.add(projectVO);
             }
             }
-            List<String> stringList = providerCategoryList.stream().distinct().map(ProviderCategory::getProviderCategoryName).collect(Collectors.toList());
+            List<String> stringList = providerCategoryList.stream().map(ProviderCategory::getProviderCategoryName).distinct().collect(Collectors.toList());
             //stringList.add("未分类");
             //stringList.add("未分类");
             stringList.add(MessageUtils.message("excel.unclassified"));
             stringList.add(MessageUtils.message("excel.unclassified"));
             Long total = projectIPage.getTotal();
             Long total = projectIPage.getTotal();
@@ -1059,8 +1059,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
 
                 //获取负责的部门的相关的项目,对于这些项目是有查看全部参与人的权限的
                 //获取负责的部门的相关的项目,对于这些项目是有查看全部参与人的权限的
                 List<Integer> allMyManagedDeptIds = new ArrayList<>();
                 List<Integer> allMyManagedDeptIds = new ArrayList<>();
-                List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -1146,8 +1146,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 deptIds.add(-1);
                 deptIds.add(-1);
                 //获取负责的部门的相关的项目,对于这些项目是有查看全部参与人的权限的
                 //获取负责的部门的相关的项目,对于这些项目是有查看全部参与人的权限的
                 List<Integer> allMyManagedDeptIds = new ArrayList<>();
                 List<Integer> allMyManagedDeptIds = new ArrayList<>();
-                List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -1649,7 +1649,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                                 deptIds.addAll(branchDepartment);
                                 deptIds.addAll(branchDepartment);
                             }
                             }
                             List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
                             List<Integer> collect = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
-                            List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                            List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                             collect.addAll(otherCollect);
                             collect.addAll(otherCollect);
                             for (Integer integer : collect) {
                             for (Integer integer : collect) {
                                 List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                                 List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -2774,8 +2774,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
                 deptIds=new ArrayList<>();
                 deptIds=new ArrayList<>();
                 deptIds.add(-1);
                 deptIds.add(-1);
-                List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -2836,8 +2836,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 if(functionDeptList.size()>0){
                 if(functionDeptList.size()>0){
                     deptIds=new ArrayList<>();
                     deptIds=new ArrayList<>();
                     deptIds.add(-1);
                     deptIds.add(-1);
-                    List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                    List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                    List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                    List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                     collect.addAll(otherCollect);
                     collect.addAll(otherCollect);
                     for (Integer integer : collect) {
                     for (Integer integer : collect) {
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -4488,8 +4488,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDpartList.size()>0){
             if(functionDpartList.size()>0){
                 if(functionTimeList.size()>0||functionCostList.size()>0){
                 if(functionTimeList.size()>0||functionCostList.size()>0){
-                    List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                    List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                    List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                    List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                     collect.addAll(otherCollect);
                     collect.addAll(otherCollect);
                     for (Integer integer : collect) {
                     for (Integer integer : collect) {
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -4647,7 +4647,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         DecimalFormat df = new DecimalFormat("##0.0#");
         DecimalFormat df = new DecimalFormat("##0.0#");
         df.setRoundingMode(RoundingMode.HALF_UP);
         df.setRoundingMode(RoundingMode.HALF_UP);
         //获取项目子表 数据
         //获取项目子表 数据
-        List<Integer> collect = projectVOList.stream().distinct().map(pv -> pv.getId()).collect(Collectors.toList());
+        List<Integer> collect = projectVOList.stream().map(pv -> pv.getId()).distinct().collect(Collectors.toList());
         //防止空数据
         //防止空数据
         collect.add(-1);
         collect.add(-1);
         List<ProjectSeparate> projectSeparateList= projectSeparateMapper.selectList(new QueryWrapper<ProjectSeparate>().in("id", collect));
         List<ProjectSeparate> projectSeparateList= projectSeparateMapper.selectList(new QueryWrapper<ProjectSeparate>().in("id", collect));
@@ -5108,8 +5108,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds=new ArrayList<>();
             deptIds=new ArrayList<>();
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
-                List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -5535,8 +5535,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 deptIds.add(-1);
                 deptIds.add(-1);
                 if(functionDpartList.size()>0){
                 if(functionDpartList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
-                        List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                         collect.addAll(otherCollect);
                         collect.addAll(otherCollect);
                         for (Integer integer : collect) {
                         for (Integer integer : collect) {
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -5606,7 +5606,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 if(functionDpartList.size()>0){
                 if(functionDpartList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                         List<Integer> collect  = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
                         List<Integer> collect  = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
-                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                         collect.addAll(otherCollect);
                         collect.addAll(otherCollect);
                         for (Integer integer : collect) {
                         for (Integer integer : collect) {
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -5833,8 +5833,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds=new ArrayList<>();
             deptIds=new ArrayList<>();
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
-                List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -6034,6 +6034,27 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         HttpRespMsg userWorkingTimeList = getUserWorkingTimeList(userId,projectId,startDate, endDate, null,null,request,departmentId);
         HttpRespMsg userWorkingTimeList = getUserWorkingTimeList(userId,projectId,startDate, endDate, null,null,request,departmentId);
         HashMap result = (HashMap) userWorkingTimeList.data;
         HashMap result = (HashMap) userWorkingTimeList.data;
         List<Map<String, Object>> resultList = (List<Map<String, Object>>) result.get("result");
         List<Map<String, Object>> resultList = (List<Map<String, Object>>) result.get("result");
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司工时分配");
+        List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门工时分配");
+        List<Integer> deptIds=null;
+        List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
+        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
+        List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
+        //判断查看权限
+        if(functionAllList.size()==0){
+            deptIds=new ArrayList<>();
+            deptIds.add(-1);
+            if(functionDeptList.size()>0){
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
+                collect.addAll(otherCollect);
+                for (Integer integer : collect) {
+                    List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
+                    deptIds.addAll(branchDepartment);
+                }
+            }
+        }
+        List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,null,deptIds);
         //String[] string={"人员","部门","工号","普通项目工时","公共项目工时","请假时长","总工时","公共项目工时占比"};
         //String[] string={"人员","部门","工号","普通项目工时","公共项目工时","请假时长","总工时","公共项目工时占比"};
         String[] string={MessageUtils.message("entry.personnel"),MessageUtils.message("excel.department"),MessageUtils.message("entry.No"),MessageUtils.message("entry.GenProHours"),MessageUtils.message("entry.PubProHours"),MessageUtils.message("leave.duration"),MessageUtils.message("entry.totalManHours"),MessageUtils.message("entry.PubProHoursProp")};
         String[] string={MessageUtils.message("entry.personnel"),MessageUtils.message("excel.department"),MessageUtils.message("entry.No"),MessageUtils.message("entry.GenProHours"),MessageUtils.message("entry.PubProHours"),MessageUtils.message("leave.duration"),MessageUtils.message("entry.totalManHours"),MessageUtils.message("entry.PubProHoursProp")};
         List<List<String>> dataList=new ArrayList<>();
         List<List<String>> dataList=new ArrayList<>();
@@ -6100,8 +6121,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds=new ArrayList<>();
             deptIds=new ArrayList<>();
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
-                List<Integer> collect = userDepartmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = userDepartmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -6400,8 +6421,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<DepartmentOtherManager> otherManagers = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
         List<DepartmentOtherManager> otherManagers = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
         //获取全部子部门
         //获取全部子部门
         List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
         List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
-        List<Integer> collect = departmentList.stream().distinct().map(Department::getDepartmentId).collect(Collectors.toList());
-        List<Integer> collect1 = otherManagers.stream().distinct().map(DepartmentOtherManager::getDepartmentId).collect(Collectors.toList());
+        List<Integer> collect = departmentList.stream().map(Department::getDepartmentId).distinct().collect(Collectors.toList());
+        List<Integer> collect1 = otherManagers.stream().map(DepartmentOtherManager::getDepartmentId).distinct().collect(Collectors.toList());
         List<Integer> deptIds=new ArrayList<>();
         List<Integer> deptIds=new ArrayList<>();
         for (Integer dpId : collect) {
         for (Integer dpId : collect) {
             List<Integer> ids = departmentService.getDeptIncludeSubDeptIds(dpId, allDeptList);
             List<Integer> ids = departmentService.getDeptIncludeSubDeptIds(dpId, allDeptList);
@@ -6535,8 +6556,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds=new ArrayList<>();
             deptIds=new ArrayList<>();
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
-                List<Integer> collect = userDepartmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = userDepartmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                     List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -6694,8 +6715,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 deptIds.add(-1);
                 deptIds.add(-1);
                 if(functionDpartList.size()>0){
                 if(functionDpartList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
                     if(functionTimeList.size()>0||functionCostList.size()>0){
-                        List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                        List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                         collect.addAll(otherCollect);
                         collect.addAll(otherCollect);
                         for (Integer integer : collect) {
                         for (Integer integer : collect) {
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                             List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -7009,13 +7030,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     queryWrapper.eq("company_id",user.getCompanyId()));
                     queryWrapper.eq("company_id",user.getCompanyId()));
         }
         }
         List<Project> targetProjectList = projectIPage.getRecords();
         List<Project> targetProjectList = projectIPage.getRecords();
-        List<Integer> collect = targetProjectList.stream().distinct().map(Project::getId).collect(Collectors.toList());
+        List<Integer> collect = targetProjectList.stream().map(Project::getId).distinct().collect(Collectors.toList());
         List<ProjectBasecost> projectBasecostList=new ArrayList<>();
         List<ProjectBasecost> projectBasecostList=new ArrayList<>();
         if(collect!=null&&collect.size()>0){
         if(collect!=null&&collect.size()>0){
             projectBasecostList = projectBasecostMapper.selectList(new QueryWrapper<ProjectBasecost>().in("project_id", collect));
             projectBasecostList = projectBasecostMapper.selectList(new QueryWrapper<ProjectBasecost>().in("project_id", collect));
         }
         }
         List<ProjectBasecostSetting> settingList = projectBasecostSettingMapper.selectList(new QueryWrapper<ProjectBasecostSetting>().eq("company_id", user.getCompanyId()));
         List<ProjectBasecostSetting> settingList = projectBasecostSettingMapper.selectList(new QueryWrapper<ProjectBasecostSetting>().eq("company_id", user.getCompanyId()));
-        List<String> titleList = settingList.stream().distinct().map(ProjectBasecostSetting::getName).collect(Collectors.toList());
+        List<String> titleList = settingList.stream().map(ProjectBasecostSetting::getName).distinct().collect(Collectors.toList());
         for (Project project : targetProjectList) {
         for (Project project : targetProjectList) {
             List<ProjectBasecost> basecostList = projectBasecostList.stream().filter(pb -> pb.getProjectId().equals(project.getId())).collect(Collectors.toList());
             List<ProjectBasecost> basecostList = projectBasecostList.stream().filter(pb -> pb.getProjectId().equals(project.getId())).collect(Collectors.toList());
             if(basecostList!=null){
             if(basecostList!=null){
@@ -7095,8 +7116,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDpartList.size()>0){
             if(functionDpartList.size()>0){
                 if(functionTimeList.size()>0||functionCostList.size()>0){
                 if(functionTimeList.size()>0||functionCostList.size()>0){
-                    List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                    List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                    List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                    List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                     collect.addAll(otherCollect);
                     collect.addAll(otherCollect);
                     for (Integer integer : collect) {
                     for (Integer integer : collect) {
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
                         List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
@@ -7804,8 +7825,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds=new ArrayList<>();
             deptIds=new ArrayList<>();
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
-                List<Integer> collect = userDepartmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = userDepartmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 //将该用户管理的所有部门以及部门的子部门id添加到deptIds集合中
                 //将该用户管理的所有部门以及部门的子部门id添加到deptIds集合中
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
@@ -7971,8 +7992,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
                 //获取管理的部门id
                 //获取管理的部门id
-                List<Integer> collect = userDepartmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = userDepartmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 //将该用户管理的所有部门以及部门的子部门id添加到deptIds集合中
                 //将该用户管理的所有部门以及部门的子部门id添加到deptIds集合中
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
@@ -8635,6 +8656,114 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
 
         return msg;
         return msg;
     }
     }
+
+    @Override
+    public HttpRespMsg projectGroupAndCategoryWorkTime(HttpServletRequest request, String startDate, String endDate, Integer projectId,Integer pageIndex,Integer pageSize) {
+        HttpRespMsg msg = new HttpRespMsg();
+        Integer start = (pageIndex-1)*pageSize;
+        Integer size = pageSize*pageIndex;
+        User user = userMapper.selectById(request.getHeader("token"));
+        List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部分组阶段工时");
+        List<SysRichFunction> functionInchargeList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责项目分组阶段工时");
+        //判断查看权限
+        List<Integer> inchagerIds=null;
+        if(false){
+            inchagerIds=new ArrayList<>();
+            if(functionInchargeList.size()>0){
+                List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
+                if(list!=null){
+                    List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
+                    inchagerIds.addAll(collect);
+                }
+            }else {
+                inchagerIds.add(-1);
+            }
+        }
+        List<Map<String,Object>> projectGroupAndCategoryList=projectMapper.getProjectGroupAndCategoryList(startDate,endDate,projectId,user.getCompanyId(),start,size,inchagerIds);
+        long total=projectMapper.getProjectGroupAndCategoryCount(startDate,endDate,projectId,user.getCompanyId(),null,null,inchagerIds);
+        List<Integer> projectIds = projectGroupAndCategoryList.stream().map(pl ->Integer.valueOf(String.valueOf(pl.get("projectId")))).distinct().collect(Collectors.toList());
+        List<Stages> stagesList = stagesMapper.selectList(new QueryWrapper<Stages>().in("project_id", projectIds));
+        List<String> titleList=new ArrayList<>();
+        titleList.add("项目编号");
+        titleList.add("项目名称");
+        titleList.add("任务分组");
+        titleList.add("分组合计工时");
+        List<String> stagesNameList = stagesList.stream().map(sl -> sl.getStagesName()).distinct().collect(Collectors.toList());
+        stagesNameList.add("非阶段");
+        titleList.addAll(stagesNameList);
+        List<Map<String,Object>> projectGroupAndCategoryData=projectMapper.getProjectGroupAndCategoryData(startDate,endDate,projectId,user.getCompanyId(),start,size,projectIds);
+        for (Map<String, Object> item : projectGroupAndCategoryList) {
+            List<Map<String, Object>> list = projectGroupAndCategoryData.stream().filter(pl -> pl.get("groupId").equals(item.get("groupId")) && pl.get("projectId").equals(item.get("projectId"))).collect(Collectors.toList());
+            item.put("categoryList",list);
+        }
+        Map<String,Object> map=new HashMap<>();
+        map.put("data",projectGroupAndCategoryList);
+        map.put("total",total);
+        map.put("titleList",titleList);
+        msg.data=map;
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg exportProjectGroupAndCategoryWorkTime(HttpServletRequest request, String startDate, String endDate, Integer projectId) {
+        HttpRespMsg msg=new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("token"));
+        List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", user.getCompanyId()));
+        List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全部任务阶段工时");
+        List<SysRichFunction> functionInchargeList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责项目任务阶段工时");
+        //判断查看权限
+        List<Integer> inchagerIds=null;
+        if(false){
+            inchagerIds=new ArrayList<>();
+            if(functionInchargeList.size()>0){
+                List<Project> list = projectList.stream().filter(pl -> (pl.getInchargerId()==null?0:pl.getInchargerId()).equals(user.getId())).collect(Collectors.toList());
+                if(list!=null){
+                    List<Integer> collect = list.stream().map(li -> li.getId()).collect(Collectors.toList());
+                    inchagerIds.addAll(collect);
+                }
+            }else {
+                inchagerIds.add(-1);
+            }
+        }
+        List<Map<String,Object>> projectGroupAndCategoryList=projectMapper.getProjectGroupAndCategoryList(startDate,endDate,projectId,user.getCompanyId(),null,null,inchagerIds);
+        List<Integer> projectIds = projectGroupAndCategoryList.stream().map(pl ->Integer.valueOf(String.valueOf(pl.get("projectId")))).distinct().collect(Collectors.toList());
+        List<Stages> stagesList = stagesMapper.selectList(new QueryWrapper<Stages>().in("project_id", projectIds));
+        List<String> titleList=new ArrayList<>();
+        titleList.add("项目编号");
+        titleList.add("项目名称");
+        titleList.add("任务分组");
+        titleList.add("分组合计工时");
+        List<String> stagesNameList = stagesList.stream().map(sl -> sl.getStagesName()).distinct().collect(Collectors.toList());
+        stagesNameList.add("非阶段");
+        titleList.addAll(stagesNameList);
+        List<List<String>> dataList=new ArrayList<>();
+        dataList.add(titleList);
+        List<Map<String,Object>> projectGroupAndCategoryData=projectMapper.getProjectGroupAndCategoryData(startDate,endDate,projectId,user.getCompanyId(),null,null,projectIds);
+        for (Map<String, Object> item : projectGroupAndCategoryList) {
+            List<String> stringList=new ArrayList<>();
+            List<Map<String, Object>> list = projectGroupAndCategoryData.stream().filter(pl -> pl.get("groupId").equals(item.get("groupId")) && pl.get("projectId").equals(item.get("projectId"))).collect(Collectors.toList());
+            stringList.add(String.valueOf(item.get("projectCode")));
+            stringList.add(String.valueOf(item.get("projectName")));
+            stringList.add(String.valueOf(item.get("groupName")));
+            stringList.add(String.valueOf(item.get("workingTime"))+"h");
+            for (String s : stagesNameList) {
+                Optional<Map<String, Object>> stagesName = list.stream().filter(l -> l.get("stagesName").equals(s)).findFirst();
+                if(stagesName.isPresent()){
+                    stringList.add(String.valueOf(stagesName.get().get("workingTime"))+"h");
+                }else {
+                    stringList.add("0h");
+                }
+            }
+            dataList.add(stringList);
+
+        }
+        String fileName = "项目分组阶段工时表"+System.currentTimeMillis();
+        String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName, dataList, path);
+        msg.data=resp;
+        return msg;
+    }
+
     private List<GanttDataItem> getUserGanttDataItemList(GanttDataItem userGantt, List<GanttDataItem> itemList) {
     private List<GanttDataItem> getUserGanttDataItemList(GanttDataItem userGantt, List<GanttDataItem> itemList) {
         if(itemList==null){
         if(itemList==null){
             itemList=new ArrayList<>();
             itemList=new ArrayList<>();

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

@@ -50,6 +50,7 @@ import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
 import java.time.format.DateTimeParseException;
 import java.time.temporal.ChronoUnit;
 import java.time.temporal.ChronoUnit;
+import java.time.temporal.TemporalAdjusters;
 import java.util.*;
 import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Executor;
@@ -2073,7 +2074,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         List<Department> allMDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", curUser.getId()));
         List<Department> allMDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", curUser.getId()));
         //其他负责的部门
         //其他负责的部门
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", curUser.getId()));
         List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", curUser.getId()));
-        List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+        List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
         for (Integer integer : otherCollect) {
         for (Integer integer : otherCollect) {
             Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
             Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
             if(first.isPresent()){
             if(first.isPresent()){
@@ -2126,7 +2127,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             List<Department> allMDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", token));
             List<Department> allMDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", token));
             //其他负责的部门
             //其他负责的部门
             List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", curUser.getId()));
             List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", curUser.getId()));
-            List<Integer> otherCollect = departmentOtherManagerList.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+            List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
             for (Integer integer : otherCollect) {
             for (Integer integer : otherCollect) {
                 Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
                 Optional<Department> first = allDepartmentList.stream().filter(ad -> ad.getDepartmentId().equals(integer)).findFirst();
                 if(first.isPresent()){
                 if(first.isPresent()){
@@ -5047,6 +5048,78 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         return httpRespMsg;
         return httpRespMsg;
     }
     }
 
 
+    @Override
+    public HttpRespMsg pushReportDataToThird(String yearMonth,HttpServletRequest request) {
+        HttpRespMsg msg=new HttpRespMsg();
+        Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
+        String dateStr = yearMonth+"-01";
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+        LocalDate start = LocalDate.parse(dateStr,df);
+        LocalDate end = LocalDate.parse(dateStr,df);
+        TimeType timeType = timeTypeMapper.selectOne(new QueryWrapper<TimeType>().eq("company_id", companyId));
+        List<HashMap<String, Object>> allReportByProject = reportMapper.geReportByProject(start.format(df),companyId,end.format(df));
+        String url=timeType.getPushReportUrl();
+        //认证的账号和密码
+        HttpHeaders headers=new HttpHeaders();
+        JSONObject param = new JSONObject();
+        JSONArray array=new JSONArray();
+        allReportByProject.forEach(rl->{
+            JSONObject object=new JSONObject();
+            object.put("projectMainCode",rl.get("projectMainCode"));
+            object.put("projectMainName",rl.get("projectMainName"));
+            object.put("projectCode",rl.get("projectCode"));
+            object.put("project",rl.get("project"));
+            object.put("duration",rl.get("duration"));
+            object.put("cost",rl.get("cost"));
+            object.put("year",rl.get("year"));
+            object.put("month",rl.get("month"));
+            array.add(object);
+        });
+        String username = "WPG_GS";
+        String password = "Sap_GS@12345";
+        String authorization =username + ":" + password;
+        JSONObject header=new JSONObject();
+        String s = "Basic "+Base64.getEncoder().encodeToString(authorization.getBytes());
+        header.put("Authorization",s);
+        param.put("IT_TAB",array);
+        JSONObject item=new JSONObject();
+        item.put("headers",header);
+        item.put("body",param);
+        //在请求头信息中携带Basic认证信息(这里才是实际Basic认证传递用户名密码的方式)
+        headers.set("app_id","3bf356d5-bdba-48d4-b1f5-e91468beefa3");
+        headers.set("app_key","f2960f3bf3c5ca58ee0c6970c1242e87-1655272886142-371814");
+        headers.set("Authorization",s);
+        headers.setContentType(MediaType.APPLICATION_JSON);
+        HttpEntity<String> requestEntity = new HttpEntity<String>(item.toJSONString(), headers);
+        //过滤掉账号认证失败的时候抛出的401异常
+        restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
+            @Override
+            public void handleError(ClientHttpResponse response) throws IOException {
+                if(response.getRawStatusCode() != 401){
+                    super.handleError(response);
+                }
+            }
+        });
+        //发送请求
+        ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST,requestEntity,String.class);
+        if (response.getStatusCode() == HttpStatus.OK) {
+            String resp = response.getBody();
+            JSONObject obj = JSONObject.parseObject(resp);
+            if (obj.getString("msg").equals("SUCCESS")) {
+                msg.data=obj;
+                return msg;
+            } else {
+                //抛出异常
+                try {
+                    throw new Exception(obj.getString("msg"));
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return msg;
+    }
+
     private void selfUpdateToNextWorkFlow(Integer companyId, User auditTargetUser, List<Integer> targetRids, List<Department> allDepts) {
     private void selfUpdateToNextWorkFlow(Integer companyId, User auditTargetUser, List<Integer> targetRids, List<Department> allDepts) {
         List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(
         List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(
                 new QueryWrapper<AuditWorkflowTimeSetting>().eq("company_id", companyId)
                 new QueryWrapper<AuditWorkflowTimeSetting>().eq("company_id", companyId)

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

@@ -1795,7 +1795,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             }
             }
             List<User> data = userMapper.selectList(queryWrapper);
             List<User> data = userMapper.selectList(queryWrapper);
             List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
             List<Department> deptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()));
-            List<String> collect = data.stream().distinct().map(da -> da.getId()).collect(Collectors.toList());
+            List<String> collect = data.stream().map(da -> da.getId()).distinct().collect(Collectors.toList());
             List<UserCert> userCertList=new ArrayList<>();
             List<UserCert> userCertList=new ArrayList<>();
             if(collect!=null&&!StringUtils.isEmpty(data)){
             if(collect!=null&&!StringUtils.isEmpty(data)){
                 userCertList = userCertMapper.selectList(new QueryWrapper<UserCert>().in("user_id", collect));
                 userCertList = userCertMapper.selectList(new QueryWrapper<UserCert>().in("user_id", collect));
@@ -2437,8 +2437,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
             deptIds=new ArrayList<>();
             deptIds=new ArrayList<>();
             deptIds.add(-1);
             deptIds.add(-1);
             if(functionDeptList.size()>0){
             if(functionDeptList.size()>0){
-                List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
-                List<Integer> otherCollect = otherManagers.stream().distinct().map(dom -> dom.getDepartmentId()).collect(Collectors.toList());
+                List<Integer> collect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
+                List<Integer> otherCollect = otherManagers.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
                 collect.addAll(otherCollect);
                 collect.addAll(otherCollect);
                 for (Integer integer : collect) {
                 for (Integer integer : collect) {
                     List<Integer> branchDepartment = departmentService.getDeptIncludeSubDeptIds(integer, allDeptList);
                     List<Integer> branchDepartment = departmentService.getDeptIncludeSubDeptIds(integer, allDeptList);

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

@@ -316,7 +316,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
     @Override
     @Override
     public void sendWXCorpTemplateMsg(WxCorpInfo corpInfo, String corpUserid, JSONObject msg) {
     public void sendWXCorpTemplateMsg(WxCorpInfo corpInfo, String corpUserid, JSONObject msg) {
         try {
         try {
-            if (isDev) return;
+            /*if (isDev) return;*/
             String accessToken = getCorpAccessToken(corpInfo);
             String accessToken = getCorpAccessToken(corpInfo);
             String url=URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
             String url=URL_SEND_WXCORP_MSG.replaceAll("ACCESS_TOKEN", accessToken);
             HttpHeaders headers = new HttpHeaders();
             HttpHeaders headers = new HttpHeaders();
@@ -327,12 +327,14 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                 reqParam.put("toparty", "");
                 reqParam.put("toparty", "");
                 reqParam.put("totag", "");
                 reqParam.put("totag", "");
                 reqParam.put("msgtype", "text");
                 reqParam.put("msgtype", "text");
+                reqParam.put("enable_id_trans",1);
                 reqParam.put("agentid", corpInfo.getAgentid());
                 reqParam.put("agentid", corpInfo.getAgentid());
                 reqParam.put("text", msg);
                 reqParam.put("text", msg);
             }else {
             }else {
                 reqParam.put("touser", corpUserid);
                 reqParam.put("touser", corpUserid);
                 reqParam.put("toparty", "");
                 reqParam.put("toparty", "");
                 reqParam.put("totag", "");
                 reqParam.put("totag", "");
+                reqParam.put("enable_id_trans",1);
                 reqParam.put("msgtype", "template_msg");
                 reqParam.put("msgtype", "template_msg");
                 reqParam.put("agentid", corpInfo.getAgentid());
                 reqParam.put("agentid", corpInfo.getAgentid());
                 reqParam.put("template_msg", msg);
                 reqParam.put("template_msg", msg);

+ 63 - 47
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/task/TimingTask.java

@@ -18,17 +18,17 @@ import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
 import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import org.springframework.http.ResponseEntity;
+import org.springframework.http.*;
+import org.springframework.http.client.ClientHttpResponse;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
 import org.springframework.util.StringUtils;
+import org.springframework.web.client.DefaultResponseErrorHandler;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.client.RestTemplate;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.security.SecureRandom;
 import java.security.SecureRandom;
 import java.sql.Timestamp;
 import java.sql.Timestamp;
@@ -203,7 +203,7 @@ public class TimingTask {
         }
         }
     }
     }
 
 
-    //每个月五号推送日报信息
+    //每个月五号推送上月日报信息
     @Scheduled(cron = "0 0 1 5 * ?")
     @Scheduled(cron = "0 0 1 5 * ?")
     private void pushReportListByToken(){
     private void pushReportListByToken(){
         if(isDev) return;
         if(isDev) return;
@@ -215,57 +215,73 @@ public class TimingTask {
         LocalDate end=now.with(TemporalAdjusters.lastDayOfMonth());
         LocalDate end=now.with(TemporalAdjusters.lastDayOfMonth());
         List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("push_report_data", 1));
         List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("push_report_data", 1));
         for (TimeType timeType : timeTypeList) {
         for (TimeType timeType : timeTypeList) {
-            List<ReportLog> reportLogList = reportLogMapper.selectList(new QueryWrapper<ReportLog>().eq("company_id", timeType.getCompanyId()).ge("operate_date",start.atTime(LocalTime.now())).orderByAsc("operate_date"));
-            List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", timeType.getCompanyId()));
-                List<HashMap<String, Object>> allReportByDate = reportMapper.getAllReportByDate(start.format(df),timeType.getCompanyId(), null, end.format(df), null, 1, null);
-                final CountDownLatch latch=new CountDownLatch(allReportByDate.size());
-                for (HashMap<String, Object> map : allReportByDate) {
-                    java.sql.Date sqlCreateDate= (java.sql.Date) map.get("createDate");
-                    java.sql.Timestamp sqlProjectAuditTime= (Timestamp) map.get("projectAuditTime");
-                    java.sql.Timestamp sqlTime= (Timestamp) map.get("time");
-                    if(sqlCreateDate!=null){
-                        LocalDate createDate = sqlCreateDate.toLocalDate();
-                        map.put("createDate",df.format(createDate));
-                    }
-                    if(sqlProjectAuditTime!=null){
-                        LocalDateTime projectAuditTime = sqlProjectAuditTime.toLocalDateTime();
-                        map.put("projectAuditTime",projectAuditTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+            List<HashMap<String, Object>> allReportByProject = reportMapper.geReportByProject(start.format(df),timeType.getCompanyId(),end.format(df));
+            String url=timeType.getPushReportUrl();
+            //认证的账号和密码
+            HttpHeaders headers=new HttpHeaders();
+            JSONObject param = new JSONObject();
+            JSONArray array=new JSONArray();
+            allReportByProject.forEach(rl->{
+                JSONObject object=new JSONObject();
+                object.put("projectMainCode",rl.get("projectMainCode"));
+                object.put("projectMainName",rl.get("projectMainName"));
+                object.put("projectCode",rl.get("projectCode"));
+                object.put("project",rl.get("project"));
+                object.put("duration",rl.get("duration"));
+                object.put("cost",rl.get("cost"));
+                object.put("year",rl.get("year"));
+                object.put("month",rl.get("month"));
+                array.add(object);
+            });
+            String username = "WPG_GS";
+            String password = "Sap_GS@12345";
+            String authorization =username + ":" + password;
+            JSONObject header=new JSONObject();
+            String s = "Basic "+Base64.getEncoder().encodeToString(authorization.getBytes());
+            header.put("Authorization",s);
+            param.put("IT_TAB",array);
+            JSONObject item=new JSONObject();
+            item.put("headers",header);
+            item.put("body",param);
+            //在请求头信息中携带Basic认证信息(这里才是实际Basic认证传递用户名密码的方式)
+            headers.set("app_id","3bf356d5-bdba-48d4-b1f5-e91468beefa3");
+            headers.set("app_key","f2960f3bf3c5ca58ee0c6970c1242e87-1655272886142-371814");
+            headers.set("Authorization",s);
+            headers.setContentType(MediaType.APPLICATION_JSON);
+            HttpEntity<String> requestEntity = new HttpEntity<String>(item.toJSONString(), headers);
+            //过滤掉账号认证失败的时候抛出的401异常
+            restTemplate.setErrorHandler(new DefaultResponseErrorHandler(){
+                @Override
+                public void handleError(ClientHttpResponse response) throws IOException {
+                    if(response.getRawStatusCode() != 401){
+                        super.handleError(response);
                     }
                     }
-                    if(sqlTime!=null){
-                        LocalDateTime time = sqlTime.toLocalDateTime();
-                        map.put("time",time.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
+                }
+            });
+            //发送请求
+            ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST,requestEntity,String.class);
+            if (response.getStatusCode() == HttpStatus.OK) {
+                String resp = response.getBody();
+                JSONObject obj = JSONObject.parseObject(resp);
+                if (obj.getString("msg").equals("SUCCESS")) {
+                    msg.data=obj;
+                } else {
+                    //抛出异常
+                    try {
+                        throw new Exception(obj.getString("msg"));
+                    } catch (Exception e) {
+                        e.printStackTrace();
                     }
                     }
-                    executor.execute(new Runnable(){
-                        @Override
-                        public void run() {
-                            List<ReportLog> item=new ArrayList<>();
-                            Integer reportId = (Integer) map.get("id");
-                            for (ReportLog reportLog : reportLogList) {
-                                List<String> list = Arrays.asList(reportLog.getReportIds().split(","));
-                                reportLog.setCreatorName(!userList.stream().filter(
-                                        ul->ul.getId().equals(reportLog.getCreatorId())).findFirst().isPresent()?"":userList.stream().filter(
-                                        ul->ul.getId().equals(reportLog.getCreatorId())).findFirst().get().getName());
-                                reportLog.setOperateName(!userList.stream().filter(
-                                        ul->ul.getId().equals(reportLog.getOperatorId())).findFirst().isPresent()?"":userList.stream().filter(
-                                        ul->ul.getId().equals(reportLog.getOperatorId())).findFirst().get().getName());
-                                if(list.contains(String.valueOf(reportId))&&!reportLog.getMsg().contains("提交")){
-                                    item.add(reportLog);
-                                }
-                            }
-                            map.put("checkLog",item);
-                            latch.countDown();
-                        }
-                    });
                 }
                 }
-                msg.data=allReportByDate;
+            }
         }
         }
     }
     }
 
 
 
 
     //每天2:11 同步钉钉用户前2天到未来30天时间段的打卡,请假,出差数据
     //每天2:11 同步钉钉用户前2天到未来30天时间段的打卡,请假,出差数据
-    @Scheduled(cron = "0 53 15 ? * *")
+    @Scheduled(cron = "0 11 2 ? * *")
     private void synFanWeiWorkData() {
     private void synFanWeiWorkData() {
-        /*if (isDev) return;*/
+        if (isDev) return;
         List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_fanwei", 1));
         List<TimeType> timeTypeList = timeTypeMapper.selectList(new QueryWrapper<TimeType>().eq("sync_fanwei", 1));
         List<Integer> compIds = timeTypeList.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
         List<Integer> compIds = timeTypeList.stream().map(TimeType::getCompanyId).collect(Collectors.toList());
         if(compIds.isEmpty()){
         if(compIds.isEmpty()){

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

@@ -1198,6 +1198,82 @@
         </if>) as total
         </if>) as total
     </select>
     </select>
 
 
+    <select id="getProjectGroupAndCategoryList" resultType="java.util.Map">
+        select c.id as projectId,c.project_name as projectName,c.project_code as projectCode,IFNULL(b.name,'未分组') as groupName,SUM(a.working_time) as workingTime,ifnull(b.id,0) as groupId
+        from report a
+        left join task_group b on a.group_id=b.id
+        left join project c on a.project_id=c.id
+        left join stages f on a.stage=f.stages_name and a.group_id=f.group_id
+        where c.company_id=#{companyId} and a.state=1
+        <if test="startDate!=null and endDate!=null">
+            and a.create_date &gt;=#{startDate} and a.create_date &lt;=#{endDate}
+        </if>
+        <if test="projectId!=null">
+            and c.id=#{projectId}
+        </if>
+        <if test="inchagerIds!=null and inchagerIds.size()>0">
+            and c.id in
+            <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
+                #{item}
+            </foreach>
+        </if>
+        group by c.id,b.id
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>
+    </select>
+
+    <select id="getProjectGroupAndCategoryCount" resultType="java.lang.Long">
+        select count(1) from
+        (select c.id as projectId,c.project_name as projectName,c.project_code as projectCode,IFNULL(b.name,'未分组') as groupName,SUM(a.working_time) as workingTime,ifnull(b.id,0) as groupId
+        from report a
+        left join task_group b on a.group_id=b.id
+        left join project c on a.project_id=c.id
+        left join stages f on a.stage=f.stages_name and a.group_id=f.group_id
+        where c.company_id=#{companyId} and a.state=1
+        <if test="startDate!=null and endDate!=null">
+            and a.create_date &gt;=#{startDate} and a.create_date &lt;=#{endDate}
+        </if>
+        <if test="projectId!=null">
+            and c.id=#{projectId}
+        </if>
+        <if test="inchagerIds!=null and inchagerIds.size()>0">
+            and c.id in
+            <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
+                #{item}
+            </foreach>
+        </if>
+        group by c.id,b.id
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>) as total
+    </select>
+
+    <select id="getProjectGroupAndCategoryData" resultType="java.util.Map">
+        select c.id as projectId,ifnull(b.id,0) as groupId,c.project_name as projectName,c.project_code as projectCode,SUM(a.working_time) as workingTime,IFNULL(f.stages_name,'非阶段') as stagesName
+        from report a
+        left join task_group b on a.group_id=b.id
+        left join project c on a.project_id=c.id
+        left join stages f on a.stage=f.stages_name and a.group_id=f.group_id
+        where c.company_id=#{companyId} and a.state=1
+        <if test="startDate!=null and endDate!=null">
+            and a.create_date &gt;=#{startDate} and a.create_date &lt;=#{endDate}
+        </if>
+        <if test="projectId!=null">
+            and c.id=#{projectId}
+        </if>
+        <if test="inchagerIds!=null and inchagerIds.size()>0">
+            and c.id in
+            <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
+                #{item}
+            </foreach>
+        </if>
+        group by c.id,f.id
+        <if test="start!=null and size!=null">
+            limit #{start},#{size}
+        </if>
+    </select>
+
     <select id="getCostByUserCustom" resultType="java.util.Map">
     <select id="getCostByUserCustom" resultType="java.util.Map">
         SELECT IFNULL(suc.name,'未定义') as name,SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney
         SELECT IFNULL(suc.name,'未定义') as name,SUM(b.working_time) AS cost, SUM(b.cost) AS costMoney
         FROM user AS a
         FROM user AS a

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

@@ -104,6 +104,25 @@
         ORDER BY a.creator_id, a.create_date desc
         ORDER BY a.creator_id, a.create_date desc
     </select>
     </select>
 
 
+    <select id="geReportByProject" resultType="java.util.Map">
+        SELECT project_main.name as projectMainName,project_main.code as projectMainCode,
+        b.project_name as project,b.project_code as projectCode,
+        SUM(a.cost) as cost,SUM(a.working_time)AS duration,DATE_FORMAT(a.create_date,'%Y') as year,DATE_FORMAT(a.create_date,'%m') as month
+        FROM report AS a
+        JOIN project AS b ON a.project_id=b.id
+        LEFT JOIN user AS c ON a.creator_id=c.id
+        left join project_main on b.project_main_id=project_main.id
+        WHERE a.state = 1
+        <if test="startDate != null and startDate != ''">
+            AND a.create_date between #{startDate} and #{endDate}
+        </if>
+        <if test="companyId != null">
+            AND c.company_id = #{companyId}
+        </if>
+        group by b.id
+        ORDER BY a.creator_id, a.create_date desc
+    </select>
+
     <select id="getPMOReportByDate" resultType="java.util.Map">
     <select id="getPMOReportByDate" resultType="java.util.Map">
         SELECT c.name, b.project_name AS project, a.working_time AS duration, a.content, a.create_time AS time, a.create_date as createDate,
         SELECT c.name, 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.state, a.time_type as timeType, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,

File diff suppressed because it is too large
+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/TimeTypeMapper.xml