QuYueTing 10 часов назад
Родитель
Сommit
97ce2ce2e5
19 измененных файлов с 336 добавлено и 362 удалено
  1. 1 0
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/PlatformStartApplication.java
  2. 36 9
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceController.java
  3. 2 6
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java
  4. 4 6
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java
  5. 2 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskController.java
  6. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Report.java
  7. 1 2
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java
  8. 7 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java
  9. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/FinanceService.java
  10. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ProjectService.java
  11. 1 1
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportService.java
  12. 2 2
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/FinanceServiceImpl.java
  13. 74 208
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java
  14. 106 79
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java
  15. 35 19
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java
  16. 0 3
      fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/SplitDateUtil.java
  17. 3 0
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml
  18. 0 17
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ProjectMapper.xml
  19. 59 5
      fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

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

@@ -3,6 +3,7 @@ package com.management.platform;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
 import org.springframework.context.annotation.Bean;
 import org.springframework.data.redis.connection.RedisConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;

+ 36 - 9
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/FinanceController.java

@@ -1,22 +1,21 @@
 package com.management.platform.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.management.platform.entity.Company;
-import com.management.platform.entity.FinanceFixedcolname;
-import com.management.platform.entity.FinanceTblcuscol;
-import com.management.platform.entity.TimeType;
-import com.management.platform.mapper.CompanyMapper;
-import com.management.platform.mapper.FinanceTblcuscolMapper;
-import com.management.platform.mapper.TimeTypeMapper;
-import com.management.platform.mapper.WxCorpInfoMapper;
+import com.management.platform.config.NewLimitRequest;
+import com.management.platform.entity.*;
+import com.management.platform.mapper.*;
 import com.management.platform.service.ExcelExportService;
 import com.management.platform.service.FinanceFixedcolnameService;
 import com.management.platform.service.FinanceService;
+import com.management.platform.service.UserService;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.MessageUtils;
 import com.management.platform.util.UserNotFoundException;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
