| | |
| | | package com.ard.work.service.impl; |
| | | |
| | | import com.ard.common.annotation.DataScope; |
| | | import com.ard.common.utils.uuid.IdUtils; |
| | | import com.ard.work.component.forest.TyClient; |
| | | import com.ard.work.component.netty.TyTcpClientManager; |
| | | import com.ard.work.domain.dto.TokenDTO; |
| | | import com.ard.work.domain.entity.ArdDroneInfo; |
| | | import com.ard.work.domain.entity.ArdServerInfo; |
| | | import com.ard.work.domain.receiver.AccessTokenReceiver; |
| | | import com.ard.work.domain.receiver.TyHttpCommonReceiver; |
| | | import com.ard.work.mapper.ArdDroneInfoMapper; |
| | | import com.ard.work.mapper.ArdServerInfoMapper; |
| | | import com.ard.work.service.IArdServerInfoService; |
| | | import com.dtflys.forest.exceptions.ForestRuntimeException; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | |
| | | public class ArdServerInfoServiceImpl implements IArdServerInfoService { |
| | | |
| | | @Resource |
| | | private ArdServerInfoMapper ardServerInfoMapper; |
| | | @Resource |
| | | private TyClient tyClient; |
| | | |
| | | @Resource |
| | | private ArdServerInfoMapper ardServerInfoMapper; |
| | | |
| | | @Resource |
| | | private TyTcpClientManager tyTcpClientManager; |
| | | |
| | | @Resource |
| | | private ArdDroneInfoMapper ArdDroneInfoMapper; |
| | | |
| | | /** |
| | | * 查询服务器管理 |
| | |
| | | * @return 服务器管理 |
| | | */ |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u") |
| | | public List<ArdServerInfo> selectArdServerInfoList(ArdServerInfo ardServerInfo) { |
| | | return ardServerInfoMapper.selectArdServerInfoList(ardServerInfo); |
| | | } |
| | | |
| | | @Override |
| | | @DataScope(deptAlias = "d", userAlias = "u") |
| | | public List<ArdServerInfo> selectArdServerInfoListNo(ArdServerInfo ardServerInfo) { |
| | | |
| | | // List<ArdDroneInfo> ardDroneInfos = ArdDroneInfoMapper.selectArdDroneList(new ArdDroneInfo()); |
| | | // for (ArdDroneInfo ardDroneInfo : ardDroneInfos) { |
| | | // ardDroneInfo.getBoxSn(); |
| | | // } |
| | | // List<ArdServerInfo> servers = ardServerInfoMapper.selectArdServerInfoList(ardServerInfo); |
| | | // for (ArdServerInfo server : servers) { |
| | | // for (ArdDroneInfo ardDroneInfo : server.getArdDroneInfoList()) { |
| | | // ardDroneInfo.getBoxSn(); |
| | | // } |
| | | // } |
| | | |
| | | return ardServerInfoMapper.selectArdServerInfoList(ardServerInfo); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public AccessTokenReceiver getAccessToken(String id) { |
| | | long timeStamp = getTimeStamp(); |
| | | AccessTokenReceiver accessToken = null; |
| | | |
| | | ArdServerInfo serverInfo = selectArdServerInfoById(id); |
| | | // 准备请求的json |
| | | TokenDTO gtd = TokenDTO.builder() |
| | |
| | | .encryptStr(getEncryptStr(serverInfo, timeStamp)) |
| | | .timeStamp(timeStamp) |
| | | .build(); |
| | | try { |
| | | TyHttpCommonReceiver<AccessTokenReceiver> getTokenRes = tyClient.getToken(id, gtd); |
| | | accessToken = getTokenRes.getContent(); |
| | | } catch (Exception e) { |
| | | log.error("获取token失败:{}", e.getMessage()); |
| | | } |
| | | // try { |
| | | TyHttpCommonReceiver<AccessTokenReceiver> getTokenRes = tyClient.getToken(id, gtd); |
| | | return getTokenRes.getContent(); |
| | | // } catch (Exception e) { |
| | | // log.error("获取 Token 失败 serverId={}, 异常: {}", id, e.getMessage()); |
| | | // return null; // 请求失败返回 null |
| | | // } |
| | | //{"state":0,"content":{"companyId":4127,"accessToken":"sOONT0MMVdoKcMBibb40xxgrUrq0Hw9RFiajic3KOzoNtk"}} |
| | | return accessToken; |
| | | } |
| | | |
| | | /** |
| | | * 修改服务器状态 |
| | | */ |
| | | @Override |
| | | public int updateServerStatus(String id) { |
| | | return ardServerInfoMapper.updateServerStatus(id); |
| | | public int updateServerStatus(String id, String status) { |
| | | return ardServerInfoMapper.updateServerStatus(id, status); |
| | | } |
| | | |
| | | @Override |
| | | public List<String> getServerIdsList() { |
| | | return ardServerInfoMapper.getServerIdsList(); |
| | | } |
| | | |
| | | private String getEncryptStr(ArdServerInfo serverInfo, long timeStamp) { |