|
@@ -134,7 +134,7 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
}
|
|
|
|
|
|
@PostMapping("rest")
|
|
|
- @ApiOperation("重置某项质检")
|
|
|
+ @ApiOperation("重置多项质检")
|
|
|
public R rest(@RequestBody DeviceQualityDto.Rest rest) {
|
|
|
SysDictRedis sysDictRedis1 = SysDictUtils.get(DeviceEnum.DEVICE_QUALITY_STATUS.getKey(), DeviceSonEnum.DEVICE_QUALITY_STATUS_QUALIFIED.getKey());
|
|
|
SysDictRedis sysDictRedis2 = SysDictUtils.get(DeviceEnum.DEVICE_FACTORY_STATUS.getKey(), DeviceSonEnum.DEVICE_FACTORY_STATUS_CAN_SHIPPED.getKey());
|
|
@@ -142,22 +142,27 @@ public class DeviceQualityServiceImpl extends ServiceImpl<DeviceQualityMapper, D
|
|
|
if (sysDictRedis1.getValue().equals(deviceQuality.getQualityState()) || sysDictRedis2.getValue().equals(deviceQuality.getFactoryState())) {
|
|
|
return R.fail("设备已合格或已出厂");
|
|
|
}
|
|
|
- //修改质检
|
|
|
- UpdateWrapper<DeviceQuality> updateWrapper = new UpdateWrapper<DeviceQuality>()
|
|
|
- .set(rest.getCode() + "_state_begin_time", LocalDateTime.now())
|
|
|
- .set(rest.getCode() + "_state_end_time", null)
|
|
|
- .eq(StringTools.humpToLine(LambdaUtils.getProperty(DeviceQuality::getQualityId)), rest.getQualityId());
|
|
|
- update(updateWrapper);
|
|
|
- //修改质检属性
|
|
|
- DeviceQualityValueDto.Update update = new DeviceQualityValueDto.Update()
|
|
|
- .setCode(rest.getCode());
|
|
|
- update.setQualityId(rest.getQualityId());
|
|
|
- deviceQualityValueService.update(update);
|
|
|
- //发送mqtt指令
|
|
|
- CommandMqtt commandMqtt = new CommandMqtt()
|
|
|
- .setDeviceId(deviceQuality.getDeviceId())
|
|
|
- .setTemplet(rest.getTemplet());
|
|
|
- mqttService.senCommand(Arrays.asList(commandMqtt));
|
|
|
+ List<CommandMqtt> commandMqtts = new ArrayList<>();
|
|
|
+ List<DeviceQualityDto.Save.Templet> templets = rest.getTemplets();
|
|
|
+ for (DeviceQualityDto.Save.Templet templet : templets) {
|
|
|
+ //修改质检
|
|
|
+ UpdateWrapper<DeviceQuality> updateWrapper = new UpdateWrapper<DeviceQuality>()
|
|
|
+ .set(templet.getCode() + "_state_begin_time", LocalDateTime.now())
|
|
|
+ .set(templet.getCode() + "_state_end_time", null)
|
|
|
+ .eq(StringTools.humpToLine(LambdaUtils.getProperty(DeviceQuality::getQualityId)), rest.getQualityId());
|
|
|
+ update(updateWrapper);
|
|
|
+ //修改质检属性
|
|
|
+ DeviceQualityValueDto.Update update = new DeviceQualityValueDto.Update()
|
|
|
+ .setCode(templet.getCode());
|
|
|
+ update.setQualityId(rest.getQualityId());
|
|
|
+ deviceQualityValueService.update(update);
|
|
|
+ //发送mqtt指令
|
|
|
+ CommandMqtt commandMqtt = new CommandMqtt()
|
|
|
+ .setDeviceId(deviceQuality.getDeviceId())
|
|
|
+ .setTemplet(templet.getTemplet());
|
|
|
+ commandMqtts.add(commandMqtt);
|
|
|
+ }
|
|
|
+ mqttService.senCommand(commandMqtts);
|
|
|
return R.ok();
|
|
|
}
|
|
|
|