@@ -56,9 +55,13 @@ public class FinanceController {
     private WxCorpInfoMapper wxCorpInfoMapper;
     @Resource
     private ExcelExportService excelExportService;
+    @Resource
+    ThirdPartyInterfaceMapper thirdPartyInterfaceMapper;
 
     @Value(value = "${upload.path}")
     private String path;
+    @Autowired
+    private UserService userService;
 
     @RequestMapping("/getByMonth")
     public HttpRespMsg getByMonth(Integer companyId, String yearMonth,Integer deptId, @RequestParam(required = false, defaultValue = "1") Integer salaryType) {
@@ -123,7 +126,31 @@ public class FinanceController {
     //按照项目分配财务成本
     @RequestMapping("/getTimeCost")
     public HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser,@RequestParam(required = false, defaultValue = "1") Integer salaryType, HttpServletRequest request) {
-        return financeService.getTimeCost(yearMonth,deptId, assignNoProUser,salaryType, request);
+        Integer companyId = userService.getById(request.getHeader("Token")).getCompanyId();
+        return financeService.getTimeCost(yearMonth,deptId, assignNoProUser,salaryType, companyId);
+    }
+
+    @NewLimitRequest(count = 10)
+    @RequestMapping("/getProjectTimeCost")
+    public HttpRespMsg getProjectTimeCost(@RequestBody String json) {
+        HttpRespMsg msg = new HttpRespMsg();
+        JSONObject jsonObject = JSONObject.parseObject(json);
+        String yearMonth = jsonObject.getString("yearMonth");
+        String token = jsonObject.getString("token");
+        Integer salaryType = jsonObject.getInteger("salaryType");
+        //判断以上参数是否为空
+        if(yearMonth==null||token==null||salaryType==null){
+            msg.setError("缺少参数,请检查:yearMonth,token,salaryType");
+            return msg;
+        }
+        List<ThirdPartyInterface> thirdPartyInterfaceList = thirdPartyInterfaceMapper.selectList(new QueryWrapper<ThirdPartyInterface>().eq("token", token));
+        if(thirdPartyInterfaceList.size()==0){
+            //msg.setError("token错误");
+            msg.setError(MessageUtils.message("other.tokenError"));
+            return msg;
+        }
+        ThirdPartyInterface thirdPartyInterface = thirdPartyInterfaceList.get(0);
+        return financeService.getTimeCost(yearMonth,null, true,salaryType, thirdPartyInterface.getCompanyId());
     }
 
     @RequestMapping("/getNoProjectUsers")

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

@@ -1664,8 +1664,6 @@ public class ProjectController {
 
     /**
      * 按部门汇总统计工时成本数据(分页)
-     * @param pageIndex 页码
-     * @param pageSize 每页大小
      * @param startDate 开始日期(可选)
      * @param endDate 结束日期(可选)
      * @param projectId 项目ID(可选)
@@ -1673,13 +1671,11 @@ public class ProjectController {
      * @return 返回部门、项目编号、项目名称、项目分类、工时(h)、成本(元)
      */
     @RequestMapping("/getTimeCostForTableByDept")
-    public HttpRespMsg getTimeCostForTableByDept(@RequestParam Integer pageIndex,
-                                                  @RequestParam Integer pageSize,
-                                                  String startDate,
+    public HttpRespMsg getTimeCostForTableByDept( String startDate,
                                                   String endDate,
                                                   Integer projectId,
                                                   Integer departmentId) {
-        return projectService.getTimeCostForTableByDept(pageIndex, pageSize, startDate, endDate, projectId, departmentId, request);
+        return projectService.getTimeCostForTableByDept(startDate, endDate, projectId, departmentId, request);
     }
 
     /**

+ 4 - 6
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -468,7 +468,7 @@ public class ReportController {
                                   Integer[] taskId,
                                   Integer[] taskFinish,
                                   Integer[] isOvertime,
-                                  Integer[] progress,
+                                  Double[] progress,
                                   String[] targetUids,
                                   String[] professionProgress,
                                   String[] stage,
@@ -1521,7 +1521,7 @@ public class ReportController {
                     if(WorkDayCalculateUtils.isWorkDay(report.getCreateDate())){
                         HttpRespMsg httpRespMsg = new HttpRespMsg();
                         double overTimeSum = reportList.stream().filter(rl -> rl.getCreateDate().equals(report.getCreateDate()) && rl.getCreatorId().equals(report.getCreatorId())).mapToDouble(Report::getOvertimeHours).sum();
-                        UserCorpwxTime userCorpwxTime = userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().eq("ot_status", 1).eq("corpwx_userid", curReporter.getCorpwxUserid()).eq("create_date", report.getCreateDate()));
+                        UserCorpwxTime userCorpwxTime = userCorpwxTimeMapper.selectOne(new QueryWrapper<UserCorpwxTime>().ne("ot_status", 0).eq("corpwx_userid", curReporter.getCorpwxUserid()).eq("create_date", report.getCreateDate()));
                         if(overTimeSum > 0){
                             if (userCorpwxTime == null || userCorpwxTime.getOtTime() == 0) {
                                 httpRespMsg.setError("未同步到加班时长,请先补填加班申请");
@@ -1736,7 +1736,6 @@ public class ReportController {
             LocalDate endDate = startDate.minusDays(1);
             startDate = startDate.minusDays(8);
             List<String> missingReportDates = reportService.getUserMissingReportDates(user.getId(), dateTimeFormatter.format(startDate), dateTimeFormatter.format(endDate));
-            System.out.println("missingReportDates.size()=="+missingReportDates.size() + ", startDate=" + dateTimeFormatter.format(startDate) + ", endDate=" + dateTimeFormatter.format(endDate));
             if (missingReportDates != null && missingReportDates.size() > 0) {
                 HttpRespMsg httpRespMsg = new HttpRespMsg();
                 httpRespMsg.setError("请按顺序填写近期日报:" + String.join(",", missingReportDates));
@@ -1761,7 +1760,6 @@ public class ReportController {
                 //校验下限
                 if (dailyWorktime < comTimeType.getMinReportTime()) {
                     HttpRespMsg httpRespMsg = new HttpRespMsg();
-                    //httpRespMsg.setError("每日工作时长不得超过"+comTimeType.getAllday()+"小时");
                     httpRespMsg.setError("每日工作时长不得少于" + comTimeType.getMinReportTime() + "小时");
                     return httpRespMsg;
                 }
@@ -2770,11 +2768,11 @@ public class ReportController {
     @RequestMapping("/listByStateDepartment")
     public HttpRespMsg listByStateDepartment(@RequestParam Integer state,
                                              Integer projectId,
-                                             String date,
+                                             String date,Integer pageIndex, Integer pageSize,
                                              HttpServletRequest request) {
         return reportService.listByStateDepartment(state,
                 projectId,
-                date,request);
+                date,pageIndex,pageSize,  request);
     }
 
     /**

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

@@ -665,7 +665,8 @@ public class TaskController {
         }
 
         taskService.updateById(task);
-        ArrayList<Integer> finishedTaskIds = Lists.list(task.getId());
+        ArrayList<Integer> finishedTaskIds = new ArrayList<>();
+        finishedTaskIds.add(task.getId());
         if (isFinishTask) {
             List<Task> finishedMileStoneList = taskMapper.selectList(new QueryWrapper<Task>().select("id, name, project_id, finish_date").in("id", finishedTaskIds).eq("task_type", 1));
             taskService.notifyMileStoneFinish(user.getCompanyId(), finishedMileStoneList);

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

@@ -137,7 +137,7 @@ public class Report extends Model<Report> {
      * 用时占比
      */
     @TableField("progress")
-    private Integer progress;
+    private Double progress;
 
 
     @TableField(exist = false)

+ 1 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ProjectMapper.java

@@ -303,8 +303,7 @@ public interface ProjectMapper extends BaseMapper<Project> {
 
     List<Map<String, Object>> getTimeCostForTableByDept(@Param("companyId") Integer companyId, @Param("startDate") String startDate,
                                                          @Param("endDate") String endDate, @Param("projectId") Integer projectId,
-                                                         @Param("departmentId") Integer departmentId,
-                                                         @Param("start") Integer start, @Param("size") Integer size);
+                                                         @Param("departmentId") Integer departmentId);
 
     long getTimeCostForTableByDeptCount(@Param("companyId") Integer companyId, @Param("startDate") String startDate,
                                          @Param("endDate") String endDate, @Param("projectId") Integer projectId,

+ 7 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportMapper.java

@@ -137,7 +137,9 @@ public interface ReportMapper extends BaseMapper<Report> {
     List<Map<String, Object>> getReportFillStatus(String startDate, String endDate, String userId);
 
     List<Map<String, Object>> getDepartmentDetailByState(@Param("departmentIds") List<Integer> departmentIds,
-                                               @Param("companyId") Integer companyId);
+                                               @Param("companyId") Integer companyId, @Param("date") String date, Integer pageStart, Integer pageSize);
+    long getDepartmentDetailByStateCount(@Param("departmentIds") List<Integer> departmentIds,
+                                                         @Param("companyId") Integer companyId, @Param("date") String date);
 
     List<Map<String, Object>> getUserDailyWorkTime(Integer companyId, String startDate, String endDate, List<Integer> deptIds, String leaderId,String userId);
 
@@ -302,4 +304,8 @@ public interface ReportMapper extends BaseMapper<Report> {
                                       @Param("departmentId") Integer departmentId,
                                       @Param("projectId") Integer projectId,
                                       @Param("deptIds") List<Integer> deptIds);
+
+    List<Map<String, Object>> getDepartmentAuditList(@Param("startDate") String startDate,
+                                                     @Param("endDate") String endDate, @Param("userIds") List<String> userIds, @Param("projectId") Integer projectId);
+
 }

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

@@ -23,7 +23,7 @@ public interface FinanceService extends IService<Finance> {
 
     HttpRespMsg exportData(Integer groupByCategory,Integer onlyTotal, String date, Boolean assignNoProUser,Integer deptId, Integer salaryType, HttpServletRequest request);
 
-    HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser, Integer salaryType, HttpServletRequest request);
+    HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser, Integer salaryType, Integer companyId);
 
     HttpRespMsg getNoProjectUsers(String yearMonth, Integer salaryType, HttpServletRequest request);
 

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

@@ -351,7 +351,7 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg exportTimeCostForTable(String startDate, String endDate, Integer projectId, String userId, Integer departmentId, HttpServletRequest request);
 
-    HttpRespMsg getTimeCostForTableByDept(Integer pageIndex, Integer pageSize, String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request);
+    HttpRespMsg getTimeCostForTableByDept(String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request);
 
     HttpRespMsg exportTimeCostForTableByDept(String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request);
 }

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

@@ -65,7 +65,7 @@ public interface ReportService extends IService<Report> {
 
     HttpRespMsg listByStateProfession(Integer state, Integer departmentId, Integer projectId, String date, HttpServletRequest request);
 
-    HttpRespMsg listByStateDepartment(Integer state, Integer projectId, String date, HttpServletRequest request);
+    HttpRespMsg listByStateDepartment(Integer state, Integer projectId, String date, Integer pageIndex, Integer pageSize,HttpServletRequest request);
 
     HttpRespMsg getUserDailyWorkTime(HttpServletRequest request, String startDate, String endDate,Integer hasReportDeptId) throws Exception;
 

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

@@ -2198,10 +2198,10 @@ public class FinanceServiceImpl extends ServiceImpl<FinanceMapper, Finance> impl
     }
 
     @Override
-    public HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser, Integer salaryType, HttpServletRequest request) {
+    public HttpRespMsg getTimeCost(String yearMonth,Integer deptId, Boolean assignNoProUser, Integer salaryType, Integer companyId) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
-            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
+//            Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
             TimeType timeType = timeTypeMapper.selectById(companyId);
             Map<String, Object> resultMap = new HashMap<>();
             //获取月成本列表

+ 74 - 208
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -937,160 +937,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         return httpRespMsg;
     }
 
-    /*@Override
-    public HttpRespMsg getProjectEstimatedWorkNew(Integer pageIndex, Integer pageSize, Integer projectId, Integer type,Integer isWarn, HttpServletRequest request) {
-        HttpRespMsg httpRespMsg = new HttpRespMsg();
-        //通过公司id获取该公司所有的项目列表
-        User user = userMapper.selectById(request.getHeader("Token"));
-        Integer companyId = user.getCompanyId();
-        EstimateTimeSetting estimateTimeSetting = estimateTimeSettingMapper.selectOne(new QueryWrapper<EstimateTimeSetting>().eq("company_id", companyId));
-        //该公司下的allday
-        float allday=timeTypeMapper.selectOne(new QueryWrapper<TimeType>()
-                .eq("company_id",companyId)).getAllday();
-        //根据公司的id搜索该公司有哪些项目  20231108之前完成的不统计,状态为进行中/已完成
-        List<Project> records = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId).in("status", 1, 2)
-                .and(wrapper -> wrapper.isNull("finish_date").or()
-                        .ge("finish_date", "2023-11-08")).eq(projectId != null, "id", projectId));
-
-        List<Integer> collectIds = records.stream().map(Project::getId).collect(Collectors.toList());
-
-        //根据查询道德project列表查询总的reporeList
-        List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>()
-                .in("project_id", collectIds));
-        //根据查询道德project列表查询总的task_groupList
-        List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>()
-                .in("project_id", collectIds));
-
-        DecimalFormat df = new DecimalFormat("0.00");
-        List<GroupEstimatedWorkVO> lastList=new ArrayList<>();
-        for (Project project : records) {
-
-            List<TaskGroup> taskGroupCollect = taskGroups.stream().filter(t -> t.getProjectId().equals(project.getId())).collect(Collectors.toList());
-
-            //0代表按项目查看
-            if (type==0){
-                GroupEstimatedWorkVO estimatedWorkVO = new GroupEstimatedWorkVO();
-                Double reallWorkTime = reportList.stream().filter(r -> r.getProjectId() .equals( project.getId())&&r.getWorkingTime()!=null)
-                        .mapToDouble(Report::getWorkingTime).sum();
-                String rWorkTime=reallWorkTime==null ? "0":df.format(reallWorkTime);
-                estimatedWorkVO.setProjectId(project.getId());
-                estimatedWorkVO.setProjectName(project.getProjectName());
-                estimatedWorkVO.setProjectCode(project.getProjectCode());
-                estimatedWorkVO.setWorkTime(rWorkTime);
-                String pEstimatedWork=project.getManDay()==null? "0": (project.getManDay()*allday+"");
-                estimatedWorkVO.setEstimatedWorkTime(pEstimatedWork);
-                if (project.getManDay()==null){
-                    estimatedWorkVO.setRemainWorkTime("\\");
-                    estimatedWorkVO.setRemainWorkTimeProportion("\\");
-                }else{
-                    double rWorkTimeDouble = Double.parseDouble(rWorkTime);
-                    double pEstimatedWorkDouble = Double.parseDouble(pEstimatedWork);
-                    double remainDouble = pEstimatedWorkDouble - rWorkTimeDouble;
-                    estimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
-                    double proportion = (remainDouble / pEstimatedWorkDouble)*100;
-                    estimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
-                }
-                lastList.add(estimatedWorkVO);
-            }
-            else {
-                if (taskGroupCollect.size()>0){
-                    List<Integer> groupIds = taskGroupCollect.stream().map(TaskGroup::getId).collect(Collectors.toList());
-                    List<Report> getByProjectAndGroup = reportMapper.selectList(new QueryWrapper<Report>()
-                            .eq("project_id", project.getId())
-                            .in("group_id", groupIds));
-                    for (TaskGroup taskGroup : taskGroupCollect) {
-                        Double gReallWorkTime = getByProjectAndGroup.stream().filter(r -> r.getGroupId().equals( taskGroup.getId()))
-                                .mapToDouble(r->r.getWorkingTime()).sum();
-                        GroupEstimatedWorkVO groupEstimatedWorkVO = new GroupEstimatedWorkVO();
-                        String grWorkTime=gReallWorkTime==null ? "0":gReallWorkTime+"";
-                        String gEstimatedWork=taskGroup.getManDay()==null ? 0*allday+"": taskGroup.getManDay()*allday+"";
-
-                        if (taskGroup.getManDay()==null){
-                            groupEstimatedWorkVO.setRemainWorkTime("\\");
-                            groupEstimatedWorkVO.setRemainWorkTimeProportion("\\");
-                        }else{
-                            double grWorkTimeDouble = Double.parseDouble(grWorkTime);
-                            double gEstimatedWorkDouble = Double.parseDouble(gEstimatedWork);
-                            double remainDouble = gEstimatedWorkDouble - grWorkTimeDouble;
-                            groupEstimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
-                            double proportion = (remainDouble / gEstimatedWorkDouble)*100;
-                            groupEstimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
-                        }
-
-                        groupEstimatedWorkVO.setWorkTime(grWorkTime);
-                        groupEstimatedWorkVO.setEstimatedWorkTime(gEstimatedWork);
-                        groupEstimatedWorkVO.setId(taskGroup.getId());
-                        groupEstimatedWorkVO.setGroupName(taskGroup.getName());
-                        groupEstimatedWorkVO.setProjectId(project.getId());
-                        groupEstimatedWorkVO.setProjectName(project.getProjectName());
-
-                        lastList.add(groupEstimatedWorkVO);
-                    }
-                }
-                else {
-                    GroupEstimatedWorkVO groupEstimatedWorkVO = new GroupEstimatedWorkVO();
-                    groupEstimatedWorkVO.setWorkTime("");
-                    groupEstimatedWorkVO.setEstimatedWorkTime("");
-                    groupEstimatedWorkVO.setId(null);
-                    groupEstimatedWorkVO.setGroupName("");
-                    groupEstimatedWorkVO.setProjectId(project.getId());
-                    groupEstimatedWorkVO.setProjectName(project.getProjectName());
-                    groupEstimatedWorkVO.setRemainWorkTime("\\");
-                    groupEstimatedWorkVO.setRemainWorkTimeProportion("\\");
-                    lastList.add(groupEstimatedWorkVO);
-                }
-            }
-        }
-        Integer projectWarningPercent = estimateTimeSetting.getProjectWarningPercent();
-        Integer groupWarningPercent = estimateTimeSetting.getGroupWarningPercent();
-        if (isWarn!=null){
-            lastList = lastList.stream().
-                    filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")).collect(Collectors.toList());
-            if (type==0){
-                lastList = lastList.stream().
-                        filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < projectWarningPercent)
-                        .collect(Collectors.toList());
-            }else {
-                lastList = lastList.stream().
-                        filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < groupWarningPercent)
-                        .collect(Collectors.toList());
-            }
-        }
-
-        if (type==0){
-            lastList.stream().
-                    filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")&&Double.parseDouble(l.getRemainWorkTimeProportion()) < projectWarningPercent)
-                    .forEach(s->s.setIsRed(true));
-        }else {
-            lastList.stream().
-                    filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")&&Double.parseDouble(l.getRemainWorkTimeProportion()) < groupWarningPercent)
-                    .forEach(s->s.setIsRed(true));
-        }
-
-        Integer size=(pageIndex-1)*pageSize;
-        List<GroupEstimatedWorkVO> subList = new ArrayList<>();
-        if (lastList.size()>size+pageSize){
-            subList=lastList.subList(size,size+pageSize);
-        }else {
-            subList=lastList.subList(size,lastList.size());
-        }
-        if (!subList.isEmpty()){
-            subList.forEach(s->{
-                if (!StringUtils.isEmpty(s.getRemainWorkTimeProportion())&&s.getRemainWorkTimeProportion().equals("\\")){
-                    s.setRemainWorkTimeProportion("\\");
-                }else {
-                    s.setRemainWorkTimeProportion(s.getRemainWorkTimeProportion()+"%");
-                }
-            });
-        }
-        Map<String,Object> resultMap=new HashMap<>();
-        resultMap.put("total",lastList.size());
-        resultMap.put("records",subList);
-        httpRespMsg.data=resultMap;
-        return httpRespMsg;
-    }*/
-
-
     @Override
     public HttpRespMsg getProjectEstimatedWorkNew(Integer pageIndex, Integer pageSize, Integer projectId, Integer type,Integer isWarn, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -9161,7 +9007,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<List<String>> exportList = new ArrayList<>();
         //String[] titles = {"项目编号", "项目名称", "当前总预算","当前剩余预算","总剩余预算","已发生总工时成本"};
         String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.totalBudget"),MessageUtils.message("entry.curRemBud"),MessageUtils.message("entry.totalRemBud"),MessageUtils.message("entry.totalLaborCostIncurred")};
-        ArrayList<String> headList = Lists.list(titles);
+        ArrayList<String> headList = new ArrayList<>(Arrays.asList(titles));
         //列,根据定义的工时预警类型的成本项来
         List<ProjectBasecostSetting> settingList = projectBasecostSettingMapper.selectList(new QueryWrapper<ProjectBasecostSetting>().eq("company_id", companyId).eq("alarm_type", 1));
         for (ProjectBasecostSetting setting : settingList) {
@@ -17288,26 +17134,78 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
      * 按部门汇总统计工时成本数据(分页)
      */
     @Override
-    public HttpRespMsg getTimeCostForTableByDept(Integer pageIndex, Integer pageSize, String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request) {
+    public HttpRespMsg getTimeCostForTableByDept(String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             User targetUser = userMapper.selectById(request.getHeader("Token"));
             Integer companyId = targetUser.getCompanyId();
 
-            // 计算分页参数
-            int start = (pageIndex - 1) * pageSize;
-
+            List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
             // 查询数据(分页)
-            List<Map<String, Object>> list = projectMapper.getTimeCostForTableByDept(companyId, startDate, endDate, projectId, departmentId, start, pageSize);
-
-            // 查询总数
-            long total = projectMapper.getTimeCostForTableByDeptCount(companyId, startDate, endDate, projectId, departmentId);
-
-            Map<String, Object> resultMap = new HashMap<>();
-            resultMap.put("records", list);
-            resultMap.put("total", total);
-
-            httpRespMsg.data = resultMap;
+            List<Map<String, Object>> list = projectMapper.getTimeCostForTableByDept(companyId, startDate, endDate, projectId, departmentId);
+            List<Integer> deptIds = new ArrayList<>();
+            for (Map<String, Object> map : list) {
+                //取上一级部门
+                Integer deptId = (Integer) map.get("deptId");
+                deptIds.add(deptId);
+            }
+            List<Department> superDeptList = new ArrayList<>();
+            for (Integer id : deptIds) {
+                Department curDept = allDeptList.stream().filter(department -> department.getDepartmentId().equals(id)).findFirst().orElse(null);
+                if (curDept != null) {
+                    if (curDept.getSuperiorId() != null && curDept.getSuperiorId() != 0) {
+                        //加入到父级部门
+                        superDeptList.add(allDeptList.stream().filter(su->su.getDepartmentId().equals(curDept.getSuperiorId())).findFirst().orElse(null));
+                    }
+                }
+            }
+            //去重
+            superDeptList = superDeptList.stream().distinct().collect(Collectors.toList());
+            List<Map<String, Object>> sumList = new ArrayList<>();
+            //计算每个父部门的合计工时
+            for (Department superDept : superDeptList) {
+                //计算合计工时
+                double sum = 0.0;
+                BigDecimal cost = new BigDecimal(0);
+                List<Map<String, Object>> childList = new ArrayList<>();
+                for (Map<String, Object> map : list) {
+                    Integer deptId = (Integer) map.get("deptId");
+                    if (deptId.equals(superDept.getDepartmentId())) {
+                        sum += (Double)map.get("workingTime");
+                        cost = cost.add((BigDecimal) map.get("cost"));
+                        childList.add(map);
+                    } else {
+                        //取父部门
+                        Department curDept = allDeptList.stream().filter(department -> department.getDepartmentId().equals(deptId)).findFirst().orElse(null);
+                        if (curDept != null && curDept.getSuperiorId() != null && curDept.getSuperiorId() != 0) {
+                            if (curDept.getSuperiorId().equals(superDept.getDepartmentId())) {
+                                sum += (Double)map.get("workingTime");
+                                cost = cost.add((BigDecimal) map.get("cost"));
+                                childList.add(map);
+                            }
+                        }
+                    }
+                }
+                Map<String, Object> superMap = new HashMap<>();
+                superMap.put("deptId", superDept.getDepartmentId());
+                superMap.put("departmentName", superDept.getDepartmentName());
+                superMap.put("workingTime", sum);
+                superMap.put("cost", cost);
+                superMap.put("isSum", true);
+                superMap.put("childList", childList);
+                sumList.add(superMap);
+            }
+            //以sumList为基准,重新排列list
+            List<Map<String, Object>> newList = new ArrayList<>();
+            for (Map<String, Object> superMap : sumList) {
+                newList.add(superMap);
+                List<Map<String, Object>> childList = (List<Map<String, Object>>) superMap.get("childList");
+                for (Map<String, Object> child : childList) {
+                    newList.add(child);
+                }
+                superMap.remove("childList");
+            }
+            httpRespMsg.data = newList;
         } catch (NullPointerException e) {
             e.printStackTrace();
             httpRespMsg.setError(MessageUtils.message("access.verificationError"));
@@ -17333,13 +17231,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
             // 获取企业微信和钉钉配置
             WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
-            CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
-
-            // 获取所有部门信息用于转译
-            List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
-
+            HttpRespMsg httpRespMsg = getTimeCostForTableByDept(startDate, endDate, projectId, departmentId, request);
             // 查询所有数据(不分页)
-            List<Map<String, Object>> list = projectMapper.getTimeCostForTableByDept(companyId, startDate, endDate, projectId, departmentId, null, null);
+            List<Map<String, Object>> list = (List<Map<String, Object>>)httpRespMsg.getData();
 
             // 构建Excel表头
             List<String> headers = new ArrayList<>();
@@ -17358,40 +17252,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     if("未分配".equals(item.get("departmentName"))) {
                         row.add("未分配");
                     } else {
-                        // 查找部门对象进行转译
-                        Department dept = null;
-                        if(item.get("deptId") != null) {
-                            Integer deptId = Integer.valueOf(item.get("deptId").toString());
-                            dept = allDepartmentList.stream()
-                                    .filter(d -> d.getDepartmentId().equals(deptId))
-                                    .findFirst().orElse(null);
-                        }
-                        if(dept != null) {
-                            row.add(departmentService.exportWxDepartment(dept, allDepartmentList));
-                        } else {
-                            row.add(item.get("departmentName") != null ? item.get("departmentName").toString() : "");
-                        }
-                    }
-                } else if(dingding != null && dingding.getContactNeedTranslate() == 1) {
-                    if("未分配".equals(item.get("departmentName"))) {
-                        row.add("未分配");
-                    } else {
-                        // 查找部门对象进行转译
-                        Department dept = null;
-                        if(item.get("deptId") != null) {
-                            Integer deptId = Integer.valueOf(item.get("deptId").toString());
-                            dept = allDepartmentList.stream()
-                                    .filter(d -> d.getDepartmentId().equals(deptId))
-                                    .findFirst().orElse(null);
-                        }
-                        if(dept != null) {
-                            row.add(departmentService.exportDdDepartment(dept, allDepartmentList));
-                        } else {
-                            row.add(item.get("departmentName") != null ? item.get("departmentName").toString() : "");
-                        }
+                        String deptName = item.get("departmentName") != null ? "$departmentName="+item.get("departmentName").toString() + "$": "";
+                        row.add(deptName + (item.get("isSum") != null && item.get("isSum").equals(true) ? "(合计)" : ""));
                     }
                 } else {
-                    row.add(item.get("departmentName") != null ? item.get("departmentName").toString() : "");
+                    String deptName = item.get("departmentName") != null ? item.get("departmentName").toString(): "";
+                    row.add(deptName + (item.get("isSum") != null && item.get("isSum").equals(true) ? "(合计)" : ""));
                 }
                 row.add(item.get("workingTime") != null ? item.get("workingTime").toString() : "0");
                 row.add(item.get("cost") != null ? item.get("cost").toString() : "0");
@@ -17400,7 +17266,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
             // 生成Excel文件
             String fileName = "按部门汇总工时成本统计_" + System.currentTimeMillis();
-            return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, dingding, fileName, dataList, path);
+            return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, null, fileName, dataList, path);
         } catch (Exception e) {
             e.printStackTrace();
             msg.setError(e.getMessage());

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

@@ -2446,6 +2446,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             map.put("cardHours", wh);
                             map.put("startTime", first.get().getStartTime());
                             map.put("endTime", first.get().getEndTime());
+                            map.put("overtime", first.get().getOtTime());//加班申请时长
+                            map.put("askLeaveTime", first.get().getAskLeaveTime());//请假时长
                         }
                     }
                 }
