| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | 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.dto.AlarmDaoFactory; |
| | | import com.whyc.dto.BattCapFactory; |
| | | import com.whyc.dto.InterfaceParam; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.result.AlarmRes; |
| | |
| | | @Autowired |
| | | private BattRealdataService battRealdataService; |
| | | |
| | | @Autowired |
| | | private BattInfService battInfService; |
| | | |
| | | @Autowired |
| | | private BattEnduranceService battEnduranceService; |
| | | |
| | | public Response getBattinf(int pageNum, int pageSize, String interfaceNumber) { |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | //分页信息 |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List list = battInfMapper.selectList(null); |
| | | List list = battInfMapper.selectList((Wrapper<Battinf>) ActionUtil.objeNull); |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1, pageInfo); |
| | | } else { |
| | |
| | | if (flag == 1) { |
| | | //分页信息 |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List list = powerInfMapper.selectList(null); |
| | | List list = powerInfMapper.selectList((Wrapper<PowerInf>) ActionUtil.objeNull); |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1, pageInfo); |
| | | } else { |
| | |
| | | for (PwrdevAlarm p : list) { |
| | | p.setAlarmName(AlarmDaoFactory.getAllAlarmName(p.getAlmType())); |
| | | if (p.getAlmIndex() != 0) { |
| | | p.setAlarmName(p.getAlarmName().replace("N", "第" + p.getAlmIndex() + "路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N", p.getAlmIndex() + "")); |
| | | } |
| | | } |
| | | // PageInfo pageInfo=new PageInfo(list); |
| | |
| | | for (PwrdevAlarmHistory p : list) { |
| | | p.setAlarmName(AlarmDaoFactory.getAllAlarmName(p.getAlmType())); |
| | | if (p.getAlmIndex() != 0) { |
| | | p.setAlarmName(p.getAlarmName().replace("N", "第" + p.getAlmIndex() + "路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N", p.getAlmIndex() + "")); |
| | | } |
| | | } |
| | | PageInfo pageInfo = new PageInfo(list); |
| | |
| | | //先验证 |
| | | int flag = decryptInterface(param.getInterfaceNumber()); |
| | | if (flag == 1) { |
| | | List<PwrdevAcdcdata> powerRts = pwrdevAcdcdataMapper.getPowerRealtime(param.getPowerDeviceIds()); |
| | | List<Fbs9100State> fbs9100States = fbs9100StateMapper.getRealtime(param.getDeviceIds()); |
| | | List<BattRtdata> battRtDatas = battRtdataMapper.getRealtime(param.getStationIds()); |
| | | List<BattRtstate> battRtstates = battRtstateMapper.getRealtime(param.getBattgroupIds()); |
| | | //判断param.getPowerDeviceIds()是否为空,不为空则查询 |
| | | List<PwrdevAcdcdata> powerRts = new ArrayList<>(); |
| | | if (param.getPowerDeviceIds() != null && param.getPowerDeviceIds().size() > 0) { |
| | | powerRts = pwrdevAcdcdataMapper.getPowerRealtime(param.getPowerDeviceIds()); |
| | | } |
| | | List<Fbs9100State> fbs9100States = new ArrayList<>(); |
| | | if (param.getDeviceIds() != null && param.getDeviceIds().size() > 0) { |
| | | fbs9100States = fbs9100StateMapper.getRealtime(param.getDeviceIds()); |
| | | } |
| | | List<BattRtdata> battRtDatas = new ArrayList<>(); |
| | | if (param.getStationIds() != null && param.getStationIds().size() > 0) { |
| | | battRtDatas = battRtdataMapper.getRealtime(param.getStationIds()); |
| | | } |
| | | List<BattRtstate> battRtstates = new ArrayList<>(); |
| | | if (param.getBattgroupIds() != null && param.getBattgroupIds().size() > 0) { |
| | | battRtstates = battRtstateMapper.getRealtime(param.getBattgroupIds()); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("powerRts", powerRts); |
| | | map.put("fbs9100States", fbs9100States); |
| | |
| | | //获取所有第三方码的信息 |
| | | public Response getInterface(int pageNum, int pageSize) { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<Interface> list = interfaceMapper.selectList(null); |
| | | List<Interface> list = interfaceMapper.selectList((Wrapper<Interface>) ActionUtil.objeNull); |
| | | if (list != null && list.size() > 0) { |
| | | for (Interface iface : list) { |
| | | String random = iface.getInterfaceNumber(); |
| | |
| | | } |
| | | |
| | | //生成第三方验证码 |
| | | public Response createInterface(String interfaceName) { |
| | | public Response createInterface(String interfaceName) throws NoSuchAlgorithmException { |
| | | String random = getRandomString(25); |
| | | //rsa加密 |
| | | String encryptRandom = RSAUtil.encrypt(random, RSAUtil.getPublicKey()); |
| | |
| | | UpdateWrapper wrapper = new UpdateWrapper(); |
| | | wrapper.set("enable", enable); |
| | | wrapper.eq("num", num); |
| | | interfaceMapper.update(null, wrapper); |
| | | interfaceMapper.update((Interface) ActionUtil.objeNull, wrapper); |
| | | return new Response().set(1, true, "编辑是否可用"); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //length用户要求产生字符串的长度 |
| | | public static String getRandomString(int length) { |
| | | public static String getRandomString(int length) throws NoSuchAlgorithmException { |
| | | String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; |
| | | //Random random = new Random(); |
| | | SecureRandom random = null; |
| | | try { |
| | | random = SecureRandom.getInstance("SHA1PRNG"); |
| | | } catch (NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); |
| | | |
| | | StringBuffer sb = new StringBuffer(); |
| | | for (int i = 0; i < length; i++) { |
| | | int number = random.nextInt(62); |
| | |
| | | for (PwrdevAlarm p : powerAlarmList) { |
| | | p.setAlarmName(AlarmDaoFactory.getAllAlarmName(p.getAlmType())); |
| | | if (p.getAlmIndex() != 0) { |
| | | p.setAlarmName(p.getAlarmName().replace("N", "第" + p.getAlmIndex() + "路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N", p.getAlmIndex() + "")); |
| | | } |
| | | } |
| | | |
| | |
| | | for (PwrdevAlarm p : powerAlarmList) { |
| | | p.setAlarmName(AlarmDaoFactory.getAllAlarmName(p.getAlmType())); |
| | | if (p.getAlmIndex() != 0) { |
| | | p.setAlarmName(p.getAlarmName().replace("N", "第" + p.getAlmIndex() + "路")); |
| | | p.setAlarmName(p.getAlarmName().replace("N", p.getAlmIndex() + "")); |
| | | } |
| | | } |
| | | map.put("powerAlarmList",powerAlarmList); |
| | |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | boolean bl = fbs9100SetparamService.sendCmdToFBS9100Dev2(opCmd, testCmd != null ? testCmd : 0, devId, battGroupNum); |
| | | Fbs9100Setparam setparam = fbs9100SetparamMapper.serchbyDev_id(devId); |
| | | Fbs9100Setparam setparam = fbs9100SetparamMapper.serchbyDev_id(devId,battGroupNum-1); |
| | | return new Response().setII(1, setparam, bl, bl == true ? "查询成功!" : "设置9100参数失败,请检查网络!"); |
| | | }else{ |
| | | return new Response().set(1, "越权访问"); |
| | |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 1.电池基本信息:电池品牌、电池型号、投入使用时间、标称容量、电池组id |
| | | * 2.运行数据:实际容量、电池组数、负载电流、续航时长 |
| | | */ |
| | | public Response getBattGroupDataList(String stationId, String interfaceNumber) { |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | Map<String, Object> resultMap = new HashMap<>(); |
| | | |
| | | //根据站点查询电池组列表及基础信息 |
| | | List<Battinf> battGroupList = battInfService.getBattListByStatoinId(stationId); |
| | | resultMap.put("basicInfo",battGroupList); |
| | | //根据站点查询运行数据 |
| | | List<BattEndurance> enduranceInfoList = battEnduranceService.getEnduranceInfoByStationId(stationId); |
| | | if(battGroupList.size() != 0 && enduranceInfoList.size() != 0) { //存在电池组且存在电池组的续航信息记录 |
| | | //这里只考虑一个站点只有1台设备. |
| | | BattEndurance battEndurance = enduranceInfoList.get(0); |
| | | //运行数据 |
| | | List<BattEndurance> runDataList = new ArrayList<>(); |
| | | battGroupList.forEach(battinf -> { |
| | | Integer groupIndex = battinf.getGroupIndexInFBSDevice(); |
| | | Float loadCurrFromDis = battinf.getLoadCurrFromDis(); |
| | | Float capStd = battinf.getMonCapStd(); |
| | | |
| | | BattEndurance temp = new BattEndurance(); |
| | | switch (groupIndex) { |
| | | case 0: |
| | | temp.setRealCap(battEndurance.getRealCapGroup1()); |
| | | temp.setNum(0); |
| | | temp.setLoadCurr(String.valueOf(loadCurrFromDis)); |
| | | temp.setEnduranceTheoryTimelong(BattCapFactory.getTheoryTime(loadCurrFromDis, battEndurance.getRealCapGroup1(), capStd)); |
| | | break; |
| | | case 1: |
| | | temp.setRealCap(battEndurance.getRealCapGroup2()); |
| | | temp.setNum(1); |
| | | temp.setLoadCurr(String.valueOf(loadCurrFromDis)); |
| | | temp.setEnduranceTheoryTimelong(BattCapFactory.getTheoryTime(loadCurrFromDis, battEndurance.getRealCapGroup2(), capStd)); |
| | | break; |
| | | case 2: |
| | | temp.setRealCap(battEndurance.getRealCapGroup3()); |
| | | temp.setNum(2); |
| | | temp.setLoadCurr(String.valueOf(loadCurrFromDis)); |
| | | temp.setEnduranceTheoryTimelong(BattCapFactory.getTheoryTime(loadCurrFromDis, battEndurance.getRealCapGroup3(), capStd)); |
| | | break; |
| | | case 3: |
| | | temp.setRealCap(battEndurance.getRealCapGroup4()); |
| | | temp.setNum(3); |
| | | temp.setLoadCurr(String.valueOf(loadCurrFromDis)); |
| | | temp.setEnduranceTheoryTimelong(BattCapFactory.getTheoryTime(loadCurrFromDis, battEndurance.getRealCapGroup4(), capStd)); |
| | | break; |
| | | } |
| | | runDataList.add(temp); |
| | | |
| | | }); |
| | | resultMap.put("runData", runDataList); |
| | | }else{ |
| | | resultMap.put("runData",null); |
| | | } |
| | | return new Response().set(1,resultMap); |
| | | }else{ |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | } |