Commit 230257be authored by 高东东's avatar 高东东

*)修改bug

parent e2feb471
...@@ -17,7 +17,34 @@ ...@@ -17,7 +17,34 @@
</parent> </parent>
<dependencies> <dependencies>
<!-- 安全模块jar --> <!-- fegion客户端引用start -->
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-privilege</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-feign-systemctl</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.yeejoin</groupId>
<artifactId>amos-component-feign</artifactId>
<version>1.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-foundation</artifactId>
<version>1.1.13-Ty</version>
</dependency>
<dependency>
<groupId>com.yeejoin.amos</groupId>
<artifactId>AmosOPService</artifactId>
<version>${YeeOp.version}</version>
</dependency>
<!-- fegion客户端引用end -->
<!-- 安全模块jar
<dependency> <dependency>
<groupId>com.yeejoin.amos</groupId> <groupId>com.yeejoin.amos</groupId>
<artifactId>AmosOPService</artifactId> <artifactId>AmosOPService</artifactId>
...@@ -37,7 +64,7 @@ ...@@ -37,7 +64,7 @@
<artifactId>spring-security-config</artifactId> <artifactId>spring-security-config</artifactId>
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>-->
<!-- drools规则 start --> <!-- drools规则 start -->
<dependency> <dependency>
<groupId>org.kie</groupId> <groupId>org.kie</groupId>
...@@ -76,9 +103,14 @@ ...@@ -76,9 +103,14 @@
<artifactId>freemarker</artifactId> <artifactId>freemarker</artifactId>
</dependency> </dependency>
<!--串口通信依赖--> <!--串口通信依赖-->
<!-- <dependency>-->
<!-- <groupId>org.bidib.jbidib.org.qbang.rxtx</groupId>-->
<!-- <artifactId>rxtxcomm</artifactId>-->
<!-- <version>2.2</version>-->
<!-- </dependency>-->
<dependency> <dependency>
<groupId>org.bidib.jbidib.org.qbang.rxtx</groupId> <groupId>gnu.io</groupId>
<artifactId>rxtxcomm</artifactId> <artifactId>RxTxComm</artifactId>
<version>2.2</version> <version>2.2</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -3,6 +3,19 @@ ...@@ -3,6 +3,19 @@
*/ */
package com.yeejoin.amos.iot.business.controller; package com.yeejoin.amos.iot.business.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
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 com.yeejoin.amos.iot.business.enums.AlarmStatus; import com.yeejoin.amos.iot.business.enums.AlarmStatus;
import com.yeejoin.amos.iot.business.param.AlarmPageParam; import com.yeejoin.amos.iot.business.param.AlarmPageParam;
import com.yeejoin.amos.iot.business.param.DeleteAlarmParam; import com.yeejoin.amos.iot.business.param.DeleteAlarmParam;
...@@ -14,19 +27,10 @@ import com.yeejoin.amos.iot.mongodb.service.intfc.IMetricDataQueryService; ...@@ -14,19 +27,10 @@ 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.query.DaoCriteria;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; 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;
/** /**
* 告警控制器 * 告警控制器
...@@ -61,6 +65,7 @@ public class AlarmController extends BaseController { ...@@ -61,6 +65,7 @@ public class AlarmController extends BaseController {
@ApiParam(value = "查询参数", required = true) @RequestBody(required = false) List<CommonRequest> requests, @ApiParam(value = "查询参数", required = true) @RequestBody(required = false) List<CommonRequest> requests,
@ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) { @ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) {
List<DaoCriteria> criterias = buildDaoCriteriasNoDelete(requests); List<DaoCriteria> criterias = buildDaoCriteriasNoDelete(requests);
criterias = criterias.stream().filter(e -> !"orgCode".equals(e.getPropertyName())).collect(Collectors.<DaoCriteria>toList());
if (!"SUPER".equals(getUserId())) { if (!"SUPER".equals(getUserId())) {
DaoCriteria daoCriteria = new DaoCriteria(); DaoCriteria daoCriteria = new DaoCriteria();
daoCriteria.setPropertyName("orgCode"); daoCriteria.setPropertyName("orgCode");
...@@ -68,6 +73,7 @@ public class AlarmController extends BaseController { ...@@ -68,6 +73,7 @@ public class AlarmController extends BaseController {
daoCriteria.setValue(getCompanyOrgCode() + "%"); daoCriteria.setValue(getCompanyOrgCode() + "%");
criterias.add(daoCriteria); criterias.add(daoCriteria);
} }
pageable.setSort(Sort.unsorted());
Map<String, Object> map = alarmService.findAllByParam(criterias, pageable); Map<String, Object> map = alarmService.findAllByParam(criterias, pageable);
return CommonResponseUtil.success(map); return CommonResponseUtil.success(map);
} }
......
package com.yeejoin.amos.iot.business.controller; package com.yeejoin.amos.iot.business.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.iot.business.param.CompanyBo; import com.yeejoin.amos.iot.business.param.CompanyBo;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.ApplicationConfig; import com.yeejoin.amos.op.core.util.ApplicationConfig;
...@@ -8,6 +12,7 @@ import com.yeejoin.amos.op.core.util.CommonResponseUtil; ...@@ -8,6 +12,7 @@ import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.op.core.util.Constants; import com.yeejoin.amos.op.core.util.Constants;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
...@@ -18,9 +23,11 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -18,9 +23,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -36,29 +43,35 @@ public class CompanyController extends BaseController { ...@@ -36,29 +43,35 @@ public class CompanyController extends BaseController {
@ApiOperation(httpMethod = "POST", value = "获取公司权限树", notes = "获取公司权限树(包含子公司)") @ApiOperation(httpMethod = "POST", value = "获取公司权限树", notes = "获取公司权限树(包含子公司)")
@RequestMapping(value = "/manger-tree", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/manger-tree", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse mangerTree() { public CommonResponse mangerTree() {
String url = applicationConfig.getParamValueStr("params.remoteurl"); // String url = applicationConfig.getParamValueStr("params.remoteurl");
HttpHeaders headers = new HttpHeaders(); // HttpHeaders headers = new HttpHeaders();
MediaType type = MediaType // MediaType type = MediaType
.parseMediaType("application/json; charset=UTF-8"); // .parseMediaType("application/json; charset=UTF-8");
headers.setContentType(type); // headers.setContentType(type);
headers.add("Accept", MediaType.APPLICATION_JSON.toString()); // headers.add("Accept", MediaType.APPLICATION_JSON.toString());
headers.add("X-From-Service", "true"); // headers.add("X-From-Service", "true");
HttpEntity<String> formEntity = new HttpEntity<String>(headers); // HttpEntity<String> formEntity = new HttpEntity<String>(headers);
List<HashMap> companys = null; // List<HashMap> companys = null;
try { try {
RestTemplate restTemplate = new RestTemplate(); // RestTemplate restTemplate = new RestTemplate();
CommonResponse commonResponse = restTemplate.exchange(url + "v1/company/subtree/" + getSelectedOrgInfo().getCompany().getSequenceNbr(), // CommonResponse commonResponse = restTemplate.exchange(url + "v1/company/subtree/" + getSelectedOrgInfo().getCompany().getSequenceNbr(),
HttpMethod.GET, formEntity, CommonResponse.class).getBody(); // HttpMethod.GET, formEntity, CommonResponse.class).getBody();
if (commonResponse.getResult().equals(Constants.RESULT_SUCCESS)) { // if (commonResponse.getResult().equals(Constants.RESULT_SUCCESS)) {
companys = JSON.parseArray(JSON.toJSONString(commonResponse.getDataList()), HashMap.class); // companys = JSON.parseArray(JSON.toJSONString(commonResponse.getDataList()), HashMap.class);
} // }
CompanyBo selectCompany = this.getSelectedOrgInfo().getCompany(); CompanyBo selectCompany = this.getSelectedOrgInfo().getCompany();
if (ObjectUtils.isEmpty(selectCompany)) {
CompanyModel companyModel = getUserInfo().getCompanys().get(0);
selectCompany = new CompanyBo();
BeanUtils.copyProperties(companyModel, selectCompany);
}
Map<String, Object> mapCompany = Obj2Map(selectCompany); Map<String, Object> mapCompany = Obj2Map(selectCompany);
mapCompany.put("orgCode", selectCompany.getOrgCode()); mapCompany.put("orgCode", selectCompany.getOrgCode());
mapCompany.put("levelName", selectCompany.getCompanyName()); mapCompany.put("levelName", selectCompany.getCompanyName());
mapCompany.put("title", selectCompany.getCompanyName()); mapCompany.put("title", selectCompany.getCompanyName());
mapCompany.put("value", selectCompany.getSequenceNbr()); mapCompany.put("value", String.valueOf(selectCompany.getSequenceNbr()));
mapCompany.put("children", mapList(companys)); //mapCompany.put("children", mapList(companys));
mapCompany.put("children", getCompanyChild(selectCompany.getSequenceNbr()));
List resultList = new ArrayList(); List resultList = new ArrayList();
resultList.add(mapCompany); resultList.add(mapCompany);
return CommonResponseUtil.success(resultList); return CommonResponseUtil.success(resultList);
...@@ -78,14 +91,44 @@ public class CompanyController extends BaseController { ...@@ -78,14 +91,44 @@ public class CompanyController extends BaseController {
} }
return list; return list;
} }
private Map<String, Object> Obj2Map(Object obj) throws Exception { private Map<String, Object> Obj2Map(Object obj) throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Field[] fields = obj.getClass().getDeclaredFields(); Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
field.setAccessible(true); field.setAccessible(true);
map.put(field.getName(), field.get(obj)); map.put(field.getName(), String.valueOf(field.get(obj)));
} }
return map; return map;
} }
/**
* 根据公司ID查询下的子公司
*/
public List<CompanyModel> getCompanyChild(Long companySeq) {
Map<String, Object> map = new HashMap<>();
List<CompanyModel> childrens = new ArrayList<CompanyModel>();
try {
String token = request.getHeader("token");
String product = request.getHeader("product");
String appKey = request.getHeader("appKey");
RequestContext.setToken(token);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
CompanyModel result = Privilege.companyClient.seleteOne(companySeq).getResult();
if(result.getChildren()!=null && !result.getChildren().isEmpty()) {
childrens = (List<CompanyModel>) result.getChildren();
}
} catch (InnerInvokException e) {
System.err.println("get user info fail");
}
return childrens;
}
} }
...@@ -56,8 +56,6 @@ import com.yeejoin.amos.op.core.common.response.CommonResponse; ...@@ -56,8 +56,6 @@ import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.BasicUtil; import com.yeejoin.amos.op.core.util.BasicUtil;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.op.core.util.JSONUtil; import com.yeejoin.amos.op.core.util.JSONUtil;
import com.yeejoin.amos.security.common.authorization.Authorization;
import com.yeejoin.amos.security.common.context.CurrentAuthentication;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
...@@ -427,38 +425,45 @@ public class DeviceController extends BaseController { ...@@ -427,38 +425,45 @@ public class DeviceController extends BaseController {
@ApiParam(value = "查询参数", required = true) @RequestBody EqpTemplPageParam requestParam) { @ApiParam(value = "查询参数", required = true) @RequestBody EqpTemplPageParam requestParam) {
List<EquipmentTemplate> eqpTempls = new ArrayList<EquipmentTemplate>(); List<EquipmentTemplate> eqpTempls = new ArrayList<EquipmentTemplate>();
List<DaoCriteria> daoCriterias = new ArrayList<DaoCriteria>(); List<DaoCriteria> daoCriterias = new ArrayList<DaoCriteria>();
List<DaoCriteria> filterCriterias = getFilterCriterias(requestParam); HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("name", requestParam.getName());
paramMap.put("industryId", requestParam.getIndustryId());
paramMap.put("model", requestParam.getModel());
paramMap.put("type", requestParam.getType());
paramMap.put("orgCode", getCompanyOrgCode());
eqpTempls.addAll(eqpTemplService.findAllMybatis(paramMap));
/** /**
* 查询公共的设备类型 * 查询公共的设备类型
*/ */
DaoCriteria visDaoCriteria = new DaoCriteria(); // List<DaoCriteria> filterCriterias = getFilterCriterias(requestParam);
visDaoCriteria.setPropertyName("visibility"); // DaoCriteria visDaoCriteria = new DaoCriteria();
visDaoCriteria.setOperator(QueryOperatorEnum.EQUAL.getName()); // visDaoCriteria.setPropertyName("visibility");
visDaoCriteria.setValue(0); // visDaoCriteria.setOperator(QueryOperatorEnum.EQUAL.getName());
// visDaoCriteria.setValue(0);
daoCriterias.add(visDaoCriteria); // daoCriterias.add(visDaoCriteria);
// daoCriterias.add(orgDaoCriteria); //// daoCriterias.add(orgDaoCriteria);
daoCriterias.addAll(filterCriterias); // daoCriterias.addAll(filterCriterias);
eqpTempls.addAll(eqpTemplService.findAll(daoCriterias));
/** /**
* 查询私有的设备类型 * 查询私有的设备类型
*/ */
//构建查询条件 //构建查询条件
DaoCriteria orgDaoCriteria = new DaoCriteria(); // DaoCriteria orgDaoCriteria = new DaoCriteria();
orgDaoCriteria.setPropertyName("orgCode"); // orgDaoCriteria.setPropertyName("orgCode");
orgDaoCriteria.setOperator(QueryOperatorEnum.LIKE.getName()); // orgDaoCriteria.setOperator(QueryOperatorEnum.LIKE.getName());
orgDaoCriteria.setValue(getCompanyOrgCode() + "%"); // orgDaoCriteria.setValue(getCompanyOrgCode() + "%");
// buildOrgDaoCriteriaInChildren(daoCriterias, getOrgCode()); //// buildOrgDaoCriteriaInChildren(daoCriterias, getOrgCode());
DaoCriteria daoCriteria = new DaoCriteria(); // DaoCriteria daoCriteria = new DaoCriteria();
daoCriteria.setPropertyName("visibility"); // daoCriteria.setPropertyName("visibility");
daoCriteria.setOperator(QueryOperatorEnum.EQUAL.getName()); // daoCriteria.setOperator(QueryOperatorEnum.EQUAL.getName());
daoCriteria.setValue(1); // daoCriteria.setValue(1);
daoCriterias.add(daoCriteria); // daoCriterias.add(daoCriteria);
daoCriterias.add(orgDaoCriteria); // daoCriterias.add(orgDaoCriteria);
daoCriterias.addAll(filterCriterias); // daoCriterias.addAll(filterCriterias);
//根据条件进行查询 //根据条件进行查询
eqpTempls.addAll(eqpTemplService.findAll(daoCriterias)); // eqpTempls.addAll(eqpTemplService.findAll(daoCriterias));
List<Map<String, Object>> eqpTemplList = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> eqpTemplList = new ArrayList<Map<String, Object>>();
Map<String, Object> eqpTemplMap = null; Map<String, Object> eqpTemplMap = null;
QueryEqpCountParam queryEqpCountParam = new QueryEqpCountParam(); QueryEqpCountParam queryEqpCountParam = new QueryEqpCountParam();
...@@ -612,7 +617,6 @@ public class DeviceController extends BaseController { ...@@ -612,7 +617,6 @@ public class DeviceController extends BaseController {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ApiOperation(httpMethod = "POST", value = "新增/编辑测试设备", notes = "新增/编辑测试设备") @ApiOperation(httpMethod = "POST", value = "新增/编辑测试设备", notes = "新增/编辑测试设备")
@RequestMapping(value = "/saveFakeEquipment", produces = "application/json;charset=UTF-8", method = RequestMethod.POST) @RequestMapping(value = "/saveFakeEquipment", produces = "application/json;charset=UTF-8", method = RequestMethod.POST)
@Authorization(ingore = true)
public CommonResponse addFakeEquipment( public CommonResponse addFakeEquipment(
@ApiParam(value = "测试设备数量", required = true) @RequestParam int num, @ApiParam(value = "测试设备数量", required = true) @RequestParam int num,
@ApiParam(value = "设备基本信息", required = true) @RequestBody String basicInfoStr) { @ApiParam(value = "设备基本信息", required = true) @RequestBody String basicInfoStr) {
...@@ -634,6 +638,10 @@ public class DeviceController extends BaseController { ...@@ -634,6 +638,10 @@ public class DeviceController extends BaseController {
equipment.setOrgCode(getCompanyOrgCode()); equipment.setOrgCode(getCompanyOrgCode());
equipment.setName("testDevice" + i); equipment.setName("testDevice" + i);
if (!ObjectUtils.isEmpty(basicInfoMap.get("id"))) {
equipment.setId(Long.parseLong(basicInfoMap.get("id").toString()));
}
if (equipmentService.checkNameConflict(equipment)) { if (equipmentService.checkNameConflict(equipment)) {
return CommonResponseUtil.success(null, "设备名称重复"); return CommonResponseUtil.success(null, "设备名称重复");
} }
...@@ -657,6 +665,7 @@ public class DeviceController extends BaseController { ...@@ -657,6 +665,7 @@ public class DeviceController extends BaseController {
equipment.setCfgParamJson(JSONUtil.toJson(map.get("propertyMap")).toString()); equipment.setCfgParamJson(JSONUtil.toJson(map.get("propertyMap")).toString());
equipment.setUserId(getUserId()); equipment.setUserId(getUserId());
equipment.setCreateTime(new Date()); equipment.setCreateTime(new Date());
equipment.setAuthOrg(String.valueOf(basicInfoMap.get("authOrg")));
equipment = equipmentService.save(equipment); equipment = equipmentService.save(equipment);
/** /**
...@@ -705,7 +714,7 @@ public class DeviceController extends BaseController { ...@@ -705,7 +714,7 @@ public class DeviceController extends BaseController {
eqpCpblProperty.setMinValue(Double.parseDouble(thresholdInfoMap.get("lower").toString())); eqpCpblProperty.setMinValue(Double.parseDouble(thresholdInfoMap.get("lower").toString()));
thresholdList.add(eqpCpblProperty); thresholdList.add(eqpCpblProperty);
} }
iEqpCpblPropertyService.save(thresholdList); iEqpCpblPropertyService.saveAll(thresholdList);
} }
return CommonResponseUtil.success(equipment); return CommonResponseUtil.success(equipment);
...@@ -746,8 +755,18 @@ public class DeviceController extends BaseController { ...@@ -746,8 +755,18 @@ public class DeviceController extends BaseController {
String eqpTmplId = String.valueOf(basicInfoMap.get("eqpTmplId")); String eqpTmplId = String.valueOf(basicInfoMap.get("eqpTmplId"));
equipment.setEqpTmplId(Long.valueOf(eqpTmplId)); equipment.setEqpTmplId(Long.valueOf(eqpTmplId));
equipment.setCfgParamJson(JSONUtil.toJson(map.get("propertyMap")).toString()); equipment.setCfgParamJson(JSONUtil.toJson(map.get("propertyMap")).toString());
equipment.setUserId(CurrentAuthentication.getAuthenticatedUserId()); equipment.setUserId(getUserId());
equipment.setCreateTime(new Date()); equipment.setCreateTime(new Date());
// ArrayList<String> authOrg = (ArrayList) basicInfoMap.get("authOrg");
// if (authOrg == null) {
// authOrg = new ArrayList<String>();
// }
// ArrayList newAuthOrg = new ArrayList<>();
// newAuthOrg.addAll(authOrg);
// newAuthOrg.add(getCompanyOrgCode());
// newAuthOrg.add(getOrgCode());
// equipment.setAuthOrg(String.valueOf(newAuthOrg));
equipment.setAuthOrg(String.valueOf(basicInfoMap.get("authOrg")));
equipment = equipmentService.save(equipment); equipment = equipmentService.save(equipment);
/** /**
* 删除旧的关联数据 * 删除旧的关联数据
...@@ -799,7 +818,9 @@ public class DeviceController extends BaseController { ...@@ -799,7 +818,9 @@ public class DeviceController extends BaseController {
thresholdList.add(eqpCpblProperty); thresholdList.add(eqpCpblProperty);
} }
iEqpCpblPropertyService.save(thresholdList); if(thresholdList.size()>0) {
iEqpCpblPropertyService.saveAll(thresholdList);
}
return CommonResponseUtil.success(equipment); return CommonResponseUtil.success(equipment);
} }
...@@ -887,7 +908,6 @@ public class DeviceController extends BaseController { ...@@ -887,7 +908,6 @@ public class DeviceController extends BaseController {
@ApiOperation(httpMethod = "GET", value = "导出测试数据", notes = "导出测试数据") @ApiOperation(httpMethod = "GET", value = "导出测试数据", notes = "导出测试数据")
@RequestMapping(value = "/export", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/export", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
@Authorization(ingore = true)
public void exportData(HttpServletRequest req, HttpServletResponse res) { public void exportData(HttpServletRequest req, HttpServletResponse res) {
try { try {
...@@ -1247,4 +1267,18 @@ public class DeviceController extends BaseController { ...@@ -1247,4 +1267,18 @@ public class DeviceController extends BaseController {
return CommonResponseUtil.success(iDeviceService.listByOrgCodeAndModel(orgCode, model)); return CommonResponseUtil.success(iDeviceService.listByOrgCodeAndModel(orgCode, model));
} }
@ApiOperation(value = "根据设备Id查询", notes = "统计设备总数和异常设备总数")
@GetMapping(value = "/cpbl/attr")
public CommonResponse listDeviceAndDeviceCpblAttr(@RequestParam(required = false) Long equipmentId) {
List<EquipmentVo> list = iDeviceService.listDeviceAndDeviceCpblAttr(equipmentId);
return CommonResponseUtil.success(list);
}
@ApiOperation(value = "根据设备Id查询", notes = "根据设备Id查询模板能力")
@GetMapping(value = "/cpbl/list/{equipmentId}")
public CommonResponse listDeviceCpbl(@PathVariable long equipmentId) {
Equipment equipment = equipmentService.findOne(equipmentId);
List<Capability> list = iCapabilityService.findByEqpTmpl(equipment.getEqpTmplId());
return CommonResponseUtil.success(list);
}
} }
...@@ -12,7 +12,6 @@ import com.yeejoin.amos.iot.mongodb.service.intfc.IEquipMetricDataService; ...@@ -12,7 +12,6 @@ import com.yeejoin.amos.iot.mongodb.service.intfc.IEquipMetricDataService;
import com.yeejoin.amos.iot.mongodb.service.intfc.IMetricDataQueryService; import com.yeejoin.amos.iot.mongodb.service.intfc.IMetricDataQueryService;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
......
...@@ -41,7 +41,6 @@ import com.yeejoin.amos.op.core.common.query.DaoCriteria; ...@@ -41,7 +41,6 @@ import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.common.response.TreeResponse; import com.yeejoin.amos.op.core.common.response.TreeResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -49,7 +48,6 @@ import io.swagger.annotations.ApiParam; ...@@ -49,7 +48,6 @@ import io.swagger.annotations.ApiParam;
@RestController @RestController
@RequestMapping("/iot") @RequestMapping("/iot")
@Authorization(ingore = true)
@Api(value = "iot", tags = { "提供给外部的接口" }) @Api(value = "iot", tags = { "提供给外部的接口" })
public class ExportController extends BaseController{ public class ExportController extends BaseController{
@Autowired @Autowired
......
...@@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam; ...@@ -21,6 +21,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -155,9 +156,9 @@ public class IntfcController extends BaseController { ...@@ -155,9 +156,9 @@ public class IntfcController extends BaseController {
@ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) { @ApiParam(value = "分页对象", required = true, defaultValue = "pageNumber=0&pageSize=10") CommonPageable pageable) {
List<DaoCriteria> criterias = new ArrayList<>(); List<DaoCriteria> criterias = new ArrayList<>();
criterias.add(new DaoCriteria("intfcId", QueryOperatorEnum.EQUAL.getName(), id)); criterias.add(new DaoCriteria("intfcId", QueryOperatorEnum.EQUAL.getName(), id));
pageable.setSort(Sort.unsorted());
Page<IntfcAttribute> result = intfcService.queryIntfcAttributeList(criterias, pageable); Page<IntfcAttribute> result = intfcService.queryIntfcAttributeList(criterias, pageable);
return CommonResponseUtil.success(new PageImpl<IntfcAttribute>(result.getContent(), pageable, result.getTotalElements())); return CommonResponseUtil.success(new PageImpl<IntfcAttribute>(result.getContent(), pageable, result.getTotalElements()));
} }
......
...@@ -15,7 +15,6 @@ import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum; ...@@ -15,7 +15,6 @@ import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.op.core.common.query.DaoCriteria; import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
......
...@@ -26,7 +26,6 @@ import com.yeejoin.amos.iot.business.service.intfc.IRuleNodeService; ...@@ -26,7 +26,6 @@ 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.CommonResponse;
import com.yeejoin.amos.op.core.common.response.TreeResponse; import com.yeejoin.amos.op.core.common.response.TreeResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; import com.yeejoin.amos.op.core.util.CommonResponseUtil;
import com.yeejoin.amos.security.common.authorization.Authorization;
/** /**
* *
...@@ -111,7 +110,6 @@ public class RuleDeployController extends BaseController ...@@ -111,7 +110,6 @@ public class RuleDeployController extends BaseController
*/ */
@ApiOperation(httpMethod = "GET", value = "获取规则节点元素", notes = "获取规则节点元素") @ApiOperation(httpMethod = "GET", value = "获取规则节点元素", notes = "获取规则节点元素")
@RequestMapping(value = "/elements", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/elements", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
@Authorization(ingore = true)
public CommonResponse getRuleElements() public CommonResponse getRuleElements()
{ {
List<RuleNode> ruleNodeList = IRuleNodeService.findAll(); List<RuleNode> ruleNodeList = IRuleNodeService.findAll();
......
package com.yeejoin.amos.iot.business.controller; 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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -18,9 +14,11 @@ import com.yeejoin.amos.iot.business.service.intfc.IRuleService; ...@@ -18,9 +14,11 @@ import com.yeejoin.amos.iot.business.service.intfc.IRuleService;
import com.yeejoin.amos.iot.core.common.response.CommonPage; import com.yeejoin.amos.iot.core.common.response.CommonPage;
import com.yeejoin.amos.op.core.common.response.CommonResponse; import com.yeejoin.amos.op.core.common.response.CommonResponse;
import com.yeejoin.amos.op.core.util.CommonResponseUtil; 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 io.swagger.annotations.Api;
import com.yeejoin.amos.security.common.model.UserModel; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.Authorization;
/** /**
* *
...@@ -40,7 +38,6 @@ public class RuleManageController extends BaseController ...@@ -40,7 +38,6 @@ public class RuleManageController extends BaseController
@Autowired @Autowired
private IRuleService ruleService; private IRuleService ruleService;
@Authorization(ingore= true)
@ApiOperation(httpMethod = "GET", value = "根据ID查询规则", notes = "根据ID查询规则") @ApiOperation(httpMethod = "GET", value = "根据ID查询规则", notes = "根据ID查询规则")
@RequestMapping(value = "/rule/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/rule/{id}", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse fetchRuleEntity( public CommonResponse fetchRuleEntity(
......
...@@ -13,7 +13,7 @@ import io.swagger.annotations.Api; ...@@ -13,7 +13,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@RestController @RestController
@RequestMapping(value = "/safe") @RequestMapping(value = "/iot/safe")
@Api(tags = "公司选择api") @Api(tags = "公司选择api")
public class SafetyController extends BaseController { public class SafetyController extends BaseController {
......
...@@ -144,4 +144,8 @@ public interface DeviceMapper { ...@@ -144,4 +144,8 @@ public interface DeviceMapper {
List<Map> findTempAttr(Long eqpId); List<Map> findTempAttr(Long eqpId);
List<Map> qryEqpCountByTemplAttrs(@Param("orgCode") String orgCode, @Param("attrNames") List<String> attrName); List<Map> qryEqpCountByTemplAttrs(@Param("orgCode") String orgCode, @Param("attrNames") List<String> attrName);
List<EquipmentVo> listDeviceAndDeviceCpblAttr(@Param("equipmentId") Long equipmentId);
List<EquipmentVo> listDeviceCpblAttr(@Param("equipmentId") long equipmentId);
} }
package com.yeejoin.amos.iot.business.dao.mapper; package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.EqpTmplAttribute;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo; import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -24,4 +25,5 @@ public interface EqpTmplAttrMapper { ...@@ -24,4 +25,5 @@ public interface EqpTmplAttrMapper {
*/ */
List<EqpTmplAttributeBo> listByEqpTmplId(@Param(value = "eqpTmplId") Long eqpTmplId); List<EqpTmplAttributeBo> listByEqpTmplId(@Param(value = "eqpTmplId") Long eqpTmplId);
List<EqpTmplAttribute> findAllByEqpTmplId(@Param(value = "id") Long id);
} }
package com.yeejoin.amos.iot.business.dao.mapper; package com.yeejoin.amos.iot.business.dao.mapper;
import com.yeejoin.amos.iot.business.entity.EquipmentTemplate;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo; import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo;
import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentTemplateVo; import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentTemplateVo;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.HashMap;
import java.util.List; import java.util.List;
/** /**
...@@ -18,6 +20,7 @@ public interface EqpTmplMapper { ...@@ -18,6 +20,7 @@ public interface EqpTmplMapper {
/** /**
* 根据模板编号获取指定字段集合 * 根据模板编号获取指定字段集合
*/ */
EquipmentTemplateVo getByModel(String name); List<EquipmentTemplateVo> getByModel(String name);
List<EquipmentTemplate> findAll(HashMap<String, Object> param);
} }
package com.yeejoin.amos.iot.business.dao.repository;
import java.io.Serializable;
import java.util.List;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
* 基础dao
*
* @param <T>
* @param <ID>
*/
@NoRepositoryBean
public interface BaseDao<T, ID extends Serializable> extends JpaRepository<T, ID>, CrudRepository<T, ID>,
PagingAndSortingRepository<T, ID>, JpaSpecificationExecutor<T> {
public default T getOneBySpecification(Specification<T> specification) {
List<T> list = findAll(specification);
if (list.isEmpty()) {
return null;
} else {
return list.get(0);
}
}
}
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("alarmDao") @Repository("alarmDao")
public interface IAlarmDao extends IBaseRepository<Alarm, Long> { public interface IAlarmDao extends BaseDao<Alarm, Long> {
@Modifying @Modifying
@Transactional @Transactional
@Query("UPDATE Alarm SET is_delete = 1 WHERE id = ?1") @Query("UPDATE Alarm SET is_delete = 1 WHERE id = ?1")
......
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("capabilityDao") @Repository("capabilityDao")
public interface ICapabilityDao extends IBaseRepository<Capability, Long> public interface ICapabilityDao extends BaseDao<Capability, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: ICapabilitylInterfaceDao.java, v 0.1 2018年1月30日 上午11:21:08 as-chenjiajun Exp $ * @version $Id: ICapabilitylInterfaceDao.java, v 0.1 2018年1月30日 上午11:21:08 as-chenjiajun Exp $
*/ */
public interface ICapabilityInterfaceDao extends IBaseRepository<CapabilitylInterface, Long> public interface ICapabilityInterfaceDao extends BaseDao<CapabilitylInterface, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: ICapabilityPropertyDao.java, v 0.1 2018年1月30日 上午11:29:07 as-chenjiajun Exp $ * @version $Id: ICapabilityPropertyDao.java, v 0.1 2018年1月30日 上午11:29:07 as-chenjiajun Exp $
*/ */
public interface ICapabilityPropertyDao extends IBaseRepository<CapabilityAttribute, Long> public interface ICapabilityPropertyDao extends BaseDao<CapabilityAttribute, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -16,7 +16,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -16,7 +16,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: IConnectionDao.java, v 0.1 2018年3月8日 下午1:43:38 as-chenjiajun Exp $ * @version $Id: IConnectionDao.java, v 0.1 2018年3月8日 下午1:43:38 as-chenjiajun Exp $
*/ */
public interface IConnectionDao extends IBaseRepository<Connection, Long> public interface IConnectionDao extends BaseDao<Connection, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.DataGroup;
public interface IDataGroupDao extends BaseDao<DataGroup, Long>{
}
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.DataModel;
import java.util.List;
public interface IDataModeDao extends BaseDao<DataModel, Long>{
List<DataModel> findAllByOrgCodeAndVisibility(String orgCode, int visibility);
List<DataModel> findAllByVisibility(int visibility);
List<DataModel> findAllByNameAndVisibility(String name, Integer visibility);
List<DataModel> findAllByVisibility(Integer visibility);
List<DataModel> findAllByVisibilityAndIsBlock(int i, boolean b);
List<DataModel> findAllByOrgCodeAndVisibilityAndIsBlock(String orgCode, int i, boolean b);
}
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.DataModelItem;
import java.util.List;
public interface IDataModelItemDao extends BaseDao<DataModelItem, Long>{
List<DataModelItem> findAllByDataModelId(long id);
List<DataModelItem> findAllByDataModelIdAndParentId(Long id, long parentId);
}
...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IDicDao.java, v 0.1 2018年1月26日 下午2:29:53 as-shibaobao Exp $ * @version $Id: IDicDao.java, v 0.1 2018年1月26日 下午2:29:53 as-shibaobao Exp $
*/ */
@Repository("dicDao") @Repository("dicDao")
public interface IDicDao extends IBaseRepository<Dic, Long> { public interface IDicDao extends BaseDao<Dic, Long> {
default Long findIdByTypeAndCode(String type, String code) { default Long findIdByTypeAndCode(String type, String code) {
Dic systemDic = this.findByTypeAndCode(type, code); Dic systemDic = this.findByTypeAndCode(type, code);
if (null != systemDic) { if (null != systemDic) {
...@@ -65,11 +65,12 @@ public interface IDicDao extends IBaseRepository<Dic, Long> { ...@@ -65,11 +65,12 @@ public interface IDicDao extends IBaseRepository<Dic, Long> {
* @param id * @param id
* @return * @return
*/ */
public Dic findById(Long id); // public Dic findById(Long id);
@Modifying @Modifying
@Transactional @Transactional
@Query("UPDATE Dic SET is_delete = 1 WHERE id = ?1") @Query("UPDATE Dic SET is_delete = 1 WHERE id = ?1")
void delDicById(Long id); void delDicById(Long id);
List<Dic> findAllByType(String equipTemplateIndustry);
} }
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-guowubin * @author as-guowubin
* @version $Id: IDroolsRuleDao.java, v 0.1 2018年4月20日 下午4:22:05 as-guowubin Exp $ * @version $Id: IDroolsRuleDao.java, v 0.1 2018年4月20日 下午4:22:05 as-guowubin Exp $
*/ */
public interface IDroolsRuleDao extends IBaseRepository<DroolsRule, String> public interface IDroolsRuleDao extends BaseDao<DroolsRule, String>
{ {
/** /**
* *
......
...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-guowubin * @author as-guowubin
* @version $Id: IEqpCpblDao.java, v 0.1 2018年6月9日 上午10:51:25 as-guowubin Exp $ * @version $Id: IEqpCpblDao.java, v 0.1 2018年6月9日 上午10:51:25 as-guowubin Exp $
*/ */
public interface IEqpCpblDao extends IBaseRepository<EquipmentCapability, Long> public interface IEqpCpblDao extends BaseDao<EquipmentCapability, Long>
{ {
/** /**
* *
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: IEqpCpblPropertyDao.java, v 0.1 2018年7月12日 上午9:29:57 as-chenjiajun Exp $ * @version $Id: IEqpCpblPropertyDao.java, v 0.1 2018年7月12日 上午9:29:57 as-chenjiajun Exp $
*/ */
public interface IEqpCpblPropertyDao extends IBaseRepository<EqpCpblProperty, Long> public interface IEqpCpblPropertyDao extends BaseDao<EqpCpblProperty, Long>
{ {
@Modifying @Modifying
......
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.EqpTmplCpbl;
public interface IEqpTmplCpblDao extends BaseDao<EqpTmplCpbl, Long>{
void deleteByEquipmentDataId(long id);
}
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.entity.EqpTmplData;
public interface IEqpTmplDataDao extends BaseDao<EqpTmplData, Long>{
}
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: IEqpTmplInterfaceDao.java, v 0.1 2018年1月30日 上午10:53:30 as-chenjiajun Exp $ * @version $Id: IEqpTmplInterfaceDao.java, v 0.1 2018年1月30日 上午10:53:30 as-chenjiajun Exp $
*/ */
public interface IEqpTmplInterfaceDao extends IBaseRepository<EqpTmplInterface, Long> public interface IEqpTmplInterfaceDao extends BaseDao<EqpTmplInterface, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-lixiangyang * @author as-lixiangyang
* @version $Id: IEqpTmplPropertyDao.java, v 0.1 2018年1月30日 下午8:13:07 as-lixiangyang Exp $ * @version $Id: IEqpTmplPropertyDao.java, v 0.1 2018年1月30日 下午8:13:07 as-lixiangyang Exp $
*/ */
public interface IEqpTmplPropertyDao extends IBaseRepository<EqpTmplAttribute, Long> public interface IEqpTmplPropertyDao extends BaseDao<EqpTmplAttribute, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
package com.yeejoin.amos.iot.business.dao.repository;
import com.yeejoin.amos.iot.business.dic.EquipTemplateIndustry;
import org.springframework.stereotype.Repository;
@Repository("equipTemplateIndustryDao")
public interface IEquipTemplateIndustryDao extends BaseDao<EquipTemplateIndustry, Long> {
}
...@@ -11,7 +11,6 @@ import org.springframework.stereotype.Repository; ...@@ -11,7 +11,6 @@ import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.entity.Equipment; import com.yeejoin.amos.iot.business.entity.Equipment;
import com.yeejoin.amos.op.core.jpa.IBaseRepository;
/** /**
* 设备dao * 设备dao
...@@ -20,7 +19,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -20,7 +19,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("equipmentDao") @Repository("equipmentDao")
public interface IEquipmentDao extends IBaseRepository<Equipment, Long> { public interface IEquipmentDao extends BaseDao<Equipment, Long> {
@Query(value = "select * from t_equipment e where e.cfg_param_json->'$.sid' = ?1", nativeQuery = true) @Query(value = "select * from t_equipment e where e.cfg_param_json->'$.sid' = ?1", nativeQuery = true)
Equipment findByCfgParamJson(String sid); Equipment findByCfgParamJson(String sid);
......
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("equipmentTemplateDao") @Repository("equipmentTemplateDao")
public interface IEquipmentTemplateDao extends IBaseRepository<EquipmentTemplate, Long> { public interface IEquipmentTemplateDao extends BaseDao<EquipmentTemplate, Long> {
@Query("Select id from EquipmentTemplate where type =?1") @Query("Select id from EquipmentTemplate where type =?1")
List<Long> findIdByType(Integer type); List<Long> findIdByType(Integer type);
......
...@@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository; ...@@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository;
* @author as-youjun * @author as-youjun
*/ */
@Repository("frameProtocolDao") @Repository("frameProtocolDao")
public interface IFrameProtocolDao extends IBaseRepository<FrameProtocol, Long> { public interface IFrameProtocolDao extends BaseDao<FrameProtocol, Long> {
/** /**
* 查询帧类型对应的FrameProtocol * 查询帧类型对应的FrameProtocol
......
...@@ -6,6 +6,6 @@ import com.yeejoin.amos.iot.business.entity.IntfcProtocolVo; ...@@ -6,6 +6,6 @@ import com.yeejoin.amos.iot.business.entity.IntfcProtocolVo;
import com.yeejoin.amos.op.core.jpa.IBaseRepository; import com.yeejoin.amos.op.core.jpa.IBaseRepository;
@Repository("infcProtocolDao") @Repository("infcProtocolDao")
public interface IInfcProtocolDao extends IBaseRepository<IntfcProtocolVo, Long>{ public interface IInfcProtocolDao extends BaseDao<IntfcProtocolVo, Long>{
} }
...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IIntfcAttributeDao.java, v 0.1 2018年1月26日 下午1:18:23 as-shibaobao Exp $ * @version $Id: IIntfcAttributeDao.java, v 0.1 2018年1月26日 下午1:18:23 as-shibaobao Exp $
*/ */
@Repository("intfcAttributeDao") @Repository("intfcAttributeDao")
public interface IIntfcAttributeDao extends IBaseRepository<IntfcAttribute, Long> public interface IIntfcAttributeDao extends BaseDao<IntfcAttribute, Long>
{ {
/** /**
* *
......
...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("intfcDao") @Repository("intfcDao")
public interface IIntfcDao extends IBaseRepository<Intfc, Long> { public interface IIntfcDao extends BaseDao<Intfc, Long> {
@Modifying @Modifying
@Transactional @Transactional
@Query("UPDATE Intfc SET is_delete = 1 WHERE id = ?1") @Query("UPDATE Intfc SET is_delete = 1 WHERE id = ?1")
......
...@@ -21,7 +21,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -21,7 +21,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: ILinkVoDao.java, v 0.1 2018年4月10日 下午3:12:57 AS-guowubin Exp $ * @version $Id: ILinkVoDao.java, v 0.1 2018年4月10日 下午3:12:57 AS-guowubin Exp $
*/ */
@Repository @Repository
public interface ILinkVoDao extends IBaseRepository<LinkVo, String> { public interface ILinkVoDao extends BaseDao<LinkVo, String> {
List<LinkVo> findBySourceId(String sourceId); List<LinkVo> findBySourceId(String sourceId);
......
...@@ -10,6 +10,6 @@ import org.springframework.stereotype.Repository; ...@@ -10,6 +10,6 @@ import org.springframework.stereotype.Repository;
* @author as-youjun * @author as-youjun
*/ */
@Repository("listenCommDao") @Repository("listenCommDao")
public interface IListenCommDao extends IBaseRepository<ListenComm, Long> { public interface IListenCommDao extends BaseDao<ListenComm, Long> {
} }
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("metricDataDao") @Repository("metricDataDao")
public interface IMetricDataDao extends IBaseRepository<MetricData, Long> { public interface IMetricDataDao extends BaseDao<MetricData, Long> {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: INodeDao.java, v 0.1 2018年3月8日 下午1:43:57 as-chenjiajun Exp $ * @version $Id: INodeDao.java, v 0.1 2018年3月8日 下午1:43:57 as-chenjiajun Exp $
*/ */
public interface INodeDao extends IBaseRepository<Node, Long> public interface INodeDao extends BaseDao<Node, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: INodeVoDao.java, v 0.1 2018年4月10日 下午3:31:46 as-chenjiajun Exp $ * @version $Id: INodeVoDao.java, v 0.1 2018年4月10日 下午3:31:46 as-chenjiajun Exp $
*/ */
@Repository @Repository
public interface INodeVoDao extends IBaseRepository<NodeVo,String> public interface INodeVoDao extends BaseDao<NodeVo,String>
{ {
/** /**
* *
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IOrgImgRelationshipsDao.java, v 0.1 2018年5月7日 下午1:57:08 as-chenjiajun Exp $ * @version $Id: IOrgImgRelationshipsDao.java, v 0.1 2018年5月7日 下午1:57:08 as-chenjiajun Exp $
*/ */
@Repository @Repository
public interface IOrgImgRelationshipsDao extends IBaseRepository<OrgImgRelationships,Long> public interface IOrgImgRelationshipsDao extends BaseDao<OrgImgRelationships,Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("pollingJobDao") @Repository("pollingJobDao")
public interface IPollingJobDao extends IBaseRepository<PollingJob, Long> { public interface IPollingJobDao extends BaseDao<PollingJob, Long> {
/** /**
* 查询可用job * 查询可用job
......
...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("protocolDao") @Repository("protocolDao")
public interface IProtocolDao extends IBaseRepository<Protocol, Long> { public interface IProtocolDao extends BaseDao<Protocol, Long> {
/** /**
* 根据名称查询 * 根据名称查询
......
...@@ -16,7 +16,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -16,7 +16,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: IRuleDao.java, v 0.1 2018年4月10日 下午3:50:41 as-chenjiajun Exp $ * @version $Id: IRuleDao.java, v 0.1 2018年4月10日 下午3:50:41 as-chenjiajun Exp $
*/ */
public interface IRuleDao extends IBaseRepository<Rule, String> public interface IRuleDao extends BaseDao<Rule, String>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -20,7 +20,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IRuleDataSourceDao.java, v 0.1 2018年4月10日 下午3:27:50 as-chenjiajun Exp $ * @version $Id: IRuleDataSourceDao.java, v 0.1 2018年4月10日 下午3:27:50 as-chenjiajun Exp $
*/ */
@Repository @Repository
public interface IRuleDataSourceDao extends IBaseRepository<RuleDataSource,String> public interface IRuleDataSourceDao extends BaseDao<RuleDataSource,String>
{ {
/** /**
* *
......
...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IRuleElementDao.java, v 0.1 2018年4月10日 下午3:59:49 as-chenjiajun Exp $ * @version $Id: IRuleElementDao.java, v 0.1 2018年4月10日 下午3:59:49 as-chenjiajun Exp $
*/ */
@Repository @Repository
public interface IRuleElementDao extends IBaseRepository<RuleElement,Long> public interface IRuleElementDao extends BaseDao<RuleElement,Long>
{ {
} }
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IRuleEmailDao.java, v 0.1 2018年4月10日 下午3:29:51 as-chenjiajun Exp $ * @version $Id: IRuleEmailDao.java, v 0.1 2018年4月10日 下午3:29:51 as-chenjiajun Exp $
*/ */
@Repository @Repository
public interface IRuleEmailDao extends IBaseRepository<RuleEmail,String> public interface IRuleEmailDao extends BaseDao<RuleEmail,String>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-chenjiajun * @author as-chenjiajun
* @version $Id: IRuleGroupDao.java, v 0.1 2018年4月10日 下午3:51:41 as-chenjiajun Exp $ * @version $Id: IRuleGroupDao.java, v 0.1 2018年4月10日 下午3:51:41 as-chenjiajun Exp $
*/ */
public interface IRuleGroupDao extends IBaseRepository<RuleGroup, String> public interface IRuleGroupDao extends BaseDao<RuleGroup, String>
{ {
/** /**
* <pre> * <pre>
......
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IRuleMqttDao.java, v 0.1 2018年5月4日 下午2:29:52 as-guowubin Exp $ * @version $Id: IRuleMqttDao.java, v 0.1 2018年5月4日 下午2:29:52 as-guowubin Exp $
*/ */
@Repository @Repository
public interface IRuleMqttDao extends IBaseRepository<RuleMqtt,String> public interface IRuleMqttDao extends BaseDao<RuleMqtt,String>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -12,7 +12,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -12,7 +12,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @author as-guowubin * @author as-guowubin
* @version $Id: IRuleNodeDao.java, v 0.1 2018年4月24日 下午5:16:59 as-guowubin Exp $ * @version $Id: IRuleNodeDao.java, v 0.1 2018年4月24日 下午5:16:59 as-guowubin Exp $
*/ */
public interface IRuleNodeDao extends IBaseRepository<RuleNode, String> public interface IRuleNodeDao extends BaseDao<RuleNode, String>
{ {
} }
...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -18,7 +18,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: IRuleTcpDao.java, v 0.1 2018年5月4日 下午2:27:46 as-guowubin Exp $ * @version $Id: IRuleTcpDao.java, v 0.1 2018年5月4日 下午2:27:46 as-guowubin Exp $
*/ */
@Repository @Repository
public interface IRuleTcpDao extends IBaseRepository<RuleTcp,String> public interface IRuleTcpDao extends BaseDao<RuleTcp,String>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -15,7 +15,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: ISectionDao.java, v 0.1 2018年6月27日 下午2:10:31 as-chenjiajun Exp $ * @version $Id: ISectionDao.java, v 0.1 2018年6月27日 下午2:10:31 as-chenjiajun Exp $
*/ */
@Repository("sectionDao") @Repository("sectionDao")
public interface ISectionDao extends IBaseRepository<Section, Long> public interface ISectionDao extends BaseDao<Section, Long>
{ {
} }
...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,7 +17,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: ISubgraohDao.java, v 0.1 2018年3月8日 下午1:27:53 as-chenjiajun Exp $ * @version $Id: ISubgraohDao.java, v 0.1 2018年3月8日 下午1:27:53 as-chenjiajun Exp $
*/ */
@Repository("subgraohDao") @Repository("subgraohDao")
public interface ISubgraohDao extends IBaseRepository<Subgraph, Long> public interface ISubgraohDao extends BaseDao<Subgraph, Long>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -12,6 +12,6 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -12,6 +12,6 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("subviewDao") @Repository("subviewDao")
public interface ISubviewDao extends IBaseRepository<Subview, Long> { public interface ISubviewDao extends BaseDao<Subview, Long> {
} }
...@@ -19,7 +19,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -19,7 +19,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: ISystemLogDao.java, v 0.1 2018年4月23日 下午5:48:14 as-guowubin Exp $ * @version $Id: ISystemLogDao.java, v 0.1 2018年4月23日 下午5:48:14 as-guowubin Exp $
*/ */
@Repository @Repository
public interface ISystemLogDao extends IBaseRepository<SystemLog, String> public interface ISystemLogDao extends BaseDao<SystemLog, String>
{ {
@Modifying @Modifying
@Transactional @Transactional
......
...@@ -12,7 +12,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -12,7 +12,7 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* *
*/ */
@Repository("verticleDao") @Repository("verticleDao")
public interface IVerticleDao extends IBaseRepository<Verticle, Long> { public interface IVerticleDao extends BaseDao<Verticle, Long> {
/** /**
* 查询包名对应的verticle * 查询包名对应的verticle
......
...@@ -11,6 +11,7 @@ import javax.persistence.Transient; ...@@ -11,6 +11,7 @@ import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yeejoin.amos.op.core.entity.Resource; import com.yeejoin.amos.op.core.entity.Resource;
import org.hibernate.annotations.NotFound;
/** /**
* 基本实体类 * 基本实体类
...@@ -31,10 +32,10 @@ public class BasicEntity extends Resource implements Serializable { ...@@ -31,10 +32,10 @@ public class BasicEntity extends Resource implements Serializable {
/** /**
* 是否删除 * 是否删除
*/ */
private Boolean isDelete = false; private Boolean isDelete = new Boolean(false);
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true) @Column(name = "id", nullable = false, unique = true)
public Long getId() { public Long getId() {
return id; return id;
......
package com.yeejoin.amos.iot.business.entity;
import com.yeejoin.amos.op.core.entity.Resource;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Inheritance
@Table(name = "t_data_group")
public class DataGroup extends Resource implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true)
private long id;
private String name;
private String code;
private String type;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
package com.yeejoin.amos.iot.business.entity;
import com.yeejoin.amos.op.core.entity.Resource;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@Entity
@Inheritance
@Table(name = "t_interface_data_model")
public class DataModel extends Resource implements Serializable {
private static final long serialVersionUID = 1L;
/**
* ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true)
private Long id;
private String name;
int maxFrameLength;
int lengthFieldOffset;
int lengthFieldLength;
int lengthAdjustment;
int initialBytesToStrip;
boolean failFast;
private String checkFun;
private int checkLength;
private int checkEndLengthOffset;
private String orgCode;
private int visibility;
private String version;
private String descr;
private String type;
private String byteOrder;
private boolean isBlock;
public boolean getIsBlock() {
return isBlock;
}
public void setIsBlock(boolean block) {
isBlock = block;
}
@Transient
@OneToMany(mappedBy = "dataModelId", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
@Where(clause="is_delete=0")//表示未删除的数据
private List<DataModelItem> items;
@Transient
private List<DataModelItem> deleteData;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMaxFrameLength() {
return maxFrameLength;
}
public void setMaxFrameLength(int maxFrameLength) {
this.maxFrameLength = maxFrameLength;
}
public int getLengthFieldOffset() {
return lengthFieldOffset;
}
public void setLengthFieldOffset(int lengthFieldOffset) {
this.lengthFieldOffset = lengthFieldOffset;
}
public int getLengthFieldLength() {
return lengthFieldLength;
}
public void setLengthFieldLength(int lengthFieldLength) {
this.lengthFieldLength = lengthFieldLength;
}
public int getLengthAdjustment() {
return lengthAdjustment;
}
public void setLengthAdjustment(int lengthAdjustment) {
this.lengthAdjustment = lengthAdjustment;
}
public int getInitialBytesToStrip() {
return initialBytesToStrip;
}
public void setInitialBytesToStrip(int initialBytesToStrip) {
this.initialBytesToStrip = initialBytesToStrip;
}
public boolean getIsFailFast() {
return failFast;
}
public void setIsFailFast(boolean failFast) {
this.failFast = failFast;
}
public String getCheckFun() {
return checkFun;
}
public void setCheckFun(String checkFun) {
this.checkFun = checkFun;
}
public int getCheckLength() {
return checkLength;
}
public void setCheckLength(int checkLength) {
this.checkLength = checkLength;
}
public int getCheckEndLengthOffset() {
return checkEndLengthOffset;
}
public void setCheckEndLengthOffset(int checkEndLengthOffset) {
this.checkEndLengthOffset = checkEndLengthOffset;
}
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public int getVisibility() {
return visibility;
}
public void setVisibility(int visibility) {
this.visibility = visibility;
}
public String getDescr() {
return descr;
}
public void setDescr(String descr) {
this.descr = descr;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getByteOrder() {
return byteOrder;
}
public void setByteOrder(String byteOrder) {
this.byteOrder = byteOrder;
}
public List<DataModelItem> getItems() {
return items;
}
public void setItems(List<DataModelItem> items) {
this.items = items;
}
public List<DataModelItem> getDeleteData() {
return deleteData;
}
public void setDeleteData(List<DataModelItem> deleteData) {
this.deleteData = deleteData;
}
}
package com.yeejoin.amos.iot.business.entity;
import com.yeejoin.amos.op.core.entity.Resource;
import javax.persistence.*;
import java.io.Serializable;
import java.util.List;
@Entity
@Inheritance
@Table(name = "t_interface_data_model_item")
public class DataModelItem extends Resource implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true)
private long id;
private long groupId;
private long length;
private Boolean isDelete;
private String name;
private long serialNumber;
private long dataModelId;
private String displayName;
private long parentId;
@OneToMany(mappedBy="parentId", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private List<DataModelItem> children;
public List<DataModelItem> getChildren() {
return children;
}
public void setChildren(List<DataModelItem> children) {
this.children = children;
}
public long getParentId() {
return parentId;
}
public void setParentId(long parentId) {
this.parentId = parentId;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getGroupId() {
return groupId;
}
public void setGroupId(long groupId) {
this.groupId = groupId;
}
public long getLength() {
return length;
}
public void setLength(long length) {
this.length = length;
}
public Boolean getIsDelete() {
return isDelete;
}
public void setIsDelete(Boolean delete) {
isDelete = delete;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public long getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(long serialNumber) {
this.serialNumber = serialNumber;
}
public long getDataModelId() {
return dataModelId;
}
public void setDataModelId(long dataModelId) {
this.dataModelId = dataModelId;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
package com.yeejoin.amos.iot.business.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.op.core.entity.Resource;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name = "t_equipment_templ_cpbl")
public class EqpTmplCpbl extends Resource implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true)
private long id;
private long intfcId;
private String dataType;
@Column(name = "code")
private String name;
@Column(name = "name")
private String displayName;
private String strValue;
private String maxValue;
private String minValue;
private String enumTypes;
private String type;
private long equipmentDataId;
private long intfcDataModelItem;
private long serialNumber;
private String endian;
private long length;
private long objectId;
private long parentId;
private boolean isArray;
private long arrayLength;
private boolean isControl;
private long accuracy;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getIntfcId() {
return intfcId;
}
public void setIntfcId(long intfcId) {
this.intfcId = intfcId;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getStrValue() {
return strValue;
}
public void setStrValue(String strValue) {
this.strValue = strValue;
}
public String getMaxValue() {
return maxValue;
}
public void setMaxValue(String maxValue) {
this.maxValue = maxValue;
}
public String getMinValue() {
return minValue;
}
public void setMinValue(String minValue) {
this.minValue = minValue;
}
public String getEnumTypes() {
return enumTypes;
}
public void setEnumTypes(String enumTypes) {
this.enumTypes = enumTypes;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public long getEquipmentDataId() {
return equipmentDataId;
}
public void setEquipmentDataId(long equipmentDataId) {
this.equipmentDataId = equipmentDataId;
}
public long getIntfcDataModelItem() {
return intfcDataModelItem;
}
public void setIntfcDataModelItem(long intfcDataModelItem) {
this.intfcDataModelItem = intfcDataModelItem;
}
public long getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(long serialNumber) {
this.serialNumber = serialNumber;
}
public String getEndian() {
return endian;
}
public void setEndian(String endian) {
this.endian = endian;
}
public long getLength() {
return length;
}
public void setLength(long length) {
this.length = length;
}
public long getObjectId() {
return objectId;
}
public void setObjectId(long objectId) {
this.objectId = objectId;
}
public long getParentId() {
return parentId;
}
public void setParentId(long parentId) {
this.parentId = parentId;
}
public boolean getIsArray() {
return isArray;
}
public void setIsArray(boolean array) {
isArray = array;
}
public long getArrayLength() {
return arrayLength;
}
public void setArrayLength(long arrayLength) {
this.arrayLength = arrayLength;
}
public boolean getIsControl() {
return isControl;
}
public void setIsControl(boolean control) {
isControl = control;
}
public long getAccuracy() {
return accuracy;
}
public void setAccuracy(long accuracy) {
this.accuracy = accuracy;
}
}
package com.yeejoin.amos.iot.business.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.op.core.entity.Resource;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name = "t_equipment_templ_data")
@Where(clause="is_delete=0")//表示未删除的数据
public class EqpTmplData extends Resource implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true)
private long id;
private long intfcId;
private long intfcDataModelId;
private boolean isDelete;
private long equipmentTemplId;
private long eqpTmplIntfcId;
private String name;
private String control;
private boolean isArray;
private long cpblId;
private long dataModelItemId;
public long getDataModelItemId() {
return dataModelItemId;
}
public void setDataModelItemId(long dataModelItemId) {
this.dataModelItemId = dataModelItemId;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getIntfcId() {
return intfcId;
}
public void setIntfcId(long intfcId) {
this.intfcId = intfcId;
}
public long getIntfcDataModelId() {
return intfcDataModelId;
}
public void setIntfcDataModelId(long intfcDataModelId) {
this.intfcDataModelId = intfcDataModelId;
}
public boolean isDelete() {
return isDelete;
}
public void setDelete(boolean delete) {
isDelete = delete;
}
public long getEquipmentTemplId() {
return equipmentTemplId;
}
public void setEquipmentTemplId(long equipmentTemplId) {
this.equipmentTemplId = equipmentTemplId;
}
public long getEqpTmplIntfcId() {
return eqpTmplIntfcId;
}
public void setEqpTmplIntfcId(long eqpTmplIntfcId) {
this.eqpTmplIntfcId = eqpTmplIntfcId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getControl() {
return control;
}
public void setControl(String control) {
this.control = control;
}
public boolean isArray() {
return isArray;
}
public void setArray(boolean array) {
isArray = array;
}
public long getCpblId() {
return cpblId;
}
public void setCpblId(long cpblId) {
this.cpblId = cpblId;
}
}
package com.yeejoin.amos.iot.business.entity;
import com.yeejoin.amos.op.core.entity.Resource;
import org.hibernate.annotations.Where;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name = "t_equipment_templ_cpbl")
@Where(clause="is_delete=0")//表示未删除的数据
public class EqpTmplDataAttr extends Resource implements Serializable {
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true)
private long id;
private String dataType;
private String name;
private String code;
private String strValue;
private String maxValue;
private String minValue;
private String enumTypes;
private String type;
private long equipmentDataId;
private long intfcDataModelItem;
private long serialNumber;
private String endian;
private long length;
private long parentId;
private boolean isArray;
private long arrayLength;
private boolean isControl;
private long accuracy;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getDataType() {
return dataType;
}
public void setDataType(String dataType) {
this.dataType = dataType;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getStrValue() {
return strValue;
}
public void setStrValue(String strValue) {
this.strValue = strValue;
}
public String getMaxValue() {
return maxValue;
}
public void setMaxValue(String maxValue) {
this.maxValue = maxValue;
}
public String getMinValue() {
return minValue;
}
public void setMinValue(String minValue) {
this.minValue = minValue;
}
public String getEnumTypes() {
return enumTypes;
}
public void setEnumTypes(String enumTypes) {
this.enumTypes = enumTypes;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public long getEquipmentDataId() {
return equipmentDataId;
}
public void setEquipmentDataId(long equipmentDataId) {
this.equipmentDataId = equipmentDataId;
}
public long getIntfcDataModelItem() {
return intfcDataModelItem;
}
public void setIntfcDataModelItem(long intfcDataModelItem) {
this.intfcDataModelItem = intfcDataModelItem;
}
public long getSerialNumber() {
return serialNumber;
}
public void setSerialNumber(long serialNumber) {
this.serialNumber = serialNumber;
}
public String getEndian() {
return endian;
}
public void setEndian(String endian) {
this.endian = endian;
}
public long getLength() {
return length;
}
public void setLength(long length) {
this.length = length;
}
public boolean getIsArray() {
return isArray;
}
public void setIsArray(boolean array) {
isArray = array;
}
public boolean getIsControl() {
return isControl;
}
public void setIsControl(boolean control) {
isControl = control;
}
public long getAccuracy() {
return accuracy;
}
public void setAccuracy(long accuracy) {
this.accuracy = accuracy;
}
public long getParentId() {
return parentId;
}
public void setParentId(long parentId) {
this.parentId = parentId;
}
public long getArrayLength() {
return arrayLength;
}
public void setArrayLength(long arrayLength) {
this.arrayLength = arrayLength;
}
}
...@@ -90,6 +90,9 @@ public class Equipment extends TimeEntity { ...@@ -90,6 +90,9 @@ public class Equipment extends TimeEntity {
*/ */
private String icon; private String icon;
private String authOrg;
@Column(name = "name", length = 100, nullable = false) @Column(name = "name", length = 100, nullable = false)
public String getName() { public String getName() {
return name; return name;
...@@ -204,4 +207,12 @@ public class Equipment extends TimeEntity { ...@@ -204,4 +207,12 @@ public class Equipment extends TimeEntity {
this.icon = icon; this.icon = icon;
} }
@Column(name="auth_org")
public String getAuthOrg() {
return authOrg;
}
public void setAuthOrg(String authOrg) {
this.authOrg = authOrg;
}
} }
...@@ -58,7 +58,7 @@ public class EquipmentCapability implements Serializable { ...@@ -58,7 +58,7 @@ public class EquipmentCapability implements Serializable {
private Integer monitorPeriod = 30; private Integer monitorPeriod = 30;
@Id @Id
@GeneratedValue(strategy = GenerationType.AUTO) @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", nullable = false, unique = true) @Column(name = "id", nullable = false, unique = true)
public Long getId() { public Long getId() {
return id; return id;
......
...@@ -19,6 +19,7 @@ import org.hibernate.annotations.Fetch; ...@@ -19,6 +19,7 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.iot.business.dic.CommunityProtocol; import com.yeejoin.amos.iot.business.dic.CommunityProtocol;
/** /**
...@@ -30,6 +31,7 @@ import com.yeejoin.amos.iot.business.dic.CommunityProtocol; ...@@ -30,6 +31,7 @@ import com.yeejoin.amos.iot.business.dic.CommunityProtocol;
@Entity @Entity
@Table(name = "t_interface") @Table(name = "t_interface")
@Where(clause="is_delete=0")//表示未删除的数据 @Where(clause="is_delete=0")//表示未删除的数据
@JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
public class Intfc extends TimeEntity { public class Intfc extends TimeEntity {
/** /**
...@@ -187,4 +189,19 @@ public class Intfc extends TimeEntity { ...@@ -187,4 +189,19 @@ public class Intfc extends TimeEntity {
this.isUser = isUser; this.isUser = isUser;
} }
@Override
public String toString() {
return "Intfc{" +
"name='" + name + '\'' +
", displayName='" + displayName + '\'' +
", visibility=" + visibility +
", remark='" + remark + '\'' +
", dicIdCommMode=" + dicIdCommMode +
", communityProtocol=" + communityProtocol +
", userId='" + userId + '\'' +
", attributes=" + attributes +
", orgCode='" + orgCode + '\'' +
", isUser=" + isUser +
'}';
}
} }
package com.yeejoin.amos.iot.business.entity;
import org.apache.log4j.Logger;
import org.hibernate.annotations.Where;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@Entity
@Table(name = "t_intfc_default_attr")
@Where(clause = "is_delete=0")//表示未删除的数据
public class IntfcDefaultAttribute extends BasicAttribute implements Serializable, Cloneable{
/**
*
*/
private static final long serialVersionUID = 6818794079648782928L;
/**
* 日志记录器
*/
private static final Logger logger = Logger
.getLogger(IntfcDefaultAttribute.class);
/**
* 是否必填
*/
private Boolean isRequired;
@Column(name = "is_required", columnDefinition = "bit")
public Boolean getIsRequired() {
return isRequired;
}
public void setIsRequired(Boolean isRequired) {
this.isRequired = isRequired;
}
/**
* 接口外键ID
*/
private Long dicId;
@Column(name = "dicId")
public Long getDicId() {
return dicId;
}
public void setDicId(Long dicId) {
this.dicId = dicId;
}
@Override
public Object clone() {
IntfcDefaultAttribute newObj = null;
try {
newObj = (IntfcDefaultAttribute) super.clone();
} catch (CloneNotSupportedException e) {
logger.error(e);
}
return newObj;
}
}
...@@ -6,6 +6,7 @@ package com.yeejoin.amos.iot.business.entity; ...@@ -6,6 +6,7 @@ package com.yeejoin.amos.iot.business.entity;
import java.util.List; import java.util.List;
import com.yeejoin.amos.iot.rule.resource.RuleAIEntity; import com.yeejoin.amos.iot.rule.resource.RuleAIEntity;
import org.springframework.util.ObjectUtils;
/** /**
* *
...@@ -36,6 +37,8 @@ public class MetricDataRo extends RuleAIEntity { ...@@ -36,6 +37,8 @@ public class MetricDataRo extends RuleAIEntity {
* 装备id * 装备id
*/ */
private Long eqpId; private Long eqpId;
private String eqpName;
/** /**
* 视图对象id * 视图对象id
...@@ -46,6 +49,29 @@ public class MetricDataRo extends RuleAIEntity { ...@@ -46,6 +49,29 @@ public class MetricDataRo extends RuleAIEntity {
*/ */
private String orgCode; private String orgCode;
private Long cpblId;
private Object eqpConfigMap;
private String[] authOrg;
public Object getEqpConfigMap() {
return eqpConfigMap;
}
public void setEqpConfigMap(Object eqpConfigMap) {
this.eqpConfigMap = eqpConfigMap;
}
public String getEqpName() {
return eqpName;
}
public void setEqpName(String eqpName) {
this.eqpName = eqpName;
}
public List<MetricData> getMetricDatas() public List<MetricData> getMetricDatas()
{ {
return metricDatas; return metricDatas;
...@@ -86,4 +112,37 @@ public class MetricDataRo extends RuleAIEntity { ...@@ -86,4 +112,37 @@ public class MetricDataRo extends RuleAIEntity {
this.orgCode = orgCode; this.orgCode = orgCode;
} }
public Long getCpblId() {
return cpblId;
}
public void setCpblId(Long cpblId) {
this.cpblId = cpblId;
}
public String[] getAuthOrg() {
return authOrg;
}
public void setAuthOrg(String authOrg) {
if (!ObjectUtils.isEmpty(authOrg)) {
String str = authOrg.replace("[", "");
str = str.replace("]", "");
str = str.replace(" ", "");
this.authOrg = str.split(",");
return;
}
this.authOrg = null;
}
@Override
public String toString() {
return "MetricDataRo{" +
"metricDatas=" + metricDatas +
", eqpId=" + eqpId +
", subgraphId=" + subgraphId +
", orgCode='" + orgCode + '\'' +
", cpblId=" + cpblId +
'}';
}
} }
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
*/ */
package com.yeejoin.amos.iot.business.entity; package com.yeejoin.amos.iot.business.entity;
import java.io.Serializable;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.FetchType; import javax.persistence.FetchType;
...@@ -14,6 +16,7 @@ import org.hibernate.annotations.Fetch; ...@@ -14,6 +16,7 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.iot.business.dic.ScriptLang; import com.yeejoin.amos.iot.business.dic.ScriptLang;
/** /**
...@@ -22,10 +25,11 @@ import com.yeejoin.amos.iot.business.dic.ScriptLang; ...@@ -22,10 +25,11 @@ import com.yeejoin.amos.iot.business.dic.ScriptLang;
* @author as-youjun * @author as-youjun
* *
*/ */
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
@Entity @Entity
@Table(name = "t_protocol") @Table(name = "t_protocol")
@Where(clause="is_delete=0")//表示未删除的数据 @Where(clause="is_delete=0")//表示未删除的数据
public class Protocol extends TimeEntity { public class Protocol extends TimeEntity implements Serializable{
/** /**
* *
...@@ -182,5 +186,5 @@ public class Protocol extends TimeEntity { ...@@ -182,5 +186,5 @@ public class Protocol extends TimeEntity {
public void setOrgCode(String orgCode) { public void setOrgCode(String orgCode) {
this.orgCode = orgCode; this.orgCode = orgCode;
} }
} }
package com.yeejoin.amos.iot.business.entity; package com.yeejoin.amos.iot.business.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import javax.persistence.Column; import javax.persistence.Column;
...@@ -10,14 +7,17 @@ import javax.persistence.Entity; ...@@ -10,14 +7,17 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty; import org.hibernate.validator.constraints.NotEmpty;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.yeejoin.amos.op.core.entity.BusinessEntity; import com.yeejoin.amos.op.core.entity.BusinessEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/** /**
* *
* <pre> * <pre>
...@@ -31,6 +31,7 @@ import com.yeejoin.amos.op.core.entity.BusinessEntity; ...@@ -31,6 +31,7 @@ import com.yeejoin.amos.op.core.entity.BusinessEntity;
@ApiModel @ApiModel
@Table(name = "t_rm_rule") @Table(name = "t_rm_rule")
@Where(clause="is_delete=0")//表示未删除的数据 @Where(clause="is_delete=0")//表示未删除的数据
@JsonIgnoreProperties(value = { "hibernateLazyInitializer"})
public class Rule extends BusinessEntity implements Serializable public class Rule extends BusinessEntity implements Serializable
{ {
......
...@@ -9,6 +9,7 @@ import javax.persistence.Id; ...@@ -9,6 +9,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
...@@ -27,15 +28,16 @@ import com.yeejoin.amos.op.core.entity.Resource; ...@@ -27,15 +28,16 @@ import com.yeejoin.amos.op.core.entity.Resource;
@Entity @Entity
@Table(name = "t_rm_datasource") @Table(name = "t_rm_datasource")
@Where(clause="is_delete=0")//表示未删除的数据 @Where(clause="is_delete=0")//表示未删除的数据
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class RuleDataSource extends Resource implements Serializable public class RuleDataSource extends Resource implements Serializable
{ {
/** /**
* <pre> * <pre>
* *
* </pre> * </pre>
*/ */
private static final long serialVersionUID = 853297157740075669L; private static final long serialVersionUID = 1L;
/** /**
* id * id
...@@ -75,6 +77,9 @@ public class RuleDataSource extends Resource implements Serializable ...@@ -75,6 +77,9 @@ public class RuleDataSource extends Resource implements Serializable
*/ */
@Column(name = "monitor_Rule_id") @Column(name = "monitor_Rule_id")
private Long monitorRuleId; private Long monitorRuleId;
@Column(name = "cpbl_id")
private long cpblId;
/** /**
* 是否删除 * 是否删除
...@@ -180,6 +185,13 @@ public class RuleDataSource extends Resource implements Serializable ...@@ -180,6 +185,13 @@ public class RuleDataSource extends Resource implements Serializable
{ {
this.monitorRuleId = monitorRuleId; this.monitorRuleId = monitorRuleId;
} }
public long getCpblId() {
return cpblId;
}
public void setCpblId(long cpblId) {
this.cpblId = cpblId;
}
} }
\ No newline at end of file
...@@ -9,7 +9,9 @@ import javax.persistence.Id; ...@@ -9,7 +9,9 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Proxy;
import org.hibernate.annotations.Where; import org.hibernate.annotations.Where;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
...@@ -25,7 +27,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore; ...@@ -25,7 +27,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
*/ */
@Entity @Entity
@Table(name = "t_rm_mqtt") @Table(name = "t_rm_mqtt")
@Where(clause="is_delete=0")//表示未删除的数据 @Where(clause="is_delete=0")//表示未删除的数据
@Proxy(lazy = false)
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class RuleMqtt implements Serializable public class RuleMqtt implements Serializable
{ {
...@@ -163,6 +167,20 @@ public class RuleMqtt implements Serializable ...@@ -163,6 +167,20 @@ public class RuleMqtt implements Serializable
{ {
this.password = password; this.password = password;
} }
@Override
public String toString() {
return "RuleMqtt{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", displayName='" + displayName + '\'' +
", serverIp='" + serverIp + '\'' +
", port='" + port + '\'' +
", theme='" + theme + '\'' +
", userName='" + userName + '\'' +
", password='" + password + '\'' +
", isDelete=" + isDelete +
'}';
}
} }
\ No newline at end of file
package com.yeejoin.amos.iot.business.entity.mybatis; package com.yeejoin.amos.iot.business.entity.mybatis;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.springframework.util.ObjectUtils;
public class EquipmentVo { public class EquipmentVo {
/** /**
* 名称 * 名称
...@@ -83,6 +87,9 @@ public class EquipmentVo { ...@@ -83,6 +87,9 @@ public class EquipmentVo {
* 设备logo * 设备logo
*/ */
private String logo; private String logo;
private String authOrg;
/** /**
* 所属拓扑视图名称 * 所属拓扑视图名称
*/ */
...@@ -100,6 +107,21 @@ public class EquipmentVo { ...@@ -100,6 +107,21 @@ public class EquipmentVo {
return name; return name;
} }
public String[] getAuthOrg() {
if (!ObjectUtils.isEmpty(authOrg)) {
String str = authOrg.replace("[", "");
str = str.replace("]", "");
str = str.replace(" ", "");
return str.split(",");
}
return null;
}
public void setAuthOrg(String authOrg) {
this.authOrg = authOrg;
}
public void setName(String name) { public void setName(String name) {
if(name != null){ if(name != null){
name = name.trim();//去掉前后空格 name = name.trim();//去掉前后空格
......
...@@ -19,6 +19,7 @@ public class RuleNodeType ...@@ -19,6 +19,7 @@ public class RuleNodeType
public static final String DATANODE_SUBUSER = "datanodeSubUser"; // 子用户 public static final String DATANODE_SUBUSER = "datanodeSubUser"; // 子用户
public static final String DATANODE_TASK = "datanodeTask"; // 任务 public static final String DATANODE_TASK = "datanodeTask"; // 任务
public static final String DATANODE_VIEW = "datanodeView"; // 视图 public static final String DATANODE_VIEW = "datanodeView"; // 视图
public static final String DATANODE_CPBL = "datanodeCapability"; // 视图
/** /**
* 告警节点 * 告警节点
*/ */
......
...@@ -5,11 +5,7 @@ package com.yeejoin.amos.iot.business.polling; ...@@ -5,11 +5,7 @@ package com.yeejoin.amos.iot.business.polling;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils; import org.apache.commons.collections.MapUtils;
...@@ -18,9 +14,14 @@ import org.apache.log4j.Logger; ...@@ -18,9 +14,14 @@ import org.apache.log4j.Logger;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.constants.IotConstant; import com.yeejoin.amos.iot.business.constants.IotConstant;
import com.yeejoin.amos.iot.business.dao.repository.IEqpTmplPropertyDao;
import com.yeejoin.amos.iot.business.dao.repository.IEquipmentDao;
import com.yeejoin.amos.iot.business.dao.repository.IIntfcAttributeDao; import com.yeejoin.amos.iot.business.dao.repository.IIntfcAttributeDao;
import com.yeejoin.amos.iot.business.entity.EqpTmplAttribute;
import com.yeejoin.amos.iot.business.entity.Equipment;
import com.yeejoin.amos.iot.business.entity.IntfcAttribute; import com.yeejoin.amos.iot.business.entity.IntfcAttribute;
import com.yeejoin.amos.iot.business.entity.MetricData; import com.yeejoin.amos.iot.business.entity.MetricData;
import com.yeejoin.amos.iot.business.entity.MetricDataRo;
import com.yeejoin.amos.iot.business.entity.mybatis.CapabilityBo; import com.yeejoin.amos.iot.business.entity.mybatis.CapabilityBo;
import com.yeejoin.amos.iot.business.entity.mybatis.CapacityPropertyDataVo; import com.yeejoin.amos.iot.business.entity.mybatis.CapacityPropertyDataVo;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo; import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo;
...@@ -36,8 +37,11 @@ import com.yeejoin.amos.iot.context.IotContext; ...@@ -36,8 +37,11 @@ import com.yeejoin.amos.iot.context.IotContext;
import com.yeejoin.amos.iot.entity.ParseResult; import com.yeejoin.amos.iot.entity.ParseResult;
import com.yeejoin.amos.iot.mongodb.service.intfc.IEquipMetricDataService; import com.yeejoin.amos.iot.mongodb.service.intfc.IEquipMetricDataService;
import com.yeejoin.amos.iot.netty.vehicle.IVehicleDataService; import com.yeejoin.amos.iot.netty.vehicle.IVehicleDataService;
import com.yeejoin.amos.iot.rule.engine.service.IRuleEngineService;
import com.yeejoin.amos.iot.rule.engine.service.impl.RuleEngineServiceImpl;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.springframework.util.ObjectUtils;
/** /**
* 轮询执行单元 * 轮询执行单元
...@@ -56,7 +60,14 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -56,7 +60,14 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
* 监测对象 * 监测对象
*/ */
private EquipmentBo equipmentBo; private EquipmentBo equipmentBo;
IRuleEngineService ruleEngineService = (IRuleEngineService) IotContext.getInstance().getBean(RuleEngineServiceImpl.class);
IVehicleDataService vehicleDataService = (IVehicleDataService) IotContext.getInstance().getBean("vehicleDataService");
IEquipMetricDataService equipMetricDataService = (IEquipMetricDataService) IotContext
.getInstance().getBean("equipMetricDataService");
IMetricDataService metricDataService = (IMetricDataService) IotContext
.getInstance().getBean("metricDataService");
IEqpTmplPropertyDao iEqpTmplPropertyDao = (IEqpTmplPropertyDao) IotContext
.getInstance().getBean(IEqpTmplPropertyDao.class);
/** /**
* 构造方法 * 构造方法
* *
...@@ -84,7 +95,6 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -84,7 +95,6 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
continue; continue;
} }
if (CollectionUtils.isEmpty(capabilityBo.getCpblAttrs())) { if (CollectionUtils.isEmpty(capabilityBo.getCpblAttrs())) {
continue; continue;
} }
try { try {
...@@ -112,13 +122,68 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -112,13 +122,68 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
// 6.告警处理 // 6.告警处理
raiseAalrm(metricData); raiseAalrm(metricData);
// 7.规则执行 // 7.规则执行
triggerRuleTask(metricData);
originalCpblDataMap = null;
} catch (Exception e) { } catch (Exception e) {
logger.error(e); logger.error(e);
} } finally {
System.gc();
}
} }
equipmentBo = null;
}
public void triggerRuleTask(MetricData metricData) {
List list = new ArrayList();
List<Map<String, Object>> propertys = new ArrayList<>();
list.add(metricData);
IEquipmentDao equipmentDao = (IEquipmentDao) IotContext
.getInstance().getBean("equipmentDao");
MetricDataRo metricDataRo = new MetricDataRo(list);
Equipment equipment = equipmentDao.findById(metricData.getEqpId()).get();
metricDataRo.setEqpId(metricData.getEqpId());
metricDataRo.setSubgraphId(metricData.getSubgraphId());
metricDataRo.setOrgCode(equipment.getOrgCode());
metricDataRo.setCpblId(metricData.getCpblId());
metricDataRo.setEqpName(equipment.getName());
metricDataRo.setAuthOrg(equipment.getAuthOrg());
Map<String, Object> configs = equipment.getCfgParamMap();
configs.keySet().forEach(item -> {
if (item.startsWith("equip_")) {
Map<String, Object> tempProperty = new HashMap<>();
String idStr = item.substring(6, item.length());
tempProperty.put("id", idStr);
tempProperty.put("valueStr", configs.get(item));
EqpTmplAttribute eqpTmplAttribute = iEqpTmplPropertyDao.findById(Long.valueOf(idStr)).get();
if (eqpTmplAttribute != null) {
tempProperty.put("displayName", eqpTmplAttribute.getDisplayName());
propertys.add(tempProperty);
}
}
});
metricDataRo.setEqpConfigMap(propertys);
ruleEngineService.fireRule(metricDataRo);
logger.info(String.format("polling executeUnit ===> [%s]", metricDataRo.toString()));
// String strAuthOrg = equipment.getAuthOrg();
// if (!ObjectUtils.isEmpty(strAuthOrg)) {
// String str = strAuthOrg.replaceAll(" +","");// 去空格
// String strSub = str.substring(1,str.length()-1);
// String strArray[] = strSub.split(",");
// List<String> rowIdList = Arrays.asList(strArray);
// for (String org : rowIdList) {
// if ("null".equals(org) || ObjectUtils.isEmpty(org)) {
// continue;
// }
// metricDataRo.setOrgCode(org);
// ruleEngineService.fireRule(metricDataRo);
// }
//
// }
} }
/** /**
...@@ -128,8 +193,7 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -128,8 +193,7 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
*/ */
public void sendWebSocketMessage(MetricData metricData) { public void sendWebSocketMessage(MetricData metricData) {
try { try {
IVehicleDataService vehicleDataService = (IVehicleDataService) IotContext
.getInstance().getBean("vehicleDataService");
vehicleDataService.sendWebSocketMessage(metricData); vehicleDataService.sendWebSocketMessage(metricData);
} catch (Exception e) { } catch (Exception e) {
logger.error(e); logger.error(e);
...@@ -143,10 +207,7 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -143,10 +207,7 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
*/ */
@Transactional @Transactional
public void saveMetricData(MetricData metricData) { public void saveMetricData(MetricData metricData) {
IEquipMetricDataService equipMetricDataService = (IEquipMetricDataService) IotContext
.getInstance().getBean("equipMetricDataService");
IMetricDataService metricDataService = (IMetricDataService) IotContext
.getInstance().getBean("metricDataService");
// 1.保存到mysql // 1.保存到mysql
metricDataService.saveMetricData(metricData); metricDataService.saveMetricData(metricData);
// 2.保存到mongodb // 2.保存到mongodb
...@@ -202,11 +263,13 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -202,11 +263,13 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
EqpTmplIntfcBo eqpTmplIntfcBo = getEqpTmplIntfc(eqpTmplIntfcBos, EqpTmplIntfcBo eqpTmplIntfcBo = getEqpTmplIntfc(eqpTmplIntfcBos,
intfcBo.getId()); intfcBo.getId());
if (eqpTmplIntfcBo == null) { if (eqpTmplIntfcBo == null) {
originals = null;
logger.debug("eqpTmplIntfcBo is null!"); logger.debug("eqpTmplIntfcBo is null!");
return cpblDataMap; return cpblDataMap;
} }
if (eqpTmplIntfcBo.getIntfcDirection().intValue() == IntfcDirection.UP if (eqpTmplIntfcBo.getIntfcDirection().intValue() == IntfcDirection.UP
.getValue()) { .getValue()) {
originals = null;
return cpblDataMap; return cpblDataMap;
} }
} }
...@@ -243,7 +306,8 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -243,7 +306,8 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
} else { } else {
logger.error("parseResult error! " + parseResult.getErrorMsg()); logger.error("parseResult error! " + parseResult.getErrorMsg());
} }
originals = null;
parseResult = null;
return cpblDataMap; return cpblDataMap;
} }
...@@ -295,6 +359,8 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -295,6 +359,8 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
// invoke是执行该方法,并携带参数值 // invoke是执行该方法,并携带参数值
pollingResult = (PollingResult) method.invoke(obj, pollingResult = (PollingResult) method.invoke(obj,
new Object[]{paramMap}); new Object[]{paramMap});
obj = null;
method = null;
} catch (ClassNotFoundException | InstantiationException } catch (ClassNotFoundException | InstantiationException
| IllegalAccessException | NoSuchMethodException | IllegalAccessException | NoSuchMethodException
| SecurityException | IllegalArgumentException | SecurityException | IllegalArgumentException
...@@ -302,7 +368,8 @@ public class PollingExecuteUnit extends BaseExecuteUnit { ...@@ -302,7 +368,8 @@ public class PollingExecuteUnit extends BaseExecuteUnit {
e.printStackTrace(); e.printStackTrace();
logger.error(e); logger.error(e);
} }
className = null;
pkg = null;
return pollingResult; return pollingResult;
} }
......
...@@ -9,7 +9,6 @@ import java.util.concurrent.ScheduledExecutorService; ...@@ -9,7 +9,6 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
......
package com.yeejoin.amos.iot.business.polling; package com.yeejoin.amos.iot.business.polling;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.yeejoin.amos.iot.business.enums.MonitorType;
import com.yeejoin.amos.iot.core.threadpool.AmosThreadPool;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.yeejoin.amos.iot.business.constants.IotConstant;
import com.yeejoin.amos.iot.business.entity.PollingJob; import com.yeejoin.amos.iot.business.entity.PollingJob;
import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentBo; import com.yeejoin.amos.iot.business.entity.mybatis.EquipmentBo;
import com.yeejoin.amos.iot.business.enums.MonitorType;
import com.yeejoin.amos.iot.business.param.QueryMonitorEqpParam; import com.yeejoin.amos.iot.business.param.QueryMonitorEqpParam;
import com.yeejoin.amos.iot.business.service.intfc.IMonitorService; import com.yeejoin.amos.iot.business.service.intfc.IMonitorService;
import com.yeejoin.amos.iot.context.IotContext; import com.yeejoin.amos.iot.context.IotContext;
import com.yeejoin.amos.iot.core.threadpool.AmosThreadPool;
import com.yeejoin.amos.iot.exception.YeeException; import com.yeejoin.amos.iot.exception.YeeException;
/** /**
...@@ -35,6 +32,7 @@ public class PollingScheduledExecutor implements Runnable { ...@@ -35,6 +32,7 @@ public class PollingScheduledExecutor implements Runnable {
*/ */
private PollingJob pollingJob; private PollingJob pollingJob;
IMonitorService monitorService = null;
/** /**
* 构造方法 * 构造方法
* *
...@@ -42,6 +40,7 @@ public class PollingScheduledExecutor implements Runnable { ...@@ -42,6 +40,7 @@ public class PollingScheduledExecutor implements Runnable {
*/ */
public PollingScheduledExecutor(PollingJob pollingJob) { public PollingScheduledExecutor(PollingJob pollingJob) {
this.pollingJob = pollingJob; this.pollingJob = pollingJob;
monitorService = (IMonitorService) IotContext.getInstance().getBean("monitorService");
} }
/** /**
...@@ -49,8 +48,6 @@ public class PollingScheduledExecutor implements Runnable { ...@@ -49,8 +48,6 @@ public class PollingScheduledExecutor implements Runnable {
*/ */
@Override @Override
public void run() { public void run() {
IMonitorService monitorService = (IMonitorService) IotContext
.getInstance().getBean("monitorService");
try { try {
// 1.查询监测设备 // 1.查询监测设备
QueryMonitorEqpParam queryParam = new QueryMonitorEqpParam(); QueryMonitorEqpParam queryParam = new QueryMonitorEqpParam();
...@@ -70,10 +67,15 @@ public class PollingScheduledExecutor implements Runnable { ...@@ -70,10 +67,15 @@ public class PollingScheduledExecutor implements Runnable {
equipmentBo); equipmentBo);
AmosThreadPool.getInstance().execute(pollingExecuteUnit); AmosThreadPool.getInstance().execute(pollingExecuteUnit);
}); });
equipmentBos.clear();
equipmentBos = null;
queryParam = null;
} catch (Exception e) { } catch (Exception e) {
logger.error(e); logger.error(e);
throw new YeeException("running polling job error! " + e, 1000030); throw new YeeException("running polling job error! " + e, 1000030);
} } finally {
System.gc();
}
} }
} }
...@@ -69,7 +69,7 @@ public class Test123Service { ...@@ -69,7 +69,7 @@ public class Test123Service {
for (int i = 0; i < totalIntfcCount; i++) { for (int i = 0; i < totalIntfcCount; i++) {
finishedCount++; finishedCount++;
long intfcId = Long.valueOf(intfcIdStrs.get(i)); long intfcId = Long.valueOf(intfcIdStrs.get(i));
Intfc intfc = intfcDao.findOne(intfcId); Intfc intfc = intfcDao.findById(intfcId).get();
TestIntfc testIntfc = new TestIntfc(); TestIntfc testIntfc = new TestIntfc();
testIntfc.setId(intfc.getId()); testIntfc.setId(intfc.getId());
testIntfc.setName(intfc.getName()); testIntfc.setName(intfc.getName());
...@@ -110,7 +110,7 @@ public class Test123Service { ...@@ -110,7 +110,7 @@ public class Test123Service {
for (int i = 0; i < totalCpblCount; i++) { for (int i = 0; i < totalCpblCount; i++) {
finishedCount++; finishedCount++;
long cpblId = Long.valueOf(selCpblIdStrs.get(i)); long cpblId = Long.valueOf(selCpblIdStrs.get(i));
Capability capability = iCapabilityDao.findOne(cpblId); Capability capability = iCapabilityDao.findById(cpblId).get();
TestCapablility testCapablility = new TestCapablility(); TestCapablility testCapablility = new TestCapablility();
testCapablility.setId(capability.getId()); testCapablility.setId(capability.getId());
testCapablility.setName(capability.getName()); testCapablility.setName(capability.getName());
......
...@@ -83,7 +83,7 @@ public abstract class AbstractDataAlarm implements IDataAlarm { ...@@ -83,7 +83,7 @@ public abstract class AbstractDataAlarm implements IDataAlarm {
queryEqpTmplAttrParam.setEqpTmplIds(eqpTmplIds); queryEqpTmplAttrParam.setEqpTmplIds(eqpTmplIds);
List<EqpTmplAttributeBo> eqpTmplAttributes = monitorMapper List<EqpTmplAttributeBo> eqpTmplAttributes = monitorMapper
.findEqpTmplAttrByEqpTmplIds(queryEqpTmplAttrParam); .findEqpTmplAttrByEqpTmplIds(queryEqpTmplAttrParam);
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(eqpTmplAttributes)) { if (CollectionUtils.isNotEmpty(eqpTmplAttributes)) {
Map<String, Object> paramMap = (Map<String, Object>) JSONObject Map<String, Object> paramMap = (Map<String, Object>) JSONObject
.toBean(JSONObject.fromObject(equipment), Map.class); .toBean(JSONObject.fromObject(equipment), Map.class);
String key = null; String key = null;
......
package com.yeejoin.amos.iot.business.remote;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.yeejoin.amos.component.feign.config.InnerInvokException;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.amos.iot.business.param.ReginParams;
import com.yeejoin.amos.op.core.common.response.CommonResponse;
@Service("remoteSecurityService")
public class RemoteSecurityService {
private static final Logger log = org.apache.log4j.Logger.getLogger(RemoteSecurityService.class);
@Autowired
protected HttpServletRequest request;
public List<DepartmentModel> getDepartmentTreeByCompanyId(String toke,String product,String appKey,String companyId) {
if (companyId == null || companyId.equals("")) {
return null;
}
RequestContext.setToken(toke);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
List<DepartmentModel> departmentModel=null;
FeignClientResult feignClientResult;
try {
feignClientResult = Privilege.departmentClient.queryDeptTree(null,Long.valueOf(companyId));
departmentModel = (List<DepartmentModel>)feignClientResult.getResult();
} catch (InnerInvokException e) {
e.printStackTrace();
}
return departmentModel;
// CommonResponse commonResponse = iAmosSecurityServer.getDepartmentTreeByCompanyId(companyId);
// return handleArray(commonResponse, DepartmentBo.class);
}
/**
* 当前登录用户信息
*/
public AgencyUserModel getUserInfo() {
try {
String token = request.getHeader("token");
String product = request.getHeader("product");
String appKey = request.getHeader("appKey");
RequestContext.setToken(token);
RequestContext.setProduct(product);
RequestContext.setAppKey(appKey);
AgencyUserModel result = Privilege.agencyUserClient.getme().getResult();
return result;
} catch (InnerInvokException e) {
System.err.println("get user info fail");
}
return null;
}
public String getUserId() {
return getUserInfo().getUserId();
}
}
package com.yeejoin.amos.iot.business.service.impl; package com.yeejoin.amos.iot.business.service.impl;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeConfig; import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature; import com.alibaba.fastjson.serializer.SerializerFeature;
...@@ -15,19 +26,18 @@ import com.yeejoin.amos.iot.business.dao.repository.IEquipmentDao; ...@@ -15,19 +26,18 @@ import com.yeejoin.amos.iot.business.dao.repository.IEquipmentDao;
import com.yeejoin.amos.iot.business.entity.Alarm; import com.yeejoin.amos.iot.business.entity.Alarm;
import com.yeejoin.amos.iot.business.entity.Equipment; import com.yeejoin.amos.iot.business.entity.Equipment;
import com.yeejoin.amos.iot.business.entity.mybatis.AlarmDataVo; import com.yeejoin.amos.iot.business.entity.mybatis.AlarmDataVo;
import com.yeejoin.amos.iot.business.entity.mybatis.CapacityAttrBo;
import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo; import com.yeejoin.amos.iot.business.entity.mybatis.EqpTmplAttributeBo;
import com.yeejoin.amos.iot.business.enums.AlarmClearType; import com.yeejoin.amos.iot.business.enums.AlarmClearType;
import com.yeejoin.amos.iot.business.enums.AlarmLevel; import com.yeejoin.amos.iot.business.enums.AlarmLevel;
import com.yeejoin.amos.iot.business.enums.AlarmStatus; import com.yeejoin.amos.iot.business.enums.AlarmStatus;
import com.yeejoin.amos.iot.business.param.DeleteAlarmParam; import com.yeejoin.amos.iot.business.param.DeleteAlarmParam;
import com.yeejoin.amos.iot.business.remote.RemoteSecurityService;
import com.yeejoin.amos.iot.business.service.intfc.IAlarmService; 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.CommonPageable;
import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum; import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.iot.core.remote.services.RemoteOperationService; import com.yeejoin.amos.iot.core.remote.services.RemoteOperationService;
import com.yeejoin.amos.iot.core.util.DateUtil; import com.yeejoin.amos.iot.core.util.DateUtil;
import com.yeejoin.amos.iot.core.util.query.BaseQuerySpecification; import com.yeejoin.amos.iot.core.util.query.BaseQuerySpecification;
import com.yeejoin.amos.iot.mongodb.service.impl.EquipMetricDataServiceImpl;
import com.yeejoin.amos.iot.rule.engine.service.IRuleEngineService; import com.yeejoin.amos.iot.rule.engine.service.IRuleEngineService;
import com.yeejoin.amos.iot.socket.websocket.alarm.IAlarmSocketService; import com.yeejoin.amos.iot.socket.websocket.alarm.IAlarmSocketService;
import com.yeejoin.amos.iot.socket.websocket.service.IWebSocketService; import com.yeejoin.amos.iot.socket.websocket.service.IWebSocketService;
...@@ -36,17 +46,6 @@ import com.yeejoin.amos.op.core.entity.Resource; ...@@ -36,17 +46,6 @@ import com.yeejoin.amos.op.core.entity.Resource;
import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler; import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
import com.yeejoin.amos.op.core.jpa.IBaseRepository; import com.yeejoin.amos.op.core.jpa.IBaseRepository;
import com.yeejoin.amos.security.common.context.CurrentAuthentication;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 告警service实现类 * 告警service实现类
...@@ -54,9 +53,14 @@ import java.util.Map; ...@@ -54,9 +53,14 @@ import java.util.Map;
* @author as-youjun * @author as-youjun
*/ */
@Service("alarmService") @Service("alarmService")
public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements IAlarmService { public class AlarmServiceImpl
//extends GenericManagerImpl<Alarm, Long>
implements IAlarmService {
private Logger log = Logger.getLogger(AlarmServiceImpl.class); private Logger log = Logger.getLogger(AlarmServiceImpl.class);
@Autowired
RemoteSecurityService userController;
@Autowired @Autowired
private AlarmMapper alarmMapper; private AlarmMapper alarmMapper;
...@@ -85,10 +89,10 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -85,10 +89,10 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
@Autowired @Autowired
private IWebSocketService webSocketService; private IWebSocketService webSocketService;
public AlarmServiceImpl(IBaseRepository<Alarm, Long> repository) { // public AlarmServiceImpl(IBaseRepository<Alarm, Long> repository) {
super(repository); // super(repository);
EntityChangeHandler.addModel(this); // EntityChangeHandler.addModel(this);
} // }
/** /**
* 分页带条件查询告警数据 * 分页带条件查询告警数据
...@@ -97,7 +101,8 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -97,7 +101,8 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
public Map<String, Object> findAllByParam(List<DaoCriteria> criterias, CommonPageable pageable) { public Map<String, Object> findAllByParam(List<DaoCriteria> criterias, CommonPageable pageable) {
// criterias.add(new DaoCriteria("userId", QueryOperatorEnum.EQUAL.getName(), // criterias.add(new DaoCriteria("userId", QueryOperatorEnum.EQUAL.getName(),
// Long.parseLong(CurrentAuthentication.getAuthenticatedUserId()))); // Long.parseLong(CurrentAuthentication.getAuthenticatedUserId())));
Page<Alarm> page = findAll(criterias, pageable); BaseQuerySpecification<Alarm> spec = new BaseQuerySpecification(criterias);
Page<Alarm> page = alarmDao.findAll(spec, pageable);
List<Alarm> alarmList = page.getContent(); List<Alarm> alarmList = page.getContent();
List<AlarmDataVo> alarmDataVoList = new ArrayList<AlarmDataVo>(); List<AlarmDataVo> alarmDataVoList = new ArrayList<AlarmDataVo>();
...@@ -140,8 +145,8 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -140,8 +145,8 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
@Override @Override
public void raise(Alarm alarm, boolean isClear) { public void raise(Alarm alarm, boolean isClear) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
log.info("Alarm---->" + alarm.toString()); // log.info("Alarm---->" + alarm.toString());
System.err.println("Alarm---->" + alarm.toString()); // System.err.println("Alarm---->" + alarm.toString());
List<Alarm> alarms = new ArrayList<Alarm>(); List<Alarm> alarms = new ArrayList<Alarm>();
List<DaoCriteria> listCriteria = new ArrayList<DaoCriteria>(); List<DaoCriteria> listCriteria = new ArrayList<DaoCriteria>();
...@@ -184,7 +189,8 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -184,7 +189,8 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
listCriteria.add(nameCriteria); listCriteria.add(nameCriteria);
Alarm currentAlarm = null; Alarm currentAlarm = null;
if (isClear) {//是清除告警 if (isClear) {//是清除告警
alarms = (List<Alarm>) findAll(listCriteria); BaseQuerySpecification<Alarm> spec = new BaseQuerySpecification(listCriteria);
alarms = (List<Alarm>) alarmDao.findAll(spec);
if (null != alarms && alarms.size() > 0) { if (null != alarms && alarms.size() > 0) {
currentAlarm = alarms.get(0); currentAlarm = alarms.get(0);
currentAlarm.setStatus(AlarmStatus.HISTORY.getValue()); currentAlarm.setStatus(AlarmStatus.HISTORY.getValue());
...@@ -193,7 +199,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -193,7 +199,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
currentAlarm.setClearUserId(IotConstant.ADMIN_ID); currentAlarm.setClearUserId(IotConstant.ADMIN_ID);
currentAlarm.setClearTime(new Date()); currentAlarm.setClearTime(new Date());
currentAlarm.setRemark("告警已处理"); currentAlarm.setRemark("告警已处理");
save(currentAlarm); alarmDao.save(currentAlarm);
sendAlarm(currentAlarm); sendAlarm(currentAlarm);
//触发告警规则 //触发告警规则
ruleEngineService.fireRule(alarm); ruleEngineService.fireRule(alarm);
...@@ -202,8 +208,9 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -202,8 +208,9 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
return; return;
} }
} else //不是清除告警 } else //不是清除告警
{ {
alarms = (List<Alarm>) findAll(listCriteria); BaseQuerySpecification<Alarm> spec = new BaseQuerySpecification(listCriteria);
alarms = (List<Alarm>) alarmDao.findAll(spec);
//是一件存在的告警 //是一件存在的告警
if (null != alarms && alarms.size() > 0) { if (null != alarms && alarms.size() > 0) {
if (alarms.size() == 1) { if (alarms.size() == 1) {
...@@ -212,7 +219,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -212,7 +219,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
currentAlarm.setCount(currentAlarm.getCount() + 1); currentAlarm.setCount(currentAlarm.getCount() + 1);
currentAlarm.setSubgraphId(alarm.getSubgraphId()); currentAlarm.setSubgraphId(alarm.getSubgraphId());
currentAlarm.setDescr(alarm.getDescr()); currentAlarm.setDescr(alarm.getDescr());
save(currentAlarm); alarmDao.save(currentAlarm);
} else { } else {
log.info("double alarms:size=" + alarms.size()); log.info("double alarms:size=" + alarms.size());
return; return;
...@@ -220,7 +227,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -220,7 +227,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
} else {//新发告警 } else {//新发告警
alarm.setStatus(AlarmStatus.RAISE.getValue()); alarm.setStatus(AlarmStatus.RAISE.getValue());
save(alarm); alarmDao.save(alarm);
sendAlarm(alarm); sendAlarm(alarm);
} }
//触发告警规则 //触发告警规则
...@@ -253,7 +260,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -253,7 +260,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
} }
private JSONObject getAttrByEqpTmplId(Long equipmentId) { private JSONObject getAttrByEqpTmplId(Long equipmentId) {
Equipment equipment = equipmentDao.findOne(equipmentId); Equipment equipment = equipmentDao.findById(equipmentId).get();
Map<String, Object> cfgParamMap = equipment.getCfgParamMap(); Map<String, Object> cfgParamMap = equipment.getCfgParamMap();
List<EqpTmplAttributeBo> positionBos = eqpTmplAttrMapper.listByEqpTmplId(equipment.getEqpTmplId()); List<EqpTmplAttributeBo> positionBos = eqpTmplAttrMapper.listByEqpTmplId(equipment.getEqpTmplId());
JSONObject attr = new JSONObject(); JSONObject attr = new JSONObject();
...@@ -291,7 +298,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -291,7 +298,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
if (requests.getStatus() == 2) { if (requests.getStatus() == 2) {
map.put("remark", requests.getRemark()); map.put("remark", requests.getRemark());
map.put("clearTime", new Date()); map.put("clearTime", new Date());
map.put("clearUser", CurrentAuthentication.getAuthenticatedUserId()); map.put("clearUser", userController.getUserId());
map.put("clearType", 1); map.put("clearType", 1);
alarmMapper.eliminateAlarmByIds(map); alarmMapper.eliminateAlarmByIds(map);
} else if (requests.getStatus() == 3) { } else if (requests.getStatus() == 3) {
...@@ -336,7 +343,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements ...@@ -336,7 +343,7 @@ public class AlarmServiceImpl extends GenericManagerImpl<Alarm, Long> implements
return alarmMapper.queryAlarmByEquipAttr(attrName); return alarmMapper.queryAlarmByEquipAttr(attrName);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) { public void fireResourceReomoved(Resource resource) {
if (resource instanceof Equipment) { if (resource instanceof Equipment) {
Equipment equipment = (Equipment) resource; Equipment equipment = (Equipment) resource;
......
package com.yeejoin.amos.iot.business.service.impl; package com.yeejoin.amos.iot.business.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.yeejoin.amos.iot.business.dao.repository.ICapabilityDao;
import com.yeejoin.amos.iot.business.dao.repository.ICapabilityPropertyDao;
import com.yeejoin.amos.iot.business.entity.CapabilityAttribute; import com.yeejoin.amos.iot.business.entity.CapabilityAttribute;
import com.yeejoin.amos.iot.business.service.intfc.ICapabilityAttrService; import com.yeejoin.amos.iot.business.service.intfc.ICapabilityAttrService;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
...@@ -17,12 +23,16 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -17,12 +23,16 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: CapabilityAttrServiceImpl.java, v 0.1 2018年5月4日 下午5:16:01 as-guowubin Exp $ * @version $Id: CapabilityAttrServiceImpl.java, v 0.1 2018年5月4日 下午5:16:01 as-guowubin Exp $
*/ */
@Service("CapabilityAttrService") @Service("CapabilityAttrService")
public class CapabilityAttrServiceImpl extends GenericManagerImpl<CapabilityAttribute, Long> implements ICapabilityAttrService public class CapabilityAttrServiceImpl
implements ICapabilityAttrService
{ {
public CapabilityAttrServiceImpl(IBaseRepository<CapabilityAttribute, Long> repository) @Autowired
{ private ICapabilityPropertyDao capabilityPropertyDao;
super(repository);
@Override
public List<CapabilityAttribute> findAll(Specification<CapabilityAttribute> capaAttrSpec) {
return capabilityPropertyDao.findAll(capaAttrSpec);
} }
} }
...@@ -32,7 +32,8 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -32,7 +32,8 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: CapabilityServiceImpl.java, v 0.1 2018年5月4日 下午5:12:47 as-guowubin Exp $ * @version $Id: CapabilityServiceImpl.java, v 0.1 2018年5月4日 下午5:12:47 as-guowubin Exp $
*/ */
@Service("CapabilityService") @Service("CapabilityService")
public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long> implements ICapabilityService public class CapabilityServiceImpl
implements ICapabilityService
{ {
@Autowired @Autowired
...@@ -41,21 +42,15 @@ public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long> ...@@ -41,21 +42,15 @@ public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long>
@Autowired @Autowired
private Capacity_Intfc_protocolMapper capacity_Intfc_protocolMapper; private Capacity_Intfc_protocolMapper capacity_Intfc_protocolMapper;
public CapabilityServiceImpl(IBaseRepository<Capability, Long> repository)
{
super(repository);
EntityChangeHandler.addModel(this);
}
@Override @Override
public void delCapabilityById(Long id) public void delCapabilityById(Long id)
{ {
EntityChangeHandler.fireResourceReomoved(findOne(id)); EntityChangeHandler.fireResourceReomoved(iCapabilityDao.getOne(id));
iCapabilityDao.delCapabilityById(id); iCapabilityDao.delCapabilityById(id);
capacity_Intfc_protocolMapper.delCaIntfProRelation(id); capacity_Intfc_protocolMapper.delCaIntfProRelation(id);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) public void fireResourceReomoved(Resource resource)
{ {
if (resource instanceof EquipmentTemplate) if (resource instanceof EquipmentTemplate)
...@@ -70,7 +65,7 @@ public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long> ...@@ -70,7 +65,7 @@ public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long>
return cb.and(list.toArray(p)); return cb.and(list.toArray(p));
} }
}; };
List<Capability> capabilities = findAll(capabilitySpec); List<Capability> capabilities = iCapabilityDao.findAll(capabilitySpec);
if (capabilities != null) { if (capabilities != null) {
for (Capability capability : capabilities) { for (Capability capability : capabilities) {
delCapabilityById(capability.getId()); delCapabilityById(capability.getId());
...@@ -81,8 +76,12 @@ public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long> ...@@ -81,8 +76,12 @@ public class CapabilityServiceImpl extends GenericManagerImpl<Capability, Long>
@Override @Override
public List<Capability> findByEqpTmpl(Long id) { public List<Capability> findByEqpTmpl(Long id) {
// TODO Auto-generated method stub
return iCapabilityDao.findByEqpTmplId(id); return iCapabilityDao.findByEqpTmplId(id);
} }
@Override
public Capability findOne(Long cpblId) {
return iCapabilityDao.getOne(cpblId);
}
} }
...@@ -32,24 +32,18 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -32,24 +32,18 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: CapacityInterfaceServiceImpl.java, v 0.1 2018年5月29日 下午5:55:32 as-chenjiajun Exp $ * @version $Id: CapacityInterfaceServiceImpl.java, v 0.1 2018年5月29日 下午5:55:32 as-chenjiajun Exp $
*/ */
@Service @Service
public class CapacityInterfaceServiceImpl extends GenericManagerImpl<CapabilitylInterface, Long> implements ICapacityInterfaceService public class CapacityInterfaceServiceImpl
implements ICapacityInterfaceService
{ {
@Autowired @Autowired
private ICapabilityInterfaceDao iCapabilitylInterfaceDao; private ICapabilityInterfaceDao iCapabilitylInterfaceDao;
public CapacityInterfaceServiceImpl(
IBaseRepository<CapabilitylInterface, Long> repository)
{
super(repository);
EntityChangeHandler.addModel(this);
}
@Override @Override
public void deleteCapacityInterface(Long id) { public void deleteCapacityInterface(Long id) {
iCapabilitylInterfaceDao.delCapabilitylInterfaceById(id); iCapabilitylInterfaceDao.delCapabilitylInterfaceById(id);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) public void fireResourceReomoved(Resource resource)
{ {
if (resource instanceof Capability) if (resource instanceof Capability)
......
...@@ -30,23 +30,19 @@ import java.util.List; ...@@ -30,23 +30,19 @@ import java.util.List;
* @version $Id: CapacityPropertyServiceImpl.java, v 0.1 2018年5月29日 下午5:55:43 as-chenjiajun Exp $ * @version $Id: CapacityPropertyServiceImpl.java, v 0.1 2018年5月29日 下午5:55:43 as-chenjiajun Exp $
*/ */
@Service @Service
public class CapacityPropertyServiceImpl extends GenericManagerImpl<CapabilityAttribute, Long> implements ICapacityPropertyService { public class CapacityPropertyServiceImpl
implements ICapacityPropertyService
{
@Autowired @Autowired
private ICapabilityPropertyDao iCapabilityPropertyDao; private ICapabilityPropertyDao iCapabilityPropertyDao;
public CapacityPropertyServiceImpl(
IBaseRepository<CapabilityAttribute, Long> repository) {
super(repository);
EntityChangeHandler.addModel(this);
}
@Override @Override
public void deleteCapacityProperty(Long id) { public void deleteCapacityProperty(Long id) {
iCapabilityPropertyDao.delCapabilityAttributeById(id); iCapabilityPropertyDao.delCapabilityAttributeById(id);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) { public void fireResourceReomoved(Resource resource) {
if (resource instanceof Capability) { if (resource instanceof Capability) {
......
...@@ -3,27 +3,33 @@ ...@@ -3,27 +3,33 @@
*/ */
package com.yeejoin.amos.iot.business.service.impl; package com.yeejoin.amos.iot.business.service.impl;
import com.yeejoin.amos.iot.business.dao.repository.IDicDao;
import com.yeejoin.amos.iot.business.entity.Dic; import com.yeejoin.amos.iot.business.entity.Dic;
import com.yeejoin.amos.iot.business.service.intfc.IDicService; import com.yeejoin.amos.iot.business.service.intfc.IDicService;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
import com.yeejoin.amos.op.core.jpa.IBaseRepository; import com.yeejoin.amos.op.core.jpa.IBaseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
/** /**
* 数据字典service实现类 * 数据字典service实现类
* *
* @author as-youjun * @author as-youjun
*/ */
@Service("dicService") @Service("dicService")
public class DicServiceImpl extends GenericManagerImpl<Dic, Long> implements IDicService { public class DicServiceImpl
implements IDicService
public DicServiceImpl(IBaseRepository<Dic, Long> repository) { {
super(repository); @Autowired
} private IDicDao dicDao;
@Override @Override
@Transactional
public Dic getById(String id) { public Dic getById(String id) {
return findOne(Long.valueOf(id)); return dicDao.getOne(Long.valueOf(id));
} }
} }
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.iot.business.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.iot.business.service.impl;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.yeejoin.amos.iot.business.dao.repository.IDroolsRuleDao; import com.yeejoin.amos.iot.business.dao.repository.IDroolsRuleDao;
...@@ -22,17 +23,18 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; ...@@ -22,17 +23,18 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
* @version $Id: DroolsRuleServiceImpl.java, v 0.1 2018年4月20日 下午4:25:59 as-guowubin Exp $ * @version $Id: DroolsRuleServiceImpl.java, v 0.1 2018年4月20日 下午4:25:59 as-guowubin Exp $
*/ */
@Service("DroolsRuleService") @Service("DroolsRuleService")
public class DroolsRuleServiceImpl extends GenericManagerImpl<DroolsRule, String> implements IDroolsRuleService public class DroolsRuleServiceImpl
implements IDroolsRuleService
{ {
@Autowired
IDroolsRuleDao droolsRuleDao; IDroolsRuleDao droolsRuleDao;
public DroolsRuleServiceImpl(IDroolsRuleDao droolsRuleDao) // public DroolsRuleServiceImpl(IDroolsRuleDao droolsRuleDao)
{ // {
super(droolsRuleDao); // super(droolsRuleDao);
this.droolsRuleDao = droolsRuleDao; // this.droolsRuleDao = droolsRuleDao;
EntityChangeHandler.addModel(this); // EntityChangeHandler.addModel(this);
} // }
@Override @Override
public List<DroolsRule> findByGroupIdAndIsUser(String groupId, Boolean isUser) public List<DroolsRule> findByGroupIdAndIsUser(String groupId, Boolean isUser)
...@@ -53,7 +55,7 @@ public class DroolsRuleServiceImpl extends GenericManagerImpl<DroolsRule, String ...@@ -53,7 +55,7 @@ public class DroolsRuleServiceImpl extends GenericManagerImpl<DroolsRule, String
droolsRuleDao.delDroolsRuleById(id); droolsRuleDao.delDroolsRuleById(id);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) public void fireResourceReomoved(Resource resource)
{ {
if (resource instanceof Rule) if (resource instanceof Rule)
...@@ -67,4 +69,10 @@ public class DroolsRuleServiceImpl extends GenericManagerImpl<DroolsRule, String ...@@ -67,4 +69,10 @@ public class DroolsRuleServiceImpl extends GenericManagerImpl<DroolsRule, String
} }
} }
} }
@Override
public void saveAll(List<DroolsRule> newDroolsRules) {
droolsRuleDao.saveAll(newDroolsRules);
}
} }
...@@ -21,18 +21,13 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -21,18 +21,13 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: EqpCpblPropertyServiceImpl.java, v 0.1 2018年7月12日 上午9:35:10 as-chenjiajun Exp $ * @version $Id: EqpCpblPropertyServiceImpl.java, v 0.1 2018年7月12日 上午9:35:10 as-chenjiajun Exp $
*/ */
@Service("EqpCpblPropertyService") @Service("EqpCpblPropertyService")
public class EqpCpblPropertyServiceImpl extends GenericManagerImpl<EqpCpblProperty, Long> implements IEqpCpblPropertyService public class EqpCpblPropertyServiceImpl
implements IEqpCpblPropertyService
{ {
@Autowired @Autowired
private IEqpCpblPropertyDao iEqpCpblPropertyDao; private IEqpCpblPropertyDao iEqpCpblPropertyDao;
public EqpCpblPropertyServiceImpl(
IBaseRepository<EqpCpblProperty, Long> repository)
{
super(repository);
}
@Override @Override
public void deleteByEqpId(Long eqpId) public void deleteByEqpId(Long eqpId)
{ {
...@@ -50,4 +45,14 @@ public class EqpCpblPropertyServiceImpl extends GenericManagerImpl<EqpCpblProper ...@@ -50,4 +45,14 @@ public class EqpCpblPropertyServiceImpl extends GenericManagerImpl<EqpCpblProper
{ {
return iEqpCpblPropertyDao.findByEqpIdAndCpblId(eqpId, cpblId); return iEqpCpblPropertyDao.findByEqpIdAndCpblId(eqpId, cpblId);
} }
@Override
public void saveAll(List<EqpCpblProperty> thresholdList) {
iEqpCpblPropertyDao.saveAll(thresholdList);
}
@Override
public void delete(EqpCpblProperty eqpCpblProperty) {
iEqpCpblPropertyDao.delete(eqpCpblProperty);
}
} }
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.iot.business.service.impl; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.iot.business.service.impl;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.yeejoin.amos.iot.business.dao.repository.IEqpCpblDao; import com.yeejoin.amos.iot.business.dao.repository.IEqpCpblDao;
...@@ -19,16 +20,17 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; ...@@ -19,16 +20,17 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
* @version $Id: EqpIntfcServiceImpl.java, v 0.1 2018年6月9日 上午10:50:02 as-guowubin Exp $ * @version $Id: EqpIntfcServiceImpl.java, v 0.1 2018年6月9日 上午10:50:02 as-guowubin Exp $
*/ */
@Service("EqpCpblService") @Service("EqpCpblService")
public class EqpCpblServiceImpl extends public class EqpCpblServiceImpl
GenericManagerImpl<EquipmentCapability, Long> implements IEqpCpblService implements IEqpCpblService
{ {
@Autowired
IEqpCpblDao eqpCpblDao; IEqpCpblDao eqpCpblDao;
public EqpCpblServiceImpl(IEqpCpblDao eqpCpblDao) // public EqpCpblServiceImpl(IEqpCpblDao eqpCpblDao)
{ // {
super(eqpCpblDao); // super(eqpCpblDao);
this.eqpCpblDao = eqpCpblDao; // this.eqpCpblDao = eqpCpblDao;
} // }
@Override @Override
public List<EquipmentCapability> findByEqpId(Long eqpId) public List<EquipmentCapability> findByEqpId(Long eqpId)
...@@ -47,4 +49,14 @@ public class EqpCpblServiceImpl extends ...@@ -47,4 +49,14 @@ public class EqpCpblServiceImpl extends
{ {
return eqpCpblDao.findByEpbIdAndCpblId(eqpId,cpblId); return eqpCpblDao.findByEpbIdAndCpblId(eqpId,cpblId);
} }
@Override
public void delete(EquipmentCapability equipmentCapability) {
eqpCpblDao.delete(equipmentCapability);
}
@Override
public void save(EquipmentCapability eqpCapability) {
eqpCpblDao.save(eqpCapability);
}
} }
package com.yeejoin.amos.iot.business.service.impl; package com.yeejoin.amos.iot.business.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import com.yeejoin.amos.iot.business.dao.mapper.EqpTmplAttrMapper;
import com.yeejoin.amos.iot.business.dao.mapper.EqpTmplMapper;
import com.yeejoin.amos.iot.business.dao.repository.IDicDao;
import com.yeejoin.amos.iot.business.dao.repository.IEqpTmplPropertyDao;
import com.yeejoin.amos.iot.business.dao.repository.IEquipTemplateIndustryDao;
import com.yeejoin.amos.iot.business.dic.EquipTemplateIndustry;
import com.yeejoin.amos.iot.business.entity.Dic;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.yeejoin.amos.iot.business.dao.repository.IEquipmentTemplateDao; import com.yeejoin.amos.iot.business.dao.repository.IEquipmentTemplateDao;
import com.yeejoin.amos.iot.business.entity.EquipmentTemplate; import com.yeejoin.amos.iot.business.entity.EquipmentTemplate;
import com.yeejoin.amos.iot.business.service.intfc.IEqpTemplService; import com.yeejoin.amos.iot.business.service.intfc.IEqpTemplService;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.iot.core.util.query.BaseQuerySpecification;
import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import javax.annotation.PostConstruct;
/** /**
* *
...@@ -17,15 +36,57 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; ...@@ -17,15 +36,57 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
* @version $Id: EqpTemplServiceImpl.java, v 0.1 2018年6月6日 下午5:41:44 as-guowubin Exp $ * @version $Id: EqpTemplServiceImpl.java, v 0.1 2018年6月6日 下午5:41:44 as-guowubin Exp $
*/ */
@Service("EqpTemplService") @Service("EqpTemplService")
public class EqpTemplServiceImpl extends public class EqpTemplServiceImpl
GenericManagerImpl<EquipmentTemplate, Long> implements IEqpTemplService implements IEqpTemplService
{ {
@Autowired
IEquipmentTemplateDao equipmentTemplateDao; IEquipmentTemplateDao equipmentTemplateDao;
@Autowired
EqpTmplMapper EqpTmplMapper;
@Autowired
IDicDao dicDao;
@Autowired
EqpTmplAttrMapper eqpTmplAttrMapper;
public EqpTemplServiceImpl(IEquipmentTemplateDao equipmentTemplateDao) @Override
{ public List<EquipmentTemplate> findAll(List<DaoCriteria> daoCriterias) {
super(equipmentTemplateDao); BaseQuerySpecification<EquipmentTemplate> spec = new BaseQuerySpecification<>(daoCriterias);
this.equipmentTemplateDao = equipmentTemplateDao; return equipmentTemplateDao.findAll(spec);
} }
@Override
public List<EquipmentTemplate> findAllMybatis(HashMap<String, Object> param) {
List<Dic> list = dicDao.findAllByType("EquipTemplateIndustry");
List<EquipmentTemplate> equipmentTemplates = EqpTmplMapper.findAll(param).stream().map(item->{
for (Dic dic : list) {
if (dic.getId() == item.getIndustryId()) {
item.setEquipTemplateIndustry((EquipTemplateIndustry) dic);
break;
}
}
item.setAttributes(eqpTmplAttrMapper.findAllByEqpTmplId(item.getId()));
return item;
}).collect(Collectors.toList());
return equipmentTemplates;
}
@PostConstruct
public void test() {
HashMap<String, Object> paramMap = new HashMap<>();
paramMap.put("orgCode", "1*2");
findAllMybatis(paramMap);
}
@Override
public EquipmentTemplate findOne(Long id) {
return equipmentTemplateDao.getOne(id);
}
// public EqpTemplServiceImpl(IEquipmentTemplateDao equipmentTemplateDao)
// {
// super(equipmentTemplateDao);
// this.equipmentTemplateDao = equipmentTemplateDao;
// }
} }
...@@ -10,8 +10,11 @@ import com.yeejoin.amos.iot.business.dao.repository.IEqpTmplInterfaceDao; ...@@ -10,8 +10,11 @@ import com.yeejoin.amos.iot.business.dao.repository.IEqpTmplInterfaceDao;
import com.yeejoin.amos.iot.business.entity.EqpTmplInterface; import com.yeejoin.amos.iot.business.entity.EqpTmplInterface;
import com.yeejoin.amos.iot.business.entity.EquipmentTemplate; import com.yeejoin.amos.iot.business.entity.EquipmentTemplate;
import com.yeejoin.amos.iot.business.entity.Intfc; import com.yeejoin.amos.iot.business.entity.Intfc;
import com.yeejoin.amos.iot.business.entity.MetricData;
import com.yeejoin.amos.iot.business.entity.mybatis.DeviceInterfaceDataVo; import com.yeejoin.amos.iot.business.entity.mybatis.DeviceInterfaceDataVo;
import com.yeejoin.amos.iot.business.service.intfc.IEqpTmplInterfaceService; import com.yeejoin.amos.iot.business.service.intfc.IEqpTmplInterfaceService;
import com.yeejoin.amos.iot.core.util.query.BaseQuerySpecification;
import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.entity.Resource; import com.yeejoin.amos.op.core.entity.Resource;
import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler; import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
...@@ -27,7 +30,8 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -27,7 +30,8 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: EqpTmplInterfaceServiceImpl.java, v 0.1 2018年5月29日 下午5:28:09 as-chenjiajun Exp $ * @version $Id: EqpTmplInterfaceServiceImpl.java, v 0.1 2018年5月29日 下午5:28:09 as-chenjiajun Exp $
*/ */
@Service @Service
public class EqpTmplInterfaceServiceImpl extends GenericManagerImpl<EqpTmplInterface, Long> implements IEqpTmplInterfaceService public class EqpTmplInterfaceServiceImpl
implements IEqpTmplInterfaceService
{ {
@Autowired @Autowired
...@@ -36,19 +40,12 @@ public class EqpTmplInterfaceServiceImpl extends GenericManagerImpl<EqpTmplInter ...@@ -36,19 +40,12 @@ public class EqpTmplInterfaceServiceImpl extends GenericManagerImpl<EqpTmplInter
@Autowired @Autowired
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
public EqpTmplInterfaceServiceImpl(
IBaseRepository<EqpTmplInterface, Long> repository)
{
super(repository);
EntityChangeHandler.addModel(this);
}
@Override @Override
public void deleteDeviceInterface(Long id) { public void deleteDeviceInterface(Long id) {
iEqpTmplInterfaceDao.delEqpTmplInterfaceById(id); iEqpTmplInterfaceDao.delEqpTmplInterfaceById(id);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) public void fireResourceReomoved(Resource resource)
{ {
if (resource instanceof EquipmentTemplate) if (resource instanceof EquipmentTemplate)
...@@ -71,4 +68,10 @@ public class EqpTmplInterfaceServiceImpl extends GenericManagerImpl<EqpTmplInter ...@@ -71,4 +68,10 @@ public class EqpTmplInterfaceServiceImpl extends GenericManagerImpl<EqpTmplInter
} }
} }
@Override
public List<EqpTmplInterface> findAll(List<DaoCriteria> daoCriterias) {
BaseQuerySpecification<EqpTmplInterface> spec = new BaseQuerySpecification<>(daoCriterias);
return iEqpTmplInterfaceDao.findAll(spec);
}
} }
...@@ -33,7 +33,8 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -33,7 +33,8 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: EqpTmplPropertyServiceImpl.java, v 0.1 2018年5月29日 下午5:29:55 as-chenjiajun Exp $ * @version $Id: EqpTmplPropertyServiceImpl.java, v 0.1 2018年5月29日 下午5:29:55 as-chenjiajun Exp $
*/ */
@Service @Service
public class EqpTmplPropertyServiceImpl extends GenericManagerImpl<EqpTmplAttribute, Long> implements IEqpTmplPropertyService public class EqpTmplPropertyServiceImpl
implements IEqpTmplPropertyService
{ {
@Autowired @Autowired
...@@ -42,13 +43,6 @@ public class EqpTmplPropertyServiceImpl extends GenericManagerImpl<EqpTmplAttrib ...@@ -42,13 +43,6 @@ public class EqpTmplPropertyServiceImpl extends GenericManagerImpl<EqpTmplAttrib
@javax.annotation.Resource @javax.annotation.Resource
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
public EqpTmplPropertyServiceImpl(
IBaseRepository<EqpTmplAttribute, Long> repository)
{
super(repository);
EntityChangeHandler.addModel(this);
}
@Override @Override
public void deleteDeviceProperty(Long id) { public void deleteDeviceProperty(Long id) {
iEqpTmplPropertyDao.delEqpTmplAttributeById(id); iEqpTmplPropertyDao.delEqpTmplAttributeById(id);
...@@ -59,7 +53,7 @@ public class EqpTmplPropertyServiceImpl extends GenericManagerImpl<EqpTmplAttrib ...@@ -59,7 +53,7 @@ public class EqpTmplPropertyServiceImpl extends GenericManagerImpl<EqpTmplAttrib
return deviceMapper.findTempAttr(eqpId); return deviceMapper.findTempAttr(eqpId);
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) public void fireResourceReomoved(Resource resource)
{ {
if (resource instanceof EquipmentTemplate) if (resource instanceof EquipmentTemplate)
......
...@@ -2,13 +2,19 @@ package com.yeejoin.amos.iot.business.service.impl; ...@@ -2,13 +2,19 @@ package com.yeejoin.amos.iot.business.service.impl;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.yeejoin.amos.iot.business.dao.repository.IEquipmentDao; import com.yeejoin.amos.iot.business.dao.repository.IEquipmentDao;
import com.yeejoin.amos.iot.business.dao.repository.IIntfcDao;
import com.yeejoin.amos.iot.business.entity.Equipment; import com.yeejoin.amos.iot.business.entity.Equipment;
import com.yeejoin.amos.iot.business.entity.Intfc;
import com.yeejoin.amos.iot.business.entity.IntfcAttribute;
import com.yeejoin.amos.iot.business.service.intfc.IEquipmentService; import com.yeejoin.amos.iot.business.service.intfc.IEquipmentService;
import com.yeejoin.amos.iot.core.util.query.BaseQuerySpecification;
import com.yeejoin.amos.iot.core.util.query.QuerySpecificationHelper; import com.yeejoin.amos.iot.core.util.query.QuerySpecificationHelper;
import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler; import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
...@@ -22,17 +28,17 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; ...@@ -22,17 +28,17 @@ import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
* @version $Id: EquipmentServiceImpl.java, v 0.1 2018年6月6日 下午6:15:07 as-guowubin Exp $ * @version $Id: EquipmentServiceImpl.java, v 0.1 2018年6月6日 下午6:15:07 as-guowubin Exp $
*/ */
@Service("EquipmentService") @Service("EquipmentService")
public class EquipmentServiceImpl extends public class EquipmentServiceImpl
GenericManagerImpl<Equipment, Long> implements IEquipmentService implements IEquipmentService
{ {
@Autowired
IEquipmentDao equipmentDao; IEquipmentDao equipmentDao;
public EquipmentServiceImpl(IEquipmentDao equipmentDao) // public EquipmentServiceImpl(IEquipmentDao equipmentDao)
{ // {
super(equipmentDao); // super(equipmentDao);
this.equipmentDao = equipmentDao; // this.equipmentDao = equipmentDao;
} // }
@Override @Override
public List<Equipment> findByEqpTmplId(Long eqpTmplId) public List<Equipment> findByEqpTmplId(Long eqpTmplId)
...@@ -50,7 +56,7 @@ public class EquipmentServiceImpl extends ...@@ -50,7 +56,7 @@ public class EquipmentServiceImpl extends
public void delEquipmentById(List<Long> ids) public void delEquipmentById(List<Long> ids)
{ {
ids.forEach(i -> { ids.forEach(i -> {
EntityChangeHandler.fireResourceReomoved(equipmentDao.findOne(i)); EntityChangeHandler.fireResourceReomoved(equipmentDao.findById(i).get());
equipmentDao.delEquipmentById(i); equipmentDao.delEquipmentById(i);
}); });
} }
...@@ -73,4 +79,20 @@ public class EquipmentServiceImpl extends ...@@ -73,4 +79,20 @@ public class EquipmentServiceImpl extends
return false; return false;
} }
} }
@Override
public Equipment save(Equipment equipment) {
return equipmentDao.save(equipment);
}
@Override
public Equipment findOne(Long id) {
return equipmentDao.getOne(id);
}
@Override
public List<Equipment> findAll(List<DaoCriteria> daoCriterias) {
BaseQuerySpecification<Equipment> spec = new BaseQuerySpecification<>(daoCriterias);
return equipmentDao.findAll(spec);
}
} }
...@@ -24,18 +24,12 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository; ...@@ -24,18 +24,12 @@ import com.yeejoin.amos.op.core.jpa.IBaseRepository;
* @version $Id: InterfacePropertyServiceImpl.java, v 0.1 2018年5月30日 上午10:09:23 as-chenjiajun Exp $ * @version $Id: InterfacePropertyServiceImpl.java, v 0.1 2018年5月30日 上午10:09:23 as-chenjiajun Exp $
*/ */
@Service @Service
public class InterfacePropertyServiceImpl extends GenericManagerImpl<IntfcAttribute, Long> implements IInterfacePropertyService public class InterfacePropertyServiceImpl
implements IInterfacePropertyService
{ {
@Autowired @Autowired
private IIntfcAttributeDao intfcAttributeDao; private IIntfcAttributeDao intfcAttributeDao;
public InterfacePropertyServiceImpl(
IBaseRepository<IntfcAttribute, Long> repository)
{
super(repository);
EntityChangeHandler.addModel(this);
}
@Override @Override
public List<IntfcAttribute> getPropertysById(Long id) public List<IntfcAttribute> getPropertysById(Long id)
{ {
...@@ -49,11 +43,11 @@ public class InterfacePropertyServiceImpl extends GenericManagerImpl<IntfcAttrib ...@@ -49,11 +43,11 @@ public class InterfacePropertyServiceImpl extends GenericManagerImpl<IntfcAttrib
@Override @Override
public void delAttribute(List<Long> ids){ public void delAttribute(List<Long> ids){
List<IntfcAttribute> attributes = intfcAttributeDao.findAll(ids); List<IntfcAttribute> attributes = intfcAttributeDao.findAllById(ids);
attributes.forEach(attr -> delOneAttribute(attr.getId())); attributes.forEach(attr -> delOneAttribute(attr.getId()));
} }
@Override // @Override
public void fireResourceReomoved(Resource resource) public void fireResourceReomoved(Resource resource)
{ {
if (resource instanceof Intfc) if (resource instanceof Intfc)
......
...@@ -17,6 +17,7 @@ import com.yeejoin.amos.iot.business.dao.repository.IIntfcDao; ...@@ -17,6 +17,7 @@ import com.yeejoin.amos.iot.business.dao.repository.IIntfcDao;
import com.yeejoin.amos.iot.business.entity.Intfc; import com.yeejoin.amos.iot.business.entity.Intfc;
import com.yeejoin.amos.iot.business.entity.IntfcAttribute; import com.yeejoin.amos.iot.business.entity.IntfcAttribute;
import com.yeejoin.amos.iot.business.exceptions.IntfcException; import com.yeejoin.amos.iot.business.exceptions.IntfcException;
import com.yeejoin.amos.iot.business.remote.RemoteSecurityService;
import com.yeejoin.amos.iot.business.service.intfc.IIntfcService; import com.yeejoin.amos.iot.business.service.intfc.IIntfcService;
import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum; import com.yeejoin.amos.iot.core.enums.QueryOperatorEnum;
import com.yeejoin.amos.iot.core.util.StringUtil; import com.yeejoin.amos.iot.core.util.StringUtil;
...@@ -25,7 +26,6 @@ import com.yeejoin.amos.op.core.common.query.DaoCriteria; ...@@ -25,7 +26,6 @@ import com.yeejoin.amos.op.core.common.query.DaoCriteria;
import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler; import com.yeejoin.amos.op.core.entity.handler.EntityChangeHandler;
import com.yeejoin.amos.op.core.jpa.GenericManagerImpl; import com.yeejoin.amos.op.core.jpa.GenericManagerImpl;
import com.yeejoin.amos.op.core.jpa.IBaseRepository; import com.yeejoin.amos.op.core.jpa.IBaseRepository;
import com.yeejoin.amos.security.common.context.CurrentAuthentication;
/** /**
* *
...@@ -38,14 +38,18 @@ import com.yeejoin.amos.security.common.context.CurrentAuthentication; ...@@ -38,14 +38,18 @@ import com.yeejoin.amos.security.common.context.CurrentAuthentication;
* Exp $ * Exp $
*/ */
@Service("intfcService") @Service("intfcService")
public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements IIntfcService { public class IntfcServiceImpl
implements IIntfcService {
public IntfcServiceImpl(IBaseRepository<Intfc, Long> repository) // public IntfcServiceImpl(IBaseRepository<Intfc, Long> repository)
{ // {
super(repository); // super(repository);
} // }
@Autowired @Autowired
RemoteSecurityService userController;
@Autowired
private IIntfcDao intfcDao; private IIntfcDao intfcDao;
@Autowired @Autowired
...@@ -57,7 +61,7 @@ public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements ...@@ -57,7 +61,7 @@ public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements
List<IntfcAttribute> intfcAttrs = intfc.getAttributes(); List<IntfcAttribute> intfcAttrs = intfc.getAttributes();
Intfc basic = null; Intfc basic = null;
if (intfc.getUserId() == null) { if (intfc.getUserId() == null) {
intfc.setUserId(CurrentAuthentication.getAuthenticatedUserId()); intfc.setUserId(userController.getUserId());
} }
if (intfc.getDicIdCommMode() == null || intfc.getDicIdCommMode() <= 0) { if (intfc.getDicIdCommMode() == null || intfc.getDicIdCommMode() <= 0) {
throw new IntfcException("通讯方式异常!"); throw new IntfcException("通讯方式异常!");
...@@ -84,7 +88,7 @@ public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements ...@@ -84,7 +88,7 @@ public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements
attr.setIntfcId(basic.getId()); attr.setIntfcId(basic.getId());
} }
intfcAttrs = intfcAttributeDao.save(intfcAttrs); intfcAttrs = intfcAttributeDao.saveAll(intfcAttrs);
basic.setAttributes(intfcAttrs); basic.setAttributes(intfcAttrs);
} }
...@@ -150,4 +154,9 @@ public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements ...@@ -150,4 +154,9 @@ public class IntfcServiceImpl extends GenericManagerImpl<Intfc, Long> implements
BaseQuerySpecification<Intfc> spec = new BaseQuerySpecification<>(criterias); BaseQuerySpecification<Intfc> spec = new BaseQuerySpecification<>(criterias);
return intfcDao.findAll(spec); return intfcDao.findAll(spec);
} }
@Override
public Intfc findOne(Long intfcId) {
return intfcDao.getOne(intfcId);
}
} }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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