| | |
| | | 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.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.security.NoSuchAlgorithmException; |
| | | import java.security.SecureRandom; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | |
| | | @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); |
| | | 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 { |
| | |
| | | } |
| | | } |
| | | |
| | | //电池告警历史查询 |
| | | @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 |
| | | public Response getPwrdevAlarmHistory(List powerDeviceIds, String interfaceNumber, int pageNum, int pageSize) { |
| | |
| | | |
| | | } |
| | | |
| | | 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 getRealTime(InterfaceParam param) { |
| | | //先验证 |
| | | int flag = decryptInterface(param.getInterfaceNumber()); |
| | |
| | | //获取所有第三方码的信息 |
| | | 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(); |
| | | //Random random = new Random(); |
| | | SecureRandom random = SecureRandom.getInstance("SHA1PRNG"); |
| | | |
| | | StringBuffer sb = new StringBuffer(); |
| | | for (int i = 0; i < length; i++) { |
| | | int number = random.nextInt(62); |
| | |
| | | } |
| | | } |
| | | |
| | | 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, "越权访问"); |
| | | } |
| | | } |
| | | } |