提交修改

This commit is contained in:
LEED
2025-03-27 17:15:27 +08:00
parent 6a8cbff440
commit 988e68bdc7
47 changed files with 1051 additions and 255 deletions

View File

@@ -135,51 +135,56 @@ public class SysDeptController extends BaseController
return error(StringUtils.format(MessageUtils.message("dept.add.failed.name.exists"), dept.getDeptName())); return error(StringUtils.format(MessageUtils.message("dept.add.failed.name.exists"), dept.getDeptName()));
} }
dept.setCreateBy(getUsername()); dept.setCreateBy(getUsername());
// 校验系统账号信息 if(dept.getDeptType()>1){
if (StringUtils.isNotEmpty(dept.getUserName())) { int result = deptService.insertDept(dept);
SysUser sysUser = sysUserService.selectUserByUserName(dept.getUserName()); return toAjax(result);
if (ObjectUtil.isNotNull(sysUser)) { }else{
throw new ServiceException(MessageUtils.message("user.username.exists")); // 校验系统账号信息
if (StringUtils.isNotEmpty(dept.getUserName())) {
SysUser sysUser = sysUserService.selectUserByUserName(dept.getUserName());
if (ObjectUtil.isNotNull(sysUser)) {
throw new ServiceException(MessageUtils.message("user.username.exists"));
}
if (!dept.getPassword().equals(dept.getConfirmPassword())) {
throw new ServiceException(MessageUtils.message("user.password.differ"));
}
} }
if (!dept.getPassword().equals(dept.getConfirmPassword())) { int result = deptService.insertDept(dept);
throw new ServiceException(MessageUtils.message("user.password.differ")); // 新增机构关联系统账号
} if (result > 0) {
} // 添加管理员角色,给所有权限
int result = deptService.insertDept(dept); // 查询所有权限
// 新增机构关联系统账号
if (result > 0) {
// 添加管理员角色,给所有权限
// 查询所有权限
// List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), 1L, request.getHeader(LANGUAGE)); // List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), 1L, request.getHeader(LANGUAGE));
SysDept sysDept = deptService.selectDeptById(dept.getParentId()); SysDept sysDept = deptService.selectDeptById(dept.getParentId());
List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId()); List<SysMenu> sysMenuList = sysMenuService.selectMenuList(new SysMenu(), sysDept.getDeptUserId());
Long[] menuIdList = sysMenuList.stream().map(SysMenu::getMenuId).toArray(Long[]::new); Long[] menuIdList = sysMenuList.stream().map(SysMenu::getMenuId).toArray(Long[]::new);
SysRole sysRole = new SysRole(); SysRole sysRole = new SysRole();
sysRole.setRoleName("管理员"); sysRole.setRoleName("管理员");
sysRole.setRoleKey("manager"); sysRole.setRoleKey("manager");
sysRole.setRoleSort(1); sysRole.setRoleSort(1);
sysRole.setStatus("0"); sysRole.setStatus("0");
sysRole.setDeptId(dept.getDeptId()); sysRole.setDeptId(dept.getDeptId());
sysRole.setMenuIds(menuIdList); sysRole.setMenuIds(menuIdList);
sysRoleService.insertRole(sysRole); sysRoleService.insertRole(sysRole);
// 注册机构管理员用户 // 注册机构管理员用户
RegisterUserInput registerUserInput = new RegisterUserInput(); RegisterUserInput registerUserInput = new RegisterUserInput();
registerUserInput.setUsername(dept.getUserName()); registerUserInput.setUsername(dept.getUserName());
registerUserInput.setPassword(dept.getPassword()); registerUserInput.setPassword(dept.getPassword());
registerUserInput.setPhonenumber(dept.getPhone()); registerUserInput.setPhonenumber(dept.getPhone());
registerUserInput.setDeptId(dept.getDeptId()); registerUserInput.setDeptId(dept.getDeptId());
registerUserInput.setRoleIds(new Long[]{sysRole.getRoleId()}); registerUserInput.setRoleIds(new Long[]{sysRole.getRoleId()});
RegisterUserOutput registerUserOutput = toolService.registerNoCaptcha(registerUserInput); RegisterUserOutput registerUserOutput = toolService.registerNoCaptcha(registerUserInput);
if (StringUtils.isNotEmpty(registerUserOutput.getMsg())) { if (StringUtils.isNotEmpty(registerUserOutput.getMsg())) {
deptService.deleteDeptById(dept.getDeptId()); deptService.deleteDeptById(dept.getDeptId());
sysRoleService.deleteRoleById(sysRole.getRoleId()); sysRoleService.deleteRoleById(sysRole.getRoleId());
return AjaxResult.error(registerUserOutput.getMsg()); return AjaxResult.error(registerUserOutput.getMsg());
}
// 更新机构管理员角色绑定信息
deptService.updateDeptUserId(dept.getDeptId(), registerUserOutput.getSysUserId());
} }
// 更新机构管理员角色绑定信息 return toAjax(result);
deptService.updateDeptUserId(dept.getDeptId(), registerUserOutput.getSysUserId());
} }
return toAjax(result);
} }
/** /**

View File

@@ -284,6 +284,16 @@ public class SysUserController extends BaseController
return success(deptService.selectDeptTreeList(dept)); return success(deptService.selectDeptTreeList(dept));
} }
/**
* 获取部门树列表
*/
@ApiOperation("获取部门树列表")
@GetMapping("/depProTree")
public AjaxResult deptProTree(SysDept dept)
{
return success(deptService.selectDeptProTreeList(dept));
}
/** /**
* 获取终端用户列表 * 获取终端用户列表
* @param user 用户信息 * @param user 用户信息

View File

@@ -0,0 +1,89 @@
package com.xinda.common.core.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.xinda.common.core.domain.entity.SysDept;
import com.xinda.common.core.domain.entity.SysMenu;
import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;
/**
* Treeselect树结构实体类
*
* @author ruoyi
*/
public class TreeProSelect implements Serializable
{
private static final long serialVersionUID = 1L;
/** 节点ID */
private Long id;
/** 节点名称 */
private String label;
private Integer type;
/** 子节点 */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<TreeProSelect> children;
public TreeProSelect()
{
}
public TreeProSelect(SysDept dept)
{
this.id = dept.getDeptId();
this.label = dept.getDeptName();
this.type = dept.getDeptType();
this.children = dept.getChildren().stream().map(TreeProSelect::new).collect(Collectors.toList());
}
public TreeProSelect(SysMenu menu)
{
this.id = menu.getMenuId();
this.label = menu.getMenuName();
this.children = menu.getChildren().stream().map(TreeProSelect::new).collect(Collectors.toList());
}
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getLabel()
{
return label;
}
public void setLabel(String label)
{
this.label = label;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public List<TreeProSelect> getChildren()
{
return children;
}
public void setChildren(List<TreeProSelect> children)
{
this.children = children;
}
}

View File

@@ -91,9 +91,10 @@ public class DeviceStatusConsumer {
if (!containsKey && isOnline) { if (!containsKey && isOnline) {
bo.setStatus(DeviceStatus.OFFLINE); bo.setStatus(DeviceStatus.OFFLINE);
} }
// 判断下 项目id // 判断下 项目机构tStatus().getDescription().equals("离线")){
if(bo.getStatus().getDescription().equals("离线")){ if(bo.getStatus().getDescription().equals("离线")){
if (device.getGroupId().equals(0L) || device.getGroupId() == null) { // if (device.getGroupId().equals(0L) || device.getGroupId() == null) {
if (device.getAgenciesId() == null) {
//设置删除状态 todo //设置删除状态 todo
device.setDelFlag("2"); device.setDelFlag("2");
} }

View File

@@ -50,7 +50,8 @@ public class DeviceOtherMsgHandler {
if (bo.getTopicName().startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix()) || bo.getTopicName().startsWith(TopicType.FUNCTION_XINDA_DOWN.getTopicSuffix())) { if (bo.getTopicName().startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix()) || bo.getTopicName().startsWith(TopicType.FUNCTION_XINDA_DOWN.getTopicSuffix())) {
name = topicsUtils.parseNewTopicName(bo.getTopicName()); name = topicsUtils.parseNewTopicName(bo.getTopicName());
}else{ }else{
name = topicsUtils.parseTopicName(bo.getTopicName()); return;
// name = topicsUtils.parseTopicName(bo.getTopicName());
} }
if (StringUtils.isEmpty(name) || name.endsWith(TopicType.FUNCTION_GET.getTopicSuffix()) || name.startsWith(TopicType.FUNCTION_XINDA_DOWN.getTopicSuffix()) ) return; if (StringUtils.isEmpty(name) || name.endsWith(TopicType.FUNCTION_GET.getTopicSuffix()) || name.startsWith(TopicType.FUNCTION_XINDA_DOWN.getTopicSuffix()) ) return;
ReportDataBo data = this.buildReportData(bo); ReportDataBo data = this.buildReportData(bo);

View File

@@ -84,6 +84,7 @@ public class RuleEngineHandler implements IRuleEngine {
for(Script script : list) { for(Script script : list) {
requestId = requestId + "/" + script.getScriptId(); requestId = requestId + "/" + script.getScriptId();
} }
// String requestId = "scene/" + scene.getChainName();
flowExecutor.execute2FutureWithRid(scene.getChainName(), null, requestId, context); flowExecutor.execute2FutureWithRid(scene.getChainName(), null, requestId, context);
} }
} }

View File

@@ -108,6 +108,33 @@ public class DeviceController extends BaseController
return getDataTable(deviceService.selectDeviceListByGroup(device)); return getDataTable(deviceService.selectDeviceListByGroup(device));
} }
/**
* 查询设备简短列表,主页列表数据
*/
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/gshortList")
@ApiOperation("设备分页简短列表")
public TableDataInfo gshortList1(Device device)
{
startPage();
LoginUser loginUser = getLoginUser();
if (null == loginUser.getDeptId()) {
// 终端用户查询设备
device.setTenantId(loginUser.getUserId());
return getDataTable(deviceService.listTerminalUser(device));
}
if (null == device.getDeptId()) {
device.setDeptId(getLoginUser().getDeptId());
}
if (Objects.isNull(device.getTenantId())){
device.setTenantId(getLoginUser().getUserId());
}
if (null == device.getShowChild()) {
device.setShowChild(false);
}
return getDataTable(deviceService.selectGDeviceShortList(device));
}
/** /**
* 查询设备简短列表,主页列表数据 * 查询设备简短列表,主页列表数据
*/ */
@@ -189,6 +216,8 @@ public class DeviceController extends BaseController
return AjaxResult.success(device); return AjaxResult.success(device);
} }
/** /**
* 设备数据同步 * 设备数据同步
*/ */

View File

@@ -111,4 +111,15 @@ public class FunctionLogController extends BaseController
{ {
return toAjax(functionLogService.deleteFunctionLogByIds(ids)); return toAjax(functionLogService.deleteFunctionLogByIds(ids));
} }
@ApiOperation("清空日志")
@Log(title = "清空日志", businessType = BusinessType.CLEAN)
@PreAuthorize("@ss.hasPermi('iot:log:remove')")
@DeleteMapping("/clean/{serialNumber}")
public AjaxResult clean(@PathVariable("serialNumber") String serialNumber)
{
functionLogService.cleanOperLog(serialNumber);
return success();
}
} }

View File

@@ -10,6 +10,7 @@ import com.xinda.common.utils.StringUtils;
import com.xinda.common.utils.poi.ExcelUtil; import com.xinda.common.utils.poi.ExcelUtil;
import com.xinda.iot.cache.ITSLCache; import com.xinda.iot.cache.ITSLCache;
import com.xinda.iot.domain.ThingsModel; import com.xinda.iot.domain.ThingsModel;
import com.xinda.iot.model.ImportCategoryModelInput;
import com.xinda.iot.model.ImportStandardModelInput; import com.xinda.iot.model.ImportStandardModelInput;
import com.xinda.iot.model.ImportThingsModelInput; import com.xinda.iot.model.ImportThingsModelInput;
import com.xinda.iot.model.ThingsModelPerm; import com.xinda.iot.model.ThingsModelPerm;
@@ -126,6 +127,18 @@ public class ThingsModelController extends BaseController
} }
} }
@PostMapping("/importCategory")
@ApiOperation("导入产品分类")
public AjaxResult ImportByCategoryId(@RequestBody ImportCategoryModelInput input){
int repeatCount=thingsModelService.importBytCategoryId(input);
if(repeatCount==0){
return AjaxResult.success(MessageUtils.message("import.success"));
}else{
return AjaxResult.success(StringUtils.format(MessageUtils.message("things.model.import.failed.identifier.repeat"), repeatCount));
}
}
/** /**
* 修改物模型 * 修改物模型
*/ */
@@ -157,6 +170,19 @@ public class ThingsModelController extends BaseController
return toAjax(thingsModelService.deleteThingsModelByModelIds(modelIds)); return toAjax(thingsModelService.deleteThingsModelByModelIds(modelIds));
} }
/**
* 删除物模型
*/
@PreAuthorize("@ss.hasPermi('iot:model:remove')")
@Log(title = "清空物模型", businessType = BusinessType.DELETE)
@DeleteMapping("delAll/{productId}")
@ApiOperation("清空物模型")
public AjaxResult removeAll(@PathVariable Long productId)
{
thingsModelService.deleteProductThingsModelAndCacheByProductId(productId);
return toAjax(1);
}
/** /**
* 获取缓存的JSON物模型 * 获取缓存的JSON物模型
*/ */

View File

@@ -74,18 +74,26 @@ public class ThingsModelStandardController extends BaseController {
@PostMapping @PostMapping
@ApiOperation("添加通用物模型") @ApiOperation("添加通用物模型")
public AjaxResult add(@RequestBody ThingsModelStandard thingsModelStandard) { public AjaxResult add(@RequestBody ThingsModelStandard thingsModelStandard) {
return toAjax(thingsModelStandardService.insertThingsModelStandard(thingsModelStandard)); if(thingsModelStandardService.checkUnique(thingsModelStandard)){
return error("模板下存在重复标识符,请重新输入");
}else{
return toAjax(thingsModelStandardService.insertThingsModelStandard(thingsModelStandard));
}
} }
/** /**
* 修改通用物模型 * 修改通用物模型
*/ */
@PreAuthorize("@ss.hasPermi('iot:standard:edit')") // @PreAuthorize("@ss.hasPermi('iot:standard:edit')")
@Log(title = "通用物模型", businessType = BusinessType.UPDATE) @Log(title = "通用物模型", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
@ApiOperation("修改通用物模型") @ApiOperation("修改通用物模型")
public AjaxResult edit(@RequestBody ThingsModelStandard thingsModelStandard) { public AjaxResult edit(@RequestBody ThingsModelStandard thingsModelStandard) {
return toAjax(thingsModelStandardService.updateThingsModelStandard(thingsModelStandard)); if(thingsModelStandardService.checkUnique(thingsModelStandard)){
return error("模板下存在重复标识符,请重新输入");
}else{
return toAjax(thingsModelStandardService.updateThingsModelStandard(thingsModelStandard));
}
} }
/** /**

View File

@@ -27,6 +27,7 @@ import javax.annotation.Resource;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.*; import java.util.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@@ -109,7 +110,18 @@ public class IECF6113ProtocolService implements IProtocol {
* } * }
* </p> * </p>
* *
* {"AD6":0.20666666666667,"AD15":0.22,"AD14":0.22,"AD7":0.20666666666667,"AD11":0.20666666666667,
* "AD1":18.886666666667,"AD4":0.22,"AD3":0.22,"AD10":0.22,"AD8":15.526666666667,"AD16":0.22,"AD12":0.22,
* "AD13":0.22,"AD9":0.20666666666667,"AD2":0.22,"AD5":0.22}
* {"I0.1":0,"I0.3":0,"I0.4":0,"I0.6":0,"I0.5":0,"I0.2":0}
* {"K0":1001,"温度":17.9375,"K1":48303.94921875,"标况流量":0,"工况流量":0,"压力":96.8515625}
* {"lng":"104.1536100","lat":"030.8336398","PAD":4185,"CSQ":28}
*/ */
private static final Set<String> EXCLUDE_KEYS = new HashSet<>(Arrays.asList(
"AD1", "AD2", "AD3","AD4", "AD5", "AD6","AD7", "AD8", "AD9","AD10", "AD11", "AD12",
"AD13", "AD14", "AD15","AD16", "I0.1", "I0.2","I0.3", "I0.4", "I0.5","I0.6","lng", "lat", "PAD", "CSQ",
"K0", "K1", "温度","温度1", "标况流量", "工况流量", "压力"
));
@Override @Override
public DeviceReport decode(DeviceData deviceData, String clientId) { public DeviceReport decode(DeviceData deviceData, String clientId) {
try { try {
@@ -120,37 +132,38 @@ public class IECF6113ProtocolService implements IProtocol {
log.info(data); log.info(data);
}else{ }else{
Map<String,Object> values = JSON.parseObject(data, Map.class); Map<String,Object> values = JSON.parseObject(data, Map.class);
if (values.containsKey("AD1") || values.containsKey("lng") || values.containsKey("I0.1")||values.containsKey("PAD")){ // if (values.containsKey("AD1") || values.containsKey("lng") || values.containsKey("I0.1")||values.containsKey("PAD")||values.containsKey("K1")){
// 初始化纬度变量使用BigDecimal来存储高精度值 // 初始化纬度变量使用BigDecimal来存储高精度值
BigDecimal latitude = new BigDecimal("39.9042"); BigDecimal latitude = new BigDecimal("39.9042");
// 初始化经度变量同样使用BigDecimal // 初始化经度变量同样使用BigDecimal
BigDecimal longitude = new BigDecimal("116.4074"); BigDecimal longitude = new BigDecimal("116.4074");
for (Map.Entry<String, Object> entry : values.entrySet()) { for (Map.Entry<String, Object> entry : values.entrySet()) {
// JSONArray value = (JSONArray) entry.getValue(); // if (EXCLUDE_KEYS.contains(entry.getKey())){
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem(); ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
simpleItem.setTs(DateUtils.getNowDate()); simpleItem.setTs(DateUtils.getNowDate());
simpleItem.setId(entry.getKey()); simpleItem.setId(entry.getKey());
simpleItem.setValue(entry.getValue()+""); simpleItem.setValue(entry.getValue()+"");
result.add(simpleItem); result.add(simpleItem);
if(values.containsKey("lng")) { if(values.containsKey("lng")) {
if (entry.getKey().equals("lng")) { if (entry.getKey().equals("lng")) {
longitude = new BigDecimal(entry.getValue() + ""); longitude = new BigDecimal(entry.getValue() + "");
}
if (entry.getKey().equals("lat")) { }
latitude = new BigDecimal(entry.getValue() + ""); if (entry.getKey().equals("lat")) {
latitude = new BigDecimal(entry.getValue() + "");
}
//更新设备经纬度信息 //更新设备经纬度信息
Device device = new Device(); Device device = new Device();
device.setSerialNumber(deviceData.getSerialNumber()); device.setSerialNumber(deviceData.getSerialNumber());
device.setLatitude(latitude);
device.setLongitude(longitude); device.setLongitude(longitude);
device.setLatitude(latitude);
deviceService.updateDeviceStatus(device); deviceService.updateDeviceStatus(device);
} }
} // }
} }
} // }
} }
reportMessage.setThingsModelSimpleItem(result); reportMessage.setThingsModelSimpleItem(result);
reportMessage.setClientId(clientId); reportMessage.setClientId(clientId);
reportMessage.setSerialNumber(clientId); reportMessage.setSerialNumber(clientId);
@@ -166,7 +179,8 @@ public class IECF6113ProtocolService implements IProtocol {
* 3.查询输入开关量 GKB29810,IPUT, * 3.查询输入开关量 GKB29810,IPUT,
* 4.更改上报时间 GKB29810,JCZ,{"TIME":20} * 4.更改上报时间 GKB29810,JCZ,{"TIME":20}
* 5.通 信 控制 GKB29810,MODBUS, {"KO":12} * 5.通 信 控制 GKB29810,MODBUS, {"KO":12}
* 6.开关量输出控制 GKB29810,OUT,{"Q0.1":0,"Q0.2":0,"Q0.3":0,"Q0.4":0,"Q0.5":0,"Q0.6":0}GKB29810,0UT,{"Q0.1":1 ,"Q0.2":1,"Q0.3":1,"Q0.4":1,"Q0.5":1 "Q0.6":1) * 6.开关量输出控制 GKB29810,OUT,{"Q0.1":0,"Q0.2":0,"Q0.3":0,"Q0.4":0,"Q0.5":0,"Q0.6":0}
* GKB29810,0UT,{"Q0.1":1 ,"Q0.2":1,"Q0.3":1,"Q0.4":1,"Q0.5":1 "Q0.6":1)
* @param message * @param message
* @return * @return
*/ */
@@ -176,17 +190,59 @@ public class IECF6113ProtocolService implements IProtocol {
FunctionCallBackBo callBack = new FunctionCallBackBo(); FunctionCallBackBo callBack = new FunctionCallBackBo();
JSONObject params = message.getParams(); JSONObject params = message.getParams();
// Map<String,Object> values = JSON.parseObject(data, Map.class); // Map<String,Object> values = JSON.parseObject(data, Map.class);
ValueItem valueItem = new ValueItem(); // JSONObject subJson = new JSONObject();
// for (Map.Entry<String, Object> entry : params.entrySet()) {
// String key = entry.getKey();
// if (checkVariable(key)) {
// subJson.put(key, params.get(key));
// }
// }
// if (!subJson.isEmpty()) {
// String msg = "GKB29810,MODBUS, " + subJson.toJSONString();
// callBack.setSources(msg);
// callBack.setMessage(msg.getBytes());
// }
// 调用方法检查并获取以前缀开头的键和值
Map<String, Object> modresult = getValidKeyValuesToMap(params);
// 输出结果
if (!modresult.isEmpty()) {
StringBuilder msg = new StringBuilder("GKB29810,MODBUS,{\"");
modresult.forEach((k, v) -> {
msg.append(k).append("\":").append(v).append(",");
});
// 删除最后一个逗号
if (msg.charAt(msg.length() - 1) == ',') {
msg.deleteCharAt(msg.length() - 1);
}
// 添加结尾的双引号和大括号
msg.append("}");
callBack.setSources(msg.toString());
callBack.setMessage(msg.toString().getBytes());
}
// 调用方法检查并获取以前缀开头的键和值
Map<String, Object> chinaresult = getChineseKeyValues(params);
// 输出结果
if (!chinaresult.isEmpty()) {
StringBuilder msg = new StringBuilder("GKB29810,MODBUS,{\"");
chinaresult.forEach((k, v) -> {
msg.append(k).append("\":").append(v).append(",");
});
// 删除最后一个逗号
if (msg.charAt(msg.length() - 1) == ',') {
msg.deleteCharAt(msg.length() - 1);
}
// 添加结尾的双引号和大括号
msg.append("}");
callBack.setSources(msg.toString());
callBack.setMessage(msg.toString().getBytes());
}
if(params.containsKey("select")) { if(params.containsKey("select")) {
String msg = params.get("select") + ""; String msg = params.get("select") + "";
callBack.setSources(msg); callBack.setSources(msg);
callBack.setMessage(msg.getBytes()); callBack.setMessage(msg.getBytes());
} }
if(params.containsKey("MODBUS")){
String msg ="GKB29810,MODBUS," + params.get("MODBUS");
callBack.setSources(msg);
callBack.setMessage(msg.getBytes());
}
if(params.containsKey("OUT")){ if(params.containsKey("OUT")){
String msg = params.get("OUT") + ""; String msg = params.get("OUT") + "";
callBack.setSources(msg); callBack.setSources(msg);
@@ -246,4 +302,88 @@ public class IECF6113ProtocolService implements IProtocol {
return result; return result;
} }
// 生成所有符合规则的变量集合
private static Set<String> generateAllValidVariables() {
Set<String> validVariables = new HashSet<>();
// 生成字节型变量
for (int i = 0; i <= 30000; i++) {
validVariables.add("MB" + i);
validVariables.add("VB" + i);
}
// 生成字型变量
for (int i = 0; i <= 30000; i++) {
validVariables.add("MW" + i);
validVariables.add("VW" + i);
}
// 生成双字型变量
for (int i = 0; i <= 30000; i++) {
validVariables.add("MD" + i);
validVariables.add("VD" + i);
}
// 生成其他变量
for (int i = 0; i <= 30000; i++) {
validVariables.add("M" + i);
validVariables.add("D" + i);
validVariables.add("Y" + i);
validVariables.add("N" + i);
validVariables.add("Q" + i);
}
return validVariables;
}
// 获取包含在指定变量范围内的 params 变量的键和值
public static JSONObject getValidKeyValues(JSONObject params) {
Set<String> validVariables = generateAllValidVariables();
JSONObject validKeyValues = new JSONObject();
for (String key : params.keySet()) {
if (validVariables.contains(key)) {
validKeyValues.put(key, params.get(key));
}
}
return validKeyValues;
}
// 检测 params 中的键是否在有效变量范围内
public static boolean checkParams(JSONObject params) {
Set<String> validVariables = generateAllValidVariables();
for (String key : params.keySet()) {
if (validVariables.contains(key)) {
return true;
}
}
return false;
}
// 获取包含在指定变量范围内的 params 变量的键和值,并存储到 Map 中
public static Map<String, Object> getValidKeyValuesToMap(JSONObject params) {
Set<String> validVariables = generateAllValidVariables();
Map<String, Object> result = new HashMap<>();
for (String key : params.keySet()) {
if (validVariables.contains(key)) {
result.put(key, params.get(key));
}
}
return result;
}
// 检查字符串是否包含中文
private static boolean containsChinese(String str) {
String regex = ".*[\u4e00-\u9fa5].*";
return Pattern.matches(regex, str);
}
// 获取 params 里名字包含中文的变量的键和值
public static Map<String, Object> getChineseKeyValues(JSONObject params) {
Map<String, Object> result = new HashMap<>();
for (String key : params.keySet()) {
if (containsChinese(key)) {
result.put(key, params.get(key));
}
}
return result;
}
} }

View File

@@ -266,12 +266,12 @@ public class DeviceReportMessageServiceImpl implements IDeviceReportMessageServi
report.setDeviceName(message.getDeviceName()); report.setDeviceName(message.getDeviceName());
report.setSources(message.getSources()); report.setSources(message.getSources());
//属性上报执行规则引擎 //属性上报执行规则引擎
if(topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())){ // if(topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())){
report.setRuleEngine(false); // report.setRuleEngine(false);
}else{ // }else{
report.setRuleEngine(true); // report.setRuleEngine(true);
} // }
report.setRuleEngine(true);
dataHandler.reportData(report); dataHandler.reportData(report);
} }

View File

@@ -27,11 +27,14 @@ public class Category extends BaseEntity
@Excel(name = "产品分类名称") @Excel(name = "产品分类名称")
private String categoryName; private String categoryName;
@ApiModelProperty("网关型号")
@Excel(name = "网关型号")
private String modelName;
/** 产品分类名称 */ /** 产品分类名称 */
@ApiModelProperty("产品型号") @ApiModelProperty("产品型号")
@Excel(name = "产品型号") @Excel(name = "产品型号")
private String modelName; private String proName;
/** 产品分类ID */ /** 产品分类ID */
@@ -42,6 +45,8 @@ public class Category extends BaseEntity
@Excel(name = "标准模板") @Excel(name = "标准模板")
private String standardName; private String standardName;
private String useOrg;
/** 租户ID */ /** 租户ID */
@ApiModelProperty("租户ID") @ApiModelProperty("租户ID")
@Excel(name = "租户ID") @Excel(name = "租户ID")
@@ -186,6 +191,22 @@ public class Category extends BaseEntity
this.standardName = standardName; this.standardName = standardName;
} }
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public String getUseOrg() {
return useOrg;
}
public void setUseOrg(String useOrg) {
this.useOrg = useOrg;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@@ -242,6 +242,8 @@ public class Device extends BaseEntity {
private List<SipRelation> sipRelationList; private List<SipRelation> sipRelationList;
private List<Long> deptIds;
public static long getSerialVersionUID() { public static long getSerialVersionUID() {
return serialVersionUID; return serialVersionUID;

View File

@@ -55,6 +55,17 @@ public class Product extends BaseEntity {
@Excel(name = "产品分类名称") @Excel(name = "产品分类名称")
private String categoryName; private String categoryName;
@ApiModelProperty("网关型号")
@Excel(name = "网关型号")
private String modelName;
/** 产品分类名称 */
@ApiModelProperty("产品型号")
@Excel(name = "产品型号")
private String proName;
private String useOrg;
/** /**
* 租户ID * 租户ID
*/ */
@@ -433,6 +444,30 @@ public class Product extends BaseEntity {
this.productModel = productModel; this.productModel = productModel;
} }
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public String getProName() {
return proName;
}
public void setProName(String proName) {
this.proName = proName;
}
public String getUseOrg() {
return useOrg;
}
public void setUseOrg(String useOrg) {
this.useOrg = useOrg;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

View File

@@ -122,6 +122,10 @@ public class ThingsModel extends BaseEntity
@Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum") @Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum")
private String datatype; private String datatype;
@ApiModelProperty(value = "保留位数")
@Excel(name = "保留位数")
private Integer places;
@Excel(name = "有效值范围") @Excel(name = "有效值范围")
private String limitValue; private String limitValue;

View File

@@ -70,6 +70,10 @@ public class ThingsModelStandard extends BaseEntity
@ApiModelProperty("是否系统通用0-否1-是)") @ApiModelProperty("是否系统通用0-否1-是)")
private Integer isSys; private Integer isSys;
/** 是否计算属性0-否1-是) */
@ApiModelProperty(value = "是否计算属性", notes = "0-否1-是)")
@Excel(name = "是否计算属性", readConverterExp = "0=否,1=是")
private Integer isCalc;
/** 是否图表显示0-否1-是) */ /** 是否图表显示0-否1-是) */
@ApiModelProperty("是否图表显示0-否1-是)") @ApiModelProperty("是否图表显示0-否1-是)")
@@ -107,6 +111,10 @@ public class ThingsModelStandard extends BaseEntity
@Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum") @Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum")
private String datatype; private String datatype;
@ApiModelProperty(value = "保留位数")
@Excel(name = "保留位数")
private Integer places;
@ApiModelProperty("有效值范围") @ApiModelProperty("有效值范围")
@Excel(name = "有效值范围") @Excel(name = "有效值范围")
private String limitValue; private String limitValue;

View File

@@ -124,8 +124,8 @@ public interface DeviceMapper
* @param device 设备 * @param device 设备
* @return 设备集合 * @return 设备集合
*/ */
public List<DeviceShortOutput> selectDeviceGShortList(Device device);
public List<DeviceShortOutput> selectDeviceShortList(Device device); public List<DeviceShortOutput> selectDeviceShortList(Device device);
/** /**
* 查询所有设备简短列表 * 查询所有设备简短列表
* *

View File

@@ -118,4 +118,6 @@ public interface FunctionLogMapper
* @return * @return
*/ */
FunctionLog selectLogByMessageId(String messageId); FunctionLog selectLogByMessageId(String messageId);
void cleanOperLog(String serialNumber);
} }

View File

@@ -70,12 +70,6 @@ public interface StandardMapper
*/ */
public int deleteStandardByStandardIds(Long[] standardIds); public int deleteStandardByStandardIds(Long[] standardIds);
/**
* 分类下的产品数量
*
* @param standardIds 需要删除的数据主键集合
* @return 结果
*/
public int productCountInStandards(Long[] standardIds);
boolean checkName(String standardName);
} }

View File

@@ -83,4 +83,5 @@ public interface ThingsModelStandardMapper
int batchThingsModelStandards(List<ThingsModelStandard> thingsModelStandards); int batchThingsModelStandards(List<ThingsModelStandard> thingsModelStandards);
int deleteThingsModelStandardByStandardId(Long standardId);
} }

View File

@@ -11,6 +11,9 @@ public class ThingsModel
/** 影子值 */ /** 影子值 */
private String shadow; private String shadow;
/** 是否首页显示0-否1-是) */ /** 是否首页显示0-否1-是) */
private Integer isCalc;
/** 是否实时监测0-否1-是) */
private Integer isChart; private Integer isChart;
/** 是否实时监测0-否1-是) */ /** 是否实时监测0-否1-是) */
private Integer isMonitor; private Integer isMonitor;
@@ -33,6 +36,7 @@ public class ThingsModel
value=""; value="";
shadow=""; shadow="";
order=0; order=0;
isCalc=0;
isMonitor=0; isMonitor=0;
isHistory=0; isHistory=0;
isReadonly=0; isReadonly=0;
@@ -144,4 +148,12 @@ public class ThingsModel
public void setDatatype(Datatype datatype) { public void setDatatype(Datatype datatype) {
this.datatype = datatype; this.datatype = datatype;
} }
public Integer getIsCalc() {
return isCalc;
}
public void setIsCalc(Integer isCalc) {
this.isCalc = isCalc;
}
} }

View File

@@ -100,6 +100,8 @@ public class ThingsModelValueItem {
private Datatype datatype; private Datatype datatype;
private Integer places;
private Integer isSharePerm; private Integer isSharePerm;
private Long modelId; private Long modelId;

View File

@@ -78,7 +78,7 @@ public class RuleProcess {
.topic(topic) .topic(topic)
.build(); .build();
//返回处理完的消息上下文 //返回处理完的消息上下文
return context; return scriptService.execRuleScript(scriptCondition, context);
} }

View File

@@ -109,6 +109,14 @@ public interface IDeviceService
*/ */
public List<DeviceAllShortOutput> selectAllDeviceShortList(Device device); public List<DeviceAllShortOutput> selectAllDeviceShortList(Device device);
/**
* 查询设备简短列表
*
* @param device 设备
* @return 设备集合
*/
public List<DeviceShortOutput> selectGDeviceShortList(Device device);
/** /**
* 查询设备简短列表 * 查询设备简短列表
* *

View File

@@ -109,4 +109,6 @@ public interface IFunctionLogService
* @return * @return
*/ */
FunctionLog selectLogByMessageId(String messageId); FunctionLog selectLogByMessageId(String messageId);
void cleanOperLog(String serialNumber);
} }

View File

@@ -2,10 +2,7 @@ package com.xinda.iot.service;
import com.xinda.common.core.iot.response.IdentityAndName; import com.xinda.common.core.iot.response.IdentityAndName;
import com.xinda.iot.domain.ThingsModel; import com.xinda.iot.domain.ThingsModel;
import com.xinda.iot.model.ImportStandardModelInput; import com.xinda.iot.model.*;
import com.xinda.iot.model.ImportThingsModelInput;
import com.xinda.iot.model.ThingsModelPerm;
import com.xinda.iot.model.ThingsModelSimVO;
import com.xinda.iot.model.ThingsModels.IdentifierVO; import com.xinda.iot.model.ThingsModels.IdentifierVO;
import com.xinda.iot.model.ThingsModels.PropertyDto; import com.xinda.iot.model.ThingsModels.PropertyDto;
import com.xinda.iot.model.ThingsModels.ThingsItems; import com.xinda.iot.model.ThingsModels.ThingsItems;
@@ -194,4 +191,6 @@ public interface IThingsModelService
List<ThingsModel> selectThingsModelBySerialNumber(Long deviceId); List<ThingsModel> selectThingsModelBySerialNumber(Long deviceId);
public int importByStandardId(ImportStandardModelInput input); public int importByStandardId(ImportStandardModelInput input);
public int importBytCategoryId(ImportCategoryModelInput input);
} }

View File

@@ -80,4 +80,5 @@ public interface IThingsModelStandardService
*/ */
public List<ThingsModelStandard> selectThingsModelStandardExport(ThingsModelStandard thingsModelStandard); public List<ThingsModelStandard> selectThingsModelStandardExport(ThingsModelStandard thingsModelStandard);
public boolean checkUnique(ThingsModelStandard thingsModelStandard);
} }

View File

