| | |
| | | |
| | | 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.mapper.*; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.MessageUtils; |
| | | import com.whyc.util.RSAUtil; |
| | | import com.whyc.util.SubTablePageInfoUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.ServletContext; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | @Autowired(required = false) |
| | | private InterfaceMapper interfaceMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private BattMapInformationMapper mapMapper; |
| | | |
| | | @Autowired |
| | | private Fbs9100SetparamService fbs9100SetparamService; |
| | | |
| | | @Autowired(required = false) |
| | | private Fbs9100SetparamMapper fbs9100SetparamMapper; |
| | | |
| | | @Autowired |
| | | private SubTablePageInfoUtils subTablePageInfoUtils; |
| | | |
| | | @Autowired |
| | | private BattRealdataService battRealdataService; |
| | | |
| | | public Response getBattinf(int pageNum, int pageSize, String interfaceNumber) { |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | |
| | | |
| | | //电池告警实时查询-websocket使用 |
| | | @Transactional |
| | | public Response getBattAlarm(List battgroupIds, String interfaceNumber) { |
| | | public Response getBattAlarm(List battgroupIds, String interfaceNumber, String lang) { |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | |
| | | for (AlarmRes a : list) { |
| | | List<BattalarmData> l = a.getAdatas(); |
| | | for (BattalarmData adata : l) { |
| | | adata.setAlmSignalIdName(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId())); |
| | | adata.setAlmLevelName(AlarmDaoFactory.getAlarmType(adata.getAlmLevel())); |
| | | adata.setAlmSignalIdName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId()), lang)); |
| | | adata.setAlmLevelName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmType(adata.getAlmLevel()), lang)); |
| | | } |
| | | } |
| | | // PageInfo<AlarmRes> pinfo=new PageInfo<AlarmRes>(list); |
| | |
| | | //电池告警历史查询 |
| | | @Transactional |
| | | public Response getBattAlarmHistory(List battgroupIds, String interfaceNumber, int pageNum, int pageSize) { |
| | | String lang = ActionUtil.getLang(); |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | |
| | | for (AlarmRes a : list) { |
| | | List<BattalarmData> l = a.getAdatas(); |
| | | for (BattalarmData adata : l) { |
| | | adata.setAlmSignalIdName(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId())); |
| | | adata.setAlmLevelName(AlarmDaoFactory.getAlarmType(adata.getAlmLevel())); |
| | | adata.setAlmSignalIdName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId()), lang)); |
| | | adata.setAlmLevelName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmType(adata.getAlmLevel()), lang)); |
| | | } |
| | | } |
| | | PageInfo<AlarmRes> pageInfo = new PageInfo<AlarmRes>(list); |
| | |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | //电池告警历史查询 |
| | | @Transactional |
| | | public Response getBattAlarmHistory2(InterfaceParam param, String interfaceNumber, int pageNum, int pageSize) throws ParseException { |
| | | String lang = ActionUtil.getLang(); |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | PageInfo<Object> pageInfo = subTablePageInfoUtils.getPageInfo(pageNum, pageSize, param.getStartTime(), param.getEndTime(), |
| | | "db_alarm", "tb_battalarm_data_history", param); |
| | | List<Object> list = pageInfo.getList(); |
| | | for (Object obj : list) { |
| | | AlarmRes a = (AlarmRes) obj; |
| | | List<BattalarmData> l = a.getAdatas(); |
| | | for (BattalarmData adata : l) { |
| | | adata.setAlmSignalIdName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId()), lang)); |
| | | adata.setAlmLevelName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmType(adata.getAlmLevel()), lang)); |
| | | } |
| | | } |
| | | return new Response().set(1, pageInfo); |
| | | } else { |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | |
| | | //电源告警历史查询 |
| | | @Transactional |
| | |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List list = devalarmDataHistoryMapper.getDevAlarmHistory(deviceIds); |
| | | PageInfo pageInfo = new PageInfo(list); |
| | | return new Response().set(1, pageInfo); |
| | | } else { |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | |
| | | } |
| | | |
| | | public Response getDevAlarmHistory2(InterfaceParam param, String interfaceNumber, int pageNum, int pageSize) throws ParseException { |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | PageInfo<Object> pageInfo = subTablePageInfoUtils.getPageInfo(pageNum, pageSize, param.getStartTime(), param.getEndTime(), |
| | | "db_alarm", "tb_devalarm_data_history", param); |
| | | return new Response().set(1, pageInfo); |
| | | } else { |
| | | return new Response().set(1, "越权访问"); |
| | |
| | | } |
| | | |
| | | |
| | | public Response getAlarmDiffMap(String interfaceNumber) { |
| | | public Response getAlarmDiffMap(String interfaceNumber, String lang) { |
| | | //先验证 |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | |
| | | ServletContext application = ActionUtil.getApplication(); |
| | | Map<String, Object> alarmMap = (Map<String, Object>) application.getAttribute("alarmMap"); |
| | | //获取当前的告警列表 |
| | | Map<String, Object> alarmMapNow = getAlarmMap(); |
| | | Map<String, Object> alarmMapNow = getAlarmMap(lang); |
| | | |
| | | List<BattalarmData> battAlarmList = (List<BattalarmData>) alarmMap.get("battAlarmList"); |
| | | List<DevalarmData> devAlarmList = (List<DevalarmData>) alarmMap.get("devAlarmList"); |
| | |
| | | } |
| | | } |
| | | |
| | | public Map<String, Object> getAlarmMap() { |
| | | public Map<String, Object> getAlarmMap(String lang) { |
| | | List<BattalarmData> battAlarmList = battalarmDataMapper.getBattAlarm2(); |
| | | for (BattalarmData adata : battAlarmList) { |
| | | adata.setAlmSignalIdName(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId())); |
| | | adata.setAlmLevelName(AlarmDaoFactory.getAlarmType(adata.getAlmLevel())); |
| | | adata.setAlmSignalIdName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId()), lang)); |
| | | adata.setAlmLevelName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmType(adata.getAlmLevel()), lang)); |
| | | } |
| | | |
| | | List devAlarmList = devalarmDataMapper.getDevAlarm2(); |
| | |
| | | } |
| | | |
| | | public Response getRealTimeAlarm(InterfaceParam param) { |
| | | String lang = ActionUtil.getLang(); |
| | | int flag = decryptInterface(param.getInterfaceNumber()); |
| | | if (flag == 1) { |
| | | Map<String,List> map = new HashMap<>(); |
| | |
| | | for (AlarmRes a : battAlarmList) { |
| | | List<BattalarmData> l = a.getAdatas(); |
| | | for (BattalarmData adata : l) { |
| | | adata.setAlmSignalIdName(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId())); |
| | | adata.setAlmLevelName(AlarmDaoFactory.getAlarmType(adata.getAlmLevel())); |
| | | adata.setAlmSignalIdName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmName(adata.getAlmSignalId()), lang)); |
| | | adata.setAlmLevelName(MessageUtils.getMessageSocket(AlarmDaoFactory.getAlarmType(adata.getAlmLevel()), lang)); |
| | | } |
| | | } |
| | | map.put("battAlarmList",battAlarmList); |
| | |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | public Response getBattStationInfoByStationId(String stationId, String interfaceNumber) { |
| | | int flag = decryptInterface(interfaceNumber); |
| | | //int flag = 1; |
| | | if (flag == 1) { |
| | | QueryWrapper<Battinf> query = Wrappers.query(); |
| | | query.eq("StationId", stationId).last(" limit 1"); |
| | | Battinf battinf = battInfMapper.selectOne(query); |
| | | |
| | | QueryWrapper<BattMapInformation> mapQuery = Wrappers.query(); |
| | | mapQuery.select("longitude", "latitude").eq("stationId", stationId).last(" limit 1"); |
| | | BattMapInformation mapInfo = mapMapper.selectOne(mapQuery); |
| | | if (mapInfo != null) { |
| | | battinf.setLongitude(mapInfo.getLongitude()); |
| | | battinf.setLatitude(mapInfo.getLatitude()); |
| | | } else { |
| | | battinf.setLongitude(0d); |
| | | battinf.setLatitude(0d); |
| | | } |
| | | |
| | | return new Response().set(1, battinf); |
| | | }else{ |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | public Response sendCmdGet(int opCmd, Integer testCmd, int devId, int battGroupNum, String interfaceNumber) { |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | boolean bl = fbs9100SetparamService.sendCmdToFBS9100Dev2(opCmd, testCmd != null ? testCmd : 0, devId, battGroupNum); |
| | | Fbs9100Setparam setparam = fbs9100SetparamMapper.serchbyDev_id(devId); |
| | | return new Response().setII(1, setparam, bl, bl == true ? "查询成功!" : "设置9100参数失败,请检查网络!"); |
| | | }else{ |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | public Response sendCmdSet(Fbs9100Setparam param, String interfaceNumber) { |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | Long devId = param.getDevId(); |
| | | if (devId.toString().startsWith("61850")) { |
| | | return fbs9100SetparamService.update61850Param(param); |
| | | } else { |
| | | return fbs9100SetparamService.update(param); |
| | | } |
| | | }else{ |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | |
| | | public Response getBattHistoryDataList(BattRealdata data, String interfaceNumber) throws ParseException, InterruptedException { |
| | | int flag = decryptInterface(interfaceNumber); |
| | | if (flag == 1) { |
| | | Response response = battRealdataService.serchByCondition2(data); |
| | | return new Response().set(1,response); |
| | | }else{ |
| | | return new Response().set(1, "越权访问"); |
| | | } |
| | | } |
| | | } |