Browse Source

部门参与项目情况表

cs 2 năm trước cách đây
mục cha
commit
9b088d4930

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

@@ -1093,5 +1093,17 @@ public class ProjectController {
     public HttpRespMsg synchronizationProject(@RequestBody String dataJson){
         return projectService.synchronizationProject(dataJson);
     }
+
+    //部门参与项目情况表
+    @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);
+    }
+
+    //导出部门参与项目情况表
+    @RequestMapping("/exportDeptPartInProjects")
+    public HttpRespMsg exportDeptPartInProjects(String startDate,String endDate,Integer departmentId,HttpServletRequest request){
+        return projectService.exportDeptPartInProjects(startDate,endDate,departmentId,request);
+    }
 }
 

+ 4 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/User.java

@@ -257,4 +257,8 @@ public class User extends Model<User> {
         return this.id;
     }
 
+//    public LocalDateTime getCreateTime() {
+//        if ()
+//        return createTime;
+//    }
 }

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

@@ -132,4 +132,6 @@ public interface ProjectMapper extends BaseMapper<Project> {
     List<Map<String, Object>> getEmpMonthHours(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);
 }

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

@@ -204,4 +204,9 @@ public interface ProjectService extends IService<Project> {
     HttpRespMsg getEmpMonthHours(Integer pageIndex, Integer pageSize, String month,Integer departmentId,String userId,Integer whether,HttpServletRequest request);
 
     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 exportDeptPartInProjects(String startDate,String endDate, Integer departmentId, HttpServletRequest request);
+
 }

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

@@ -1707,8 +1707,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         List<Project> projectList = projectMapper.selectList(queryWrapper);
         List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
         List<ProjectVO> list = new ArrayList<>();
-        //String[] statusNames = {"-","进行中","已完成","已撤销"};
-        String[] statusNames = {"-",MessageUtils.message("excel.onGoing"),MessageUtils.message("excel.complete"),MessageUtils.message("excel.revoke")};
+        //String[] statusNames = {"-","进行中","已完成","已撤销","暂停"};
+        String[] statusNames = {"-",MessageUtils.message("excel.onGoing"),MessageUtils.message("excel.complete"),MessageUtils.message("excel.revoke"),MessageUtils.message("excel.pause")};
         List<List<String>> exportList = new ArrayList<>();
         //String[] titles = {"项目编号", "项目名称", "负责人", "项目金额(元)", "状态","计划开始时间", "计划结束时间", "完成度"};
         String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("excel.charge"), MessageUtils.message("excel.projectAmount")+"(元)", MessageUtils.message("leave.status"),MessageUtils.message("excel.planStart"), MessageUtils.message("excel.planEnd"), MessageUtils.message("excel.degree")};
@@ -7502,4 +7502,119 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         return msg;
     }
 
+    //部门参与项目情况表
+    @Override
+    public HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String startDate,String endDate, Integer departmentId, HttpServletRequest request){
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        User user = userMapper.selectById(request.getHeader("token"));
+        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> userDepartmentList = 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){
+                //获取管理的部门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());
+                collect.addAll(otherCollect);
+                //将该用户管理的所有部门以及部门的子部门id添加到deptIds集合中
+                for (Integer integer : collect) {
+                    List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
+                    deptIds.addAll(branchDepartment);
+                }
+            }
+        }
+        long total  = 0;
+        List<Map<String,Object>> resultList = null;
+        List<Integer> branchDepartment =null;
+        //若用户传入departmentId参数,则查询该部门所有子部门,添加到branchDepartment集合中
+        if(departmentId!=null){
+            branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
+        }
+        //分页查询数据
+        if(pageIndex!=null&&pageSize!=null){
+            Integer size=pageSize;
+            Integer start=(pageIndex-1)*size;
+            resultList = projectMapper.selectDeptPartInProjects(size, start, startDate, endDate, user.getCompanyId(), branchDepartment, deptIds);
+            List<Map<String, Object>> maps = projectMapper.selectDeptPartInProjects(null, null, startDate, endDate, user.getCompanyId(), branchDepartment, deptIds);
+            total = maps.size();
+        }else{
+            resultList = projectMapper.selectDeptPartInProjects(null, null, startDate, endDate, user.getCompanyId(), branchDepartment, deptIds);
+            List<Map<String, Object>> maps = projectMapper.selectDeptPartInProjects(null,null,startDate,endDate,user.getCompanyId(),branchDepartment,deptIds);
+            total = maps.size();
+        }
+        WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
+        if (resultList.size() > 0){
+            for (Map<String, Object> stringObjectMap : resultList) {
+                Department department = departmentMapper.selectById(stringObjectMap.get("departmentId").toString());
+                if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
+                    stringObjectMap.put("deptName",getWxDepartment(department));
+                }else {
+                    stringObjectMap.put("deptName",getSupDepartment(department));
+                }
+                if (stringObjectMap.get("projectCount")==null){
+                    stringObjectMap.put("projectCount",0);
+                }
+                if (stringObjectMap.get("tripCount")==null){
+                    stringObjectMap.put("tripCount",0);
+                }
+                if (stringObjectMap.get("peopleCount")==null){
+                    stringObjectMap.put("peopleCount",0);
+                }
+            }
+        }
+        HashMap<String, Object> result = new HashMap<>();
+        result.put("resultList",resultList);
+        result.put("total",total);
+        httpRespMsg.data = result;
+        return  httpRespMsg;
+    }
+
+    //导出员工月度工时表
+    @Override
+    public HttpRespMsg exportDeptPartInProjects(String startDate,String endDate, 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);
+        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(MessageUtils.message("excel.deptName"));
+        titleList.add(MessageUtils.message("excel.joinProCount"));
+        titleList.add(MessageUtils.message("excel.joinPeopleCount"));
+        titleList.add(MessageUtils.message("excel.tripDays"));
+        dataList.add(titleList);
+        for (Map<String, Object> map : resultList) {
+            List<String> item=new ArrayList<>();
+            item.add(map.get("deptName").toString());
+            item.add(map.get("projectCount").toString());
+            item.add(map.get("peopleCount").toString());
+            item.add(map.get("tripCount").toString());
+            dataList.add(item);
+        }
+        //生成excel文件导出
+        //String fileName = "部门参与项目情况表"+System.currentTimeMillis();
+        String fileName = MessageUtils.message("fileName.deptJoinPro")+System.currentTimeMillis();
+        try {
+            return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,fileName , dataList, path);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return msg;
+    }
+
 }

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

