Ver código fonte

过滤掉停用的人

seyason 2 anos atrás
pai
commit
74f95cf8e8

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

@@ -724,7 +724,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         list.add(unAssignedDept);
 
         //获取公司全部人员
-        List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+        List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 1));
         List<HashMap> userMapList = new ArrayList<>();
         for (User u : userList) {
             HashMap<String, Object> user = new HashMap<String, Object>();
@@ -753,7 +753,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
         list.add(unAssignedDept);
 
         List<User> userList = new ArrayList<>();
-        userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+        userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 1));
 
         List<HashMap> userMapList = new ArrayList<>();
         for (User u : userList) {

+ 36 - 164
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -1007,7 +1007,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         try {
             //根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
             User targetUser = userMapper.selectById(request.getHeader("Token"));
-            Integer companyId =targetUser.getCompanyId();
+            Integer companyId = targetUser.getCompanyId();
             Map<String, Object> resultMap = new HashMap<>();
             //当前用户管理部门
             List<Integer> deptIds=null;
@@ -1034,109 +1034,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
                     }
                 }
             }
-            TimeType timeType = timeTypeMapper.selectById(companyId);
-            if (timeType.getFixMonthcost() == 1) {
-                //每月固定月薪的方式计算,平摊到各个项目中
-                List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null,deptIds);
-                //检查财务表中是否已经导入成本
-                List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
-                List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
-                //计算人员总工时
-                for (Map<String, Object> map : list) {
-                    String creatorId = (String)map.get("creatorId");
-                    double cost = (double)map.get("cost");
-                    User user = userList.stream().filter(u -> u.getId().equals(creatorId)).findFirst().get();
-                    user.setTotalHours(user.getTotalHours() + cost);
-                }
-                //计算实际时薪
-                for (User user : userList) {
-                    if (user.getTotalHours() != 0) {
-                        Optional<Finance> first = financeList.stream().filter(f -> f.getUserId().equals(user.getId())).findFirst();
-                        BigDecimal monthCost = null;
-                        if (first.isPresent()) {
-                            monthCost = first.get().getTotalCost();
-                        } else {
-                            monthCost = user.getMonthCost();
-                        }
-                        user.setCost(monthCost.divide(new BigDecimal(user.getTotalHours()), 6, BigDecimal.ROUND_HALF_UP));
-                    } else {
-                        user.setCost(new BigDecimal(0));
-                    }
-                }
 
-                BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
-                List<Map<String, Object>> retList = new ArrayList<>();
-                List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId).orderByAsc("id"));
-                for (Project p : projectList) {
-                    Map<String, Object> projectMap = new HashMap<>();
-                    projectMap.put("id", p.getId());
-                    projectMap.put("name", p.getProjectName());
-                    //按照项目汇总
-                    double pTotalTime = 0;
-                    BigDecimal pTotalMoney = new BigDecimal(0);
-                    for (Map<String, Object> map : list) {
-                        String creatorId = (String)map.get("creatorId");
-                        int projectId = (int)map.get("projectId");
-                        if (projectId == p.getId()) {
-                            double costTime = (double)map.get("cost");
-                            pTotalTime += costTime;
-                            User curUser = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst().get();
-                            //该人员的成本
-                            pTotalMoney = pTotalMoney.add(curUser.getCost().multiply(new BigDecimal(costTime)));
-                        }
-                    }
-                    if (pTotalTime > 0) {
-                        projectMap.put("cost", pTotalTime);
-                        projectMap.put("costMoney", pTotalMoney);
-                        retList.add(projectMap);
-                        totalMoneyCost = totalMoneyCost.add(pTotalMoney);
-                    }
-                }
-
-                resultMap.put("costList", retList);
-                resultMap.put("totalMoneyCost", totalMoneyCost);
-                if(functionCostList.size()==0){
-                    resultMap.put("totalCostMoney",new BigDecimal(0));
-                    list.forEach(li->{
-                        li.put("costMoney",new BigDecimal(0));
-                    });
-                }
-                if(functionTimeList.size()==0){
-                    retList.forEach(li->{
-                        li.put("cost",0.0);
-                    });
+            List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds,null);
+            BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
+            for (Map<String, Object> map : list) {
+                if (!map.containsKey("cost")) {
+                    map.put("cost", 0);
                 }
-                httpRespMsg.data = resultMap;
-
-            } else {
-                List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds,null);
-                BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
-                for (Map<String, Object> map : list) {
-                    if (!map.containsKey("cost")) {
-                        map.put("cost", 0);
-                    }
-                    if (!map.containsKey("costMoney")) {
-                        map.put("costMoney", 0);
-                    } else {
-                        totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
-                    }
+                if (!map.containsKey("costMoney")) {
+                    map.put("costMoney", 0);
+                } else {
+                    totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
                 }
+            }
 
