提交修改

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -85,6 +85,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where standard_id = #{standardId}
</select>
<select id="checkName" parameterType="String" resultType="java.lang.Boolean">
SELECT COUNT(*) > 0
FROM iot_standard
where standard_name = #{standardName}
</select>
<insert id="insertStandard" parameterType="com.xinda.iot.domain.Standard" useGeneratedKeys="true" keyProperty="standardId">
insert into iot_standard
<trim prefix="(" suffix=")" suffixOverrides=",">
@@ -141,10 +147,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</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>

View File

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

View File

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