Browse Source

Merge branch 'master' of http://47.100.37.243:10080/wutt/manHourHousekeeper

Lijy 2 years ago
parent
commit
e6eb03094c

+ 23 - 101
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -5236,7 +5236,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     public HttpRespMsg getTimeCostByCategory(String startDate, String endDate, String userId, HttpServletRequest request) {
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         try {
-            //根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
             User targetUser = userMapper.selectById(request.getHeader("Token"));
             Integer companyId =targetUser.getCompanyId();
             Map<String, Object> resultMap = new HashMap<>();
@@ -5266,110 +5265,33 @@ 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<ProjectCategory> projectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", companyId).orderByAsc("id"));
-                for (ProjectCategory pc : projectCategoryList) {
-                    Map<String, Object> projectCategoryMap = new HashMap<>();
-                    projectCategoryMap.put("id", pc.getId());
-                    projectCategoryMap.put("name", pc.getName());
-                    //按照项目分类汇总
-                    double pTotalTime = 0;
-                    BigDecimal pTotalMoney = new BigDecimal(0);
-                    for (Map<String, Object> map : list) {
-                        String creatorId = (String)map.get("creatorId");
-                        String projectCategoryName =StringUtils.isEmpty( (String) map.get("categoryName"))?MessageUtils.message("excel.unclassified"): (String) map.get("categoryName");
-                        if (projectCategoryName.equals(pc.getName())) {
-                            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) {
-                        projectCategoryMap.put("cost", pTotalTime);
-                        projectCategoryMap.put("costMoney", pTotalMoney);
-                        retList.add(projectCategoryMap);
-                        totalMoneyCost = totalMoneyCost.add(pTotalMoney);
-                    }
-                }
-
-                resultMap.put("costList", retList);
-                resultMap.put("totalMoneyCost", totalMoneyCost);
-                if(functionCostList.size()==0){
-                    resultMap.put("totalCostMoney",new BigDecimal(0));
-                    retList.forEach(li->{
-                        li.put("costMoney",new BigDecimal(0));
-                    });
-                }
-                if(functionTimeList.size()==0){
-                    retList.forEach(li->{
-                        li.put("cost",0.0);
-                    });
-                }
-                httpRespMsg.data = resultMap;
-
-            } else {
-                List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, null, userId,deptIds);
-                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"));
-                    }
-                }
-
-                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));
-                    });
+            List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, null, userId,deptIds);
+            BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
+            for (Map<String, Object> map : list) {
+                if (!map.containsKey("cost")) {
+                    map.put("cost", 0);
                 }
-                if(functionTimeList.size()==0){
-                    list.forEach(li->{
-                        li.put("cost",0.0);
-                    });
+                if (!map.containsKey("costMoney")) {
+                    map.put("costMoney", 0);
+                } else {
+                    totalMoneyCost = totalMoneyCost.add((BigDecimal)map.get("costMoney"));
                 }
-                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) {
             //httpRespMsg.setError("验证失败");
             httpRespMsg.setError(MessageUtils.message("access.verificationError"));

+ 3 - 5
fhKeeper/formulahousekeeper/timesheet/src/views/project/cost.vue

@@ -972,13 +972,11 @@
                             }
                         } 
                         else {
-                            // list = res.data
-                            // this.allListData = res.data
-                            this.total = this.allListData.list.length
-                            list = this.allListData.list.slice(0+50*(this.page-1),49+50*(this.page-1))
+                            //自定义列表:data:{cost:3, costMoney:222}
+                            this.total = this.allListData.length
+                            list = this.allListData.slice(0+50*(this.page-1),49+50*(this.page-1))
                             
                             for(var i in list) {
-                                // console.log(list[i].name, list[i].costMoney, list[i].cost)
                                 xList.push(list[i].name);
                                 let item = {
                                     "value": this.yAxisValue==0?list[i].costMoney:list[i].cost,