@@ -525,6 +525,7 @@ fileName.dailyManHour=人员每日工时统计_{0}至{1}
 fileName.perNoFill=未填人员统计_
 fileName.laborHour=工时对比
 fileName.monthWork=月度工时表
+fileName.deptJoinPro=部门参与项目情况表
 #excel
 excel.publicProject=是否为公共项目
 excel.projectName=项目名称必填
@@ -671,6 +672,10 @@ excel.standard=标准工时
 excel.actual=实际工时
 excel.leave=请假工时
 excel.workWeather=是否满足工时
+excel.joinProCount = 参与的项目的数量
+excel.deptName = 部门名称
+excel.joinPeopleCount= 参与人次
+excel.tripDays = 出差的天数
 #推送
 push.fillIn=您今天的工时填报还未完成
 push.name=屈跃庭

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

@@ -525,6 +525,7 @@ fileName.dailyManHour=Daily man hour statistics_ {0} to {1}
 fileName.perNoFill=Personnel statistics not filled_
 fileName.laborHour=Labor hour comparison
 fileName.monthWork=Monthly man hour table
+fileName.deptJoinPro=Department Participation in Projects
 #excel
 excel.publicProject=Whether it is a public project
 excel.projectName=Project name is required
@@ -671,6 +672,10 @@ excel.standard=Standard working hours
 excel.actual=Actual working time
 excel.leave=Time of leave
 excel.workWeather=Whether the working hours are met
+excel.joinProCount = Number of projects involved
+excel.deptName = Department name
+excel.joinPeopleCount= Number of participants
+excel.tripDays = Days of business trip
 #推送
 push.fillIn=Your work hour report for today has not been completed.
 push.name=Qu Yue ting

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

@@ -1276,4 +1276,61 @@
         group by us.id
         order  by us.department_id)as total
     </select>
+
+    <!--    分页查询部门参与项目情况-->
+    <select id="selectDeptPartInProjects" resultType="java.util.Map">
+        SELECT department.department_id AS departmentId,
+        department.department_name AS deptName,
+        u.projectCount,
+        u.peopleCount,
+        u.tripCount
+        from department
+        left JOIN (
+        SELECT `user`.department_id AS departmentId,
+        project.create_date,
+        COUNT(DISTINCT(project.id)) AS projectCount,
+        COUNT(`user`.id) AS peopleCount,
+        (select COUNT(DISTINCT(business_trip.id)) from business_trip where owner_id = user.id) AS tripCount
+        from  `user`
+        LEFT JOIN participation ON `user`.id = participation.user_id
+        LEFT JOIN project ON project.id = participation.project_id
+        WHERE user.company_id = #{companyId}
+        <if test="branchDepartment!=null and branchDepartment.size()>0">
+            and user.department_id in
+            <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and user.department_id in
+            <foreach collection="deptIds" open="(" item="item" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        <if test="startDate!= null and startDate!= ''" >
+            and project.create_date &gt;= #{startDate}
+        </if>
+        <if test="endDate!= null and endDate!= ''">
+            and project.create_date &lt;= #{endDate}
+        </if>
+        GROUP BY `user`.department_id
+        ) u ON department.department_id = u.departmentId
+        WHERE department.company_id = #{companyId}
+        <if test="branchDepartment!=null and branchDepartment.size()>0">
+            and department.department_id in
+            <foreach collection="branchDepartment" open="(" close=")" separator="," item="item">
+                #{item}
+            </foreach>
+        </if>
+        <if test="deptIds!=null and deptIds.size()>0">
+            and department.department_id in
+            <foreach collection="deptIds" open="(" item="item" close=")" separator=",">
+                #{item}
+            </foreach>
+        </if>
+        ORDER BY u.projectCount,u.peopleCount
+        <if test="size!=null and start!=null">
+            limit #{start},#{size}
+        </if>
+    </select>
 </mapper>