@@ -5,6 +5,7 @@ import java.util.List;
import com.xinda.common.core.domain.entity.SysRole; import com.xinda.common.core.domain.entity.SysRole;
import com.xinda.common.core.domain.entity.SysUser; import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.utils.DateUtils; import com.xinda.common.utils.DateUtils;
import com.xinda.common.utils.SecurityUtils;
import com.xinda.iot.model.AlertCountVO; import com.xinda.iot.model.AlertCountVO;
import com.xinda.iot.model.param.DataCenterParam; import com.xinda.iot.model.param.DataCenterParam;
import com.xinda.iot.model.DeviceAlertCount; import com.xinda.iot.model.DeviceAlertCount;
@@ -81,7 +82,8 @@ public class AlertLogServiceImpl implements IAlertLogService {
*/ */
@Override @Override
public Long selectAlertLogListCount(AlertLog alertLog) { public Long selectAlertLogListCount(AlertLog alertLog) {
SysUser user = getLoginUser().getUser(); // SysUser user = getLoginUser().getUser();
SysUser user = SecurityUtils.getLoginUser().getUser();
List<SysRole> roles = user.getRoles(); List<SysRole> roles = user.getRoles();
for (int i = 0; i < roles.size(); i++) { for (int i = 0; i < roles.size(); i++) {
// 租户和用户,只查看自己分组 // 租户和用户,只查看自己分组

View File

@@ -6,6 +6,8 @@ import com.xinda.common.core.domain.entity.SysUser;
import com.xinda.common.utils.DateUtils; import com.xinda.common.utils.DateUtils;
import com.xinda.iot.domain.Category; import com.xinda.iot.domain.Category;
import com.xinda.iot.mapper.CategoryMapper; import com.xinda.iot.mapper.CategoryMapper;
import com.xinda.iot.mapper.StandardMapper;
import com.xinda.iot.mapper.ThingsModelStandardMapper;
import com.xinda.iot.model.IdAndName; import com.xinda.iot.model.IdAndName;
import com.xinda.iot.service.ICategoryService; import com.xinda.iot.service.ICategoryService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +30,9 @@ public class CategoryServiceImpl implements ICategoryService
@Autowired @Autowired
private CategoryMapper categoryMapper; private CategoryMapper categoryMapper;
@Autowired
private StandardMapper standardMapper;
/** /**
* 查询产品分类 * 查询产品分类
* *
@@ -105,6 +110,10 @@ public class CategoryServiceImpl implements ICategoryService
@Override @Override
public int updateCategory(Category category) public int updateCategory(Category category)
{ {
Long standardId = category.getStandardId();
if(null != standardId){
category.setStandardName(standardMapper.selectStandardByStandardId(standardId).getStandardName());
}
category.setUpdateTime(DateUtils.getNowDate()); category.setUpdateTime(DateUtils.getNowDate());
return categoryMapper.updateCategory(category); return categoryMapper.updateCategory(category);
} }
@@ -118,10 +127,10 @@ public class CategoryServiceImpl implements ICategoryService
@Override @Override
public AjaxResult deleteCategoryByCategoryIds(Long[] categoryIds) public AjaxResult deleteCategoryByCategoryIds(Long[] categoryIds)
{ {
int productCount=categoryMapper.productCountInCategorys(categoryIds); // int productCount=categoryMapper.productCountInCategorys(categoryIds);
if(productCount>0){ // if(productCount>0){
return AjaxResult.error("删除失败,请先删除对应分类下的产品"); // return AjaxResult.error("删除失败,请先删除对应分类下的产品");
} // }
if(categoryMapper.deleteCategoryByCategoryIds(categoryIds)>0){ if(categoryMapper.deleteCategoryByCategoryIds(categoryIds)>0){
return AjaxResult.success("删除成功"); return AjaxResult.success("删除成功");
} }

View File

@@ -252,6 +252,7 @@ public class DeviceServiceImpl implements IDeviceService {
List<FunctionLog> functionLogList = new ArrayList<>(); List<FunctionLog> functionLogList = new ArrayList<>();
//事件存储集合 //事件存储集合
List<EventLog> eventLogList = new ArrayList<>(); List<EventLog> eventLogList = new ArrayList<>();
outer:
for (ThingsModelSimpleItem item : input.getThingsModelValueRemarkItem()) { for (ThingsModelSimpleItem item : input.getThingsModelValueRemarkItem()) {
String identity = item.getId(); String identity = item.getId();
String serialNumber = input.getDeviceNumber(); String serialNumber = input.getDeviceNumber();
@@ -260,76 +261,87 @@ public class DeviceServiceImpl implements IDeviceService {
} }
ThingsModelValueItem thingModels = thingsModelService.getSingleThingModels(input.getProductId(), identity); ThingsModelValueItem thingModels = thingsModelService.getSingleThingModels(input.getProductId(), identity);
log.error("=>查询物模型为[{}],标识符:[{}]",input.getProductId(),identity);
if (Objects.isNull(thingModels)) { if (Objects.isNull(thingModels)) {
log.warn("=>查询物模型为空[{}],标识符:[{}]",input.getProductId(),identity); log.warn("=>查询物模型为空[{}],标识符:[{}]",input.getProductId(),identity);
} }else{
String id = item.getId(); String id = item.getId();
String value = item.getValue(); String value = item.getValue();
item.setName(thingModels.getName()); item.setName(thingModels.getName());
/* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -开始 ★★★★★★★★★★★★★★★★★★★★★★*/ /* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -开始 ★★★★★★★★★★★★★★★★★★★★★★*/
//有计算公式的,经过计算公式 //有计算公式的,经过计算公式
// if (thingModels.getFormula() != null && !"".equals(thingModels.getFormula())) { // if (thingModels.getFormula() != null && !"".equals(thingModels.getFormula())) {
// Map<String, String> params = new HashMap<>(); // Map<String, String> params = new HashMap<>();
// params.put("%s", value); // params.put("%s", value);
// value = String.valueOf(CaculateUtils.execute(thingModels.getFormula(), params)); // value = String.valueOf(CaculateUtils.execute(thingModels.getFormula(), params));
// item.setValue(value); // item.setValue(value);
// } // }
if (thingModels.getFormula() != null && !"".equals(thingModels.getFormula())) { if (thingModels.getFormula() != null && !"".equals(thingModels.getFormula())) {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put(thingModels.getId(), value); params.put(thingModels.getId(), value);
if(FormulaCalculator.containsAllVariables(thingModels.getFormula(), params)) { if(FormulaCalculator.containsAllVariables(thingModels.getFormula(), params)) {
value = FormulaCalculator.evaluate(thingModels.getFormula(), params); int jscale = 2;
item.setValue(value); if(thingModels.getDatatype().getType().equals("decimal") && thingModels.getPlaces() != null){
jscale = thingModels.getPlaces();
}
value = FormulaCalculator.evaluate(thingModels.getFormula(), params,jscale);
}
} }
} /* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -结束 ★★★★★★★★★★★★★★★★★★★★★★*/
/* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -结束 ★★★★★★★★★★★★★★★★★★★★★★*/
/* ★★★★★★★★★★★★★★★★★★★★★★ 处理数据 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/ /* ★★★★★★★★★★★★★★★★★★★★★★ 处理小数位数据 - 开始 ★★★★★★★★★★★★★★★★★★★*/
ValueItem valueItem = new ValueItem(); if(thingModels.getDatatype().getType().equals("decimal") && thingModels.getPlaces() != null){
valueItem.setId(identity); value = FormulaCalculator.roundStringNumber(value, thingModels.getPlaces());
if (id.startsWith("array_")) {
// 查询是否有缓存,如果没有先进行缓存
if (!redisCache.containsKey(key)) {
Device device = this.selectDeviceBySerialNumber(input.getDeviceNumber());
this.selectDeviceByDeviceId(device.getDeviceId());
} }
item.setValue(value);
/* ★★★★★★★★★★★★★★★★★★★★★★ 处理小数位数据 - 结束 ★★★★★★★★★★★★★★★★★★★*/
int index = Integer.parseInt(id.substring(6, 8)); /* ★★★★★★★★★★★★★★★★★★★★★★ 处理数据 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/
if (isShadow) { ValueItem valueItem = new ValueItem();
String[] shadows = valueItem.getShadow().split(","); valueItem.setId(identity);
shadows[index] = value; if (id.startsWith("array_")) {
valueItem.setShadow(String.join(",", shadows)); // 查询是否有缓存,如果没有先进行缓存
if (!redisCache.containsKey(key)) {
Device device = this.selectDeviceBySerialNumber(input.getDeviceNumber());
this.selectDeviceByDeviceId(device.getDeviceId());
}
int index = Integer.parseInt(id.substring(6, 8));
if (isShadow) {
String[] shadows = valueItem.getShadow().split(",");
shadows[index] = value;
valueItem.setShadow(String.join(",", shadows));
} else {
// 设置值,获取数组值,然后替换其中元素
valueItem.setTs(DateUtils.getNowDate());
String[] values = valueItem.getValue().split(",");
values[index] = value;
valueItem.setValue(String.join(",", values));
String[] shadows = valueItem.getShadow().split(",");
shadows[index] = value;
valueItem.setShadow(String.join(",", shadows));
}
redisCache.setCacheMapValue(key,identity,JSONObject.toJSONString(valueItem));
//maps.put(identity, JSONObject.toJSONString(valueItem));
} else { } else {
// 设置值,获取数组值,然后替换其中元素 if (isShadow) {
valueItem.setTs(DateUtils.getNowDate()); valueItem.setShadow(value);
String[] values = valueItem.getValue().split(","); } else {
values[index] = value; valueItem.setValue(value);
valueItem.setValue(String.join(",", values)); valueItem.setShadow(value);
valueItem.setTs(DateUtils.getNowDate());
String[] shadows = valueItem.getShadow().split(","); }
shadows[index] = value; maps.put(identity, JSONObject.toJSONString(valueItem));
valueItem.setShadow(String.join(",", shadows)); variables.put(identity,value);
} }
redisCache.setCacheMapValue(key,identity,JSONObject.toJSONString(valueItem)); /* ★★★★★★★★★★★★★★★★★★★★★★ 处理数据 - 结束 ★★★★★★★★★★★★★★★★★★★★★★*/
//maps.put(identity, JSONObject.toJSONString(valueItem));
} else {
if (isShadow) {
valueItem.setShadow(value);
} else {
valueItem.setValue(value);
valueItem.setShadow(value);
valueItem.setTs(DateUtils.getNowDate());
}
maps.put(identity, JSONObject.toJSONString(valueItem));
variables.put(identity,value);
}
/* ★★★★★★★★★★★★★★★★★★★★★★ 处理数据 - 结束 ★★★★★★★★★★★★★★★★★★★★★★*/
/*★★★★★★★★★★★★★★★★★★★★★★ 存储数据 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/ /*★★★★★★★★★★★★★★★★★★★★★★ 存储数据 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/
ThingsModelType modelType = ThingsModelType.getType(thingModels.getType()); ThingsModelType modelType = ThingsModelType.getType(thingModels.getType());
Device device = this.selectDeviceBySerialNumber(input.getDeviceNumber()); Device device = this.selectDeviceBySerialNumber(input.getDeviceNumber());
switch (modelType) { switch (modelType) {
case PROP: case PROP:
if (1 == thingModels.getIsHistory()) { if (1 == thingModels.getIsHistory()) {
DeviceLog deviceLog = new DeviceLog(); DeviceLog deviceLog = new DeviceLog();
@@ -383,19 +395,24 @@ public class DeviceServiceImpl implements IDeviceService {
eventLogList.add(event); eventLogList.add(event);
break; break;
} }
list.add(item); list.add(item);
}
} }
/*★★★★★★★★★★★★★★★★★★★★★★ 处理计算属性 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/ /*★★★★★★★★★★★★★★★★★★★★★★ 处理计算属性 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/
//1、根据产品ID获取计算属性列表 //1、根据产品ID获取计算属性列表
List<ThingsModelValueItem> thingsModelList = itslCache.getThingsModelList(input.getProductId()); List<ThingsModelValueItem> thingsModelList = itslCache.getThingsModelList(input.getProductId());
for (ThingsModelValueItem mItem : thingsModelList) { for (ThingsModelValueItem mItem : thingsModelList) {
if (mItem.getIsCalc() == 1) { if (mItem != null && mItem.getIsCalc() != null && mItem.getIsCalc() == 1) {
if (mItem.getFormula() != null && !"".equals(mItem.getFormula())) { if (mItem.getFormula() != null && !"".equals(mItem.getFormula())) {
//2、获取计算属性列表的变量 检查每个变量都存在maps里 如果不存在则不计算,如果存在则计算 //2、获取计算属性列表的变量 检查每个变量都存在maps里 如果不存在则不计算,如果存在则计算
if(FormulaCalculator.containsAllVariables(mItem.getFormula(), variables)){ if(FormulaCalculator.containsAllVariables(mItem.getFormula(), variables)){
//3、先执行 上面的★★ 处理数据 - 开始 ★★ //3、先执行 上面的★★ 处理数据 - 开始 ★★
String calcValue = FormulaCalculator.evaluate(mItem.getFormula(), variables); int scale = 2;
if(mItem.getDatatype().getType().equals("decimal") && mItem.getPlaces() != null){
scale = mItem.getPlaces();
}
String calcValue = FormulaCalculator.evaluate(mItem.getFormula(), variables, scale);
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem(); ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
simpleItem.setId(mItem.getId()); simpleItem.setId(mItem.getId());
simpleItem.setName(mItem.getName()); simpleItem.setName(mItem.getName());
@@ -543,7 +560,7 @@ public class DeviceServiceImpl implements IDeviceService {
* @return 设备 * @return 设备
*/ */
@Override @Override
public List<DeviceShortOutput> selectDeviceShortList(Device device) { public List<DeviceShortOutput> selectGDeviceShortList(Device device) {
// 清空离线并且 group_id = 0 的数据 // 清空离线并且 group_id = 0 的数据
// deviceMapper.deleteDeviceBygroupId(); // deviceMapper.deleteDeviceBygroupId();
@@ -551,7 +568,7 @@ public class DeviceServiceImpl implements IDeviceService {
List<DeviceShortOutput> list = deviceMapper.selectDeviceShortList(device); List<DeviceShortOutput> list = deviceMapper.selectDeviceGShortList(device);
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount(); List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) { for (DeviceAlertCount item : alist) {
list.stream() list.stream()
@@ -568,8 +585,25 @@ public class DeviceServiceImpl implements IDeviceService {
} }
return list;
}
/**
* 查询设备分页简短列表
*
* @param device 设备
* @return 设备
*/
@Override
public List<DeviceShortOutput> selectDeviceShortList(Device device) {
List<DeviceShortOutput> list = deviceMapper.selectDeviceShortList(device);
List<DeviceAlertCount> alist = alertLogService.selectDeviceAlertCount();
for (DeviceAlertCount item : alist) {
list.stream()
.filter(it -> Objects.equals(it.getSerialNumber(), item.getSerialNumber()))
.forEach(it -> it.setAlertCount(item));
}
return list; return list;
} }
@@ -775,7 +809,6 @@ public class DeviceServiceImpl implements IDeviceService {
Product product = productService.selectProductByProductId(device.getProductId()); Product product = productService.selectProductByProductId(device.getProductId());
device.setImgUrl(product.getImgUrl()); device.setImgUrl(product.getImgUrl());
// 随机经纬度和地址 // 随机经纬度和地址
SysUser user = getLoginUser().getUser(); SysUser user = getLoginUser().getUser();
device.setNetworkIp(user.getLoginIp()); device.setNetworkIp(user.getLoginIp());
@@ -789,6 +822,19 @@ public class DeviceServiceImpl implements IDeviceService {
// redis缓存设备默认状态物模型值 // redis缓存设备默认状态物模型值
itslValueCache.addCacheDeviceStatus(device.getProductId(), device.getSerialNumber()); itslValueCache.addCacheDeviceStatus(device.getProductId(), device.getSerialNumber());
if(null != device.getAgenciesId()){
SysDept sysDept = sysDeptMapper.selectDeptById(device.getAgenciesId());
Long deptUserId = sysDept.getDeptUserId();
if ( null == deptUserId) {
deptUserId = sysDeptMapper.selectDeptById(sysDept.getParentId()).getDeptUserId();
}
SysUser suser = userService.selectUserById(deptUserId);
List<Long> deviceIdList = new ArrayList<>();
deviceIdList.add(device.getDeviceId());
deviceMapper.updateTenantIdByDeptIds(deptUserId, suser.getUserName(), deviceIdList);
}
return device; return device;
} }
@Override @Override
@@ -984,6 +1030,18 @@ public class DeviceServiceImpl implements IDeviceService {
device.setProductName(null); device.setProductName(null);
} }
deviceMapper.updateDevice(device); deviceMapper.updateDevice(device);
if(null != device.getAgenciesId()){
SysDept sysDept = sysDeptMapper.selectDeptById(device.getAgenciesId());
Long deptUserId = sysDept.getDeptUserId();
if ( null == deptUserId) {
deptUserId = sysDeptMapper.selectDeptById(sysDept.getParentId()).getDeptUserId();
}
SysUser suser = userService.selectUserById(deptUserId);
List<Long> deviceIdList = new ArrayList<>();
deviceIdList.add(device.getDeviceId());
deviceMapper.updateTenantIdByDeptIds(deptUserId, suser.getUserName(), deviceIdList);
}
return AjaxResult.success("修改成功", 1); return AjaxResult.success("修改成功", 1);
} }

View File

@@ -154,4 +154,9 @@ public class FunctionLogServiceImpl implements IFunctionLogService
public FunctionLog selectLogByMessageId(String messageId){ public FunctionLog selectLogByMessageId(String messageId){
return functionLogMapper.selectLogByMessageId(messageId); return functionLogMapper.selectLogByMessageId(messageId);
} }
@Override
public void cleanOperLog(String serialNumber) {
functionLogMapper.cleanOperLog(serialNumber);
}
} }

View File

@@ -5,16 +5,15 @@ import com.xinda.common.core.redis.RedisCache;
import com.xinda.common.core.redis.RedisKeyBuilder; import com.xinda.common.core.redis.RedisKeyBuilder;
import com.xinda.common.utils.DateUtils; import com.xinda.common.utils.DateUtils;
import com.xinda.iot.cache.ITSLCache; import com.xinda.iot.cache.ITSLCache;
import com.xinda.iot.domain.Category;
import com.xinda.iot.domain.Product; import com.xinda.iot.domain.Product;
import com.xinda.iot.mapper.DeviceMapper; import com.xinda.iot.mapper.*;
import com.xinda.iot.mapper.ProductAuthorizeMapper;
import com.xinda.iot.mapper.ProductMapper;
import com.xinda.iot.mapper.SceneDeviceMapper;
import com.xinda.iot.model.ChangeProductStatusModel; import com.xinda.iot.model.ChangeProductStatusModel;
import com.xinda.iot.model.IdAndName; import com.xinda.iot.model.IdAndName;
import com.xinda.iot.model.ProductCode; import com.xinda.iot.model.ProductCode;
import com.xinda.iot.model.SceneDeviceBindVO; import com.xinda.iot.model.SceneDeviceBindVO;
import com.xinda.iot.service.IProductService; import com.xinda.iot.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.*; import org.springframework.cache.annotation.*;
import com.xinda.iot.cache.ITSLValueCache; import com.xinda.iot.cache.ITSLValueCache;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
@@ -54,6 +53,8 @@ public class ProductServiceImpl implements IProductService
private ITSLValueCache thingModelCache; private ITSLValueCache thingModelCache;
@Resource @Resource
private ITSLCache itslCache; private ITSLCache itslCache;
@Autowired
private CategoryMapper categoryMapper;
/** /**
* 查询产品 * 查询产品
@@ -127,6 +128,13 @@ public class ProductServiceImpl implements IProductService
if(product.getMqttSecret()==null || product.getMqttSecret().equals("")){ if(product.getMqttSecret()==null || product.getMqttSecret().equals("")){
product.setMqttSecret("K"+toolService.getStringRandom(15)); product.setMqttSecret("K"+toolService.getStringRandom(15));
} }
if(product.getCategoryId()==null ){
Category category =categoryMapper.selectCategoryByCategoryId(product.getCategoryId());
product.setCategoryName(category.getCategoryName());
product.setModelName(category.getModelName());
product.setProName(category.getProName());
product.setUseOrg(category.getUseOrg());
}
product.setStatus(product.getStatus()==null?1:product.getStatus()); product.setStatus(product.getStatus()==null?1:product.getStatus());
product.setCreateTime(DateUtils.getNowDate()); product.setCreateTime(DateUtils.getNowDate());
productMapper.insertProduct(product); productMapper.insertProduct(product);
@@ -146,6 +154,13 @@ public class ProductServiceImpl implements IProductService
public int updateProduct(Product product) public int updateProduct(Product product)
{ {
product.setUpdateTime(DateUtils.getNowDate()); product.setUpdateTime(DateUtils.getNowDate());
if(product.getCategoryId()==null ){
Category category =categoryMapper.selectCategoryByCategoryId(product.getCategoryId());
product.setCategoryName(category.getCategoryName());
product.setModelName(category.getModelName());
product.setProName(category.getProName());
product.setUseOrg(category.getUseOrg());
}
return productMapper.updateProduct(product); return productMapper.updateProduct(product);
} }

View File

@@ -12,7 +12,9 @@ import com.xinda.iot.model.IdAndName;
import com.xinda.iot.service.IStandardService; import com.xinda.iot.service.IStandardService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import static com.xinda.common.utils.SecurityUtils.getLoginUser; import static com.xinda.common.utils.SecurityUtils.getLoginUser;
@@ -107,29 +109,29 @@ public class StandardServiceImpl implements IStandardService
SysUser user = getLoginUser().getUser(); SysUser user = getLoginUser().getUser();
Standard cloneStandard = new Standard(); Standard cloneStandard = new Standard();
BeanUtil.copyProperties(standard, cloneStandard, "standardId","standardName","orderNum"); BeanUtil.copyProperties(standard, cloneStandard, "standardId","standardName","orderNum");
cloneStandard.setStandardName(standard.getStandardName()+"_副本"); String baseName = standard.getStandardName() + "_副本";
String name = baseName;
int copyCount = 1;
// 不断检查名称是否存在,如果存在则添加 "_副本" 后缀
while (standardMapper.checkName(name)) {
copyCount++;
name = baseName + "_" + copyCount;
}
cloneStandard.setStandardName(name);
if (null != standard.getOrderNum()) { if (null != standard.getOrderNum()) {
cloneStandard.setOrderNum(standard.getOrderNum()+1); cloneStandard.setOrderNum(standard.getOrderNum()+1);
} }
// cloneStandard.setOrderNum(standard.getOrderNum()+1);
// if (null != user.getDeptId()) {
// standard.setTenantId(user.getDept().getDeptUserId());
// standard.setTenantName(user.getDept().getDeptUserName());
// } else {
// standard.setTenantId(user.getUserId());
// standard.setTenantName(user.getUserName());
// }
// if (!isAdmin(user.getUserId())) {
// standard.setIsSys(0);
// }
cloneStandard.setCreateTime(DateUtils.getNowDate()); cloneStandard.setCreateTime(DateUtils.getNowDate());
standardMapper.insertStandard(cloneStandard); standardMapper.insertStandard(cloneStandard);
List<ThingsModelStandard> thingsModelStandards = thingsModelStandardMapper.selectModelListByStandardId(standard.getStandardId()); List<ThingsModelStandard> thingsModelStandards = thingsModelStandardMapper.selectModelListByStandardId(standard.getStandardId());
List<ThingsModelStandard> clonethingsModelStandards = new ArrayList<>();
thingsModelStandardMapper.selectModelListByStandardId(standard.getStandardId()).forEach(model -> { thingsModelStandardMapper.selectModelListByStandardId(standard.getStandardId()).forEach(model -> {
model.setStandardId(cloneStandard.getStandardId()); model.setStandardId(cloneStandard.getStandardId());
thingsModelStandards.add(model); clonethingsModelStandards.add(model);
}); });
return thingsModelStandardMapper.batchThingsModelStandards(thingsModelStandards); return thingsModelStandardMapper.batchThingsModelStandards(clonethingsModelStandards);
} }
/** /**
@@ -152,11 +154,11 @@ public class StandardServiceImpl implements IStandardService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public AjaxResult deleteStandardByStandardIds(Long[] standardIds) public AjaxResult deleteStandardByStandardIds(Long[] standardIds)
{ {
int productCount=standardMapper.productCountInStandards(standardIds); for (Long standardId : standardIds) {
if(productCount>0){ thingsModelStandardMapper.deleteThingsModelStandardByStandardId(standardId);
return AjaxResult.error("删除失败,请先删除对应分类下的产品");
} }
if(standardMapper.deleteStandardByStandardIds(standardIds)>0){ if(standardMapper.deleteStandardByStandardIds(standardIds)>0){
return AjaxResult.success("删除成功"); return AjaxResult.success("删除成功");
@@ -171,8 +173,10 @@ public class StandardServiceImpl implements IStandardService
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional
public int deleteStandardByStandardId(Long standardId) public int deleteStandardByStandardId(Long standardId)
{ {
thingsModelStandardMapper.deleteThingsModelStandardByStandardId(standardId);
return standardMapper.deleteStandardByStandardId(standardId); return standardMapper.deleteStandardByStandardId(standardId);
} }
} }

View File

@@ -15,11 +15,8 @@ import com.xinda.common.utils.StringUtils;
import com.xinda.iot.cache.ITSLCache; import com.xinda.iot.cache.ITSLCache;
import com.xinda.iot.domain.*; import com.xinda.iot.domain.*;
import com.xinda.iot.mapper.*; import com.xinda.iot.mapper.*;
import com.xinda.iot.model.ImportStandardModelInput; import com.xinda.iot.model.*;
import com.xinda.iot.model.ImportThingsModelInput;
import com.xinda.iot.model.ThingsModelItem.Datatype; import com.xinda.iot.model.ThingsModelItem.Datatype;
import com.xinda.iot.model.ThingsModelPerm;
import com.xinda.iot.model.ThingsModelSimVO;
import com.xinda.iot.model.ThingsModels.IdentifierVO; import com.xinda.iot.model.ThingsModels.IdentifierVO;
import com.xinda.iot.model.ThingsModels.ThingsModelValueItem; import com.xinda.iot.model.ThingsModels.ThingsModelValueItem;
import com.xinda.iot.model.ThingsModels.ValueItem; import com.xinda.iot.model.ThingsModels.ValueItem;
@@ -58,6 +55,9 @@ public class ThingsModelServiceImpl implements IThingsModelService {
@Autowired @Autowired
private ThingsModelStandardMapper thingsModelStandardMapper; private ThingsModelStandardMapper thingsModelStandardMapper;
@Autowired
private CategoryMapper categoryMapper;
@Autowired @Autowired
private ProductMapper productMapper; private ProductMapper productMapper;
@@ -249,7 +249,11 @@ public class ThingsModelServiceImpl implements IThingsModelService {
ThingsModel inputParameter = new ThingsModel(); ThingsModel inputParameter = new ThingsModel();
inputParameter.setLanguage(SecurityUtils.getLanguage()); inputParameter.setLanguage(SecurityUtils.getLanguage());
inputParameter.setProductId(input.getProductId()); inputParameter.setProductId(input.getProductId());
List<ThingsModel> dbList = thingsModelMapper.selectThingsModelList(inputParameter);
//清空模型再导入
thingsModelMapper.deleteThingsModelByProductId(input.getProductId());
// List<ThingsModel> dbList = thingsModelMapper.selectThingsModelList(inputParameter);
SysUser user = getLoginUser().getUser(); SysUser user = getLoginUser().getUser();
// 根据ID集合获取通用物模型列表 // 根据ID集合获取通用物模型列表
@@ -272,12 +276,73 @@ public class ThingsModelServiceImpl implements IThingsModelService {
thingsModel.setIsChart(template.getIsChart()); thingsModel.setIsChart(template.getIsChart());
thingsModel.setIsHistory(template.getIsHistory()); thingsModel.setIsHistory(template.getIsHistory());
thingsModel.setModelOrder(template.getModelOrder()); thingsModel.setModelOrder(template.getModelOrder());
Boolean isRepeat = dbList.stream().anyMatch(x -> x.getIdentifier().equals(thingsModel.getIdentifier())); // Boolean isRepeat = dbList.stream().anyMatch(x -> x.getIdentifier().equals(thingsModel.getIdentifier()));
if (isRepeat) { // if (isRepeat) {
repeatCount = repeatCount + 1; // repeatCount = repeatCount + 1;
} else { // } else {
list.add(thingsModel); list.add(thingsModel);
// }
}
if (list.size() > 0) {
int result = thingsModelMapper.insertBatchThingsModel(list);
if (result > 0) {
// 更新场景管理变量
List<SceneModelDevice> sceneModelDeviceList = sceneModelDeviceMapper.listDeviceByProductId(input.getProductId());
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(sceneModelDeviceList)) {
List<SceneModelData> sceneModelDataList = new ArrayList<>();
for (ThingsModel thingsModel : list) {
List<ThingsModelDTO> thingsModelDTOList = this.changeObjectOrArray(thingsModel);
for (SceneModelDevice sceneModelDevice : sceneModelDeviceList) {
sceneModelDataList.addAll(getSceneModelData(sceneModelDevice, thingsModelDTOList));
}
}
sceneModelDataMapper.insertBatchSceneModelData(sceneModelDataList);
}
} }
//更新redis缓存
itslCache.setCacheThingsModelByProductId(input.getProductId());
}
return repeatCount;
}
@Override
public int importBytCategoryId(ImportCategoryModelInput input) {
ThingsModel inputParameter = new ThingsModel();
inputParameter.setLanguage(SecurityUtils.getLanguage());
inputParameter.setProductId(input.getProductId());
//清空模型再导入
thingsModelMapper.deleteThingsModelByProductId(input.getProductId());
// List<ThingsModel> dbList = thingsModelMapper.selectThingsModelList(inputParameter);
SysUser user = getLoginUser().getUser();
// 根据ID集合获取通用物模型列表
List<ThingsModelStandard> templateList = thingsModelStandardMapper.selectModelListByStandardId(categoryMapper.selectCategoryByCategoryId(input.getCategoryId()).getStandardId());
//转换为产品物模型,并批量插入
List<ThingsModel> list = new ArrayList<>();
int repeatCount = 0;
for (ThingsModelStandard template : templateList) {
ThingsModel thingsModel = new ThingsModel();
BeanUtils.copyProperties(template, thingsModel);
thingsModel.setTenantId(user.getUserId());
thingsModel.setTenantName(user.getUserName());
thingsModel.setCreateTime(DateUtils.getNowDate());
thingsModel.setProductId(input.getProductId());
thingsModel.setProductName(input.getProductName());
thingsModel.setModelId(template.getTemplateId());
thingsModel.setModelName(template.getTemplateName());
thingsModel.setIsReadonly(template.getIsReadonly());
thingsModel.setIsMonitor(template.getIsMonitor());
thingsModel.setIsChart(template.getIsChart());
thingsModel.setIsHistory(template.getIsHistory());
thingsModel.setModelOrder(template.getModelOrder());
// Boolean isRepeat = dbList.stream().anyMatch(x -> x.getIdentifier().equals(thingsModel.getIdentifier()));
// if (isRepeat) {
// repeatCount = repeatCount + 1;
// } else {
list.add(thingsModel);
// }
} }
if (list.size() > 0) { if (list.size() > 0) {
int result = thingsModelMapper.insertBatchThingsModel(list); int result = thingsModelMapper.insertBatchThingsModel(list);
@@ -401,14 +466,19 @@ public class ThingsModelServiceImpl implements IThingsModelService {
thingsModel.setProductId(productId); thingsModel.setProductId(productId);
ThingsModel selectModel = this.selectSingleThingsModel(thingsModel); ThingsModel selectModel = this.selectSingleThingsModel(thingsModel);
item = new ThingsModelValueItem(); item = new ThingsModelValueItem();
BeanUtils.copyProperties(selectModel, item); if(selectModel != null){
item.setId(selectModel.getIdentifier()); BeanUtils.copyProperties(selectModel, item);
item.setName(selectModel.getModelName()); item.setId(selectModel.getIdentifier());
item.setDatatype(JSONObject.parseObject(selectModel.getSpecs(), Datatype.class)); item.setName(selectModel.getModelName());
item.setOrder(selectModel.getModelOrder()); item.setDatatype(JSONObject.parseObject(selectModel.getSpecs(), Datatype.class));
item.setFormula(selectModel.getFormula()); item.setOrder(selectModel.getModelOrder());
itslCache.setCacheThingsModelByProductId(productId); item.setFormula(selectModel.getFormula());
return item; itslCache.setCacheThingsModelByProductId(productId);
return item;
}else{
return null;
}
} }

View File

@@ -136,6 +136,11 @@ public class ThingsModelStandardServiceImpl implements IThingsModelStandardServi
} }
@Override
public boolean checkUnique(ThingsModelStandard thingsModelStandard) {
return false;
}
/** /**
* 修改通用物模型 * 修改通用物模型
* *

View File

@@ -2,6 +2,8 @@ package com.xinda.iot.util;
import org.apache.commons.jexl3.*; import org.apache.commons.jexl3.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
@@ -19,21 +21,22 @@ public class FormulaCalculator {
// 匹配字母开头包含字母、数字的变量名至少1位 // 匹配字母开头包含字母、数字的变量名至少1位
private static final Pattern VAR_PATTERN = Pattern.compile("\\b[a-zA-Z][a-zA-Z0-9]*\\b"); private static final Pattern VAR_PATTERN = Pattern.compile("\\b[a-zA-Z][a-zA-Z0-9]*\\b");
public static String evaluate(String formula, Map<String, String> variables) { public static String evaluate(String formula, Map<String, String> variables, int scale) {
// 校验公式安全性 // 校验公式安全性
// validateFormula(formula, variables.keySet()); // validateFormula(formula, variables.keySet());
// 创建上下文并注入变量 // 创建上下文并注入变量
JexlContext context = new MapContext(); JexlContext context = new MapContext();
variables.forEach((name, value) -> { variables.forEach((name, value) -> {
Number num = parseNumber(value); BigDecimal num = new BigDecimal(value);
context.set(name, num); context.set(name, num);
}); });
try { try {
// 执行计算 // 执行计算
JexlExpression expr = jexl.createExpression(formula); JexlExpression expr = jexl.createExpression(formula);
return expr.evaluate(context).toString(); BigDecimal result = (BigDecimal) expr.evaluate(context);
return result.setScale(scale, BigDecimal.ROUND_HALF_UP).toPlainString();
} catch (JexlException e) { } catch (JexlException e) {
throw new RuntimeException("Formula evaluation failed: " + e.getMessage()); throw new RuntimeException("Formula evaluation failed: " + e.getMessage());
} }
@@ -113,4 +116,16 @@ public class FormulaCalculator {
private static boolean isPureNumber(String str) { private static boolean isPureNumber(String str) {
return str.matches("^\\d+$"); return str.matches("^\\d+$");
} }
/**
* 当输入字符串 要保留的小数位数输出Stringh结果。
* @param number
* @param scale
* @return
*/
public static String roundStringNumber(String number, int scale) {
BigDecimal bd = new BigDecimal(number);
bd = bd.setScale(scale, RoundingMode.HALF_UP);
return bd.toString();
}
} }

