Merge branch 'dev-V0.4.5' of https://gitee.com/iotkit-open-source/iotkit-parent into dev-V0.4.5

V0.5.x
荭琪枫 2023-07-19 21:53:29 +08:00
commit a0ee59b6c5
20 changed files with 128 additions and 81 deletions

View File

@ -11,10 +11,9 @@ function getMid() {
this.decode = function (msg) {
var content = msg.content;
var topic = content.topic;
var bytes = CRC.strToByte(content.payload);
var bytes = arrayGroup(content.payload.params,2);
var byteData=content.payload.params;
if (topic.endsWith("/thing/model/up_raw")) {
var byteData = ab2hex(bytes)
var data = arrayGroup(byteData, 2);
var params = {};
var uint8Array = new Uint8Array(bytes.length);
@ -170,7 +169,12 @@ this.encode = function (service, device) {
var method = "thing.service.";
var topic = "/sys/" + service.productKey + "/" + service.deviceName + "/thing/model/down_raw";
var params = {};
var payloadArray = [];
var deviceArray = [];;
var totalArray =[];
var totalItemArray = [];
var itemArray = [];
var outFFIndex = ''
var type = service.type;
var identifier = service.identifier;
if (type == "property" && identifier == "get") {
@ -195,6 +199,7 @@ this.encode = function (service, device) {
for (var p in service.params) {
params[p] = service.params[p];
}
var paramsArr = Object.keys(params)
//站地址
if (paramsArr.includes('query')) {
let queryHexData = arrayGroup(params['query'],2)
@ -465,14 +470,14 @@ CRC.ToModbusCRC16 = function (str) {
};
CRC.strToByte = function (str) {
var tmp = str.split(''),
var tmp = str.split(""),
arr = [];
for (var i = 0, c = tmp.length; i < c; i++) {
var j = encodeURI(tmp[i]);
if (j.length == 1) {
arr.push(j.charCodeAt());
} else {
var b = j.split('%');
var b = j.split("%");
for (var m = 1; m < b.length; m++) {
arr.push(parseInt('0x' + b[m]));
}
@ -482,7 +487,7 @@ CRC.strToByte = function (str) {
};
CRC.convertChinese = function (str) {
var tmp = str.split(''),
var tmp = str.split(""),
arr = [];
for (var i = 0, c = tmp.length; i < c; i++) {
var s = tmp[i].charCodeAt();
@ -496,7 +501,7 @@ CRC.convertChinese = function (str) {
};
CRC.filterChinese = function (str) {
var tmp = str.split(''),
var tmp = str.split(""),
arr = [];
for (var i = 0, c = tmp.length; i < c; i++) {
var s = tmp[i].charCodeAt();

View File

@ -2498,5 +2498,24 @@
"remark": "",
"status": "0",
"visible": "0"
}
},
{
"id": 2225,
"menuName": "OTA",
"parentId": 0,
"orderNum": 1,
"path": "upgradePack",
"component": "iot/ota/upgradePack/index",
"queryParam": null,
"isFrame": "1",
"isCache": "0",
"menuType": "C",
"visible": "0",
"status": "0",
"perms": null,
"icon": "",
"createBy": 1,
"createDept": 103,
"updateBy": 1
}
]

View File

@ -403,5 +403,10 @@
"id": 2023070901,
"menuId": 2224,
"roleId": 2
}
},
{
"id": 2023071901,
"menuId": 2225,
"roleId": 2
}
]

View File

@ -9,6 +9,7 @@
*/
package cc.iotkit.data.service;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.utils.JsonUtils;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.IJPACommData;
@ -16,6 +17,8 @@ import cc.iotkit.data.manager.IRuleInfoData;
import cc.iotkit.data.dao.RuleInfoRepository;
import cc.iotkit.data.model.TbRuleInfo;
import cc.iotkit.common.api.Paging;
import cc.iotkit.data.model.TbTaskInfo;
import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.model.rule.FilterConfig;
import cc.iotkit.model.rule.RuleAction;
import cc.iotkit.model.rule.RuleInfo;
@ -105,6 +108,12 @@ public class RuleInfoDataImpl implements IRuleInfoData, IJPACommData<RuleInfo, S
return null;
}
@Override
public Paging<RuleInfo> findAll(PageRequest<RuleInfo> pageRequest) {
Page<TbRuleInfo> ret = ruleInfoRepository.findAll(PageBuilder.toPageable(pageRequest));
return new Paging<>(ret.getTotalElements(), fromTb(ret.getContent()));
}
@Override
public RuleInfo save(RuleInfo data) {
if (StringUtils.isBlank(data.getId())) {

View File

@ -9,13 +9,15 @@
*/
package cc.iotkit.data.service;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.utils.JsonUtils;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.dao.IJPACommData;
import cc.iotkit.data.manager.ITaskInfoData;
import cc.iotkit.data.dao.TaskInfoRepository;
import cc.iotkit.data.manager.ITaskInfoData;
import cc.iotkit.data.model.TbTaskInfo;
import cc.iotkit.common.api.Paging;
import cc.iotkit.data.util.PageBuilder;
import cc.iotkit.model.rule.RuleAction;
import cc.iotkit.model.rule.TaskInfo;
import lombok.RequiredArgsConstructor;
@ -80,6 +82,15 @@ public class TaskInfoDataImpl implements ITaskInfoData, IJPACommData<TaskInfo, S
return to(taskInfoRepository.findById(s).orElse(null));
}
@Override
public Paging<TaskInfo> findAll(PageRequest<TaskInfo> pageRequest) {
Page<TbTaskInfo> ret = taskInfoRepository.findAll(PageBuilder.toPageable(pageRequest));
return new Paging<>(ret.getTotalElements(),
ret.getContent().stream().map(this::to)
.collect(Collectors.toList())
);
}
@Override
public TaskInfo save(TaskInfo data) {
if (StringUtils.isBlank(data.getId())) {

View File

@ -18,6 +18,6 @@ public interface RuleLogRepository extends ElasticsearchRepository<DocRuleLog, S
void deleteByRuleId(String ruleId);
Page<DocRuleLog> findByRuleId(String ruleId, Pageable pageable);
Page<DocRuleLog> findByRuleIdOrderByLogAtDesc(String ruleId, Pageable pageable);
}

View File

@ -18,6 +18,6 @@ public interface TaskLogRepository extends ElasticsearchRepository<DocTaskLog, S
void deleteByTaskId(String taskId);
Page<DocTaskLog> findByTaskId(String taskId, Pageable pageable);
Page<DocTaskLog> findByTaskIdOrderByLogAtDesc(String taskId, Pageable pageable);
}

View File

@ -35,7 +35,7 @@ public class RuleLogDataImpl implements IRuleLogData {
@Override
public Paging<RuleLog> findByRuleId(String ruleId, int page, int size) {
Page<DocRuleLog> paged = ruleLogRepository.findByRuleId(ruleId, Pageable.ofSize(size).withPage(page - 1));
Page<DocRuleLog> paged = ruleLogRepository.findByRuleIdOrderByLogAtDesc(ruleId, Pageable.ofSize(size).withPage(page - 1));
return new Paging<>(paged.getTotalElements(),
paged.getContent().stream().map(o -> MapstructUtils.convert(o, RuleLog.class))
.collect(Collectors.toList()));

View File

@ -35,7 +35,7 @@ public class TaskLogDataImpl implements ITaskLogData {
@Override
public Paging<TaskLog> findByTaskId(String taskId, int page, int size) {
Page<DocTaskLog> paged = taskLogRepository.findByTaskId(taskId, Pageable.ofSize(size).withPage(page - 1));
Page<DocTaskLog> paged = taskLogRepository.findByTaskIdOrderByLogAtDesc(taskId, Pageable.ofSize(size).withPage(page - 1));
return new Paging<>(paged.getTotalElements(),
paged.getContent().stream().map(o -> MapstructUtils.convert(o, TaskLog.class))
.collect(Collectors.toList()));

View File

@ -17,11 +17,13 @@ import cc.iotkit.common.utils.JsonUtils;
import cc.iotkit.common.utils.UniqueIdUtil;
import cc.iotkit.comp.model.DeviceState;
import cc.iotkit.comp.model.RegisterInfo;
import cc.iotkit.data.manager.*;
import cc.iotkit.data.manager.IDeviceInfoData;
import cc.iotkit.data.manager.IDeviceOtaDetailData;
import cc.iotkit.data.manager.IProductData;
import cc.iotkit.data.manager.IProductModelData;
import cc.iotkit.model.device.DeviceInfo;
import cc.iotkit.model.device.message.ThingModelMessage;
import cc.iotkit.model.ota.DeviceOtaDetail;
import cc.iotkit.model.ota.DeviceOtaInfo;
import cc.iotkit.model.product.Product;
import cc.iotkit.model.product.ProductModel;
import cc.iotkit.mq.MqProducer;

View File

@ -127,7 +127,7 @@ function register(payload) {
var pwd = md5(product.getProductSecret() + auth.clientid);
if (pwd.toLocaleLowerCase() != auth.password.toLocaleLowerCase()) {
throw new Error("incorrect password" + "pwd->" + pwd + " productSecret->" + product.productSecret);
throw new Error("incorrect password" + "pwd->" + pwd + " productSecret->" + product.getProductSecret());
}
return {
type: "register",

View File

@ -1,5 +1,5 @@
var mid = 1;
var COMMAD_UNKOWN = 0xff; //未知的命令
function getMid() {
mid++;
if (mid > 10000) {
@ -11,10 +11,9 @@ function getMid() {
this.decode = function (msg) {
var content = msg.content;
var topic = content.topic;
var bytes = CRC.strToByte(content.payload);
var bytes = arrayGroup(content.payload.params,2);
var byteData=content.payload.params;
if (topic.endsWith("/thing/model/up_raw")) {
var byteData = ab2hex(bytes)
var data = arrayGroup(byteData, 2);
var params = {};
var uint8Array = new Uint8Array(bytes.length);
@ -170,7 +169,12 @@ this.encode = function (service, device) {
var method = "thing.service.";
var topic = "/sys/" + service.productKey + "/" + service.deviceName + "/thing/model/down_raw";
var params = {};
var payloadArray = [];
var deviceArray = [];;
var totalArray =[];
var totalItemArray = [];
var itemArray = [];
var outFFIndex = ''
var type = service.type;
var identifier = service.identifier;
if (type == "property" && identifier == "get") {
@ -195,6 +199,7 @@ this.encode = function (service, device) {
for (var p in service.params) {
params[p] = service.params[p];
}
var paramsArr = Object.keys(params)
//站地址
if (paramsArr.includes('query')) {
let queryHexData = arrayGroup(params['query'],2)
@ -289,12 +294,12 @@ this.encode = function (service, device) {
// payloadArray = payloadArray.concat(buffer_float32(prop_float)); //属性'prop_float'的值。
}else if (method == 'thing.event.property.post') { //设备上报数据返回结果,如果不需要回复,可以去除该内容
var code = json['code'];
payloadArray = payloadArray.concat(buffer_uint8(COMMAND_REPORT_REPLY)); //command字段
payloadArray = payloadArray.concat(buffer_int32(parseInt(id))); // ALink JSON格式 'id'
payloadArray = payloadArray.concat(buffer_uint8(code));
// var code = json['code'];
// payloadArray = payloadArray.concat(buffer_uint8(COMMAND_REPORT_REPLY)); //command字段
// payloadArray = payloadArray.concat(buffer_int32(parseInt(id))); // ALink JSON格式 'id'
// payloadArray = payloadArray.concat(buffer_uint8(code));
} else { //未知命令,对于有些命令不做处理
var code = json['code'];
var code = "FF";
payloadArray = payloadArray.concat(buffer_uint8(COMMAD_UNKOWN)); //command字段
payloadArray = payloadArray.concat(buffer_int32(parseInt(id))); // ALink JSON格式 'id'
payloadArray = payloadArray.concat(buffer_uint8(code));
@ -308,7 +313,7 @@ this.encode = function (service, device) {
payload: JSON.stringify({
id: deviceMid,
method: method += "property." + identifier,
params: payloadArray
params: ab2hex(payloadArray).toUpperCase()
})
}
}
@ -465,14 +470,14 @@ CRC.ToModbusCRC16 = function (str) {
};
CRC.strToByte = function (str) {
var tmp = str.split(''),
var tmp = str.split(""),
arr = [];
for (var i = 0, c = tmp.length; i < c; i++) {
var j = encodeURI(tmp[i]);
if (j.length == 1) {
arr.push(j.charCodeAt());
} else {
var b = j.split('%');
var b = j.split("%");
for (var m = 1; m < b.length; m++) {
arr.push(parseInt('0x' + b[m]));
}
@ -482,7 +487,7 @@ CRC.strToByte = function (str) {
};
CRC.convertChinese = function (str) {
var tmp = str.split(''),
var tmp = str.split(""),
arr = [];
for (var i = 0, c = tmp.length; i < c; i++) {
var s = tmp[i].charCodeAt();
@ -496,7 +501,7 @@ CRC.convertChinese = function (str) {
};
CRC.filterChinese = function (str) {
var tmp = str.split(''),
var tmp = str.split(""),
arr = [];
for (var i = 0, c = tmp.length; i < c; i++) {
var s = tmp[i].charCodeAt();

View File

@ -44,14 +44,14 @@ public class RuleEngineController {
@PostMapping("/list")
public Paging<RuleInfoVo> rules(
@Validated @RequestBody
PageRequest<RuleInfoBo> request
PageRequest<RuleInfoBo> request
) {
return ruleEngineService.selectPageList(request);
}
@ApiOperation("保存规则")
@PostMapping("/edit")
public boolean saveRule(@RequestBody @Validated Request<RuleInfoBo> ruleInfoBo) {
public boolean saveRule(@RequestBody @Validated Request<RuleInfoBo> ruleInfoBo) {
return ruleEngineService.saveRule(ruleInfoBo.getData());
}
@ -80,7 +80,7 @@ public class RuleEngineController {
@ApiOperation("规则日志")
@PostMapping("/ruleLog/list")
public Paging<RuleLogVo> getRuleLogs(
@Validated @RequestBody PageRequest<RuleLogBo> request
@Validated @RequestBody PageRequest<RuleLogBo> request
) {
return ruleEngineService.selectRuleLogPageList(request);
}
@ -102,7 +102,7 @@ public class RuleEngineController {
@ApiOperation("保存定时任务")
@PostMapping("/task/save")
public boolean saveTask(@Validated @RequestBody Request<TaskInfoBo> taskInfo) {
return ruleEngineService.saveTask(taskInfo.getData());
return ruleEngineService.saveTask(taskInfo.getData());
}
@ApiOperation("停止定时任务")
@ -122,7 +122,7 @@ public class RuleEngineController {
@PostMapping("/task/renew")
public boolean renewTask(@Validated @RequestBody Request<String> request) {
String taskId = request.getData();
return ruleEngineService.renewTask(taskId);
return ruleEngineService.renewTask(taskId);
}
@ -140,13 +140,12 @@ public class RuleEngineController {
@Validated @RequestBody PageRequest<TaskLogBo> request
) {
return ruleEngineService.selectTaskLogPageList(request);
}
@ApiOperation("清除定时任务日志")
@PostMapping("/taskLogs/clear")
public boolean clearTaskLogs( @Validated @RequestBody Request<String> request) {
return ruleEngineService.clearTaskLogs(request.getData());
public boolean clearTaskLogs(@Validated @RequestBody Request<String> request) {
return ruleEngineService.clearTaskLogs(request.getData());
}
}

View File

@ -20,19 +20,15 @@ public class RuleLogBo extends BaseDto {
private Long time;
@ApiModelProperty(value="规则id")
private String ruleId;
@ApiModelProperty(value="状态")
private String state1;
@ApiModelProperty(value="内容")
private String content;
@ApiModelProperty(value="是否成功")
private Boolean success;
}

View File

@ -1,38 +1,36 @@
package cc.iotkit.manager.dto.vo.ruleinfo;
import cc.iotkit.common.api.BaseDto;
import cc.iotkit.model.rule.RuleInfo;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ApiModel(value = "RuleLogBo")
import java.io.Serializable;
@ApiModel(value = "RuleLogVo")
@Data
@EqualsAndHashCode(callSuper = true)
@AutoMapper(target = RuleInfo.class, reverseConvertGenerate = false)
public class RuleLogVo extends BaseDto {
@AutoMapper(target = RuleInfo.class)
public class RuleLogVo implements Serializable {
private static final long serialVersionUID = -1L;
private static final long serialVersionUID = -1L;
@ApiModelProperty(value = "时间")
private Long time;
@ApiModelProperty(value="时间")
private Long time;
@ApiModelProperty(value = "规则id")
@ApiModelProperty(value="规则id")
private String ruleId;
private String ruleId;
@ApiModelProperty(value = "状态")
@ApiModelProperty(value="状态")
private String state1;
private String state1;
@ApiModelProperty(value = "内容")
@ApiModelProperty(value="内容")
private String content;
private String content;
@ApiModelProperty(value = "是否成功")
@ApiModelProperty(value="是否成功")
private Boolean success;
private Boolean success;
}
}

View File

@ -9,16 +9,19 @@
*/
package cc.iotkit.manager.dto.vo.taskinfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import cc.iotkit.model.rule.TaskLog;
import io.github.linpeilie.annotations.AutoMapper;
import io.swagger.annotations.ApiModel;
import lombok.*;
import java.io.Serializable;
@ApiModel(value = "TaskLogVo")
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class TaskLogVo {
@AutoMapper(target = TaskLog.class)
public class TaskLogVo implements Serializable {
private static final long serialVersionUID = -1L;
private String id;

View File

@ -257,9 +257,7 @@ public class RuleEngineServiceImpl implements IRuleEngineService {
@Override
public Paging<TaskLogVo> selectTaskLogPageList(PageRequest<TaskLogBo> request) {
TaskLog taskLog = request.getData().to(TaskLog.class);
Paging<TaskLog> byTaskId = taskLogData.findByTaskId(taskLog.getTaskId(), request.getPageNum(), request.getPageSize());
return byTaskId.to(TaskLogVo.class);
}

View File

@ -78,7 +78,7 @@ public class RuleManager {
int idx = 1;
while (true) {
PageRequest<RuleInfo> pageRequest = new PageRequest<>();
pageRequest.setPageNum(idx += 1);
pageRequest.setPageNum(idx);
pageRequest.setPageSize(100);
Paging<RuleInfo> all = ruleInfoData.findAll(pageRequest);
List<RuleInfo> rules = all.getRows();

View File

@ -55,7 +55,7 @@ public class TaskManager implements ApplicationContextAware {
int idx = 1;
while (true) {
PageRequest<TaskInfo> pageRequest = new PageRequest<>();
pageRequest.setPageNum(idx+=1);
pageRequest.setPageNum(idx);
pageRequest.setPageSize(100);
Paging<TaskInfo> all = taskInfoData.findAll(pageRequest);
List<TaskInfo> tasks = all.getRows();
@ -134,7 +134,7 @@ public class TaskManager implements ApplicationContextAware {
TriggerKey triggerKey = new TriggerKey(task.getId(), task.getUid());
Trigger oldTrigger = getScheduler().getTrigger(triggerKey);
if (oldTrigger == null) {
log.warn("task isn't exists,to add");
log.warn("saveTask:trigger does not exist");
addTask(task);
return;
}
@ -147,9 +147,6 @@ public class TaskManager implements ApplicationContextAware {
}
public void renewTask(TaskInfo task) throws SchedulerException {
if (!TaskInfo.TYPE_DELAY.equals(task.getType())) {
throw new BizException(ErrCode.TASK_NOT_SUPPORT_RENEW);
}
saveTask(task);
}

BIN
iot-starter/.DS_Store vendored Normal file

Binary file not shown.