Commit 3952b419 authored by xukaiqiang's avatar xukaiqiang

init

parents
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
*.iml
*.settings
*.classpath
*.project
*.springBeans
*.factorypath
target
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>YeeAMOSIotServer</artifactId>
<name>YeeAMOSIotServer</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<drools.version>6.5.0.Final</drools.version>
</properties>
<parent>
<groupId>com.yeejoin.amos</groupId>
<artifactId>YeeAMOSIotRoot</artifactId>
<version>3.1.22</version>
</parent>
<dependencies>
<!-- 安全模块jar -->
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>AmosOPService</artifactId>
<version>${YeeOp.version}</version>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>amos-authtoken</artifactId>
<version>${YeeSecurity.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- drools规则 start -->
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-decisiontables</artifactId>
<version>${drools.version}</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-templates</artifactId>
<version>${drools.version}</version>
</dependency>
<!-- drools规则 end -->
<!-- https://mvnrepository.com/artifact/org.fusesource.mqtt-client/mqtt-client -->
<dependency>
<groupId>org.fusesource.mqtt-client</groupId>
<artifactId>mqtt-client</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<!--串口通信依赖-->
<dependency>
<groupId>org.bidib.jbidib.org.qbang.rxtx</groupId>
<artifactId>rxtxcomm</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.9</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
/**
*
*/
package com.yeejoin.amos.iot.business.constants;
import org.apache.log4j.Logger;
import java.text.SimpleDateFormat;
/**
* iot常量
*
* @author as-youjun
*/
public class IotConstant {
/**
* 构造方法
*/
private IotConstant() {
Logger.getLogger(this.getClass()).debug(IotConstant.CONSTRUCTOR);
}
/**
* 网络服务ip
*/
public static final String NET_SERVER_HOST = "0.0.0.0";
/**
* 时间格式(yyyy-MM-dd HH:mm:ss)
*/
public static final SimpleDateFormat SIMPLEDATAFORMAT_YMDHMS = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/**
* 构造方法字符串
*/
public static final String CONSTRUCTOR = "constructor...";
/**
* 轮询job最大线程数
*/
public static final int POLLING_JOB_THREAD_MAX_NUM = 20;
/**
* amos线程池数量
*/
public static final int AMOS_THREAD_NUM = 20;
/**
* 设备测试最大线程数
*/
public static final int TEST_EQUIPMENT_THREAD_MAX_NUM = 5;
/**
* 时间格式字符串:yyyy-MM-dd HH:mm:ss
*/
public static final String DATE_TIME_STR_YMDHMS = "yyyy-MM-dd HH:mm:ss";
/**
* bar
*/
public static final String BAR = "-";
/**
* Underline
*/
public static final String UNDERLINE = "_";
/**
* user
*/
public static final String USER = "user";
/**
* token
*/
public static final String TOKEN = "token";
/**
* loginType
*/
public static final String LOGIN_TYPE = "loginType";
/**
* subGraphId
*/
public static final String SUB_GRAPH_ID = "subGraphId";
public static final String ADMIN_ID = "SUPER";
/**
* 帧报文异常
*/
public static final String FRAME_EXECPTION = "FRAME";
/**
* 性能指标
*/
public static final String METRIC = "METRIC";
/**
* 报文通道
*/
public static final String CHANNEL = "CHANNEL";
/**
* 设备状态(掉线)告警
*/
public static final String EQUIPMENT_STATUS = "EQUIPMENT_STATUS";
/**
* 设备连通性告警告警
*/
public static final String EQUIPMENT_CONNECTION = "EQUIPMENT_CONNECTION";
/**
* 通道注册
*/
public static final String REGISTER = "REGISTER";
/**
* 通道注销
*/
public static final String UNREGISTER = "UNREGISTER";
/**
* 报文正常
*/
public static final String NORMAL = "NORMAL";
/**
* 报文异常
*/
public static final String UNNORMAL = "UNNORMAL";
/**
* 告警socket类型
*/
public static final String ALARM_SOCKET = "ALARM_SOCKET";
/**
* 数据socket类型
*/
public static final String METRIC_SOCKET = "METRIC_SOCKET";
/**
* 数据socket类型
*/
public static final String MORPHIC_SOCKET = "MORPHIC_SOCKET";
/**
* false
*/
public static final Boolean FAIL_BOOLEAN_VALUE = Boolean.FALSE;
/**
* 0
*/
public static final Integer ZERO_INT_VALUE = Integer.parseInt("0");
/**
* -1
*/
public static final Integer FAIL_INT_VALUE = Integer.parseInt("-1");
/**
* -1
*/
public static final Long FAIL_LONG_VALUE = Long.parseLong("-1");
/**
* -1
*/
public static final Short FAIL_SHORT_VALUE = Short.parseShort("-1");
/**
*
*/
public static final Float FAIL_FLOAT_VALUE = Float.parseFloat("-1");
/**
* -1
*/
public static final Double FAIL_DOUBLE_VALUE = Double.parseDouble("-1");
/**
* 空格
*/
public static final Character FAIL_CHARACTER_VALUE = Character.valueOf(' ');
/**
* 失败
*/
public static final int FAILURE = 0;
/**
* 成功
*/
public static final int SUCCESS = 1;
/**
* 在线
*/
public static final String ONLINE = "在线";
/**
* 掉线
*/
public static final String OFFLINE = "掉线";
/**
* 通
*/
public static final String OPEN = "通";
/**
* 不通
*/
public static final String OFF = "不通";
/**
* ip
*/
public static final String IP = "ip";
/**
* #
*/
public static final String SHARP = "#";
/**
* 设备相关常量
*
* @author as-youjun
*/
public static final class EquipmentConstant {
/**
* 下划线
*/
public static final String UNDERLINE = "_";
/**
* 设备属性key前缀
*/
public static final String KEY_PREFIX_EQUIP = "equip_";
/**
* 能力属性key前缀
*/
public static final String KEY_PREFIX_CPBL = "cpbl_";
/**
* 接口属性key前缀
*/
public static final String KEY_PREFIX_INTFC = "intfc_";
/**
* 测试设备标识
*/
public static final String TEST_EQUIPMENT = "test_equipment";
/**
* 选择接口key
*/
public static final String KEY_SELINTFCIDS = "selIntfcIds";
/**
* 选择能力key
*/
public static final String KEY_SELCPBLIDS = "selCpblIds";
/**
* 测试接口标识
*/
public static final String CONNECT = "connect";
/**
* 测试指标标识
*/
public static final String METRIC = "metric";
/**
* 测试接口key
*/
public static final String CONNECTDATA = "connectData";
/**
* 测试指标key
*/
public static final String METRICDATA = "metricData";
/**
* sourceId
*/
public static final String SOURCEID = "sourceId";
/**
* frameType
*/
public static final String FRAMETYPE = "frameType";
/**
* labelType
*/
public static final String LABELTYPE = "labelType";
/**
* quotaSelected
*/
public static final String QUOTASELECTED = "quotaSelected";
/**
* eqpId设备id
*/
public static final String EQPID = "eqpId";
/**
* 设备连通性判断时长:超过eqp_connected_time_span毫秒的缓存数据无效!!!
*/
public static final long EQP_CONNECTED_TIME_SPAN = 120000;//2分钟
}
/**
* TCP
*/
public static final String TCP = "TCP";
public static final String PIE_CHAR = "pieChar";
public static final String BAR_CHAR = "barChar";
public static final String HBAR_CHAR = "hbarChar";
public static final String LINE_CHAR = "lineChar";
public static final String DOUGHUNT_CHAR = "doughuntChar";
public static final String ROSE_CHAR = "roseChar";
public static final String AREA_CHAR = "areaChar";
public static final String DIMENSION = "dimension";
public static final String MEASURE = "measure";
}
package com.yeejoin.amos.iot.business.constants;
/**
*
* <pre>
* 系统字典类型常量类
* </pre>
*
* @author as-shibaobao
* @version $Id: SystemDicType.java, v 0.1 2018年1月26日 下午2:44:47 as-shibaobao Exp $
*/
public class SystemDicType
{
/**
* 通信协议
*/
public static final String CommunityProtocol = "CommunityProtocol";
/**
*脚本语言
*/
public static final String ScriptLang = "ScriptLang";
/**
* 设备原型领域
*/
public static final String EquipTemplateIndustry = "EquipTemplateIndustry";
}
/**
*
*/
package com.yeejoin.amos.iot.business.controller;
import com.yeejoin.amos.iot.business.enums.AlarmStatus;
import com.yeejoin.amos.iot.business.param.AlarmPageParam;
import com.yeejoin.amos.iot.business.param.DeleteAlarmParam;
import com.yeejoin.amos.iot.business.service.intfc.IAlarmService;
import com.yeejoin.amos.iot.core.common.request.CommonPageable;
import com.yeejoin.amos.iot.core.common.request.CommonRequest;
import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.iot.mongodb.service.intfc.IMetricDataQueryService;
import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 告警控制器
*
* @author as-youjun
*
*/
@RestController
@RequestMapping("/alarm")
@Api(value = "alarm", tags = {"告警管理"})
public class AlarmController extends BaseController {
@Autowired
private IAlarmService alarmService;
@Autowired
private IMetricDataQueryService metricDataQueryService;
/**
*
* <pre>
* 分页查询告警数据(基础数据)
* </pre>
*
* @param requests 查询条件集合,可以为空
* @param pageable 分页参数,默认pageNumber=0&pageSize=10
* @return CommonResponse
*/
@ApiOperation(httpMethod = "POST", value = "分页查询告警数据(基础数据)", notes = "分页查询告警数据(基础数据)")
@RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryAlarmList(
@ApiParam(value = "查询参数", required = true) @RequestBody(required = false) List<CommonRequest> requests,
@ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) {
List<DaoCriteria> criterias = buildDaoCriteriasNoDelete(requests);
if (!"SUPER".equals(getUserId())) {
DaoCriteria daoCriteria = new DaoCriteria();
daoCriteria.setPropertyName("orgCode");
daoCriteria.setOperator(QueryOperatorEnum.LIKE.getName());
daoCriteria.setValue(getCompanyOrgCode() + "%");
criterias.add(daoCriteria);
}
Map<String, Object> map = alarmService.findAllByParam(criterias, pageable);
return CommonResponseUtil.success(map);
}
/**
*
* <pre>
* 清除告警数据(只改变数据状态)
* </pre>
*
* @param requests 要删除的条件实体
* @return CommonResponse
*/
@ApiOperation(httpMethod = "POST", value = "清除告警数据(只改变数据状态)", notes = "清除告警数据(只改变数据状态)")
@RequestMapping(value = "/delete", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse deleteAlarm(
@ApiParam(value = "清除告警数据的参数", required = true) @RequestBody(required = false) DeleteAlarmParam requests) {
alarmService.deleteAlarm(requests);
return CommonResponseUtil.success();
}
/**
*
* <pre>
* 当前告警统计
* </pre>
* @return CommonResponse
*/
@ApiOperation(httpMethod = "GET", value = "当前告警统计", notes = "当前告警统计")
@RequestMapping(value = "/presentAlarm-static", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryPresentAlarmStatic() {
List<DaoCriteria> daoCriterias = buildDaoCriteriasNoParam();
daoCriterias.add(new DaoCriteria("status", QueryOperatorEnum.EQUAL.getName(), AlarmStatus.RAISE.getValue()));
Map<String, Object> result = alarmService.queryPresentAlarmStatic(daoCriterias);
return CommonResponseUtil.success(result);
}
/**
*
* <pre>
* 根据状态统计告警数据
* </pre>
* @return CommonResponse
*/
@ApiOperation(httpMethod = "GET", value = "根据状态统计告警数据", notes = "根据状态统计告警数据")
@RequestMapping(value = "/alarmStaticByStatus", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse alarmStaticByStatus() {
return CommonResponseUtil.success(alarmService.alarmStaticByStatus(getOrgCode()));
}
@ApiOperation(httpMethod = "POST", value = "根据设备属性获取告警信息", notes = "根据设备属性获取告警信息")
@RequestMapping(value = "/equipAttr", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryAlarmByEquipAttr(@ApiParam(value = "查询参数", required = true) @RequestBody(required = true) List<CommonRequest> requests) {
HashMap<String, Object> param = new HashMap<>();
HashMap<String, Object> attrs = new HashMap<>();
for (CommonRequest cr : requests) {
attrs.put(cr.getName(), cr.getValue());
}
param.put("orgCode", getCompanyOrgCode());
param.put("attrs", attrs);
List list = alarmService.queryAlarmByEquipAttr(param);
return CommonResponseUtil.success(list);
}
@ApiOperation(value = "根据状态统计告警指标数据", notes = "根据状态统计告警指标数据")
@PostMapping(value = "/alarmPage")
public CommonResponse alarmPage(@ApiParam(value = "查询参数", required = true) @RequestBody AlarmPageParam alarmPageParam) {
return CommonResponseUtil.success(metricDataQueryService.alarmPage(alarmPageParam));
}
}
package com.yeejoin.amos.iot.business.controller;
import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.iot.business.param.CompanyBo;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.ApplicationConfig;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.op.core.util.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/company")
@Api(value = "company", tags = {"公司"})
public class CompanyController extends BaseController {
@Autowired
private ApplicationConfig applicationConfig;
@ApiOperation(httpMethod = "POST", value = "获取公司权限树", notes = "获取公司权限树(包含子公司)")
@RequestMapping(value = "/manger-tree", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse mangerTree() {
String url = applicationConfig.getParamValueStr("params.remoteurl");
HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType
.parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.add("X-From-Service", "true");
HttpEntity<String> formEntity = new HttpEntity<String>(headers);
List<HashMap> companys = null;
try {
RestTemplate restTemplate = new RestTemplate();
CommonResponse commonResponse = restTemplate.exchange(url + "v1/company/subtree/" + getSelectedOrgInfo().getCompany().getSequenceNbr(),
HttpMethod.GET, formEntity, CommonResponse.class).getBody();
if (commonResponse.getResult().equals(Constants.RESULT_SUCCESS)) {
companys = JSON.parseArray(JSON.toJSONString(commonResponse.getDataList()), HashMap.class);
}
CompanyBo selectCompany = this.getSelectedOrgInfo().getCompany();
Map<String, Object> mapCompany = Obj2Map(selectCompany);
mapCompany.put("orgCode", selectCompany.getOrgCode());
mapCompany.put("levelName", selectCompany.getCompanyName());
mapCompany.put("title", selectCompany.getCompanyName());
mapCompany.put("value", selectCompany.getSequenceNbr());
mapCompany.put("children", mapList(companys));
List resultList = new ArrayList();
resultList.add(mapCompany);
return CommonResponseUtil.success(resultList);
} catch (Exception e) {
e.printStackTrace();
return CommonResponseUtil.failure();
}
}
private List<HashMap> mapList(List<HashMap> list) {
for (HashMap hm : list) {
hm.put("value", hm.get("sequenceNbr"));
hm.put("title", hm.get("companyName"));
if (!ObjectUtils.isEmpty(hm.get("children"))) {
hm.put("children", mapList((List<HashMap>) hm.get("children")));;
}
}
return list;
}
private Map<String, Object> Obj2Map(Object obj) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true);
map.put(field.getName(), field.get(obj));
}
return map;
}
}
package com.yeejoin.amos.iot.business.controller;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.iot.business.param.MongoPageParam;
import com.yeejoin.amos.iot.business.param.QueryMetricDataParam;
import com.yeejoin.amos.iot.core.common.response.CommonPage;
import com.yeejoin.amos.iot.mongodb.MongoCondition;
import com.yeejoin.amos.iot.mongodb.MongoSort;
import com.yeejoin.amos.iot.mongodb.dao.repository.EquipMetricDataRepository;
import com.yeejoin.amos.iot.mongodb.entity.EqpMetricData;
import com.yeejoin.amos.iot.mongodb.service.intfc.IEquipMetricDataService;
import com.yeejoin.amos.iot.mongodb.service.intfc.IMetricDataQueryService;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.common.authorization.Authorization;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 设备指标数据管理控制器
*
* @author as-youjun
*/
@RestController
@RequestMapping("/metricdata")
@Api(value = "metricdata", tags = {"设备指标数据管理"})
public class EquipMetricDataController extends BaseController {
@Autowired
private IEquipMetricDataService equipMetricDataService;
@Autowired
private IMetricDataQueryService metricDataQueryService;
@Autowired
private EquipMetricDataRepository equipMetricDataRepository;
@ApiOperation(httpMethod = "POST", value = "条件查询指标数据", notes = "条件查询指标数据")
@RequestMapping(value = "/findMetricData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse findMetricData(
@ApiParam(value = "参数", required = true) @RequestBody QueryMetricDataParam param) {
List<EqpMetricData> data = equipMetricDataService.findByParam(param);
return CommonResponseUtil.success(data);
}
@ApiOperation(httpMethod = "POST", value = "条件查询指标数据", notes = "条件查询指标数据")
@RequestMapping(value = "/pageByParam", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse pageByParam(
@ApiParam(value = "参数", required = true) @RequestBody QueryMetricDataParam param) {
List<EqpMetricData> data = equipMetricDataRepository.pageByParam(param);
return CommonResponseUtil.success(data);
}
@ApiOperation(httpMethod = "POST", value = "条件查询指标数据", notes = "条件查询指标数据")
@RequestMapping(value = "/testBasicQuery", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse testBasicQuery(
@ApiParam(value = "参数", required = true) @RequestBody QueryMetricDataParam param) {
List<EqpMetricData> data = equipMetricDataRepository.testBasicQuery(param);
return CommonResponseUtil.success(data);
}
@ApiOperation(httpMethod = "POST", value = "条件查询指标数据", notes = "条件查询指标数据")
@RequestMapping(value = "/testTextQuery", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse testTextQuery(
@ApiParam(value = "参数", required = true) @RequestBody QueryMetricDataParam param) {
List<EqpMetricData> data = equipMetricDataRepository.testTextQuery(param);
return CommonResponseUtil.success(data);
}
@ApiOperation(value = "通用条件[指标数据列表]", notes = "通用条件[指标数据列表]")
@PostMapping(value = "/listMongoData")
public CommonResponse listMongoData(
@ApiParam(value = "参数", required = true) @RequestBody MongoPageParam param) {
String collectionName = param.getCollectionName();
List<MongoCondition> conditions = param.getConditions();
Integer skip = param.getSkip();
Integer limit = param.getLimit();
List<MongoSort> sorts = param.getSorts();
List<JSONObject> data = metricDataQueryService.list(collectionName, conditions, skip, limit, sorts);
Long count = metricDataQueryService.count(collectionName, conditions);
return CommonResponseUtil.success(new CommonPage<>(data, null, count));
}
@ApiOperation(value = "通用条件[指标数据详情]", notes = "通用条件[指标数据详情]")
@PostMapping(value = "/findMongoData")
public CommonResponse findMongoData(
@ApiParam(value = "参数", required = true) @RequestBody MongoPageParam param) {
String collectionName = param.getCollectionName();
List<MongoCondition> conditions = param.getConditions();
JSONObject data = metricDataQueryService.findOne(collectionName, conditions);
return CommonResponseUtil.success(data);
}
@ApiOperation(value = "通用条件[统计指标数据]", notes = "通用条件[统计指标数据]")
@PostMapping(value = "/statisticMongoData")
public CommonResponse statisticMongoData(
@ApiParam(value = "参数", required = true) @RequestBody MongoPageParam param) {
String collectionName = param.getCollectionName();
List<MongoCondition> conditions = param.getConditions();
String statisticType = param.getStatisticType();
String groupBy = param.getGroupBy();
String sumBy = param.getSumBy();
List<MongoSort> sorts = param.getSorts();
List<JSONObject> data = metricDataQueryService.statistic(collectionName, conditions, statisticType, groupBy, sumBy, sorts);
return CommonResponseUtil.success(data);
}
}
package com.yeejoin.amos.iot.business.controller;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.iot.business.entity.EquipmentTemplate;
import com.yeejoin.amos.iot.business.param.QueryMetricDataParam;
import com.yeejoin.amos.iot.business.service.intfc.IHistoryDataService;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
/**
*
* <pre>
* 历史数据模块
* </pre>
*
* @author as-chenjiajun
* @version $Id: HistoricalDataController.java, v 0.1 2018年3月22日 上午9:44:49 as-chenjiajun Exp $
*/
@RestController
@RequestMapping("/history")
@Api(value = "history", tags = { "设备历史数据管理" })
public class HistoricalDataController extends BaseController
{
@Autowired
private IHistoryDataService iHistoryDataService;
@ApiOperation(httpMethod = "POST", value = "条件查询指标数据", notes = "条件查询指标数据")
@RequestMapping(value = "/history-condition-data", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse findMetricData(
@ApiParam(value = "参数", required = true) @RequestBody QueryMetricDataParam param) {
Map<String, List<Map<String, Object>>> data = iHistoryDataService.findByParam(param);
return CommonResponseUtil.success(data);
}
@ApiOperation(httpMethod = "GET", value = "查询设备数据", notes = "查询设备数据")
@RequestMapping(value = "/template-entity/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse fetchDeviceEntity(@ApiParam(value = "ID", required = true, defaultValue = "1")
@PathVariable Long id) {
EquipmentTemplate equipmentTemplate = iHistoryDataService.getDeviceById(id);
return CommonResponseUtil.success(equipmentTemplate);
}
}
/**
*
*/
package com.yeejoin.amos.iot.business.controller;
import com.yeejoin.amos.iot.business.entity.MetricData;
import com.yeejoin.amos.iot.business.entity.mybatis.MetricDataBo;
import com.yeejoin.amos.iot.business.entity.mybatis.MetricDataVo;
import com.yeejoin.amos.iot.business.param.MetricDataPageParam;
import com.yeejoin.amos.iot.business.service.intfc.IMetricDataService;
import com.yeejoin.amos.iot.business.service.intfc.IProtocolService;
import com.yeejoin.amos.iot.core.common.request.CommonPageable;
import com.yeejoin.amos.iot.core.common.response.CommonPage;
import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.common.authorization.Authorization;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Random;
/**
* 指标数据控制器
*
* @author as-youjun
*/
@RestController
@RequestMapping("/mericdata")
@Api(value = "mericdata", tags = {"指标数据管理"})
public class MetricDataController extends BaseController {
@Autowired
private IMetricDataService metricDataService;
@Autowired
private IProtocolService protocolService;
private Random random = new Random(100);
@ApiOperation(httpMethod = "GET", value = "测试保存指标数据", notes = "测试保存指标数据")
@RequestMapping(value = "/testSave", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse testSave() {
MetricData metricData = new MetricData();
long longValue = random.nextLong();
if (longValue < 0) {
longValue = 0 - longValue;
} else if (longValue == 0) {
longValue = 1;
}
longValue = random.nextLong();
if (longValue < 0) {
longValue = 0 - longValue;
} else if (longValue == 0) {
longValue = 1;
}
metricData.setCpblId(longValue);
longValue = random.nextLong();
if (longValue < 0) {
longValue = 0 - longValue;
} else if (longValue == 0) {
longValue = 1;
}
metricData.setEqpId(longValue);
longValue = random.nextLong();
if (longValue < 0) {
longValue = 0 - longValue;
} else if (longValue == 0) {
longValue = 1;
}
metricData.setEqpTmplId(longValue);
metricData.setExeTime(new Date());
metricData.setIsDelete(false);
metricDataService.save(metricData);
return CommonResponseUtil.success(metricData);
}
@ApiOperation(httpMethod = "POST", value = "分页查询指标数据", notes = "分页查询指标数据")
@RequestMapping(value = "/pageMetricData", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonPage<MetricDataVo> pageMetricData(
@ApiParam(value = "查询参数", required = true) @RequestBody MetricDataPageParam request,
@ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) {
if (pageable == null) {
pageable = new CommonPageable(1, DEFAULT_PAGE_SIZE);
}
request.setPageNumber(pageable.getPageNumber());
request.setPageSize(pageable.getPageSize());
request.setOffset(pageable.getPageNumber() * pageable.getPageSize());
CommonPage<MetricDataVo> page = metricDataService.pageMetricData(request);
return page;
}
@ApiOperation(httpMethod = "GET", value = "获取设备当前能力数据", notes = "获取设备当前能力数据")
@RequestMapping(value = "/equip/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getMetricData(@ApiParam(value = "设备ID", required = true) @PathVariable long id) {
List<DaoCriteria> daoCriterias = new ArrayList<DaoCriteria>();
DaoCriteria eqpId = new DaoCriteria();
eqpId.setPropertyName("eqpId");
eqpId.setOperator(QueryOperatorEnum.EQUAL.getName());
eqpId.setValue(id);
daoCriterias.add(eqpId);
List<MetricDataBo> list = metricDataService.findAllMetricDataByEquipId(id);
return CommonResponseUtil.success(list);
}
@ApiOperation(httpMethod = "GET", value = "获取设备当前能力数据", notes = "获取设备当前能力数据")
@RequestMapping(value = "/equip/{id}/{attrId}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getMetricData(@ApiParam(value = "设备ID", required = true) @PathVariable long id, @ApiParam(value = "设备能力ID", required = true) @PathVariable long attrId) {
List<DaoCriteria> daoCriterias = new ArrayList<DaoCriteria>();
DaoCriteria eqpId = new DaoCriteria();
eqpId.setPropertyName("eqpId");
eqpId.setOperator(QueryOperatorEnum.EQUAL.getName());
eqpId.setValue(id);
DaoCriteria cpblId = new DaoCriteria();
cpblId.setPropertyName("cpblId");
cpblId.setOperator(QueryOperatorEnum.EQUAL.getName());
cpblId.setValue(attrId);
daoCriterias.add(eqpId);
daoCriterias.add(cpblId);
List<MetricData> list = metricDataService.findAllMetricData(daoCriterias);
return CommonResponseUtil.success(list);
}
}
package com.yeejoin.amos.iot.business.controller;
import com.yeejoin.amos.iot.business.entity.Protocol;
import com.yeejoin.amos.iot.business.exceptions.IntfcException;
import com.yeejoin.amos.iot.business.exceptions.ProtocolException;
import com.yeejoin.amos.iot.business.service.intfc.IProtocolService;
import com.yeejoin.amos.iot.core.common.request.CommonPageable;
import com.yeejoin.amos.iot.core.common.request.CommonRequest;
import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* <pre>
* 协议控制器
* </pre>
*
* @author as-lixiangyang
* @version $Id: ProtocolController.java, v 0.1 2018年1月29日 上午10:48:00 as-lixiangyang Exp $
*/
@RestController
@RequestMapping("/protocol")
@Api(value = "protocol", tags = {"协议管理"})
public class ProtocolController extends BaseController {
private final static Logger log = LoggerFactory.getLogger(ProtocolController.class);
@Autowired
private IProtocolService protocolService;
/**
* <pre>
* 新增协议/编辑基本信息/编辑脚本信息
* </pre>
*
* @param protocol 协议实体
* @return CommonResponse
* @throws ProtocolException
*/
@ApiOperation(httpMethod = "POST", value = "新增协议", notes = "新增协议")
@RequestMapping(value = "/save", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse save(@ApiParam(value = "新增协议数据", required = true) @RequestBody Protocol protocol) throws ProtocolException {
try {
protocol.setOrgCode(getCompanyOrgCode());
//通过实体id是否为空区分新增还是修改,为空则为新增,否则为修改
protocolService.saveProtocol(protocol);
return CommonResponseUtil.success();
} catch (Exception e) {
log.error(e.getMessage(), e);
return CommonResponseUtil.failure("新增协议数据失败!");
}
}
/**
* <pre>
* 分页查询协议数据
* </pre>
*
* @param requests 查询条件集合,可以为空
* @param pageable 分页参数,默认pageNumber=0&pageSize=10
* @return CommonResponse
*/
@ApiOperation(httpMethod = "POST", value = "分页查询协议数据", notes = "分页查询协议数据")
@RequestMapping(value = "/list", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse queryProtocolList(
@ApiParam(value = "查询参数", required = true) @RequestBody(required = false) List<CommonRequest> requests,
@ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) {
List<Protocol> result = new ArrayList<Protocol>();
//如果查询参数中无visibility且当前用户ID不为1(superadmin),则需要查询公共协议
boolean isquery = true;
boolean isPublic = true;
if (requests != null) {
for (CommonRequest commonRequest : requests) {
if (commonRequest.getName() != null && commonRequest.getName().equals("visibility")) {
isquery = false;
isPublic = commonRequest.getValue().equals("0");
break;
}
}
}
if (isquery && !"SUPER".equals(getUserInfo().getUserId())) {
List<DaoCriteria> daoCriterias = new ArrayList<DaoCriteria>();
DaoCriteria visDaoCriteria = new DaoCriteria();
visDaoCriteria.setPropertyName("visibility");
visDaoCriteria.setOperator(QueryOperatorEnum.EQUAL.getName());
visDaoCriteria.setValue(0);
daoCriterias.add(visDaoCriteria);
// daoCriterias.add(new DaoCriteria("orgCode", QueryOperatorEnum.LIKE.getName(), getCompanyOrgCode() + "%"));
result.addAll(protocolService.findAll(daoCriterias));
// return CommonResponseUtil.success(result);
}
//根据条件查询
List<DaoCriteria> criterias = buildDaoCriterias(requests);
if (!isPublic) {
criterias.add(new DaoCriteria("orgCode", QueryOperatorEnum.LIKE.getName(), getCompanyOrgCode() + "%"));
}
criterias.add(new DaoCriteria("createTime", QueryOperatorEnum.ORDER_BY.getName(), "DESC"));
result.addAll(protocolService.findAll(criterias));
return CommonResponseUtil.success(result);
}
/**
* <pre>
* 根据协议ID获取详情数据
* </pre>
*
* @param id 协议ID
* @return CommonResponse
*/
@ApiOperation(httpMethod = "GET", value = "根据协议ID获取详情数据", notes = "根据协议ID获取详情数据")
@RequestMapping(value = "/{id}/detail", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryProtocolDetail(
@ApiParam(value = "协议ID", required = true) @PathVariable("id") Long id) {
Protocol protocol = protocolService.queryById(id);
return CommonResponseUtil.success(protocol);
}
/**
* <pre>
* 删除协议
* </pre>
*
* @param id 协议ID
* @return CommonResponse
* @throws IntfcException
*/
@ApiOperation(httpMethod = "DELETE", value = "删除协议 ", notes = "删除协议 ")
@RequestMapping(value = "/delete/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.DELETE)
public CommonResponse delProtocol(
@ApiParam(value = "协议ID", required = true) @PathVariable Long id) throws IntfcException {
protocolService.delProtocol(id);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "GET", value = "协议统计", notes = "协议统计")
@RequestMapping(value = "/statistics", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse countProtocolInfo() {
List<DaoCriteria> daoCriteria = buildDaoCriteriasNoParam();
Map<String, Long> intfcCount = protocolService.countProtocolInfo(daoCriteria);
return CommonResponseUtil.success(intfcCount);
}
}
package com.yeejoin.amos.iot.business.controller;
import com.yeejoin.amos.iot.business.entity.Protocol;
import com.yeejoin.amos.iot.business.exceptions.ProtocolException;
import com.yeejoin.amos.iot.business.protocol.ReportData;
import com.yeejoin.amos.iot.business.service.intfc.IProtocolService;
import com.yeejoin.amos.iot.business.vo.ProtocolVo;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/reportdata")
@Api(value = "reportdata", tags = {"上报数据管理"})
public class ReportDataController extends BaseController {
@Resource
private IProtocolService protocolService;
@ApiOperation(httpMethod = "POST", value = "缓存上报数据", notes = "缓存上报数据")
@RequestMapping(value = "/add", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse add(@ApiParam(value = "参数", required = true) @RequestBody ReportData reportData) {
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "POST", value = "获取上报数据", notes = "获取上报数据")
@RequestMapping(value = "/getByKey", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse getByKey(@ApiParam(value = "参数", required = true) @RequestBody String key) {
ReportData reportData = new ReportData();
return CommonResponseUtil.success(reportData);
}
@RequestMapping(value = "/addProtocol", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse addProtocol(@ApiParam(value = "参数", required = true) @RequestBody Protocol protocol) throws ProtocolException {
protocolService.saveProtocol(protocol);
return CommonResponseUtil.success();
}
@RequestMapping(value = "/getProtocol", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse getProtocol(@ApiParam(value = "参数", required = true) @RequestBody Long id) {
ProtocolVo protocol = protocolService.findById(id);
return CommonResponseUtil.success(protocol);
}
}
\ No newline at end of file
package com.yeejoin.amos.iot.business.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.iot.business.entity.NodeVo;
import com.yeejoin.amos.iot.business.entity.RuleNode;
import com.yeejoin.amos.iot.business.param.NodeVoParam;
import com.yeejoin.amos.iot.business.param.RuleConfigParam;
import com.yeejoin.amos.iot.business.param.RuleDataParam;
import com.yeejoin.amos.iot.business.service.intfc.INodeVoService;
import com.yeejoin.amos.iot.business.service.intfc.IRuleNodeService;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.common.response.TreeResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.common.authorization.Authorization;
/**
*
* <pre>
* 规则部署模块
* </pre>
*
* @author as-chenjiajun
* @version $Id: RuleDeployController.java, v 0.1 2018年4月10日 下午4:14:17 as-chenjiajun Exp $
*/
@RestController
@RequestMapping("/ruledeploy")
@Api(value = "ruledeploy", tags = { "规则部署模块" })
public class RuleDeployController extends BaseController
{
@Autowired
private INodeVoService nodeVoService;
@Autowired
private IRuleNodeService IRuleNodeService;
@ApiOperation(httpMethod = "POST", value = "新增/编辑规则部署", notes = "新增/编辑规则部署")
@RequestMapping(value = "/rule-data", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse addEditRuleNodeAndLinks(
@ApiParam(value = "规则部署参数", required = true) @RequestBody RuleDataParam ruleData)
{
nodeVoService.addEditRuleNodeAndLinks(ruleData);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "DELETE", value = "删除node", notes = "删除node")
@RequestMapping(value = "/nodevo/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.DELETE)
public CommonResponse deleteNode(
@ApiParam(value = "nodeID", required = true) @PathVariable String id)
{
nodeVoService.deleteNode(id);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "PUT", value = "编辑node", notes = "编辑node")
@RequestMapping(value = "/nodevoname", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse editNodeName(
@ApiParam(value = "node参数", required = true) @RequestBody NodeVo nodeVo)
{
nodeVoService.editNodeName(nodeVo);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "POST", value = "新增node", notes = "新增node")
@RequestMapping(value = "/nodevo", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse addNode(
@ApiParam(value = "node参数", required = true) @RequestBody NodeVoParam nodeVo)
{
nodeVoService.addNode(nodeVo);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "PUT", value = "编辑node", notes = "编辑node")
@RequestMapping(value = "/nodevo", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse editNode(
@ApiParam(value = "node配置参数", required = true) @RequestBody RuleConfigParam param)
{
nodeVoService.editNode(param);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "GET", value = "获取node", notes = "获取node")
@RequestMapping(value = "/nodevo/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse getNode(
@ApiParam(value = "nodeID", required = true) @PathVariable String id)
{
RuleConfigParam ruleConfigParam = nodeVoService.fetchNode(id);
return CommonResponseUtil.success(ruleConfigParam);
}
/**
*
* <pre>
* 获取规则节点元素
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取规则节点元素", notes = "获取规则节点元素")
@RequestMapping(value = "/elements", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
@Authorization(ingore = true)
public CommonResponse getRuleElements()
{
List<RuleNode> ruleNodeList = IRuleNodeService.findAll();
List<TreeResponse> treeResponseList = new ArrayList<TreeResponse>();
Map<String, List<TreeResponse>> subTreeRespMap = new HashMap<String, List<TreeResponse>>();
//转换为树节点
for (RuleNode ruleNode : ruleNodeList)
{
TreeResponse treeResponse = new TreeResponse();
treeResponse.setKey(ruleNode.getId());
treeResponse.setValue(ruleNode.getValue());
treeResponse.setLabel(ruleNode.getDisplayName());
treeResponse.setType(ruleNode.getType());
treeResponse.setIcon(ruleNode.getIcon());
treeResponse.setObject(ruleNode);
if (ruleNode.getParentId() == null)
{
treeResponseList.add(treeResponse);
}else
{
List<TreeResponse> treeResponses = subTreeRespMap.get(ruleNode.getParentId());
if (treeResponses == null)
{
treeResponses = new ArrayList<TreeResponse>();
}
treeResponses.add(treeResponse);
subTreeRespMap.put(ruleNode.getParentId(), treeResponses);
}
}
//填充子节点
for (TreeResponse treeResponse : treeResponseList)
{
treeResponse.setChildren(subTreeRespMap.get(treeResponse.getKey()));
}
return CommonResponseUtil.success(treeResponseList);
}
}
package com.yeejoin.amos.iot.business.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.iot.business.entity.Rule;
import com.yeejoin.amos.iot.business.param.RuleDataParam;
import com.yeejoin.amos.iot.business.param.RulePageParam;
import com.yeejoin.amos.iot.business.service.intfc.IRuleService;
import com.yeejoin.amos.iot.core.common.response.CommonPage;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.common.authorization.Authorization;
import com.yeejoin.amos.security.common.context.CurrentAuthentication;
import com.yeejoin.amos.security.common.model.UserModel;
/**
*
* <pre>
* 规则库管理模块
* </pre>
*
* @author as-chenjiajun
* @version $Id: RuleManageController.java, v 0.1 2018年4月10日 下午4:13:57 as-chenjiajun Exp $
*/
@RestController
@RequestMapping("/rulemanage")
@Api(value = "rulemanage", tags = { "规则库管理模块" })
public class RuleManageController extends BaseController
{
@Autowired
private IRuleService ruleService;
@Authorization(ingore= true)
@ApiOperation(httpMethod = "GET", value = "根据ID查询规则", notes = "根据ID查询规则")
@RequestMapping(value = "/rule/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse fetchRuleEntity(
@ApiParam(value = "ID", required = true, defaultValue = "1") @PathVariable String id)
{
RuleDataParam result = ruleService.fetchRuleDataByID(id);
return CommonResponseUtil.success(result);
}
@ApiOperation(httpMethod = "POST", value = "查询规则数据", notes = "查询规则数据")
@RequestMapping(value = "/rule-list", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse fetchRuleEntityList(
@ApiParam(value = "查询参数", required = true) @RequestBody RulePageParam request)
{
String orgCode = request.getOrgCode();
//如果过滤条件为空,则查询登录用户及子用户的数据
if (orgCode == null)
{
request.setOrgCode(getCompanyOrgCode());
}
CommonPage<Rule> page = ruleService
.pageRuleData(request);
return CommonResponseUtil.success(page);
}
@ApiOperation(httpMethod = "POST", value = "保存规则", notes = "保存规则")
@RequestMapping(value = "/rule", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse saveRuleEntity(
@ApiParam(value = "规则对象", required = true) @RequestBody Rule rule)
{
try {
rule = ruleService.saveRuleEntity(rule);
return CommonResponseUtil.success(rule);
} catch (Exception e) {
return CommonResponseUtil.failure(getErrorMessage(e));
}
}
@ApiOperation(httpMethod = "PUT", value = "编辑规则", notes = "编辑规则")
@RequestMapping(value = "/rule", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse editRuleEntity(
@ApiParam(value = "规则对象", required = true) @RequestBody Rule rule)
{
try {
rule = ruleService.editRuleEntity(rule);
return CommonResponseUtil.success(rule);
} catch (Exception e) {
return CommonResponseUtil.failure(getErrorMessage(e));
}
}
@ApiOperation(httpMethod = "PUT", value = "启用/停用规则", notes = "启用/停用规则")
@RequestMapping(value = "/rule-enabled/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse startOrStopRule(
@ApiParam(value = "规则id集合", required = true) @PathVariable String id)
{
ruleService.startOrStopRule(id);
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "PUT", value = "启用/停用全部规则", notes = "启用/停用全部规则")
@RequestMapping(value = "/all-rule-enabled/{status}", produces = "application/json;charset=UTF-8", method = RequestMethod.PUT)
public CommonResponse startOrStopRules(
@ApiParam(value = "规则id集合", required = true) @PathVariable Boolean status)
{
ruleService.startOrStopRules(status, getCompanyOrgCode());
return CommonResponseUtil.success();
}
@ApiOperation(httpMethod = "DELETE", value = "删除规则", notes = "删除规则")
@RequestMapping(value = "/rule/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.DELETE)
public CommonResponse deleteRule(
@ApiParam(value = "设备ID", required = true) @PathVariable String id)
{
ruleService.deleteRule(id);
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.iot.business.controller;
import com.yeejoin.amos.iot.business.param.ReginParams;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping(value = "/safe")
@Api(tags = "公司选择api")
public class SafetyController extends BaseController {
/**
* 保存登陆用户选择公司信息
*/
@ApiOperation(value = " 保存登陆用户选择公司信息", notes = " 保存登陆用户选择公司信息")
@PostMapping(value = "/save/curCompany")
public CommonResponse saveCurCompany(@RequestBody ReginParams reginParams) {
this.saveSelectedOrgInfo(reginParams);
return CommonResponseUtil.success();
}
}
package com.yeejoin.amos.iot.business.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.iot.business.entity.Section;
import com.yeejoin.amos.iot.business.param.SectionParam;
import com.yeejoin.amos.iot.business.service.intfc.ISectionService;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
*
* <pre>
* 插件管理
* </pre>
*
* @author as-chenjiajun
* @version $Id: SectionController.java, v 0.1 2018年6月27日 下午2:13:28 as-chenjiajun Exp $
*/
@RestController
@RequestMapping("/section")
@Api(value = "section", tags = { "插件管理" })
public class SectionController extends BaseController
{
@Autowired
private ISectionService iSectionService;
@ApiOperation(httpMethod = "POST", value = "查询插件数据", notes = "查询插件数据")
@RequestMapping(value = "/sections-entitys", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
public CommonResponse fetchSubgraphInfos(@RequestBody SectionParam param) {
param.setOrgCode(getCompanyOrgCode());
List<Section> recommend = iSectionService.getSectionsByCondition(param,5);
param.setIsRecommend(null);
List<Section> last = iSectionService.getSectionsByCondition(param,5);
Map<String, List<Section>> map = new HashMap<String, List<Section>>();
map.put("last", last);
map.put("recommend", recommend);
return CommonResponseUtil.success(map);
}
}
package com.yeejoin.amos.iot.business.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.iot.business.constants.SystemDicType;
import com.yeejoin.amos.iot.business.dao.repository.IDicDao;
import com.yeejoin.amos.iot.business.entity.Dic;
import com.yeejoin.amos.iot.business.enums.AttributeType;
import com.yeejoin.amos.iot.business.enums.CapabilityType;
import com.yeejoin.amos.iot.business.enums.DataType;
import com.yeejoin.amos.iot.business.enums.Visibility;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
*
* <pre>
* 枚举、系统字典控制器
* </pre>
*
* @author as-shibaobao
* @version $Id: SysDicController.java, v 0.1 2018年1月29日 上午11:31:48 as-shibaobao Exp $
*/
@RestController
@RequestMapping("/dic")
@Api(value = "dic", tags = { "系统字典数据、枚举管理" })
public class SysDicController extends BaseController {
/**
* 系统字典无业务逻辑,直接访问DAO
*/
@Autowired
private IDicDao dicDao;
/**
*
* <pre>
* 获取设备原型行业种类
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取设备原型行业种类", notes = "获取设备原型行业种类")
@RequestMapping(value = "/equiptemplate-industry", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryEquipTemplateIndustry() {
List<Dic> comms = dicDao.findByType(SystemDicType.EquipTemplateIndustry);
return CommonResponseUtil.success(comms);
}
/**
*
* <pre>
* 获取通讯方式
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取通讯方式", notes = "获取通讯方式")
@RequestMapping(value = "/community", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryCommunityProtocol() {
List<Dic> comms = dicDao.findByType(SystemDicType.CommunityProtocol);
return CommonResponseUtil.success(comms);
}
/**
*
* <pre>
* 获取数据类型
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取数据类型", notes = "获取数据类型")
@RequestMapping(value = "/data-type", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryDataType() {
List<Map<String,Object>> list = new ArrayList<>();
for (DataType dt : DataType.values())
{
Map<String,Object> m = new HashMap<>();
m.put("code", dt.getValue());
m.put("name", dt.getName());
list.add(m);
}
return CommonResponseUtil.success(list);
}
/**
*
* <pre>
* 获取属性类型
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取属性类型", notes = "获取属性类型")
@RequestMapping(value = "/attr-type", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryAttributeType() {
List<Map<String,Object>> list = new ArrayList<>();
for (AttributeType at : AttributeType.values())
{
Map<String,Object> m = new HashMap<>();
m.put("code", at.getValue());
m.put("name", at.getName());
list.add(m);
}
return CommonResponseUtil.success(list);
}
/**
*
* <pre>
* 获取可见枚举性
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取可见枚举性", notes = "获取可见枚举性")
@RequestMapping(value = "/visibility", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryVisibility() {
List<Map<String,Object>> list = new ArrayList<>();
for (Visibility vis : Visibility.values())
{
Map<String,Object> m = new HashMap<>();
m.put("code", vis.getValue());
m.put("name", vis.getName());
list.add(m);
}
return CommonResponseUtil.success(list);
}
/**
*
* <pre>
* 获取脚本语言类型
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取脚本语言类型", notes = "获取脚本语言类型")
@RequestMapping(value = "/script-type", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryScriptLanguage() {
List<Dic> scripts = dicDao.findByType(SystemDicType.ScriptLang);
return CommonResponseUtil.success(scripts);
}
/**
*
* <pre>
* 获取能力分类
* </pre>
*
* @return
*/
@ApiOperation(httpMethod = "GET", value = "获取能力分类", notes = "获取能力分类")
@RequestMapping(value = "/capability-type", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse queryCapabilityType() {
List<Map<String,Object>> list = new ArrayList<>();
for (CapabilityType ct : CapabilityType.values())
{
Map<String,Object> m = new HashMap<>();
m.put("code", ct.getValue());
m.put("name", ct.getName());
list.add(m);
}
return CommonResponseUtil.success(list);
}
}
/**
*
*/
package com.yeejoin.amos.iot.business.controller.param;
import java.util.Map;
import com.yeejoin.amos.iot.business.entity.Equipment;
/**
* 设备测试参数
*
* @author as-youjun
*
*/
public class TestEqpParam {
/**
* 基本信息
*/
private Equipment basicInfo;
/**
* 配置数据
*/
private Map<String, Object> propertyMap;
/**
* 监测方式/周期
*/
private Map<String, Object> taskParam;
/**
* @return the basicInfo
*/
public Equipment getBasicInfo() {
return basicInfo;
}
/**
* @param basicInfo
* the basicInfo to set
*/
public void setBasicInfo(Equipment basicInfo) {
this.basicInfo = basicInfo;
}
/**
* @return the propertyMap
*/
public Map<String, Object> getPropertyMap() {
return propertyMap;
}
/**
* @param propertyMap
* the propertyMap to set
*/
public void setPropertyMap(Map<String, Object> propertyMap) {
this.propertyMap = propertyMap;
}
/**
* @return the taskParam
*/
public Map<String, Object> getTaskParam() {
return taskParam;
}
/**
* @param taskParam
* the taskParam to set
*/
public void setTaskParam(Map<String, Object> taskParam) {
this.taskParam = taskParam;
}
}
/**
*
*/
package com.yeejoin.amos.iot.business.dao;
import java.util.List;
import org.apache.log4j.Logger;
/**
* hql助手类
*
* @author as-youjun
*
*/
public class DaoHelper {
/**
* 构造方法
*/
private DaoHelper() {
Logger.getLogger(this.getClass()).debug("constructor");
}
/**
* 转换成in语句
*
* @param objs
* @return
*/
public static String buildInStr(List<?> objs) {
StringBuilder sb = new StringBuilder();
objs.forEach(item -> {
if ((item instanceof Integer) || (item instanceof Long)) {
sb.append(item.toString()).append(",");
} else if (item instanceof String) {
sb.append("'").append(item.toString()).append("',");
}
});
String s = sb.toString();
s = s.substring(0, s.length() - 1);
return s;
}
/**
* 构造in条件
*
* @param size
* @return
*/
public static String buildInStr(int size) {
if (size <= 0) {
return "";
}
StringBuilder sb = new StringBuilder();
sb.append("(");
for (int i = 0; i < size; i++) {
sb.append("?,");
}
String s = sb.toString();
s = s.substring(0, s.length() - 1);
s += ")";
return s;
}
/**
* 构建查询数量结果sql
*
* @return
*/
public static String buildCountResultSql() {
return "select count(1) as totalNum ";
}
}
//package com.yeejoin.amos.iot.business.dao;
//
//import com.google.common.collect.Lists;
//import com.google.common.collect.Maps;
//import com.yeejoin.amos.op.core.common.query.DaoCriteria;
//import com.yeejoin.amos.op.core.common.query.QueryOperatorEnum;
//import org.hibernate.jpa.criteria.CriteriaBuilderImpl;
//import org.hibernate.jpa.criteria.predicate.InPredicate;
//import org.springframework.data.jpa.domain.Specification;
//
//import javax.persistence.criteria.CriteriaBuilder;
//import javax.persistence.criteria.CriteriaQuery;
//import javax.persistence.criteria.Order;
//import javax.persistence.criteria.Predicate;
//import javax.persistence.criteria.Root;
//import java.util.Iterator;
//import java.util.List;
//import java.util.Map;
//
//public class IotSpecification<T> implements Specification<T> {
// private Map<String, List<DaoCriteria>> criterias;
// private List<DaoCriteria> daoCriterias;
// private Map<String, List<String>> orderbys;
//
// public IotSpecification(List<DaoCriteria> daoCriterias) {
// this.daoCriterias = daoCriterias;
// }
//
// @Override
// public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
// if (this.daoCriterias == null) {
// return builder.and(new Predicate[0]);
// } else {
// this.criterias = this.classify(this.daoCriterias);
// List<Predicate> conditions = Lists.newArrayList();
// Iterator var5 = this.criterias.keySet().iterator();
//
// while (true) {
// while (var5.hasNext()) {
// String key = (String) var5.next();
// List<DaoCriteria> daoCriterias = this.criterias.get(key);
// if (daoCriterias.size() > 1) {
// List<Predicate> sameConditions = Lists.newArrayList();
// Iterator var16 = daoCriterias.iterator();
//
// while (var16.hasNext()) {
// DaoCriteria daoCriteria = (DaoCriteria) var16.next();
// Predicate predicate = this.createPredicate(root, builder, daoCriteria);
// if (null == predicate) {
// throw new IllegalArgumentException("查询条件生成错误!");
// }
//
// sameConditions.add(predicate);
// }
//
// Predicate[] predicates = new Predicate[sameConditions.size()];
// conditions.add(builder.or((Predicate[]) sameConditions.toArray(predicates)));
// } else {
// Iterator var8 = daoCriterias.iterator();
//
// while (var8.hasNext()) {
// DaoCriteria daoCriteria = (DaoCriteria) var8.next();
// Predicate predicate = this.createPredicate(root, builder, daoCriteria);
// if (null != predicate) {
// conditions.add(predicate);
// }
// }
// }
// }
// Predicate[] predicates = new Predicate[conditions.size()];
// query.where(builder.and((Predicate[]) conditions.toArray(predicates)));
// List<Order> orders = Lists.newArrayList();
// this.orderbys.keySet().forEach((keyx) -> {
// if (keyx.toLowerCase().equals("asc") && !(this.orderbys.get(keyx)).isEmpty()) {
// (this.orderbys.get(keyx)).forEach(propertyName -> orders.add(builder.asc(root.get(propertyName))));
// } else if (keyx.toLowerCase().equals("desc") && !(this.orderbys.get(keyx)).isEmpty()) {
// (this.orderbys.get(keyx)).forEach((propertyName) -> orders.add(builder.desc(root.get(propertyName))));
// }
// });
// query.orderBy(orders);
// return query.getRestriction();
// }
// }
// }
//
// private Map<String, List<DaoCriteria>> classify(List<DaoCriteria> criteraList) {
// Map<String, List<DaoCriteria>> criteraType = Maps.newHashMap();
// this.orderbys = Maps.newHashMap();
// this.orderbys.put("asc", Lists.newArrayList());
// this.orderbys.put("desc", Lists.newArrayList());
// if (criteraList != null && criteraList.size() > 0) {
// Iterator var3 = criteraList.iterator();
// while (var3.hasNext()) {
// DaoCriteria daoCriteria = (DaoCriteria) var3.next();
// if (daoCriteria.getOperator().equals(QueryOperatorEnum.ORDER_BY.getName())) {
// (this.orderbys.get(daoCriteria.getValue().toString().toLowerCase())).add(daoCriteria.getPropertyName());
// } else {
// List<DaoCriteria> temp = criteraType.get(daoCriteria.getPropertyName());
// if (temp == null) {
// temp = Lists.newArrayList();
// criteraType.put(daoCriteria.getPropertyName(), temp);
// }
// temp.add(daoCriteria);
// }
// }
// }
// return criteraType;
// }
//
// private Predicate createPredicate(Root<T> root, CriteriaBuilder builder, DaoCriteria daoCriteria) {
// String name = daoCriteria.getPropertyName();
// Object value = daoCriteria.getValue();
// String operator = daoCriteria.getOperator();
// if (name.equals("orgCode")) {
// return builder.like(root.get(name).as(String.class), value + "%");
// }
// if (operator.equals(QueryOperatorEnum.EQUAL.getName())) {
// return builder.equal(root.get(name).as(String.class), value);
// } else if (operator.equals(QueryOperatorEnum.LIKE.getName())) {
// return builder.like(root.get(name).as(String.class), value.toString());
// } else if (operator.equals(QueryOperatorEnum.NOT_IN.getName())) {
// return builder.not(new InPredicate((CriteriaBuilderImpl) builder, root.get(name).as(String.class), new Object[]{value}));
// } else if (operator.equals(QueryOperatorEnum.BIGGER.getName())) {
// return builder.greaterThan(root.get(name).as(String.class), value.toString());
// } else if (operator.equals(QueryOperatorEnum.BIGGER_EQUAL.getName())) {
// return builder.greaterThanOrEqualTo(root.get(name).as(String.class), value.toString());
// } else if (operator.equals(QueryOperatorEnum.LESS.getName())) {
// return builder.lessThan(root.get(name).as(String.class), value.toString());
// } else if (operator.equals(QueryOperatorEnum.LESS_EQUAL.getName())) {
// return builder.lessThanOrEqualTo(root.get(name).as(String.class), value.toString());
// } else if (operator.equals(QueryOperatorEnum.NOT_EQUAL.getName())) {
// return builder.notEqual(root.get(name).as(String.class), value);
// } else {
// return operator.equals(QueryOperatorEnum.IN.getName()) ? builder.and(new Predicate[]{new InPredicate((CriteriaBuilderImpl) builder, root.get(name).as(String.class), new Object[]{value})}) : null;
// }
// }
//}
package com.yeejoin.amos.iot.business.dao.mapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <pre>
* 任务管理操作mapper接口
* </pre>
*
* @author as-xuwei
* @version $Id: MonitorRuleMapper.java, v 0.1 2018年03月09日 上午11:52:39 as-xuwei Exp $
*/
@Mapper
public interface AlarmMapper {
/**
* 根据告警id消除告警信息
*
* @param map
* @return
*/
void eliminateAlarmByIds(Map<String, Object> map);
/**
* 根据告警id清除告警信息
*
* @param map
* @return
*/
void deleteAlarmByIds(Map<String, Object> map);
Map<String, Object> alarmStaticByStatus(String orgCode);
List<HashMap<String, Object>> queryAlarmByEquipAttr(HashMap<String, Object> attrName);
}
package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.mybatis.CapacityAttrBo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 设备能力参数
*
* @author as-xukaiqiang
*/
@Mapper
public interface CapacityAttrMapper {
List<CapacityAttrBo> listByCapacityId(Long capacityId);
}
package com.yeejoin.amos.iot.business.dao.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import com.yeejoin.amos.iot.business.entity.mybatis.MetricDataVo;
import com.yeejoin.amos.iot.netty.customer.entity.CustomerData;
/**
* 设备接口和协议操作mapper
*/
@Mapper
public interface Capacity_Intfc_protocolMapper
{
/**
*
* <pre>
* 删除能力接口和协议关系数据
* </pre>
*
* @param capid
*/
public void delCaIntfProRelation(Long capid);
public List<MetricDataVo> findMetricDatas(CustomerData customerData);
}
/**
* NewHeight.com Inc.
* Copyright (c) 2008-2010 All Rights Reserved.
*/
package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.mybatis.CapacityInterfaceDataVo;
import com.yeejoin.amos.iot.business.entity.mybatis.CapacityPropertyDataVo;
import com.yeejoin.amos.iot.business.entity.mybatis.DeviceInterfaceDataVo;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpCount;
import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentBo;
import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentTemplateVo;
import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentVo;
import com.yeejoin.amos.iot.business.entity.mybatis.IntfcAttrBo;
import com.yeejoin.amos.iot.business.param.DevicePageParam;
import com.yeejoin.amos.iot.business.param.EqpTemplPageParam;
import com.yeejoin.amos.iot.business.param.QueryEqpCountParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* <pre>
* 设备操作mapper接口
* </pre>
*
* @author as-shibaobao
* @version $Id: DeviceMapper.java, v 0.1 2018年1月31日 下午3:45:39 as-shibaobao Exp
* $
*/
@Mapper
public interface DeviceMapper {
/**
* <pre>
* 获取设备总数量
* </pre>
*
* @param param
* @return
*/
long countDeviceData(DevicePageParam param);
/**
* 获取设备列表
*
* @param param
* @return
*/
List<EquipmentTemplateVo> pageDeviceData(DevicePageParam param);
/**
* <pre>
* 根据设备ID获取设备接口信息
* </pre>
*
* @param id
* @return
*/
List<DeviceInterfaceDataVo> getDeviceInterfaceById(Long id);
/**
* <pre>
* 根据能力id查询能力接口
* </pre>
*
* @param id
* @return
*/
List<CapacityInterfaceDataVo> getCapacityInterfaceByCapId(Long capId);
/**
* <pre>
* 根据能力id查询能力属性
* </pre>
*
* @param id
* @return
*/
List<CapacityPropertyDataVo> getCapacityPropertyById(Long id);
/**
* 查询能力集合对应的能力属性
*
* @param cpblIds
* @return
*/
List<CapacityPropertyDataVo> getCapacityPropertyByCpblIds(List<Long> cpblIds);
/**
* 根据能力属性id集合查询能力属性
*
* @param ids
* @return
*/
List<CapacityPropertyDataVo> getCapacityPropertyByCpblProIds(List<Long> ids);
/**
* 查询接口集合对应的接口属性
*
* @param intfcIds
* @return
*/
List<IntfcAttrBo> findIntfcAttrByIntfcIds(List<Long> intfcIds);
List<EquipmentBo> findEqpBySubgraphId(@Param("subgraphId") Long subgraphId, @Param("orgCode") String orgCode);
/**
* 查询设备数量
*
* @param param
* @return
*/
List<EqpCount> findEqpCount(QueryEqpCountParam param);
/**
* 查询设备类型
*
* @param param
* @return
*/
List<EquipmentTemplateVo> getEqpTmpModelByOrgCode(String orgCode);
/**
* 分页查询设备
*
* @param param
* @return
*/
List<EquipmentVo> pageDeviceDataByMybatis(EqpTemplPageParam requestParam);
/**
* 分页查询计算总数
*
* @param param
* @return
*/
long countDeviceDataByMybatis(EqpTemplPageParam requestParam);
List<EquipmentVo> listByOrgCodeAndTmplId(@Param("orgCode") String orgCode, @Param("eqpTmplId") Long eqpTmplId);
List<Map> findTempAttr(Long eqpId);
List<Map> qryEqpCountByTemplAttrs(@Param("orgCode") String orgCode, @Param("attrNames") List<String> attrName);
}
package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 设备基础参数
*
* @author as-xukaiqiang
*/
@Mapper
public interface EqpTmplAttrMapper {
/**
* 根据模板编号获取指定字段集合
*/
List<EqpTmplAttributeBo> listByNameAndEqpTmplIds(@Param(value = "name") String name, @Param(value = "eqpTmplIds") List<Long> eqpTmplIds);
/**
* 根据模板编号获取指定字段集合
*/
List<EqpTmplAttributeBo> listByEqpTmplId(@Param(value = "eqpTmplId") Long eqpTmplId);
}
package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo;
import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentTemplateVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 设备模板基础参数
*
* @author as-xukaiqiang
*/
@Mapper
public interface EqpTmplMapper {
/**
* 根据模板编号获取指定字段集合
*/
EquipmentTemplateVo getByModel(String name);
}
package com.yeejoin.amos.iot.business.dao.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
/**
*
* <pre>
* 设备接口操作mapper
* </pre>
*
* @author as-shibaobao
* @version $Id: IntfcMapper.java, v 0.1 2018年1月29日 上午9:40:59 as-shibaobao Exp $
*/
@Mapper
public interface IntfcMapper
{
/**
*
* <pre>
* 批量删除接口
* </pre>
*
* @param ids 接口ID集合
*/
public void batchDelIntfc(List<Long> ids);
}
/**
* NewHeight.com Inc.
* Copyright (c) 2008-2010 All Rights Reserved.
*/
package com.yeejoin.amos.iot.business.dao.mapper;
import java.util.List;
import java.util.Map;
import com.yeejoin.amos.iot.business.entity.mybatis.MetricDataBo;
import org.apache.ibatis.annotations.Mapper;
import com.yeejoin.amos.iot.business.entity.mybatis.MetricDataVo;
import com.yeejoin.amos.iot.business.param.MetricDataPageParam;
/**
* 消防单位装备查询mapper
*
* @author as-youjun
*
*/
@Mapper
public interface MetricDataMapper {
/**
* 获取指标数据数量
*
* @return
*/
long countMetricData();
/**
* 分页查询指标数据
*
* @param param
* @return
*/
List<MetricDataVo> pageMetricData(MetricDataPageParam pageParam);
MetricDataVo getRealTimeData(Map<String, Object> map);
List<MetricDataBo> findAllMetricDataByEquipId(long id);
}
/**
*
*/
package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.Node;
import com.yeejoin.amos.iot.business.entity.Subgraph;
import com.yeejoin.amos.iot.business.entity.mybatis.*;
import com.yeejoin.amos.iot.business.param.*;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 采集/控制/诊断等核心业务查询数据mapper
*
* @author as-youjun
*/
@Mapper
public interface MonitorMapper {
/**
* 查询监测设备数量
*
* @param param
* @return
*/
long countMonitorEquipment(QueryMonitorEqpParam param);
/**
* 查询监测设备
*
* @param param
* @return
*/
List<EquipmentBo> findMonitorEquipment(QueryMonitorEqpParam param);
/**
* 查询设备模板的能力
*
* @param param
* @return
*/
List<CapabilityBo> findCpblByEqpTmplIds(QueryCapabilityParam param);
/**
* 根据设备id查询设备能力
*
* @param id
* @return
*/
List<CapabilityBo> getCapabilityByDeviceId(Long id);
/**
* 查询设备模板的能力的接口
*
* @param param
* @return
*/
List<IntfcBo> findIntfcOfCpblByEqpTmplIds(QueryIntfcParam param);
/**
* @param eqpId
* @return
*/
List<EqpNodeSubGraphBo> findEqpNodeGraphByEqpId(Long eqpId);
/**
* 查询设备模板的属性集合
*
* @param param
* @return
*/
List<EqpTmplAttributeBo> findEqpTmplAttrByEqpTmplIds(
QueryEqpTmplAttrParam param);
/**
* 查询设备接口集合
*
* @param param
* @return
*/
List<EqpTmplIntfcBo> findEqpTmplIntfcByEqpTmplIds(
QueryEqpTmplIntfcParam param);
/**
* 根据设备id查询视图名称
*
* @return
*/
Subgraph getSubgraphByEqbId(Long eqpId);
/**
* 根据设备id查询node
*
* @return
*/
Node getNodeByEqbId(Long eqpId);
/**
* 查询设备id、节点id、视图id
*
* @param eqpId
* @return
*/
List<EqpGraphNodeBo> findEqpGraphNodeByEqpId(Long eqpId);
/**
* 查询监听端口信息
*
* @param param
* @return
*/
List<ListenPortBo> findListenPortBo(QueryListenPortParam param);
/**
* 查询设备监听端口信息
*
* @param param
* @return
*/
List<EquipmentBo> findMonitorEquipmentPorts(QueryMonitorEqpParam param);
/**
* 查询设备原型监听端口信息
*
* @param param
* @return
*/
List<ListenPortBo> findTempListenPortBo(QueryListenPortParam param);
/**
* 查询监测设备,优化后
*
* @param param
* @return
*/
List<EquipmentBo> findMonitorEquipmentDet(QueryMonitorEqpParam param);
/**
* 查询长连接监测设备
*
* @param param
* @return
*/
List<EquipmentBo> findLongConMonitorEqp(QueryMonitorEqpParam param);
}
/**
* NewHeight.com Inc.
* Copyright (c) 2008-2010 All Rights Reserved.
*/
package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.vo.ProtocolDicVo;
import org.apache.ibatis.annotations.Mapper;
import com.yeejoin.amos.iot.business.param.ProtocolParam;
/**
*
* <pre>
* 协议mapper
* </pre>
*
* @author as-lixiangyang
* @version $Id: ProtocolMapper.java, v 0.1 2018年1月29日 下午3:33:51 as-lixiangyang Exp $
*/
@Mapper
public interface ProtocolMapper {
/**
* 获取指标数据数量
*
* @return
*/
void updateProtocol(ProtocolParam ProtocolParam);
ProtocolDicVo findProtocolDicVoByFrameType(Integer frameType);
}
package com.yeejoin.amos.iot.business.dao.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface StatisticMapper {
List<Map<String, Object>> statisticDeviceGroupByModel(String orgCode);
int statisticDeviceHaveAlarmByEqpTmplId(@Param("eqpTmplId") Long eqpTmplId, @Param("eqpIds") List<Long> eqpIds);
Map<String, Object> statisticDeviceByAlarmLevel(String orgCode);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Alarm;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 告警dao
*
* @author as-youjun
*
*/
@Repository("alarmDao")
public interface IAlarmDao extends IBaseRepository<Alarm, Long> {
@Modifying
@Transactional
@Query("UPDATE Alarm SET is_delete = 1 WHERE id = ?1")
void delAlarmById(Long id);
@Modifying(clearAutomatically = true)
@Transactional
@Query(value="UPDATE t_alarm SET is_delete = 1 WHERE c_eqp_id = ?1",nativeQuery = true)
int delAlarmByEqpId(Long id);
@Query("from Alarm WHERE c_eqp_id = ?1")
List<Alarm> fetchAlarmsByRqpId(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Capability;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 能力dao
*
* @author as-youjun
*
*/
@Repository("capabilityDao")
public interface ICapabilityDao extends IBaseRepository<Capability, Long>
{
@Modifying
@Transactional
@Query("UPDATE Capability SET is_delete = 1 WHERE id = ?1")
void delCapabilityById(Long id);
@Query(value = "SELECT ca FROM Capability ca WHERE ca.eqpTmpl.id = ?1 ")
List<Capability> findByEqpTmplId(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.CapabilitylInterface;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 能力接口
* </pre>
*
* @author as-chenjiajun
* @version $Id: ICapabilitylInterfaceDao.java, v 0.1 2018年1月30日 上午11:21:08 as-chenjiajun Exp $
*/
public interface ICapabilityInterfaceDao extends IBaseRepository<CapabilitylInterface, Long>
{
@Modifying
@Transactional
@Query("UPDATE CapabilitylInterface SET is_delete = 1 WHERE id = ?1")
void delCapabilitylInterfaceById(Long id);
@Query("from CapabilitylInterface WHERE intfc_id = ?1")
List<CapabilitylInterface> getCapacityIntfcByIntfc(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.CapabilityAttribute;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 能力属性
* </pre>
*
* @author as-chenjiajun
* @version $Id: ICapabilityPropertyDao.java, v 0.1 2018年1月30日 上午11:29:07 as-chenjiajun Exp $
*/
public interface ICapabilityPropertyDao extends IBaseRepository<CapabilityAttribute, Long>
{
@Modifying
@Transactional
@Query("UPDATE CapabilityAttribute SET is_delete = 1 WHERE id = ?1")
void delCapabilityAttributeById(Long id);
@Query(value = "SELECT ca FROM CapabilityAttribute ca WHERE ca.capability.id = ?1 ")
List<CapabilityAttribute> findByCapabilityId(Long cpId);
@Modifying
@Transactional
@Query(value="SELECT * FROM t_cpbl_attr WHERE id IN ?1", nativeQuery = true)
List<CapabilityAttribute> getInfoByIds(Long... ids);
@Query(value = "SELECT id FROM CapabilityAttribute ca WHERE ca.capability.id = ?1 ")
List<Long> findIdByCapabilityId(Long cpId);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Connection;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 连接dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IConnectionDao.java, v 0.1 2018年3月8日 下午1:43:38 as-chenjiajun Exp $
*/
public interface IConnectionDao extends IBaseRepository<Connection, Long>
{
@Modifying
@Transactional
@Query("UPDATE Connection SET is_delete = 1 WHERE id = ?1")
void delConnectionById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Dic;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 系统数据字典Dao接口
* </pre>
*
* @author as-shibaobao
* @version $Id: IDicDao.java, v 0.1 2018年1月26日 下午2:29:53 as-shibaobao Exp $
*/
@Repository("dicDao")
public interface IDicDao extends IBaseRepository<Dic, Long> {
default Long findIdByTypeAndCode(String type, String code) {
Dic systemDic = this.findByTypeAndCode(type, code);
if (null != systemDic) {
return systemDic.getId();
} else {
return null;
}
}
/**
* 根据type,code获取SystemDic
*
* @param type
* @param code
* @return
*/
@Query(value = "from Dic where type = ?1 AND code = ?2")
public Dic findByTypeAndCode(String type, String code);
/**
* 根据type,code获取SystemDic
*
* @param type
* @param name
* @return
*/
@Query(value = "from Dic where type = ?1 AND name = ?2")
public Dic findByTypeAndName(String type, String name);
/**
* 根据type获取SystemDic集合
*
* @param type
* @return
*/
public List<Dic> findByType(String type);
/**
* 根据id查询
*
* @param id
* @return
*/
public Dic findById(Long id);
@Modifying
@Transactional
@Query("UPDATE Dic SET is_delete = 1 WHERE id = ?1")
void delDicById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.DroolsRule;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* drools规则dao
* </pre>
*
* @author as-guowubin
* @version $Id: IDroolsRuleDao.java, v 0.1 2018年4月20日 下午4:22:05 as-guowubin Exp $
*/
public interface IDroolsRuleDao extends IBaseRepository<DroolsRule, String>
{
/**
*
* <pre>
* 根据组id查询已启用的drools规则
* </pre>
*
* @param groupId
* @param isUser
* @return
*/
List<DroolsRule> findByGroupIdAndIsUser(String groupId, Boolean isUser);
/**
*
* <pre>
* 根据s所属规则id查询drools规则
* </pre>
*
* @param ruleId
* @return
*/
List<DroolsRule> findByRuleId(String ruleId);
@Modifying
@Transactional
@Query("UPDATE DroolsRule SET is_delete = 1 WHERE id = ?1")
void delDroolsRuleById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import com.yeejoin.amos.iot.business.entity.EquipmentCapability;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 设备与能力关联关系dao
* </pre>
*
* @author as-guowubin
* @version $Id: IEqpCpblDao.java, v 0.1 2018年6月9日 上午10:51:25 as-guowubin Exp $
*/
public interface IEqpCpblDao extends IBaseRepository<EquipmentCapability, Long>
{
/**
*
* <pre>
* 根据eqpId查询
* </pre>
*
* @param eqpId
* @return
*/
List<EquipmentCapability> findByEqpId(Long eqpId);
/**
*
* <pre>
* 删除设备和能力关联关系
* </pre>
*
* @param eqpId
*/
@Query("DELETE FROM EquipmentCapability WHERE eqpId = ?1")
void delByEqpId(Long eqpId);
/**
*
* <pre>
* 根据cpblId查询
* </pre>
*
* @param cpblId
* @return
*/
@Query("FROM EquipmentCapability WHERE eqpId = ?1 and cpblId = ?2")
List<EquipmentCapability> findByEpbIdAndCpblId(Long eqpId,Long cpblId);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.EqpCpblProperty;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 设备能力属性上下限dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IEqpCpblPropertyDao.java, v 0.1 2018年7月12日 上午9:29:57 as-chenjiajun Exp $
*/
public interface IEqpCpblPropertyDao extends IBaseRepository<EqpCpblProperty, Long>
{
@Modifying
@Transactional
@Query("DELETE FROM EqpCpblProperty WHERE eqpId = ?1")
void deleteByEqpId(Long eqpId);
@Query("FROM EqpCpblProperty WHERE eqpId = ?1")
List<EqpCpblProperty> findInfoByEqpId(Long eqpId);
/**
*
* <pre>
* 查询设备及能力查询门限配置信息
* </pre>
*
* @param eqpId
* @param cpblId
* @return
*/
List<EqpCpblProperty> findByEqpIdAndCpblId(Long eqpId, Long cpblId);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.EqpTmplInterface;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 设备接口
* </pre>
*
* @author as-chenjiajun
* @version $Id: IEqpTmplInterfaceDao.java, v 0.1 2018年1月30日 上午10:53:30 as-chenjiajun Exp $
*/
public interface IEqpTmplInterfaceDao extends IBaseRepository<EqpTmplInterface, Long>
{
@Modifying
@Transactional
@Query("UPDATE EqpTmplInterface SET is_delete = 1 WHERE id = ?1")
void delEqpTmplInterfaceById(Long id);
@Query("from EqpTmplInterface WHERE intfc_id = ?1")
List<EqpTmplInterface> getDeviceInterfaceByIntfcId(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.EqpTmplAttribute;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 设备属性
* </pre>
*
* @author as-lixiangyang
* @version $Id: IEqpTmplPropertyDao.java, v 0.1 2018年1月30日 下午8:13:07 as-lixiangyang Exp $
*/
public interface IEqpTmplPropertyDao extends IBaseRepository<EqpTmplAttribute, Long>
{
@Modifying
@Transactional
@Query("UPDATE EqpTmplAttribute SET is_delete = 1 WHERE id = ?1")
void delEqpTmplAttributeById(Long id);
@Transactional
@Query("select name, valueStr from EqpTmplAttribute where name = ?1 and valueStr = ?2")
public List<EqpTmplAttribute> getAttributesByNameAndValueStr(String name, String val);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.Collection;
import java.util.List;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Equipment;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 设备dao
*
* @author as-youjun
*
*/
@Repository("equipmentDao")
public interface IEquipmentDao extends IBaseRepository<Equipment, Long> {
@Query(value = "select * from t_equipment e where e.cfg_param_json->'$.sid' = ?1", nativeQuery = true)
Equipment findByCfgParamJson(String sid);
@Query("SELECT COUNT(*) FROM Equipment WHERE isDelete=false AND (orgCode = ?1 OR orgCode LIKE ?2)")
long countByOrgCode(String orgCode, String likeOrgCode);
long countByIsDeleteFalseAndIdIn(Collection<Long> ids);
@Query("SELECT eqpTmplId FROM Equipment WHERE isDelete=false AND (orgCode = ?1 OR orgCode LIKE ?2)")
List<Long> findEqpTempIdsByOrgCode(String orgCode, String likeOrgCode);
@Modifying(clearAutomatically = true)
@Transactional
@Query(value="update t_equipment set is_delete = 1 WHERE id = ?1",nativeQuery = true)
int delEquipmentById(Long id);
@Query(value = "SELECT e.id as id,e.eqp_tmpl_id as eqp_tmpl_id,e.name as name,eq.model as model,eq.type as type,eq.industry_id as industryid FROM t_node as n INNER JOIN t_equipment as e inner JOIN t_eqp_tmpl as eq on n.equipment_id = e.id and eq.id = e.eqp_tmpl_id where n.subgraph_id = ?1 and e.org_code = ?2 ORDER BY ?#{#pageable}",
countQuery ="SELECT count(e.id) FROM t_node as n INNER JOIN t_equipment as e inner JOIN t_eqp_tmpl as eq on n.equipment_id = e.id and eq.id = e.eqp_tmpl_id where n.subgraph_id = ?1 and e.org_code = ?2"
,nativeQuery = true)
Page<Object> findEqpBySubgraph(String subgraphId, String orgCode,Pageable pageable);
/**
*
* <pre>
* 根据eqpTmplId查询
* </pre>
*
* @param eqpTmplId
* @return
*/
List<Equipment> findByEqpTmplId(Long eqpTmplId);
/**
*
* <pre>
* 根据eqpTmplId查询设备数量
* </pre>
*
* @param eqpTmplId
* @return
*/
@Query("SELECT COUNT(*) FROM Equipment WHERE isDelete=false AND eqpTmplId = ?1 AND (orgCode = ?2 OR orgCode LIKE ?3)")
long countByEqpTmplId(Long eqpTmplId, String orgCode, String orgCodeLike);
/**
*
* <pre>
* 条件查询设备
* </pre>
*
* @param name 设备名称
* @param type 设备模板类别
* @param industryId 设备模板行业
* @return
*/
@Query(value = "select e.* from t_equipment as e LEFT JOIN t_eqp_tmpl as ep on e.eqp_tmpl_id = ep.id where (e.name like ?1 or IFNULL(?1,'null')='null')"
+ " and (ep.type = ?2 or IFNULL(?2,'null')='null')"
+ " and (ep.industry_id = ?3 or IFNULL(?3,'null')='null')"
+ " and e.is_delete = false"
+ " and e.org_code = ?4"
, nativeQuery = true)
List<Equipment> getEquipmentByParam(String name,Integer type,Long industryId,String orgCode);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.EquipmentTemplate;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 设备模板dao
*
* @author as-youjun
*
*/
@Repository("equipmentTemplateDao")
public interface IEquipmentTemplateDao extends IBaseRepository<EquipmentTemplate, Long> {
@Query("Select id from EquipmentTemplate where type =?1")
List<Long> findIdByType(Integer type);
@Query("Select id from EquipmentTemplate where industryId =?1")
List<Long> findIdByIndustryId(Long industryId);
@Modifying
@Transactional
@Query("UPDATE EquipmentTemplate SET is_delete = 1 WHERE id = ?1")
void delEquipmentTemplateById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.FrameProtocol;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
import org.springframework.stereotype.Repository;
/**
* 报文关键字与解析协议关系dao
*
* @author as-youjun
*/
@Repository("frameProtocolDao")
public interface IFrameProtocolDao extends IBaseRepository<FrameProtocol, Long> {
/**
* 查询帧类型对应的FrameProtocol
*
* @param frameType
* @return
*/
FrameProtocol findByFrameType(int frameType);
/**
* 根据数据帧头类型和common查询对应的FrameProtocol
* @param frameType
* @param command
* @return
*/
FrameProtocol findByFrameTypeAndCommand(int frameType, String command);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.iot.business.entity.IntfcProtocolVo;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
@Repository("infcProtocolDao")
public interface IInfcProtocolDao extends IBaseRepository<IntfcProtocolVo, Long>{
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.IntfcAttribute;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 接口属性数据DAO接口
* </pre>
*
* @author as-shibaobao
* @version $Id: IIntfcAttributeDao.java, v 0.1 2018年1月26日 下午1:18:23 as-shibaobao Exp $
*/
@Repository("intfcAttributeDao")
public interface IIntfcAttributeDao extends IBaseRepository<IntfcAttribute, Long>
{
/**
*
* <pre>
* 根据接口ID查询接口属性
* </pre>
*
* @param ids
* @return
*/
List<IntfcAttribute> findAllByIntfcIdIn(List<Long> ids);
@Modifying
@Transactional
@Query("UPDATE IntfcAttribute SET is_delete = 1 WHERE id = ?1")
void delIntfcAttributeById(Long id);
@Query("from IntfcAttribute WHERE intfc_id = ?1")
List<IntfcAttribute> getPropertysById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Intfc;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 接口管理dao
*
* @author as-youjun
*
*/
@Repository("intfcDao")
public interface IIntfcDao extends IBaseRepository<Intfc, Long> {
@Modifying
@Transactional
@Query("UPDATE Intfc SET is_delete = 1 WHERE id = ?1")
void delIntfcById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.LinkVo;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 界面视图线路DAO
* </pre>
*
* @author AS-guowubin
* @version $Id: ILinkVoDao.java, v 0.1 2018年4月10日 下午3:12:57 AS-guowubin Exp $
*/
@Repository
public interface ILinkVoDao extends IBaseRepository<LinkVo, String> {
List<LinkVo> findBySourceId(String sourceId);
List<LinkVo> findByRuleId(String id);
@Modifying
@Transactional
@Query("UPDATE LinkVo SET is_delete = 1 WHERE id = ?1")
void delLinkVoById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.ListenComm;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
import org.springframework.stereotype.Repository;
/**
* 需要监听采集的通信模式信息dao
*
* @author as-youjun
*/
@Repository("listenCommDao")
public interface IListenCommDao extends IBaseRepository<ListenComm, Long> {
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import com.yeejoin.amos.iot.business.entity.mybatis.MetricDataBo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.MetricData;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 指标数据dao
*
* @author as-youjun
*
*/
@Repository("metricDataDao")
public interface IMetricDataDao extends IBaseRepository<MetricData, Long> {
@Modifying
@Transactional
@Query("UPDATE MetricData SET is_delete = 1 WHERE id = ?1")
void delMetricDataById(Long id);
@Query(value = "SELECT * FROM t_metric_data WHERE eqp_id = ?1 ", nativeQuery = true)
List<MetricData> findByEqpId(Long eqpId);
@Query(value = "SELECT * FROM t_metric_data WHERE eqp_id = ?1 order by exe_time DESC limit 1", nativeQuery = true)
MetricData findLastDataByEqpId(Long eqpId);
@Query(value = "SELECT * FROM t_metric_data WHERE eqp_id = ?1 and cpbl_id = ?2 order by exe_time DESC limit 1", nativeQuery = true)
MetricData findLastDataByEqpIdAndCapId(Long eqpId,Long cpblId);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Node;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 节点dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: INodeDao.java, v 0.1 2018年3月8日 下午1:43:57 as-chenjiajun Exp $
*/
public interface INodeDao extends IBaseRepository<Node, Long>
{
@Modifying
@Transactional
@Query("UPDATE Node SET is_delete = 1 WHERE id = ?1")
void delNodeById(Long id);
@Query(value = "SELECT * FROM t_node WHERE subgraph_id = ?1 and is_delete = 0 ", nativeQuery = true)
List<Node> findNodBysubgraphId(Long subgraphId);
@Query(value = "SELECT * FROM t_node WHERE equipment_id = ?1 and is_delete = 0 ", nativeQuery = true)
List<Node> findNodByEquipmentId(Long equipmentId);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.NodeVo;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 视图节点元素dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: INodeVoDao.java, v 0.1 2018年4月10日 下午3:31:46 as-chenjiajun Exp $
*/
@Repository
public interface INodeVoDao extends IBaseRepository<NodeVo,String>
{
/**
*
* <pre>
* 使用ruleid查询
* </pre>
*
* @param id
* @return
*/
List<NodeVo> findByRuleId(String id);
/**
*
* <pre>
* 使用Key查询
* </pre>
*
* @param id
* @return
*/
List<NodeVo> findByViewKey(String id);
@Modifying
@Transactional
@Query("UPDATE NodeVo SET is_delete = 1 WHERE id = ?1")
void delNodeVoById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.OrgImgRelationships;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IOrgImgRelationshipsDao.java, v 0.1 2018年5月7日 下午1:57:08 as-chenjiajun Exp $
*/
@Repository
public interface IOrgImgRelationshipsDao extends IBaseRepository<OrgImgRelationships,Long>
{
@Modifying
@Transactional
@Query("UPDATE OrgImgRelationships SET is_delete = 1 WHERE id = ?1")
void delOrgImgRelationshipsById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.PollingJob;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 定时任务dao
*
* @author as-youjun
*
*/
@Repository("pollingJobDao")
public interface IPollingJobDao extends IBaseRepository<PollingJob, Long> {
/**
* 查询可用job
*
* @return
*/
@Query("select p from PollingJob p where p.isDelete=false")
List<PollingJob> findEnabledJob();
@Modifying
@Transactional
@Query("UPDATE PollingJob SET is_delete = 1 WHERE id = ?1")
void delPollingJobById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Protocol;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 协议dao
*
* @author as-youjun
*
*/
@Repository("protocolDao")
public interface IProtocolDao extends IBaseRepository<Protocol, Long> {
/**
* 根据名称查询
*
* @param name
* @return
*/
@Query(value = "from Protocol where name = ?1 AND isDelete = 0")
Protocol findByName(String name);
@Modifying
@Transactional
@Query("UPDATE Protocol SET is_delete = 1 WHERE id = ?1")
void delProtocolById(Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Rule;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 规则dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IRuleDao.java, v 0.1 2018年4月10日 下午3:50:41 as-chenjiajun Exp $
*/
public interface IRuleDao extends IBaseRepository<Rule, String>
{
@Modifying
@Transactional
@Query("UPDATE Rule SET is_delete = 1 WHERE id = ?1")
void delRuleById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.RuleDataSource;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 规则视图中数据源dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IRuleDataSourceDao.java, v 0.1 2018年4月10日 下午3:27:50 as-chenjiajun Exp $
*/
@Repository
public interface IRuleDataSourceDao extends IBaseRepository<RuleDataSource,String>
{
/**
*
* <pre>
*
* </pre>
*
* @param eqpId
* @return
*/
List<RuleDataSource> findAllByEqpId(Long eqpId);
@Modifying
@Transactional
@Query("UPDATE RuleDataSource SET is_delete = 1 WHERE id = ?1")
void delRuleDataSourceById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.iot.business.entity.RuleElement;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 视图基本元素dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IRuleElementDao.java, v 0.1 2018年4月10日 下午3:59:49 as-chenjiajun Exp $
*/
@Repository
public interface IRuleElementDao extends IBaseRepository<RuleElement,Long>
{
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.RuleEmail;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 规则视图中email信息dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IRuleEmailDao.java, v 0.1 2018年4月10日 下午3:29:51 as-chenjiajun Exp $
*/
@Repository
public interface IRuleEmailDao extends IBaseRepository<RuleEmail,String>
{
@Modifying
@Transactional
@Query("UPDATE RuleEmail SET is_delete = 1 WHERE id = ?1")
void delRuleEmailById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import java.util.List;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.RuleGroup;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 规则组dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: IRuleGroupDao.java, v 0.1 2018年4月10日 下午3:51:41 as-chenjiajun Exp $
*/
public interface IRuleGroupDao extends IBaseRepository<RuleGroup, String>
{
/**
* <pre>
* 根据是否启用查询规则组
* </pre>
*
* @param isUser
* @return
*/
List<RuleGroup> findAllByIsUser(boolean isUser);
@Modifying
@Transactional
@Query("UPDATE RuleGroup SET is_delete = 1 WHERE id = ?1")
void delRuleGroupById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.RuleMqtt;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 规则视图中mqtt信息dao
* </pre>
*
* @author as-guowubin
* @version $Id: IRuleMqttDao.java, v 0.1 2018年5月4日 下午2:29:52 as-guowubin Exp $
*/
@Repository
public interface IRuleMqttDao extends IBaseRepository<RuleMqtt,String>
{
@Modifying
@Transactional
@Query("UPDATE RuleMqtt SET is_delete = 1 WHERE id = ?1")
void delRuleMqttById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.RuleNode;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 节点元素dao
* </pre>
*
* @author as-guowubin
* @version $Id: IRuleNodeDao.java, v 0.1 2018年4月24日 下午5:16:59 as-guowubin Exp $
*/
public interface IRuleNodeDao extends IBaseRepository<RuleNode, String>
{
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.RuleTcp;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 规则视图中tcp信息dao
* </pre>
*
* @author as-guowubin
* @version $Id: IRuleTcpDao.java, v 0.1 2018年5月4日 下午2:27:46 as-guowubin Exp $
*/
@Repository
public interface IRuleTcpDao extends IBaseRepository<RuleTcp,String>
{
@Modifying
@Transactional
@Query("UPDATE RuleTcp SET is_delete = 1 WHERE id = ?1")
void delRuleTcpById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.iot.business.entity.Section;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 插件管理
* </pre>
*
* @author as-chenjiajun
* @version $Id: ISectionDao.java, v 0.1 2018年6月27日 下午2:10:31 as-chenjiajun Exp $
*/
@Repository("sectionDao")
public interface ISectionDao extends IBaseRepository<Section, Long>
{
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Subgraph;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 子图dao
* </pre>
*
* @author as-chenjiajun
* @version $Id: ISubgraohDao.java, v 0.1 2018年3月8日 下午1:27:53 as-chenjiajun Exp $
*/
@Repository("subgraohDao")
public interface ISubgraohDao extends IBaseRepository<Subgraph, Long>
{
@Modifying
@Transactional
@Query("UPDATE Subgraph SET is_delete = 1 WHERE id = ?1")
void delSubgraphById(Long id);
@Modifying
@Transactional
@Query(value="UPDATE t_subgraph SET enable_monitor = ?1 WHERE id = ?2", nativeQuery = true)
void oneOpenOrClose(Boolean enableMonitor, Long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.iot.business.entity.Subview;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* 子图dao
*
* @author as-youjun
*
*/
@Repository("subviewDao")
public interface ISubviewDao extends IBaseRepository<Subview, Long> {
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.SystemLog;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
*
* <pre>
* 系统日志dao
* </pre>
*
* @author as-guowubin
* @version $Id: ISystemLogDao.java, v 0.1 2018年4月23日 下午5:48:14 as-guowubin Exp $
*/
@Repository
public interface ISystemLogDao extends IBaseRepository<SystemLog, String>
{
@Modifying
@Transactional
@Query("UPDATE SystemLog SET is_delete = 1 WHERE id = ?1")
void delSystemLogById(String id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import org.springframework.stereotype.Repository;
import com.yeejoin.amos.iot.business.entity.Verticle;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/**
* verticledao
*
* @author as-youjun
*
*/
@Repository("verticleDao")
public interface IVerticleDao extends IBaseRepository<Verticle, Long> {
/**
* 查询包名对应的verticle
*
* @param name
* @return
*/
Verticle findByName(String name);
}
package com.yeejoin.amos.iot.business.dic;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import com.yeejoin.amos.iot.business.entity.Dic;
/**
* 通讯方式数据字典
*
* @author as-youjun
*
*/
@Entity
@DiscriminatorValue("CommunityProtocol")
public class CommunityProtocol extends Dic {
/**
*
*/
private static final long serialVersionUID = 2326119923735983883L;
/**
* String:001表示Serial;002表示HTTP;003表示MQTT;004表示CoAP;005表示AMQP;006表示JMS;007表示ZigBee;008表示Kafka;009表示TCP;010表示STOMP;011表示XMPP
*
*/
public static final String SERIAL = "001";
public static final String HTTP = "002";
public static final String MQTT = "003";
public static final String COAP = "004";
public static final String AMQP = "005";
public static final String JMS = "006";
public static final String ZIGBEE = "007";
public static final String KAFKA = "008";
public static final String TCP = "009";
public static final String STOMP = "010";
public static final String XMPP = "011";
}
package com.yeejoin.amos.iot.business.dic;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import com.yeejoin.amos.iot.business.entity.Dic;
/**
* 设备模型领域类型
* @author maoying
*
*/
@Entity
@DiscriminatorValue("EquipTemplateIndustry")
public class EquipTemplateIndustry extends Dic{
/**
*
*/
private static final long serialVersionUID = 8679802783462492469L;
/**
* String:01表示消防行业;02表示电力行业;03表示网络行业;99表示其他
*
*/
public static final String FIRE = "01";
public static final String POWER = "02";
public static final String INTERNET = "03";
public static final String INDUSTRIAL = "04";
public static final String OTHER = "99";
}
/**
*
*/
package com.yeejoin.amos.iot.business.dic;
import com.yeejoin.amos.iot.business.constants.IotConstant;
import com.yeejoin.amos.iot.netty.vehicle.dic.VehicleDic.CommonDic;
import org.apache.log4j.Logger;
/**
* 数据字典
*
* @author as-youjun
*/
public final class IotDic {
private IotDic() {
Logger.getLogger(CommonDic.class).debug(IotConstant.CONSTRUCTOR);
}
/**
* 设备状态
*
* @author as-youjun
*/
public static final class EqpStatus {
/**
* 在线
*/
public static final String ONLINE = "在线";
/**
* 离线
*/
public static final String OFLINE = "离线";
}
/**
* 协议名称
*
* @author as-youjun
*/
public static final class ProtocolName {
/**
* TCP
*/
public static final String TCP = "TCP";
/**
* ICMP
*/
public static final String ICMP = "ICMP";
/**
* SNMP
*/
public static final String SNMP = "SNMP";
}
}
package com.yeejoin.amos.iot.business.dic;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import com.yeejoin.amos.iot.business.entity.Dic;
/**
* 协议解析脚本语言数据字典
*
* @author as-youjun
*
*/
@Entity
@DiscriminatorValue("ScriptLang")
public class ScriptLang extends Dic {
/**
*
*/
private static final long serialVersionUID = 6850799852470282844L;
/**
* String:01表示groovy;02表示javascript;03表示lua;04表示python
*/
public static final String GROOVY = "01";
public static final String JAVASCRIPT = "02";
public static final String LUA = "03";
public static final String PYTHON = "04";
}
/**
*
*/
package com.yeejoin.amos.iot.business.entity;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Where;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.yeejoin.amos.iot.rule.resource.RuleAIEntity;
/**
* 告警
*
* @author as-youjun
*
*/
@JsonInclude(Include.NON_EMPTY)
@Entity
@Table(name = "t_alarm")
@Where(clause="is_delete=0")//表示未删除的数据
public class Alarm extends RuleAIEntity {
/**
*
*/
private static final long serialVersionUID = -2202364109261157364L;
/**
* 名称
*/
private String name;
/**
* 描述
*/
private String descr;
/**
* 告警类型:1表示设备掉线,2表示采集异常,3表示指标越界
*/
private Integer type;
/***
* 二级分类,列如:连通性告警下的二级分类:TCP不通告警、SNMP不通告警
*/
private String secondaryType;
/**
* 告警级别:1表示一级,2表示二级,3表示三级
*/
private Integer level;
/**
* 告警状态:1表示未处理(产生),2表示历史(清除),3表示删除(逻辑删除)
*/
private Integer status;
/**
* 产生时间
*/
private Date raiseTime;
/**
* 更新时间
*/
private Date updateTime;
/**
* 告警次数
*/
private Integer count;
/**
* 清除类型:1表示用户清除,2表示系统清除
*/
private Integer clearType;
/**
* 清除时间
*/
private Date clearTime;
/**
* 清除用户id
*/
private String clearUserId;
/**
* 清除信息
*/
private String clearInfo;
/**
* 装备id
*/
private Long eqpId;
/**
* 能力属性id
*/
private Long cpblAttrId;
/**
* 备注
*/
private String remark;
/**
* 活动记录
*/
private String record;
/**
* 公司Id
*/
private String orgCode;
/**
* 活动记录列表
*/
private List<String> recordList;
/**
* 视图对象id
*/
private Long subgraphId;
@Column(name = "c_name", length = 100, nullable = false)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "c_level", nullable = false)
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
@Column(name = "c_status", nullable = false)
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
@Column(name = "c_raise_time", nullable = false)
public Date getRaiseTime() {
return raiseTime;
}
public void setRaiseTime(Date raiseTime) {
this.raiseTime = raiseTime;
}
@Column(name = "c_clear_time")
public Date getClearTime() {
return clearTime;
}
public void setClearTime(Date clearTime) {
this.clearTime = clearTime;
}
@Column(name = "c_clear_user_id")
public String getClearUserId() {
return clearUserId;
}
public void setClearUserId(String clearUserId) {
this.clearUserId = clearUserId;
}
@Column(name = "c_clear_info", length = 512)
public String getClearInfo() {
return clearInfo;
}
public void setClearInfo(String clearInfo) {
this.clearInfo = clearInfo;
}
@Column(name = "c_eqp_id", nullable = false)
public Long getEqpId() {
return eqpId;
}
public void setEqpId(Long eqpId) {
this.eqpId = eqpId;
}
@Column(name = "c_cpbl_attr_id", nullable = false)
public Long getCpblAttrId() {
return cpblAttrId;
}
public void setCpblAttrId(Long cpblAttrId) {
this.cpblAttrId = cpblAttrId;
}
@Column(name = "c_update_time")
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
/**
* @return the descr
*/
@Column(name = "c_descr", length = 512)
public String getDescr() {
return descr;
}
/**
* @param descr
* the descr to set
*/
public void setDescr(String descr) {
this.descr = descr;
}
/**
* @return the type
*/
@Column(name = "c_type", nullable = false)
public Integer getType() {
return type;
}
/**
* @param type
* the type to set
*/
public void setType(Integer type) {
this.type = type;
}
@Column(name = "c_secondary_type", length = 50)
public String getSecondaryType() {
return secondaryType;
}
public void setSecondaryType(String secondaryType) {
this.secondaryType = secondaryType;
}
/**
* @return the count
*/
@Column(name = "c_count", nullable = false)
public Integer getCount() {
return count;
}
/**
* @param count
* the count to set
*/
public void setCount(Integer count) {
this.count = count;
}
/**
* @return the clearType
*/
@Column(name = "c_clear_type")
public Integer getClearType() {
return clearType;
}
/**
* @param clearType
* the clearType to set
*/
public void setClearType(Integer clearType) {
this.clearType = clearType;
}
/**
* @return the record
*/
@Column(name = "c_record", length = 1024)
public String getRecord() {
return record;
}
/**
* @param record
* the record to set
*/
public void setRecord(String record) {
this.record = record;
}
@Column(name = "c_remark", length = 512)
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
/**
* @return the recordList
*/
@Transient
public List<String> getRecordList() {
return recordList;
}
@Column(name = "org_code")
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
@Column(name = "subgraph_id")
public Long getSubgraphId() {
return subgraphId;
}
public void setSubgraphId(Long subgraphId) {
this.subgraphId = subgraphId;
}
}
package com.yeejoin.amos.iot.business.entity;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.NotBlank;
import com.yeejoin.amos.iot.core.util.StringUtil;
/**
* 基本属性
*
* @author as-youjun
*
*/
@MappedSuperclass
public class BasicAttribute extends BasicEntity {
/**
*
*/
private static final long serialVersionUID = 7046485114948164091L;
/**
* 属性名称(英文、数字、下划线)
*/
private String name;
/**
* 属性分类:1表示变量,2表示常量,3表示标签
*/
private Integer type;
/**
* 显示名称
*/
private String displayName;
/**
* 计量单位
*/
private String unit;
/**
* 描述
*/
private String descr;
/**
* 数据类型:1表示整型,2表示浮点型,3表示布尔型,4表示枚举,5表示字符串,6表示密码
*/
private Integer dataType;
/**
* 字符串值
*/
private String valueStr;
/**
* 数值型值
*/
private Double valueNumeric;
/**
* 最小值
*/
private Double minValue;
/**
* 最大值
*/
private Double maxValue;
/**
* float/double类型精度
*/
private Integer precision;
/**
* 枚举范围,使用逗号分隔
*/
private String enumRange;
@Column(name = "name", length = 100, nullable = false)
@NotNull(message = "属性名不能为空!")
@NotBlank(message = "属性名不能为空字符串!")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Column(name = "type", nullable = false)
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
@Column(name = "display_name", length = 100, nullable = false)
@NotNull(message = "显示名称不能为空!")
@NotBlank(message = "显示名称不能为空字符串!")
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@Column(name = "unit", length = 20)
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
@Column(name = "descr", length = 512)
public String getDescr() {
if (StringUtil.isNotEmpty(descr)) {
return descr.trim();
}
return null;
}
public void setDescr(String descr) {
this.descr = descr;
}
@Column(name = "data_type", nullable = false)
public Integer getDataType() {
return dataType;
}
public void setDataType(Integer dataType) {
this.dataType = dataType;
}
@Column(name = "value_str")
public String getValueStr() {
return valueStr;
}
public void setValueStr(String valueStr) {
this.valueStr = valueStr;
}
@Column(name = "value_numeric")
public Double getValueNumeric() {
return valueNumeric;
}
public void setValueNumeric(Double valueNumeric) {
this.valueNumeric = valueNumeric;
}
@Column(name = "min_value")
public Double getMinValue() {
return minValue;
}
public void setMinValue(Double minValue) {
this.minValue = minValue;
}
@Column(name = "max_value")
public Double getMaxValue() {
return maxValue;
}
public void setMaxValue(Double maxValue) {
this.maxValue = maxValue;
}
@Column(name="accuracy")
public Integer getPrecision() {
return precision;
}
public void setPrecision(Integer precision)
{
this.precision = precision;
}
@Column(name="enum_range",length=200)
public String getEnumRange()
{
return enumRange;
}
public void setEnumRange(String enumRange)
{
this.enumRange = enumRange;
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment