feat: update code

This commit is contained in:
pnoker
2022-08-15 01:43:03 +08:00
parent 543c3bd8d1
commit ab094518e1
82 changed files with 810 additions and 814 deletions
@@ -25,8 +25,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* PointValueClientFallback
*
@@ -44,17 +42,12 @@ public class PointValueClientFallback implements FallbackFactory<PointValueClien
return new PointValueClient() {
@Override
public R<List<PointValue>> latest(String deviceId, Boolean history) {
public R<Page<PointValue>> latest(PointValueDto pointValueDto, String tenantId) {
return R.fail(message);
}
@Override
public R<PointValue> latest(String deviceId, String pointId, Boolean history) {
return R.fail(message);
}
@Override
public R<Page<PointValue>> list(PointValueDto pointValueDto) {
public R<Page<PointValue>> list(PointValueDto pointValueDto, String tenantId) {
return R.fail(message);
}
@@ -23,37 +23,29 @@ import io.github.pnoker.common.bean.point.PointValue;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.PointValueDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
/**
* 数据 FeignClient
*
* @author pnoker
*/
@Validated
@FeignClient(path = ServiceConstant.Data.VALUE_URL_PREFIX, name = ServiceConstant.Data.SERVICE_NAME, fallbackFactory = PointValueClientFallback.class)
public interface PointValueClient {
/**
* 查询最新 PointValue 集合
*
* @param deviceId Device Id
* @return PointValue Array
* @param pointValueDto PointValueDto
* @return Page<PointValue>
*/
@GetMapping("/latest/device_id/{deviceId}")
R<List<PointValue>> latest(@NotNull @PathVariable(value = "deviceId") String deviceId, @RequestParam(required = false, defaultValue = "false") Boolean history);
/**
* 查询最新 PointValue
*
* @param deviceId Device Id
* @param pointId Point Id
* @return PointValue
*/
@GetMapping("/latest/device_id/{deviceId}/point_id/{pointId}")
R<PointValue> latest(@NotNull @PathVariable(value = "deviceId") String deviceId, @NotNull @PathVariable(value = "pointId") String pointId, @RequestParam(required = false, defaultValue = "false") Boolean history);
@PostMapping("/latest")
R<Page<PointValue>> latest(@RequestBody PointValueDto pointValueDto, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
/**
* 分页查询 PointValue
@@ -62,5 +54,5 @@ public interface PointValueClient {
* @return Page<PointValue>
*/
@PostMapping("/list")
R<Page<PointValue>> list(@RequestBody(required = false) PointValueDto pointValueDto);
R<Page<PointValue>> list(@RequestBody(required = false) PointValueDto pointValueDto, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
}
@@ -16,15 +16,15 @@
package io.github.pnoker.api.center.manager.fallback;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DictionaryClient;
import io.github.pnoker.common.bean.Dictionary;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.dto.DictionaryDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* DictionaryClientFallback
*
@@ -42,32 +42,22 @@ public class DictionaryClientFallback implements FallbackFactory<DictionaryClien
return new DictionaryClient() {
@Override
public R<List<Dictionary>> driverDictionary(String tenantId) {
public R<Page<Dictionary>> driverDictionary(DictionaryDto dictionaryDto, String tenantId) {
return R.fail(message);
}
@Override
public R<List<Dictionary>> driverAttributeDictionary(String tenantId) {
public R<Page<Dictionary>> profileDictionary(DictionaryDto dictionaryDto, String tenantId) {
return R.fail(message);
}
@Override
public R<List<Dictionary>> pointAttributeDictionary(String tenantId) {
public R<Page<Dictionary>> deviceDictionary(DictionaryDto dictionaryDto, String tenantId) {
return R.fail(message);
}
@Override
public R<List<Dictionary>> profileDictionary(String tenantId) {
return R.fail(message);
}
@Override
public R<List<Dictionary>> deviceDictionary(String tenantId) {
return R.fail(message);
}
@Override
public R<List<Dictionary>> pointDictionary(String parent, String tenantId) {
public R<Page<Dictionary>> pointDictionary(DictionaryDto dictionaryDto, String tenantId) {
return R.fail(message);
}
};
@@ -16,18 +16,17 @@
package io.github.pnoker.api.center.manager.feign;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.fallback.DictionaryClientFallback;
import io.github.pnoker.common.bean.Dictionary;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.DictionaryDto;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 字典 FeignClient
*
@@ -39,50 +38,36 @@ public interface DictionaryClient {
/**
* 查询驱动 Dictionary
*
* @return List<Dictionary>
* @param dictionaryDto DictionaryDto
* @return Page<Dictionary>
*/
@GetMapping("/driver")
R<List<Dictionary>> driverDictionary(@RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
/**
* 查询驱动属性 Dictionary
*
* @return List<Dictionary>
*/
@GetMapping("/driver_attribute")
R<List<Dictionary>> driverAttributeDictionary(@RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
/**
* 查询位号属性 Dictionary
*
* @return List<Dictionary>
*/
@GetMapping("/point_attribute")
R<List<Dictionary>> pointAttributeDictionary(@RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
@PostMapping("/driver")
R<Page<Dictionary>> driverDictionary(@RequestBody(required = false) DictionaryDto dictionaryDto, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
/**
* 查询模板 Dictionary
*
* @return List<Dictionary>
* @return Page<Dictionary>
*/
@GetMapping("/profile")
R<List<Dictionary>> profileDictionary(@RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
@PostMapping("/profile")
R<Page<Dictionary>> profileDictionary(@RequestBody(required = false) DictionaryDto dictionaryDto, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
/**
* 查询设备 Dictionary
*
* @return List<Dictionary>
* @param dictionaryDto DictionaryDto
* @return Page<Dictionary>
*/
@GetMapping("/device")
R<List<Dictionary>> deviceDictionary(@RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
@PostMapping("/device")
R<Page<Dictionary>> deviceDictionary(@RequestBody(required = false) DictionaryDto dictionaryDto, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
/**
* 查询位号 Dictionary
*
* @param parent profile/device
* @return List<Dictionary>
* @param dictionaryDto DictionaryDto
* @return Page<Dictionary>
*/
@GetMapping("/point/{parent}")
R<List<Dictionary>> pointDictionary(@NotNull @PathVariable("parent") String parent, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
@PostMapping("/point")
R<Page<Dictionary>> pointDictionary(@RequestBody(required = false) DictionaryDto dictionaryDto, @RequestHeader(value = ServiceConstant.Header.X_AUTH_TENANT_ID, defaultValue = "-1") String tenantId);
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.auth.feign.BlackIpClient;
import io.github.pnoker.center.auth.service.BlackIpService;
@@ -46,7 +47,7 @@ public class BlackIpApi implements BlackIpClient {
public R<BlackIp> add(BlackIp blackIp) {
try {
BlackIp add = blackIpService.add(blackIp);
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -68,7 +69,7 @@ public class BlackIpApi implements BlackIpClient {
public R<BlackIp> update(BlackIp blackIp) {
try {
BlackIp update = blackIpService.update(blackIp);
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -81,7 +82,7 @@ public class BlackIpApi implements BlackIpClient {
public R<BlackIp> selectById(String id) {
try {
BlackIp select = blackIpService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -94,7 +95,7 @@ public class BlackIpApi implements BlackIpClient {
public R<BlackIp> selectByIp(String ip) {
try {
BlackIp select = blackIpService.selectByIp(ip);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -106,8 +107,11 @@ public class BlackIpApi implements BlackIpClient {
@Override
public R<Page<BlackIp>> list(BlackIpDto blackIpDto) {
try {
if (ObjectUtil.isEmpty(blackIpDto)) {
blackIpDto = new BlackIpDto();
}
Page<BlackIp> page = blackIpService.list(blackIpDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.auth.feign.TenantClient;
import io.github.pnoker.center.auth.service.TenantService;
@@ -38,6 +39,7 @@ import javax.annotation.Resource;
@RestController
@RequestMapping(ServiceConstant.Auth.TENANT_URL_PREFIX)
public class TenantApi implements TenantClient {
@Resource
private TenantService tenantService;
@@ -45,7 +47,7 @@ public class TenantApi implements TenantClient {
public R<Tenant> add(Tenant tenant) {
try {
Tenant add = tenantService.add(tenant);
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -67,7 +69,7 @@ public class TenantApi implements TenantClient {
public R<Tenant> update(Tenant tenant) {
try {
Tenant update = tenantService.update(tenant.setName(null));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -80,7 +82,7 @@ public class TenantApi implements TenantClient {
public R<Tenant> selectById(String id) {
try {
Tenant select = tenantService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -93,7 +95,7 @@ public class TenantApi implements TenantClient {
public R<Tenant> selectByName(String name) {
try {
Tenant select = tenantService.selectByName(name);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -105,8 +107,11 @@ public class TenantApi implements TenantClient {
@Override
public R<Page<Tenant>> list(TenantDto tenantDto) {
try {
if (ObjectUtil.isEmpty(tenantDto)) {
tenantDto = new TenantDto();
}
Page<Tenant> page = tenantService.list(tenantDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.auth.feign.UserClient;
import io.github.pnoker.center.auth.service.UserService;
@@ -46,7 +47,7 @@ public class UserApi implements UserClient {
public R<User> add(User user) {
try {
User add = userService.add(user);
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -68,7 +69,7 @@ public class UserApi implements UserClient {
public R<User> update(User user) {
try {
User update = userService.update(user.setName(null));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -90,7 +91,7 @@ public class UserApi implements UserClient {
public R<User> selectById(String id) {
try {
User select = userService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -103,7 +104,7 @@ public class UserApi implements UserClient {
public R<User> selectByName(String name) {
try {
User select = userService.selectByName(name, false);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -115,8 +116,11 @@ public class UserApi implements UserClient {
@Override
public R<Page<User>> list(UserDto userDto) {
try {
if (ObjectUtil.isEmpty(userDto)) {
userDto = new UserDto();
}
Page<User> page = userService.list(userDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -46,7 +47,7 @@ public class BlackIpServiceImpl implements BlackIpService {
@Override
public BlackIp add(BlackIp blackIp) {
BlackIp select = selectByIp(blackIp.getIp());
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
throw new ServiceException("The ip already exists in the blacklist");
}
if (blackIpMapper.insert(blackIp) > 0) {
@@ -98,7 +99,7 @@ public class BlackIpServiceImpl implements BlackIpService {
@Override
public boolean checkBlackIpValid(String ip) {
BlackIp blackIp = selectByIp(ip);
if (null != blackIp) {
if (ObjectUtil.isNotNull(blackIp)) {
return blackIp.getEnable();
}
return false;
@@ -107,10 +108,8 @@ public class BlackIpServiceImpl implements BlackIpService {
@Override
public LambdaQueryWrapper<BlackIp> fuzzyQuery(BlackIpDto blackIpDto) {
LambdaQueryWrapper<BlackIp> queryWrapper = Wrappers.<BlackIp>query().lambda();
if (null != blackIpDto) {
if (StrUtil.isNotBlank(blackIpDto.getIp())) {
queryWrapper.like(BlackIp::getIp, blackIpDto.getIp());
}
if (ObjectUtil.isNotNull(blackIpDto)) {
queryWrapper.like(StrUtil.isNotEmpty(blackIpDto.getIp()), BlackIp::getIp, blackIpDto.getIp());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -31,7 +32,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Optional;
/**
* TenantBindService Impl
@@ -41,6 +41,7 @@ import java.util.Optional;
@Slf4j
@Service
public class TenantBindServiceImpl implements TenantBindService {
@Resource
private TenantBindMapper tenantBindMapper;
@@ -91,7 +92,7 @@ public class TenantBindServiceImpl implements TenantBindService {
@Override
public Page<TenantBind> list(TenantBindDto tenantBindDto) {
if (!Optional.ofNullable(tenantBindDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(tenantBindDto.getPage())) {
tenantBindDto.setPage(new Pages());
}
return tenantBindMapper.selectPage(tenantBindDto.getPage().convert(), fuzzyQuery(tenantBindDto));
@@ -100,13 +101,9 @@ public class TenantBindServiceImpl implements TenantBindService {
@Override
public LambdaQueryWrapper<TenantBind> fuzzyQuery(TenantBindDto tenantBindDto) {
LambdaQueryWrapper<TenantBind> queryWrapper = Wrappers.<TenantBind>query().lambda();
if (null != tenantBindDto) {
if (StrUtil.isNotBlank(tenantBindDto.getTenantId())) {
queryWrapper.eq(TenantBind::getTenantId, tenantBindDto.getTenantId());
}
if (StrUtil.isNotBlank(tenantBindDto.getUserId())) {
queryWrapper.eq(TenantBind::getUserId, tenantBindDto.getUserId());
}
if (ObjectUtil.isNotNull(tenantBindDto)) {
queryWrapper.eq(StrUtil.isNotEmpty(tenantBindDto.getTenantId()), TenantBind::getTenantId, tenantBindDto.getTenantId());
queryWrapper.eq(StrUtil.isNotEmpty(tenantBindDto.getUserId()), TenantBind::getUserId, tenantBindDto.getUserId());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -49,7 +50,7 @@ public class TenantServiceImpl implements TenantService {
@Override
public Tenant add(Tenant tenant) {
Tenant select = selectByName(tenant.getName());
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
throw new DuplicateException("The tenant already exists");
}
if (tenantMapper.insert(tenant) > 0) {
@@ -96,7 +97,7 @@ public class TenantServiceImpl implements TenantService {
@Override
public Page<Tenant> list(TenantDto tenantDto) {
if (!Optional.ofNullable(tenantDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(tenantDto.getPage())) {
tenantDto.setPage(new Pages());
}
return tenantMapper.selectPage(tenantDto.getPage().convert(), fuzzyQuery(tenantDto));
@@ -105,10 +106,8 @@ public class TenantServiceImpl implements TenantService {
@Override
public LambdaQueryWrapper<Tenant> fuzzyQuery(TenantDto tenantDto) {
LambdaQueryWrapper<Tenant> queryWrapper = Wrappers.<Tenant>query().lambda();
if (null != tenantDto) {
if (StrUtil.isNotBlank(tenantDto.getName())) {
queryWrapper.like(Tenant::getName, tenantDto.getName());
}
if (ObjectUtil.isNotNull(tenantDto)) {
queryWrapper.like(StrUtil.isNotEmpty(tenantDto.getName()), Tenant::getName, tenantDto.getName());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.auth.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import io.github.pnoker.center.auth.bean.TokenValid;
@@ -81,7 +82,7 @@ public class TokenServiceImpl implements TokenService {
tenantBindService.selectByTenantIdAndUserId(tempTenant.getId(), tempUser.getId());
String redisSaltKey = CacheConstant.Entity.USER + CacheConstant.Suffix.SALT + CommonConstant.Symbol.SEPARATOR + name;
String tempSalt = redisUtil.getKey(redisSaltKey, String.class);
if (StrUtil.isNotBlank(tempSalt) && tempSalt.equals(salt)) {
if (StrUtil.isNotEmpty(tempSalt) && tempSalt.equals(salt)) {
if (Dc3Util.md5(tempUser.getPassword() + tempSalt).equals(password)) {
String redisTokenKey = CacheConstant.Entity.USER + CacheConstant.Suffix.TOKEN + CommonConstant.Symbol.SEPARATOR + name;
String token = KeyUtil.generateToken(name, tempSalt);
@@ -122,7 +123,7 @@ public class TokenServiceImpl implements TokenService {
private void checkUserLimit(String username) {
String redisKey = CacheConstant.Entity.USER + CacheConstant.Suffix.LIMIT + CommonConstant.Symbol.SEPARATOR + username;
UserLimit limit = redisUtil.getKey(redisKey, UserLimit.class);
if (null != limit && limit.getTimes() >= 5) {
if (ObjectUtil.isNotNull(limit) && limit.getTimes() >= 5) {
Date now = new Date();
long interval = limit.getExpireTime().getTime() - now.getTime();
if (interval > 0) {
@@ -100,7 +100,7 @@ public class UserServiceImpl implements UserService {
public User update(User user) {
User byId = selectById(user.getId());
// 判断 phone 是否修改
if (StrUtil.isNotBlank(user.getPhone())) {
if (StrUtil.isNotEmpty(user.getPhone())) {
if (null == byId.getPhone() || !byId.getPhone().equals(user.getPhone())) {
if (null != selectByPhone(user.getPhone(), false)) {
throw new DuplicateException("The user already exists with phone {}", user.getPhone());
@@ -111,7 +111,7 @@ public class UserServiceImpl implements UserService {
}
// 判断 email 是否修改
if (StrUtil.isNotBlank(user.getEmail())) {
if (StrUtil.isNotEmpty(user.getEmail())) {
if (null == byId.getEmail() || !byId.getEmail().equals(user.getEmail())) {
if (null != selectByEmail(user.getEmail(), false)) {
throw new DuplicateException("The user already exists with email {}", user.getEmail());
@@ -176,7 +176,7 @@ public class UserServiceImpl implements UserService {
@Override
public Page<User> list(UserDto userDto) {
if (!Optional.ofNullable(userDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(userDto.getPage())) {
userDto.setPage(new Pages());
}
return userMapper.selectPage(userDto.getPage().convert(), fuzzyQuery(userDto));
@@ -185,17 +185,17 @@ public class UserServiceImpl implements UserService {
@Override
public boolean checkUserValid(String name) {
User user = selectByName(name, false);
if (null != user) {
if (ObjectUtil.isNotNull(user)) {
return user.getEnable();
}
user = selectByPhone(name, false);
if (null != user) {
if (ObjectUtil.isNotNull(user)) {
return user.getEnable();
}
user = selectByEmail(name, false);
if (null != user) {
if (ObjectUtil.isNotNull(user)) {
return user.getEnable();
}
@@ -205,7 +205,7 @@ public class UserServiceImpl implements UserService {
@Override
public boolean restPassword(String id) {
User user = selectById(id);
if (null != user) {
if (ObjectUtil.isNotNull(user)) {
user.setPassword(Dc3Util.md5(CommonConstant.Algorithm.DEFAULT_PASSWORD));
return null != update(user);
}
@@ -215,10 +215,8 @@ public class UserServiceImpl implements UserService {
@Override
public LambdaQueryWrapper<User> fuzzyQuery(UserDto userDto) {
LambdaQueryWrapper<User> queryWrapper = Wrappers.<User>query().lambda();
if (null != userDto) {
if (StrUtil.isNotBlank(userDto.getName())) {
queryWrapper.like(User::getName, userDto.getName());
}
if (ObjectUtil.isNotNull(userDto)) {
queryWrapper.like(StrUtil.isNotEmpty(userDto.getName()), User::getName, userDto.getName());
}
return queryWrapper;
}
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
spring:
datasource:
@@ -16,10 +16,10 @@
package io.github.pnoker.center.data.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.data.feign.PointValueClient;
import io.github.pnoker.center.data.service.PointValueService;
import io.github.pnoker.common.bean.Pages;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.bean.point.PointValue;
import io.github.pnoker.common.constant.ServiceConstant;
@@ -29,8 +29,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author pnoker
@@ -44,25 +42,14 @@ public class PointValueApi implements PointValueClient {
private PointValueService pointValueService;
@Override
public R<List<PointValue>> latest(String deviceId, Boolean history) {
public R<Page<PointValue>> latest(PointValueDto pointValueDto, String tenantId) {
try {
List<PointValue> pointValues = pointValueService.realtime(deviceId);
if (null == pointValues) {
pointValues = pointValueService.latest(deviceId);
if (ObjectUtil.isEmpty(pointValueDto)) {
pointValueDto = new PointValueDto();
}
if (null != pointValues) {
// 返回最近100个非字符类型的历史值
if (history) {
pointValues.forEach(pointValue -> {
PointValueDto pointValueDto = (new PointValueDto()).setDeviceId(deviceId).setPointId(pointValue.getPointId()).setPage((new Pages()).setSize(100));
Page<PointValue> page = pointValueService.list(pointValueDto);
if (null != page) {
pointValue.setChildren(page.getRecords().stream()
.map(pointValueChild -> pointValueChild.setId(null).setDeviceId(null).setPointId(null)).collect(Collectors.toList()));
}
});
}
return R.ok(pointValues);
Page<PointValue> page = pointValueService.latest(pointValueDto, tenantId);
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
return R.fail(e.getMessage());
@@ -71,35 +58,13 @@ public class PointValueApi implements PointValueClient {
}
@Override
public R<PointValue> latest(String deviceId, String pointId, Boolean history) {
public R<Page<PointValue>> list(PointValueDto pointValueDto, String tenantId) {
try {
PointValue pointValue = pointValueService.realtime(deviceId, pointId);
if (null == pointValue) {
pointValue = pointValueService.latest(deviceId, pointId);
if (ObjectUtil.isEmpty(pointValueDto)) {
pointValueDto = new PointValueDto();
}
if (null != pointValue) {
// 返回最近100个非字符类型的历史值
if (history) {
PointValueDto pointValueDto = (new PointValueDto()).setDeviceId(deviceId).setPointId(pointId).setPage((new Pages()).setSize(100));
Page<PointValue> page = pointValueService.list(pointValueDto);
if (null != page) {
pointValue.setChildren(page.getRecords().stream()
.map(pointValueChild -> pointValueChild.setId(null).setDeviceId(null).setPointId(null)).collect(Collectors.toList()));
}
}
return R.ok(pointValue);
}
} catch (Exception e) {
return R.fail(e.getMessage());
}
return R.fail();
}
@Override
public R<Page<PointValue>> list(PointValueDto pointValueDto) {
try {
Page<PointValue> page = pointValueService.list(pointValueDto);
if (null != page) {
Page<PointValue> page = pointValueService.list(pointValueDto, tenantId);
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -42,38 +42,12 @@ public interface PointValueService {
void savePointValues(List<PointValue> pointValues);
/**
* 获取实时数据
* 获取带分页、排序
*
* @param deviceId Device Id
* @return PointValue Array
* @param pointValueDto PointValueDto
* @return Page<PointValue>
*/
List<PointValue> realtime(String deviceId);
/**
* 获取实时数据
*
* @param deviceId Device Id
* @param pointId Point Id
* @return PointValue
*/
PointValue realtime(String deviceId, String pointId);
/**
* 获取一个设备最新的位号数据集合
*
* @param deviceId Device Id
* @return PointValue Array
*/
List<PointValue> latest(String deviceId);
/**
* 获取最新的一个位号数据
*
* @param deviceId Device Id
* @param pointId Point Id
* @return PointValue
*/
PointValue latest(String deviceId, String pointId);
Page<PointValue> latest(PointValueDto pointValueDto,String tenantId);
/**
* 获取带分页、排序
@@ -81,6 +55,6 @@ public interface PointValueService {
* @param pointValueDto PointValueDto
* @return Page<PointValue>
*/
Page<PointValue> list(PointValueDto pointValueDto);
Page<PointValue> list(PointValueDto pointValueDto,String tenantId);
}
@@ -20,7 +20,6 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DeviceClient;
import io.github.pnoker.api.center.manager.feign.PointClient;
import io.github.pnoker.center.data.service.PointValueService;
import io.github.pnoker.center.data.service.RepositoryHandleService;
@@ -29,8 +28,9 @@ import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.bean.point.PointValue;
import io.github.pnoker.common.constant.CacheConstant;
import io.github.pnoker.common.constant.CommonConstant;
import io.github.pnoker.common.dto.PointDto;
import io.github.pnoker.common.dto.PointValueDto;
import io.github.pnoker.common.model.Device;
import io.github.pnoker.common.model.Description;
import io.github.pnoker.common.model.Point;
import io.github.pnoker.common.utils.RedisUtil;
import lombok.SneakyThrows;
@@ -42,7 +42,10 @@ import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.*;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
@@ -56,8 +59,6 @@ public class PointValueServiceImpl implements PointValueService {
@Resource
private PointClient pointClient;
@Resource
private DeviceClient deviceClient;
@Resource
private RepositoryHandleService repositoryHandleService;
@@ -90,135 +91,107 @@ public class PointValueServiceImpl implements PointValueService {
}
@Override
public List<PointValue> realtime(String deviceId) {
R<List<Point>> listR = pointClient.selectByDeviceId(deviceId);
if (!listR.isOk()) {
String prefix = CacheConstant.Prefix.REAL_TIME_VALUE_KEY_PREFIX + deviceId + CommonConstant.Symbol.UNDERSCORE;
List<String> keys = listR.getData().stream().map(point -> prefix + point.getId()).collect(Collectors.toList());
if (keys.size() > 0) {
List<PointValue> pointValues = redisUtil.getKey(keys, PointValue.class);
pointValues = pointValues.stream().filter(Objects::nonNull).collect(Collectors.toList());
if (pointValues.size() > 0) {
return pointValues;
}
}
public Page<PointValue> latest(PointValueDto pointValueDto, String tenantId) {
Page<PointValue> pointValuePage = new Page<>();
if (ObjectUtil.isEmpty(pointValueDto.getPage())) pointValueDto.setPage(new Pages());
pointValuePage.setCurrent(pointValueDto.getPage().getCurrent()).setSize(pointValueDto.getPage().getSize());
PointDto pointDto = (new PointDto()).setDeviceId(pointValueDto.getDeviceId()).setPage(pointValueDto.getPage());
pointDto.setName(pointValueDto.getName()).setEnable(pointValueDto.getEnable());
R<Page<Point>> pageR = pointClient.list(pointDto, tenantId);
if (!pageR.isOk()) return pointValuePage;
List<Point> points = pageR.getData().getRecords();
List<String> pointIds = points.stream().map(Description::getId).collect(Collectors.toList());
List<PointValue> pointValues = realtime(pointValueDto.getDeviceId(), pointIds);
if (CollectionUtil.isEmpty(pointValues)) pointValues = latest(pointValueDto.getDeviceId(), pointIds);
pointValuePage.setCurrent(pageR.getData().getCurrent()).setSize(pageR.getData().getSize()).setTotal(pageR.getData().getTotal()).setRecords(pointValues);
// 返回最近100个非字符类型的历史值
if (pointValueDto.getHistory()) {
pointValues.parallelStream().forEach(pointValue -> pointValue.setChildren(historyPointValue(pointValueDto.getDeviceId(), pointValue.getPointId(), 50)));
}
return null;
return pointValuePage;
}
@Override
@SneakyThrows
public Page<PointValue> list(PointValueDto pointValueDto, String tenantId) {
long start = System.currentTimeMillis();
Page<PointValue> pointValuePage = new Page<>();
if (ObjectUtil.isEmpty(pointValueDto.getPage())) pointValueDto.setPage(new Pages());
Criteria criteria = new Criteria();
Query query = new Query(criteria);
if (StrUtil.isNotEmpty(pointValueDto.getDeviceId())) criteria.and("deviceId").is(pointValueDto.getDeviceId());
if (StrUtil.isNotEmpty(pointValueDto.getPointId())) criteria.and("pointId").is(pointValueDto.getPointId());
Pages pages = pointValueDto.getPage();
if (pages.getStartTime() > 0 && pages.getEndTime() > 0 && pages.getStartTime() <= pages.getEndTime()) {
criteria.and("createTime").gte(new Date(pages.getStartTime())).lte(new Date(pages.getEndTime()));
}
final String collection = StrUtil.isNotEmpty(pointValueDto.getDeviceId()) ? CommonConstant.Storage.POINT_VALUE_PREFIX + pointValueDto.getDeviceId() : CacheConstant.Entity.POINT + CacheConstant.Suffix.VALUE;
Future<Long> count = threadPoolExecutor.submit(() -> mongoTemplate.count(query, collection));
Future<List<PointValue>> pointValues = threadPoolExecutor.submit(() -> {
query.limit((int) pages.getSize()).skip(pages.getSize() * (pages.getCurrent() - 1));
query.with(Sort.by(Sort.Direction.DESC, "createTime"));
return mongoTemplate.find(query, PointValue.class, collection);
});
pointValuePage.setCurrent(pages.getCurrent()).setSize(pages.getSize()).setTotal(count.get()).setRecords(pointValues.get());
long end = System.currentTimeMillis();
log.info("end:{}", end - start);
return pointValuePage;
}
public List<PointValue> realtime(String deviceId, List<String> pointIds) {
if (CollectionUtil.isEmpty(pointIds)) {
return Collections.emptyList();
}
String prefix = CacheConstant.Prefix.REAL_TIME_VALUE_KEY_PREFIX + deviceId + CommonConstant.Symbol.UNDERSCORE;
List<String> keys = pointIds.stream().map(pointId -> prefix + pointId).collect(Collectors.toList());
List<PointValue> pointValues = redisUtil.getKey(keys, PointValue.class);
return pointValues.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
public List<PointValue> latest(String deviceId, List<String> pointIds) {
if (CollectionUtil.isEmpty(pointIds)) {
return Collections.emptyList();
}
return pointIds.stream().map(pointId -> latestPointValue(deviceId, pointId)).filter(Objects::nonNull).collect(Collectors.toList());
}
public PointValue realtime(String deviceId, String pointId) {
String key = CacheConstant.Prefix.REAL_TIME_VALUE_KEY_PREFIX + deviceId + CommonConstant.Symbol.UNDERSCORE + pointId;
return redisUtil.getKey(key, PointValue.class);
}
@Override
public List<PointValue> latest(String deviceId) {
List<PointValue> pointValues = new ArrayList<>();
R<Device> deviceR = deviceClient.selectById(deviceId);
if (!deviceR.isOk()) {
return pointValues;
}
R<List<Point>> pointsR = pointClient.selectByDeviceId(deviceId);
if (!pointsR.isOk()) {
return pointValues;
}
pointsR.getData().forEach(point -> {
PointValue pointValue = latestPointValue(deviceId, point.getId());
if (null != pointValue) {
pointValues.add(pointValue);
}
});
return pointValues.stream().filter(Objects::nonNull).collect(Collectors.toList());
}
@Override
public PointValue latest(String deviceId, String pointId) {
R<Device> deviceR = deviceClient.selectById(deviceId);
if (!deviceR.isOk()) {
return null;
}
R<Point> pointR = pointClient.selectById(pointId);
if (!pointR.isOk()) {
return null;
}
Point point = pointR.getData();
return latestPointValue(deviceId, point.getId());
}
@Override
@SneakyThrows
public Page<PointValue> list(PointValueDto pointValueDto) {
Criteria criteria = new Criteria();
pointValueDto = Optional.ofNullable(pointValueDto).orElse(new PointValueDto());
if (StrUtil.isNotBlank(pointValueDto.getDeviceId())) {
R<Device> deviceR = deviceClient.selectById(pointValueDto.getDeviceId());
if (deviceR.isOk()) {
Device device = deviceR.getData();
criteria.and("deviceId").is(pointValueDto.getDeviceId());
if (!device.getMulti()) {
if (StrUtil.isNotBlank(pointValueDto.getPointId())) {
criteria.and("pointId").is(pointValueDto.getPointId());
}
} else if (StrUtil.isNotBlank(pointValueDto.getPointId())) {
criteria.and("multi").is(true);
if (StrUtil.isNotBlank(pointValueDto.getPointId())) {
criteria.and("children").elemMatch((new Criteria()).and("pointId").is(pointValueDto.getPointId()));
}
}
}
} else if (StrUtil.isNotBlank(pointValueDto.getPointId())) {
R<Point> pointR = pointClient.selectById(pointValueDto.getPointId());
if (pointR.isOk()) {
criteria.orOperator(
(new Criteria()).and("pointId").is(pointValueDto.getPointId()),
(new Criteria()).and("children").elemMatch((new Criteria()).and("pointId").is(pointValueDto.getPointId()))
);
}
}
Pages pages = Optional.ofNullable(pointValueDto.getPage()).orElse(new Pages());
if (pages.getStartTime() > 0 && pages.getEndTime() > 0 && pages.getStartTime() <= pages.getEndTime()) {
criteria.and("originTime").gte(new Date(pages.getStartTime())).lte(new Date(pages.getEndTime()));
}
final String collection = null != pointValueDto.getDeviceId() ? CommonConstant.Storage.POINT_VALUE_PREFIX + pointValueDto.getDeviceId() : "point_value";
Future<Long> count = threadPoolExecutor.submit(() -> {
Query query = new Query(criteria);
return mongoTemplate.count(query, PointValue.class, collection);
});
Future<List<PointValue>> pointValues = threadPoolExecutor.submit(() -> {
Query query = new Query(criteria);
query.limit((int) pages.getSize()).skip(pages.getSize() * (pages.getCurrent() - 1));
query.with(Sort.by(Sort.Direction.DESC, "originTime"));
return mongoTemplate.find(query, PointValue.class, collection);
});
Page<PointValue> pointValuePage = new Page<>();
List<PointValue> values = pointValues.get().stream().filter(Objects::nonNull).collect(Collectors.toList());
pointValuePage.setCurrent(pages.getCurrent()).setSize(pages.getSize()).setTotal(count.get()).setRecords(values);
return pointValuePage;
return latestPointValue(deviceId, pointId);
}
private PointValue latestPointValue(String deviceId, String pointId) {
PointValue pointValue;
Criteria criteria = new Criteria();
criteria.and("pointId").is(pointId);
Query query = new Query(criteria);
query.with(Sort.by(Sort.Direction.DESC, "originTime"));
pointValue = mongoTemplate.findOne(query, PointValue.class, CommonConstant.Storage.POINT_VALUE_PREFIX + deviceId);
criteria.and("pointId").is(pointId);
query.with(Sort.by(Sort.Direction.DESC, "createTime"));
return pointValue;
return mongoTemplate.findOne(query, PointValue.class, CommonConstant.Storage.POINT_VALUE_PREFIX + deviceId);
}
private List<String> historyPointValue(String deviceId, String pointId, int count) {
Criteria criteria = new Criteria();
Query query = new Query(criteria);
criteria.and("deviceId").is(deviceId).and("pointId").is(pointId);
query.fields().include("value").exclude("id");
query.limit(count).with(Sort.by(Sort.Direction.DESC, "createTime"));
List<PointValue> pointValues = mongoTemplate.find(query, PointValue.class, CommonConstant.Storage.POINT_VALUE_PREFIX + deviceId);
return pointValues.stream().map(PointValue::getValue).collect(Collectors.toList());
}
}
@@ -90,8 +90,8 @@ public class MongoServiceImpl implements RepositoryService, InitializingBean {
// ensure time index
Index timeIndex = new Index();
timeIndex.background()
.on("originTime", Sort.Direction.DESC)
.named("IX_origin_time");
.on("createTime", Sort.Direction.DESC)
.named("IX_create_time");
mongoTemplate.indexOps(collection).ensureIndex(timeIndex);
}
@@ -29,7 +29,7 @@ data:
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
spring:
datasource:
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import io.github.pnoker.api.center.manager.feign.AutoClient;
import io.github.pnoker.center.manager.service.AutoService;
import io.github.pnoker.common.bean.R;
@@ -44,7 +45,7 @@ public class AutoApi implements AutoClient {
public R<PointDetail> autoCreateDeviceAndPoint(PointDetail pointDetail, String tenantId) {
try {
PointDetail createDeviceAndPoint = autoService.autoCreateDeviceAndPoint(pointDetail.getDeviceName(), pointDetail.getPointName(), pointDetail.getDriverId(), tenantId);
if (null != createDeviceAndPoint) {
if (ObjectUtil.isNotNull(createDeviceAndPoint)) {
return R.ok(createDeviceAndPoint);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DeviceClient;
import io.github.pnoker.center.manager.service.DeviceService;
@@ -56,7 +57,7 @@ public class DeviceApi implements DeviceClient {
public R<Device> add(Device device, String tenantId) {
try {
Device add = deviceService.add(device.setTenantId(tenantId));
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
// 通知驱动新增设备
notifyService.notifyDriverDevice(CommonConstant.Driver.Device.ADD, add);
return R.ok(add);
@@ -86,7 +87,7 @@ public class DeviceApi implements DeviceClient {
public R<Device> update(Device device, String tenantId) {
try {
Device update = deviceService.update(device.setTenantId(tenantId));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
// 通知驱动更新设备
notifyService.notifyDriverDevice(CommonConstant.Driver.Device.UPDATE, update);
return R.ok(update);
@@ -101,7 +102,7 @@ public class DeviceApi implements DeviceClient {
public R<Device> selectById(String id) {
try {
Device select = deviceService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -124,9 +125,12 @@ public class DeviceApi implements DeviceClient {
@Override
public R<Page<Device>> list(DeviceDto deviceDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(deviceDto)) {
deviceDto = new DeviceDto();
}
deviceDto.setTenantId(tenantId);
Page<Device> page = deviceService.list(deviceDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,17 +16,19 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DictionaryClient;
import io.github.pnoker.center.manager.service.DictionaryService;
import io.github.pnoker.common.bean.Dictionary;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.DictionaryDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @author pnoker
@@ -40,11 +42,15 @@ public class DictionaryApi implements DictionaryClient {
private DictionaryService dictionaryService;
@Override
public R<List<Dictionary>> driverDictionary(String tenantId) {
public R<Page<Dictionary>> driverDictionary(DictionaryDto dictionaryDto, String tenantId) {
try {
List<Dictionary> dictionaryList = dictionaryService.driverDictionary(tenantId);
if (null != dictionaryList) {
return R.ok(dictionaryList);
if (ObjectUtil.isEmpty(dictionaryDto)) {
dictionaryDto = new DictionaryDto();
}
dictionaryDto.setTenantId(tenantId);
Page<Dictionary> page = dictionaryService.driverDictionary(dictionaryDto);
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
return R.fail(e.getMessage());
@@ -53,11 +59,15 @@ public class DictionaryApi implements DictionaryClient {
}
@Override
public R<List<Dictionary>> driverAttributeDictionary(String tenantId) {
public R<Page<Dictionary>> profileDictionary(DictionaryDto dictionaryDto, String tenantId) {
try {
List<Dictionary> dictionaryList = dictionaryService.driverAttributeDictionary(tenantId);
if (null != dictionaryList) {
return R.ok(dictionaryList);
if (ObjectUtil.isEmpty(dictionaryDto)) {
dictionaryDto = new DictionaryDto();
}
dictionaryDto.setTenantId(tenantId);
Page<Dictionary> page = dictionaryService.profileDictionary(dictionaryDto);
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
return R.fail(e.getMessage());
@@ -66,11 +76,15 @@ public class DictionaryApi implements DictionaryClient {
}
@Override
public R<List<Dictionary>> pointAttributeDictionary(String tenantId) {
public R<Page<Dictionary>> deviceDictionary(DictionaryDto dictionaryDto, String tenantId) {
try {
List<Dictionary> dictionaryList = dictionaryService.pointAttributeDictionary(tenantId);
if (null != dictionaryList) {
return R.ok(dictionaryList);
if (ObjectUtil.isEmpty(dictionaryDto)) {
dictionaryDto = new DictionaryDto();
}
dictionaryDto.setTenantId(tenantId);
Page<Dictionary> page = dictionaryService.deviceDictionary(dictionaryDto);
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
return R.fail(e.getMessage());
@@ -79,37 +93,15 @@ public class DictionaryApi implements DictionaryClient {
}
@Override
public R<List<Dictionary>> profileDictionary(String tenantId) {
public R<Page<Dictionary>> pointDictionary(DictionaryDto dictionaryDto, String tenantId) {
try {
List<Dictionary> dictionaryList = dictionaryService.profileDictionary(tenantId);
if (null != dictionaryList) {
return R.ok(dictionaryList);
if (ObjectUtil.isEmpty(dictionaryDto)) {
dictionaryDto = new DictionaryDto();
}
} catch (Exception e) {
return R.fail(e.getMessage());
}
return R.fail();
}
@Override
public R<List<Dictionary>> deviceDictionary(String tenantId) {
try {
List<Dictionary> dictionaryList = dictionaryService.deviceDictionary(tenantId);
if (null != dictionaryList) {
return R.ok(dictionaryList);
}
} catch (Exception e) {
return R.fail(e.getMessage());
}
return R.fail();
}
@Override
public R<List<Dictionary>> pointDictionary(String parent, String tenantId) {
try {
List<Dictionary> dictionaryList = dictionaryService.pointDictionary(parent, tenantId);
if (null != dictionaryList) {
return R.ok(dictionaryList);
dictionaryDto.setTenantId(tenantId);
Page<Dictionary> page = dictionaryService.pointDictionary(dictionaryDto);
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
return R.fail(e.getMessage());
@@ -16,12 +16,14 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DriverClient;
import io.github.pnoker.center.manager.service.DriverService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.DriverDto;
import io.github.pnoker.common.dto.PointValueDto;
import io.github.pnoker.common.model.Driver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -43,6 +45,7 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping(ServiceConstant.Manager.DRIVER_URL_PREFIX)
public class DriverApi implements DriverClient {
@Resource
private DriverService driverService;
@@ -50,7 +53,7 @@ public class DriverApi implements DriverClient {
public R<Driver> add(Driver driver, String tenantId) {
try {
Driver add = driverService.add(driver.setTenantId(tenantId));
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -72,7 +75,7 @@ public class DriverApi implements DriverClient {
public R<Driver> update(Driver driver, String tenantId) {
try {
Driver update = driverService.update(driver.setTenantId(tenantId));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -125,9 +128,12 @@ public class DriverApi implements DriverClient {
@Override
public R<Page<Driver>> list(DriverDto driverDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(driverDto)) {
driverDto = new DriverDto();
}
driverDto.setTenantId(tenantId);
Page<Driver> page = driverService.list(driverDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,12 +16,15 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DriverAttributeClient;
import io.github.pnoker.center.manager.service.DriverAttributeService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.DriverAttributeDto;
import io.github.pnoker.common.dto.DriverDto;
import io.github.pnoker.common.exception.NotFoundException;
import io.github.pnoker.common.model.DriverAttribute;
import lombok.extern.slf4j.Slf4j;
@@ -41,6 +44,7 @@ import java.util.List;
@RestController
@RequestMapping(ServiceConstant.Manager.DRIVER_ATTRIBUTE_URL_PREFIX)
public class DriverAttributeApi implements DriverAttributeClient {
@Resource
private DriverAttributeService driverAttributeService;
@@ -48,7 +52,7 @@ public class DriverAttributeApi implements DriverAttributeClient {
public R<DriverAttribute> add(DriverAttribute driverAttribute) {
try {
DriverAttribute add = driverAttributeService.add(driverAttribute);
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -70,7 +74,7 @@ public class DriverAttributeApi implements DriverAttributeClient {
public R<DriverAttribute> update(DriverAttribute driverAttribute) {
try {
DriverAttribute update = driverAttributeService.update(driverAttribute);
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -83,7 +87,7 @@ public class DriverAttributeApi implements DriverAttributeClient {
public R<DriverAttribute> selectById(String id) {
try {
DriverAttribute select = driverAttributeService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -96,7 +100,7 @@ public class DriverAttributeApi implements DriverAttributeClient {
public R<List<DriverAttribute>> selectByDriverId(String id) {
try {
List<DriverAttribute> select = driverAttributeService.selectByDriverId(id);
if (null != select) {
if (CollectionUtil.isNotEmpty(select)) {
return R.ok(select);
}
} catch (NotFoundException ne) {
@@ -110,8 +114,11 @@ public class DriverAttributeApi implements DriverAttributeClient {
@Override
public R<Page<DriverAttribute>> list(DriverAttributeDto driverAttributeDto) {
try {
if (ObjectUtil.isEmpty(driverAttributeDto)) {
driverAttributeDto = new DriverAttributeDto();
}
Page<DriverAttribute> page = driverAttributeService.list(driverAttributeDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.DriverInfoClient;
import io.github.pnoker.center.manager.service.DriverInfoService;
@@ -23,6 +24,7 @@ import io.github.pnoker.center.manager.service.NotifyService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.CommonConstant;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.DriverAttributeDto;
import io.github.pnoker.common.dto.DriverInfoDto;
import io.github.pnoker.common.model.DriverInfo;
import lombok.extern.slf4j.Slf4j;
@@ -132,6 +134,9 @@ public class DriverInfoApi implements DriverInfoClient {
@Override
public R<Page<DriverInfo>> list(DriverInfoDto driverInfoDto) {
try {
if (ObjectUtil.isEmpty(driverInfoDto)) {
driverInfoDto = new DriverInfoDto();
}
Page<DriverInfo> page = driverInfoService.list(driverInfoDto);
if (null != page) {
return R.ok(page);
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.EventClient;
import io.github.pnoker.center.manager.service.EventService;
@@ -45,8 +46,11 @@ public class EventApi implements EventClient {
@Override
public R<Page<DriverEvent>> driverEvent(DriverEventDto driverEventDto) {
try {
if (ObjectUtil.isEmpty(driverEventDto)) {
driverEventDto = new DriverEventDto();
}
Page<DriverEvent> page = eventService.driverEvent(driverEventDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -58,8 +62,11 @@ public class EventApi implements EventClient {
@Override
public R<Page<DeviceEvent>> deviceEvent(DeviceEventDto deviceEventDto) {
try {
if (ObjectUtil.isEmpty(deviceEventDto)) {
deviceEventDto = new DeviceEventDto();
}
Page<DeviceEvent> page = eventService.deviceEvent(deviceEventDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,11 +16,13 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.GroupClient;
import io.github.pnoker.center.manager.service.GroupService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.DriverInfoDto;
import io.github.pnoker.common.dto.GroupDto;
import io.github.pnoker.common.model.Group;
import lombok.extern.slf4j.Slf4j;
@@ -46,7 +48,7 @@ public class GroupApi implements GroupClient {
public R<Group> add(Group group, String tenantId) {
try {
Group add = groupService.add(group.setTenantId(tenantId));
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -68,7 +70,7 @@ public class GroupApi implements GroupClient {
public R<Group> update(Group group, String tenantId) {
try {
Group update = groupService.update(group.setTenantId(tenantId));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -93,6 +95,9 @@ public class GroupApi implements GroupClient {
@Override
public R<Page<Group>> list(GroupDto groupDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(groupDto)) {
groupDto = new GroupDto();
}
groupDto.setTenantId(tenantId);
Page<Group> page = groupService.list(groupDto);
if (null != page) {
@@ -16,11 +16,13 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.LabelClient;
import io.github.pnoker.center.manager.service.LabelService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.GroupDto;
import io.github.pnoker.common.dto.LabelDto;
import io.github.pnoker.common.model.Label;
import lombok.extern.slf4j.Slf4j;
@@ -46,7 +48,7 @@ public class LabelApi implements LabelClient {
public R<Label> add(Label label, String tenantId) {
try {
Label add = labelService.add(label.setTenantId(tenantId));
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -68,7 +70,7 @@ public class LabelApi implements LabelClient {
public R<Label> update(Label label, String tenantId) {
try {
Label update = labelService.update(label.setTenantId(tenantId));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -81,7 +83,7 @@ public class LabelApi implements LabelClient {
public R<Label> selectById(String id) {
try {
Label select = labelService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -93,9 +95,12 @@ public class LabelApi implements LabelClient {
@Override
public R<Page<Label>> list(LabelDto labelDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(labelDto)) {
labelDto = new LabelDto();
}
labelDto.setTenantId(tenantId);
Page<Label> page = labelService.list(labelDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,8 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.PointClient;
import io.github.pnoker.center.manager.service.NotifyService;
@@ -23,6 +25,7 @@ import io.github.pnoker.center.manager.service.PointService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.CommonConstant;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.LabelDto;
import io.github.pnoker.common.dto.PointDto;
import io.github.pnoker.common.model.Point;
import lombok.extern.slf4j.Slf4j;
@@ -56,7 +59,7 @@ public class PointApi implements PointClient {
public R<Point> add(Point point, String tenantId) {
try {
Point add = pointService.add(point.setTenantId(tenantId));
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
notifyService.notifyDriverPoint(CommonConstant.Driver.Point.ADD, add);
return R.ok(add);
}
@@ -70,7 +73,7 @@ public class PointApi implements PointClient {
public R<Boolean> delete(String id) {
try {
Point point = pointService.selectById(id);
if (null != point && pointService.delete(id)) {
if (ObjectUtil.isNotNull(point) && pointService.delete(id)) {
notifyService.notifyDriverPoint(CommonConstant.Driver.Point.DELETE, point);
return R.ok();
}
@@ -84,7 +87,7 @@ public class PointApi implements PointClient {
public R<Point> update(Point point, String tenantId) {
try {
Point update = pointService.update(point.setTenantId(tenantId));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
notifyService.notifyDriverPoint(CommonConstant.Driver.Point.UPDATE, update);
return R.ok(update);
}
@@ -98,7 +101,7 @@ public class PointApi implements PointClient {
public R<Point> selectById(String id) {
try {
Point select = pointService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -122,7 +125,7 @@ public class PointApi implements PointClient {
public R<List<Point>> selectByProfileId(String profileId) {
try {
List<Point> select = pointService.selectByProfileId(profileId);
if (null != select) {
if (CollectionUtil.isNotEmpty(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -135,7 +138,7 @@ public class PointApi implements PointClient {
public R<List<Point>> selectByDeviceId(String deviceId) {
try {
List<Point> select = pointService.selectByDeviceId(deviceId);
if (null != select) {
if (CollectionUtil.isNotEmpty(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -147,9 +150,12 @@ public class PointApi implements PointClient {
@Override
public R<Page<Point>> list(PointDto pointDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(pointDto)) {
pointDto = new PointDto();
}
pointDto.setTenantId(tenantId);
Page<Point> page = pointService.list(pointDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,12 +16,15 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.PointAttributeClient;
import io.github.pnoker.center.manager.service.PointAttributeService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.PointAttributeDto;
import io.github.pnoker.common.dto.PointDto;
import io.github.pnoker.common.exception.NotFoundException;
import io.github.pnoker.common.model.PointAttribute;
import lombok.extern.slf4j.Slf4j;
@@ -41,6 +44,7 @@ import java.util.List;
@RestController
@RequestMapping(ServiceConstant.Manager.POINT_ATTRIBUTE_URL_PREFIX)
public class PointAttributeApi implements PointAttributeClient {
@Resource
private PointAttributeService pointAttributeService;
@@ -48,7 +52,7 @@ public class PointAttributeApi implements PointAttributeClient {
public R<PointAttribute> add(PointAttribute pointAttribute) {
try {
PointAttribute add = pointAttributeService.add(pointAttribute);
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -70,7 +74,7 @@ public class PointAttributeApi implements PointAttributeClient {
public R<PointAttribute> update(PointAttribute pointAttribute) {
try {
PointAttribute update = pointAttributeService.update(pointAttribute);
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
return R.ok(update);
}
} catch (Exception e) {
@@ -83,7 +87,7 @@ public class PointAttributeApi implements PointAttributeClient {
public R<PointAttribute> selectById(String id) {
try {
PointAttribute select = pointAttributeService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -96,7 +100,7 @@ public class PointAttributeApi implements PointAttributeClient {
public R<List<PointAttribute>> selectByDriverId(String id) {
try {
List<PointAttribute> select = pointAttributeService.selectByDriverId(id);
if (null != select) {
if (CollectionUtil.isNotEmpty(select)) {
return R.ok(select);
}
} catch (NotFoundException ne) {
@@ -110,8 +114,11 @@ public class PointAttributeApi implements PointAttributeClient {
@Override
public R<Page<PointAttribute>> list(PointAttributeDto pointAttributeDto) {
try {
if (ObjectUtil.isEmpty(pointAttributeDto)) {
pointAttributeDto = new PointAttributeDto();
}
Page<PointAttribute> page = pointAttributeService.list(pointAttributeDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.PointInfoClient;
import io.github.pnoker.center.manager.service.NotifyService;
@@ -23,6 +24,7 @@ import io.github.pnoker.center.manager.service.PointInfoService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.CommonConstant;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.PointAttributeDto;
import io.github.pnoker.common.dto.PointInfoDto;
import io.github.pnoker.common.model.PointInfo;
import lombok.extern.slf4j.Slf4j;
@@ -52,7 +54,7 @@ public class PointInfoApi implements PointInfoClient {
public R<PointInfo> add(PointInfo pointInfo) {
try {
PointInfo add = pointInfoService.add(pointInfo);
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
notifyService.notifyDriverPointInfo(CommonConstant.Driver.PointInfo.ADD, add);
return R.ok(add);
}
@@ -66,7 +68,7 @@ public class PointInfoApi implements PointInfoClient {
public R<Boolean> delete(String id) {
try {
PointInfo pointInfo = pointInfoService.selectById(id);
if (null != pointInfo && pointInfoService.delete(id)) {
if (ObjectUtil.isNotNull(pointInfo) && pointInfoService.delete(id)) {
notifyService.notifyDriverPointInfo(CommonConstant.Driver.PointInfo.DELETE, pointInfo);
return R.ok();
}
@@ -145,6 +147,9 @@ public class PointInfoApi implements PointInfoClient {
@Override
public R<Page<PointInfo>> list(PointInfoDto pointInfoDto) {
try {
if (ObjectUtil.isEmpty(pointInfoDto)) {
pointInfoDto = new PointInfoDto();
}
Page<PointInfo> page = pointInfoService.list(pointInfoDto);
if (null != page) {
return R.ok(page);
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.center.manager.feign.ProfileClient;
import io.github.pnoker.center.manager.service.NotifyService;
@@ -23,6 +24,7 @@ import io.github.pnoker.center.manager.service.ProfileService;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.CommonConstant;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.PointInfoDto;
import io.github.pnoker.common.dto.ProfileDto;
import io.github.pnoker.common.model.Profile;
import lombok.extern.slf4j.Slf4j;
@@ -56,7 +58,7 @@ public class ProfileApi implements ProfileClient {
public R<Profile> add(Profile profile, String tenantId) {
try {
Profile add = profileService.add(profile.setTenantId(tenantId));
if (null != add) {
if (ObjectUtil.isNotNull(add)) {
return R.ok(add);
}
} catch (Exception e) {
@@ -69,7 +71,7 @@ public class ProfileApi implements ProfileClient {
public R<Boolean> delete(String id) {
try {
Profile profile = profileService.selectById(id);
if (null != profile && profileService.delete(id)) {
if (ObjectUtil.isNotNull(profile) && profileService.delete(id)) {
notifyService.notifyDriverProfile(CommonConstant.Driver.Profile.DELETE, profile);
return R.ok();
}
@@ -83,7 +85,7 @@ public class ProfileApi implements ProfileClient {
public R<Profile> update(Profile profile, String tenantId) {
try {
Profile update = profileService.update(profile.setTenantId(tenantId));
if (null != update) {
if (ObjectUtil.isNotNull(update)) {
notifyService.notifyDriverProfile(CommonConstant.Driver.Profile.UPDATE, update);
return R.ok(update);
}
@@ -97,7 +99,7 @@ public class ProfileApi implements ProfileClient {
public R<Profile> selectById(String id) {
try {
Profile select = profileService.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
return R.ok(select);
}
} catch (Exception e) {
@@ -133,9 +135,12 @@ public class ProfileApi implements ProfileClient {
@Override
public R<Page<Profile>> list(ProfileDto profileDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(profileDto)) {
profileDto = new ProfileDto();
}
profileDto.setTenantId(tenantId);
Page<Profile> page = profileService.list(profileDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -27,6 +27,7 @@ import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@@ -37,8 +38,11 @@ import java.util.Map;
@Configuration
public class TopicRabbitConfig {
@Resource
private ConnectionFactory connectionFactory;
@Bean
RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
RabbitTemplate rabbitTemplate() {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setMessageConverter(new Jackson2JsonMessageConverter());
rabbitTemplate.setMandatory(true);
@@ -54,7 +58,7 @@ public class TopicRabbitConfig {
}
@Bean
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory() {
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setMessageConverter(new Jackson2JsonMessageConverter());
@@ -16,9 +16,13 @@
package io.github.pnoker.center.manager.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.common.model.Point;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@@ -27,4 +31,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface PointMapper extends BaseMapper<Point> {
Page<Point> selectPageWithDevice(Page<Point> page, @Param(Constants.WRAPPER) Wrapper<Point> queryWrapper, @Param("deviceId") String deviceId);
}
@@ -16,9 +16,13 @@
package io.github.pnoker.center.manager.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.common.model.Profile;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@@ -27,4 +31,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface ProfileMapper extends BaseMapper<Profile> {
Page<Profile> selectPageWithDevice(Page<Profile> page, @Param(Constants.WRAPPER) Wrapper<Profile> queryWrapper, @Param("deviceId") String deviceId);
}
@@ -16,9 +16,9 @@
package io.github.pnoker.center.manager.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.common.bean.Dictionary;
import java.util.List;
import io.github.pnoker.common.dto.DictionaryDto;
/**
* Dictionary Interface
@@ -28,46 +28,36 @@ import java.util.List;
public interface DictionaryService {
/**
* 获取租户驱动字典
* 获取驱动字典
*
* @return Dictionary Array
* @param dictionaryDto DictionaryDto
* @return Dictionary Page
*/
List<Dictionary> driverDictionary(String tenantId);
Page<Dictionary> driverDictionary(DictionaryDto dictionaryDto);
/**
* 获取驱动配置属性字典
* 获取设备字典
*
* @return Dictionary Array
* @param dictionaryDto DictionaryDto
* @return Dictionary Page
*/
List<Dictionary> driverAttributeDictionary(String tenantId);
Page<Dictionary> deviceDictionary(DictionaryDto dictionaryDto);
/**
* 获取位号配置属性字典
* 获取模板字典
*
* @return Dictionary Array
* @param dictionaryDto DictionaryDto
* @return Dictionary Page
*/
List<Dictionary> pointAttributeDictionary(String tenantId);
Page<Dictionary> profileDictionary(DictionaryDto dictionaryDto);
/**
* 获取租户模板字典
*
* @return Dictionary Array
*/
List<Dictionary> profileDictionary(String tenantId);
/**
* 获取租户模板、设备位号字典
* 获取位号字典
* profile/device
*
* @param parent
* @return Dictionary Array
* @param dictionaryDto DictionaryDto
* @return Dictionary Page
*/
List<Dictionary> pointDictionary(String parent, String tenantId);
Page<Dictionary> pointDictionary(DictionaryDto dictionaryDto);
/**
* 获取租户驱动下设备字典
*
* @return Dictionary Array
*/
List<Dictionary> deviceDictionary(String tenantId);
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.StrUtil;
import io.github.pnoker.center.manager.service.*;
import io.github.pnoker.common.bean.point.PointDetail;
import io.github.pnoker.common.constant.CommonConstant;
@@ -77,7 +78,7 @@ public class AutoServiceImpl implements AutoService {
}
// 绑定模板
if (null != device.getId() && null != profile.getId()) {
if (StrUtil.isAllNotEmpty(device.getId(), profile.getId())) {
try {
ProfileBind profileBind = new ProfileBind();
profileBind.setDeviceId(device.getId()).setProfileId(profile.getId());
@@ -17,6 +17,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -33,7 +34,6 @@ import io.github.pnoker.common.exception.ServiceException;
import io.github.pnoker.common.model.Device;
import io.github.pnoker.common.model.Point;
import io.github.pnoker.common.model.ProfileBind;
import io.github.pnoker.center.manager.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -169,20 +169,32 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public Page<Device> list(DeviceDto deviceDto) {
if (!Optional.ofNullable(deviceDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(deviceDto.getPage())) {
deviceDto.setPage(new Pages());
}
return deviceMapper.selectPageWithProfile(deviceDto.getPage().convert(), fuzzyQuery(deviceDto), deviceDto.getProfileId());
return deviceMapper.selectPageWithProfile(deviceDto.getPage().convert(), customFuzzyQuery(deviceDto), deviceDto.getProfileId());
}
@Override
public LambdaQueryWrapper<Device> fuzzyQuery(DeviceDto deviceDto) {
LambdaQueryWrapper<Device> queryWrapper = Wrappers.<Device>query().lambda();
if (ObjectUtil.isNotEmpty(deviceDto)) {
queryWrapper.like(StrUtil.isNotBlank(deviceDto.getName()), Device::getName, deviceDto.getName());
queryWrapper.eq(StrUtil.isNotEmpty(deviceDto.getDriverId()), Device::getDriverId, deviceDto.getDriverId());
queryWrapper.eq(ObjectUtil.isNotEmpty(deviceDto.getEnable()), Device::getEnable, deviceDto.getEnable());
queryWrapper.eq(StrUtil.isNotEmpty(deviceDto.getTenantId()), Device::getTenantId, deviceDto.getTenantId());
}
return queryWrapper;
}
public LambdaQueryWrapper<Device> customFuzzyQuery(DeviceDto deviceDto) {
QueryWrapper<Device> queryWrapper = Wrappers.query();
if (null != deviceDto) {
queryWrapper.like(StrUtil.isNotBlank(deviceDto.getName()), "dd.name", deviceDto.getName());
queryWrapper.eq(StrUtil.isNotBlank(deviceDto.getDriverId()), "dd.driver_id", deviceDto.getDriverId());
queryWrapper.eq(null != deviceDto.getEnable(), "dd.enable", deviceDto.getEnable());
queryWrapper.eq(StrUtil.isNotBlank(deviceDto.getTenantId()), "dd.tenant_id", deviceDto.getTenantId());
queryWrapper.eq("dd.deleted", 0);
if (ObjectUtil.isNotNull(deviceDto)) {
queryWrapper.like(StrUtil.isNotEmpty(deviceDto.getName()), "dd.name", deviceDto.getName());
queryWrapper.eq(StrUtil.isNotEmpty(deviceDto.getDriverId()), "dd.driver_id", deviceDto.getDriverId());
queryWrapper.eq(ObjectUtil.isNotNull(deviceDto.getEnable()), "dd.enable", deviceDto.getEnable());
queryWrapper.eq(StrUtil.isNotEmpty(deviceDto.getTenantId()), "dd.tenant_id", deviceDto.getTenantId());
}
return queryWrapper.lambda();
}
@@ -16,20 +16,29 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.github.pnoker.center.manager.mapper.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.center.manager.mapper.*;
import io.github.pnoker.center.manager.service.DictionaryService;
import io.github.pnoker.center.manager.service.PointService;
import io.github.pnoker.common.bean.Dictionary;
import io.github.pnoker.common.model.*;
import io.github.pnoker.common.bean.Pages;
import io.github.pnoker.common.dto.DictionaryDto;
import io.github.pnoker.common.dto.PointDto;
import io.github.pnoker.common.model.Device;
import io.github.pnoker.common.model.Driver;
import io.github.pnoker.common.model.Point;
import io.github.pnoker.common.model.Profile;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author pnoker
@@ -37,6 +46,10 @@ import java.util.List;
@Slf4j
@Service
public class DictionaryServiceImpl implements DictionaryService {
@Resource
private PointService pointService;
@Resource
private DriverMapper driverMapper;
@Resource
@@ -46,151 +59,71 @@ public class DictionaryServiceImpl implements DictionaryService {
@Resource
private ProfileMapper profileMapper;
@Resource
private PointMapper pointMapper;
@Resource
private DeviceMapper deviceMapper;
@Override
public List<Dictionary> driverDictionary(String tenantId) {
List<Dictionary> dictionaries = new ArrayList<>(16);
LambdaQueryWrapper<Driver> queryWrapper = Wrappers.<Driver>query().lambda();
queryWrapper.eq(Driver::getTenantId, tenantId);
List<Driver> drivers = driverMapper.selectList(queryWrapper);
drivers.forEach(driver -> dictionaries.add(new Dictionary().setLabel(driver.getName()).setValue(driver.getId())));
return dictionaries;
}
@Override
public List<Dictionary> driverAttributeDictionary(String tenantId) {
List<Dictionary> dictionaries = driverDictionary(tenantId);
dictionaries.forEach(driverDictionary -> {
List<Dictionary> driverAttributeDictionaryList = new ArrayList<>(16);
LambdaQueryWrapper<DriverAttribute> queryWrapper = Wrappers.<DriverAttribute>query().lambda();
queryWrapper.eq(DriverAttribute::getDriverId, driverDictionary.getValue());
List<DriverAttribute> driverAttributeList = driverAttributeMapper.selectList(queryWrapper);
driverAttributeList.forEach(driverAttribute -> driverAttributeDictionaryList.add(new Dictionary().setLabel(driverAttribute.getDisplayName()).setValue(driverAttribute.getId())));
driverDictionary.setDisabled(true);
driverDictionary.setValue(RandomUtil.randomString(8));
driverDictionary.setChildren(driverAttributeDictionaryList);
});
return dictionaries;
}
@Override
public List<Dictionary> pointAttributeDictionary(String tenantId) {
List<Dictionary> dictionaries = driverDictionary(tenantId);
dictionaries.forEach(driverDictionary -> {
List<Dictionary> driverAttributeDictionaryList = new ArrayList<>(16);
LambdaQueryWrapper<PointAttribute> queryWrapper = Wrappers.<PointAttribute>query().lambda();
queryWrapper.eq(PointAttribute::getDriverId, driverDictionary.getValue());
List<PointAttribute> pointAttributeList = pointAttributeMapper.selectList(queryWrapper);
pointAttributeList.forEach(pointAttribute -> driverAttributeDictionaryList.add(new Dictionary().setLabel(pointAttribute.getDisplayName()).setValue(pointAttribute.getId())));
driverDictionary.setDisabled(true);
driverDictionary.setValue(RandomUtil.randomString(8));
driverDictionary.setChildren(driverAttributeDictionaryList);
});
return dictionaries;
}
@Override
public List<Dictionary> profileDictionary(String tenantId) {
List<Dictionary> dictionaries = new ArrayList<>(16);
LambdaQueryWrapper<Profile> queryWrapper = Wrappers.<Profile>query().lambda();
queryWrapper.eq(Profile::getTenantId, tenantId);
List<Profile> profiles = profileMapper.selectList(queryWrapper);
profiles.forEach(profile -> dictionaries.add(new Dictionary().setLabel(profile.getName()).setValue(profile.getId())));
return dictionaries;
}
@Override
public List<Dictionary> pointDictionary(String parent, String tenantId) {
List<Dictionary> dictionaries = new ArrayList<>(16);
switch (parent) {
case "profile":
List<Dictionary> profileDictionaryList = new ArrayList<>(16);
LambdaQueryWrapper<Profile> profileQueryWrapper = Wrappers.<Profile>query().lambda();
profileQueryWrapper.eq(Profile::getTenantId, tenantId);
List<Profile> profileList = profileMapper.selectList(profileQueryWrapper);
profileList.forEach(profile -> {
List<Dictionary> pointDictionaryList = new ArrayList<>(16);
LambdaQueryWrapper<Point> queryWrapper = Wrappers.<Point>query().lambda();
queryWrapper.eq(Point::getProfileId, profile.getId());
queryWrapper.eq(Point::getTenantId, tenantId);
List<Point> pointList = pointMapper.selectList(queryWrapper);
pointList.forEach(point -> pointDictionaryList.add(new Dictionary().setLabel(point.getName()).setValue(point.getId())));
Dictionary profileDictionary = new Dictionary().setLabel(profile.getName()).setValue(profile.getId());
profileDictionary.setChildren(pointDictionaryList);
profileDictionaryList.add(profileDictionary);
});
dictionaries = profileDictionaryList;
break;
case "device":
List<Dictionary> deviceDictionaryList = new ArrayList<>(16);
LambdaQueryWrapper<Device> deviceQueryWrapper = Wrappers.<Device>query().lambda();
deviceQueryWrapper.eq(Device::getTenantId, tenantId);
List<Device> deviceList = deviceMapper.selectList(deviceQueryWrapper);
deviceList.forEach(device -> {
List<Dictionary> profileDictionaryLists = new ArrayList<>(16);
device.getProfileIds().forEach(profileId -> {
Profile profile = profileMapper.selectById(profileId);
LambdaQueryWrapper<Point> queryWrapper = Wrappers.<Point>query().lambda();
queryWrapper.eq(Point::getProfileId, profileId);
queryWrapper.eq(Point::getTenantId, tenantId);
List<Point> pointList = pointMapper.selectList(queryWrapper);
List<Dictionary> pointDictionaryList = new ArrayList<>(16);
pointList.forEach(point -> pointDictionaryList.add(new Dictionary().setLabel(point.getName()).setValue(point.getId())));
Dictionary profileDictionary = new Dictionary().setLabel(profile.getName()).setValue(profileId);
profileDictionary.setChildren(pointDictionaryList);
profileDictionaryLists.add(profileDictionary);
});
Dictionary deviceDictionary = new Dictionary().setLabel(device.getName()).setValue(device.getId());
deviceDictionary.setChildren(profileDictionaryLists);
deviceDictionaryList.add(deviceDictionary);
});
dictionaries = deviceDictionaryList;
break;
case "point":
List<Dictionary> pointDictionaryList = new ArrayList<>(16);
LambdaQueryWrapper<Point> queryWrapper = Wrappers.<Point>query().lambda();
queryWrapper.eq(Point::getTenantId, tenantId);
List<Point> pointList = pointMapper.selectList(queryWrapper);
pointList.forEach(point -> pointDictionaryList.add(new Dictionary().setLabel(point.getName()).setValue(point.getId())));
dictionaries = pointDictionaryList;
break;
default:
break;
public Page<Dictionary> driverDictionary(DictionaryDto dictionaryDto) {
if (ObjectUtil.isNull(dictionaryDto.getPage())) {
dictionaryDto.setPage(new Pages());
}
return dictionaries;
LambdaQueryWrapper<Driver> queryWrapper = Wrappers.<Driver>query().lambda();
queryWrapper.like(StrUtil.isNotEmpty(dictionaryDto.getLabel()), Driver::getName, dictionaryDto.getLabel());
queryWrapper.eq(StrUtil.isNotEmpty(dictionaryDto.getTenantId()), Driver::getTenantId, dictionaryDto.getTenantId());
Page<Driver> driverPage = driverMapper.selectPage(dictionaryDto.getPage().convert(), queryWrapper);
List<Dictionary> dictionaryList = driverPage.getRecords().parallelStream().map(driver -> new Dictionary().setLabel(driver.getName()).setValue(driver.getId())).collect(Collectors.toList());
Page<Dictionary> page = new Page<>();
BeanUtils.copyProperties(driverPage, page);
page.setRecords(dictionaryList);
return page;
}
@Override
public List<Dictionary> deviceDictionary(String tenantId) {
List<Dictionary> dictionaries = driverDictionary(tenantId);
dictionaries.forEach(driverDictionary -> {
LambdaQueryWrapper<Device> queryWrapper = Wrappers.<Device>query().lambda();
queryWrapper.eq(Device::getDriverId, driverDictionary.getValue());
queryWrapper.eq(Device::getTenantId, tenantId);
List<Device> deviceList = deviceMapper.selectList(queryWrapper);
List<Dictionary> deviceDictionaryList = new ArrayList<>(16);
deviceList.forEach(device -> deviceDictionaryList.add(new Dictionary().setLabel(device.getName()).setValue(device.getId())));
driverDictionary.setChildren(deviceDictionaryList);
});
return dictionaries;
public Page<Dictionary> deviceDictionary(DictionaryDto dictionaryDto) {
if (ObjectUtil.isNull(dictionaryDto.getPage())) {
dictionaryDto.setPage(new Pages());
}
LambdaQueryWrapper<Device> queryWrapper = Wrappers.<Device>query().lambda();
queryWrapper.like(StrUtil.isNotEmpty(dictionaryDto.getLabel()), Device::getName, dictionaryDto.getLabel());
queryWrapper.eq(StrUtil.isNotEmpty(dictionaryDto.getParentValue1()), Device::getDriverId, dictionaryDto.getParentValue1());
queryWrapper.eq(StrUtil.isNotEmpty(dictionaryDto.getTenantId()), Device::getTenantId, dictionaryDto.getTenantId());
Page<Device> devicePage = deviceMapper.selectPage(dictionaryDto.getPage().convert(), queryWrapper);
List<Dictionary> dictionaryList = devicePage.getRecords().parallelStream().map(profile -> new Dictionary().setLabel(profile.getName()).setValue(profile.getId())).collect(Collectors.toList());
Page<Dictionary> page = new Page<>();
BeanUtils.copyProperties(devicePage, page);
page.setRecords(dictionaryList);
return page;
}
@Override
public Page<Dictionary> profileDictionary(DictionaryDto dictionaryDto) {
if (ObjectUtil.isNull(dictionaryDto.getPage())) {
dictionaryDto.setPage(new Pages());
}
LambdaQueryWrapper<Profile> queryWrapper = Wrappers.<Profile>query().lambda();
queryWrapper.like(StrUtil.isNotEmpty(dictionaryDto.getLabel()), Profile::getName, dictionaryDto.getLabel());
queryWrapper.eq(StrUtil.isNotEmpty(dictionaryDto.getTenantId()), Profile::getTenantId, dictionaryDto.getTenantId());
Page<Profile> profilePage = profileMapper.selectPage(dictionaryDto.getPage().convert(), queryWrapper);
List<Dictionary> dictionaryList = profilePage.getRecords().parallelStream().map(profile -> new Dictionary().setLabel(profile.getName()).setValue(profile.getId())).collect(Collectors.toList());
Page<Dictionary> page = new Page<>();
BeanUtils.copyProperties(profilePage, page);
page.setRecords(dictionaryList);
return page;
}
@Override
public Page<Dictionary> pointDictionary(DictionaryDto dictionaryDto) {
if (ObjectUtil.isNull(dictionaryDto.getPage())) {
dictionaryDto.setPage(new Pages());
}
PointDto pointDto = (new PointDto()).setPage(dictionaryDto.getPage());
pointDto.setDeviceId(dictionaryDto.getParentValue2());
pointDto.setName(dictionaryDto.getLabel()).setProfileId(dictionaryDto.getParentValue1()).setTenantId(dictionaryDto.getTenantId());
Page<Point> pointPage = pointService.list(pointDto);
List<Dictionary> dictionaryList = pointPage.getRecords().parallelStream().map(profile -> new Dictionary().setLabel(profile.getName()).setValue(profile.getId())).collect(Collectors.toList());
Page<Dictionary> page = new Page<>();
BeanUtils.copyProperties(pointPage, page);
page.setRecords(dictionaryList);
return page;
}
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -42,6 +43,7 @@ import java.util.List;
@Slf4j
@Service
public class DriverAttributeServiceImpl implements DriverAttributeService {
@Resource
private DriverAttributeMapper driverAttributeMapper;
@@ -119,19 +121,11 @@ public class DriverAttributeServiceImpl implements DriverAttributeService {
@Override
public LambdaQueryWrapper<DriverAttribute> fuzzyQuery(DriverAttributeDto driverAttributeDto) {
LambdaQueryWrapper<DriverAttribute> queryWrapper = Wrappers.<DriverAttribute>query().lambda();
if (null != driverAttributeDto) {
if (StrUtil.isNotBlank(driverAttributeDto.getName())) {
queryWrapper.like(DriverAttribute::getName, driverAttributeDto.getName());
}
if (StrUtil.isNotBlank(driverAttributeDto.getDisplayName())) {
queryWrapper.like(DriverAttribute::getDisplayName, driverAttributeDto.getDisplayName());
}
if (StrUtil.isNotBlank(driverAttributeDto.getType())) {
queryWrapper.eq(DriverAttribute::getType, driverAttributeDto.getType());
}
if (StrUtil.isNotBlank(driverAttributeDto.getDriverId())) {
queryWrapper.eq(DriverAttribute::getDriverId, driverAttributeDto.getDriverId());
}
if (ObjectUtil.isNotNull(driverAttributeDto)) {
queryWrapper.like(StrUtil.isNotEmpty(driverAttributeDto.getName()), DriverAttribute::getName, driverAttributeDto.getName());
queryWrapper.like(StrUtil.isNotEmpty(driverAttributeDto.getDisplayName()), DriverAttribute::getDisplayName, driverAttributeDto.getDisplayName());
queryWrapper.eq(StrUtil.isNotEmpty(driverAttributeDto.getType()), DriverAttribute::getType, driverAttributeDto.getType());
queryWrapper.eq(StrUtil.isNotEmpty(driverAttributeDto.getDriverId()), DriverAttribute::getDriverId, driverAttributeDto.getDriverId());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -33,7 +34,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
/**
* DriverInfoService Impl
@@ -130,7 +130,7 @@ public class DriverInfoServiceImpl implements DriverInfoService {
@Override
public Page<DriverInfo> list(DriverInfoDto driverInfoDto) {
if (!Optional.ofNullable(driverInfoDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(driverInfoDto.getPage())) {
driverInfoDto.setPage(new Pages());
}
return driverInfoMapper.selectPage(driverInfoDto.getPage().convert(), fuzzyQuery(driverInfoDto));
@@ -139,13 +139,9 @@ public class DriverInfoServiceImpl implements DriverInfoService {
@Override
public LambdaQueryWrapper<DriverInfo> fuzzyQuery(DriverInfoDto driverInfoDto) {
LambdaQueryWrapper<DriverInfo> queryWrapper = Wrappers.<DriverInfo>query().lambda();
if (null != driverInfoDto) {
if (StrUtil.isNotBlank(driverInfoDto.getDriverAttributeId())) {
queryWrapper.eq(DriverInfo::getDriverAttributeId, driverInfoDto.getDriverAttributeId());
}
if (StrUtil.isNotBlank(driverInfoDto.getDeviceId())) {
queryWrapper.eq(DriverInfo::getDeviceId, driverInfoDto.getDeviceId());
}
if (ObjectUtil.isNotNull(driverInfoDto)) {
queryWrapper.eq(StrUtil.isNotEmpty(driverInfoDto.getDriverAttributeId()), DriverInfo::getDriverAttributeId, driverInfoDto.getDriverAttributeId());
queryWrapper.eq(StrUtil.isNotEmpty(driverInfoDto.getDeviceId()), DriverInfo::getDeviceId, driverInfoDto.getDeviceId());
}
return queryWrapper;
}
@@ -17,6 +17,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -155,29 +156,17 @@ public class DriverServiceImpl implements DriverService {
@Override
public LambdaQueryWrapper<Driver> fuzzyQuery(DriverDto driverDto) {
LambdaQueryWrapper<Driver> queryWrapper = Wrappers.<Driver>query().lambda();
if (null != driverDto) {
if (StrUtil.isNotBlank(driverDto.getName())) {
queryWrapper.like(Driver::getName, driverDto.getName());
}
if (StrUtil.isNotBlank(driverDto.getServiceName())) {
queryWrapper.like(Driver::getServiceName, driverDto.getServiceName());
}
if (StrUtil.isNotBlank(driverDto.getHost())) {
queryWrapper.like(Driver::getHost, driverDto.getHost());
}
if (null != driverDto.getPort()) {
queryWrapper.eq(Driver::getPort, driverDto.getPort());
}
if (StrUtil.isBlank(driverDto.getType())) {
if (ObjectUtil.isNotNull(driverDto)) {
queryWrapper.like(StrUtil.isNotEmpty(driverDto.getName()), Driver::getName, driverDto.getName());
queryWrapper.like(StrUtil.isNotEmpty(driverDto.getServiceName()), Driver::getServiceName, driverDto.getServiceName());
queryWrapper.like(StrUtil.isNotEmpty(driverDto.getHost()), Driver::getHost, driverDto.getHost());
queryWrapper.eq(ObjectUtil.isNotNull(driverDto.getPort()), Driver::getPort, driverDto.getPort());
if (StrUtil.isEmpty(driverDto.getType())) {
driverDto.setType(CommonConstant.Driver.Type.DRIVER);
}
queryWrapper.like(Driver::getType, driverDto.getType());
if (null != driverDto.getEnable()) {
queryWrapper.eq(Driver::getEnable, driverDto.getEnable());
}
if (StrUtil.isNotBlank(driverDto.getTenantId())) {
queryWrapper.eq(Driver::getTenantId, driverDto.getTenantId());
}
queryWrapper.eq(ObjectUtil.isNotNull(driverDto.getEnable()), Driver::getEnable, driverDto.getEnable());
queryWrapper.eq(StrUtil.isNotEmpty(driverDto.getTenantId()), Driver::getTenantId, driverDto.getTenantId());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.center.manager.service.EventService;
@@ -46,7 +47,7 @@ public class EventServiceImpl implements EventService {
@Override
public void addDriverEvent(DriverEvent driverEvent) {
if (null != driverEvent) {
if (ObjectUtil.isNotNull(driverEvent)) {
mongoTemplate.insert(driverEvent);
}
}
@@ -62,7 +63,7 @@ public class EventServiceImpl implements EventService {
@Override
public void addDeviceEvent(DeviceEvent deviceEvent) {
if (null != deviceEvent) {
if (ObjectUtil.isNotNull(deviceEvent)) {
mongoTemplate.insert(deviceEvent);
}
}
@@ -87,22 +88,22 @@ public class EventServiceImpl implements EventService {
if (null == deviceEventDto) {
deviceEventDto = new DeviceEventDto();
}
if (StrUtil.isNotBlank(deviceEventDto.getDeviceId())) {
if (StrUtil.isNotEmpty(deviceEventDto.getDeviceId())) {
criteria.and("deviceId").is(deviceEventDto.getDeviceId());
}
if (StrUtil.isNotBlank(deviceEventDto.getPointId())) {
if (StrUtil.isNotEmpty(deviceEventDto.getPointId())) {
criteria.and("pointId").is(deviceEventDto.getPointId());
}
Pages pages = null == deviceEventDto.getPage() ? new Pages() : deviceEventDto.getPage();
if (pages.getStartTime() > 0 && pages.getEndTime() > 0 && pages.getStartTime() <= pages.getEndTime()) {
criteria.and("originTime").gte(pages.getStartTime()).lte(pages.getEndTime());
criteria.and("createTime").gte(pages.getStartTime()).lte(pages.getEndTime());
}
Query query = new Query(criteria);
long count = mongoTemplate.count(query, DeviceEvent.class);
query.with(Sort.by(Sort.Direction.DESC, "originTime"));
query.with(Sort.by(Sort.Direction.DESC, "createTime"));
long size = pages.getSize();
long page = pages.getCurrent();
query.limit((int) size).skip(size * (page - 1));
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -32,7 +33,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Optional;
/**
* GroupService Impl
@@ -101,7 +101,7 @@ public class GroupServiceImpl implements GroupService {
@Override
public Page<Group> list(GroupDto groupDto) {
if (!Optional.ofNullable(groupDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(groupDto.getPage())) {
groupDto.setPage(new Pages());
}
return groupMapper.selectPage(groupDto.getPage().convert(), fuzzyQuery(groupDto));
@@ -110,13 +110,9 @@ public class GroupServiceImpl implements GroupService {
@Override
public LambdaQueryWrapper<Group> fuzzyQuery(GroupDto groupDto) {
LambdaQueryWrapper<Group> queryWrapper = Wrappers.<Group>query().lambda();
if (null != groupDto) {
if (StrUtil.isNotBlank(groupDto.getName())) {
queryWrapper.like(Group::getName, groupDto.getName());
}
if (StrUtil.isNotBlank(groupDto.getTenantId())) {
queryWrapper.eq(Group::getTenantId, groupDto.getTenantId());
}
if (ObjectUtil.isNotNull(groupDto)) {
queryWrapper.like(StrUtil.isNotEmpty(groupDto.getName()), Group::getName, groupDto.getName());
queryWrapper.eq(StrUtil.isNotEmpty(groupDto.getTenantId()), Group::getTenantId, groupDto.getTenantId());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -41,6 +42,7 @@ import java.util.Optional;
@Slf4j
@Service
public class LabelBindServiceImpl implements LabelBindService {
@Resource
private LabelBindMapper labelBindMapper;
@@ -79,7 +81,7 @@ public class LabelBindServiceImpl implements LabelBindService {
@Override
public Page<LabelBind> list(LabelBindDto labelBindDto) {
if (!Optional.ofNullable(labelBindDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(labelBindDto.getPage())) {
labelBindDto.setPage(new Pages());
}
return labelBindMapper.selectPage(labelBindDto.getPage().convert(), fuzzyQuery(labelBindDto));
@@ -88,16 +90,10 @@ public class LabelBindServiceImpl implements LabelBindService {
@Override
public LambdaQueryWrapper<LabelBind> fuzzyQuery(LabelBindDto labelBindDto) {
LambdaQueryWrapper<LabelBind> queryWrapper = Wrappers.<LabelBind>query().lambda();
if (null != labelBindDto) {
if (StrUtil.isNotBlank(labelBindDto.getLabelId())) {
queryWrapper.eq(LabelBind::getLabelId, labelBindDto.getLabelId());
}
if (StrUtil.isNotBlank(labelBindDto.getEntityId())) {
queryWrapper.eq(LabelBind::getEntityId, labelBindDto.getEntityId());
}
if (StrUtil.isNotBlank(labelBindDto.getType())) {
queryWrapper.eq(LabelBind::getType, labelBindDto.getType());
}
if (ObjectUtil.isNotNull(labelBindDto)) {
queryWrapper.eq(StrUtil.isNotEmpty(labelBindDto.getLabelId()), LabelBind::getLabelId, labelBindDto.getLabelId());
queryWrapper.eq(StrUtil.isNotEmpty(labelBindDto.getEntityId()), LabelBind::getEntityId, labelBindDto.getEntityId());
queryWrapper.eq(StrUtil.isNotEmpty(labelBindDto.getType()), LabelBind::getType, labelBindDto.getType());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -110,7 +111,7 @@ public class LabelServiceImpl implements LabelService {
@Override
public Page<Label> list(LabelDto labelDto) {
if (!Optional.ofNullable(labelDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(labelDto.getPage())) {
labelDto.setPage(new Pages());
}
return labelMapper.selectPage(labelDto.getPage().convert(), fuzzyQuery(labelDto));
@@ -119,16 +120,10 @@ public class LabelServiceImpl implements LabelService {
@Override
public LambdaQueryWrapper<Label> fuzzyQuery(LabelDto labelDto) {
LambdaQueryWrapper<Label> queryWrapper = Wrappers.<Label>query().lambda();
if (null != labelDto) {
if (StrUtil.isNotBlank(labelDto.getName())) {
queryWrapper.like(Label::getName, labelDto.getName());
}
if (StrUtil.isNotBlank(labelDto.getColor())) {
queryWrapper.eq(Label::getColor, labelDto.getColor());
}
if (StrUtil.isNotBlank(labelDto.getTenantId())) {
queryWrapper.eq(Label::getTenantId, labelDto.getTenantId());
}
if (ObjectUtil.isNotNull(labelDto)) {
queryWrapper.like(StrUtil.isNotEmpty(labelDto.getName()), Label::getName, labelDto.getName());
queryWrapper.eq(StrUtil.isNotEmpty(labelDto.getColor()), Label::getColor, labelDto.getColor());
queryWrapper.eq(StrUtil.isNotEmpty(labelDto.getTenantId()), Label::getTenantId, labelDto.getTenantId());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -43,6 +44,7 @@ import java.util.Optional;
@Slf4j
@Service
public class PointAttributeServiceImpl implements PointAttributeService {
@Resource
private PointAttributeMapper pointAttributeMapper;
@@ -111,7 +113,7 @@ public class PointAttributeServiceImpl implements PointAttributeService {
@Override
public Page<PointAttribute> list(PointAttributeDto pointAttributeDto) {
if (!Optional.ofNullable(pointAttributeDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(pointAttributeDto.getPage())) {
pointAttributeDto.setPage(new Pages());
}
return pointAttributeMapper.selectPage(pointAttributeDto.getPage().convert(), fuzzyQuery(pointAttributeDto));
@@ -120,19 +122,11 @@ public class PointAttributeServiceImpl implements PointAttributeService {
@Override
public LambdaQueryWrapper<PointAttribute> fuzzyQuery(PointAttributeDto pointAttributeDto) {
LambdaQueryWrapper<PointAttribute> queryWrapper = Wrappers.<PointAttribute>query().lambda();
if (null != pointAttributeDto) {
if (StrUtil.isNotBlank(pointAttributeDto.getName())) {
queryWrapper.like(PointAttribute::getName, pointAttributeDto.getName());
}
if (StrUtil.isNotBlank(pointAttributeDto.getDisplayName())) {
queryWrapper.like(PointAttribute::getDisplayName, pointAttributeDto.getDisplayName());
}
if (StrUtil.isNotBlank(pointAttributeDto.getType())) {
queryWrapper.eq(PointAttribute::getType, pointAttributeDto.getType());
}
Optional.ofNullable(pointAttributeDto.getDriverId()).ifPresent(driverId -> {
queryWrapper.eq(PointAttribute::getDriverId, driverId);
});
if (ObjectUtil.isNotNull(pointAttributeDto)) {
queryWrapper.like(StrUtil.isNotEmpty(pointAttributeDto.getName()), PointAttribute::getName, pointAttributeDto.getName());
queryWrapper.like(StrUtil.isNotEmpty(pointAttributeDto.getDisplayName()), PointAttribute::getDisplayName, pointAttributeDto.getDisplayName());
queryWrapper.eq(StrUtil.isNotEmpty(pointAttributeDto.getType()), PointAttribute::getType, pointAttributeDto.getType());
queryWrapper.eq(StrUtil.isNotEmpty(pointAttributeDto.getDriverId()), PointAttribute::getDriverId, pointAttributeDto.getDriverId());
}
return queryWrapper;
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -153,7 +154,7 @@ public class PointInfoServiceImpl implements PointInfoService {
@Override
public Page<PointInfo> list(PointInfoDto pointInfoDto) {
if (!Optional.ofNullable(pointInfoDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(pointInfoDto.getPage())) {
pointInfoDto.setPage(new Pages());
}
return pointInfoMapper.selectPage(pointInfoDto.getPage().convert(), fuzzyQuery(pointInfoDto));
@@ -162,16 +163,10 @@ public class PointInfoServiceImpl implements PointInfoService {
@Override
public LambdaQueryWrapper<PointInfo> fuzzyQuery(PointInfoDto pointInfoDto) {
LambdaQueryWrapper<PointInfo> queryWrapper = Wrappers.<PointInfo>query().lambda();
if (null != pointInfoDto) {
if (StrUtil.isNotBlank(pointInfoDto.getPointAttributeId())) {
queryWrapper.eq(PointInfo::getPointAttributeId, pointInfoDto.getPointAttributeId());
}
if (StrUtil.isNotBlank(pointInfoDto.getDeviceId())) {
queryWrapper.eq(PointInfo::getDeviceId, pointInfoDto.getDeviceId());
}
if (StrUtil.isNotBlank(pointInfoDto.getPointId())) {
queryWrapper.eq(PointInfo::getPointId, pointInfoDto.getPointId());
}
if (ObjectUtil.isNotNull(pointInfoDto)) {
queryWrapper.eq(StrUtil.isNotEmpty(pointInfoDto.getPointAttributeId()), PointInfo::getPointAttributeId, pointInfoDto.getPointAttributeId());
queryWrapper.eq(StrUtil.isNotEmpty(pointInfoDto.getDeviceId()), PointInfo::getDeviceId, pointInfoDto.getDeviceId());
queryWrapper.eq(StrUtil.isNotEmpty(pointInfoDto.getPointId()), PointInfo::getPointId, pointInfoDto.getPointId());
}
return queryWrapper;
}
@@ -17,8 +17,10 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.center.manager.mapper.PointMapper;
@@ -156,10 +158,10 @@ public class PointServiceImpl implements PointService {
@Override
public Page<Point> list(PointDto pointDto) {
if (!Optional.ofNullable(pointDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(pointDto.getPage())) {
pointDto.setPage(new Pages());
}
return pointMapper.selectPage(pointDto.getPage().convert(), fuzzyQuery(pointDto));
return pointMapper.selectPageWithDevice(pointDto.getPage().convert(), customFuzzyQuery(pointDto), pointDto.getDeviceId());
}
@Override
@@ -172,29 +174,30 @@ public class PointServiceImpl implements PointService {
public LambdaQueryWrapper<Point> fuzzyQuery(PointDto pointDto) {
LambdaQueryWrapper<Point> queryWrapper = Wrappers.<Point>query().lambda();
if (null != pointDto) {
if (StrUtil.isNotBlank(pointDto.getName())) {
queryWrapper.like(Point::getName, pointDto.getName());
}
if (StrUtil.isNotBlank(pointDto.getType())) {
queryWrapper.eq(Point::getType, pointDto.getType());
}
if (null != pointDto.getRw()) {
queryWrapper.eq(Point::getRw, pointDto.getRw());
}
if (null != pointDto.getAccrue()) {
queryWrapper.eq(Point::getAccrue, pointDto.getAccrue());
}
if (StrUtil.isNotBlank(pointDto.getProfileId())) {
queryWrapper.eq(Point::getProfileId, pointDto.getProfileId());
}
if (null != pointDto.getEnable()) {
queryWrapper.eq(Point::getEnable, pointDto.getEnable());
}
if (StrUtil.isNotBlank(pointDto.getTenantId())) {
queryWrapper.eq(Point::getTenantId, pointDto.getTenantId());
}
queryWrapper.like(StrUtil.isNotBlank(pointDto.getName()), Point::getName, pointDto.getName());
queryWrapper.eq(StrUtil.isNotBlank(pointDto.getType()), Point::getType, pointDto.getType());
queryWrapper.eq(ObjectUtil.isNotEmpty(pointDto.getRw()), Point::getRw, pointDto.getRw());
queryWrapper.eq(ObjectUtil.isNotEmpty(pointDto.getAccrue()), Point::getAccrue, pointDto.getAccrue());
queryWrapper.eq(StrUtil.isNotBlank(pointDto.getProfileId()), Point::getProfileId, pointDto.getProfileId());
queryWrapper.eq(ObjectUtil.isNotEmpty(pointDto.getEnable()), Point::getEnable, pointDto.getEnable());
queryWrapper.eq(StrUtil.isNotBlank(pointDto.getTenantId()), Point::getTenantId, pointDto.getTenantId());
}
return queryWrapper;
}
public LambdaQueryWrapper<Point> customFuzzyQuery(PointDto pointDto) {
QueryWrapper<Point> queryWrapper = Wrappers.query();
queryWrapper.eq("dp.deleted", 0);
if (ObjectUtil.isNotNull(pointDto)) {
queryWrapper.like(StrUtil.isNotEmpty(pointDto.getName()), "dp.name", pointDto.getName());
queryWrapper.eq(StrUtil.isNotEmpty(pointDto.getType()), "dp.type", pointDto.getType());
queryWrapper.eq(ObjectUtil.isNotNull(pointDto.getRw()), "dp.rw", pointDto.getRw());
queryWrapper.eq(ObjectUtil.isNotNull(pointDto.getAccrue()), "dp.accrue", pointDto.getAccrue());
queryWrapper.eq(StrUtil.isNotEmpty(pointDto.getProfileId()), "dp.profile_id", pointDto.getProfileId());
queryWrapper.eq(ObjectUtil.isNotNull(pointDto.getEnable()), "dp.enable", pointDto.getEnable());
queryWrapper.eq(StrUtil.isNotEmpty(pointDto.getTenantId()), "dp.tenant_id", pointDto.getTenantId());
}
return queryWrapper.lambda();
}
}
@@ -16,6 +16,7 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -33,7 +34,6 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
@@ -132,7 +132,7 @@ public class ProfileBindServiceImpl implements ProfileBindService {
@Override
public Page<ProfileBind> list(ProfileBindDto profileBindDto) {
if (!Optional.ofNullable(profileBindDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(profileBindDto.getPage())) {
profileBindDto.setPage(new Pages());
}
return profileBindMapper.selectPage(profileBindDto.getPage().convert(), fuzzyQuery(profileBindDto));
@@ -141,13 +141,9 @@ public class ProfileBindServiceImpl implements ProfileBindService {
@Override
public LambdaQueryWrapper<ProfileBind> fuzzyQuery(ProfileBindDto profileBindDto) {
LambdaQueryWrapper<ProfileBind> queryWrapper = Wrappers.<ProfileBind>query().lambda();
if (null != profileBindDto) {
if (StrUtil.isNotBlank(profileBindDto.getProfileId())) {
queryWrapper.eq(ProfileBind::getProfileId, profileBindDto.getProfileId());
}
if (StrUtil.isNotBlank(profileBindDto.getDeviceId())) {
queryWrapper.eq(ProfileBind::getDeviceId, profileBindDto.getDeviceId());
}
if (ObjectUtil.isNotNull(profileBindDto)) {
queryWrapper.eq(StrUtil.isNotEmpty(profileBindDto.getProfileId()), ProfileBind::getProfileId, profileBindDto.getProfileId());
queryWrapper.eq(StrUtil.isNotEmpty(profileBindDto.getDeviceId()), ProfileBind::getDeviceId, profileBindDto.getDeviceId());
}
return queryWrapper;
}
@@ -17,8 +17,10 @@
package io.github.pnoker.center.manager.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.center.manager.mapper.ProfileMapper;
@@ -142,31 +144,35 @@ public class ProfileServiceImpl implements ProfileService {
@Override
// 2022-07-30 检查:不通过,在查询模板的时候请勿全量返回改模板下的位号,因为位号可能会很多,已移除
public Page<Profile> list(ProfileDto profileDto) {
if (!Optional.ofNullable(profileDto.getPage()).isPresent()) {
if (ObjectUtil.isNull(profileDto.getPage())) {
profileDto.setPage(new Pages());
}
return profileMapper.selectPage(profileDto.getPage().convert(), fuzzyQuery(profileDto));
return profileMapper.selectPageWithDevice(profileDto.getPage().convert(), customFuzzyQuery(profileDto), profileDto.getDeviceId());
}
@Override
// 2022-07-30 检查:通过
public LambdaQueryWrapper<Profile> fuzzyQuery(ProfileDto profileDto) {
LambdaQueryWrapper<Profile> queryWrapper = Wrappers.<Profile>query().lambda();
if (null != profileDto) {
if (StrUtil.isNotBlank(profileDto.getName())) {
queryWrapper.like(Profile::getName, profileDto.getName());
}
if (null != profileDto.getShare()) {
queryWrapper.eq(Profile::getShare, profileDto.getShare());
}
if (null != profileDto.getEnable()) {
queryWrapper.eq(Profile::getEnable, profileDto.getEnable());
}
if (StrUtil.isNotBlank(profileDto.getTenantId())) {
queryWrapper.eq(Profile::getTenantId, profileDto.getTenantId());
}
if (ObjectUtil.isNotEmpty(profileDto)) {
queryWrapper.like(StrUtil.isNotBlank(profileDto.getName()), Profile::getName, profileDto.getName());
queryWrapper.eq(ObjectUtil.isNotEmpty(profileDto.getShare()), Profile::getShare, profileDto.getShare());
queryWrapper.eq(ObjectUtil.isNotEmpty(profileDto.getEnable()), Profile::getEnable, profileDto.getEnable());
queryWrapper.eq(StrUtil.isNotBlank(profileDto.getTenantId()), Profile::getTenantId, profileDto.getTenantId());
}
return queryWrapper;
}
public LambdaQueryWrapper<Profile> customFuzzyQuery(ProfileDto profileDto) {
QueryWrapper<Profile> queryWrapper = Wrappers.query();
queryWrapper.eq("dp.deleted", 0);
if (ObjectUtil.isNotNull(profileDto)) {
queryWrapper.like(StrUtil.isNotEmpty(profileDto.getName()), "dp.name", profileDto.getName());
queryWrapper.eq(ObjectUtil.isNotNull(profileDto.getShare()), "dp.share", profileDto.getShare());
queryWrapper.eq(ObjectUtil.isNotNull(profileDto.getEnable()), "dp.enable", profileDto.getEnable());
queryWrapper.eq(StrUtil.isNotEmpty(profileDto.getTenantId()), "dp.tenant_id", profileDto.getTenantId());
}
return queryWrapper.lambda();
}
}
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
spring:
datasource:
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2022 Pnoker All Rights Reserved
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.github.pnoker.center.manager.mapper.PointMapper">
<select id="selectPageWithDevice" resultType="io.github.pnoker.common.model.Point">
select
dp.id,
name,
type,
rw,
base,
minimum,
maximum,
multiple,
accrue,
format,
unit,
enable,
dp.profile_id,
group_id,
tenant_id,
dp.description,
dp.create_time,
dp.update_time,
dp.deleted
from dc3_point dp
<if test="deviceId != null and deviceId != ''">
inner join dc3_profile_bind dpb on dp.profile_id = dpb.profile_id and dpb.device_id = #{deviceId}
</if>
${ew.customSqlSegment}
</select>
</mapper>
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2022 Pnoker All Rights Reserved
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.github.pnoker.center.manager.mapper.ProfileMapper">
<select id="selectPageWithDevice" resultType="io.github.pnoker.common.model.Profile">
select dp.id,
dp.name,
share,
type,
dp.enable,
dp.group_id,
dp.tenant_id,
dp.description,
dp.create_time,
dp.update_time,
dp.deleted
from dc3_profile dp
<if test="deviceId != null and deviceId != ''">
inner join dc3_profile_bind dpb on dp.id = dpb.profile_id
inner join dc3_device dd on dpb.device_id = dd.id and dd.id = #{deviceId}
</if>
${ew.customSqlSegment}
</select>
</mapper>
@@ -15,4 +15,4 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
server:
# Turn off the self-protection mechanism
enable-self-preservation: false
@@ -35,10 +35,10 @@ import java.util.List;
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Dictionary {
private String type;
private String label;
private String value;
private boolean disabled;
private boolean expand = true;
private String type;
private List<Dictionary> children;
}
@@ -16,9 +16,9 @@
package io.github.pnoker.common.bean.point;
import io.github.pnoker.common.constant.CommonConstant;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.github.pnoker.common.constant.CommonConstant;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -65,7 +65,7 @@ public class PointValue implements Serializable {
*/
private String rawValue;
private List<PointValue> children;
private List<String> children;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonFormat(pattern = CommonConstant.Time.COMPLETE_DATE_FORMAT, timezone = CommonConstant.Time.TIMEZONE)
@@ -0,0 +1,57 @@
/*
* Copyright 2022 Pnoker All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.pnoker.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.github.pnoker.common.bean.Pages;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
/**
* Device DTO
*
* @author pnoker
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
public class DictionaryDto {
@JsonInclude(JsonInclude.Include.NON_NULL)
private Pages page;
/**
* 父级 Value 值1
*/
private String parentValue1;
/**
* 父级 Value 值1
*/
private String parentValue2;
private String value;
private String label;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
private String tenantId;
}
@@ -16,10 +16,10 @@
package io.github.pnoker.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.github.pnoker.common.base.Converter;
import io.github.pnoker.common.bean.Pages;
import io.github.pnoker.common.model.Point;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;
@@ -40,6 +40,8 @@ public class PointDto extends Point implements Converter<Point, PointDto> {
@JsonInclude(JsonInclude.Include.NON_NULL)
private Pages page;
private String deviceId;
@Override
public void convertDtoToDo(Point point) {
BeanUtils.copyProperties(this, point);
@@ -16,10 +16,10 @@
package io.github.pnoker.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.github.pnoker.common.base.Converter;
import io.github.pnoker.common.bean.Pages;
import io.github.pnoker.common.bean.point.PointValue;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -42,6 +42,9 @@ public class PointValueDto implements Serializable, Converter<PointValue, PointV
private String deviceId;
private String pointId;
private String name;
private Boolean enable;
private Boolean history = false;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Pages page;
@@ -16,10 +16,10 @@
package io.github.pnoker.common.dto;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.github.pnoker.common.base.Converter;
import io.github.pnoker.common.bean.Pages;
import io.github.pnoker.common.model.Profile;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.*;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;
@@ -40,6 +40,8 @@ public class ProfileDto extends Profile implements Converter<Profile, ProfileDto
@JsonInclude(JsonInclude.Include.NON_NULL)
private Pages page;
private String deviceId;
@Override
public void convertDtoToDo(Profile profile) {
BeanUtils.copyProperties(this, profile);
@@ -16,6 +16,7 @@
package io.github.pnoker.common.sdk.bean.mqtt;
import cn.hutool.core.util.ObjectUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -43,10 +44,10 @@ public class MessageHeader implements Serializable {
private Long timestamp;
public MessageHeader(MessageHeaders messageHeaders) {
if (null != messageHeaders) {
if (ObjectUtil.isNotNull(messageHeaders)) {
try {
UUID id = messageHeaders.get("id", UUID.class);
if (null != id) {
if (ObjectUtil.isNotNull(id)) {
this.id = id.toString();
}
} catch (Exception ignored) {
@@ -17,6 +17,7 @@
package io.github.pnoker.common.sdk.service.impl;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ObjectUtil;
import io.github.pnoker.common.bean.driver.AttributeInfo;
import io.github.pnoker.common.bean.driver.DriverRegister;
import io.github.pnoker.common.constant.CommonConstant;
@@ -134,7 +135,7 @@ public class DriverMetadataServiceImpl implements DriverMetadataService {
@Override
public void upsertDriverInfo(DriverInfo driverInfo) {
DriverAttribute attribute = driverContext.getDriverMetadata().getDriverAttributeMap().get(driverInfo.getDriverAttributeId());
if (null != attribute) {
if (ObjectUtil.isNotNull(attribute)) {
// Add driver info to driver info map context
driverContext.getDriverMetadata().getDriverInfoMap().computeIfAbsent(driverInfo.getDeviceId(), k -> new ConcurrentHashMap<>(16))
.put(attribute.getName(), new AttributeInfo(driverInfo.getValue(), attribute.getType()));
@@ -144,7 +145,7 @@ public class DriverMetadataServiceImpl implements DriverMetadataService {
@Override
public void deleteDriverInfo(String deviceId, String attributeId) {
DriverAttribute attribute = driverContext.getDriverMetadata().getDriverAttributeMap().get(attributeId);
if (null != attribute) {
if (ObjectUtil.isNotNull(attribute)) {
// Delete driver info from driver info map context
driverContext.getDriverMetadata().getDriverInfoMap().computeIfPresent(deviceId, (k, v) -> {
v.entrySet().removeIf(next -> next.getKey().equals(attribute.getName()));
@@ -159,7 +160,7 @@ public class DriverMetadataServiceImpl implements DriverMetadataService {
@Override
public void upsertPointInfo(PointInfo pointInfo) {
PointAttribute attribute = driverContext.getDriverMetadata().getPointAttributeMap().get(pointInfo.getPointAttributeId());
if (null != attribute) {
if (ObjectUtil.isNotNull(attribute)) {
// Add the point info to the device point info map context
driverContext.getDriverMetadata().getPointInfoMap().computeIfAbsent(pointInfo.getDeviceId(), k -> new ConcurrentHashMap<>(16))
.computeIfAbsent(pointInfo.getPointId(), k -> new ConcurrentHashMap<>(16))
@@ -170,7 +171,7 @@ public class DriverMetadataServiceImpl implements DriverMetadataService {
@Override
public void deletePointInfo(String deviceId, String pointId, String attributeId) {
PointAttribute attribute = driverContext.getDriverMetadata().getPointAttributeMap().get(attributeId);
if (null != attribute) {
if (ObjectUtil.isNotNull(attribute)) {
// Delete the point info from the device info map context
driverContext.getDriverMetadata().getPointInfoMap().computeIfPresent(deviceId, (key1, value1) -> {
value1.computeIfPresent(pointId, (key2, value2) -> {
@@ -82,7 +82,7 @@ public class DriverServiceImpl implements DriverService {
deviceEventSender(deviceId, pointId, CommonConstant.Device.Event.OVER_UPPER_LIMIT,
String.format("Value(%s) is greater than upper limit %s", temp, point.getMaximum()));
}
if (StrUtil.isNotBlank(point.getFormat())) {
if (StrUtil.isNotEmpty(point.getFormat())) {
value = String.format(point.getFormat(), temp);
} else {
value = String.valueOf(temp);
@@ -33,6 +33,7 @@ import javax.annotation.Resource;
@Slf4j
@Component
public class DriverCustomScheduleJob extends QuartzJobBean {
@Resource
private DriverCustomService driverCustomService;
@@ -2,7 +2,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -2,7 +2,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -2,7 +2,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -2,7 +2,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -7,7 +7,7 @@ driver:
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
# Log config
logging:
@@ -60,7 +60,7 @@ public class GatewayUtil {
*/
public static String getRequestHeader(ServerHttpRequest request, String key) {
String header = request.getHeaders().getFirst(key);
if (!StrUtil.isNotBlank(header)) {
if (!StrUtil.isNotEmpty(header)) {
throw new NotFoundException("Invalid request header of " + key);
}
return header;
@@ -75,7 +75,7 @@ public class GatewayUtil {
*/
public static String getRequestCookie(ServerHttpRequest request, String key) {
HttpCookie cookie = request.getCookies().getFirst(key);
if (null == cookie || !StrUtil.isNotBlank(cookie.getValue())) {
if (null == cookie || !StrUtil.isNotEmpty(cookie.getValue())) {
throw new NotFoundException("Invalid request cookie of " + key);
}
return cookie.getValue();
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
spring:
redis:
@@ -16,10 +16,12 @@
package io.github.pnoker.transfer.rtmp.api;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.github.pnoker.api.transfer.rtmp.feign.RtmpClient;
import io.github.pnoker.common.bean.R;
import io.github.pnoker.common.constant.ServiceConstant;
import io.github.pnoker.common.dto.ProfileDto;
import io.github.pnoker.common.dto.RtmpDto;
import io.github.pnoker.common.model.Rtmp;
import io.github.pnoker.transfer.rtmp.service.RtmpService;
@@ -38,6 +40,7 @@ import javax.annotation.Resource;
@RestController
@RequestMapping(ServiceConstant.Rtmp.URL_PREFIX)
public class RtmpApi implements RtmpClient {
@Resource
private RtmpService rtmpService;
@@ -92,9 +95,12 @@ public class RtmpApi implements RtmpClient {
@Override
public R<Page<Rtmp>> list(RtmpDto rtmpDto, String tenantId) {
try {
if (ObjectUtil.isEmpty(rtmpDto)) {
rtmpDto = new RtmpDto();
}
rtmpDto.setTenantId(tenantId);
Page<Rtmp> page = rtmpService.list(rtmpDto);
if (null != page) {
if (ObjectUtil.isNotNull(page)) {
return R.ok(page);
}
} catch (Exception e) {
@@ -16,6 +16,7 @@
package io.github.pnoker.transfer.rtmp.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RuntimeUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -72,9 +73,9 @@ public class RtmpServiceImpl implements RtmpService {
@Override
public boolean delete(String id) {
Rtmp select = selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
Transcode transcode = transcodeMap.get(id);
if (null != transcode) {
if (ObjectUtil.isNotNull(transcode)) {
if (transcode.isRun()) {
throw new ServiceException("The rmp task is running");
}
@@ -93,7 +94,7 @@ public class RtmpServiceImpl implements RtmpService {
throw new NotFoundException("The rtmp task does not exist");
}
Transcode transcode = transcodeMap.get(rtmp.getId());
if (null != transcode) {
if (ObjectUtil.isNotNull(transcode)) {
if (transcode.isRun()) {
throw new ServiceException("The rtmp task is running");
}
@@ -192,9 +193,9 @@ public class RtmpServiceImpl implements RtmpService {
@Override
public boolean stop(String id) {
Rtmp select = rtmpMapper.selectById(id);
if (null != select) {
if (ObjectUtil.isNotNull(select)) {
Transcode transcode = transcodeMap.get(id);
if (null != transcode) {
if (ObjectUtil.isNotNull(transcode)) {
if (transcode.isRun()) {
transcode.quit();
if (rtmpMapper.updateById(select.setRun(false)) > 0) {
@@ -211,16 +212,10 @@ public class RtmpServiceImpl implements RtmpService {
@Override
public LambdaQueryWrapper<Rtmp> fuzzyQuery(RtmpDto rtmpDto) {
LambdaQueryWrapper<Rtmp> queryWrapper = Wrappers.<Rtmp>query().lambda();
if (null != rtmpDto) {
if (StrUtil.isNotBlank(rtmpDto.getName())) {
queryWrapper.like(Rtmp::getName, rtmpDto.getName());
}
if (null != rtmpDto.getAutoStart()) {
queryWrapper.eq(Rtmp::getAutoStart, rtmpDto.getAutoStart());
}
if (StrUtil.isNotBlank(rtmpDto.getTenantId())) {
queryWrapper.eq(Rtmp::getTenantId, rtmpDto.getTenantId());
}
if (ObjectUtil.isNotNull(rtmpDto)) {
queryWrapper.like(StrUtil.isNotEmpty(rtmpDto.getName()), Rtmp::getName, rtmpDto.getName());
queryWrapper.eq(ObjectUtil.isNotNull(rtmpDto.getAutoStart()), Rtmp::getAutoStart, rtmpDto.getAutoStart());
queryWrapper.eq(StrUtil.isNotEmpty(rtmpDto.getTenantId()), Rtmp::getTenantId, rtmpDto.getTenantId());
}
return queryWrapper;
}
@@ -15,7 +15,7 @@
eureka:
instance:
# Custom node registration IP
ip-address: ${SERVICE_HOST:192.168.0.106}
ip-address: ${SERVICE_HOST:192.168.0.101}
spring:
datasource:
+14 -19
View File
@@ -13,43 +13,38 @@
### 查询 Driver Dictionary
#/manager/dictionary/driver
GET http://localhost:8400/manager/dictionary/driver
Accept: */*
Cache-Control: no-cache
### 查询 PointAttribute Dictionary
#/manager/dictionary/point_attribute
GET http://localhost:8400/manager/dictionary/point_attribute
POST http://localhost:8400/manager/dictionary/driver
Accept: */*
Content-Type: application/json
Cache-Control: no-cache
{}
### 查询 Profile Dictionary
#/manager/dictionary/profile
GET http://localhost:8400/manager/dictionary/profile
POST http://localhost:8400/manager/dictionary/profile
Accept: */*
Content-Type: application/json
Cache-Control: no-cache
{}
### 查询 Device/driver Dictionary
#/manager/dictionary/device/driver
GET http://localhost:8400/manager/dictionary/device/driver
#/manager/dictionary/device
POST http://localhost:8400/manager/dictionary/device
Accept: */*
Content-Type: application/json
Cache-Control: no-cache
{}
### 查询 Point/profile Dictionary
#/manager/dictionary/point/profile
GET http://localhost:8400/manager/dictionary/point/profile
#/manager/dictionary/point
POST http://localhost:8400/manager/dictionary/point
Accept: */*
Content-Type: application/json
Cache-Control: no-cache
### 查询 Point/device Dictionary
#/manager/dictionary/point/device
GET http://localhost:8400/manager/dictionary/point/device
Accept: */*
Cache-Control: no-cache
{}
###
+6 -6
View File
@@ -71,10 +71,10 @@ if (db.createCollection("point_value")) {
);
db.pointValue.createIndex(
{
originTime: 1,
createTime: 1,
},
{
name: "IX_origin_time",
name: "IX_create_time",
unique: false,
background: true,
}
@@ -94,10 +94,10 @@ if (db.createCollection("driver_event")) {
);
db.driverEvent.createIndex(
{
originTime: 1,
createTime: 1,
},
{
name: "IX_origin_time",
name: "IX_create_time",
unique: false,
background: true,
}
@@ -118,10 +118,10 @@ if (db.createCollection("device_event")) {
);
db.deviceEvent.createIndex(
{
originTime: 1,
createTime: 1,
},
{
name: "IX_origin_time",
name: "IX_create_time",
unique: false,
background: true,
}
+1 -1
View File
@@ -27,7 +27,7 @@
</ThreadGroup>
<hashTree>
<net.xmeter.samplers.ConnectSampler guiclass="net.xmeter.gui.ConnectSamplerUI" testclass="net.xmeter.samplers.ConnectSampler" testname="MQTT Connect" enabled="true">
<stringProp name="mqtt.server">192.168.0.106</stringProp>
<stringProp name="mqtt.server">192.168.0.101</stringProp>
<stringProp name="mqtt.port">1884</stringProp>
<stringProp name="mqtt.version">3.1</stringProp>
<stringProp name="mqtt.conn_timeout">10</stringProp>
+2 -2
View File
@@ -80,9 +80,9 @@ docker-compose up -d mysql redis mongo rabbitmq register auth
Main函数为位置:
`dc3-center-manager`:dc3-center/dc3-center-manager/src/main/java/com/dc3/center/manager/ManagerApplication.java
`dc3-center-manager`:dc3-center/dc3-center-manager/src/main/java/io/github/pnoker/center/manager/ManagerApplication.java
`dc3-center-data`:dc3-center/dc3-center-data/src/main/java/com/dc3/center/data/DataApplication.java
`dc3-center-data`:dc3-center/dc3-center-data/src/main/java/io/github/pnoker/center/data/DataApplication.java
注意:在启动 `dc3-center-manager` 、 `dc3-center-data` 的时候由于开启了 `ASPECTJ` ,所以需要配置 `-javaagent:dc3/lib/aspectjweaver-1.9.5.jar`