cs пре 2 година
родитељ
комит
8ac941ba01

+ 11 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ProjectController.java

@@ -1,6 +1,7 @@
 package com.management.platform.controller;
 
 
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.*;
 import com.management.platform.mapper.*;
@@ -13,11 +14,16 @@ import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddressList;
 import org.springframework.beans.factory.annotation.Autowired;
 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.util.StringUtils;
 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;
+import org.springframework.web.client.RestTemplate;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
@@ -1100,14 +1106,15 @@ public class ProjectController {
 
     //部门参与项目情况表
     @RequestMapping("/deptPartInProjects")
-    public HttpRespMsg deptPartInProjects(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,String startDate,String endDate,Integer departmentId,HttpServletRequest request){
-        return projectService.deptPartInProjects(pageIndex,pageSize,startDate,endDate,departmentId,request);
+    public HttpRespMsg deptPartInProjects(@RequestParam Integer pageIndex, @RequestParam Integer pageSize,String month,Integer departmentId,HttpServletRequest request){
+        return projectService.deptPartInProjects(pageIndex,pageSize,month,departmentId,request);
     }
 
     //导出部门参与项目情况表
     @RequestMapping("/exportDeptPartInProjects")
-    public HttpRespMsg exportDeptPartInProjects(String startDate,String endDate,Integer departmentId,HttpServletRequest request){
-        return projectService.exportDeptPartInProjects(startDate,endDate,departmentId,request);
+    public HttpRespMsg exportDeptPartInProjects(String month,Integer departmentId,HttpServletRequest request){
+        return projectService.exportDeptPartInProjects(month,departmentId,request);
     }
+
 }
 

+ 17 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/TaskCommentController.java

@@ -4,6 +4,9 @@ package com.management.platform.controller;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.management.platform.entity.TaskComment;
 import com.management.platform.entity.User;
+import com.management.platform.entity.WxCorpInfo;
+import com.management.platform.mapper.UserMapper;
+import com.management.platform.mapper.WxCorpInfoMapper;
 import com.management.platform.service.TaskCommentService;
 import com.management.platform.service.UserService;
 import com.management.platform.util.HttpRespMsg;
@@ -33,11 +36,12 @@ public class TaskCommentController {
     private TaskCommentService taskCommentService;
     @Resource
     private UserService userService;
+    @Resource
+    private WxCorpInfoMapper wxCorpInfoMapper;
+    @Resource
+    private UserMapper userMapper;
     /**
      * 添加任务留言
-     * @param taskId 任务id
-     * @param userId 用户id
-     * @param content 内容
      * @return
      */
     @RequestMapping("/add")
@@ -61,6 +65,16 @@ public class TaskCommentController {
     @RequestMapping("getList")
     public HttpRespMsg getList(Integer taskId) {
         List<TaskComment> taskComments = taskCommentService.list(new QueryWrapper<TaskComment>().eq("task_id", taskId));
+        String token = request.getHeader("token");
+        User user = userMapper.selectById(token);
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id",user.getCompanyId()));
+        if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+            for (TaskComment taskComment : taskComments) {
+                String userName = taskComment.getUserName();
+                String content = taskComment.getContent();
+                taskComment.setContent(content.replace("userName", "$userName=" + userName + "$"));
+            }
+        }
         HttpRespMsg msg = new HttpRespMsg();
         msg.data = taskComments;
         return msg;

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

@@ -205,9 +205,9 @@ public interface ProjectService extends IService<Project> {
 
     HttpRespMsg exportEmpMonthHours(String month, HttpServletRequest request, String userId, Integer departmentId,Integer whether);
 
-    HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String startDate,String endDate, Integer departmentId, HttpServletRequest request);
+    HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String month, Integer departmentId, HttpServletRequest request);
 
-    HttpRespMsg exportDeptPartInProjects(String startDate,String endDate, Integer departmentId, HttpServletRequest request);
+    HttpRespMsg exportDeptPartInProjects(String month, Integer departmentId, HttpServletRequest request);
 
 
     HttpRespMsg exportReportTimelinessRateByQuarter(HttpServletRequest request, String year, Integer quarter);

+ 54 - 11
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -7631,7 +7631,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     //部门参与项目情况表
     @Override
-    public HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String startDate,String endDate, Integer departmentId, HttpServletRequest request){
+    public HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String month, Integer departmentId, HttpServletRequest request){
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         User user = userMapper.selectById(request.getHeader("token"));
         List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(),"全部部门参与项目情况表");
@@ -7665,6 +7665,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         if(departmentId!=null){
             branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
         }
+        String startDate = null;
+        String endDate = null;
+        LocalDate time = LocalDate.parse(month, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+        startDate = time.with(TemporalAdjusters.firstDayOfMonth()).toString();
+        endDate = time.with(TemporalAdjusters.lastDayOfMonth()).toString();
         //分页查询数据
         if(pageIndex!=null&&pageSize!=null){
             Integer size=pageSize;
@@ -7678,13 +7683,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             total = maps.size();
         }
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
-        System.err.println(resultList.toString());
         if (resultList.size() > 0){
+            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+            LocalDate localStartDate = LocalDate.parse(startDate, dateTimeFormatter);
+            LocalDate localEndDate = LocalDate.parse(endDate, dateTimeFormatter);
             for (Map<String, Object> stringObjectMap : resultList) {
                 Department department = departmentMapper.selectById(stringObjectMap.get("deptId").toString());
-                if ("0".equals(stringObjectMap.get("deptId").toString())){
-                    stringObjectMap.put("deptName","未分配");
-                }else if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1 && department != null){
+                List<Map<String,Object>> businessTrips = null;
+                if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1 && department != null){
                     stringObjectMap.put("deptName",getWxDepartment(department));
                 }else {
                     stringObjectMap.put("deptName",getSupDepartment(department));
@@ -7694,14 +7700,42 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                 stringObjectMap.put("centerCount",stringObjectMap.get("centerCount")==null?0:stringObjectMap.get("centerCount"));
                 stringObjectMap.put("peopleCount",stringObjectMap.get("peopleCount")==null?0:stringObjectMap.get("peopleCount"));
                 if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)){
-                    List<Map<String,Object>> businessTrips = businessTripMapper.selectBusiness(null, null,stringObjectMap.get("deptId").toString());
+                    businessTrips = businessTripMapper.selectBusiness(null, null,stringObjectMap.get("deptId").toString());
                     Integer dayCount = businessTrips.stream().collect(Collectors.summingInt((b) -> (int)b.get("dayCount")));
                     stringObjectMap.put("tripCount",dayCount==null?0:dayCount);
-                }else{
-                    List<Map<String,Object>> businessTrips = businessTripMapper.selectBusiness(startDate,endDate,stringObjectMap.get("deptId").toString());
+                }else {
+                    businessTrips = businessTripMapper.selectBusiness(startDate,endDate,stringObjectMap.get("deptId").toString());
                     for (Map<String, Object> businessTrip : businessTrips) {
-
+                        String tripStartS = businessTrip.get("startDate").toString();
+                        String tripEndS = businessTrip.get("endDate").toString();
+                        LocalDate tripStart = LocalDate.parse(tripStartS, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                        LocalDate tripEnd = LocalDate.parse(tripEndS, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                        //若出差开始时间不在本月内
+                        if(tripStart.isBefore(localStartDate)){
+                            long day = localStartDate.toEpochDay() - tripStart.toEpochDay();
+                            int dayCount = Integer.parseInt(businessTrip.get("dayCount").toString());
+                            businessTrip.put("dayCount",dayCount-day);
+                        }
+                        //若出差结束时间不在本月内
+                        if (tripEnd.isAfter(localEndDate)){
+                            long day = tripEnd.toEpochDay() - localEndDate.toEpochDay();
+                            int dayCount = Integer.parseInt(businessTrip.get("dayCount").toString());
+                            businessTrip.put("dayCount",dayCount-day);
+                        }
+                        System.err.println(stringObjectMap.get("deptId"));
+                        System.err.print(tripStart);
+                        System.err.println(tripEnd);
+                        System.err.println(businessTrip.get("dayCount"));
                     }
+                    Integer dayCount = businessTrips.stream().collect(Collectors.summingInt((b) -> Integer.parseInt(b.get("dayCount").toString())));
+                    stringObjectMap.put("tripCount",dayCount==null?0:dayCount);
+                }
+                Long peopleCount = null;
+                if (businessTrips!=null && businessTrips.size()!=0){
+                    peopleCount = businessTrips.stream().map((b) -> b.get("userId")).distinct().count();
+                    stringObjectMap.put("tripPeopleCount",peopleCount);
+                }else {
+                    stringObjectMap.put("tripPeopleCount",0);
                 }
             }
         }
@@ -7714,31 +7748,40 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
 
     //导出员工月度工时表
     @Override
-    public HttpRespMsg exportDeptPartInProjects(String startDate,String endDate, Integer departmentId, HttpServletRequest request){
+    public HttpRespMsg exportDeptPartInProjects(String month, Integer departmentId, HttpServletRequest request){
         HttpRespMsg msg=new HttpRespMsg();
         String token = request.getHeader("token");
         User user = userMapper.selectById(token);
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
-        HttpRespMsg httpRespMsg = deptPartInProjects(null, null, startDate, endDate, departmentId, request);
+        HttpRespMsg httpRespMsg = deptPartInProjects(null, null, month, departmentId, request);
         Map<String, Object> data = (Map<String, Object>) (Map<String, Object>) httpRespMsg.data;
         List<Map<String, Object>> resultList = (List<Map<String, Object>>) data.get("resultList");
         List<String> titleList=new ArrayList<>();
         List<List<String>> dataList = new ArrayList<>();
 //        titleList.add("部门名称");
+//        titleList.add("部门人数");
 //        titleList.add("参与的项目的数量");
+//        titleList.add("参与的研究中心的数量");
 //        titleList.add("参与人次");
 //        titleList.add("出差的天数");
+//        titleList.add("出差的人次");
         titleList.add(MessageUtils.message("excel.deptName"));
+        titleList.add(MessageUtils.message("excel.deptHeadCount"));
         titleList.add(MessageUtils.message("excel.joinProCount"));
+        titleList.add(MessageUtils.message("excel.joinCenterCount"));
         titleList.add(MessageUtils.message("excel.joinPeopleCount"));
         titleList.add(MessageUtils.message("excel.tripDays"));
+        titleList.add(MessageUtils.message("excel.tripPeopleCount"));
         dataList.add(titleList);
         for (Map<String, Object> map : resultList) {
             List<String> item=new ArrayList<>();
             item.add(map.get("deptName").toString());
+            item.add(map.get("deptHeadCount").toString());
             item.add(map.get("projectCount").toString());
+            item.add(map.get("centerCount").toString());
             item.add(map.get("peopleCount").toString());
             item.add(map.get("tripCount").toString());
+            item.add(map.get("tripPeopleCount").toString());
             dataList.add(item);
         }
         //生成excel文件导出

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

@@ -9,9 +9,11 @@ import com.management.platform.service.TprogressPaticipatorsService;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.ListUtil;
 import com.management.platform.util.MessageUtils;
+import org.apache.poi.ss.usermodel.Header;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.StringUtils;
+import sun.misc.Request;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages.properties

@@ -682,6 +682,9 @@ excel.deptName = 部门名称
 excel.joinPeopleCount= 参与人次
 excel.tripDays = 出差的天数
 excel.validity = 有效期
+excel.deptHeadCount=部门人数
+excel.joinCenterCount=参与的研究中心的数量
+excel.tripPeopleCount=出差的人次
 #推送
 push.fillIn=您今天的工时填报还未完成
 push.name=屈跃庭

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages_en_US.properties

@@ -682,6 +682,9 @@ excel.deptName = Department name
 excel.joinPeopleCount= Number of participants
 excel.tripDays = Days of business trip
 excel.validity = term of validity
+excel.deptHeadCount=Department headcount
+excel.joinCenterCount=Number of research centers involved
+excel.tripPeopleCount=Number of people on business trip
 #推送
 push.fillIn=Your work hour report for today has not been completed.
 push.name=Qu Yue ting

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

@@ -47,7 +47,7 @@
     </select>
 
     <select id="selectBusiness" resultType="java.util.Map">
-        SELECT `user`.department_id deptId,start_date startDate,end_date endDate,day_count dayCount
+        SELECT `user`.department_id deptId,owner_id userId,start_date startDate,end_date endDate,day_count dayCount
         FROM business_trip
         LEFT JOIN `user`
         on business_trip.owner_id = `user`.id
@@ -56,7 +56,7 @@
             and user.department_id = #{deptId}
         </if>
         <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
-            and business_trip.startDate &lt;= #{endDate} and business_trip.endDate >= #{startDate}
+            and business_trip.start_date &lt;= #{endDate} and business_trip.end_date >= #{startDate}
         </if>
     </select>
 </mapper>

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

@@ -1285,35 +1285,33 @@
     <select id="selectDeptPartInProjects" resultType="java.util.Map">
         SELECT department.department_id deptId,
         department_name deptName,
-        COUNT(`user`.id) deptHeadCount,
+        (select count(user.id) from user where user.id NOT IN (SELECT id FROM `user` WHERE company_id=#{companyId} and inactive_date IS NOT NULL AND inactive_date &lt; #{startDate} AND is_active = 0) AND user.department_id = department.department_id group by user.department_id) deptHeadCount,
         pro.projectCount projectCount,
         pro.centerCount centerCount,
         pcon.peopleCount peopleCount
         FROM department
-        LEFT JOIN `user`
-        ON `user`.department_id = department.department_id
         LEFT JOIN (
-            SELECT report.dept_id,COUNT(DISTINCT(report.project_id)) projectCount,
+            SELECT user.department_id dept_id,COUNT(DISTINCT(report.project_id)) projectCount,
             COUNT(DISTINCT(r.degree_id)) centerCount
             FROM report
             LEFT JOIN report r
             ON report.id = r.id AND r.degree_id != -1
+            LEFT JOIN `user`
+            ON report.creator_id = user.id
             WHERE report.state = 1
-            <if test="startDate!= null and startDate!= '' and endDate!=  null and endDate!= ''" >
-                And report.create_date BETWEEN #{startDate} AND #{endDate}
-            </if>
-            GROUP BY report.dept_id
+            And report.create_date BETWEEN #{startDate} AND #{endDate}
+            GROUP BY dept_id
         ) pro
-        ON pro.dept_id = department.department_id
+        on pro.dept_id = department.department_id
         LEFT JOIN (
             SELECT dept_id,sum(p.con) peopleCount
             FROM (
-            SELECT dept_id,count(DISTINCT project_id)con FROM report
+            SELECT user.department_id dept_id,count(DISTINCT project_id)con FROM report
+            LEFT JOIN `user`
+            ON report.creator_id = user.id
             WHERE report.state = 1
-            <if test="startDate!= null and startDate!= '' and endDate!=  null and endDate!= ''" >
-                And report.create_date BETWEEN #{startDate} AND #{endDate}
-            </if>
-            GROUP BY report.creator_id,report.dept_id
+            And report.create_date BETWEEN #{startDate} AND #{endDate}
+            GROUP BY report.creator_id,dept_id
         ) p  GROUP BY p.dept_id
         ) pcon
         ON pcon.dept_id = department.department_id
@@ -1330,8 +1328,6 @@
                 #{item}
             </foreach>
         </if>
-        GROUP BY department.department_id,projectCount,centerCount,peopleCount
-        ORDER BY projectCount
         <if test="size!=null and start!=null">
             limit #{start},#{size}
         </if>