-                resultMap.put("costList", list);
-                resultMap.put("totalMoneyCost", totalMoneyCost);
-                if(functionCostList.size()==0){
-                    resultMap.put("totalCostMoney",new BigDecimal(0));
-                    list.forEach(li->{
-                        li.put("costMoney",new BigDecimal(0));
-                    });
-                }
-                if(functionTimeList.size()==0){
-                    list.forEach(li->{
-                        li.put("cost",0.0);
-                    });
-                }
-                httpRespMsg.data = resultMap;
+            resultMap.put("costList", list);
+            resultMap.put("totalMoneyCost", totalMoneyCost);
+            if(functionCostList.size()==0){
+                resultMap.put("totalCostMoney",new BigDecimal(0));
+                list.forEach(li->{
+                    li.put("costMoney",new BigDecimal(0));
+                });
             }
+            if(functionTimeList.size()==0){
+                list.forEach(li->{
+                    li.put("cost",0.0);
+                });
+            }
+            httpRespMsg.data = resultMap;
         } catch (NullPointerException e) {
             e.printStackTrace();
             httpRespMsg.setError("验证失败");
@@ -1575,73 +1500,20 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             if (!projectMapper.selectById(projectId).getCompanyId().equals(companyId)) {
                 httpRespMsg.setError("无权查看其他公司的项目详情");
             } else {
-                TimeType timeType = timeTypeMapper.selectById(companyId);
-                if (timeType.getFixMonthcost() == 0) {
-                    Map<String, Object> resultMap = new HashMap<>();
-                    //数据下 非负责部门人员数据不展示
-                    List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId,stateKey, null,deptIds,null);
-                    BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
-                    for (Map<String, Object> map : list) {
-                        if (!map.containsKey("costMoney")) {
-                            map.put("costMoney", 0);
-                        } else {
-                            totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
-                        }
-                    }
-                    resultMap.put("costList", list);
-                    resultMap.put("totalMoneyCost", totalMoneyCost);
-                    httpRespMsg.data = resultMap;
-                } else {
-                    startDate = startDate + "-01";
-                    endDate = endDate + "-31";
-                    List<Map<String, Object>> userMonthTimeCostList = projectMapper.getUserMonthTimeCost(companyId, startDate+"-01", endDate+"-31");
-
-                    List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId,stateKey, null,deptIds,null);
-
-                    //检查财务表中是否已经导入成本
-                    List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
-                    List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
-
-                    //计算实际时薪
-                    for (User user : userList) {
-                        double userTotalTime = 0;
-                        for (int i=0;i<userMonthTimeCostList.size(); i++) {
-                            Map map = userMonthTimeCostList.get(i);
-                            if (map.get("creatorId").equals(user.getId())) {
-                                userTotalTime = (double)map.get("cost");
-                                break;
-                            }
-                        }
-                        if (userTotalTime != 0) {
-                            Optional<Finance> first = financeList.stream().filter(f -> f.getUserId().equals(user.getId())).findFirst();
-                            BigDecimal monthCost = null;
-                            if (first.isPresent()) {
-                                monthCost = first.get().getTotalCost();
-                            } else {
-                                monthCost = user.getMonthCost();
-                            }
-                            user.setCost(monthCost.divide(new BigDecimal(userTotalTime), 6, BigDecimal.ROUND_HALF_UP));
-                        } else {
-                            user.setCost(new BigDecimal(0));
-                        }
-                    }
-
-                    Map<String, Object> resultMap = new HashMap<>();
-                    BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
-
-                    //计算人员在项目上的投入工时
-                    for (Map<String, Object> map : list) {
-                        String creatorId = (String)map.get("creatorId");
-                        double cost = (double)map.get("cost");
-                        User user = userList.stream().filter(u -> u.getId().equals(creatorId)).findFirst().get();
-                        BigDecimal costMoney = user.getCost().multiply(new BigDecimal(cost));
-                        map.put("costMoney", costMoney);
-                        totalMoneyCost = totalMoneyCost.add(costMoney);
+                Map<String, Object> resultMap = new HashMap<>();
+                //数据下 非负责部门人员数据不展示
+                List<Map<String, Object>> list = projectMapper.getProjectCost(companyId,startDate, endDate, projectId,stateKey, null,deptIds,null);
+                BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
+                for (Map<String, Object> map : list) {
+                    if (!map.containsKey("costMoney")) {
+                        map.put("costMoney", 0);
+                    } else {
+                        totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
                     }
-                    resultMap.put("costList", list);
-                    resultMap.put("totalMoneyCost", totalMoneyCost);
-                    httpRespMsg.data = resultMap;
                 }
+                resultMap.put("costList", list);
+                resultMap.put("totalMoneyCost", totalMoneyCost);
+                httpRespMsg.data = resultMap;
             }
         } catch (NullPointerException e) {
             httpRespMsg.setError("验证失败");