| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.DeviceConstant; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.paramter.FbsStatePar; |
| | | import com.whyc.dto.result.DischargeState; |
| | | import com.whyc.mapper.BattInfMapper; |
| | | import com.whyc.mapper.BattRtstateMapper; |
| | | import com.whyc.mapper.Fbs9100StateMapper; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.pojo.Fbs9100State; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class Fbs9100StateService { |
| | |
| | | private Fbs9100StateMapper mapper; |
| | | @Autowired |
| | | private Fbs9100SetparamService service; |
| | | |
| | | @Autowired(required = false) |
| | | private BattInfMapper binfMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private BattRtstateMapper rtstateMapper; |
| | | @Autowired(required = false) |
| | | |
| | | private Fbs9600StateService fbs9600StateService; |
| | | @Autowired(required = false) |
| | | |
| | | private Ld9StateService ld9StateService; |
| | | |
| | | //开关状态 |
| | | @Transactional |
| | |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 这个是按照设备id来统计的,一拖二的设备有两个设备id,被看作两个设备,弃用 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Deprecated |
| | | public Response getBTSEquipStatus(int userId){ |
| | | |
| | | Response response = new Response(); |
| | |
| | | response.setCode(0); |
| | | return response; |
| | | }*/ |
| | | QueryWrapper<Fbs9100State> wrapper = Wrappers.query(); |
| | | /*QueryWrapper<Fbs9100State> wrapper = Wrappers.query(); |
| | | wrapper.select("record_datetime", "dev_workstate"); |
| | | List<Fbs9100State> fbs9100StateList = mapper.selectList(wrapper); |
| | | List<Fbs9100State> fbs9100StateList = mapper.selectList(wrapper);*/ |
| | | List<Fbs9100State> fbs9100StateList = mapper.getListWithoutZJDYBTSE2(userId); |
| | | //首先查看是否通讯故障,时间大于1分钟为通讯故障 |
| | | for (int i = 0; i < fbs9100StateList.size(); i++) { |
| | | Calendar instance = Calendar.getInstance(); |
| | |
| | | resultMap.put("预充电数量", resultMap.get("预充电数量") + 1); |
| | | break; |
| | | case DeviceConstant.DEV_NUCLEAR_CAP: |
| | | resultMap.put("核容数量", resultMap.get("核容测试数量") + 1); |
| | | resultMap.put("核容测试数量", resultMap.get("核容测试数量") + 1); |
| | | break; |
| | | case DeviceConstant.DEV_RES_TEST: |
| | | resultMap.put("内阻测试数量", resultMap.get("内阻测试数量") + 1); |
| | |
| | | } |
| | | } |
| | | |
| | | //管理员首页:站点状态信息 |
| | | public Response getSateAnalysis(int userId) { |
| | | return new Response().set(1); |
| | | /** |
| | | * 这个是按照设备ip来统计的. |
| | | * 通讯故障>核容放电>充电>内阻>浮充, |
| | | * 如果一拖二的设备,有两个不同状态,实现状态优先级覆盖 |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | public Response getBTSEquipStatus2(int userId){ |
| | | |
| | | Response response = new Response(); |
| | | try { |
| | | Map<String, Integer> resultMap = new HashMap<>(); |
| | | resultMap.put("在线浮充数量", 0); |
| | | resultMap.put("预充电数量", 0); |
| | | resultMap.put("核容测试数量", 0); |
| | | resultMap.put("内阻测试数量", 0); |
| | | resultMap.put("通讯故障数量", 0); |
| | | |
| | | List<Fbs9100State> fbs9100StateList = mapper.getListWithoutZJDYBTSE2(userId); |
| | | Map<String, List<Fbs9100State>> deviceMap = fbs9100StateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevIp)); |
| | | Set<String> deviceSet = deviceMap.keySet(); |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.MINUTE, -1); |
| | | Date time = instance.getTime(); |
| | | for (String deviceIp : deviceSet) { |
| | | List<Fbs9100State> fbs9100States = deviceMap.get(deviceIp); |
| | | List<Integer> workStateList = fbs9100States.stream().map(Fbs9100State::getDevWorkstate).collect(Collectors.toList()); |
| | | Map<Integer, List<Integer>> workStateMap = workStateList.stream().collect(Collectors.groupingBy(Integer::intValue)); |
| | | Set<Integer> workStateSet = workStateMap.keySet(); |
| | | boolean commError = false; |
| | | for (Fbs9100State state : fbs9100States) { |
| | | if (time.compareTo(DateUtil.YYYY_MM_DD_HH_MM_SS.parse(state.getRecordDatetime())) > 0) { |
| | | resultMap.put("通讯故障数量", resultMap.get("通讯故障数量") + 1); |
| | | commError = true; |
| | | break; |
| | | } |
| | | } |
| | | //不存在通讯故障,则需要再判断优先级覆盖 |
| | | if(!commError){ |
| | | if(workStateSet.contains(DeviceConstant.DEV_NUCLEAR_CAP)) { |
| | | resultMap.put("核容测试数量", resultMap.get("核容测试数量") + 1); |
| | | } |
| | | else if(workStateSet.contains(DeviceConstant.DEV_PRE_CHARGE)) { |
| | | resultMap.put("预充电数量", resultMap.get("预充电数量") + 1); |
| | | } |
| | | else if(workStateSet.contains(DeviceConstant.DEV_RES_TEST)) { |
| | | resultMap.put("内阻测试数量", resultMap.get("内阻测试数量") + 1); |
| | | } |
| | | else if(workStateSet.contains(DeviceConstant.DEV_ONLINE_CHARGE)) { |
| | | resultMap.put("在线浮充数量", resultMap.get("在线浮充数量") + 1); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | /*//首先查看是否通讯故障,时间大于1分钟为通讯故障 |
| | | for (int i = 0; i < fbs9100StateList.size(); i++) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.MINUTE, -1); |
| | | Date time = instance.getTime(); |
| | | if (time.compareTo(DateUtil.YYYY_MM_DD_HH_MM_SS.parse(fbs9100StateList.get(i).getRecordDatetime())) > 0) { |
| | | resultMap.put("通讯故障数量", resultMap.get("通讯故障数量") + 1); |
| | | } else { |
| | | switch (fbs9100StateList.get(i).getDevWorkstate()) { |
| | | case DeviceConstant.DEV_ONLINE_CHARGE: |
| | | resultMap.put("在线浮充数量", resultMap.get("在线浮充数量") + 1); |
| | | break; |
| | | case DeviceConstant.DEV_PRE_CHARGE: |
| | | resultMap.put("预充电数量", resultMap.get("预充电数量") + 1); |
| | | break; |
| | | case DeviceConstant.DEV_NUCLEAR_CAP: |
| | | resultMap.put("核容测试数量", resultMap.get("核容测试数量") + 1); |
| | | break; |
| | | case DeviceConstant.DEV_RES_TEST: |
| | | resultMap.put("内阻测试数量", resultMap.get("内阻测试数量") + 1); |
| | | break; |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | return response.setII(1, true, resultMap, null); |
| | | } catch (Exception e) { |
| | | return response.set(1, false, "发生异常:" + e.getCause()); |
| | | } |
| | | } |
| | | public List<Fbs9100State> getStateList(int userId) { |
| | | List<Fbs9100State> list = mapper.getStateList(userId); |
| | | return list; |
| | | } |
| | | |
| | | //首页上点击停电站 |
| | | public List<Battinf> searchPowerOff(String uId) { |
| | | List<Battinf> list = mapper.searchPowerOff(uId); |
| | | return list; |
| | | } |
| | | |
| | | //首页上点击核容放电站 |
| | | public List<Battinf> searchCheckCapDischarge(String uId) { |
| | | List<Battinf> list = mapper.searchCheckCapDischarge(uId); |
| | | return list; |
| | | } |
| | | |
| | | //今日放电站点统计 |
| | | public Response getChargeStaticToday(int userId) { |
| | | try { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<DischargeState> list = mapper.getChargeStaticToday(userId); |
| | | Map<String, Object> stateMap = new HashMap<>(); |
| | | Map<String, Object> stateNumMap = new HashMap<>(); |
| | | stateNumMap.put("state2", 0); |
| | | stateNumMap.put("state3", 0); |
| | | stateMap.put("state2", new ArrayList<>()); |
| | | stateMap.put("state3", new ArrayList<>()); |
| | | Map<Integer, List<DischargeState>> stateDisMap = list.stream().collect(Collectors.groupingBy(DischargeState::getDevWorkstate)); |
| | | for (Integer workState : stateDisMap.keySet()) { |
| | | if (workState == 2 || workState == 3) { |
| | | stateNumMap.put("state" + workState, stateDisMap.get(workState).size()); |
| | | List<DischargeState> worklist = stateDisMap.get(workState); |
| | | stateMap.put("state" + workState, worklist); |
| | | } |
| | | } |
| | | map.put("stateNumMap", stateNumMap); |
| | | map.put("stateMap", stateMap); |
| | | map.put("nowTime", ActionUtil.sdf.format(new Date())); |
| | | return new Response().setII(1, true, map, "今日放电站点统计"); |
| | | } catch (Exception e) { |
| | | return new Response().set(1, false, "出现异常" + e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | //实时停电放电 |
| | | public int getJcAnalysis(int userId) { |
| | | int jcdisNum = mapper.getJcAnalysis(userId); |
| | | return jcdisNum; |
| | | } |
| | | |
| | | public Response getFbsState(FbsStatePar fbsStatePar) { |
| | | Map<String, Response> res=new HashMap<>(); |
| | | //查询fbs9100信息 |
| | | Response f9100stateRes = searchByCondition(fbsStatePar.getPageNum(),fbsStatePar.getPageSize(),fbsStatePar.getDevErrcommcount(),fbsStatePar.getUserId()); |
| | | res.put("f9100state",f9100stateRes); |
| | | |
| | | Response f9600StateRes = fbs9600StateService.searchByCondition(fbsStatePar.getPageNum(),fbsStatePar.getPageSize(),fbsStatePar.getDevErrcommcount(),fbsStatePar.getUserId()); |
| | | res.put("f9600state",f9600StateRes); |
| | | |
| | | Response ld9stateRes = ld9StateService.searchByCondition(fbsStatePar.getPageNum(),fbsStatePar.getPageSize(),fbsStatePar.getDevErrcommcount(),fbsStatePar.getUserId()); |
| | | res.put("ld9state",ld9stateRes); |
| | | return new Response().set(1, res); |
| | | } |
| | | } |