自测 bug-fix

master
guochaojie 4 months ago
parent 3237ce9bd2
commit 0cd6e0bbca

@ -526,6 +526,8 @@ public class DeviceController {
UserDTO user = UserContext.getUser(); UserDTO user = UserContext.getUser();
String deviceCode = cmd.getDeviceCode(); String deviceCode = cmd.getDeviceCode();
Object value = redisTool.getValue(deviceCode); Object value = redisTool.getValue(deviceCode);
Long expire = redisTool.getKeyExpire(deviceCode, TimeUnit.SECONDS);
log.info("@@@@@ 过期时间:{}", expire);
if (null == value) return CommonResult.error(400, "设备不在线"); if (null == value) return CommonResult.error(400, "设备不在线");
DeviceStatus status = JSONUtil.toBean(value.toString(), DeviceStatus.class); DeviceStatus status = JSONUtil.toBean(value.toString(), DeviceStatus.class);
// 判断设备是否在线 // 判断设备是否在线
@ -542,14 +544,14 @@ public class DeviceController {
if (null != cmd.getData() && StrUtil.isNotEmpty(cmd.getData().toString())) { if (null != cmd.getData() && StrUtil.isNotEmpty(cmd.getData().toString())) {
event.setBucketCode(cmd.getData().toString());//桶编码 event.setBucketCode(cmd.getData().toString());//桶编码
} }
RecycleDevice device = deviceService.getByDeviceCode(deviceCode);
event.setEventType(deviceCode); event.setEventType(cmd.getCmd().getValue());
event.setEventDesc("设备命令下发"); event.setEventDesc("设备命令下发");
event.setEventTime(new Date()); event.setEventTime(new Date());
event.setIsLocal("0");//远程调用 event.setIsLocal("0");//远程调用
event.setCreateUserId(user.getId()); event.setCreateUserId(null != user ? user.getId() : null);
event.setCreateTime(new Date()); event.setCreateTime(new Date());
event.setCompanyId(user.getCompanyId()); event.setCompanyId(device.getBeLongCompanyId());
eventService.save(event); eventService.save(event);
return CommonResult.success("指令下发成功"); return CommonResult.success("指令下发成功");
@ -582,8 +584,10 @@ public class DeviceController {
public CommonResult<String> getStatus(@RequestBody DeviceVO deviceVO) { public CommonResult<String> getStatus(@RequestBody DeviceVO deviceVO) {
Object value = redisTool.getValue(deviceVO.getDeviceCode()); Object value = redisTool.getValue(deviceVO.getDeviceCode());
if (value == null) return CommonResult.error(400, "获取失败,设备不在线!"); if (value == null) return CommonResult.error(400, "获取失败,设备不在线!");
Long expire = redisTool.getKeyExpire(deviceVO.getDeviceCode(), TimeUnit.SECONDS);
log.info("@@@@@ 过期时间:{}", expire);
DeviceStatus status = JSONUtil.toBean(value.toString(), DeviceStatus.class); DeviceStatus status = JSONUtil.toBean(value.toString(), DeviceStatus.class);
if (status.isOnline()) return CommonResult.error(400, "获取失败,设备不在线!"); if (!status.isOnline()) return CommonResult.error(400, "获取失败,设备不在线!");
CommandVO command = new CommandVO(); CommandVO command = new CommandVO();
command.setCmd(CMDEnum.status); command.setCmd(CMDEnum.status);
command.setDeviceCode(deviceVO.getDeviceCode()); command.setDeviceCode(deviceVO.getDeviceCode());
@ -600,7 +604,7 @@ public class DeviceController {
public CommonResult<String> receiveStatus(@RequestBody DeviceStatus des, HttpServletRequest request) { public CommonResult<String> receiveStatus(@RequestBody DeviceStatus des, HttpServletRequest request) {
String deviceCode = des.getDeviceCode(); String deviceCode = des.getDeviceCode();
String host = request.getRemoteHost(); String host = request.getRemoteHost();
des.setIp(host);//ip // des.setIp(host);//ip
des.setOnline(true);//在线 des.setOnline(true);//在线
log.info("设备编码:{},状态上报:{}host:{}", deviceCode, JSONUtil.toJsonStr(des), host); log.info("设备编码:{},状态上报:{}host:{}", deviceCode, JSONUtil.toJsonStr(des), host);
Object value = redisTool.getValue(deviceCode); Object value = redisTool.getValue(deviceCode);
@ -642,7 +646,7 @@ public class DeviceController {
} }
} }
} }
redisTool.setValue(deviceCode, JSONUtil.toJsonStr(des), 1000 * 60 * 60L); redisTool.setValue(deviceCode, JSONUtil.toJsonStr(des), 1000 * 60 * 5L);//5分钟
CommonResult<String> success = CommonResult.success(deviceCode); CommonResult<String> success = CommonResult.success(deviceCode);
success.setMsg("success"); success.setMsg("success");
return success; return success;
@ -688,6 +692,7 @@ public class DeviceController {
} }
} }
@ApiOperation("更换垃圾袋")
@PostMapping("/changeBag") @PostMapping("/changeBag")
public CommonResult<String> changeBag(@RequestBody BagCodeReqVO bag) { public CommonResult<String> changeBag(@RequestBody BagCodeReqVO bag) {
boolean b = bucketService.setBagNo(bag); boolean b = bucketService.setBagNo(bag);
@ -695,6 +700,7 @@ public class DeviceController {
else return CommonResult.error(400, "error"); else return CommonResult.error(400, "error");
} }
@ApiOperation("校验垃圾袋")
@PostMapping("/checkBag") @PostMapping("/checkBag")
public CommonResult<String> checkBag(@RequestBody BagCodeReqVO bag) { public CommonResult<String> checkBag(@RequestBody BagCodeReqVO bag) {
RecycleBucket bucket = bucketService.getByBag(bag); RecycleBucket bucket = bucketService.getByBag(bag);

@ -38,10 +38,10 @@ public class RecycleDeviceEvent {
@TableField(value = "IS_LOCAL") @TableField(value = "IS_LOCAL")
@ApiModelProperty("本地调用 0-否 1-是") @ApiModelProperty("本地调用 0-否 1-是")
private String isLocal; private String isLocal;
@TableField("orderNo") @TableField("ORDER_NO")
@ApiModelProperty("订单号") @ApiModelProperty("订单号")
private String orderNo; private String orderNo;
@TableField("orderType") @TableField("ORDER_TYPE")
@ApiModelProperty("订单类型") @ApiModelProperty("订单类型")
private String orderType; private String orderType;
@TableField("phone") @TableField("phone")

@ -15,10 +15,6 @@ public class DeviceStatus {
private String deviceCode; private String deviceCode;
@ApiModelProperty(value = "是否在线", hidden = true) @ApiModelProperty(value = "是否在线", hidden = true)
private boolean online; private boolean online;
@ApiModelProperty(value = "设备ip地址", hidden = true)
private String ip;
@ApiModelProperty(value = "设备端口", hidden = true)
private Integer port;
@ApiModelProperty(value = "桶状态", required = true) @ApiModelProperty(value = "桶状态", required = true)
private List<BucketStatus> bucketList; private List<BucketStatus> bucketList;
} }

@ -16,6 +16,8 @@ public class WeightVO {
private String bucketCode; private String bucketCode;
@ApiModelProperty(value = "重量", required = true) @ApiModelProperty(value = "重量", required = true)
private BigDecimal weight; private BigDecimal weight;
@ApiModelProperty(value = "是否稳定", required = true)
private boolean stable;
@ApiModelProperty(value = "订单号", required = true) @ApiModelProperty(value = "订单号", required = true)
private String orderNo; private String orderNo;
} }

@ -36,7 +36,7 @@ public class RecycleDeviceServiceImpl extends ServiceImpl<RecycleDeviceMapper, R
public int updateDevice(DeviceStatus status) { public int updateDevice(DeviceStatus status) {
UpdateWrapper<RecycleDevice> wrapper = new UpdateWrapper<>(); UpdateWrapper<RecycleDevice> wrapper = new UpdateWrapper<>();
wrapper.lambda() wrapper.lambda()
.set(RecycleDevice::getIpAddress, status.getIp()) // .set(RecycleDevice::getIpAddress, status.getIp())
.set(RecycleDevice::getStatus, status.isOnline() ? 1 : 0) .set(RecycleDevice::getStatus, status.isOnline() ? 1 : 0)
.eq(RecycleDevice::getDeviceCode, status.getDeviceCode()); .eq(RecycleDevice::getDeviceCode, status.getDeviceCode());
return update(wrapper) ? 1 : 0; return update(wrapper) ? 1 : 0;
@ -54,7 +54,7 @@ public class RecycleDeviceServiceImpl extends ServiceImpl<RecycleDeviceMapper, R
@Override @Override
public boolean isChanged(DeviceStatus oldStatus, DeviceStatus newStatus) { public boolean isChanged(DeviceStatus oldStatus, DeviceStatus newStatus) {
if (!oldStatus.getIp().equals(newStatus.getIp())) return true; // if (!oldStatus.getIp().equals(newStatus.getIp())) return true;
return oldStatus.isOnline() != newStatus.isOnline(); return oldStatus.isOnline() != newStatus.isOnline();
} }
} }

Loading…
Cancel
Save