提交 3a01765e authored 作者: 林业通's avatar 林业通

温控修改

上级 4a5f5d4e
...@@ -139,7 +139,7 @@ public class OutletParse implements IParse { ...@@ -139,7 +139,7 @@ public class OutletParse implements IParse {
}else if("1A".equals(datas.get("cmd"))) {//温控响应 }else if("1A".equals(datas.get("cmd"))) {//温控响应
String content = datas.get("content"); String content = datas.get("content");
logger.info("设置温控响应 : {}", content); logger.info("设置温控响应 : {}", content);
String content1 = redisUtils.get(device.getNumbering() + "temp"); /* String content1 = redisUtils.get(device.getNumbering() + "temp");
//设备响应成功之后修改数据,不用等30秒,页面体验好些 //设备响应成功之后修改数据,不用等30秒,页面体验好些
if ("00".equals(content)) { if ("00".equals(content)) {
if (content1 != null) { if (content1 != null) {
...@@ -155,7 +155,7 @@ public class OutletParse implements IParse { ...@@ -155,7 +155,7 @@ public class OutletParse implements IParse {
} }
} }
} }
redisUtils.delete(device.getNumbering() + "temp"); redisUtils.delete(device.getNumbering() + "temp");*/
}else if("20".equals(datas.get("cmd"))) {//事件上报 }else if("20".equals(datas.get("cmd"))) {//事件上报
//保存开关记录 //保存开关记录
......
...@@ -53,7 +53,7 @@ public class SwitchParse implements IParse { ...@@ -53,7 +53,7 @@ public class SwitchParse implements IParse {
new Thread(() -> { new Thread(() -> {
//检测有没待下发指令 //检测有没待下发指令
String send = redisUtils.get("device:sendtemp1:" + device.getNumbering()); String send = redisUtils.get("device:sendtemp:" + device.getNumbering());
if(send != null) { if(send != null) {
try { try {
Thread.sleep(500); Thread.sleep(500);
...@@ -61,18 +61,7 @@ public class SwitchParse implements IParse { ...@@ -61,18 +61,7 @@ public class SwitchParse implements IParse {
e.printStackTrace(); e.printStackTrace();
} }
mqProducer.sendT(send); mqProducer.sendT(send);
redisUtils.delete("device:sendtemp1:" + device.getNumbering()); redisUtils.delete("device:sendtemp:" + device.getNumbering());
}
//检测有没待下发指令
String send1 = redisUtils.get("device:sendtemp2:" + device.getNumbering());
if(send1 != null) {
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
mqProducer.sendT(send1);
redisUtils.delete("device:sendtemp2:" + device.getNumbering());
} }
}).start(); }).start();
...@@ -146,7 +135,7 @@ public class SwitchParse implements IParse { ...@@ -146,7 +135,7 @@ public class SwitchParse implements IParse {
}else if("1A".equals(datas.get("cmd"))) {//温控响应 }else if("1A".equals(datas.get("cmd"))) {//温控响应
String content = datas.get("content"); String content = datas.get("content");
logger.info("设置温控响应 : {}", content); logger.info("设置温控响应 : {}", content);
String content1 = redisUtils.get(device.getNumbering() + "temp"); /* String content1 = redisUtils.get(device.getNumbering() + "temp");
//设备响应成功之后修改数据,不用等30秒,页面体验好些 //设备响应成功之后修改数据,不用等30秒,页面体验好些
if ("00".equals(content)) { if ("00".equals(content)) {
if (content1 != null) { if (content1 != null) {
...@@ -166,7 +155,7 @@ public class SwitchParse implements IParse { ...@@ -166,7 +155,7 @@ public class SwitchParse implements IParse {
} }
} }
} }
redisUtils.delete(device.getNumbering() + "temp"); redisUtils.delete(device.getNumbering() + "temp");*/
}else if("20".equals(datas.get("cmd"))) {//事件上报 }else if("20".equals(datas.get("cmd"))) {//事件上报
//保存开关记录 //保存开关记录
......
...@@ -44,87 +44,36 @@ public class ShDeviceTempController { ...@@ -44,87 +44,36 @@ public class ShDeviceTempController {
@Login @Login
@PostMapping("saveOrUpdate") @PostMapping("saveOrUpdate")
@ApiOperation("新增、修改定时(智能插座、开关、窗帘)") @ApiOperation("新增、修改(智能插座)")
@ApiLog("新增、修改定时") @ApiLog("新增、修改(智能插座)")
public R saveOrUpdate(@RequestBody ShDeviceTempForm form) throws InvocationTargetException, IllegalAccessException { public R saveOrUpdate(@RequestBody ShDeviceTempForm form) throws InvocationTargetException, IllegalAccessException {
//表单校验 //表单校验
ValidatorUtils.validateEntity(form); ValidatorUtils.validateEntity(form);
ShDeviceTempEntity tempEntity = new ShDeviceTempEntity(); ShDeviceTempEntity tempEntity = new ShDeviceTempEntity();
BeanUtils.copyProperties(tempEntity, form); BeanUtils.copyProperties(tempEntity, form);
ShDeviceTempEntity tempEntity1 = otherShDeviceTempService.getOne(new QueryWrapper<ShDeviceTempEntity>().eq("device_id", form.getDeviceId()));
if (tempEntity1 != null) {
tempEntity.setId(tempEntity1.getId());
}
logger.info("低温" + tempEntity.getTempL());
otherShDeviceTempService.saveOrUpdate(tempEntity); otherShDeviceTempService.saveOrUpdate(tempEntity);
if (form.getStatus() == 1) {
ShDeviceEntity entity = otherShDeviceService.getById(form.getDeviceId()); ShDeviceEntity entity = otherShDeviceService.getById(form.getDeviceId());
String content;
String content = null;
if (!StringUtils.isBlank(form.getTempH(), form.getMinuteH(), form.getSecondH(), form.getTempL(), form.getMinuteL(), form.getSecondL())) {
String tempH = ByteUtils.signInt2HexString(form.getTempH().toString(), 2);
String tempL = ByteUtils.signInt2HexString(form.getTempL().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(form.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(form.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(form.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(form.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010103" + tempH + tempL + minuteH + secondH + minuteL + secondL;
} else if (!StringUtils.isBlank(form.getTempH(), form.getMinuteH(), form.getSecondH())) {
String tempH = ByteUtils.signInt2HexString(form.getTempH().toString(), 2); String tempH = ByteUtils.signInt2HexString(form.getTempH().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(form.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(form.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
content = "010101" + tempH + "00" + minuteH + secondH + "00000000";
} else if (!StringUtils.isBlank(form.getTempL(), form.getMinuteL(), form.getSecondL())) {
String tempL = ByteUtils.signInt2HexString(form.getTempL().toString(), 2); String tempL = ByteUtils.signInt2HexString(form.getTempL().toString(), 2);
content = tempH + ByteUtils.int2Hex(form.getStatusH()) + tempL + ByteUtils.int2Hex(form.getStatusL()) +
"00000000";
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(form.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(form.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010102" + "00" + tempL + "00000000" + minuteL + secondL;
}else {
content = "00010000000000000000000000";
}
ProtocolContent protocol = new ProtocolContent(); ProtocolContent protocol = new ProtocolContent();
protocol.setReceiveId(entity.getNumbering()); protocol.setReceiveId(entity.getNumbering());
protocol.setDeviceType("03"); protocol.setDeviceType("03");
protocol.setCmd("1C"); protocol.setCmd("1A");
protocol.setContent(content); protocol.setContent(content);
String json = JSON.toJSONString(protocol); String json = JSON.toJSONString(protocol);
redisUtils.set("device:sendtemp:" + entity.getNumbering(), json); redisUtils.set("device:sendtemp:" + entity.getNumbering(), json);
}
return R.ok().put("id", tempEntity.getId()); return R.ok().put("id", tempEntity.getId());
} }
@Login @Login
@PostMapping("saveOrUpdate1") @PostMapping("saveOrUpdate1")
@ApiOperation("新增、修改定时(智能插座、开关、窗帘)") @ApiOperation("新增、修改温控(智能开关)")
@ApiLog("新增、修改定时") @ApiLog("新增、修改温控(智能开关)")
public R saveOrUpdate1(@RequestBody ShDeviceTempForm form) throws InvocationTargetException, IllegalAccessException { public R saveOrUpdate1(@RequestBody ShDeviceTempForm form) throws InvocationTargetException, IllegalAccessException {
//表单校验 //表单校验
ValidatorUtils.validateEntity(form); ValidatorUtils.validateEntity(form);
...@@ -133,129 +82,21 @@ public class ShDeviceTempController { ...@@ -133,129 +82,21 @@ public class ShDeviceTempController {
otherShDeviceTempService.saveOrUpdate(tempEntity); otherShDeviceTempService.saveOrUpdate(tempEntity);
ShDeviceEntity entity = otherShDeviceService.getById(form.getDeviceId()); ShDeviceEntity entity = otherShDeviceService.getById(form.getDeviceId());
String content = null; String content;
String content1 = null;
if (form.getFlag() == 1) {
if (form.getStatus() == 1) {
if (!StringUtils.isBlank(form.getTempH(), form.getMinuteH(), form.getSecondH(), form.getTempL(), form.getMinuteL(), form.getSecondL())) {
String tempH = ByteUtils.signInt2HexString(form.getTempH().toString(), 2);
String tempL = ByteUtils.signInt2HexString(form.getTempL().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(form.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(form.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(form.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(form.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010103" + tempH + tempL + minuteH + secondH + minuteL + secondL;
} else if (!StringUtils.isBlank(form.getTempH(), form.getMinuteH(), form.getSecondH())) {
String tempH = ByteUtils.signInt2HexString(form.getTempH().toString(), 2); String tempH = ByteUtils.signInt2HexString(form.getTempH().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(form.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(form.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
content = "010101" + tempH + "00" + minuteH + secondH + "00000000";
} else if (!StringUtils.isBlank(form.getTempL(), form.getMinuteL(), form.getSecondL())) {
String tempL = ByteUtils.signInt2HexString(form.getTempL().toString(), 2); String tempL = ByteUtils.signInt2HexString(form.getTempL().toString(), 2);
String tempHT = ByteUtils.signInt2HexString(form.getTempHT().toString(), 2);
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(form.getMinuteL())); String tempLT = ByteUtils.signInt2HexString(form.getTempLT().toString(), 2);
while (minuteL.length() < 4) { content = tempH + ByteUtils.int2Hex(form.getStatusH()) + tempL + ByteUtils.int2Hex(form.getStatusL()) +
minuteL.insert(0, "0"); tempHT + ByteUtils.int2Hex(form.getStatusHT()) + tempLT + ByteUtils.int2Hex(form.getStatusLT());
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(form.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010102" + "00" + tempL + "00000000" + minuteL + secondL;
}else {
content = "00010000000000000000000000";
}
ProtocolContent protocol = new ProtocolContent(); ProtocolContent protocol = new ProtocolContent();
protocol.setReceiveId(entity.getNumbering()); protocol.setReceiveId(entity.getNumbering());
protocol.setDeviceType("02"); protocol.setDeviceType("02");
protocol.setCmd("1C"); protocol.setCmd("1A");
protocol.setContent(content); protocol.setContent(content);
String json = JSON.toJSONString(protocol); String json = JSON.toJSONString(protocol);
redisUtils.set("device:sendtemp1:" + entity.getNumbering(), json); redisUtils.set("device:sendtemp:" + entity.getNumbering(), json);
}
}else {
if (form.getStatusT() == 1) {
if (!StringUtils.isBlank(form.getTempHT(), form.getMinuteHT(), form.getSecondHT(), form.getTempLT(), form.getMinuteLT(), form.getSecondLT())) {
String tempH = ByteUtils.signInt2HexString(form.getTempHT().toString(), 2);
String tempL = ByteUtils.signInt2HexString(form.getTempLT().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(form.getMinuteHT()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(form.getSecondHT()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(form.getMinuteLT()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(form.getSecondLT()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content1 = "010203" + tempH + tempL + minuteH + secondH + minuteL + secondL;
} else if (!StringUtils.isBlank(form.getTempHT(), form.getMinuteHT(), form.getSecondHT())) {
String tempH = ByteUtils.signInt2HexString(form.getTempHT().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(form.getMinuteHT()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(form.getSecondHT()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
content1 = "010201" + tempH + "00" + minuteH + secondH + "00000000";
} else if (!StringUtils.isBlank(form.getTempLT(), form.getMinuteLT(), form.getSecondLT())) {
String tempL = ByteUtils.signInt2HexString(form.getTempLT().toString(), 2);
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(form.getMinuteLT()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(form.getSecondLT()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content1 = "010202" + "00" + tempL + "00000000" + minuteL + secondL;
}else {
content1 = "00020000000000000000000000";
}
ProtocolContent protocol1 = new ProtocolContent();
protocol1.setReceiveId(entity.getNumbering());
protocol1.setDeviceType("02");
protocol1.setCmd("1C");
protocol1.setContent(content1);
String json1 = JSON.toJSONString(protocol1);
redisUtils.set("device:sendtemp2:" + entity.getNumbering(), json1);
}
}
return R.ok().put("id", tempEntity.getId()); return R.ok().put("id", tempEntity.getId());
} }
...@@ -269,224 +110,4 @@ public class ShDeviceTempController { ...@@ -269,224 +110,4 @@ public class ShDeviceTempController {
return R.ok().put("temp", otherShDeviceTempService.getOne(new QueryWrapper<ShDeviceTempEntity>().eq("device_id", id))); return R.ok().put("temp", otherShDeviceTempService.getOne(new QueryWrapper<ShDeviceTempEntity>().eq("device_id", id)));
} }
@Login
@PostMapping("updateStatus")
@ApiOperation("修改状态")
@ApiLog("修改状态")
public R updateStatus(@RequestBody Map<String, Object> params) {
Integer id = (Integer) params.get("id");
Integer status = (Integer) params.get("status");
if (StringUtils.isBlank(id, status)) {
return R.error("缺少参数!");
}
ShDeviceTempEntity tempEntity = new ShDeviceTempEntity();
tempEntity.setId(id);
tempEntity.setStatus(status);
otherShDeviceTempService.updateById(tempEntity);
ShDeviceTempEntity tempEntity1 = otherShDeviceTempService.getById(id);
ShDeviceEntity entity = otherShDeviceService.getById(tempEntity1.getDeviceId());
String content;
if (status == 1) {
content = content(tempEntity1);
}else {
content = "00010000000000000000000000";
}
ProtocolContent protocol = new ProtocolContent();
protocol.setReceiveId(entity.getNumbering());
protocol.setDeviceType("03");
protocol.setCmd("1C");
protocol.setContent(content);
String json = JSON.toJSONString(protocol);
redisUtils.set("device:sendtemp:" + entity.getNumbering(), json);
return R.ok();
}
@Login
@PostMapping("updateStatus1")
@ApiOperation("修改状态")
@ApiLog("修改状态")
public R updateStatus1(@RequestBody Map<String, Object> params) {
Integer id = (Integer) params.get("id");
Integer status = (Integer) params.get("status");
Integer statusT = (Integer) params.get("statusT");
if (StringUtils.isBlank(id)) {
return R.error("缺少参数!");
}
if (status == null && statusT == null) {
return R.error("缺少参数!");
}
ShDeviceTempEntity tempEntity = new ShDeviceTempEntity();
tempEntity.setId(id);
if(status != null) {
tempEntity.setStatus(status);
}
if(statusT != null) {
tempEntity.setStatusT(statusT);
}
otherShDeviceTempService.updateById(tempEntity);
ShDeviceTempEntity tempEntity1 = otherShDeviceTempService.getById(id);
ShDeviceEntity entity = otherShDeviceService.getById(tempEntity1.getDeviceId());
String content = null;
if (status != null && status == 1) {
if (!StringUtils.isBlank(tempEntity1.getTempH(), tempEntity1.getMinuteH(), tempEntity1.getSecondH(), tempEntity1.getTempL(), tempEntity1.getMinuteL(), tempEntity1.getSecondL())) {
String tempH = ByteUtils.signInt2HexString(tempEntity1.getTempH().toString(), 2);
String tempL = ByteUtils.signInt2HexString(tempEntity1.getTempL().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010103" + tempH + tempL + minuteH + secondH + minuteL + secondL;
} else if (!StringUtils.isBlank(tempEntity1.getTempH(), tempEntity1.getMinuteH(), tempEntity1.getSecondH())) {
String tempH = ByteUtils.signInt2HexString(tempEntity1.getTempH().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
content = "010101" + tempH + "00" + minuteH + secondH + "00000000";
} else if (!StringUtils.isBlank(tempEntity1.getTempL(), tempEntity1.getMinuteL(), tempEntity1.getSecondL())) {
String tempL = ByteUtils.signInt2HexString(tempEntity1.getTempL().toString(), 2);
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010102" + "00" + tempL + "00000000" + minuteL + secondL;
}else {
content = "00010000000000000000000000";
}
}else if (status != null && status == 2){
content = "00010000000000000000000000";
}else if (statusT != null && statusT == 1){
if (!StringUtils.isBlank(tempEntity1.getTempHT(), tempEntity1.getMinuteHT(), tempEntity1.getSecondHT())) {
String tempH = ByteUtils.signInt2HexString(tempEntity1.getTempHT().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getMinuteHT()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getSecondHT()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
content = "010201" + tempH + "00" + minuteH + secondH + "00000000";
} else if (!StringUtils.isBlank(tempEntity1.getTempLT(), tempEntity1.getMinuteLT(), tempEntity1.getSecondLT())) {
String tempL = ByteUtils.signInt2HexString(tempEntity1.getTempLT().toString(), 2);
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getMinuteLT()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(tempEntity1.getSecondLT()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010202" + "00" + tempL + "00000000" + minuteL + secondL;
}else {
content = "00020000000000000000000000";
}
}else if (statusT != null && statusT == 2){
content = "00020000000000000000000000";
}
ProtocolContent protocol = new ProtocolContent();
protocol.setReceiveId(entity.getNumbering());
protocol.setDeviceType("02");
protocol.setCmd("1C");
protocol.setContent(content);
String json = JSON.toJSONString(protocol);
if (status != null) {
redisUtils.set("device:sendtemp1:" + entity.getNumbering(), json);
}
if (statusT != null) {
redisUtils.set("device:sendtemp2:" + entity.getNumbering(), json);
}
return R.ok();
}
private String content(ShDeviceTempEntity tempEntity) {
String content;
if (!StringUtils.isBlank(tempEntity.getTempH(), tempEntity.getMinuteH(), tempEntity.getSecondH(), tempEntity.getTempL(), tempEntity.getMinuteL(), tempEntity.getSecondL())) {
String tempH = ByteUtils.signInt2HexString(tempEntity.getTempH().toString(), 2);
String tempL = ByteUtils.signInt2HexString(tempEntity.getTempL().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(tempEntity.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(tempEntity.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(tempEntity.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(tempEntity.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010103" + tempH + tempL + minuteH + secondH + minuteL + secondL;
} else if (!StringUtils.isBlank(tempEntity.getTempH(), tempEntity.getMinuteH(), tempEntity.getSecondH())) {
String tempH = ByteUtils.signInt2HexString(tempEntity.getTempH().toString(), 2);
StringBuilder minuteH = new StringBuilder(ByteUtils.int2Hex(tempEntity.getMinuteH()));
while (minuteH.length() < 4) {
minuteH.insert(0, "0");
}
StringBuilder secondH = new StringBuilder(ByteUtils.int2Hex(tempEntity.getSecondH()));
while (secondH.length() < 4) {
secondH.insert(0, "0");
}
content = "010101" + tempH + "00" + minuteH + secondH + "00000000";
} else if (!StringUtils.isBlank(tempEntity.getTempL(), tempEntity.getMinuteL(), tempEntity.getSecondL())) {
String tempL = ByteUtils.signInt2HexString(tempEntity.getTempL().toString(), 2);
StringBuilder minuteL = new StringBuilder(ByteUtils.int2Hex(tempEntity.getMinuteL()));
while (minuteL.length() < 4) {
minuteL.insert(0, "0");
}
StringBuilder secondL = new StringBuilder(ByteUtils.int2Hex(tempEntity.getSecondL()));
while (secondL.length() < 4) {
secondL.insert(0, "0");
}
content = "010102" + "00" + tempL + "00000000" + minuteL + secondL;
}else {
content = "00010000000000000000000000";
}
return content;
}
} }
\ No newline at end of file
...@@ -17,49 +17,52 @@ public class ShDeviceTempForm { ...@@ -17,49 +17,52 @@ public class ShDeviceTempForm {
@ApiModelProperty(value = "设备ID") @ApiModelProperty(value = "设备ID")
@NotNull(message="设备ID不能为空") @NotNull(message="设备ID不能为空")
private Integer deviceId; private Integer deviceId;
/**
@ApiModelProperty(value = "状态1") * 高温
private Integer status; */
@ApiModelProperty(value = "状态2")
private Integer statusT;
@ApiModelProperty(value = "高温") @ApiModelProperty(value = "高温")
@NotNull(message="高温不能为空")
private Integer tempH; private Integer tempH;
/**
@ApiModelProperty(value = "分钟") * 状态 1开 2关
private Integer minuteH; */
@ApiModelProperty(value = "状态")
@ApiModelProperty(value = "秒") @NotNull(message="状态不能为空")
private Integer secondH; private Integer statusH;
/**
@ApiModelProperty(value = "低温") * 底温
*/
@ApiModelProperty(value = "底温")
@NotNull(message="底温不能为空")
private Integer tempL; private Integer tempL;
/**
@ApiModelProperty(value = "分钟") * 状态 1开 2关
private Integer minuteL; */
@ApiModelProperty(value = "状态")
@ApiModelProperty(value = "秒") @NotNull(message="状态不能为空")
private Integer secondL; private Integer statusL;
/**
* 高温
*/
@ApiModelProperty(value = "高温") @ApiModelProperty(value = "高温")
@NotNull(message="高温不能为空")
private Integer tempHT; private Integer tempHT;
/**
@ApiModelProperty(value = "分钟") * 状态 1开 2关
private Integer minuteHT; */
@ApiModelProperty(value = "状态")
@ApiModelProperty(value = "秒") @NotNull(message="状态不能为空")
private Integer secondHT; private Integer statusHT;
/**
@ApiModelProperty(value = "低温") * 高温
*/
@ApiModelProperty(value = "高温")
@NotNull(message="高温不能为空")
private Integer tempLT; private Integer tempLT;
/**
@ApiModelProperty(value = "分钟") * 状态 1开 2关
private Integer minuteLT; */
@ApiModelProperty(value = "状态")
@ApiModelProperty(value = "秒") @NotNull(message="状态不能为空")
private Integer secondLT; private Integer statusLT;
@ApiModelProperty(value = "开关标识")
private Integer flag;
} }
...@@ -33,60 +33,32 @@ public class ShDeviceTempEntity implements Serializable { ...@@ -33,60 +33,32 @@ public class ShDeviceTempEntity implements Serializable {
*/ */
private Integer tempH; private Integer tempH;
/** /**
* 分钟 * 状态 1开 2关
*/ */
private Integer minuteH; private Integer statusH;
/** /**
* 秒 * 底温
*/
private Integer secondH;
/**
* 高温
*/ */
private Integer tempL; private Integer tempL;
/** /**
* 分钟 * 状态 1开 2关
*/
private Integer minuteL;
/**
* 秒
*/ */
private Integer secondL; private Integer statusL;
/** /**
* 高温 * 高温
*/ */
private Integer tempHT; private Integer tempHT;
/** /**
* 分钟 * 状态 1开 2关
*/
private Integer minuteHT;
/**
* 秒
*/ */
private Integer secondHT; private Integer statusHT;
/** /**
* 高温 * 高温
*/ */
private Integer tempLT; private Integer tempLT;
/**
* 分钟
*/
private Integer minuteLT;
/**
* 秒
*/
private Integer secondLT;
/**
* 创建时间
*/
private Date createTime;
/**
* 状态 1开 2关
*/
private Integer status;
/** /**
* 状态 1开 2关 * 状态 1开 2关
*/ */
private Integer statusT; private Integer statusLT;
} }
...@@ -8,20 +8,13 @@ ...@@ -8,20 +8,13 @@
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="deviceId" column="device_id"/> <result property="deviceId" column="device_id"/>
<result property="tempH" column="temp_h"/> <result property="tempH" column="temp_h"/>
<result property="minuteH" column="minute_h"/> <result property="statusH" column="status_h"/>
<result property="secondH" column="second_h"/>
<result property="tempL" column="temp_l"/> <result property="tempL" column="temp_l"/>
<result property="minuteL" column="minute_l"/> <result property="statusL" column="status_l"/>
<result property="secondL" column="second_l"/>
<result property="tempHT" column="temp_h_t"/> <result property="tempHT" column="temp_h_t"/>
<result property="minuteHT" column="minute_h_t"/> <result property="statusHT" column="status_h_t"/>
<result property="secondHT" column="second_h_t"/>
<result property="tempLT" column="temp_l_t"/> <result property="tempLT" column="temp_l_t"/>
<result property="minuteLT" column="minute_l_t"/> <result property="statusLT" column="status_l_t"/>
<result property="secondLT" column="second_l_t"/>
<result property="createTime" column="create_time"/>
<result property="status" column="status"/>
<result property="statusT" column="status_t"/>
</resultMap> </resultMap>
......
...@@ -168,20 +168,13 @@ CREATE TABLE `sh_device_temp` ( ...@@ -168,20 +168,13 @@ CREATE TABLE `sh_device_temp` (
`id` int(11) NOT NULL AUTO_INCREMENT, `id` int(11) NOT NULL AUTO_INCREMENT,
`device_id` int(11) DEFAULT NULL COMMENT '设备ID', `device_id` int(11) DEFAULT NULL COMMENT '设备ID',
`temp_h` int(10) DEFAULT NULL COMMENT '高温', `temp_h` int(10) DEFAULT NULL COMMENT '高温',
`minute_h` int(10) DEFAULT NULL COMMENT '分钟', `status_h` tinyint(2) DEFAULT NULL COMMENT '状态 0关 1开',
`second_h` int(10) DEFAULT NULL COMMENT '秒', `temp_l` int(10) DEFAULT NULL COMMENT '秒',
`temp_l` int(10) DEFAULT NULL COMMENT '高温', `status_l` tinyint(2) DEFAULT NULL COMMENT '状态 0关 1开',
`minute_l` int(10) DEFAULT NULL COMMENT '分钟', `temp_h_t` int(10) DEFAULT NULL COMMENT '分钟',
`second_l` int(10) DEFAULT NULL COMMENT '秒', `status_h_t` tinyint(2) DEFAULT NULL COMMENT '状态 0关 1开',
`temp_h_t` int(10) DEFAULT NULL COMMENT '高温',
`minute_h_t` int(10) DEFAULT NULL COMMENT '分钟',
`second_h_t` int(10) DEFAULT NULL COMMENT '秒',
`temp_l_t` int(10) DEFAULT NULL COMMENT '高温', `temp_l_t` int(10) DEFAULT NULL COMMENT '高温',
`minute_l_t` int(10) DEFAULT NULL COMMENT '分钟', `status_l_t` tinyint(2) DEFAULT NULL COMMENT '状态 0关 1开',
`second_l_t` int(10) DEFAULT NULL COMMENT '秒',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`status` tinyint(2) DEFAULT '2' COMMENT '状态 1开 2关',
`status_t` tinyint(2) DEFAULT '2' COMMENT '状态 1开 2关',
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
KEY `sh_device_temp_device_id` (`device_id`) USING BTREE KEY `sh_device_temp_device_id` (`device_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备温度控制'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='设备温度控制';
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论