@@ -2582,14 +2584,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     Report report = reportMapper.selectById(ids.get(0));
                     oneReport = report;
                     //部门待审核,部门审核通过
-                    if (report.getDepartmentAuditState() == 0){
-                        report = new Report();
-                        report.setDepartmentAuditState(1);
-                        if(timeType.getNeedEvaluate()==1){
-                            report.setEvaluate(evaluate);
-                        }
-                        reportMapper.update(report, new QueryWrapper<Report>().in("id", ids));
+                    report = new Report();
+                    report.setDepartmentAuditState(1);
+                    if(timeType.getNeedEvaluate()==1){
+                        report.setEvaluate(evaluate);
                     }
+                    reportMapper.update(report, new QueryWrapper<Report>().in("id", ids));
                 }
             } else {
                 //专业审核或者项目审核
@@ -5254,7 +5254,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     }
 
     @Override
-    public HttpRespMsg listByStateDepartment(Integer state, Integer projectId, String date, HttpServletRequest request) {
+    public HttpRespMsg listByStateDepartment(Integer state, Integer projectId, String date, Integer pageIndex, Integer pageSize, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
             SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
@@ -5263,90 +5263,108 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             Integer companyId = curUser.getCompanyId();
             List<Integer> collect = manangedDeptList.stream().map(Department::getDepartmentId).collect(Collectors.toList());
             List<Map<String, Object>> nameList = new ArrayList<>();
+            long totalCount = 0;
             if (collect.size() > 0) {
-                nameList = reportMapper.getDepartmentDetailByState(collect, companyId);
-            }
-
-            //按日期过滤
-            if (!StringUtils.isEmpty(date)) {
-                nameList = nameList.stream().filter(map->{
-                    return (sdf.format((java.sql.Date)map.get("date"))).equals(date);
-                }).collect(Collectors.toList());
+                //按分页获取
+                Integer pageStart = (pageIndex -1)* pageSize;
+                nameList = reportMapper.getDepartmentDetailByState(collect, companyId, date, pageStart, pageSize);
+                totalCount = reportMapper.getDepartmentDetailByStateCount(collect, companyId, date);
             }
             nameList.forEach(n->{
                 n.put("dateStr",sdf.format((java.sql.Date)n.get("date")));
             });
-
-//            List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
             List<Profession> professions = professionMapper.selectList(new QueryWrapper<Profession>().eq("company_id", curUser.getCompanyId()));
-            for (int index=0;index<nameList.size(); index++) {
-                Map<String, Object> map2 = nameList.get(index);
-                java.sql.Date createDate = (java.sql.Date)map2.get("date");
-                List<Map<String, Object>> list2 = null;
-                String uid = (String)map2.get("id");
-                List<String> uids = new ArrayList<>();
-                uids.add(uid);
-                list2 = reportMapper.getUserReportByDateOrId(createDate.toString(),uids, null);
-                //按项目过滤
-                if (projectId != null) {
-                    list2 = list2.stream().filter(report->(((Integer)report.get("projectId")).equals(projectId))).collect(Collectors.toList());
-                }
-                if (list2.size() == 0) {
-                    //被项目过滤掉了,没有数据。
-                    nameList.remove(index);
-                    index--;
-                } else {
-                    //项目专业进度
-                    for (Map<String, Object> map : list2) {
-                        //获取当前项目的工程专业进度
-                        List<ReportProfessionProgress> progressList = reportProfessionProgressService.list(new QueryWrapper<ReportProfessionProgress>().eq("report_id", (int)map.get("id")));
-                        progressList.stream().forEach(p->{
-                            p.setProfessionName(professions.stream().filter(m->m.getId().equals(p.getProfessionId())).findFirst().get().getName());
-                        });
-                        map.put("professionProgressList", progressList);
-                    }
-
-                    map2.put("data", list2);
-                    double reportTime = 0;
-                    BigDecimal total = new BigDecimal(0);
-                    for (Map<String, Object> m : list2) {
-                        double t = (double) m.get("time");
-                        reportTime += t;
-                        total = total.add((BigDecimal)m.get("cost"));
+            //获取全部的日报:从nameList中提取最大和最小日期
+            String minDateStr = null;
+            String maxDateStr = null;
+            List<String> userIds = new ArrayList<>();
+            if (nameList.size() > 0) {
+                java.sql.Date maxDate = (java.sql.Date)nameList.get(0).get("date");
+                java.sql.Date minDate = (java.sql.Date)nameList.get(nameList.size()-1).get("date");
+                minDateStr = sdf.format(minDate);
+                maxDateStr = sdf.format(maxDate);
+                for (int index=0;index<nameList.size(); index++) {
+                    Map<String, Object> oneItem = nameList.get(index);
+                    String uid = oneItem.get("id").toString();
+                    if (!userIds.contains(uid)) {
+                        userIds.add(uid);
+                    }
+                }
+                List<Map<String, Object>> list2 = reportMapper.getDepartmentAuditList(minDateStr, maxDateStr, userIds, projectId);
+                List<Integer> allReportIds = new ArrayList<>();
+                for (Map<String, Object> map : list2) {
+                    allReportIds.add((Integer)map.get("id"));
+                }
+                List<ReportProfessionProgress> progressList = allReportIds.size() > 0 ? reportProfessionProgressService.list(new QueryWrapper<ReportProfessionProgress>().in("report_id", allReportIds)) : new ArrayList<>();
+                for (int index=0;index<nameList.size(); index++) {
+                    Map<String, Object> map2 = nameList.get(index);
+                    String uid = (String)map2.get("id");
+                    java.sql.Date createDate = (java.sql.Date)map2.get("date");
+                    List<Map<String, Object>> curUserReportList = list2.stream().filter(r->r.get("creatorId").equals(uid) && r.get("createDate").equals(createDate)).collect(Collectors.toList());
+                    if (curUserReportList.size() == 0) {
+                        //被项目过滤掉了,没有数据。
+                        nameList.remove(index);
+                        index--;
+                    } else {
+                        //项目专业进度
+                        for (Map<String, Object> map : curUserReportList) {
+                            //获取当前项目的工程专业进度
+                            List<ReportProfessionProgress> curReportProgressList = progressList.stream().filter(p->p.getReportId().equals((Integer)map.get("id"))).collect(Collectors.toList());
+                            curReportProgressList.stream().forEach(p->{
+                                p.setProfessionName(professions.stream().filter(m->m.getId().equals(p.getProfessionId())).findFirst().get().getName());
+                            });
+                            map.put("professionProgressList", curReportProgressList);
+                        }
+                        map2.put("data", curUserReportList);
+                        double reportTime = 0;
+                        BigDecimal total = new BigDecimal(0);
+                        for (Map<String, Object> m : curUserReportList) {
+                            double t = (double) m.get("time");
+                            reportTime += t;
+                            total = total.add((BigDecimal)m.get("cost"));
+                        }
+                        DecimalFormat df = new DecimalFormat("0.00");
+                        map2.put("reportTime", df.format(reportTime));
+                        map2.put("cost", total);
+                        map2.put("state", curUserReportList.get(0).get("state"));
                     }
-                    DecimalFormat df = new DecimalFormat("0.00");
-                    map2.put("reportTime", df.format(reportTime));
-                    map2.put("cost", total);
-                    map2.put("state", list2.get(0).get("state"));
                 }
-            }
 
-            //设置照片
-            for (Map map : nameList) {
-                List<Map<String, Object>> reportList = (List<Map<String, Object>>)map.get("data");
-                for (Map<String, Object> report : reportList) {
-                    String picStr = (String)report.get("picStr");
-                    if (picStr != null && !"@".equals(picStr)) {
-                        JSONArray array = JSONArray.parseArray(picStr.replaceAll("@", ","));
-                        List<String> picList = new ArrayList<>();
-                        for (int i=0;i<array.size(); i++) {
-                            String picName = array.getString(i);
-                            if (!picName.contains(".")) {
-                                picName += ".jpg";
+                //设置照片
+                for (Map map : nameList) {
+                    List<Map<String, Object>> reportList = (List<Map<String, Object>>)map.get("data");
+                    for (Map<String, Object> report : reportList) {
+                        String picStr = (String)report.get("picStr");
+                        if (picStr != null && !"@".equals(picStr)) {
+                            JSONArray array = JSONArray.parseArray(picStr.replaceAll("@", ","));
+                            List<String> picList = new ArrayList<>();
+                            for (int i=0;i<array.size(); i++) {
+                                String picName = array.getString(i);
+                                if (!picName.contains(".")) {
+                                    picName += ".jpg";
+                                }
+                                picList.add("/upload/" + picName);
                             }
-                            picList.add("/upload/" + picName);
+                            report.put("pics", picList);
+                        }
+                        if (((Integer)report.get("multiWorktime")) == 1) {
+                            //设置多个工时情况下的报告列表
+                            String timeStr = (String)report.get("content");
+                            report.put("worktimeList", JSONArray.parse(timeStr));
                         }
-                        report.put("pics", picList);
-                    }
-                    if (((Integer)report.get("multiWorktime")) == 1) {
-                        //设置多个工时情况下的报告列表
-                        String timeStr = (String)report.get("content");
-                        report.put("worktimeList", JSONArray.parse(timeStr));
                     }
                 }
             }
-            httpRespMsg.data = nameList;
+
+
+            HashMap map = new HashMap();
+            map.put("records", nameList);
+            map.put("total", totalCount);
+            map.put("pageIndex", pageIndex);
+            map.put("pageSize", pageSize);
+            httpRespMsg.setData(map);
         } catch (NullPointerException e) {
+            e.printStackTrace();
             //httpRespMsg.setError("验证失败");
             httpRespMsg.setError(MessageUtils.message("Company.validationError"));
             return httpRespMsg;
@@ -13993,6 +14011,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     String createDate = new SimpleDateFormat("yyyy-MM-dd")
                             .format((java.sql.Date) pagedData.get(i).get("createDate"));
                     pagedData.get(i).put("createDate", createDate);
+                    //计算非加班工时
+                    double workingTime = (Double) pagedData.get(i).get("duration");
+                    double overtime = (Double) pagedData.get(i).get("overtimeHours");
+                    pagedData.get(i).put("normalWorkingTime", workingTime - overtime);
                 }
             }
             
@@ -14045,7 +14067,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             titles.add("项目名称");
             titles.add("项目分类");
             titles.add("子项目");
-            titles.add("工作时长(h)");
+            titles.add("总工作时长(h)");
+            titles.add("正常工作时长(h)");
             titles.add("加班时长(h)");
             titles.add("工作内容");
             titles.add("审核状态");
@@ -14105,10 +14128,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 if (map.get("duration") != null) {
                     double duration = ((Number) map.get("duration")).doubleValue();
                     item.add(df.format(duration));
+                    //计算正常工作时长
+                    double workingTime = (Double) map.get("duration");
+                    double overtime = (Double) map.get("overtimeHours");
+                    item.add(df.format(workingTime - overtime));
                 } else {
                     item.add("-");
+                    item.add("-");
                 }
-                
                 // 加班时长(h)
                 if (map.get("overtimeHours") != null) {
                     double overtimeHours = ((Number) map.get("overtimeHours")).doubleValue();

+ 35 - 19
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -710,7 +710,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         long startTime = startDateTime.toEpochSecond(ZoneOffset.of("+8"));
         endDateTime = endDateTime.withHour(0).withMinute(0).withSecond(0).withNano(0);
         long endTime = endDateTime.toEpochSecond(ZoneOffset.of("+8"));
-        System.out.println("startTime=" + startTime + ",endTime=" + endTime);
+        System.out.println("获取企微考勤 startTime=" + startTime + ",endTime=" + endTime);
 
         int batchCount = 1;
         int batchSize = 1;
@@ -1155,7 +1155,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         endCardTime.withHour(23).withMinute(59).withSecond(0).withNano(0);
                     }
                     BigDecimal bigDecimal = new BigDecimal(Duration.between(startCardTime,endCardTime).toMinutes());
-                    if (showLog) System.out.println("打卡时长(分钟):" + bigDecimal);
+//                     System.out.println("打卡时长(分钟):" + bigDecimal);
                     //开始时间在上午,结束时间在下午,要减去午休时长
                     if (startCardTime.compareTo(LocalTime.parse(baseMorningEnd,df)) <= 0 && endCardTime.compareTo(LocalTime.parse(baseAfternoonStart,df)) >= 0) {
                         //重新计算打卡工时时,需要减去中间午休时间
@@ -1233,7 +1233,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
         if (startTimeTxt.compareTo(baseMorningEnd) <= 0 && endTimeTxt.compareTo(baseAfternoonStart) >= 0) {
             //重新计算实际工作工时时长,需要减去中间午休时间
             time = time - restTime;
-            System.out.println("午休时间:" + restTime + ", 减去后,工作时长=" + bigDecimal);
+            System.out.println("午休时间:" + restTime + ", 减去后,工作时长=" + time);
         }
         //按小时为单位计算
         //超过8小时,进行加班补贴
@@ -1291,10 +1291,10 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         allowance.setAllowance(20);
 //                            System.out.println("非工作日,加班白班全天");
                     } else {
-                        //TODO: 非工作日,加班超过凌晨了,怎么计算
-//                            allowance.setType(1);
-//                            allowance.setOvertimeDuration(time - standWorkHours);
-//                            allowance.setAllowance(30);
+                        //加班超过凌晨了
+                        allowance.setType(1);
+                        allowance.setOvertimeDuration(time - standWorkHours);
+                        allowance.setAllowance(30);
                     }
                 } else if (startTimeTxt.compareTo("16:00") >= 0) {
                     //晚班,计算白班加班的时间
@@ -1311,10 +1311,16 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     }
                 }
             } else if (time > 0) {
-                //非工作日加班了,但是不是全天
-                allowance.setType(-1);
-                allowance.setOvertimeDuration(time);
-                allowance.setAllowance(0);
+                //排除午休外的工作时长超过3小时,补20元
+                if (startTimeTxt.compareTo("12:00") <= 0 && endTimeTxt.compareTo("13:00") >= 0) {
+                    //午休
+                    time -= 1.0;
+                }
+                if (time >= 3.0) {
+                    allowance.setType(0);
+                    allowance.setOvertimeDuration(time);
+                    allowance.setAllowance(20);
+                }
             }
         }
 
@@ -1438,6 +1444,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
 
     //获取考勤打卡记录
     private void reqOnceCardTime(WxCorpInfo corpInfo, long startTime, long endTime, Object[] objects, boolean showLog) throws Exception {
+//        showLog = true;
         DateTimeFormatter mdFormat = DateTimeFormatter.ofPattern("yyyy/M/d");
         String url = GET_CHECKIN_DAYDATA.replace("ACCESS_TOKEN", getCorpAccessToken(corpInfo));
         HttpHeaders headers = new HttpHeaders();
@@ -1498,8 +1505,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     } else if (workRules.size() == 1) {
                         baseMorningStart = DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("work_sec"));
                         if (corpInfo.getCompanyId() == 8607) {
-                            baseMorningEnd = "12:00";
-                            baseAfternoonStart = "12:00";
+                            baseMorningEnd = "13:00";
+                            baseAfternoonStart = "13:00";
                         } else {
                             baseMorningEnd = "12:00";
                             baseAfternoonStart = "13:00";
@@ -1536,7 +1543,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     int regular_work_sec = summary_info.getIntValue("regular_work_sec");//秒
                     ct.setStartTime(DateTimeUtil.getTimeFromSeconds(sTime));
                     ct.setEndTime(DateTimeUtil.getTimeFromSeconds(eTime));
-                    boolean isCrossDay = eTime >= 24 * 3600;//加班至第二天
+                    boolean isCrossDay = regular_work_sec > 0 && eTime >= 24 * 3600;//加班至第二天
                     //下班时间和上班时间不一样,正常应该有regular_work_sec,但是企业微信存在问题,传过来的是0,需要校正
                     if (regular_work_sec == 0 && ct.getEndTime() != null && !ct.getEndTime().equals(ct.getStartTime())) {
                         ct.setEndTime(ct.getStartTime());
@@ -1548,7 +1555,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     ct.setAskLeaveTime(0.0);
                     ct.setWorkHours(0.0);
                     ct.setOutdoorTime(0.0);
-
                     if (isCrossDay) {
                         //直接用cardTime作为工作时长
                         ct.setName(name);
@@ -1802,7 +1808,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                 }
                             }
                         }
-                        if (corpInfo.getCompanyId() == 469 || corpInfo.getCompanyId() == 7 || corpInfo.getCompanyId() == 8607) {
+                        if (corpInfo.getCompanyId() == 469 || corpInfo.getCompanyId() == 7 || corpInfo.getCompanyId() == 8607 || corpInfo.getCompanyId() == 8555) {
                             needRecaculate = true;//赛元微电子,都需要重新计算
                         }
                         double timeDelta = 0;
@@ -1815,7 +1821,12 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                 timeDelta -= restTime;
                             }
                         } else {
-                            timeDelta = ct.getCardTime();
+                            if (ct.getEndTime().compareTo(baseAfternoonStart) >= 0) {
+                                //重新计算工作工时时,需要用打卡总时间减去中间午休时间
+                                timeDelta = ct.getCardTime() - restTime;
+                            } else {
+                                timeDelta = ct.getCardTime();
+                            }
                         }
                         ct.setName(name);
                         //解析请假和外出的情况
@@ -1918,6 +1929,13 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         JSONObject otInfo = jsonObject.getJSONObject("ot_info");
                         Integer s = otInfo.getIntValue("ot_status");
                         Integer duration = otInfo.getInteger("ot_duration");//秒为单位
+                        if (s == 2 && duration == 0) {
+                            //加班时长不足,还是以加班单时长为准
+                            JSONArray array = otInfo.getJSONArray("exception_duration");
+                            if (array != null && array.size() > 0) {
+                                duration = array.getIntValue(0);
+                            }
+                        }
                         ct.setOtStatus(s);
                         //加班
                         double otTime = convertDayTimeToHours(DateTimeUtil.getHoursFromSeconds(duration));
@@ -2094,7 +2112,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         if (corpInfo.getCompanyId() == 8555 || corpInfo.getCompanyId() == 8128) {
                             handleAllowance(item, baseMorningStart, baseMorningEnd, baseAfternoonStart, baseAfternoonEnd, restTime);
                         }
-
                     } else {
                         if (hasTimeRecord) {
                             if (showLog) System.out.println("插入考勤记录"+curUserid+", "+localDate);
@@ -2106,7 +2123,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         } else {
                             //调用打卡详情去获取,弥补外出打卡且时间不在自动同步范围内的情况; 仅对工作日有效
                             if (timeTypeService.isWorkDay(corpInfo.getCompanyId(), localDate, timeType, holidaySettings)) {
-                                System.out.println("=========获取日打卡详情========="+localDate.toString());
                                 User user = userMapper.selectOne(new QueryWrapper<User>().eq("corpwx_userid", curUserid));
                                 if (user != null) {
                                     getUserPunchRecord(corpInfo.getCompanyId(), user.getId(), localDate.atTime(0,0,0),

+ 0 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/util/SplitDateUtil.java

@@ -1,8 +1,5 @@
 package com.management.platform.util;
 
-import org.apache.commons.collections.CollectionUtils;
-import org.ehcache.core.internal.util.CollectionUtil;
-
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/application.yml

@@ -5,6 +5,9 @@ server:
     max-http-form-post-size: -1
     connection-timeout: 18000000
 spring:
+  autoconfigure:
+    exclude:
+      - org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration
   servlet:
     multipart:
       # 配置上传文件的大小设置

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

@@ -3329,22 +3329,5 @@
             AND r.dept_id = #{departmentId}
         </if>
         group by r.dept_id
-        <if test="start != null and size != null">
-            LIMIT #{start}, #{size}
-        </if>
-    </select>
-
-    <!-- 获取部门成本表格数据总数 -->
-    <select id="getTimeCostForTableByDeptCount" resultType="long">
-        select count(distinct r.dept_id)
-        FROM report r
-        WHERE r.company_id = #{companyId}
-        AND r.state = 1
-        <if test="startDate != null and endDate != null">
-            AND r.create_date BETWEEN #{startDate} AND #{endDate}
-        </if>
-        <if test="departmentId != null">
-            AND r.dept_id = #{departmentId}
-        </if>
     </select>
 </mapper>

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

@@ -638,7 +638,7 @@
     </select>
     <!-- 批量获取员工某天的报告 -->
     <select id="getUserReportByDateOrId" resultType="java.util.Map">
-        SELECT a.id, b.project_name AS project, a.working_time AS time, a.content, a.state, a.time_type as timeType, a.creator_id as creatorId, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
+        SELECT a.id,a.project_id as projectId, b.project_name AS project, a.working_time AS time, a.content, a.state, a.time_type as timeType, a.creator_id as creatorId, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
         a.end_time as endTime, d.name as subProjectName,d.code as subProjectCode,a.task_id as taskId, task.name as taskName,
         b.incharger_id as inchargerId,b.project_code as projectCode,
         a.is_overtime as isOvertime,a.progress as progress,audit_dept_managerid as auditDeptManagerid,audit_deptid as auditDeptid,
@@ -966,7 +966,26 @@
             #{deptId}
         </foreach>
         )
+        <if test="date != null and date != ''">
+            AND a.create_date=#{date}
+        </if>
         ORDER BY a.create_date DESC
+        <if test="pageStart != null">
+            limit #{pageStart}, #{pageSize}
+        </if>
+    </select>
+    <select id="getDepartmentDetailByStateCount" resultType="java.lang.Long">
+        SELECT count(distinct a.creator_id, a.create_date)
+        FROM report AS a
+        WHERE a.department_audit_state = 0 and a.state = 0 AND a.company_id=#{companyId}
+        AND a.creator_id in (select id from user where department_id in
+        <foreach collection="departmentIds" item="deptId" open="(" close=")" index="index" separator=",">
+            #{deptId}
+        </foreach>
+        )
+        <if test="date != null and date != ''">
+            AND a.create_date=#{date}
+        </if>
     </select>
 
     <!--导入工时待审核列表-->
@@ -1183,7 +1202,6 @@
     </select>
     <select id="getProWaitingApproveCnt" resultType="java.util.HashMap">
         select count(1) as num, user.dingding_userid as auditorDDId ,user.corpwx_userid as corpwxUserid from report
-                                                                                                                 left join `user` on `user`.id = project_auditor_id
         where state = 0 and project_audit_state = 0 and is_dept_audit = 0
           and report.company_id = #{companyId}
           and `user`.is_active=1
@@ -1191,8 +1209,7 @@
     </select>
     <select id="getDeptWaitingApproveCnt" resultType="java.util.HashMap">
         select COUNT(1) as num, user.dingding_userid as auditorDDId ,user.corpwx_userid as corpwxUserid from report
-                                                                                                                 left join `user` on `user`.id = audit_dept_managerid
-        where state = 0 and department_audit_state = 0 and is_dept_audit = 1
+        where state = 0 and is_dept_audit = 1
           and report.company_id =#{companyId}
           and `user`.is_active=1
         group by audit_dept_managerid
@@ -1911,5 +1928,42 @@
             </foreach>
         </if>
     </select>
-
+    <!-- 获取工程专业版模式下部门待审核的日报列表 -->
+    <select id="getDepartmentAuditList" resultType="java.util.Map">
+        SELECT a.id,a.project_id as projectId, b.project_name AS project, a.working_time AS time, a.content, a.create_date as createDate,
+        a.state, a.time_type as timeType, a.creator_id as creatorId, a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
+        a.end_time as endTime, d.name as subProjectName,d.code as subProjectCode,a.task_id as taskId, task.name as taskName,
+        b.incharger_id as inchargerId,b.project_code as projectCode,
+        a.is_overtime as isOvertime,a.progress as progress,audit_dept_managerid as auditDeptManagerid,audit_deptid as auditDeptid,
+        a.department_audit_state as departmentAuditState, a.stage, a.pic_str as picStr, multi_worktime as multiWorktime
+        , reject_reason as rejectReason, reject_username as rejectUsername, reject_userid as rejectUserid, degree_id as degree_id,report_extra_degree.name as degreeName,
+        department.department_name as auditDeptName, a.is_dept_audit as isDeptAudit, a.project_audit_state as projectAuditState,task_group.name as groupName,a.group_id as groupId, a.custom_data as customData
+        ,u.name as projectAuditorName, a.project_auditor_id as projectAuditorId,dp2.department_name as buDepartmentName, a.overtime_hours as overtimeHours, a.custom_text as customText, dept_manager.name as deptAuditorName,a.evaluate as evaluate,a.report_auto_approve as reportAutoApprove,
+        a.extra_field1 as extraField1,a.extra_field2 as extraField2,a.extra_field3 as extraField3, a.batch_id as batchId,a.sap_service_id as sapServiceId, multi_degr_id as multiDegrId, extra_field4 as extraField4,extra_field5 as extraField5
+        FROM report AS a
+        JOIN project AS b ON a.project_id=b.id
+        left join sub_project as d on d.id = a.sub_project_id
+        left join task on task.id = a.task_id
+        left join report_extra_degree on report_extra_degree.id = a.degree_id
+        left join department on department.department_id = a.audit_deptid
+        left join department dp2 on dp2.department_id = b.bu_id
+        left join user dept_manager on dept_manager.id = a.audit_dept_managerid
+        left join task_group on task_group.id = a.group_id
+        left join user u on u.id = a.project_auditor_id
+        WHERE a.state = 0 and a.department_audit_state = 0
+        <if test="startDate != null and startDate != ''">
+            AND a.create_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != ''">
+            AND a.create_date &lt;= #{endDate}
+        </if>
+        <if test="projectId != null">
+            AND a.project_id=#{projectId}
+        </if>
+        AND a.creator_id in
+        <foreach item="item" collection="userIds" separator="," open="(" close=")" index="">
+            #{item, jdbcType=VARCHAR}
+        </foreach>
+        ORDER BY a.creator_id ASC
+    </select>
 </mapper>