tplink改成从数据获取配置信息
This commit is contained in:
parent
a2fe049233
commit
c1ec6b2647
|
@ -1,5 +1,6 @@
|
|||
package com.nu.modules.institution.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.nu.modules.institution.entity.InstitutionArea;
|
||||
import com.nu.modules.institution.model.InstitutionAreaTreeModel;
|
||||
import com.nu.modules.institution.service.IInstitutionAreaService;
|
||||
|
@ -127,4 +128,20 @@ public class InstitutionAreaController {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有子区域信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("queryChildrenByParentId")
|
||||
public Result<List<InstitutionArea>> queryChildrenByParentId(@RequestParam(name = "pid", required = false) String parentId) {
|
||||
Result<List<InstitutionArea>> result = new Result<>();
|
||||
LambdaQueryWrapper<InstitutionArea> query = new LambdaQueryWrapper<InstitutionArea>();
|
||||
query.orderByAsc(InstitutionArea::getInstName);
|
||||
query.eq(InstitutionArea::getParentId,parentId);
|
||||
List<InstitutionArea> ls = this.service.list(query);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ public class YouBianCodeUtil {
|
|||
// 数字位数(默认生成3位的数字)
|
||||
|
||||
/**代表数字位数*/
|
||||
private static final int NUM_LENGTH = 2;
|
||||
private static final int NUM_LENGTH = 3;
|
||||
|
||||
public static final int ZHANWEI_LENGTH = 1+ NUM_LENGTH;
|
||||
|
||||
|
|
|
@ -5,8 +5,12 @@ import cn.hutool.json.JSONObject;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import com.nu.modules.tplink.camera.mapper.CameraInfoMapper;
|
||||
|
@ -14,16 +18,11 @@ import com.nu.modules.tplink.camera.service.ICameraInfoService;
|
|||
import com.nu.modules.tplink.common.entity.ErrorCode;
|
||||
import com.nu.modules.tplink.common.service.IErrorCodeService;
|
||||
import com.nu.modules.tplink.utils.TumsApi;
|
||||
import com.nu.modules.tplink.utils.TumsConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
|
@ -38,12 +37,12 @@ import static java.lang.Thread.sleep;
|
|||
@Slf4j
|
||||
public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraInfo> implements ICameraInfoService {
|
||||
|
||||
@Resource
|
||||
TumsConfig tumsConfig;
|
||||
@Autowired
|
||||
private TumsApi tumsApi;
|
||||
@Autowired
|
||||
private IErrorCodeService errorCodeService;
|
||||
@Autowired
|
||||
private ITumsConfigService tumsConfigService;
|
||||
|
||||
/**
|
||||
* 获取摄像头信息-分页
|
||||
|
@ -1833,6 +1832,8 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
if(chnError.equals("0")){
|
||||
List<CameraInfo> chnList = (List)chnMap.get("data");
|
||||
if(chnList!=null&&chnList.size()>0){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigService.getByCode(sysUser.getOrgCode());
|
||||
for(int j=0;j<chnList.size();j++){
|
||||
CameraInfo chn = chnList.get(j);
|
||||
Map<String,Object> playbackMap = getPlaybackUrl(chn,1);
|
||||
|
@ -1842,7 +1843,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
if(pbList!=null&&pbList.size()>0){
|
||||
for(int k=0;k<pbList.size();k++){
|
||||
CameraInfo pb = pbList.get(k);
|
||||
pb.setQueryAddress(tumsConfig.getUrl());
|
||||
pb.setQueryAddress(tumsConfig.getTumsUrl());
|
||||
dataList.add(pb);
|
||||
}
|
||||
}
|
||||
|
@ -2012,8 +2013,10 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
Map<String,Object> multitransMap = getMultitransUrl(cameraInfo,1);
|
||||
String multitransError = multitransMap.get("error").toString();
|
||||
if(multitransError.equals("0")){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigService.getByCode(sysUser.getOrgCode());
|
||||
CameraInfo entity = (CameraInfo)multitransMap.get("data");
|
||||
entity.setQueryAddress(tumsConfig.getUrl());
|
||||
entity.setQueryAddress(tumsConfig.getTumsUrl());
|
||||
return Result.OK(entity);
|
||||
}else{
|
||||
ErrorCode errVo = errorCodeService.getByCode(multitransError);
|
||||
|
@ -2030,6 +2033,8 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
*/
|
||||
@Override
|
||||
public Result uploadToServer(CameraInfo cameraInfo){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigService.getByCode(sysUser.getOrgCode());
|
||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||
String parentId = cameraInfo.getParentId();
|
||||
String fileName = cameraInfo.getFileName();
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
package com.nu.modules.tplink.common.controller;
|
||||
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import com.tplink.ignite.libs.developersdk.api.TumsClient;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import com.nu.modules.tplink.utils.TumsApi;
|
||||
import com.nu.modules.tplink.utils.TumsConfig;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -21,8 +22,8 @@ public class TpLinkController {
|
|||
|
||||
@Autowired
|
||||
private TumsApi tumsApi;
|
||||
@Resource
|
||||
TumsConfig tumsConfig;
|
||||
@Autowired
|
||||
private ITumsConfigService tumsConfigService;
|
||||
|
||||
/**
|
||||
* 登录图门系统
|
||||
|
@ -30,9 +31,11 @@ public class TpLinkController {
|
|||
*/
|
||||
@GetMapping(value = "/login")
|
||||
public Result<Map<String,String>> login() {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
TumsConfig tumsConfig = tumsConfigService.getByCode(sysUser.getOrgCode());
|
||||
Map<String,String> map = new HashMap<>();
|
||||
map.put("cookie","");
|
||||
map.put("serverUrl",tumsConfig.getUrl());
|
||||
map.put("serverUrl",tumsConfig.getTumsUrl());
|
||||
TumsClient tc = tumsApi.createTumsClient();
|
||||
if(tc!=null){
|
||||
map.put("cookie",tc.getCookie());
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.nu.modules.tplink.common.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-TPLINK图门系统配置信息
|
||||
* @Author: caolei
|
||||
* @Date: 2025-03-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_iot_tplink_tums_base")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_iot_tplink_tums_base", description="护理单元-物联管理-TPLINK图门系统配置信息")
|
||||
public class TumsConfig implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private String tumsUrl; //获取图门系统地址
|
||||
private String tumsUsername; // 获取图门系统用户
|
||||
private String tumsPassword; //获取图门系统密码
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
private String orgCode; //机构编码
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.tplink.common.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-错误码
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-02-10
|
||||
* @Version: V1.0
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface TumsConfigMapper extends BaseMapper<TumsConfig> {
|
||||
TumsConfig getByCode(String orgCode);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.tplink.common.mapper.TumsConfigMapper">
|
||||
|
||||
<select id="getByCode" parameterType="String" resultType="com.nu.modules.tplink.common.entity.TumsConfig">
|
||||
select
|
||||
id,
|
||||
tums_url as tumsUrl,
|
||||
tums_username as tumsUsername,
|
||||
tums_password as tumsPassword,
|
||||
ftp_ip as ftpIp,
|
||||
ftp_port as ftpPort,
|
||||
ftp_username as ftpUsername,
|
||||
ftp_password as ftpPassword,
|
||||
ftp_uploadpath as ftpUploadpath,
|
||||
org_code as orgCode
|
||||
from nu_iot_tplink_tums_base
|
||||
<where>
|
||||
<if test="orgCode != null and orgCode != ''">
|
||||
AND org_code = #{orgCode}
|
||||
</if>
|
||||
<if test="orgCode == null or orgCode == ''">
|
||||
AND ifnull(org_code,'') = ''
|
||||
</if>
|
||||
</where>
|
||||
order by id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,14 @@
|
|||
package com.nu.modules.tplink.common.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-图门系统配置
|
||||
* @Author: jeecg-boot
|
||||
* @Date: caolei
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ITumsConfigService extends IService<TumsConfig> {
|
||||
TumsConfig getByCode(String orgCode);
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.nu.modules.tplink.common.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.mapper.TumsConfigMapper;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 护理单元-物联管理-图门系统配置
|
||||
* @Author: caolei
|
||||
* @Date: 2025-03-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class TumsConfigServiceImpl extends ServiceImpl<TumsConfigMapper, TumsConfig> implements ITumsConfigService {
|
||||
|
||||
@Override
|
||||
public TumsConfig getByCode(String orgCode){
|
||||
return baseMapper.getByCode(orgCode);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,21 +1,26 @@
|
|||
package com.nu.modules.tplink.utils;
|
||||
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.service.ITumsConfigService;
|
||||
import com.tplink.ignite.libs.developersdk.api.TumsClient;
|
||||
import com.tplink.ignite.libs.developersdk.vo.ResultVO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.nu.modules.tplink.enums.ApiEnum;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class TumsApi {
|
||||
|
||||
@Resource
|
||||
TumsConfig tumsConfig;
|
||||
|
||||
TumsClient tumsClient;
|
||||
|
||||
TumsConfig tumsConfig;
|
||||
@Autowired
|
||||
private ITumsConfigService tumsConfigService;
|
||||
|
||||
/**
|
||||
* 创建tumsClient
|
||||
* @return
|
||||
|
@ -36,13 +41,20 @@ public class TumsApi {
|
|||
}
|
||||
}
|
||||
|
||||
private void initTumsConfig(){
|
||||
if(tumsConfig==null){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
tumsConfig = tumsConfigService.getByCode(sysUser.getOrgCode());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @return
|
||||
*/
|
||||
public void login(){
|
||||
|
||||
TumsClient tc = new TumsClient(tumsConfig.getUsername(), tumsConfig.getPassword(), tumsConfig.getUrl());
|
||||
initTumsConfig();
|
||||
TumsClient tc = new TumsClient(tumsConfig.getTumsUsername(), tumsConfig.getTumsPassword(), tumsConfig.getTumsUrl());
|
||||
ResultVO loginResult = tc.login();
|
||||
// 判断是否登录成功
|
||||
if (loginResult.getErrorCode() != 0) {
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.nu.modules.tplink.utils;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Data
|
||||
public class TumsConfig {
|
||||
|
||||
@Value("${tplink.tums.url}")
|
||||
private String url; //获取图门系统地址
|
||||
@Value("${tplink.tums.username}")
|
||||
private String username; // 获取图门系统用户
|
||||
@Value("${tplink.tums.password}")
|
||||
private String password; //获取图门系统密码
|
||||
|
||||
@Value("${tplink.ftp.ip}")
|
||||
private String ftpIp; //回放视频转FTP上传IP
|
||||
@Value("${tplink.ftp.port}")
|
||||
private String ftpPort; //回放视频转FTP上传端口
|
||||
@Value("${tplink.ftp.username}")
|
||||
private String ftpUsername; //回放视频转FTP上传用户
|
||||
@Value("${tplink.ftp.password}")
|
||||
private String ftpPassword; //回放视频转FTP上传密码
|
||||
@Value("${tplink.ftp.uploadpath}")
|
||||
private String ftpUploadpath; //回放视频转FTP上传路径
|
||||
|
||||
}
|
|
@ -337,15 +337,3 @@ justauth:
|
|||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
#tplink登录信息
|
||||
tplink:
|
||||
tums:
|
||||
url: https://121.36.88.64:8888
|
||||
username: admin
|
||||
password: Bl20230518
|
||||
ftp:
|
||||
ip: 1.92.152.160
|
||||
port: 21
|
||||
username: administrator
|
||||
password: Root@123..
|
||||
uploadpath: /
|
||||
|
|
Loading…
Reference in New Issue