View File

@@ -8,8 +8,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="categoryId" column="category_id" /> <result property="categoryId" column="category_id" />
<result property="categoryName" column="category_name" /> <result property="categoryName" column="category_name" />
<result property="modelName" column="model_name" /> <result property="modelName" column="model_name" />
<result property="proName" column="pro_name" />
<result property="standardId" column="standard_id" /> <result property="standardId" column="standard_id" />
<result property="standardName" column="standard_name" /> <result property="standardName" column="standard_name" />
<result property="useOrg" column="use_org" />
<result property="tenantId" column="tenant_id" /> <result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" /> <result property="tenantName" column="tenant_name" />
<result property="isSys" column="is_sys" /> <result property="isSys" column="is_sys" />
@@ -27,11 +29,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectCategoryVo"> <sql id="selectCategoryVo">
select category_id, category_name,model_name, standard_id,standard_name,tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category select category_id, category_name, model_name, pro_name, standard_id,standard_name, use_org, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category
</sql> </sql>
<select id="selectCategoryList" parameterType="com.xinda.iot.domain.Category" resultMap="CategoryResult"> <select id="selectCategoryList" parameterType="com.xinda.iot.domain.Category" resultMap="CategoryResult">
select c.category_id, c.category_name,c.model_name,c.standard_id,c.standard_name, c.tenant_id, c.tenant_name, select c.category_id, c.category_name,c.model_name, c.pro_name, c.standard_id,c.standard_name,c.use_org, c.tenant_id, c.tenant_name,
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark c.is_sys,c.order_num, c.create_time, c.update_time, c.remark
from iot_category c from iot_category c
<where> <where>
@@ -54,7 +56,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
<if test="categoryName != null and categoryName != ''"> and c.category_name like concat('%', #{categoryName}, '%')</if> <if test="categoryName != null and categoryName != ''"> and c.category_name like concat('%', #{categoryName}, '%')</if>
<if test="modelName != null and modelName != ''"> and c.model_name like concat('%', #{modelName}, '%')</if> <if test="modelName != null and modelName != ''"> and c.model_name like concat('%', #{modelName}, '%')</if>
<if test="proName != null and proName != ''"> and c.pro_name like concat('%', #{proName}, '%')</if>
<if test="standardId != null and standardId != ''"> and (c.standard_id = #{standardId})</if> <if test="standardId != null and standardId != ''"> and (c.standard_id = #{standardId})</if>
<if test="useOrg != null and useOrg != ''"> and c.use_org like concat('%', #{useOrg}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if> <if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if>
</where> </where>
order by order_num order by order_num
@@ -85,7 +89,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
<if test="categoryName != null and categoryName != ''"> and c.category_name like concat('%', #{categoryName}, '%')</if> <if test="categoryName != null and categoryName != ''"> and c.category_name like concat('%', #{categoryName}, '%')</if>
<if test="modelName != null and modelName != ''"> and c.model_name like concat('%', #{modelName}, '%')</if> <if test="modelName != null and modelName != ''"> and c.model_name like concat('%', #{modelName}, '%')</if>
<if test="proName != null and proName != ''"> and c.pro_name like concat('%', #{proName}, '%')</if>
<!-- <if test="standardId != null and standardId != ''"> and (m.standard_id = #{standardId})</if>--> <!-- <if test="standardId != null and standardId != ''"> and (m.standard_id = #{standardId})</if>-->
<if test="useOrg != null and useOrg != ''"> and c.use_org like concat('%', #{useOrg}, '%')</if>
<if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if> <if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if>
</where> </where>
order by order_num order by order_num
@@ -101,8 +107,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name,</if> <if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="modelName != null and modelName != ''">model_name,</if> <if test="modelName != null and modelName != ''">model_name,</if>
<if test="proName != null and proName != ''">pro_name,</if>
<if test="standardId != null">standard_id,</if> <if test="standardId != null">standard_id,</if>
<if test="standardName != null and standardName != ''">standard_name,</if> <if test="standardName != null and standardName != ''">standard_name,</if>
<if test="useOrg != null and useOrg != ''"> use_org,</if>
<if test="tenantId != null">tenant_id,</if> <if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if> <if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="isSys != null">is_sys,</if> <if test="isSys != null">is_sys,</if>
@@ -116,8 +124,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">#{categoryName},</if> <if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="modelName != null and modelName != ''">#{modelName},</if> <if test="modelName != null and modelName != ''">#{modelName},</if>
<if test="proName != null and proName != ''">#{proName},</if>
<if test="standardId != null">#{standardId},</if> <if test="standardId != null">#{standardId},</if>
<if test="standardName != null and standardName != ''">#{standardName},</if> <if test="standardName != null and standardName != ''">#{standardName},</if>
<if test="useOrg != null and useOrg != ''"> #{useOrg},</if>
<if test="tenantId != null">#{tenantId},</if> <if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if> <if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="isSys != null">#{isSys},</if> <if test="isSys != null">#{isSys},</if>
@@ -135,8 +145,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if> <if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="modelName != null and modelName != ''">model_name = #{modelName},</if> <if test="modelName != null and modelName != ''">model_name = #{modelName},</if>
<if test="proName != null and proName != ''">pro_name = #{proName},</if>
<if test="standardId != null">standard_id = #{standardId},</if> <if test="standardId != null">standard_id = #{standardId},</if>
<if test="standardName != null and standardName != ''">standard_name = #{standardName},</if> <if test="standardName != null and standardName != ''">standard_name = #{standardName},</if>
<if test="useOrg != null and useOrg != ''"> use_org = #{useOrg},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if> <if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if> <if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="isSys != null">is_sys = #{isSys},</if> <if test="isSys != null">is_sys = #{isSys},</if>

View File

@@ -358,6 +358,7 @@
group by d.device_id,d.tenant_id group by d.device_id,d.tenant_id
</select> </select>
<select id="selectSerialNumberByProductId" parameterType="Long" resultType="String"> <select id="selectSerialNumberByProductId" parameterType="Long" resultType="String">
select serial_number select serial_number
from iot_device from iot_device
@@ -394,7 +395,7 @@
where device_id = #{deviceId} where device_id = #{deviceId}
</update> </update>
<select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult"> <select id="selectDeviceGShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type, select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code, d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way, d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
@@ -413,7 +414,7 @@
<if test="groupId != null and groupId !=0 ">left join iot_device_group g on g.device_id=d.device_id</if> <if test="groupId != null and groupId !=0 ">left join iot_device_group g on g.device_id=d.device_id</if>
<where> <where>
and d.gw_dev_code is null and d.del_flag = '0' and d.gw_dev_code is null and d.del_flag = '0'
<if test="groupId != null and groupId !=0 ">and d.group_id = #{groupId}</if> <!-- <if test="groupId != null and groupId !=0 ">and d.group_id = #{groupId}</if>-->
<if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%') <if test="deviceName != null and deviceName != ''">and d.device_name like concat('%', #{deviceName}, '%')
</if> </if>
<if test="productId != null ">and d.product_id = #{productId}</if> <if test="productId != null ">and d.product_id = #{productId}</if>
@@ -425,10 +426,11 @@
<if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode}</if> <if test="gwDevCode != null and gwDevCode != ''">and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null ">and d.status = #{status}</if> <if test="status != null ">and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if> <if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="agenciesId == null">and d.agencies_id IS NULL</if>
<if test="agenciesId != null">and d.agencies_id = #{agenciesId}</if>
<!-- <if test="groupIdExclude != null">and d.group_id != #{groupIdExclude}</if>-->
<if test="groupIdExclude != null">and d.group_id != #{groupIdExclude}</if> <if test="deptId != null and deptId != 0 and showChild != null and showChild ">
<if test="deptId != null and deptId != 0 and showChild != null and showChild">
and and
( d.tenant_id in (SELECT u.user_id FROM sys_user u ( d.tenant_id in (SELECT u.user_id FROM sys_user u
join sys_dept de on u.dept_id = de.dept_id join sys_dept de on u.dept_id = de.dept_id
@@ -450,6 +452,94 @@
order by d.create_time desc order by d.create_time desc
</select> </select>
<!-- <select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">-->
<!-- select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,-->
<!-- d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,-->
<!-- d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,-->
<!-- d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,-->
<!-- case-->
<!-- when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0-->
<!-- else 1-->
<!-- end as is_owner,-->
<!-- (select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,-->
<!-- p.protocol_code,p.transport,p.guid-->
<!-- from iot_device d-->
<!-- left join iot_product p on p.product_id=d.product_id-->
<!-- <if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>-->
<!-- <where>-->
<!-- and d.del_flag = '0'-->
<!-- <if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>-->
<!-- <if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>-->
<!-- <if test="productId != null "> and d.product_id = #{productId}</if>-->
<!-- <if test="deviceType != null "> and p.device_type = #{deviceType}</if>-->
<!-- <if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>-->
<!-- <if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>-->
<!-- <if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>-->
<!-- <if test="status != null "> and d.status = #{status}</if>-->
<!-- <if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>-->
<!--&lt;!&ndash; <if test="deptId != null and deptId != 0 and showChild != null and showChild">&ndash;&gt;-->
<!-- <if test="deptId != null and deptId != 0 ">-->
<!-- and-->
<!-- ( d.agencies_id in (SELECT u.dept_id FROM sys_user u-->
<!-- join sys_dept de on u.dept_id = de.dept_id-->
<!-- WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})-->
<!-- )-->
<!-- </if>-->
<!--&lt;!&ndash; <if test="deptId != null and deptId != 0 and showChild != null and !showChild">&ndash;&gt;-->
<!--&lt;!&ndash; and (&ndash;&gt;-->
<!--&lt;!&ndash; d.tenant_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})&ndash;&gt;-->
<!--&lt;!&ndash; or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})&ndash;&gt;-->
<!--&lt;!&ndash; )&ndash;&gt;-->
<!--&lt;!&ndash; </if>&ndash;&gt;-->
<!-- <if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>-->
<!-- </where>-->
<!-- group by d.device_id,d.tenant_id-->
<!-- order by d.create_time desc-->
<!-- </select>-->
<select id="selectDeviceShortList" parameterType="com.xinda.iot.domain.Device" resultMap="DeviceShortResult">
select d.device_id, d.device_name, p.product_id, p.product_name,p.device_type,
d.tenant_id, d.tenant_name, d.serial_number,d.gw_dev_code,
d.firmware_version, d.status,d.rssi,d.is_shadow,d.is_simulate ,d.location_way,
d.things_model_value, d.active_time,d.create_time, if(null = d.img_url or '' = d.img_url, p.img_url, d.img_url) as img_url,
case
when (select count(*) from iot_device_share du where du.device_id = d.device_id and du.user_id = #{tenantId}) then 0
else 1
end as is_owner,
(select count(*) from iot_device d1 where d1.gw_dev_code = d.serial_number) as sub_device_count,
p.protocol_code,p.transport,p.guid
from iot_device d
left join iot_product p on p.product_id=d.product_id
<if test="groupId != null and groupId !=0 "> left join iot_device_group g on g.device_id=d.device_id </if>
<where>
and d.del_flag = '0'
<if test="groupId != null and groupId !=0 "> and g.group_id = #{groupId}</if>
<if test="deviceName != null and deviceName != ''"> and d.device_name like concat('%', #{deviceName}, '%')</if>
<if test="productId != null "> and d.product_id = #{productId}</if>
<if test="deviceType != null "> and p.device_type = #{deviceType}</if>
<if test="productName != null and productName != ''"> and d.product_name like concat('%', #{productName}, '%')</if>
<if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>
<if test="gwDevCode != null and gwDevCode != ''"> and d.gw_dev_code = #{gwDevCode}</if>
<if test="status != null "> and d.status = #{status}</if>
<if test="isSimulate != null">and d.is_simulate = #{isSimulate}</if>
<if test="deptId != null and deptId != 0 ">
and
( d.agencies_id in (SELECT de.dept_id FROM sys_dept de
WHERE FIND_IN_SET(#{deptId}, de.ancestors) OR de.dept_id = #{deptId})
)
</if>
<!-- <if test="deptId != null and deptId != 0 and showChild != null and !showChild">-->
<!-- and (-->
<!-- d.agencies_id = (SELECT dept_user_id FROM sys_dept WHERE dept_id = #{deptId})-->
<!-- or d.device_id in (select du.device_id from iot_device_share du where du.user_id = #{tenantId})-->
<!-- )-->
<!-- </if>-->
<if test="params.beginActiveTime != null and params.beginActiveTime != '' and params.endActiveTime != null and params.endActiveTime != ''"> and d.active_time between #{params.beginActiveTime} and #{params.endActiveTime}</if>
</where>
group by d.device_id,d.tenant_id
order by d.create_time desc
</select>
<select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult"> <select id="selectDeviceByDeviceId" parameterType="Long" resultMap="DeviceResult">
select d.device_id, select d.device_id,
d.device_name, d.device_name,
@@ -502,6 +592,7 @@
(select count(distinct d.device_id,d.tenant_id) (select count(distinct d.device_id,d.tenant_id)
from iot_device d from iot_device d
<where> <where>
d.del_flag = '0'
<if test="deptId != null and deptId != 0"> <if test="deptId != null and deptId != 0">
and d.tenant_id in (SELECT u.user_id FROM sys_user u and d.tenant_id in (SELECT u.user_id FROM sys_user u
join sys_dept de on u.dept_id = de.dept_id join sys_dept de on u.dept_id = de.dept_id

View File

@@ -150,6 +150,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<delete id="cleanOperLog" parameterType="String">
delete from iot_function_log where serial_number = #{serialNumber}
</delete>
<update id="updateFuncLogBatch" parameterType="com.xinda.iot.domain.FunctionLog"> <update id="updateFuncLogBatch" parameterType="com.xinda.iot.domain.FunctionLog">
update iot_function_log l update iot_function_log l
set l.result_msg = #{resultMsg}, set l.result_msg = #{resultMsg},

View File

@@ -10,6 +10,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="protocolCode" column="protocol_code"/> <result property="protocolCode" column="protocol_code"/>
<result property="categoryId" column="category_id" /> <result property="categoryId" column="category_id" />
<result property="categoryName" column="category_name" /> <result property="categoryName" column="category_name" />
<result property="modelName" column="model_name" />
<result property="proName" column="pro_name" />
<result property="useOrg" column="use_org" />
<result property="tenantId" column="tenant_id" /> <result property="tenantId" column="tenant_id" />
<result property="tenantName" column="tenant_name" /> <result property="tenantName" column="tenant_name" />
<result property="isSys" column="is_sys" /> <result property="isSys" column="is_sys" />
@@ -37,12 +40,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectProductVo"> <sql id="selectProductVo">
select product_id, product_name,protocol_code,transport, category_id, category_name, tenant_id, tenant_name, is_sys, is_authorize, mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark,location_way,guid from iot_product select product_id, product_name,protocol_code,transport, category_id, category_name, model_name, pro_name, use_org, tenant_id, tenant_name, is_sys, is_authorize, mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark,location_way,guid from iot_product
</sql> </sql>
<select id="selectProductList" parameterType="com.xinda.iot.domain.Product" resultMap="ProductResult"> <select id="selectProductList" parameterType="com.xinda.iot.domain.Product" resultMap="ProductResult">
select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id, select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize, p.category_name,p.model_name, p.pro_name, p.use_org, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type, p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
p.network_method, p.vertificate_method, p.create_time, p.update_time, p.network_method, p.vertificate_method, p.create_time, p.update_time,
p.img_url,p.remark,p.guid, p.img_url,p.remark,p.guid,
@@ -52,27 +55,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
end as is_owner, end as is_owner,
p.location_way from iot_product p p.location_way from iot_product p
<where> <where>
<if test="deptId != null and showSenior and !isAdmin"> <!-- <if test="deptId != null and showSenior and !isAdmin">-->
and ( p.tenant_id = #{tenantId} <!-- and ( p.tenant_id = #{tenantId}-->
or (p.tenant_id in ( <!-- or (p.tenant_id in (-->
SELECT de.dept_user_id <!-- SELECT de.dept_user_id-->
FROM sys_dept de <!-- FROM sys_dept de-->
WHERE FIND_IN_SET( de.dept_id,( <!-- WHERE FIND_IN_SET( de.dept_id,(-->
SELECT d.ancestors <!-- SELECT d.ancestors-->
FROM sys_dept d <!-- FROM sys_dept d-->
WHERE d.dept_id = #{deptId} ) <!-- WHERE d.dept_id = #{deptId} )-->
) <!-- )-->
) <!-- )-->
and p.is_sys = 0 <!-- and p.is_sys = 0-->
) <!-- )-->
) <!-- )-->
</if> <!-- </if>-->
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin"> <!-- <if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">-->
and p.tenant_id = #{tenantId} <!-- and p.tenant_id = #{tenantId}-->
</if> <!-- </if>-->
<if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if> <if test="productName != null and productName != ''"> and p.product_name like concat('%', #{productName}, '%')</if>
<if test="productNameExclude != null and productNameExclude != ''"> and p.product_name != #{productNameExclude}</if> <if test="productNameExclude != null and productNameExclude != ''"> and p.product_name != #{productNameExclude}</if>
<if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if> <if test="categoryName != null and categoryName != ''"> and p.category_name like concat('%', #{categoryName}, '%')</if>
<if test="modelName != null and modelName != ''"> and p.model_name like concat('%', #{modelName}, '%')</if>
<if test="proName != null and proName != ''"> and p.pro_name like concat('%', #{proName}, '%')</if>
<if test="useOrg != null and useOrg != ''"> and p.use_org like concat('%', #{useOrg}, '%')</if>
<if test="status != null "> and p.status = #{status}</if> <if test="status != null "> and p.status = #{status}</if>
<if test="deviceType != null "> and device_type = #{deviceType}</if> <if test="deviceType != null "> and device_type = #{deviceType}</if>
</where> </where>
@@ -118,6 +124,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''">product_name,</if> <if test="productName != null and productName != ''">product_name,</if>
<if test="categoryId != null">category_id,</if> <if test="categoryId != null">category_id,</if>
<if test="categoryName != null and categoryName != ''">category_name,</if> <if test="categoryName != null and categoryName != ''">category_name,</if>
<if test="modelName != null and modelName != ''">model_name,</if>
<if test="proName != null and proName != ''">pro_name,</if>
<if test="useOrg != null and useOrg != ''"> use_org,</if>
<if test="tenantId != null">tenant_id,</if> <if test="tenantId != null">tenant_id,</if>
<if test="tenantName != null and tenantName != ''">tenant_name,</if> <if test="tenantName != null and tenantName != ''">tenant_name,</if>
<if test="isSys != null">is_sys,</if> <if test="isSys != null">is_sys,</if>
@@ -145,6 +154,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''">#{productName},</if> <if test="productName != null and productName != ''">#{productName},</if>
<if test="categoryId != null">#{categoryId},</if> <if test="categoryId != null">#{categoryId},</if>
<if test="categoryName != null and categoryName != ''">#{categoryName},</if> <if test="categoryName != null and categoryName != ''">#{categoryName},</if>
<if test="modelName != null and modelName != ''">#{modelName},</if>
<if test="proName != null and proName != ''">#{proName},</if>
<if test="useOrg != null and useOrg != ''"> #{useOrg},</if>
<if test="tenantId != null">#{tenantId},</if> <if test="tenantId != null">#{tenantId},</if>
<if test="tenantName != null and tenantName != ''">#{tenantName},</if> <if test="tenantName != null and tenantName != ''">#{tenantName},</if>
<if test="isSys != null">#{isSys},</if> <if test="isSys != null">#{isSys},</if>
@@ -176,6 +188,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="productName != null and productName != ''">product_name = #{productName},</if> <if test="productName != null and productName != ''">product_name = #{productName},</if>
<if test="categoryId != null">category_id = #{categoryId},</if> <if test="categoryId != null">category_id = #{categoryId},</if>
<if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if> <if test="categoryName != null and categoryName != ''">category_name = #{categoryName},</if>
<if test="modelName != null and modelName != ''">model_name = #{modelName},</if>
<if test="proName != null and proName != ''">pro_name = #{proName},</if>
<if test="useOrg != null and useOrg != ''"> use_org = #{useOrg},</if>
<if test="tenantId != null">tenant_id = #{tenantId},</if> <if test="tenantId != null">tenant_id = #{tenantId},</if>
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if> <if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
<if test="isSys != null">is_sys = #{isSys},</if> <if test="isSys != null">is_sys = #{isSys},</if>
@@ -297,7 +312,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTerminalUserProduct" resultType="com.xinda.iot.domain.Product"> <select id="selectTerminalUserProduct" resultType="com.xinda.iot.domain.Product">
select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id, select p.product_id, p.product_name,p.protocol_code,p.transport, p.category_id,
p.category_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize, p.category_name,p.model_name, p.pro_name, p.tenant_id, p.tenant_name, p.is_sys, p.is_authorize,
p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type, p.mqtt_account,p.mqtt_password,p.mqtt_secret ,p.status,p.device_type,
p.network_method, p.vertificate_method, p.create_time, p.update_time, p.network_method, p.vertificate_method, p.create_time, p.update_time,
p.img_url,p.remark p.img_url,p.remark

View File

@@ -85,6 +85,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where standard_id = #{standardId} where standard_id = #{standardId}
</select> </select>
<select id="checkName" parameterType="String" resultType="java.lang.Boolean">
SELECT COUNT(*) > 0
FROM iot_standard
where standard_name = #{standardName}
</select>
<insert id="insertStandard" parameterType="com.xinda.iot.domain.Standard" useGeneratedKeys="true" keyProperty="standardId"> <insert id="insertStandard" parameterType="com.xinda.iot.domain.Standard" useGeneratedKeys="true" keyProperty="standardId">
insert into iot_standard insert into iot_standard
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -141,10 +147,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach> </foreach>
</delete> </delete>
<select id="productCountInStandards" parameterType="String" resultType="int">
select count(*) from iot_product where standard_id in
<foreach item="standardId" collection="array" open="(" separator="," close=")">
#{standardId}
</foreach>
</select>
</mapper> </mapper>

View File

@@ -15,8 +15,10 @@
<result property="identifier" column="identifier"/> <result property="identifier" column="identifier"/>
<result property="type" column="type"/> <result property="type" column="type"/>
<result property="datatype" column="datatype"/> <result property="datatype" column="datatype"/>
<result property="places" column="places" />
<result property="formula" column="formula"/> <result property="formula" column="formula"/>
<result property="specs" column="specs"/> <result property="specs" column="specs"/>
<result property="isCalc" column="is_calc"/>
<result property="isChart" column="is_chart"/> <result property="isChart" column="is_chart"/>
<result property="isSharePerm" column="is_share_perm"/> <result property="isSharePerm" column="is_share_perm"/>
<result property="isHistory" column="is_history"/> <result property="isHistory" column="is_history"/>
@@ -56,8 +58,10 @@
identifier, identifier,
type, type,
datatype, datatype,
places,
formula, formula,
specs, specs,
is_calc,
is_chart, is_chart,
is_share_perm, is_share_perm,
is_history, is_history,
@@ -82,8 +86,8 @@
else m.model_name else m.model_name
end as model_name, end as model_name,
m.model_name as model_name_zh_cn, t.en_us as model_name_en_us, m.model_name as model_name_zh_cn, t.en_us as model_name_en_us,
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula, m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype,m.places, m.formula,
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by, m.specs, m.is_calc, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
from iot_things_model m from iot_things_model m
left join iot_things_model_translate t on m.model_id = t.id left join iot_things_model_translate t on m.model_id = t.id
@@ -94,6 +98,9 @@
<if test="type!=null and type==4 "> <if test="type!=null and type==4 ">
and type in(1,2) and type in(1,2)
</if> </if>
<if test="isCalc != null ">
and is_calc = #{isCalc}
</if>
<if test="isChart != null "> <if test="isChart != null ">
and is_chart = #{isChart} and is_chart = #{isChart}
</if> </if>
@@ -137,8 +144,8 @@
when #{language} = 'en-US' then t.en_us when #{language} = 'en-US' then t.en_us
else m.model_name else m.model_name
end as model_name, end as model_name,
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula, m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype,m.places, m.formula,
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by, m.specs, m.is_calc, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
from iot_things_model m from iot_things_model m
left join iot_things_model_translate t on m.model_id = t.id left join iot_things_model_translate t on m.model_id = t.id
@@ -155,8 +162,8 @@
when #{language} = 'en-US' then t.en_us when #{language} = 'en-US' then t.en_us
else m.model_name else m.model_name
end as model_name, end as model_name,
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula, m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype,m.places, m.formula,
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by, m.specs,m.is_calc, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
from iot_things_model m from iot_things_model m
left join iot_things_model_translate t on m.model_id = t.id left join iot_things_model_translate t on m.model_id = t.id
@@ -170,8 +177,8 @@
when #{language} = 'en-US' then t.en_us when #{language} = 'en-US' then t.en_us
else m.model_name else m.model_name
end as model_name, end as model_name,
m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.formula, m.product_id, m.product_name, m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype,m.places, m.formula,
m.specs, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by, m.specs,m.is_calc, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.is_app, m.del_flag, m.create_by,
m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order m.create_time, m.update_by, m.update_time, m.remark, m.is_readonly, m.model_order
from iot_things_model m from iot_things_model m
left join iot_things_model_translate t on m.model_id = t.id left join iot_things_model_translate t on m.model_id = t.id
@@ -213,12 +220,16 @@
<if test="datatype != null and datatype != ''"> <if test="datatype != null and datatype != ''">
datatype, datatype,
</if> </if>
<if test="places != null">places,</if>
<if test="formula != null"> <if test="formula != null">
formula, formula,
</if> </if>
<if test="specs != null and specs != ''"> <if test="specs != null and specs != ''">
specs, specs,
</if> </if>
<if test="isCalc != null">
is_calc,
</if>
<if test="isChart != null"> <if test="isChart != null">
is_chart, is_chart,
</if> </if>
@@ -284,12 +295,16 @@
<if test="datatype != null and datatype != ''"> <if test="datatype != null and datatype != ''">
#{datatype}, #{datatype},
</if> </if>
<if test="places != null and places != ''">#{places},</if>
<if test="formula != null"> <if test="formula != null">
#{formula}, #{formula},
</if> </if>
<if test="specs != null and specs != ''"> <if test="specs != null and specs != ''">
#{specs}, #{specs},
</if> </if>
<if test="isCalc != null">
#{isCalc},
</if>
<if test="isChart != null"> <if test="isChart != null">
#{isChart}, #{isChart},
</if> </if>
@@ -343,7 +358,9 @@
identifier, identifier,
type, type,
datatype, datatype,
places,
specs, specs,
is_calc,
is_chart, is_chart,
is_share_perm, is_share_perm,
is_history, is_history,
@@ -352,16 +369,17 @@
is_readonly, is_readonly,
create_by, create_by,
create_time, create_time,
formula formula,
model_order
) )
VALUES VALUES
<foreach item="model" collection="list" separator=","> <foreach item="model" collection="list" separator=",">
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
#{model.modelName},#{model.productId},#{model.productName},#{model.tenantId}, #{model.modelName},#{model.productId},#{model.productName},#{model.tenantId},
#{model.tenantName},#{model.identifier},#{model.type},#{model.datatype}, #{model.tenantName},#{model.identifier},#{model.type},#{model.datatype},#{model.places},
#{model.specs},#{model.isChart},#{model.isSharePerm},#{model.isHistory}, #{model.specs},#{model.isCalc},#{model.isChart},#{model.isSharePerm},#{model.isHistory},
#{model.isMonitor},#{model.isApp},#{model.isReadonly},#{model.createBy},#{model.createTime}, #{model.isMonitor},#{model.isApp},#{model.isReadonly},#{model.createBy},#{model.createTime},
#{model.formula} #{model.formula},#{model.modelOrder}
</trim> </trim>
</foreach> </foreach>
</insert> </insert>
@@ -393,12 +411,16 @@
<if test="datatype != null and datatype != ''"> <if test="datatype != null and datatype != ''">
datatype = #{datatype}, datatype = #{datatype},
</if> </if>
<if test="places != null and places != ''">places = #{places},</if>
<if test="formula != null"> <if test="formula != null">
formula = #{formula}, formula = #{formula},
</if> </if>
<if test="specs != null and specs != ''"> <if test="specs != null and specs != ''">
specs = #{specs}, specs = #{specs},
</if> </if>
<if test="isCalc != null">
is_calc = #{isCalc},
</if>
<if test="isChart != null"> <if test="isChart != null">
is_chart = #{isChart}, is_chart = #{isChart},
</if> </if>
@@ -458,6 +480,7 @@
<select id="selectThingsModelIsMonitor" parameterType="com.xinda.iot.model.ThingsModels.ThingsItems" <select id="selectThingsModelIsMonitor" parameterType="com.xinda.iot.model.ThingsModels.ThingsItems"
resultType="com.xinda.common.core.iot.response.IdentityAndName"> resultType="com.xinda.common.core.iot.response.IdentityAndName">
select m.is_monitor as isMonitor, select m.is_monitor as isMonitor,
m.is_calc as isCalc,
m.is_chart as isChart, m.is_chart as isChart,
m.is_share_perm as isSharePerm, m.is_share_perm as isSharePerm,
m.is_history as isHistory, m.is_history as isHistory,

View File

@@ -14,7 +14,10 @@
<result property="identifier" column="identifier" /> <result property="identifier" column="identifier" />
<result property="type" column="type" /> <result property="type" column="type" />
<result property="datatype" column="datatype" /> <result property="datatype" column="datatype" />
<result property="places" column="places" />
<result property="specs" column="specs" /> <result property="specs" column="specs" />
<result property="isCalc" column="is_calc"/>
<result property="isChart" column="is_chart"/>
<result property="isSys" column="is_sys" /> <result property="isSys" column="is_sys" />
<result property="isReadonly" column="is_readonly" /> <result property="isReadonly" column="is_readonly" />
<result property="isSharePerm" column="is_share_perm" /> <result property="isSharePerm" column="is_share_perm" />
@@ -32,42 +35,59 @@
</resultMap> </resultMap>
<sql id="selectThingsModelStandardVo"> <sql id="selectThingsModelStandardVo">
select template_id, template_name, standard_id, standard_name, tenant_id, tenant_name, identifier, type, datatype, specs, is_sys, is_readonly, is_chart,is_share_perm, is_history, formula, del_flag, create_by, create_time, update_by, update_time, remark, model_order from iot_things_model_standard select template_id, template_name, standard_id, standard_name, tenant_id, tenant_name, identifier, type, datatype, places, specs, is_calc,
is_chart, is_sys, is_readonly, is_share_perm, is_history, is_monitor, formula, del_flag, create_by, create_time, update_by, update_time, remark, model_order from iot_things_model_standard
</sql> </sql>
<select id="selectThingsModelStandardList" parameterType="com.xinda.iot.domain.ThingsModelStandard" resultMap="ThingsModelStandardResult"> <select id="selectThingsModelStandardList" parameterType="com.xinda.iot.domain.ThingsModelStandard" resultMap="ThingsModelStandardResult">
select m.template_id,m.template_name,m.standard_id,m.standard_name, select m.template_id,m.template_name,m.standard_id,m.standard_name,
m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order, m.is_monitor m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.places, m.specs, m.is_calc, m.is_chart, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.is_monitor, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order
from iot_things_model_standard m from iot_things_model_standard m
<where> <where>
<if test="templateName != null and templateName != ''"> and m.template_name like concat('%', #{templateName}, '%')</if> <if test="templateName != null and templateName != ''"> and m.template_name like concat('%', #{templateName}, '%')</if>
<if test="type != null "> and m.type = #{type}</if> <if test="type != null "> and m.type = #{type}</if>
<if test="isCalc != null ">
and is_calc = #{isCalc}
</if>
<if test="isChart != null ">
and is_chart = #{isChart}
</if>
<if test="specs != null and specs != ''"> and m.specs = #{specs}</if> <if test="specs != null and specs != ''"> and m.specs = #{specs}</if>
<if test="tenantId != null and tenantId != ''"> and (m.tenant_id = #{tenantId} or m.is_sys = 1)</if> <if test="tenantId != null and tenantId != ''"> and (m.tenant_id = #{tenantId} or m.is_sys = 1)</if>
<if test="standardId != null and standardId != ''"> and (m.standard_id = #{standardId})</if> <if test="standardId != null and standardId != ''"> and (m.standard_id = #{standardId})</if>
</where> </where>
order by m.template_id desc, m.create_time desc order by m.model_order ASC
</select>
<select id="checkUnique" parameterType="com.xinda.iot.domain.ThingsModelStandard" resultType="java.lang.Boolean">
SELECT COUNT(*) > 0
FROM iot_things_model_standard
<where>
standard_id = #{standardId} and identifier = #{identifier}
<if test="templateId != null and templateId != ''"> and template_id != #{templateId}</if>
</where>
</select> </select>
<select id="selectModelListByStandardId" parameterType="Long" resultMap="ThingsModelStandardResult"> <select id="selectModelListByStandardId" parameterType="Long" resultMap="ThingsModelStandardResult">
select m.template_id,m.template_name,m.standard_id,m.standard_name, select m.template_id,m.template_name,m.standard_id,m.standard_name,
m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order, m.is_monitor m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.places,m.specs,m.is_calc, m.is_chart, m.is_share_perm, m.is_sys, m.is_readonly, m.is_history, m.is_monitor,m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order
from iot_things_model_standard m from iot_things_model_standard m
<where> <where>
m.standard_id = #{standardId} m.standard_id = #{standardId}
</where> </where>
order by m.template_id desc, m.create_time desc order by m.model_order ASC
</select> </select>
<select id="selectThingsModelStandardByTemplateId" resultMap="ThingsModelStandardResult"> <select id="selectThingsModelStandardByTemplateId" resultMap="ThingsModelStandardResult">
select m.template_id,m.template_name, m.standard_id, m.standard_name,m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order select m.template_id,m.template_name, m.standard_id, m.standard_name,m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.places,m.specs, m.is_calc, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history,m.is_monitor, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order
from iot_things_model_standard m from iot_things_model_standard m
where m.template_id = #{templateId} where m.template_id = #{templateId}
</select> </select>
<select id="selectThingsModelStandardByTemplateIds" resultMap="ThingsModelStandardResult"> <select id="selectThingsModelStandardByTemplateIds" resultMap="ThingsModelStandardResult">
select m.template_id, m.template_name, m.standard_id, m.standard_name,m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.specs, m.is_sys, m.is_readonly, m.is_chart, m.is_share_perm, m.is_history, m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order, m.is_monitor select m.template_id, m.template_name, m.standard_id, m.standard_name,m.tenant_id, m.tenant_name, m.identifier, m.type, m.datatype, m.places, m.specs,m.is_calc, m.is_chart, m.is_sys, m.is_readonly, m.is_share_perm, m.is_history, m.is_monitor,m.formula, m.del_flag, m.create_by, m.create_time, m.update_by, m.update_time, m.remark, m.model_order
from iot_things_model_standard m from iot_things_model_standard m
where m.template_id in where m.template_id in
<foreach item="templateId" collection="templateIds" open="(" separator="," close=")"> <foreach item="templateId" collection="templateIds" open="(" separator="," close=")">
@@ -86,10 +106,12 @@
<if test="identifier != null and identifier != ''">identifier,</if> <if test="identifier != null and identifier != ''">identifier,</if>
<if test="type != null">type,</if> <if test="type != null">type,</if>
<if test="datatype != null and datatype != ''">datatype,</if> <if test="datatype != null and datatype != ''">datatype,</if>
<if test="places != null">places,</if>
<if test="specs != null and specs != ''">specs,</if> <if test="specs != null and specs != ''">specs,</if>
<if test="isCalc != null">is_calc,</if>
<if test="isChart != null">is_chart,</if>
<if test="isSys != null">is_sys,</if> <if test="isSys != null">is_sys,</if>
<if test="isReadonly != null">is_readonly,</if> <if test="isReadonly != null">is_readonly,</if>
<if test="isChart != null">is_chart,</if>
<if test="isSharePerm != null">is_share_perm,</if> <if test="isSharePerm != null">is_share_perm,</if>
<if test="isHistory != null">is_history,</if> <if test="isHistory != null">is_history,</if>
<if test="isMonitor != null">is_monitor,</if> <if test="isMonitor != null">is_monitor,</if>
@@ -112,10 +134,12 @@
<if test="identifier != null and identifier != ''">#{identifier},</if> <if test="identifier != null and identifier != ''">#{identifier},</if>
<if test="type != null">#{type},</if> <if test="type != null">#{type},</if>
<if test="datatype != null and datatype != ''">#{datatype},</if> <if test="datatype != null and datatype != ''">#{datatype},</if>
<if test="places != null and places != ''">#{places},</if>
<if test="specs != null and specs != ''">#{specs},</if> <if test="specs != null and specs != ''">#{specs},</if>
<if test="isCalc != null">#{isCalc},</if>
<if test="isChart != null"> #{isChart},</if>
<if test="isSys != null">#{isSys},</if> <if test="isSys != null">#{isSys},</if>
<if test="isReadonly != null">#{isReadonly},</if> <if test="isReadonly != null">#{isReadonly},</if>
<if test="isChart != null">#{isChart},</if>
<if test="isSharePerm != null">#{isSharePerm},</if> <if test="isSharePerm != null">#{isSharePerm},</if>
<if test="isHistory != null">#{isHistory},</if> <if test="isHistory != null">#{isHistory},</if>
<if test="isMonitor != null">#{isMonitor},</if> <if test="isMonitor != null">#{isMonitor},</if>
@@ -142,10 +166,12 @@
<if test="identifier != null and identifier != ''">identifier = #{identifier},</if> <if test="identifier != null and identifier != ''">identifier = #{identifier},</if>
<if test="type != null">type = #{type},</if> <if test="type != null">type = #{type},</if>
<if test="datatype != null and datatype != ''">datatype = #{datatype},</if> <if test="datatype != null and datatype != ''">datatype = #{datatype},</if>
<if test="places != null">places = #{places},</if>
<if test="specs != null and specs != ''">specs = #{specs},</if> <if test="specs != null and specs != ''">specs = #{specs},</if>
<if test="isCalc != null"> is_calc = #{isCalc},</if>
<if test="isChart != null">is_chart = #{isChart},</if>
<if test="isSys != null">is_sys = #{isSys},</if> <if test="isSys != null">is_sys = #{isSys},</if>
<if test="isReadonly != null">is_readonly = #{isReadonly},</if> <if test="isReadonly != null">is_readonly = #{isReadonly},</if>
<if test="isChart != null">is_chart = #{isChart},</if>
<if test="isSharePerm != null">is_share_perm = #{isSharePerm},</if> <if test="isSharePerm != null">is_share_perm = #{isSharePerm},</if>
<if test="isHistory != null">is_history = #{isHistory},</if> <if test="isHistory != null">is_history = #{isHistory},</if>
<if test="isMonitor != null">is_Monitor = #{isMonitor},</if> <if test="isMonitor != null">is_Monitor = #{isMonitor},</if>
@@ -157,6 +183,7 @@
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="modelOrder != null">model_order = #{modelOrder},</if>
</trim> </trim>
where template_id = #{templateId} where template_id = #{templateId}
</update> </update>
@@ -165,6 +192,9 @@
delete from iot_things_model_standard where template_id = #{templateId} delete from iot_things_model_standard where template_id = #{templateId}
</delete> </delete>
<delete id="deleteThingsModelStandardByStandardId" parameterType="Long">
delete from iot_things_model_standard where standard_id = #{standardId}
</delete>
<delete id="deleteThingsModelStandardByTemplateIds" parameterType="String"> <delete id="deleteThingsModelStandardByTemplateIds" parameterType="String">
delete from iot_things_model_standard where template_id in delete from iot_things_model_standard where template_id in
@@ -183,7 +213,10 @@
identifier, identifier,
type, type,
datatype, datatype,
places,
specs, specs,
is_calc,
is_chart,
is_sys, is_sys,
is_readonly, is_readonly,
is_share_perm, is_share_perm,
@@ -209,7 +242,10 @@
#{item.identifier}, #{item.identifier},
#{item.type}, #{item.type},
#{item.datatype}, #{item.datatype},
#{item.places},
#{item.specs}, #{item.specs},
#{item.isCalc},
#{item.isChart},
#{item.isSys}, #{item.isSys},
#{item.isReadonly}, #{item.isReadonly},
#{item.isSharePerm}, #{item.isSharePerm},

View File

@@ -1,5 +1,6 @@
package com.xinda.system.service; package com.xinda.system.service;
import com.xinda.common.core.domain.TreeProSelect;
import com.xinda.common.core.domain.TreeSelect; import com.xinda.common.core.domain.TreeSelect;
import com.xinda.common.core.domain.entity.SysDept; import com.xinda.common.core.domain.entity.SysDept;
import com.xinda.common.core.domain.entity.SysRole; import com.xinda.common.core.domain.entity.SysRole;
@@ -152,4 +153,6 @@ public interface ISysDeptService
* @return java.lang.Long * @return java.lang.Long
*/ */
Long selectRoleIdByDeptId(Long deptId); Long selectRoleIdByDeptId(Long deptId);
public List<TreeProSelect> selectDeptProTreeList(SysDept dept);
} }

View File

@@ -2,6 +2,7 @@ package com.xinda.system.service.impl;
import com.xinda.common.annotation.DataScope; import com.xinda.common.annotation.DataScope;
import com.xinda.common.constant.UserConstants; import com.xinda.common.constant.UserConstants;
import com.xinda.common.core.domain.TreeProSelect;
import com.xinda.common.core.domain.TreeSelect; import com.xinda.common.core.domain.TreeSelect;
import com.xinda.common.core.domain.entity.SysDept; import com.xinda.common.core.domain.entity.SysDept;
import com.xinda.common.core.domain.entity.SysRole; import com.xinda.common.core.domain.entity.SysRole;
@@ -82,6 +83,13 @@ public class SysDeptServiceImpl implements ISysDeptService
return buildDeptTreeSelect(depts); return buildDeptTreeSelect(depts);
} }
@Override
public List<TreeProSelect> selectDeptProTreeList(SysDept dept)
{
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptProTreeSelect(depts);
}
/** /**
* 构建前端所需要树结构 * 构建前端所需要树结构
* *
@@ -122,6 +130,12 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
} }
public List<TreeProSelect> buildDeptProTreeSelect(List<SysDept> depts)
{
List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeProSelect::new).collect(Collectors.toList());
}
/** /**
* 根据角色ID查询部门树信息 * 根据角色ID查询部门树信息
* *
@@ -142,7 +156,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @param deptId 部门ID * @param deptId 部门ID
* @return 部门信息 * @return 部门信息
*/ */
@Cacheable(value = "dept", key = "#root.methodName + '_' + #deptId", unless = "#result == null") // @Cacheable(value = "dept", key = "#root.methodName + '_' + #deptId", unless = "#result == null")
@Override @Override
public SysDept selectDeptById(Long deptId) public SysDept selectDeptById(Long deptId)
{ {

View File

@@ -136,7 +136,7 @@ public class SysUserServiceImpl implements ISysUserService
* @param userId 用户ID * @param userId 用户ID
* @return 用户对象信息 * @return 用户对象信息
*/ */
@Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userId", unless = "#result == null") // @Cacheable(value = "sysUser", key = "#root.methodName + '_' + #userId", unless = "#result == null")
@Override @Override
public SysUser selectUserById(Long userId) public SysUser selectUserById(Long userId)
{ {