lxw
2023-05-22 a99200c20a02f14b3f3560d24d6a9b624478d74a
领导层调用应用层接口加userId
6个文件已修改
111 ■■■■ 已修改文件
src/main/java/com/whyc/controller/BattdischargePlanController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/KPIController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattdischargePlanService.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/FaultUploadService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/KPIService.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/webSocket/taskMLeaderWebSocket.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/BattdischargePlanController.java
@@ -1,15 +1,14 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.BattDischargePlanTemp;
import com.whyc.pojo.BattdischargePlan;
import com.whyc.service.BattdischargePlanService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.util.List;
@RestController
@@ -92,8 +91,9 @@
    @ApiOperation("获取年度放电任务量统计-管理")
    @GetMapping("planCountWithTotal")
    public Response getPlanCountWithTotal(){
        return service.getPlanCountWithTotal();
    public Response getPlanCountWithTotal() {
        int userId = ActionUtil.getUser().getUId().intValue();
        return service.getPlanCountWithTotal(userId);
    }
}
src/main/java/com/whyc/controller/KPIController.java
@@ -2,6 +2,7 @@
import com.whyc.dto.Response;
import com.whyc.service.KPIService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,20 +24,23 @@
    @GetMapping("annualDetail")
    @ApiOperation("年度工作考核明细")
    public Response getAnnualDetail(@RequestParam(required = false) Integer limitN){
        return service.getAnnualDetail(limitN);
    public Response getAnnualDetail(@RequestParam(required = false) Integer limitN) {
        int userId = ActionUtil.getUser().getUId().intValue();
        return service.getAnnualDetail(limitN, userId);
    }
    @GetMapping("annualStatisticByGroupName")
    @ApiOperation("年度统计-班组")
    public Response getAnnualStatisticByGroupName(@RequestParam(required = false) Integer limitN){
        return service.getAnnualStatisticByGroupName(limitN);
    public Response getAnnualStatisticByGroupName(@RequestParam(required = false) Integer limitN) {
        int userId = ActionUtil.getUser().getUId().intValue();
        return service.getAnnualStatisticByGroupName(limitN, userId);
    }
    @GetMapping("annualStatisticByGroupNameAndUser")
    @ApiOperation("年度统计-班组和用户")
    public Response getAnnualStatisticByGroupNameAndUser(){
        return service.getAnnualStatisticByGroupNameAndUser();
    public Response getAnnualStatisticByGroupNameAndUser() {
        int userId = ActionUtil.getUser().getUId().intValue();
        return service.getAnnualStatisticByGroupNameAndUser(userId);
    }
}
src/main/java/com/whyc/service/BattdischargePlanService.java
@@ -425,21 +425,21 @@
        int userId = ActionUtil.getUser().getUId().intValue();
        Map<String,Integer> map = new HashMap<>();
        int year = Calendar.getInstance().get(Calendar.YEAR);
        List<BattdischargePlan> planList = mapper.getPlanCount(userId,year);
        List<BattdischargePlan> planList = mapper.getPlanCount(userId, year);
        //总数,已完成数量
        int total = planList.size();
        int finishNum = planList.stream().filter(plan -> plan.getDischargeState() == 2).collect(Collectors.toList()).size();
        map.put("total",total);
        map.put("finishNum",finishNum);
        return new Response().set(1,map);
        map.put("total", total);
        map.put("finishNum", finishNum);
        return new Response().set(1, map);
    }
    public Map<String,Map<String,Integer>> getPlanCount() {
        int userId = ActionUtil.getUser().getUId().intValue();
        Map<String,Map<String,Integer>> resMap = new HashMap<>();
        Map<String,Integer> map = new HashMap<>();
    public Map<String, Map<String, Integer>> getPlanCount(int userId) {
        //int userId = ActionUtil.getUser().getUId().intValue();
        Map<String, Map<String, Integer>> resMap = new HashMap<>();
        Map<String, Integer> map = new HashMap<>();
        int year = Calendar.getInstance().get(Calendar.YEAR);
        List<BattdischargePlan> planList = mapper.getPlanCount(userId,year);
        List<BattdischargePlan> planList = mapper.getPlanCount(userId, year);
        //班组,总数,已完成数量
        Map<String, List<BattdischargePlan>> groupNameListMap = planList.stream().collect(Collectors.groupingBy(BattdischargePlan::getBaojiGroupName));
        Set<String> groupNameSet = groupNameListMap.keySet();
@@ -447,27 +447,27 @@
            List<BattdischargePlan> plans = groupNameListMap.get(groupName);
            int total = plans.size();
            int finishNum = plans.stream().filter(plan -> plan.getDischargeState() == 2).collect(Collectors.toList()).size();
            map.put("total",total);
            map.put("finishNum",finishNum);
            map.put("total", total);
            map.put("finishNum", finishNum);
            resMap.put(groupName,map);
            resMap.put(groupName, map);
        }
        return resMap;
    }
    public Response getPlanCountWithTotal() {
        Map<String,Integer> resMap = new HashMap<>();
        resMap.put("放电任务总数",0);
    public Response getPlanCountWithTotal(int userId) {
        Map<String, Integer> resMap = new HashMap<>();
        resMap.put("放电任务总数", 0);
        int total = 0;
        Map<String, Map<String, Integer>> planCount = getPlanCount();
        Map<String, Map<String, Integer>> planCount = getPlanCount(userId);
        Set<String> groupNameSet = planCount.keySet();
        for (String groupName : groupNameSet) {
            //resMap.put(groupName,planCount.get(groupName).get("finishNum"));
            total = total + planCount.get(groupName).get("total");
        }
        resMap.put("放电任务总数",total);
        return new Response().setII(1,resMap,planCount,null);
        resMap.put("放电任务总数", total);
        return new Response().setII(1, resMap, planCount, null);
    }
}
src/main/java/com/whyc/service/FaultUploadService.java
@@ -325,12 +325,12 @@
        return new Response().set(1,map);
    }
    public Map<String,FaultUpload> getUploadWithGroupName() {
        Map<String,FaultUpload> resMap = new HashMap<>();
    public Map<String, FaultUpload> getUploadWithGroupName(int userId) {
        Map<String, FaultUpload> resMap = new HashMap<>();
        int userId = ActionUtil.getUser().getUId().intValue();
        //int userId = ActionUtil.getUser().getUId().intValue();
        int year = Calendar.getInstance().get(Calendar.YEAR);
        List<FaultUpload> list = mapper.getListWithGroupName(userId,year);
        List<FaultUpload> list = mapper.getListWithGroupName(userId, year);
        Map<String, List<FaultUpload>> userListMap = list.stream().collect(Collectors.groupingBy(FaultUpload::getUploadUserName));
        Set<String> userNameSet = userListMap.keySet();
        for (String userName : userNameSet) {
src/main/java/com/whyc/service/KPIService.java
@@ -1,10 +1,8 @@
package com.whyc.service;
import com.whyc.constant.Com;
import com.whyc.dto.KPIDetail;
import com.whyc.dto.Response;
import com.whyc.pojo.BaoJiGroup;
import com.whyc.pojo.BaoJiGroupUser;
import com.whyc.pojo.FaultUpload;
import com.whyc.pojo.UserInf;
import com.whyc.util.MathUtil;
@@ -29,12 +27,12 @@
    private BaoJiGroupUserService baoJiGroupUserService;
    public List<KPIDetail> getAnnualPersonalDetail() {
    public List<KPIDetail> getAnnualPersonalDetail(int userId) {
        //放电任务,班组
        Map<String, Map<String, Integer>> planCount = planService.getPlanCount();
        Map<String, Map<String, Integer>> planCount = planService.getPlanCount(userId);
        //隐患故障上报,个人
        Map<String, FaultUpload> uploadWithGroupName = uploadService.getUploadWithGroupName();
        Map<String, FaultUpload> uploadWithGroupName = uploadService.getUploadWithGroupName(userId);
        //整理最终需要统计的所有用户及所属的包机组
        List<BaoJiGroup> baoJiGroupUserList = baoJiGroupUserService.getGroupAndUserListWithDischargeFlag();
@@ -106,9 +104,9 @@
            }else{
                faultUploadDivideFloat = (float)faultUploadDivide;
            }
            float faultUploadScore = MathUtil.multiply(faultUploadNumTotal , 0.3f,2) + MathUtil.multiply(faultUploadDivideFloat,70f,2);
            float faultUploadScore = MathUtil.multiply(faultUploadNumTotal, 0.3f, 2) + MathUtil.multiply(faultUploadDivideFloat, 70f, 2);
            float personalScore = MathUtil.multiply(dischargePlanScore,0.4f,2) + MathUtil.multiply(faultUploadScore,0.6f,2);
            float personalScore = MathUtil.multiply(dischargePlanScore, 0.4f, 2) + MathUtil.multiply(faultUploadScore, 0.6f, 2);
            kpiDetail.setPersonalScore(personalScore);
        }
@@ -116,17 +114,17 @@
        return kpiDetails;
    }
    public Response getAnnualDetail(Integer limitN) {
        List<KPIDetail> details = getAnnualPersonalDetail();
        if(limitN !=null){
            details = details.stream().sorted((a,b)->b.getPersonalScore().compareTo(a.getPersonalScore())).limit(limitN).collect(Collectors.toList());
    public Response getAnnualDetail(Integer limitN, int userId) {
        List<KPIDetail> details = getAnnualPersonalDetail(userId);
        if (limitN != null) {
            details = details.stream().sorted((a, b) -> b.getPersonalScore().compareTo(a.getPersonalScore())).limit(limitN).collect(Collectors.toList());
        }
        return new Response().set(1,details);
        return new Response().set(1, details);
    }
    public Response getAnnualStatisticByGroupName(Integer limitN) {
    public Response getAnnualStatisticByGroupName(Integer limitN, int userId) {
        List<KPIDetail> groupDetails = new LinkedList<>();
        List<KPIDetail> details = getAnnualPersonalDetail();
        List<KPIDetail> details = getAnnualPersonalDetail(userId);
        //班组得分
        Map<String, List<KPIDetail>> groupNameListMap = details.stream().collect(Collectors.groupingBy(KPIDetail::getGroupName));
        Set<String> groupNameSet = groupNameListMap.keySet();
@@ -149,9 +147,9 @@
        return new Response().set(1,groupDetails);
    }
    public Response getAnnualStatisticByGroupNameAndUser() {
    public Response getAnnualStatisticByGroupNameAndUser(int userId) {
        List<KPIDetail> groupDetails = new LinkedList<>();
        List<KPIDetail> details = getAnnualPersonalDetail();
        List<KPIDetail> details = getAnnualPersonalDetail(userId);
        //班组得分
        Map<String, List<KPIDetail>> groupNameListMap = details.stream().collect(Collectors.groupingBy(KPIDetail::getGroupName));
        Set<String> groupNameSet = groupNameListMap.keySet();
src/main/java/com/whyc/webSocket/taskMLeaderWebSocket.java
@@ -2,7 +2,6 @@
import com.whyc.config.WebSocketConfig;
import com.whyc.dto.Response;
import com.whyc.pojo.UserInf;
import com.whyc.service.BattdischargePlanService;
import com.whyc.service.FaultUploadService;
import com.whyc.service.KPIService;
@@ -61,9 +60,9 @@
    @OnMessage
    public void onMessage(Session session, String message) {
        UserInf user = (UserInf) this.httpSession.getAttribute("user");
        final int userId = user.getUId().intValue();
        //final int userId = 1041;
        /*UserInf user = (UserInf) this.httpSession.getAttribute("user");
        final int userId = user.getUId().intValue();*/
        final int userId = 1041;
        Integer limitN = Integer.valueOf(message);
        thread = new Thread("Thread_RealTime") {
            @Override
@@ -133,15 +132,15 @@
        res.put("typeYearRes", typeYearRes);
        //年度放电任务统计
        Response disPlanRes = battdischargePlanService.getPlanCountWithTotal();
        Response disPlanRes = battdischargePlanService.getPlanCountWithTotal(userId);
        res.put("disPlanRes", disPlanRes);
        //年度统计-班组 排名
        Response statisticRes = kpiService.getAnnualStatisticByGroupName(limitN);
        Response statisticRes = kpiService.getAnnualStatisticByGroupName(limitN, userId);
        res.put("statisticRes", statisticRes);
        //年度工作考核明细
        Response detailRes = kpiService.getAnnualDetail(limitN);
        Response detailRes = kpiService.getAnnualDetail(limitN, userId);
        res.put("detailRes", detailRes);
        return res;