mqtt通讯修改 增加模板 计算属性
This commit is contained in:
@@ -60,7 +60,7 @@ server:
|
|||||||
spring:
|
spring:
|
||||||
# 环境配置,dev=开发环境,prod=生产环境
|
# 环境配置,dev=开发环境,prod=生产环境
|
||||||
profiles:
|
profiles:
|
||||||
active: dev # 环境配置,dev=开发环境,prod=生产环境
|
active: prod # 环境配置,dev=开发环境,prod=生产环境
|
||||||
# 资源信息
|
# 资源信息
|
||||||
messages:
|
messages:
|
||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ public interface XinDaConstant {
|
|||||||
String GEC6100D = "MODBUS-JSON-GEC6100D";
|
String GEC6100D = "MODBUS-JSON-GEC6100D";
|
||||||
String SGZ = "SGZ";
|
String SGZ = "SGZ";
|
||||||
String CH = "CH";
|
String CH = "CH";
|
||||||
String GONGKONGBANG_HTSZ = "GONGKONGBANG-HTSZ";
|
String IECF6113 = "IECF6113";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public enum TopicType {
|
|||||||
SERVICE_INVOKE_REPLY(0,8,"/service/reply", "订阅功能调用返回结果"),
|
SERVICE_INVOKE_REPLY(0,8,"/service/reply", "订阅功能调用返回结果"),
|
||||||
FIRMWARE_UPGRADE_REPLY(0,9,"/upgrade/reply", "订阅设备OTA升级结果"),
|
FIRMWARE_UPGRADE_REPLY(0,9,"/upgrade/reply", "订阅设备OTA升级结果"),
|
||||||
MESSAGE_POST(0,26,"/message/post","订阅设备上报消息"),
|
MESSAGE_POST(0,26,"/message/post","订阅设备上报消息"),
|
||||||
|
PROPERTY_XINDA_DEV(0,28,"/json/dev/", "订阅属性"),
|
||||||
|
|
||||||
/*** 通用设备订阅主题(平台下发)***/
|
/*** 通用设备订阅主题(平台下发)***/
|
||||||
FUNCTION_GET(1,17,"/function/get", "发布功能"),
|
FUNCTION_GET(1,17,"/function/get", "发布功能"),
|
||||||
@@ -36,7 +37,7 @@ public enum TopicType {
|
|||||||
STATUS_POST(1,11,"/status/post","发布状态"),
|
STATUS_POST(1,11,"/status/post","发布状态"),
|
||||||
NTP_GET(1,15,"/ntp/get","发布时钟同步"),
|
NTP_GET(1,15,"/ntp/get","发布时钟同步"),
|
||||||
INFO_GET(1,18,"/info/get","发布设备信息"),
|
INFO_GET(1,18,"/info/get","发布设备信息"),
|
||||||
|
FUNCTION_XINDA_DOWN(1,29,"/json/down/", "发布功能"),
|
||||||
|
|
||||||
/*** 视频监控设备转协议发布 ***/
|
/*** 视频监控设备转协议发布 ***/
|
||||||
DEV_INFO_POST(3,19,"/info/post","设备端发布设备信息"),
|
DEV_INFO_POST(3,19,"/info/post","设备端发布设备信息"),
|
||||||
|
|||||||
@@ -55,6 +55,24 @@ public class TopicsUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String buildNewTopic(String serialNumber, TopicType type) {
|
||||||
|
/*
|
||||||
|
* 订阅属性:
|
||||||
|
* 如果启动emq 则为 /property/post/+
|
||||||
|
* 如果启动netty的mqttBroker 则为 /property/post/{serialNumber}
|
||||||
|
*
|
||||||
|
* 发布都为/{productId}/property/get/{serialNumber}
|
||||||
|
*/
|
||||||
|
if (com.xinda.common.utils.StringUtils.isEmpty(serialNumber)) {
|
||||||
|
serialNumber = "+";
|
||||||
|
}
|
||||||
|
if (type.getType() == 0) {
|
||||||
|
return enabled ? type.getTopicSuffix() : XinDaConstant.MQTT.PREDIX + type.getTopicSuffix() + serialNumber;
|
||||||
|
} else {
|
||||||
|
return type.getTopicSuffix() + serialNumber;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有可订阅的主题
|
* 获取所有可订阅的主题
|
||||||
@@ -151,6 +169,12 @@ public class TopicsUtils {
|
|||||||
return values[2];
|
return values[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SneakyThrows
|
||||||
|
public String parseNewSerialNumber(String topic) {
|
||||||
|
String[] values = topic.split("/");
|
||||||
|
return values[3];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取topic 判断字段 name
|
* 获取topic 判断字段 name
|
||||||
**/
|
**/
|
||||||
@@ -163,6 +187,15 @@ public class TopicsUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String parseNewTopicName(String topic) {
|
||||||
|
String[] values = topic.split("/");
|
||||||
|
if (values.length >2){
|
||||||
|
return "/"+ values[1] + "/" + values[2];
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取topic 判断字段 name
|
* 获取topic 判断字段 name
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.xinda.common.core.mq.DeviceReportBo;
|
|||||||
import com.xinda.common.enums.TopicType;
|
import com.xinda.common.enums.TopicType;
|
||||||
import com.xinda.common.utils.StringUtils;
|
import com.xinda.common.utils.StringUtils;
|
||||||
import com.xinda.common.utils.gateway.mq.TopicsUtils;
|
import com.xinda.common.utils.gateway.mq.TopicsUtils;
|
||||||
|
import com.xinda.iot.domain.Device;
|
||||||
|
import com.xinda.iot.service.IDeviceService;
|
||||||
import com.xinda.mq.model.ReportDataBo;
|
import com.xinda.mq.model.ReportDataBo;
|
||||||
import com.xinda.mq.service.IDataHandler;
|
import com.xinda.mq.service.IDataHandler;
|
||||||
import com.xinda.mq.service.IMqttMessagePublish;
|
import com.xinda.mq.service.IMqttMessagePublish;
|
||||||
@@ -27,6 +29,8 @@ public class DeviceOtherMsgHandler {
|
|||||||
private IDataHandler dataHandler;
|
private IDataHandler dataHandler;
|
||||||
@Resource
|
@Resource
|
||||||
private IMqttMessagePublish messagePublish;
|
private IMqttMessagePublish messagePublish;
|
||||||
|
@Resource
|
||||||
|
private IDeviceService deviceService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* true: 使用netty搭建的mqttBroker false: 使用emq
|
* true: 使用netty搭建的mqttBroker false: 使用emq
|
||||||
@@ -42,8 +46,13 @@ public class DeviceOtherMsgHandler {
|
|||||||
*/
|
*/
|
||||||
public void messageHandler(DeviceReportBo bo) {
|
public void messageHandler(DeviceReportBo bo) {
|
||||||
String type = "";
|
String type = "";
|
||||||
String name = topicsUtils.parseTopicName(bo.getTopicName());
|
String name = "";
|
||||||
if (StringUtils.isEmpty(name) || name.endsWith(TopicType.FUNCTION_GET.getTopicSuffix())) return;
|
if (bo.getTopicName().startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix()) || bo.getTopicName().startsWith(TopicType.FUNCTION_XINDA_DOWN.getTopicSuffix())) {
|
||||||
|
name = topicsUtils.parseNewTopicName(bo.getTopicName());
|
||||||
|
}else{
|
||||||
|
name = topicsUtils.parseTopicName(bo.getTopicName());
|
||||||
|
}
|
||||||
|
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);
|
||||||
TopicType topicType = TopicType.getType(name);
|
TopicType topicType = TopicType.getType(name);
|
||||||
switch (topicType) {
|
switch (topicType) {
|
||||||
@@ -73,14 +82,20 @@ public class DeviceOtherMsgHandler {
|
|||||||
private ReportDataBo buildReportData(DeviceReportBo bo) {
|
private ReportDataBo buildReportData(DeviceReportBo bo) {
|
||||||
String message = new String(bo.getData());
|
String message = new String(bo.getData());
|
||||||
log.info("收到设备信息[{}]", message);
|
log.info("收到设备信息[{}]", message);
|
||||||
Long productId = topicsUtils.parseProductId(bo.getTopicName());
|
String serialNumber = "";
|
||||||
String serialNumber = topicsUtils.parseSerialNumber(bo.getTopicName());
|
|
||||||
ReportDataBo dataBo = new ReportDataBo();
|
ReportDataBo dataBo = new ReportDataBo();
|
||||||
dataBo.setMessage(message);
|
dataBo.setMessage(message);
|
||||||
|
Long productId;
|
||||||
|
if (bo.getTopicName().startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix()) || bo.getTopicName().startsWith(TopicType.FUNCTION_XINDA_DOWN.getTopicSuffix())) {
|
||||||
|
serialNumber = topicsUtils.parseNewSerialNumber(bo.getTopicName());
|
||||||
|
productId = deviceService.selectDeviceBySerialNumber(serialNumber).getProductId();
|
||||||
|
}else{
|
||||||
|
serialNumber = topicsUtils.parseSerialNumber(bo.getTopicName());
|
||||||
|
productId = topicsUtils.parseProductId(bo.getTopicName());
|
||||||
|
}
|
||||||
dataBo.setProductId(productId);
|
dataBo.setProductId(productId);
|
||||||
dataBo.setSerialNumber(serialNumber);
|
dataBo.setSerialNumber(serialNumber);
|
||||||
dataBo.setRuleEngine(false);
|
dataBo.setRuleEngine(false);
|
||||||
return dataBo;
|
return dataBo;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ public class CategoryController extends BaseController
|
|||||||
return AjaxResult.success(categoryService.selectCategoryShortList(category));
|
return AjaxResult.success(categoryService.selectCategoryShortList(category));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 导出产品分类列表
|
* 导出产品分类列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,144 @@
|
|||||||
|
package com.xinda.data.controller;
|
||||||
|
|
||||||
|
import com.xinda.common.annotation.Log;
|
||||||
|
import com.xinda.common.core.controller.BaseController;
|
||||||
|
import com.xinda.common.core.domain.AjaxResult;
|
||||||
|
import com.xinda.common.core.page.TableDataInfo;
|
||||||
|
import com.xinda.common.enums.BusinessType;
|
||||||
|
import com.xinda.common.utils.SecurityUtils;
|
||||||
|
import com.xinda.common.utils.poi.ExcelUtil;
|
||||||
|
import com.xinda.iot.domain.Standard;
|
||||||
|
import com.xinda.iot.service.IStandardService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类Controller
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@Api(tags = "产品分类")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/standard")
|
||||||
|
public class StandardController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IStandardService standardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品分类列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("分类分页列表")
|
||||||
|
public TableDataInfo list(Standard standard)
|
||||||
|
{
|
||||||
|
Boolean showSenior = standard.getShowSenior();
|
||||||
|
if (Objects.isNull(showSenior)){
|
||||||
|
standard.setShowSenior(true); //默认展示上级品类
|
||||||
|
}
|
||||||
|
Long deptUserId = getLoginUser().getUser().getDept().getDeptUserId();
|
||||||
|
standard.setAdmin(SecurityUtils.isAdmin(deptUserId));
|
||||||
|
standard.setDeptId(getLoginUser().getDeptId());
|
||||||
|
standard.setTenantId(deptUserId);
|
||||||
|
startPage();
|
||||||
|
return getDataTable(standardService.selectStandardList(standard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品简短分类列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:list')")
|
||||||
|
@GetMapping("/shortlist")
|
||||||
|
@ApiOperation("分类简短列表")
|
||||||
|
public AjaxResult shortlist(Standard standard)
|
||||||
|
{
|
||||||
|
Boolean showSenior = standard.getShowSenior();
|
||||||
|
if (Objects.isNull(showSenior)){
|
||||||
|
standard.setShowSenior(true); //默认展示上级品类
|
||||||
|
}
|
||||||
|
Long deptUserId = getLoginUser().getUser().getDept().getDeptUserId();
|
||||||
|
standard.setAdmin(SecurityUtils.isAdmin(deptUserId));
|
||||||
|
standard.setDeptId(getLoginUser().getDeptId());
|
||||||
|
standard.setTenantId(deptUserId);
|
||||||
|
startPage();
|
||||||
|
return AjaxResult.success(standardService.selectStandardShortList(standard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出产品分类列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:export')")
|
||||||
|
@Log(title = "产品分类", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
@ApiOperation("导出分类")
|
||||||
|
public void export(HttpServletResponse response, Standard standard)
|
||||||
|
{
|
||||||
|
List<Standard> list = standardService.selectStandardList(standard);
|
||||||
|
ExcelUtil<Standard> util = new ExcelUtil<Standard>(Standard.class);
|
||||||
|
util.exportExcel(response, list, "产品分类数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取产品分类详细信息
|
||||||
|
*/
|
||||||
|
@ApiOperation("获取分类详情")
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:query')")
|
||||||
|
@GetMapping(value = "/{standardId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("standardId") Long standardId)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(standardService.selectStandardByStandardId(standardId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品分类
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:add')")
|
||||||
|
@Log(title = "产品分类", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("添加分类")
|
||||||
|
public AjaxResult add(@RequestBody Standard standard)
|
||||||
|
{
|
||||||
|
return toAjax(standardService.insertStandard(standard));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping("/clone")
|
||||||
|
@ApiOperation("克隆分类")
|
||||||
|
public AjaxResult clone(@RequestBody Standard standard)
|
||||||
|
{
|
||||||
|
return toAjax(standardService.cloneStandard(standard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品分类
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:edit')")
|
||||||
|
@Log(title = "产品分类", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("修改分类")
|
||||||
|
public AjaxResult edit(@RequestBody Standard standard)
|
||||||
|
{
|
||||||
|
return toAjax(standardService.updateStandard(standard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品分类
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:remove')")
|
||||||
|
@Log(title = "产品分类", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{standardIds}")
|
||||||
|
@ApiOperation("批量删除分类")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] standardIds)
|
||||||
|
{
|
||||||
|
return standardService.deleteStandardByStandardIds(standardIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,11 +10,13 @@ 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.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;
|
||||||
import com.xinda.iot.model.modbus.ModbusAndThingsVO;
|
import com.xinda.iot.model.modbus.ModbusAndThingsVO;
|
||||||
import com.xinda.iot.model.varTemp.SyncModel;
|
import com.xinda.iot.model.varTemp.SyncModel;
|
||||||
import com.xinda.iot.service.IThingsModelService;
|
import com.xinda.iot.service.IThingsModelService;
|
||||||
|
import com.xinda.iot.service.IThingsModelStandardService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -40,6 +42,7 @@ public class ThingsModelController extends BaseController
|
|||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
private IThingsModelService thingsModelService;
|
private IThingsModelService thingsModelService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ITSLCache itslCache;
|
private ITSLCache itslCache;
|
||||||
|
|
||||||
@@ -111,6 +114,18 @@ public class ThingsModelController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/importStandard")
|
||||||
|
@ApiOperation("导入标准模型")
|
||||||
|
public AjaxResult ImportByTemplateIds(@RequestBody ImportStandardModelInput input){
|
||||||
|
|
||||||
|
int repeatCount=thingsModelService.importByStandardId(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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改物模型
|
* 修改物模型
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -0,0 +1,140 @@
|
|||||||
|
package com.xinda.data.controller;
|
||||||
|
|
||||||
|
import com.xinda.common.annotation.Log;
|
||||||
|
import com.xinda.common.core.controller.BaseController;
|
||||||
|
import com.xinda.common.core.domain.AjaxResult;
|
||||||
|
import com.xinda.common.core.page.TableDataInfo;
|
||||||
|
import com.xinda.common.enums.BusinessType;
|
||||||
|
import com.xinda.common.utils.poi.ExcelUtil;
|
||||||
|
import com.xinda.iot.domain.ThingsModelJsonTemplate;
|
||||||
|
import com.xinda.iot.domain.ThingsModelStandard;
|
||||||
|
import com.xinda.iot.service.IThingsModelStandardService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用物模型Controller
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/modelStandard")
|
||||||
|
@Api(tags = "通用物模型")
|
||||||
|
public class ThingsModelStandardController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private IThingsModelStandardService thingsModelStandardService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询通用物模型列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
@ApiOperation("通用物模型分页列表")
|
||||||
|
public TableDataInfo list(ThingsModelStandard thingsModelStandard) {
|
||||||
|
startPage();
|
||||||
|
return getDataTable(thingsModelStandardService.selectThingsModelStandardList(thingsModelStandard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出通用物模型列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:export')")
|
||||||
|
@Log(title = "通用物模型", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
@ApiOperation("导出通用物模型")
|
||||||
|
public void export(HttpServletResponse response, ThingsModelStandard thingsModelStandard) {
|
||||||
|
List<ThingsModelStandard> list = thingsModelStandardService.selectThingsModelStandardList(thingsModelStandard);
|
||||||
|
ExcelUtil<ThingsModelStandard> util = new ExcelUtil<ThingsModelStandard>(ThingsModelStandard.class);
|
||||||
|
util.exportExcel(response, list, "通用物模型数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取通用物模型详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:query')")
|
||||||
|
@GetMapping(value = "/{templateId}")
|
||||||
|
@ApiOperation("获取通用物模型详情")
|
||||||
|
public AjaxResult getInfo(@PathVariable("templateId") Long templateId) {
|
||||||
|
return AjaxResult.success(thingsModelStandardService.selectThingsModelStandardByTemplateId(templateId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通用物模型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:add')")
|
||||||
|
@Log(title = "通用物模型", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("添加通用物模型")
|
||||||
|
public AjaxResult add(@RequestBody ThingsModelStandard thingsModelStandard) {
|
||||||
|
return toAjax(thingsModelStandardService.insertThingsModelStandard(thingsModelStandard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改通用物模型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:edit')")
|
||||||
|
@Log(title = "通用物模型", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("修改通用物模型")
|
||||||
|
public AjaxResult edit(@RequestBody ThingsModelStandard thingsModelStandard) {
|
||||||
|
return toAjax(thingsModelStandardService.updateThingsModelStandard(thingsModelStandard));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除通用物模型
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:remove')")
|
||||||
|
@Log(title = "通用物模型", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{templateIds}")
|
||||||
|
@ApiOperation("批量删除通用物模型")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] templateIds) {
|
||||||
|
return toAjax(thingsModelStandardService.deleteThingsModelStandardByTemplateIds(templateIds));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "物模型导入模板")
|
||||||
|
@PostMapping("/temp")
|
||||||
|
public void temp(HttpServletResponse response) {
|
||||||
|
ExcelUtil<ThingsModelStandard> excelUtil = new ExcelUtil<>(ThingsModelStandard.class);
|
||||||
|
excelUtil.importTemplateExcel(response, "采集点");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "物模型导入模板")
|
||||||
|
@RequestMapping(value = "/temp-json",method = RequestMethod.POST)
|
||||||
|
public void tempJson(HttpServletResponse response) {
|
||||||
|
ExcelUtil<ThingsModelJsonTemplate> excelUtil = new ExcelUtil<>(ThingsModelJsonTemplate.class);
|
||||||
|
excelUtil.importTemplateExcel(response, "JSON采集点模板");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入采集点
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:add')")
|
||||||
|
@ApiOperation(value = "采集点导入")
|
||||||
|
@PostMapping(value = "/importData")
|
||||||
|
public AjaxResult importData(MultipartFile file, String tempSlaveId) throws Exception {
|
||||||
|
ExcelUtil<ThingsModelStandard> excelUtil = new ExcelUtil<>(ThingsModelStandard.class);
|
||||||
|
List<ThingsModelStandard> list = excelUtil.importExcel(file.getInputStream());
|
||||||
|
String result = thingsModelStandardService.importData(list, tempSlaveId);
|
||||||
|
return AjaxResult.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("导出采集点")
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:standard:query')")
|
||||||
|
@PostMapping("/exportJson")
|
||||||
|
public void exportJson(HttpServletResponse response, ThingsModelStandard template)
|
||||||
|
{
|
||||||
|
List<ThingsModelStandard> thingsModelStandards = thingsModelStandardService.selectThingsModelStandardExport(template);
|
||||||
|
ExcelUtil<ThingsModelStandard> util = new ExcelUtil<ThingsModelStandard>(ThingsModelStandard.class);
|
||||||
|
util.exportExcel(response, thingsModelStandards, "采集点");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ import com.xinda.common.core.thingsModel.ThingsModelSimpleItem;
|
|||||||
import com.xinda.common.exception.ServiceException;
|
import com.xinda.common.exception.ServiceException;
|
||||||
import com.xinda.common.utils.DateUtils;
|
import com.xinda.common.utils.DateUtils;
|
||||||
import com.xinda.common.utils.gateway.mq.TopicsUtils;
|
import com.xinda.common.utils.gateway.mq.TopicsUtils;
|
||||||
|
import com.xinda.iot.domain.Device;
|
||||||
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;
|
||||||
import com.xinda.iot.service.IDeviceService;
|
import com.xinda.iot.service.IDeviceService;
|
||||||
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Component;
|
|||||||
import javax.annotation.Resource;
|
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.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,8 +35,8 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@SysProtocol(name = "工控帮-华泰数智网关",protocolCode = XinDaConstant.PROTOCOL.GONGKONGBANG_HTSZ,description = "工控帮-华泰数智网关")
|
@SysProtocol(name = "IECF6113-JSON协议",protocolCode = XinDaConstant.PROTOCOL.IECF6113,description = "IECF6113-JSON协议")
|
||||||
public class GKBHTSZProtocolService implements IProtocol {
|
public class IECF6113ProtocolService implements IProtocol {
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
@@ -119,6 +121,10 @@ public class GKBHTSZProtocolService implements IProtocol {
|
|||||||
}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")){
|
||||||
|
// 初始化纬度变量,使用BigDecimal来存储高精度值
|
||||||
|
BigDecimal latitude = new BigDecimal("39.9042");
|
||||||
|
// 初始化经度变量,同样使用BigDecimal
|
||||||
|
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();
|
// JSONArray value = (JSONArray) entry.getValue();
|
||||||
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
|
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
|
||||||
@@ -126,6 +132,20 @@ public class GKBHTSZProtocolService implements IProtocol {
|
|||||||
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 (entry.getKey().equals("lng")) {
|
||||||
|
longitude = new BigDecimal(entry.getValue() + "");
|
||||||
|
}
|
||||||
|
if (entry.getKey().equals("lat")) {
|
||||||
|
latitude = new BigDecimal(entry.getValue() + "");
|
||||||
|
//更新设备经纬度信息
|
||||||
|
Device device = new Device();
|
||||||
|
device.setSerialNumber(deviceData.getSerialNumber());
|
||||||
|
device.setLatitude(latitude);
|
||||||
|
device.setLongitude(longitude);
|
||||||
|
deviceService.updateDeviceStatus(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +201,7 @@ public class GKBHTSZProtocolService implements IProtocol {
|
|||||||
Map<String, Object> result = getKeysAndValuesWithPrefix(params, "Q0.");
|
Map<String, Object> result = getKeysAndValuesWithPrefix(params, "Q0.");
|
||||||
// 输出结果
|
// 输出结果
|
||||||
if (!result.isEmpty()) {
|
if (!result.isEmpty()) {
|
||||||
StringBuilder msg = new StringBuilder("GKB29810,0UT,{\"");
|
StringBuilder msg = new StringBuilder("GKB29810,OUT,{\"");
|
||||||
result.forEach((k, v) -> {
|
result.forEach((k, v) -> {
|
||||||
msg.append(k).append("\":").append(v).append(",");
|
msg.append(k).append("\":").append(v).append(",");
|
||||||
});
|
});
|
||||||
@@ -105,6 +105,15 @@ public class AuthService {
|
|||||||
log.warn("=>设备端认证失败");
|
log.warn("=>设备端认证失败");
|
||||||
throw new ServiceException("设备端认证失败:" + response.getBody());
|
throw new ServiceException("设备端认证失败:" + response.getBody());
|
||||||
}
|
}
|
||||||
|
}else if (clientId.startsWith("8")) {
|
||||||
|
// 设备端认证
|
||||||
|
ResponseEntity response = toolService.clientAuthNoClient(clientId, username, password);
|
||||||
|
if (response.getStatusCodeValue() == HttpStatus.OK.value()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
log.warn("=>设备端认证失败");
|
||||||
|
throw new ServiceException("设备端认证失败:" + response.getBody());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Product product = productService.selectProductByProductId(147L);
|
Product product = productService.selectProductByProductId(147L);
|
||||||
if (!username.equals(product.getMqttAccount()) && !password.equals(product.getMqttPassword())) {
|
if (!username.equals(product.getMqttAccount()) && !password.equals(product.getMqttPassword())) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.xinda.common.core.mq.DeviceStatusBo;
|
|||||||
import com.xinda.common.core.redis.RedisCache;
|
import com.xinda.common.core.redis.RedisCache;
|
||||||
import com.xinda.common.enums.DeviceStatus;
|
import com.xinda.common.enums.DeviceStatus;
|
||||||
import com.xinda.common.enums.ServerType;
|
import com.xinda.common.enums.ServerType;
|
||||||
|
import com.xinda.common.enums.TopicType;
|
||||||
import com.xinda.common.utils.DateUtils;
|
import com.xinda.common.utils.DateUtils;
|
||||||
import com.xinda.common.utils.StringUtils;
|
import com.xinda.common.utils.StringUtils;
|
||||||
import com.xinda.common.utils.gateway.mq.TopicsUtils;
|
import com.xinda.common.utils.gateway.mq.TopicsUtils;
|
||||||
@@ -59,9 +60,9 @@ public class MqttPublish implements MqttHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handler(ChannelHandlerContext ctx, MqttMessage message) {
|
public void handler(ChannelHandlerContext ctx, MqttMessage message) {
|
||||||
|
|
||||||
JSONObject jsonObject = JSON.parseObject((String) message.payload());
|
// JSONObject jsonObject = JSON.parseObject((String) message.payload());
|
||||||
|
//
|
||||||
System.out.println(jsonObject);
|
// System.out.println(jsonObject);
|
||||||
|
|
||||||
// 查看消息
|
// 查看消息
|
||||||
MqttPublishMessage publishMessage = (MqttPublishMessage) message;
|
MqttPublishMessage publishMessage = (MqttPublishMessage) message;
|
||||||
@@ -114,9 +115,18 @@ public class MqttPublish implements MqttHandler {
|
|||||||
/*获取topic*/
|
/*获取topic*/
|
||||||
String topicName = message.variableHeader().topicName();
|
String topicName = message.variableHeader().topicName();
|
||||||
byte[] source = ByteBufUtil.getBytes(message.content());
|
byte[] source = ByteBufUtil.getBytes(message.content());
|
||||||
DeviceReportBo reportBo = DeviceReportBo.builder()
|
DeviceReportBo reportBo;
|
||||||
|
if (topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())) {
|
||||||
|
reportBo = DeviceReportBo.builder()
|
||||||
|
.serialNumber(topicsUtils.parseNewSerialNumber(topicName)).topicName(topicName).packetId((long) message.variableHeader().packetId())
|
||||||
|
.platformDate(DateUtils.getNowDate()).data(source).serverType(ServerType.MQTT).build();
|
||||||
|
}else{
|
||||||
|
reportBo = DeviceReportBo.builder()
|
||||||
.serialNumber(topicsUtils.parseSerialNumber(topicName)).topicName(topicName).packetId((long) message.variableHeader().packetId())
|
.serialNumber(topicsUtils.parseSerialNumber(topicName)).topicName(topicName).packetId((long) message.variableHeader().packetId())
|
||||||
.platformDate(DateUtils.getNowDate()).data(source).serverType(ServerType.MQTT).build();
|
.platformDate(DateUtils.getNowDate()).data(source).serverType(ServerType.MQTT).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (topicName.endsWith(XinDaConstant.TOPIC.MSG_REPLY) ||
|
if (topicName.endsWith(XinDaConstant.TOPIC.MSG_REPLY) ||
|
||||||
topicName.endsWith(XinDaConstant.TOPIC.UPGRADE_REPLY)) {
|
topicName.endsWith(XinDaConstant.TOPIC.UPGRADE_REPLY)) {
|
||||||
/*设备应答服务器回调数据*/
|
/*设备应答服务器回调数据*/
|
||||||
@@ -126,14 +136,20 @@ public class MqttPublish implements MqttHandler {
|
|||||||
reportBo.setReportType(1);
|
reportBo.setReportType(1);
|
||||||
}
|
}
|
||||||
// 规则引擎脚本处理,完成后返回结果
|
// 规则引擎脚本处理,完成后返回结果
|
||||||
MsgContext context = ruleProcess.processRuleScript(topicsUtils.parseSerialNumber(topicName), 1, topicName, new String(source));
|
MsgContext context;
|
||||||
|
if (topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())) {
|
||||||
|
context = ruleProcess.processNoRuleScript(topicsUtils.parseNewSerialNumber(topicName), 1, topicName, new String(source));
|
||||||
|
}else{
|
||||||
|
context = ruleProcess.processRuleScript(topicsUtils.parseSerialNumber(topicName), 1, topicName, new String(source));
|
||||||
|
}
|
||||||
|
|
||||||
if (!Objects.isNull(context) && StringUtils.isNotEmpty(context.getPayload())
|
if (!Objects.isNull(context) && StringUtils.isNotEmpty(context.getPayload())
|
||||||
&& StringUtils.isNotEmpty(context.getTopic())) {
|
&& StringUtils.isNotEmpty(context.getTopic())) {
|
||||||
reportBo.setTopicName(context.getTopic());
|
reportBo.setTopicName(context.getTopic());
|
||||||
reportBo.setData(context.getPayload().getBytes(StandardCharsets.UTF_8));
|
reportBo.setData(context.getPayload().getBytes(StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportBo.getTopicName().contains("property")) {
|
if (reportBo.getTopicName().contains("property")||reportBo.getTopicName().contains("/json/dev/")) {
|
||||||
MessageProducer.sendPublishMsg(reportBo);
|
MessageProducer.sendPublishMsg(reportBo);
|
||||||
} else if (reportBo.getTopicName().contains("status")) {
|
} else if (reportBo.getTopicName().contains("status")) {
|
||||||
String jsonString = new String(reportBo.getData(), StandardCharsets.UTF_8);
|
String jsonString = new String(reportBo.getData(), StandardCharsets.UTF_8);
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ public class MqttRemoteManager {
|
|||||||
public void pushDeviceStatus(Long productId, String serialNumber, DeviceStatus status){
|
public void pushDeviceStatus(Long productId, String serialNumber, DeviceStatus status){
|
||||||
//兼容emqx推送TCP客户端上线
|
//兼容emqx推送TCP客户端上线
|
||||||
Device device = deviceService.selectDeviceNoModel(serialNumber);
|
Device device = deviceService.selectDeviceNoModel(serialNumber);
|
||||||
|
if (device == null) {//设备不存在,添加设备
|
||||||
|
return;
|
||||||
|
}
|
||||||
String message = "{\"status\":" + status.getType() + ",\"isShadow\":" + device.getIsShadow() + ",\"rssi\":" + device.getRssi() + "}";
|
String message = "{\"status\":" + status.getType() + ",\"isShadow\":" + device.getIsShadow() + ",\"rssi\":" + device.getRssi() + "}";
|
||||||
String topic = topicsUtils.buildTopic(device.getProductId(), serialNumber, TopicType.STATUS_POST);
|
String topic = topicsUtils.buildTopic(device.getProductId(), serialNumber, TopicType.STATUS_POST);
|
||||||
if (enabled){
|
if (enabled){
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import com.xinda.common.enums.DeviceStatus;
|
|||||||
import com.xinda.common.exception.ServiceException;
|
import com.xinda.common.exception.ServiceException;
|
||||||
import com.xinda.common.utils.StringUtils;
|
import com.xinda.common.utils.StringUtils;
|
||||||
import com.xinda.common.utils.spring.SpringUtils;
|
import com.xinda.common.utils.spring.SpringUtils;
|
||||||
|
import com.xinda.iot.domain.Device;
|
||||||
|
import com.xinda.iot.service.IDeviceService;
|
||||||
import com.xinda.mq.redischannel.consumer.DeviceStatusConsumer;
|
import com.xinda.mq.redischannel.consumer.DeviceStatusConsumer;
|
||||||
import com.xinda.mq.service.IMessagePublishService;
|
import com.xinda.mq.service.IMessagePublishService;
|
||||||
import com.xinda.base.service.ISessionStore;
|
import com.xinda.base.service.ISessionStore;
|
||||||
@@ -34,6 +36,7 @@ public class SessionManger {
|
|||||||
private static ISessionStore sessionStore = SpringUtils.getBean(ISessionStore.class);
|
private static ISessionStore sessionStore = SpringUtils.getBean(ISessionStore.class);
|
||||||
private static MqttRemoteManager remoteManager = SpringUtils.getBean(MqttRemoteManager.class);
|
private static MqttRemoteManager remoteManager = SpringUtils.getBean(MqttRemoteManager.class);
|
||||||
private static DeviceStatusConsumer statusConsumer = SpringUtils.getBean(DeviceStatusConsumer.class);
|
private static DeviceStatusConsumer statusConsumer = SpringUtils.getBean(DeviceStatusConsumer.class);
|
||||||
|
private static IDeviceService deviceService = SpringUtils.getBean(IDeviceService.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前的在线客户Map
|
* 获取当前的在线客户Map
|
||||||
@@ -116,6 +119,11 @@ public class SessionManger {
|
|||||||
sessionStore.cleanSession(clientId);
|
sessionStore.cleanSession(clientId);
|
||||||
session.setMqttMessageType(MqttMessageType.DISCONNECT);
|
session.setMqttMessageType(MqttMessageType.DISCONNECT);
|
||||||
//发送至MQ,设备下线
|
//发送至MQ,设备下线
|
||||||
|
Device device = deviceService.selectDeviceBySerialNumber(session.getClientId());
|
||||||
|
//设备不存在,不做处理
|
||||||
|
if (device == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
DeviceStatusBo statusBo = MqttMessageUtils.buildStatusMsg(session.getHandlerContext(), session.getClientId(), DeviceStatus.OFFLINE, session.getIp());
|
DeviceStatusBo statusBo = MqttMessageUtils.buildStatusMsg(session.getHandlerContext(), session.getClientId(), DeviceStatus.OFFLINE, session.getIp());
|
||||||
if (!statusBo.getSerialNumber().startsWith(XinDaConstant.SERVER.WM_PREFIX) &&
|
if (!statusBo.getSerialNumber().startsWith(XinDaConstant.SERVER.WM_PREFIX) &&
|
||||||
!statusBo.getSerialNumber().startsWith(XinDaConstant.SERVER.WS_PREFIX)) {
|
!statusBo.getSerialNumber().startsWith(XinDaConstant.SERVER.WS_PREFIX)) {
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ public class DeviceReportMessageServiceImpl implements IDeviceReportMessageServi
|
|||||||
if (message.getServerType().equals(ServerType.MQTT)) {
|
if (message.getServerType().equals(ServerType.MQTT)) {
|
||||||
//处理topic以prop结尾上报的数据 (属性)
|
//处理topic以prop结尾上报的数据 (属性)
|
||||||
if (message.getServerType().equals(ServerType.MQTT)) {
|
if (message.getServerType().equals(ServerType.MQTT)) {
|
||||||
if (!topicName.endsWith(TopicType.PROPERTY_POST.getTopicSuffix())) {
|
if (!topicName.endsWith(TopicType.PROPERTY_POST.getTopicSuffix())&&!topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,12 @@ public class DeviceReportMessageServiceImpl implements IDeviceReportMessageServi
|
|||||||
report.setDeviceName(message.getDeviceName());
|
report.setDeviceName(message.getDeviceName());
|
||||||
report.setSources(message.getSources());
|
report.setSources(message.getSources());
|
||||||
//属性上报执行规则引擎
|
//属性上报执行规则引擎
|
||||||
report.setRuleEngine(true);
|
if(topicName.startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())){
|
||||||
|
report.setRuleEngine(false);
|
||||||
|
}else{
|
||||||
|
report.setRuleEngine(true);
|
||||||
|
}
|
||||||
|
|
||||||
dataHandler.reportData(report);
|
dataHandler.reportData(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,17 +131,23 @@ public class MqttMessagePublishImpl implements IMqttMessagePublish {
|
|||||||
FunctionLog funcLog = this.handleLog(bo, thingModels.getName());
|
FunctionLog funcLog = this.handleLog(bo, thingModels.getName());
|
||||||
ServerType serverType = ServerType.explain(transport);
|
ServerType serverType = ServerType.explain(transport);
|
||||||
//组建下发服务指令
|
//组建下发服务指令
|
||||||
FunctionCallBackBo backBo = buildMessage(bo);
|
//FunctionCallBackBo backBo = buildMessage(bo);
|
||||||
|
FunctionCallBackBo backBo = buildNewMessage(bo);
|
||||||
switch (serverType) {
|
switch (serverType) {
|
||||||
case MQTT:
|
case MQTT:
|
||||||
// 规则引擎脚本处理,完成后返回结果
|
// 规则引擎脚本处理,完成后返回结果
|
||||||
MsgContext context = ruleProcess.processRuleScript(serialNumber, 2, backBo.getTopicName(), new String(backBo.getMessage()));
|
MsgContext context;
|
||||||
|
if (backBo.getTopicName().startsWith(TopicType.PROPERTY_XINDA_DEV.getTopicSuffix())) {
|
||||||
|
context = ruleProcess.processNoRuleScript(serialNumber, 2, backBo.getTopicName(), new String(backBo.getMessage()));
|
||||||
|
}else{
|
||||||
|
context = ruleProcess.processRuleScript(serialNumber, 2, backBo.getTopicName(), new String(backBo.getMessage()));
|
||||||
|
}
|
||||||
|
// MsgContext context = ruleProcess.processRuleScript(serialNumber, 2, backBo.getTopicName(), new String(backBo.getMessage()));
|
||||||
if (!Objects.isNull(context) && StringUtils.isNotEmpty(context.getPayload())
|
if (!Objects.isNull(context) && StringUtils.isNotEmpty(context.getPayload())
|
||||||
&& StringUtils.isNotEmpty(context.getTopic())) {
|
&& StringUtils.isNotEmpty(context.getTopic())) {
|
||||||
backBo.setTopicName(context.getTopic());
|
backBo.setTopicName(context.getTopic());
|
||||||
backBo.setMessage(context.getPayload().getBytes());
|
backBo.setMessage(context.getPayload().getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
publishWithLog(backBo.getTopicName(), backBo.getMessage(), funcLog);
|
publishWithLog(backBo.getTopicName(), backBo.getMessage(), funcLog);
|
||||||
log.debug("=>服务下发,topic=[{}],指令=[{}]", backBo.getTopicName(), new String(backBo.getMessage()));
|
log.debug("=>服务下发,topic=[{}],指令=[{}]", backBo.getTopicName(), new String(backBo.getMessage()));
|
||||||
break;
|
break;
|
||||||
@@ -290,6 +296,21 @@ public class MqttMessagePublishImpl implements IMqttMessagePublish {
|
|||||||
return callBackBo;
|
return callBackBo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FunctionCallBackBo buildNewMessage(MQSendMessageBo bo) {
|
||||||
|
String protocolCode = bo.getDp().getProtocolCode();
|
||||||
|
String serialNumber = bo.getSerialNumber();
|
||||||
|
/*组建Topic*/
|
||||||
|
String topic = topicsUtils.buildNewTopic(serialNumber, TopicType.FUNCTION_XINDA_DOWN);
|
||||||
|
bo.setTopicName(topic);
|
||||||
|
/*获取编码协议*/
|
||||||
|
IProtocol protocolInstance = protocolManagerService.getProtocolByProtocolCode(protocolCode);
|
||||||
|
//根据协议编码后数据
|
||||||
|
FunctionCallBackBo callBackBo = protocolInstance.encode(bo);
|
||||||
|
callBackBo.setSerialNumber(serialNumber);
|
||||||
|
callBackBo.setTopicName(topic);
|
||||||
|
return callBackBo;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1.发布设备状态
|
* 1.发布设备状态
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -156,7 +156,11 @@
|
|||||||
<artifactId>forest-spring-boot-starter</artifactId>
|
<artifactId>forest-spring-boot-starter</artifactId>
|
||||||
<version>1.5.36</version>
|
<version>1.5.36</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-jexl3</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,21 @@ public class Category extends BaseEntity
|
|||||||
@Excel(name = "产品分类名称")
|
@Excel(name = "产品分类名称")
|
||||||
private String categoryName;
|
private String categoryName;
|
||||||
|
|
||||||
|
|
||||||
|
/** 产品分类名称 */
|
||||||
|
@ApiModelProperty("产品型号")
|
||||||
|
@Excel(name = "产品型号")
|
||||||
|
private String modelName;
|
||||||
|
|
||||||
|
|
||||||
|
/** 产品分类ID */
|
||||||
|
@ApiModelProperty("标准模板ID")
|
||||||
|
private Long standardId;
|
||||||
|
|
||||||
|
@ApiModelProperty("标准模板")
|
||||||
|
@Excel(name = "标准模板")
|
||||||
|
private String standardName;
|
||||||
|
|
||||||
/** 租户ID */
|
/** 租户ID */
|
||||||
@ApiModelProperty("租户ID")
|
@ApiModelProperty("租户ID")
|
||||||
@Excel(name = "租户ID")
|
@Excel(name = "租户ID")
|
||||||
@@ -107,6 +122,14 @@ public class Category extends BaseEntity
|
|||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getModelName() {
|
||||||
|
return modelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModelName(String modelName) {
|
||||||
|
this.modelName = modelName;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getTenantId()
|
public Long getTenantId()
|
||||||
{
|
{
|
||||||
return tenantId;
|
return tenantId;
|
||||||
@@ -147,6 +170,22 @@ public class Category extends BaseEntity
|
|||||||
return delFlag;
|
return delFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getStandardId() {
|
||||||
|
return standardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStandardId(Long standardId) {
|
||||||
|
this.standardId = standardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStandardName() {
|
||||||
|
return standardName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStandardName(String standardName) {
|
||||||
|
this.standardName = standardName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ public class Product extends BaseEntity {
|
|||||||
@Excel(name = "产品名称")
|
@Excel(name = "产品名称")
|
||||||
private String productName;
|
private String productName;
|
||||||
|
|
||||||
|
@Excel(name = "产品型号")
|
||||||
|
@ApiModelProperty("产品型号")
|
||||||
|
private String productModel;;
|
||||||
|
|
||||||
// 判断的未分类
|
// 判断的未分类
|
||||||
private String productNameExclude;
|
private String productNameExclude;
|
||||||
|
|
||||||
@@ -421,6 +425,14 @@ public class Product extends BaseEntity {
|
|||||||
this.productNameExclude = productNameExclude;
|
this.productNameExclude = productNameExclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProductModel() {
|
||||||
|
return productModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductModel(String productModel) {
|
||||||
|
this.productModel = productModel;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
|||||||
@@ -0,0 +1,167 @@
|
|||||||
|
package com.xinda.iot.domain;
|
||||||
|
|
||||||
|
import com.xinda.common.annotation.Excel;
|
||||||
|
import com.xinda.common.core.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类对象 iot_standard
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "Standard", description = "产品分类对象 iot_standard")
|
||||||
|
public class Standard extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 产品分类ID */
|
||||||
|
@ApiModelProperty("产品分类ID")
|
||||||
|
private Long standardId;
|
||||||
|
|
||||||
|
/** 产品分类名称 */
|
||||||
|
@ApiModelProperty("产品分类名称")
|
||||||
|
@Excel(name = "产品分类名称")
|
||||||
|
private String standardName;
|
||||||
|
|
||||||
|
/** 租户ID */
|
||||||
|
@ApiModelProperty("租户ID")
|
||||||
|
@Excel(name = "租户ID")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
/** 租户名称 */
|
||||||
|
@ApiModelProperty("租户名称")
|
||||||
|
@Excel(name = "租户名称")
|
||||||
|
private String tenantName;
|
||||||
|
|
||||||
|
/** 是否系统通用(0-否,1-是) */
|
||||||
|
@ApiModelProperty("是否系统通用(0-否,1-是)")
|
||||||
|
@Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是")
|
||||||
|
private Integer isSys;
|
||||||
|
|
||||||
|
/** 显示顺序 */
|
||||||
|
@ApiModelProperty("显示顺序")
|
||||||
|
@Excel(name = "显示顺序")
|
||||||
|
private Integer orderNum;
|
||||||
|
|
||||||
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否显示上级品类")
|
||||||
|
private Boolean showSenior;
|
||||||
|
|
||||||
|
@ApiModelProperty("是否是总账号")
|
||||||
|
private Boolean isAdmin;
|
||||||
|
|
||||||
|
@ApiModelProperty("机构ID")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
public Boolean getShowSenior() {
|
||||||
|
return showSenior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowSenior(Boolean showSenior) {
|
||||||
|
this.showSenior = showSenior;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDeptId() {
|
||||||
|
return deptId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeptId(Long deptId) {
|
||||||
|
this.deptId = deptId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getAdmin() {
|
||||||
|
return isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdmin(Boolean admin) {
|
||||||
|
isAdmin = admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStandardId(Long standardId)
|
||||||
|
{
|
||||||
|
this.standardId = standardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStandardId()
|
||||||
|
{
|
||||||
|
return standardId;
|
||||||
|
}
|
||||||
|
public void setStandardName(String standardName)
|
||||||
|
{
|
||||||
|
this.standardName = standardName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStandardName()
|
||||||
|
{
|
||||||
|
return standardName;
|
||||||
|
}
|
||||||
|
public void setTenantId(Long tenantId)
|
||||||
|
{
|
||||||
|
this.tenantId = tenantId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getTenantId()
|
||||||
|
{
|
||||||
|
return tenantId;
|
||||||
|
}
|
||||||
|
public void setTenantName(String tenantName)
|
||||||
|
{
|
||||||
|
this.tenantName = tenantName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTenantName()
|
||||||
|
{
|
||||||
|
return tenantName;
|
||||||
|
}
|
||||||
|
public void setIsSys(Integer isSys)
|
||||||
|
{
|
||||||
|
this.isSys = isSys;
|
||||||
|
}
|
||||||
|
public Integer getIsSys()
|
||||||
|
{
|
||||||
|
return isSys;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderNum(Integer orderNum)
|
||||||
|
{
|
||||||
|
this.orderNum = orderNum;
|
||||||
|
}
|
||||||
|
public Integer getOrderNum()
|
||||||
|
{
|
||||||
|
return orderNum;
|
||||||
|
}
|
||||||
|
public void setDelFlag(String delFlag)
|
||||||
|
{
|
||||||
|
this.delFlag = delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDelFlag()
|
||||||
|
{
|
||||||
|
return delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("standardId", getStandardId())
|
||||||
|
.append("standardName", getStandardName())
|
||||||
|
.append("tenantId", getTenantId())
|
||||||
|
.append("tenantName", getTenantName())
|
||||||
|
.append("isSys", getIsSys())
|
||||||
|
.append("orderNum", getOrderNum())
|
||||||
|
.append("delFlag", getDelFlag())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("remark", getRemark())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -81,6 +81,11 @@ public class ThingsModel extends BaseEntity
|
|||||||
@ApiModelProperty("数据定义")
|
@ApiModelProperty("数据定义")
|
||||||
private String specs;
|
private String specs;
|
||||||
|
|
||||||
|
/** 是否计算属性(0-否,1-是) */
|
||||||
|
@ApiModelProperty(value = "是否计算属性", notes = "(0-否,1-是)")
|
||||||
|
@Excel(name = "是否计算属性", readConverterExp = "0=否,1=是")
|
||||||
|
private Integer isCalc;
|
||||||
|
|
||||||
/** 是否图表显示(0-否,1-是) */
|
/** 是否图表显示(0-否,1-是) */
|
||||||
@ApiModelProperty(value = "是否图表显示", notes = "(0-否,1-是)")
|
@ApiModelProperty(value = "是否图表显示", notes = "(0-否,1-是)")
|
||||||
@Excel(name = "是否图表显示", readConverterExp = "0=否,1=是")
|
@Excel(name = "是否图表显示", readConverterExp = "0=否,1=是")
|
||||||
|
|||||||
@@ -0,0 +1,128 @@
|
|||||||
|
package com.xinda.iot.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.xinda.common.annotation.Excel;
|
||||||
|
import com.xinda.common.core.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用物模型对象 iot_things_model_standard
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2023-01-15
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "ThingsModelStandard", description = "通用物模型对象 iot_things_model_standard")
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
@Data
|
||||||
|
public class ThingsModelStandard extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 物模型ID */
|
||||||
|
@ApiModelProperty("物模型ID")
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
/** 物模型名称 */
|
||||||
|
@ApiModelProperty("物模型名称")
|
||||||
|
@Excel(name = "物模型名称" ,prompt = "必填")
|
||||||
|
private String templateName;
|
||||||
|
|
||||||
|
/** 租户ID */
|
||||||
|
@ApiModelProperty("标准模板ID")
|
||||||
|
private Long standardId;
|
||||||
|
|
||||||
|
/** 租户名称 */
|
||||||
|
@ApiModelProperty("标准模板")
|
||||||
|
private String standardName;
|
||||||
|
|
||||||
|
/** 租户ID */
|
||||||
|
@ApiModelProperty("租户ID")
|
||||||
|
private Long tenantId;
|
||||||
|
|
||||||
|
/** 租户名称 */
|
||||||
|
@ApiModelProperty("租户名称")
|
||||||
|
private String tenantName;
|
||||||
|
|
||||||
|
/** 标识符,产品下唯一 */
|
||||||
|
@ApiModelProperty("标识符,产品下唯一")
|
||||||
|
@Excel(name = "标识符",prompt = "modbus不填,默认为寄存器地址")
|
||||||
|
private String identifier;
|
||||||
|
|
||||||
|
/** 模型类别(1-属性,2-功能,3-事件) */
|
||||||
|
@ApiModelProperty(value = "模型类别", notes = "(1-属性,2-功能,3-事件)")
|
||||||
|
@Excel(name = "模型类别", readConverterExp = "1=属性,2=功能,3=事件",prompt ="1=属性,2-功能,3-事件")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
/** 计算公式 */
|
||||||
|
@ApiModelProperty("计算公式")
|
||||||
|
@Excel(name = "计算公式",prompt = "选填,例如:%s*10,%s是占位符")
|
||||||
|
private String formula;
|
||||||
|
|
||||||
|
/** 数据定义 */
|
||||||
|
@ApiModelProperty("数据定义")
|
||||||
|
private String specs;
|
||||||
|
|
||||||
|
/** 是否系统通用(0-否,1-是) */
|
||||||
|
@ApiModelProperty("是否系统通用(0-否,1-是)")
|
||||||
|
private Integer isSys;
|
||||||
|
|
||||||
|
|
||||||
|
/** 是否图表显示(0-否,1-是) */
|
||||||
|
@ApiModelProperty("是否图表显示(0-否,1-是)")
|
||||||
|
//@Excel(name = "是否图表显示", readConverterExp = "0=否,1=是")
|
||||||
|
private Integer isChart;
|
||||||
|
|
||||||
|
/** 是否历史存储(0-否,1-是) */
|
||||||
|
@ApiModelProperty("是否历史存储(0-否,1-是)")
|
||||||
|
@Excel(name = "是否历史存储", readConverterExp = "0=否,1=是")
|
||||||
|
private Integer isHistory;
|
||||||
|
|
||||||
|
/** 是否实时监测(0-否,1-是) */
|
||||||
|
@ApiModelProperty("是否实时监测(0-否,1-是)")
|
||||||
|
private Integer isMonitor;
|
||||||
|
|
||||||
|
/** 是否分享设备权限(0-否,1-是) */
|
||||||
|
@ApiModelProperty(value = "是否分享设备权限", notes = "(0-否,1-是) ")
|
||||||
|
private Integer isSharePerm;
|
||||||
|
|
||||||
|
|
||||||
|
/** 是否分享设备权限(0-否,1-是) */
|
||||||
|
@ApiModelProperty(value = "是否分享设备权限", notes = "(0-否,1-是) ")
|
||||||
|
@Excel(name = "是否分享设备权限", readConverterExp = "0=否,1=是")
|
||||||
|
private Integer isApp;
|
||||||
|
|
||||||
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
|
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
@Excel(name = "单位")
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/** 数据类型(integer、decimal、string、bool、array、enum) */
|
||||||
|
@ApiModelProperty(value = "数据类型", notes = "(integer、decimal、string、bool、array、enum)")
|
||||||
|
@Excel(name = "数据类型", prompt = "integer、decimal、string、bool、array、enum")
|
||||||
|
private String datatype;
|
||||||
|
|
||||||
|
@ApiModelProperty("有效值范围")
|
||||||
|
@Excel(name = "有效值范围")
|
||||||
|
private String limitValue;
|
||||||
|
|
||||||
|
/** 是否只读数据(0-否,1-是) */
|
||||||
|
@ApiModelProperty("是否只读数据(0-否,1-是)")
|
||||||
|
@Excel(name = "是否只读", readConverterExp = "0=否,1=是",prompt = "0=否,1=是")
|
||||||
|
private Integer isReadonly;
|
||||||
|
|
||||||
|
private Integer modelOrder;
|
||||||
|
|
||||||
|
private String language;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同一租户或用户为true
|
||||||
|
*/
|
||||||
|
private Boolean owner;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
package com.xinda.iot.mapper;
|
||||||
|
|
||||||
|
import com.xinda.iot.domain.Standard;
|
||||||
|
import com.xinda.iot.model.IdAndName;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类Mapper接口
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface StandardMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询产品分类
|
||||||
|
*
|
||||||
|
* @param standardId 产品分类主键
|
||||||
|
* @return 产品分类
|
||||||
|
*/
|
||||||
|
public Standard selectStandardByStandardId(Long standardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品分类列表
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 产品分类集合
|
||||||
|
*/
|
||||||
|
public List<Standard> selectStandardList(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品简短分类列表
|
||||||
|
*
|
||||||
|
* @return 产品分类集合
|
||||||
|
*/
|
||||||
|
public List<IdAndName> selectStandardShortList(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品分类
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertStandard(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品分类
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateStandard(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品分类
|
||||||
|
*
|
||||||
|
* @param standardId 产品分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardByStandardId(Long standardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除产品分类
|
||||||
|
*
|
||||||
|
* @param standardIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardByStandardIds(Long[] standardIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类下的产品数量
|
||||||
|
*
|
||||||
|
* @param standardIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int productCountInStandards(Long[] standardIds);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
package com.xinda.iot.mapper;
|
||||||
|
|
||||||
|
import com.xinda.iot.domain.ThingsModelStandard;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用物模型Mapper接口
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@Repository
|
||||||
|
public interface ThingsModelStandardMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询通用物模型
|
||||||
|
*
|
||||||
|
* @param templateId 通用物模型主键
|
||||||
|
* @param language 语言
|
||||||
|
* @return 通用物模型
|
||||||
|
*/
|
||||||
|
public ThingsModelStandard selectThingsModelStandardByTemplateId(@Param("templateId") Long templateId, @Param("language") String language);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id数组查询通用物模型集合
|
||||||
|
* @param templateIds
|
||||||
|
* @param language 语言
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<ThingsModelStandard> selectThingsModelStandardByTemplateIds (@Param("templateIds") Long[] templateIds, @Param("language") String language);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询通用物模型列表
|
||||||
|
*
|
||||||
|
* @param thingsModelTemplate 通用物模型
|
||||||
|
* @return 通用物模型集合
|
||||||
|
*/
|
||||||
|
public List<ThingsModelStandard> selectThingsModelStandardList(ThingsModelStandard thingsModelTemplate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通用物模型
|
||||||
|
*
|
||||||
|
* @param thingsModelTemplate 通用物模型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertThingsModelStandard(ThingsModelStandard thingsModelTemplate);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改通用物模型
|
||||||
|
*
|
||||||
|
* @param thingsModelTemplate 通用物模型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateThingsModelStandard(ThingsModelStandard thingsModelTemplate);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除通用物模型
|
||||||
|
*
|
||||||
|
* @param templateId 通用物模型主键
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteThingsModelStandardByTemplateId(Long templateId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除通用物模型
|
||||||
|
*
|
||||||
|
* @param templateIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteThingsModelStandardByTemplateIds(Long[] templateIds);
|
||||||
|
|
||||||
|
|
||||||
|
List<ThingsModelStandard> selectModelListByStandardId(Long standardId);
|
||||||
|
|
||||||
|
int batchThingsModelStandards(List<ThingsModelStandard> thingsModelStandards);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.xinda.iot.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入产品物模型的输入对象
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
public class ImportStandardModelInput
|
||||||
|
{
|
||||||
|
/** 产品ID */
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
/** 产品名称 */
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
/** 通用物模型ID集合 */
|
||||||
|
private Long standardId;
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getStandardId() {
|
||||||
|
return standardId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStandardId(Long standardId) {
|
||||||
|
this.standardId = standardId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,6 +60,11 @@ public class ThingsModelValueItem {
|
|||||||
**/
|
**/
|
||||||
private Integer isHistory;
|
private Integer isHistory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为图表展示
|
||||||
|
**/
|
||||||
|
private Integer isCalc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为图表展示
|
* 是否为图表展示
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -59,6 +59,27 @@ public class RuleProcess {
|
|||||||
//返回处理完的消息上下文
|
//返回处理完的消息上下文
|
||||||
return scriptService.execRuleScript(scriptCondition, context);
|
return scriptService.execRuleScript(scriptCondition, context);
|
||||||
}
|
}
|
||||||
|
public MsgContext processNoRuleScript(String serialNumber, int event, String topic, String payload) {
|
||||||
|
ProductCode productCode = getDeviceDetail(serialNumber);
|
||||||
|
if (Objects.isNull(productCode)) {
|
||||||
|
return new MsgContext();
|
||||||
|
}
|
||||||
|
// 查询数据流脚本组件
|
||||||
|
ScriptCondition scriptCondition = ScriptCondition.builder()
|
||||||
|
.scriptPurpose(1)
|
||||||
|
.scriptEvent(event)
|
||||||
|
.productId(productCode.getProductId())
|
||||||
|
.build();
|
||||||
|
MsgContext context = MsgContext.builder()
|
||||||
|
.serialNumber(serialNumber)
|
||||||
|
.productId(productCode.getProductId())
|
||||||
|
.protocolCode(productCode.getProtocolCode())
|
||||||
|
.payload(payload)
|
||||||
|
.topic(topic)
|
||||||
|
.build();
|
||||||
|
//返回处理完的消息上下文
|
||||||
|
return context;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package com.xinda.iot.service;
|
||||||
|
|
||||||
|
import com.xinda.common.core.domain.AjaxResult;
|
||||||
|
import com.xinda.iot.domain.Standard;
|
||||||
|
import com.xinda.iot.model.IdAndName;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类Service接口
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
public interface IStandardService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询产品分类
|
||||||
|
*
|
||||||
|
* @param standardId 产品分类主键
|
||||||
|
* @return 产品分类
|
||||||
|
*/
|
||||||
|
public Standard selectStandardByStandardId(Long standardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品分类列表
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 产品分类集合
|
||||||
|
*/
|
||||||
|
public List<Standard> selectStandardList(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品简短分类列表
|
||||||
|
*
|
||||||
|
* @return 产品分类集合
|
||||||
|
*/
|
||||||
|
public List<IdAndName> selectStandardShortList(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品分类
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertStandard(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品分类
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateStandard(Standard standard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除产品分类
|
||||||
|
*
|
||||||
|
* @param standardIds 需要删除的产品分类主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public AjaxResult deleteStandardByStandardIds(Long[] standardIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品分类信息
|
||||||
|
*
|
||||||
|
* @param standardId 产品分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteStandardByStandardId(Long standardId);
|
||||||
|
|
||||||
|
public int cloneStandard(Standard standard);
|
||||||
|
}
|
||||||
@@ -2,6 +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.ImportThingsModelInput;
|
import com.xinda.iot.model.ImportThingsModelInput;
|
||||||
import com.xinda.iot.model.ThingsModelPerm;
|
import com.xinda.iot.model.ThingsModelPerm;
|
||||||
import com.xinda.iot.model.ThingsModelSimVO;
|
import com.xinda.iot.model.ThingsModelSimVO;
|
||||||
@@ -188,8 +189,9 @@ public interface IThingsModelService
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据设备编号获取读写物模型
|
* 根据设备编号获取读写物模型
|
||||||
* @param serialNumber
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ThingsModel> selectThingsModelBySerialNumber(Long deviceId);
|
List<ThingsModel> selectThingsModelBySerialNumber(Long deviceId);
|
||||||
|
|
||||||
|
public int importByStandardId(ImportStandardModelInput input);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package com.xinda.iot.service;
|
||||||
|
|
||||||
|
import com.xinda.iot.domain.ThingsModelStandard;
|
||||||
|
import com.xinda.iot.model.ImportStandardModelInput;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用物模型Service接口
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
public interface IThingsModelStandardService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询通用物模型
|
||||||
|
*
|
||||||
|
* @param templateId 通用物模型主键
|
||||||
|
* @return 通用物模型
|
||||||
|
*/
|
||||||
|
public ThingsModelStandard selectThingsModelStandardByTemplateId(Long templateId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询通用物模型列表
|
||||||
|
*
|
||||||
|
* @param thingsModelStandard 通用物模型
|
||||||
|
* @return 通用物模型集合
|
||||||
|
*/
|
||||||
|
public List<ThingsModelStandard> selectThingsModelStandardList(ThingsModelStandard thingsModelStandard);
|
||||||
|
|
||||||
|
public List<ThingsModelStandard> selectModelListByStandardId(Long standardId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通用物模型
|
||||||
|
*
|
||||||
|
* @param thingsModelStandard 通用物模型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertThingsModelStandard(ThingsModelStandard thingsModelStandard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改通用物模型
|
||||||
|
*
|
||||||
|
* @param thingsModelStandard 通用物模型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateThingsModelStandard(ThingsModelStandard thingsModelStandard);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除通用物模型
|
||||||
|
*
|
||||||
|
* @param templateIds 需要删除的通用物模型主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteThingsModelStandardByTemplateIds(Long[] templateIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除通用物模型信息
|
||||||
|
*
|
||||||
|
* @param templateId 通用物模型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteThingsModelStandardByTemplateId(Long templateId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入采集点数据
|
||||||
|
* @param lists 数据列表
|
||||||
|
* @param tempSlaveId 从机编码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public String importData(List<ThingsModelStandard> lists,String tempSlaveId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出采集点数据
|
||||||
|
*
|
||||||
|
* @param thingsModelStandard 通用物模型
|
||||||
|
* @return 通用物模型集合
|
||||||
|
*/
|
||||||
|
public List<ThingsModelStandard> selectThingsModelStandardExport(ThingsModelStandard thingsModelStandard);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -49,6 +49,8 @@ public interface IToolService
|
|||||||
*/
|
*/
|
||||||
public ResponseEntity simpleMqttAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel);
|
public ResponseEntity simpleMqttAuthentication(MqttAuthenticationModel mqttModel, ProductAuthenticateModel productModel);
|
||||||
|
|
||||||
|
ResponseEntity miniMqttAuthentication(MqttAuthenticationModel mqttModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备加密认证
|
* 设备加密认证
|
||||||
*
|
*
|
||||||
@@ -67,4 +69,6 @@ public interface IToolService
|
|||||||
* 返回认证信息
|
* 返回认证信息
|
||||||
*/
|
*/
|
||||||
public ResponseEntity returnUnauthorized(MqttAuthenticationModel mqttModel, String message);
|
public ResponseEntity returnUnauthorized(MqttAuthenticationModel mqttModel, String message);
|
||||||
|
|
||||||
|
public ResponseEntity clientAuthNoClient(String clientId, String username, String password);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
|
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
|
||||||
import static com.xinda.common.utils.SecurityUtils.isAdmin;
|
import static com.xinda.common.utils.SecurityUtils.isAdmin;
|
||||||
|
import com.xinda.iot.util.FormulaCalculator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备Service业务层处理
|
* 设备Service业务层处理
|
||||||
@@ -242,6 +243,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
public List<ThingsModelSimpleItem> reportDeviceThingsModelValue(ThingsModelValuesInput input, int type, boolean isShadow) {
|
public List<ThingsModelSimpleItem> reportDeviceThingsModelValue(ThingsModelValuesInput input, int type, boolean isShadow) {
|
||||||
String key = RedisKeyBuilder.buildTSLVCacheKey(input.getProductId(), input.getDeviceNumber());
|
String key = RedisKeyBuilder.buildTSLVCacheKey(input.getProductId(), input.getDeviceNumber());
|
||||||
Map<String, String> maps = new HashMap<String, String>();
|
Map<String, String> maps = new HashMap<String, String>();
|
||||||
|
Map<String, String> variables = new HashMap<String, String>();
|
||||||
List<ThingsModelSimpleItem> list = new ArrayList<>();
|
List<ThingsModelSimpleItem> list = new ArrayList<>();
|
||||||
|
|
||||||
//属性存储集合
|
//属性存储集合
|
||||||
@@ -267,11 +269,19 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
|
|
||||||
/* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -开始 ★★★★★★★★★★★★★★★★★★★★★★*/
|
/* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -开始 ★★★★★★★★★★★★★★★★★★★★★★*/
|
||||||
//有计算公式的,经过计算公式
|
//有计算公式的,经过计算公式
|
||||||
|
// if (thingModels.getFormula() != null && !"".equals(thingModels.getFormula())) {
|
||||||
|
// Map<String, String> params = new HashMap<>();
|
||||||
|
// params.put("%s", value);
|
||||||
|
// value = String.valueOf(CaculateUtils.execute(thingModels.getFormula(), params));
|
||||||
|
// 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("%s", value);
|
params.put(thingModels.getId(), value);
|
||||||
value = String.valueOf(CaculateUtils.execute(thingModels.getFormula(), params));
|
if(FormulaCalculator.containsAllVariables(thingModels.getFormula(), params)) {
|
||||||
item.setValue(value);
|
value = FormulaCalculator.evaluate(thingModels.getFormula(), params);
|
||||||
|
item.setValue(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -结束 ★★★★★★★★★★★★★★★★★★★★★★*/
|
/* ★★★★★★★★★★★★★★★★★★★★★★ 数据计算 -结束 ★★★★★★★★★★★★★★★★★★★★★★*/
|
||||||
|
|
||||||
@@ -312,6 +322,7 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
valueItem.setTs(DateUtils.getNowDate());
|
valueItem.setTs(DateUtils.getNowDate());
|
||||||
}
|
}
|
||||||
maps.put(identity, JSONObject.toJSONString(valueItem));
|
maps.put(identity, JSONObject.toJSONString(valueItem));
|
||||||
|
variables.put(identity,value);
|
||||||
}
|
}
|
||||||
/* ★★★★★★★★★★★★★★★★★★★★★★ 处理数据 - 结束 ★★★★★★★★★★★★★★★★★★★★★★*/
|
/* ★★★★★★★★★★★★★★★★★★★★★★ 处理数据 - 结束 ★★★★★★★★★★★★★★★★★★★★★★*/
|
||||||
|
|
||||||
@@ -374,6 +385,58 @@ public class DeviceServiceImpl implements IDeviceService {
|
|||||||
}
|
}
|
||||||
list.add(item);
|
list.add(item);
|
||||||
}
|
}
|
||||||
|
/*★★★★★★★★★★★★★★★★★★★★★★ 处理计算属性 - 开始 ★★★★★★★★★★★★★★★★★★★★★★*/
|
||||||
|
|
||||||
|
//1、根据产品ID获取计算属性列表
|
||||||
|
List<ThingsModelValueItem> thingsModelList = itslCache.getThingsModelList(input.getProductId());
|
||||||
|
for (ThingsModelValueItem mItem : thingsModelList) {
|
||||||
|
if (mItem.getIsCalc() == 1) {
|
||||||
|
if (mItem.getFormula() != null && !"".equals(mItem.getFormula())) {
|
||||||
|
//2、获取计算属性列表的变量 检查每个变量都存在maps里 如果不存在则不计算,如果存在则计算
|
||||||
|
if(FormulaCalculator.containsAllVariables(mItem.getFormula(), variables)){
|
||||||
|
//3、先执行 上面的★★ 处理数据 - 开始 ★★
|
||||||
|
String calcValue = FormulaCalculator.evaluate(mItem.getFormula(), variables);
|
||||||
|
ThingsModelSimpleItem simpleItem = new ThingsModelSimpleItem();
|
||||||
|
simpleItem.setId(mItem.getId());
|
||||||
|
simpleItem.setName(mItem.getName());
|
||||||
|
simpleItem.setValue(calcValue);
|
||||||
|
simpleItem.setTs(DateUtils.getNowDate());
|
||||||
|
list.add(simpleItem);
|
||||||
|
|
||||||
|
ValueItem valueItem = new ValueItem();
|
||||||
|
valueItem.setId(mItem.getId());
|
||||||
|
valueItem.setValue(calcValue);
|
||||||
|
valueItem.setShadow(calcValue);
|
||||||
|
valueItem.setTs(DateUtils.getNowDate());
|
||||||
|
maps.put(mItem.getId(), JSONObject.toJSONString(valueItem));
|
||||||
|
Device device = this.selectDeviceBySerialNumber(input.getDeviceNumber());
|
||||||
|
//4、★★★ 存储数据 - 开始 ★★(属性部分)
|
||||||
|
if (1 == mItem.getIsHistory()) {
|
||||||
|
DeviceLog deviceLog = new DeviceLog();
|
||||||
|
deviceLog.setSerialNumber(input.getDeviceNumber());
|
||||||
|
deviceLog.setLogType(type);
|
||||||
|
// 1=影子模式,2=在线模式,3=其他
|
||||||
|
deviceLog.setMode(isShadow ? 1 : 2);
|
||||||
|
// 设备日志值
|
||||||
|
deviceLog.setLogValue(calcValue);
|
||||||
|
//deviceLog.setRemark(mItem.getRemark());
|
||||||
|
deviceLog.setIdentity(mItem.getId());
|
||||||
|
deviceLog.setCreateTime(DateUtils.getNowDate());
|
||||||
|
deviceLog.setUserId(device.getTenantId());
|
||||||
|
deviceLog.setUserName(device.getTenantName());
|
||||||
|
deviceLog.setTenantId(device.getTenantId());
|
||||||
|
deviceLog.setTenantName(device.getTenantName());
|
||||||
|
deviceLog.setModelName(mItem.getName());
|
||||||
|
deviceLog.setIsMonitor(mItem.getIsMonitor());
|
||||||
|
deviceLogList.add(deviceLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*★★★★★★★★★★★★★★★★★★★★★★ 处理计算属性 - 结束 ★★★★★★★★★★★★★★★★★★★★★★*/
|
||||||
// 缓存最新一条数据到redis
|
// 缓存最新一条数据到redis
|
||||||
redisCache.hashPutAll(key, maps);
|
redisCache.hashPutAll(key, maps);
|
||||||
//存储历史数据
|
//存储历史数据
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ public class ProductServiceImpl implements IProductService
|
|||||||
* @param productId 产品主键
|
* @param productId 产品主键
|
||||||
* @return 产品
|
* @return 产品
|
||||||
*/
|
*/
|
||||||
@Cacheable(value = "product", key = "#root.methodName + '_' + #productId", unless = "#result == null")
|
// @Cacheable(value = "product", key = "#root.methodName + '_' + #productId", unless = "#result == null")
|
||||||
@Override
|
@Override
|
||||||
public Product selectProductByProductId(Long productId)
|
public Product selectProductByProductId(Long productId)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,178 @@
|
|||||||
|
package com.xinda.iot.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.xinda.common.core.domain.AjaxResult;
|
||||||
|
import com.xinda.common.core.domain.entity.SysUser;
|
||||||
|
import com.xinda.common.utils.DateUtils;
|
||||||
|
import com.xinda.iot.domain.Standard;
|
||||||
|
import com.xinda.iot.domain.ThingsModelStandard;
|
||||||
|
import com.xinda.iot.mapper.StandardMapper;
|
||||||
|
import com.xinda.iot.mapper.ThingsModelStandardMapper;
|
||||||
|
import com.xinda.iot.model.IdAndName;
|
||||||
|
import com.xinda.iot.service.IStandardService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
|
||||||
|
import static com.xinda.common.utils.SecurityUtils.isAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品分类Service业务层处理
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class StandardServiceImpl implements IStandardService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private StandardMapper standardMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThingsModelStandardMapper thingsModelStandardMapper;
|
||||||
|
/**
|
||||||
|
* 查询产品分类
|
||||||
|
*
|
||||||
|
* @param standardId 产品分类主键
|
||||||
|
* @return 产品分类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Standard selectStandardByStandardId(Long standardId)
|
||||||
|
{
|
||||||
|
return standardMapper.selectStandardByStandardId(standardId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品分类列表
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 产品分类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Standard> selectStandardList(Standard standard)
|
||||||
|
{
|
||||||
|
return standardMapper.selectStandardList(standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品分简短类列表
|
||||||
|
*
|
||||||
|
* @return 产品分类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<IdAndName> selectStandardShortList(Standard standard)
|
||||||
|
{
|
||||||
|
return standardMapper.selectStandardShortList(standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品分类
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertStandard(Standard standard)
|
||||||
|
{
|
||||||
|
// 判断是否为管理员
|
||||||
|
standard.setIsSys(1);
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
// List<SysRole> roles=user.getRoles();
|
||||||
|
// for(int i=0;i<roles.size();i++){
|
||||||
|
// if(roles.get(i).getRoleKey().equals("tenant") || roles.get(i).getRoleKey().equals("general")){
|
||||||
|
// standard.setIsSys(0);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
standard.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return standardMapper.insertStandard(standard);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int cloneStandard(Standard standard)
|
||||||
|
{
|
||||||
|
// 判断是否为管理员
|
||||||
|
standard.setIsSys(1);
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
Standard cloneStandard = new Standard();
|
||||||
|
BeanUtil.copyProperties(standard, cloneStandard, "standardId","standardName","orderNum");
|
||||||
|
cloneStandard.setStandardName(standard.getStandardName()+"_副本");
|
||||||
|
if (null != standard.getOrderNum()) {
|
||||||
|
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());
|
||||||
|
standardMapper.insertStandard(cloneStandard);
|
||||||
|
List<ThingsModelStandard> thingsModelStandards = thingsModelStandardMapper.selectModelListByStandardId(standard.getStandardId());
|
||||||
|
thingsModelStandardMapper.selectModelListByStandardId(standard.getStandardId()).forEach(model -> {
|
||||||
|
model.setStandardId(cloneStandard.getStandardId());
|
||||||
|
thingsModelStandards.add(model);
|
||||||
|
});
|
||||||
|
return thingsModelStandardMapper.batchThingsModelStandards(thingsModelStandards);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品分类
|
||||||
|
*
|
||||||
|
* @param standard 产品分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateStandard(Standard standard)
|
||||||
|
{
|
||||||
|
standard.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return standardMapper.updateStandard(standard);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除产品分类
|
||||||
|
*
|
||||||
|
* @param standardIds 需要删除的产品分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult deleteStandardByStandardIds(Long[] standardIds)
|
||||||
|
{
|
||||||
|
int productCount=standardMapper.productCountInStandards(standardIds);
|
||||||
|
if(productCount>0){
|
||||||
|
return AjaxResult.error("删除失败,请先删除对应分类下的产品");
|
||||||
|
}
|
||||||
|
if(standardMapper.deleteStandardByStandardIds(standardIds)>0){
|
||||||
|
return AjaxResult.success("删除成功");
|
||||||
|
}
|
||||||
|
return AjaxResult.error("删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品分类信息
|
||||||
|
*
|
||||||
|
* @param standardId 产品分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteStandardByStandardId(Long standardId)
|
||||||
|
{
|
||||||
|
return standardMapper.deleteStandardByStandardId(standardId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ 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.ImportThingsModelInput;
|
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.ThingsModelPerm;
|
||||||
@@ -54,6 +55,9 @@ public class ThingsModelServiceImpl implements IThingsModelService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ThingsModelTemplateMapper thingsModelTemplateMapper;
|
private ThingsModelTemplateMapper thingsModelTemplateMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThingsModelStandardMapper thingsModelStandardMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ProductMapper productMapper;
|
private ProductMapper productMapper;
|
||||||
|
|
||||||
@@ -240,6 +244,63 @@ public class ThingsModelServiceImpl implements IThingsModelService {
|
|||||||
return repeatCount;
|
return repeatCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int importByStandardId(ImportStandardModelInput input) {
|
||||||
|
ThingsModel inputParameter = new ThingsModel();
|
||||||
|
inputParameter.setLanguage(SecurityUtils.getLanguage());
|
||||||
|
inputParameter.setProductId(input.getProductId());
|
||||||
|
List<ThingsModel> dbList = thingsModelMapper.selectThingsModelList(inputParameter);
|
||||||
|
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
// 根据ID集合获取通用物模型列表
|
||||||
|
List<ThingsModelStandard> templateList = thingsModelStandardMapper.selectModelListByStandardId(input.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) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改物模型
|
* 修改物模型
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,290 @@
|
|||||||
|
package com.xinda.iot.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.xinda.common.core.domain.entity.SysUser;
|
||||||
|
import com.xinda.common.exception.ServiceException;
|
||||||
|
import com.xinda.common.utils.DateUtils;
|
||||||
|
import com.xinda.common.utils.SecurityUtils;
|
||||||
|
import com.xinda.iot.domain.*;
|
||||||
|
import com.xinda.iot.mapper.ThingsModelStandardMapper;
|
||||||
|
import com.xinda.iot.model.ImportStandardModelInput;
|
||||||
|
import com.xinda.iot.model.ThingsModelItem.Datatype;
|
||||||
|
import com.xinda.iot.model.ThingsModelItem.EnumItem;
|
||||||
|
import com.xinda.iot.model.dto.ThingsModelDTO;
|
||||||
|
import com.xinda.iot.model.varTemp.EnumClass;
|
||||||
|
import com.xinda.iot.service.IThingsModelStandardService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.xinda.common.utils.SecurityUtils.getLoginUser;
|
||||||
|
import static com.xinda.common.utils.SecurityUtils.isAdmin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通用物模型Service业务层处理
|
||||||
|
*
|
||||||
|
* @author kerwincui
|
||||||
|
* @date 2021-12-16
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class ThingsModelStandardServiceImpl implements IThingsModelStandardService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ThingsModelStandardMapper thingsModelStandardMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询通用物模型
|
||||||
|
*
|
||||||
|
* @param templateId 通用物模型主键
|
||||||
|
* @return 通用物模型
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ThingsModelStandard selectThingsModelStandardByTemplateId(Long templateId)
|
||||||
|
{
|
||||||
|
return thingsModelStandardMapper.selectThingsModelStandardByTemplateId(templateId, SecurityUtils.getLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询通用物模型列表
|
||||||
|
*
|
||||||
|
* @param thingsModelStandard 通用物模型
|
||||||
|
* @return 通用物模型
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ThingsModelStandard> selectThingsModelStandardList(ThingsModelStandard thingsModelStandard)
|
||||||
|
{
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
// List<SysRole> roles=user.getRoles();
|
||||||
|
// 租户
|
||||||
|
// if(roles.stream().anyMatch(a->a.getRoleKey().equals("tenant"))){
|
||||||
|
// thingsModelStandard.setTenantId(user.getUserId());
|
||||||
|
// }
|
||||||
|
thingsModelStandard.setLanguage(SecurityUtils.getLanguage());
|
||||||
|
List<ThingsModelStandard> list = thingsModelStandardMapper.selectThingsModelStandardList(thingsModelStandard);
|
||||||
|
for (ThingsModelStandard modelTemplate : list) {
|
||||||
|
if (null != user.getDeptId()) {
|
||||||
|
modelTemplate.setOwner(user.getDept().getDeptUserId().equals(modelTemplate.getTenantId()));
|
||||||
|
} else {
|
||||||
|
modelTemplate.setOwner(user.getUserId().equals(modelTemplate.getTenantId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ThingsModelStandard> selectModelListByStandardId(Long standardId)
|
||||||
|
{
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
List<ThingsModelStandard> list = thingsModelStandardMapper.selectModelListByStandardId(standardId);
|
||||||
|
for (ThingsModelStandard modelTemplate : list) {
|
||||||
|
if (null != user.getDeptId()) {
|
||||||
|
modelTemplate.setOwner(user.getDept().getDeptUserId().equals(modelTemplate.getTenantId()));
|
||||||
|
} else {
|
||||||
|
modelTemplate.setOwner(user.getUserId().equals(modelTemplate.getTenantId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增通用物模型
|
||||||
|
*
|
||||||
|
* @param template 通用物模型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertThingsModelStandard(ThingsModelStandard template)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// 判断是否为管理员
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
if (isAdmin(user.getUserId())) {
|
||||||
|
template.setIsSys(1);
|
||||||
|
} else {
|
||||||
|
template.setIsSys(0);
|
||||||
|
}
|
||||||
|
// List<SysRole> roles=user.getRoles();
|
||||||
|
// for(int i=0;i<roles.size();i++){
|
||||||
|
// if(roles.get(i).getRoleKey().equals("tenant") || roles.get(i).getRoleKey().equals("general")){
|
||||||
|
// template.setIsSys(0);
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if (null != user.getDeptId()) {
|
||||||
|
template.setTenantId(user.getDept().getDeptUserId());
|
||||||
|
template.setTenantName(user.getDept().getDeptUserName());
|
||||||
|
} else {
|
||||||
|
template.setTenantId(user.getUserId());
|
||||||
|
template.setTenantName(user.getUserName());
|
||||||
|
}
|
||||||
|
template.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return thingsModelStandardMapper.insertThingsModelStandard(template);
|
||||||
|
}catch (Exception e){
|
||||||
|
if (e.getMessage().contains("iot_things_modes_slaveId_reg")){
|
||||||
|
throw new ServiceException("同一个采集点模板下,寄存器地址重复,请检查导入变量寄存器地址");
|
||||||
|
}else {
|
||||||
|
throw new ServiceException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改通用物模型
|
||||||
|
*
|
||||||
|
* @param template 通用物模型
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateThingsModelStandard(ThingsModelStandard template)
|
||||||
|
{
|
||||||
|
template.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return thingsModelStandardMapper.updateThingsModelStandard(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除通用物模型
|
||||||
|
*
|
||||||
|
* @param templateIds 需要删除的通用物模型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteThingsModelStandardByTemplateIds(Long[] templateIds)
|
||||||
|
{
|
||||||
|
return thingsModelStandardMapper.deleteThingsModelStandardByTemplateIds(templateIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除通用物模型信息
|
||||||
|
*
|
||||||
|
* @param templateId 通用物模型主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteThingsModelStandardByTemplateId(Long templateId)
|
||||||
|
{
|
||||||
|
return thingsModelStandardMapper.deleteThingsModelStandardByTemplateId(templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导入采集点数据
|
||||||
|
*
|
||||||
|
* @param lists 数据列表
|
||||||
|
* @param tempSlaveId 从机编码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public String importData(List<ThingsModelStandard> lists, String tempSlaveId) {
|
||||||
|
if (null == tempSlaveId || CollectionUtils.isEmpty(lists)) {
|
||||||
|
throw new ServiceException("导入数据异常");
|
||||||
|
}
|
||||||
|
int success = 0;
|
||||||
|
int failure = 0;
|
||||||
|
StringBuilder succSb = new StringBuilder();
|
||||||
|
StringBuilder failSb = new StringBuilder();
|
||||||
|
|
||||||
|
for (ThingsModelStandard model : lists) {
|
||||||
|
try {
|
||||||
|
//处理数据定义
|
||||||
|
this.parseSpecs(model);
|
||||||
|
this.insertThingsModelStandard(model);
|
||||||
|
success++;
|
||||||
|
succSb.append("<br/>").append(success).append(",采集点: ").append(model.getTemplateName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("导入错误:", e);
|
||||||
|
failure++;
|
||||||
|
failSb.append("<br/>").append(failure).append(",采集点: ").append(model.getTemplateName()).append("导入失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (failure > 0) {
|
||||||
|
throw new ServiceException(failSb.toString());
|
||||||
|
}
|
||||||
|
return succSb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSpecs(ThingsModelStandard model) {
|
||||||
|
JSONObject specs = new JSONObject();
|
||||||
|
String datatype = model.getDatatype();
|
||||||
|
String limitValue = model.getLimitValue();
|
||||||
|
if (limitValue != null && !"".equals(limitValue)) {
|
||||||
|
String[] values = limitValue.trim().split("/");
|
||||||
|
switch (datatype) {
|
||||||
|
case "integer":
|
||||||
|
specs.put("max", new BigDecimal(values[1]));
|
||||||
|
specs.put("min", new BigDecimal(values[0]));
|
||||||
|
specs.put("type", datatype);
|
||||||
|
specs.put("unit", model.getUnit());
|
||||||
|
specs.put("step", 0);
|
||||||
|
break;
|
||||||
|
case "bool":
|
||||||
|
specs.put("type",datatype);
|
||||||
|
specs.put("trueText",values[1]);
|
||||||
|
specs.put("falseText",values[0]);
|
||||||
|
break;
|
||||||
|
case "enum":
|
||||||
|
List<EnumClass> list = new ArrayList<>();
|
||||||
|
for (String value : values) {
|
||||||
|
String[] params = value.trim().split(":");
|
||||||
|
EnumClass enumCls = new EnumClass();
|
||||||
|
enumCls.setText(params[1]);
|
||||||
|
enumCls.setValue(params[0]);
|
||||||
|
list.add(enumCls);
|
||||||
|
}
|
||||||
|
specs.put("type",datatype);
|
||||||
|
specs.put("enumList",list);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
model.setSpecs(specs.toJSONString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出采集点数据
|
||||||
|
*
|
||||||
|
* @param thingsModelStandard 通用物模型
|
||||||
|
* @return 通用物模型集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ThingsModelStandard> selectThingsModelStandardExport(ThingsModelStandard thingsModelStandard){
|
||||||
|
thingsModelStandard.setLanguage(SecurityUtils.getLanguage());
|
||||||
|
List<ThingsModelStandard> thingsModelStandards = thingsModelStandardMapper.selectThingsModelStandardList(thingsModelStandard);
|
||||||
|
for (ThingsModelStandard template : thingsModelStandards) {
|
||||||
|
Datatype datatype = JSONObject.parseObject(template.getSpecs(), Datatype.class);
|
||||||
|
switch (datatype.getType()) {
|
||||||
|
case "integer":
|
||||||
|
template.setLimitValue(datatype.getMin()+ "/"+ datatype.getMax());
|
||||||
|
template.setDatatype(datatype.getType());
|
||||||
|
template.setUnit(datatype.getUnit());
|
||||||
|
break;
|
||||||
|
case "bool":
|
||||||
|
template.setLimitValue("0:"+datatype.getFalseText()+ "/" + "1:"+datatype.getTrueText());
|
||||||
|
template.setDatatype(datatype.getType());
|
||||||
|
break;
|
||||||
|
case "enum":
|
||||||
|
List<EnumItem> enumList = datatype.getEnumList();
|
||||||
|
StringBuilder buffer = new StringBuilder();
|
||||||
|
for (int i = 0; i < enumList.size(); i++) {
|
||||||
|
EnumItem item = enumList.get(i);
|
||||||
|
String s = item.getValue() + ":" + item.getText();
|
||||||
|
buffer.append(s);
|
||||||
|
if (i < enumList.size() -1){
|
||||||
|
buffer.append("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
template.setLimitValue(buffer.toString());
|
||||||
|
template.setDatatype(datatype.getType());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return thingsModelStandards;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import com.alibaba.fastjson2.JSONObject;
|
|||||||
import com.xinda.common.constant.CacheConstants;
|
import com.xinda.common.constant.CacheConstants;
|
||||||
import com.xinda.common.constant.Constants;
|
import com.xinda.common.constant.Constants;
|
||||||
import com.xinda.common.constant.UserConstants;
|
import com.xinda.common.constant.UserConstants;
|
||||||
import com.xinda.common.core.domain.AjaxResult;
|
|
||||||
import com.xinda.common.core.domain.entity.SysUser;
|
import com.xinda.common.core.domain.entity.SysUser;
|
||||||
import com.xinda.common.core.redis.RedisCache;
|
import com.xinda.common.core.redis.RedisCache;
|
||||||
import com.xinda.common.exception.user.CaptchaException;
|
import com.xinda.common.exception.user.CaptchaException;
|
||||||
@@ -29,6 +28,7 @@ import com.xinda.system.service.ISysUserService;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
@@ -50,6 +50,12 @@ public class ToolServiceImpl implements IToolService
|
|||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(ToolServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(ToolServiceImpl.class);
|
||||||
|
|
||||||
|
@Value("${spring.mqtt.gen-username}")
|
||||||
|
private String genUsername;
|
||||||
|
|
||||||
|
@Value("${spring.mqtt.gen-password}")
|
||||||
|
private String genPassword;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisCache redisCache;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
@@ -70,6 +76,7 @@ public class ToolServiceImpl implements IToolService
|
|||||||
@Resource
|
@Resource
|
||||||
private ISysDeptService sysDeptService;
|
private ISysDeptService sysDeptService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成随机数字和字母
|
* 生成随机数字和字母
|
||||||
*/
|
*/
|
||||||
@@ -371,6 +378,26 @@ public class ToolServiceImpl implements IToolService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备简单认证
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ResponseEntity miniMqttAuthentication(MqttAuthenticationModel mqttModel) {
|
||||||
|
|
||||||
|
// 验证用户名
|
||||||
|
if (!mqttModel.getUserName().equals(genUsername)) {
|
||||||
|
return returnUnauthorized(mqttModel, "设备简单认证,设备mqtt用户名错误");
|
||||||
|
}
|
||||||
|
// 验证密码
|
||||||
|
if (!mqttModel.getPassword().equals(genPassword)) {
|
||||||
|
return returnUnauthorized(mqttModel, "设备简单认证,设备mqtt密码错误");
|
||||||
|
}
|
||||||
|
log.info("-----------设备简单认证成功,clientId:" + mqttModel.getClientId() + "---------------");
|
||||||
|
return ResponseEntity.ok().body("ok");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备加密认证
|
* 设备加密认证
|
||||||
*
|
*
|
||||||
@@ -468,6 +495,13 @@ public class ToolServiceImpl implements IToolService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity clientAuthNoClient(String clientid,String username,String password) {
|
||||||
|
// 设备简单认证
|
||||||
|
return this.miniMqttAuthentication(new MqttAuthenticationModel(clientid, username, password));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity clientAuthv5(String clientid,String username,String password) throws Exception {
|
public ResponseEntity clientAuthv5(String clientid,String username,String password) throws Exception {
|
||||||
JSONObject ret = new JSONObject();
|
JSONObject ret = new JSONObject();
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package com.xinda.iot.util;
|
||||||
|
|
||||||
|
import org.apache.commons.jexl3.*;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class FormulaCalculator {
|
||||||
|
private static final JexlEngine jexl = new JexlBuilder()
|
||||||
|
.cache(512)
|
||||||
|
.silent(false)
|
||||||
|
.strict(true)
|
||||||
|
.create();
|
||||||
|
|
||||||
|
// 匹配字母开头,包含字母、数字的变量名(至少1位)
|
||||||
|
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) {
|
||||||
|
// 校验公式安全性
|
||||||
|
// validateFormula(formula, variables.keySet());
|
||||||
|
|
||||||
|
// 创建上下文并注入变量
|
||||||
|
JexlContext context = new MapContext();
|
||||||
|
variables.forEach((name, value) -> {
|
||||||
|
Number num = parseNumber(value);
|
||||||
|
context.set(name, num);
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 执行计算
|
||||||
|
JexlExpression expr = jexl.createExpression(formula);
|
||||||
|
return expr.evaluate(context).toString();
|
||||||
|
} catch (JexlException e) {
|
||||||
|
throw new RuntimeException("Formula evaluation failed: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Number parseNumber(String value) {
|
||||||
|
try {
|
||||||
|
if (value.contains(".")) {
|
||||||
|
return Double.parseDouble(value);
|
||||||
|
}
|
||||||
|
return Long.parseLong(value);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException("Invalid number format: " + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void validateFormula(String formula, Set<String> validVars) {
|
||||||
|
// 安全字符校验(允许变量名、运算符、数字和括号)
|
||||||
|
if (!formula.matches("^[\\w+\\-*/%().]+$")) {
|
||||||
|
throw new IllegalArgumentException("包含非法字符");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提取公式中的变量
|
||||||
|
Matcher matcher = VAR_PATTERN.matcher(formula);
|
||||||
|
Set<String> formulaVars = new HashSet<>();
|
||||||
|
while (matcher.find()) {
|
||||||
|
String var = matcher.group();
|
||||||
|
// 排除纯数字的情况
|
||||||
|
if (!var.matches("\\d+")) {
|
||||||
|
formulaVars.add(var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验变量是否存在
|
||||||
|
formulaVars.removeAll(validVars);
|
||||||
|
if (!formulaVars.isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("未定义的变量: " + formulaVars);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验变量集合是否包含公式所需全部参数
|
||||||
|
* @param formula 运算公式
|
||||||
|
* @param variables 变量集合(key为变量名)
|
||||||
|
* @return true-变量完整 | false-存在缺失
|
||||||
|
*/
|
||||||
|
public static boolean containsAllVariables(String formula, Map<String, String> variables) {
|
||||||
|
// 提取公式中的有效变量名(过滤纯数字)
|
||||||
|
Set<String> requiredVars = extractFormulaVariables(formula);
|
||||||
|
|
||||||
|
// 空值安全校验
|
||||||
|
if (variables == null) return requiredVars.isEmpty();
|
||||||
|
|
||||||
|
// 检查所有必要变量是否存在
|
||||||
|
return variables.keySet().containsAll(requiredVars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 公开的变量提取方法
|
||||||
|
*/
|
||||||
|
public static Set<String> extractFormulaVariables(String formula) {
|
||||||
|
Matcher matcher = VAR_PATTERN.matcher(formula);
|
||||||
|
Set<String> vars = new HashSet<>();
|
||||||
|
while (matcher.find()) {
|
||||||
|
String var = matcher.group();
|
||||||
|
if (!isPureNumber(var)) { // 过滤纯数字
|
||||||
|
vars.add(var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.unmodifiableSet(vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断字符串是否为纯数字
|
||||||
|
*/
|
||||||
|
private static boolean isPureNumber(String str) {
|
||||||
|
return str.matches("^\\d+$");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,6 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<resultMap type="com.xinda.iot.domain.Category" id="CategoryResult">
|
<resultMap type="com.xinda.iot.domain.Category" id="CategoryResult">
|
||||||
<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="standardId" column="standard_id" />
|
||||||
|
<result property="standardName" column="standard_name" />
|
||||||
<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" />
|
||||||
@@ -19,14 +22,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<resultMap type="com.xinda.iot.model.IdAndName" id="CategoryShortResult">
|
<resultMap type="com.xinda.iot.model.IdAndName" id="CategoryShortResult">
|
||||||
<result property="id" column="category_id" />
|
<result property="id" column="category_id" />
|
||||||
<result property="name" column="category_name" />
|
<result property="name" column="category_name" />
|
||||||
|
<!-- <result property="modelName" column="model_name" />-->
|
||||||
|
<!-- <result property="standardId" column="standard_id" />-->
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectCategoryVo">
|
<sql id="selectCategoryVo">
|
||||||
select category_id, category_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_category
|
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
|
||||||
</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.tenant_id, c.tenant_name,
|
select c.category_id, c.category_name,c.model_name,c.standard_id,c.standard_name, 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>
|
||||||
@@ -48,6 +53,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and c.tenant_id = #{tenantId}
|
and c.tenant_id = #{tenantId}
|
||||||
</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="standardId != null and standardId != ''"> and (c.standard_id = #{standardId})</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
|
||||||
@@ -55,6 +62,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
|
|
||||||
<select id="selectCategoryShortList" resultMap="CategoryShortResult">
|
<select id="selectCategoryShortList" resultMap="CategoryShortResult">
|
||||||
select c.category_id, c.category_name
|
select c.category_id, c.category_name
|
||||||
|
-- select c.category_id, CONCAT_WS('-', c.category_name, c.model_name) AS category_name
|
||||||
|
-- ,c.model_name,c.standard_id
|
||||||
from iot_category c
|
from iot_category c
|
||||||
<where>
|
<where>
|
||||||
<if test="deptId != null and showSenior and !isAdmin">
|
<if test="deptId != null and showSenior and !isAdmin">
|
||||||
@@ -75,6 +84,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
and c.tenant_id = #{tenantId}
|
and c.tenant_id = #{tenantId}
|
||||||
</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="standardId != null and standardId != ''"> and (m.standard_id = #{standardId})</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
|
||||||
@@ -89,6 +100,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
insert into iot_category
|
insert into iot_category
|
||||||
<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="standardId != null">standard_id,</if>
|
||||||
|
<if test="standardName != null and standardName != ''">standard_name,</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>
|
||||||
@@ -101,6 +115,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</trim>
|
</trim>
|
||||||
<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="standardId != null">#{standardId},</if>
|
||||||
|
<if test="standardName != null and standardName != ''">#{standardName},</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>
|
||||||
@@ -117,6 +134,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
update iot_category
|
update iot_category
|
||||||
<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="standardId != null">standard_id = #{standardId},</if>
|
||||||
|
<if test="standardName != null and standardName != ''">standard_name = #{standardName},</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>
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.xinda.iot.mapper.StandardMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.xinda.iot.domain.Standard" id="StandardResult">
|
||||||
|
<result property="standardId" column="standard_id" />
|
||||||
|
<result property="standardName" column="standard_name" />
|
||||||
|
<result property="tenantId" column="tenant_id" />
|
||||||
|
<result property="tenantName" column="tenant_name" />
|
||||||
|
<result property="isSys" column="is_sys" />
|
||||||
|
<result property="orderNum" column="order_num" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap type="com.xinda.iot.model.IdAndName" id="StandardShortResult">
|
||||||
|
<result property="id" column="standard_id" />
|
||||||
|
<result property="name" column="standard_name" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectStandardVo">
|
||||||
|
select standard_id, standard_name, tenant_id, tenant_name, is_sys,order_num, create_time, update_time, remark from iot_standard
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectStandardList" parameterType="com.xinda.iot.domain.Standard" resultMap="StandardResult">
|
||||||
|
select c.standard_id, c.standard_name, c.tenant_id, c.tenant_name,
|
||||||
|
c.is_sys,c.order_num, c.create_time, c.update_time, c.remark
|
||||||
|
from iot_standard c
|
||||||
|
<where>
|
||||||
|
<if test="deptId != null and showSenior and !isAdmin">
|
||||||
|
and ( c.tenant_id = #{tenantId}
|
||||||
|
or (c.tenant_id in (
|
||||||
|
SELECT de.dept_user_id
|
||||||
|
FROM sys_dept de
|
||||||
|
WHERE FIND_IN_SET( de.dept_id,(
|
||||||
|
SELECT d.ancestors
|
||||||
|
FROM sys_dept d
|
||||||
|
WHERE d.dept_id = #{deptId} )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
|
||||||
|
and c.tenant_id = #{tenantId}
|
||||||
|
</if>
|
||||||
|
<if test="standardName != null and standardName != ''"> and c.standard_name like concat('%', #{standardName}, '%')</if>
|
||||||
|
<if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if>
|
||||||
|
</where>
|
||||||
|
order by order_num
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectStandardShortList" resultMap="StandardShortResult">
|
||||||
|
select c.standard_id, c.standard_name
|
||||||
|
from iot_standard c
|
||||||
|
<where>
|
||||||
|
<if test="deptId != null and showSenior and !isAdmin">
|
||||||
|
and ( c.tenant_id = #{tenantId}
|
||||||
|
or (c.tenant_id in (
|
||||||
|
SELECT de.dept_user_id
|
||||||
|
FROM sys_dept de
|
||||||
|
WHERE FIND_IN_SET( de.dept_id,(
|
||||||
|
SELECT d.ancestors
|
||||||
|
FROM sys_dept d
|
||||||
|
WHERE d.dept_id = #{deptId} )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
<if test="!showSenior and tenantId != null and tenantId != 0 and !isAdmin">
|
||||||
|
and c.tenant_id = #{tenantId}
|
||||||
|
</if>
|
||||||
|
<if test="standardName != null and standardName != ''"> and c.standard_name like concat('%', #{standardName}, '%')</if>
|
||||||
|
<if test="tenantId != null and tenantId != ''"> and (c.tenant_id = #{tenantId} or c.is_sys = 1)</if>
|
||||||
|
</where>
|
||||||
|
order by order_num
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectStandardByStandardId" parameterType="Long" resultMap="StandardResult">
|
||||||
|
<include refid="selectStandardVo"/>
|
||||||
|
where standard_id = #{standardId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertStandard" parameterType="com.xinda.iot.domain.Standard" useGeneratedKeys="true" keyProperty="standardId">
|
||||||
|
insert into iot_standard
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="standardName != null and standardName != ''">standard_name,</if>
|
||||||
|
<if test="tenantId != null">tenant_id,</if>
|
||||||
|
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
||||||
|
<if test="isSys != null">is_sys,</if>
|
||||||
|
<if test="orderNum != null">order_num,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="standardName != null and standardName != ''">#{standardName},</if>
|
||||||
|
<if test="tenantId != null">#{tenantId},</if>
|
||||||
|
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
||||||
|
<if test="isSys != null">#{isSys},</if>
|
||||||
|
<if test="orderNum != null">#{orderNum},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateStandard" parameterType="com.xinda.iot.domain.Standard">
|
||||||
|
update iot_standard
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="standardName != null and standardName != ''">standard_name = #{standardName},</if>
|
||||||
|
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||||
|
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
|
||||||
|
<if test="isSys != null">is_sys = #{isSys},</if>
|
||||||
|
<if test="orderNum != null">order_num = #{orderNum},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
</trim>
|
||||||
|
where standard_id = #{standardId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteStandardByStandardId" parameterType="Long">
|
||||||
|
delete from iot_standard where standard_id = #{standardId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteStandardByStandardIds" parameterType="String">
|
||||||
|
delete from iot_standard where standard_id in
|
||||||
|
<foreach item="standardId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{standardId}
|
||||||
|
</foreach>
|
||||||
|
</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>
|
||||||
@@ -0,0 +1,232 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.xinda.iot.mapper.ThingsModelStandardMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.xinda.iot.domain.ThingsModelStandard" id="ThingsModelStandardResult">
|
||||||
|
<result property="templateId" column="template_id" />
|
||||||
|
<result property="templateName" column="template_name" />
|
||||||
|
<result property="standardId" column="standard_id" />
|
||||||
|
<result property="standardName" column="standard_name" />
|
||||||
|
<result property="tenantId" column="tenant_id" />
|
||||||
|
<result property="tenantName" column="tenant_name" />
|
||||||
|
<result property="identifier" column="identifier" />
|
||||||
|
<result property="type" column="type" />
|
||||||
|
<result property="datatype" column="datatype" />
|
||||||
|
<result property="specs" column="specs" />
|
||||||
|
<result property="isSys" column="is_sys" />
|
||||||
|
<result property="isReadonly" column="is_readonly" />
|
||||||
|
<result property="isSharePerm" column="is_share_perm" />
|
||||||
|
<result property="isHistory" column="is_history" />
|
||||||
|
<result property="isMonitor" column="is_monitor" />
|
||||||
|
<result property="isApp" column="is_app"/>
|
||||||
|
<result property="formula" column="formula" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<result property="createBy" column="create_by" />
|
||||||
|
<result property="createTime" column="create_time" />
|
||||||
|
<result property="updateBy" column="update_by" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="remark" column="remark" />
|
||||||
|
<result property="modelOrder" column="model_order" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<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
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectThingsModelStandardList" parameterType="com.xinda.iot.domain.ThingsModelStandard" 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
|
||||||
|
from iot_things_model_standard m
|
||||||
|
<where>
|
||||||
|
<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="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="standardId != null and standardId != ''"> and (m.standard_id = #{standardId})</if>
|
||||||
|
</where>
|
||||||
|
order by m.template_id desc, m.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectModelListByStandardId" parameterType="Long" 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
|
||||||
|
from iot_things_model_standard m
|
||||||
|
<where>
|
||||||
|
m.standard_id = #{standardId}
|
||||||
|
</where>
|
||||||
|
order by m.template_id desc, m.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<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
|
||||||
|
from iot_things_model_standard m
|
||||||
|
where m.template_id = #{templateId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<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
|
||||||
|
from iot_things_model_standard m
|
||||||
|
where m.template_id in
|
||||||
|
<foreach item="templateId" collection="templateIds" open="(" separator="," close=")">
|
||||||
|
#{templateId}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertThingsModelStandard" parameterType="com.xinda.iot.domain.ThingsModelStandard" useGeneratedKeys="true" keyProperty="templateId">
|
||||||
|
insert into iot_things_model_standard
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="templateName != null and templateName != ''">template_name,</if>
|
||||||
|
<if test="standardId != null">standard_id,</if>
|
||||||
|
<if test="standardName != null and standardName != ''">standard_name,</if>
|
||||||
|
<if test="tenantId != null">tenant_id,</if>
|
||||||
|
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
||||||
|
<if test="identifier != null and identifier != ''">identifier,</if>
|
||||||
|
<if test="type != null">type,</if>
|
||||||
|
<if test="datatype != null and datatype != ''">datatype,</if>
|
||||||
|
<if test="specs != null and specs != ''">specs,</if>
|
||||||
|
<if test="isSys != null">is_sys,</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="isHistory != null">is_history,</if>
|
||||||
|
<if test="isMonitor != null">is_monitor,</if>
|
||||||
|
<if test="isApp != null">is_app,</if>
|
||||||
|
<if test="formula != null">formula,</if>
|
||||||
|
<if test="delFlag != null">del_flag,</if>
|
||||||
|
<if test="createBy != null">create_by,</if>
|
||||||
|
<if test="createTime != null">create_time,</if>
|
||||||
|
<if test="updateBy != null">update_by,</if>
|
||||||
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="remark != null">remark,</if>
|
||||||
|
<if test="modelOrder != null">model_order,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="templateName != null and templateName != ''">#{templateName},</if>
|
||||||
|
<if test="standardId != null">#{standardId},</if>
|
||||||
|
<if test="standardName != null and standardName != ''">#{standardName},</if>
|
||||||
|
<if test="tenantId != null">#{tenantId},</if>
|
||||||
|
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
||||||
|
<if test="identifier != null and identifier != ''">#{identifier},</if>
|
||||||
|
<if test="type != null">#{type},</if>
|
||||||
|
<if test="datatype != null and datatype != ''">#{datatype},</if>
|
||||||
|
<if test="specs != null and specs != ''">#{specs},</if>
|
||||||
|
<if test="isSys != null">#{isSys},</if>
|
||||||
|
<if test="isReadonly != null">#{isReadonly},</if>
|
||||||
|
<if test="isChart != null">#{isChart},</if>
|
||||||
|
<if test="isSharePerm != null">#{isSharePerm},</if>
|
||||||
|
<if test="isHistory != null">#{isHistory},</if>
|
||||||
|
<if test="isMonitor != null">#{isMonitor},</if>
|
||||||
|
<if test="isApp != null">#{isApp},</if>
|
||||||
|
<if test="formula != null">#{formula},</if>
|
||||||
|
<if test="delFlag != null">#{delFlag},</if>
|
||||||
|
<if test="createBy != null">#{createBy},</if>
|
||||||
|
<if test="createTime != null">#{createTime},</if>
|
||||||
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="remark != null">#{remark},</if>
|
||||||
|
<if test="modelOrder != null">#{modelOrder},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateThingsModelStandard" parameterType="com.xinda.iot.domain.ThingsModelStandard">
|
||||||
|
update iot_things_model_standard
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="templateName != null and templateName != ''">template_name = #{templateName},</if>
|
||||||
|
<if test="standardId != null">standard_id = #{standardId},</if>
|
||||||
|
<if test="standardName != null and standardName != ''">standard_name = #{standardName},</if>
|
||||||
|
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||||
|
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
|
||||||
|
<if test="identifier != null and identifier != ''">identifier = #{identifier},</if>
|
||||||
|
<if test="type != null">type = #{type},</if>
|
||||||
|
<if test="datatype != null and datatype != ''">datatype = #{datatype},</if>
|
||||||
|
<if test="specs != null and specs != ''">specs = #{specs},</if>
|
||||||
|
<if test="isSys != null">is_sys = #{isSys},</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="isHistory != null">is_history = #{isHistory},</if>
|
||||||
|
<if test="isMonitor != null">is_Monitor = #{isMonitor},</if>
|
||||||
|
<if test="isApp != null">is_app = #{isApp},</if>
|
||||||
|
<if test="formula != null">formula = #{formula},</if>
|
||||||
|
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||||
|
<if test="createBy != null">create_by = #{createBy},</if>
|
||||||
|
<if test="createTime != null">create_time = #{createTime},</if>
|
||||||
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||||
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||||
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
</trim>
|
||||||
|
where template_id = #{templateId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteThingsModelStandardByTemplateId" parameterType="Long">
|
||||||
|
delete from iot_things_model_standard where template_id = #{templateId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
|
||||||
|
<delete id="deleteThingsModelStandardByTemplateIds" parameterType="String">
|
||||||
|
delete from iot_things_model_standard where template_id in
|
||||||
|
<foreach item="templateId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{templateId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="batchThingsModelStandards" parameterType="java.util.List">
|
||||||
|
INSERT INTO iot_things_model_standard (
|
||||||
|
template_name,
|
||||||
|
standard_id,
|
||||||
|
standard_name,
|
||||||
|
tenant_id,
|
||||||
|
tenant_name,
|
||||||
|
identifier,
|
||||||
|
type,
|
||||||
|
datatype,
|
||||||
|
specs,
|
||||||
|
is_sys,
|
||||||
|
is_readonly,
|
||||||
|
is_share_perm,
|
||||||
|
is_history,
|
||||||
|
is_monitor,
|
||||||
|
is_app,
|
||||||
|
formula,
|
||||||
|
del_flag,
|
||||||
|
create_by,
|
||||||
|
create_time,
|
||||||
|
update_by,
|
||||||
|
update_time,
|
||||||
|
remark,
|
||||||
|
model_order
|
||||||
|
) VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{item.templateName},
|
||||||
|
#{item.standardId},
|
||||||
|
#{item.standardName},
|
||||||
|
#{item.tenantId},
|
||||||
|
#{item.tenantName},
|
||||||
|
#{item.identifier},
|
||||||
|
#{item.type},
|
||||||
|
#{item.datatype},
|
||||||
|
#{item.specs},
|
||||||
|
#{item.isSys},
|
||||||
|
#{item.isReadonly},
|
||||||
|
#{item.isSharePerm},
|
||||||
|
#{item.isHistory},
|
||||||
|
#{item.isMonitor},
|
||||||
|
#{item.isApp},
|
||||||
|
#{item.formula},
|
||||||
|
#{item.delFlag},
|
||||||
|
#{item.createBy},
|
||||||
|
#{item.createTime},
|
||||||
|
#{item.updateBy},
|
||||||
|
#{item.updateTime},
|
||||||
|
#{item.remark},
|
||||||
|
#{item.modelOrder}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user