| | |
| | | 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 |
| | |
| | | |
| | | @ApiOperation("获取年度放电任务量统计-管理") |
| | | @GetMapping("planCountWithTotal") |
| | | public Response getPlanCountWithTotal(){ |
| | | return service.getPlanCountWithTotal(); |
| | | public Response getPlanCountWithTotal() { |
| | | int userId = ActionUtil.getUser().getUId().intValue(); |
| | | return service.getPlanCountWithTotal(userId); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | 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; |
| | |
| | | |
| | | @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); |
| | | } |
| | | |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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); |
| | | |
| | | } |
| | | } |
| | |
| | | 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) { |
| | |
| | | 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; |
| | |
| | | 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(); |
| | |
| | | }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); |
| | | |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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(); |
| | |
| | | |
| | | 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; |
| | |
| | | |
| | | @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 |
| | |
| | | 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; |