|
@@ -55,16 +55,31 @@ public class DeviceParamsConfigServiceImpl extends ServiceImpl<DeviceParamsConfi
|
|
|
public R<List<DeviceParamsConfigDto.Vo>> query(@RequestBody @Validated DeviceParamsConfigDto.Query query) {
|
|
|
DeviceInfo deviceInfo = deviceInfoService.getById(query.getDeviceId());
|
|
|
// 查询设备参数
|
|
|
- List<DeviceParamsConfig> deviceParamsConfigs1 = list(new LambdaQueryWrapper<DeviceParamsConfig>().eq(DeviceParamsConfig::getDeviceId, deviceInfo.getDeviceId()));
|
|
|
+ List<DeviceParamsConfig> deviceParamsConfigs1 = list(new LambdaQueryWrapper<DeviceParamsConfig>()
|
|
|
+ .eq(DeviceParamsConfig::getDeviceId, deviceInfo.getDeviceId())
|
|
|
+ );
|
|
|
JMap<String, DeviceParamsConfig> cover = new JArrayList<>(deviceParamsConfigs1).toMap(DeviceParamsConfig::getCode).cover();
|
|
|
// 查询商家参数
|
|
|
- List<DeviceParamsConfig> deviceParamsConfigs2 = list(new LambdaQueryWrapper<DeviceParamsConfig>().eq(DeviceParamsConfig::getMercId, deviceInfo.getMercId()));
|
|
|
+ List<DeviceParamsConfig> deviceParamsConfigs2 = list(new LambdaQueryWrapper<DeviceParamsConfig>()
|
|
|
+ .eq(DeviceParamsConfig::getMercId, deviceInfo.getMercId())
|
|
|
+ );
|
|
|
for (DeviceParamsConfig deviceParamsConfig : deviceParamsConfigs2) {
|
|
|
if (cover.containsKey(deviceParamsConfig.getCode())) {
|
|
|
continue;
|
|
|
}
|
|
|
cover.put(deviceParamsConfig.getCode(), deviceParamsConfig);
|
|
|
}
|
|
|
+ // 查询平台参数
|
|
|
+ List<DeviceParamsConfig> deviceParamsConfigs3 = list(new LambdaQueryWrapper<DeviceParamsConfig>()
|
|
|
+ .isNull(DeviceParamsConfig::getMercId)
|
|
|
+ .isNull(DeviceParamsConfig::getDeviceId)
|
|
|
+ );
|
|
|
+ for (DeviceParamsConfig deviceParamsConfig : deviceParamsConfigs3) {
|
|
|
+ if (cover.containsKey(deviceParamsConfig.getCode())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ cover.put(deviceParamsConfig.getCode(), deviceParamsConfig);
|
|
|
+ }
|
|
|
List<DeviceParamsConfigDto.Vo> vos = copy(DeviceParamsConfigDto.Vo.class, cover.getValues());
|
|
|
return R.ok(vos);
|
|
|
}
|
|
@@ -105,12 +120,17 @@ public class DeviceParamsConfigServiceImpl extends ServiceImpl<DeviceParamsConfi
|
|
|
@PostMapping("save")
|
|
|
@ApiOperation("保存")
|
|
|
public R save(@RequestBody @Validated DeviceParamsConfigDto.Save save) {
|
|
|
- if ((!Emptys.check(save.getMercId()) && !Emptys.check(save.getDeviceId())) || Emptys.check(save.getMercId()) && Emptys.check(save.getDeviceId())) {
|
|
|
- throw new RuntimeException("mercId和deviceId二选一");
|
|
|
+ if (Emptys.check(save.getMercId()) && Emptys.check(save.getDeviceId())) {
|
|
|
+ throw new RuntimeException("mercId和deviceId只能二选一");
|
|
|
}
|
|
|
- DeviceParamsConfig deviceParamsConfig = getOne(new LambdaQueryWrapper<DeviceParamsConfig>().eq(Emptys.check(save.getMercId()), DeviceParamsConfig::getMercId, save.getMercId()).eq(Emptys.check(save.getDeviceId()), DeviceParamsConfig::getDeviceId, save.getDeviceId()).eq(DeviceParamsConfig::getCode, save.getCode()));
|
|
|
+ DeviceParamsConfig deviceParamsConfig = getOne(new LambdaQueryWrapper<DeviceParamsConfig>()
|
|
|
+ .eq(Emptys.check(save.getMercId()), DeviceParamsConfig::getMercId, save.getMercId())
|
|
|
+ .eq(Emptys.check(save.getDeviceId()), DeviceParamsConfig::getDeviceId, save.getDeviceId())
|
|
|
+ .eq(DeviceParamsConfig::getCode, save.getCode()));
|
|
|
if (deviceParamsConfig == null) {
|
|
|
- deviceParamsConfig = new DeviceParamsConfig().setId(YitIdHelper.nextId()).setCreateTime(LocalDateTime.now());
|
|
|
+ deviceParamsConfig = new DeviceParamsConfig()
|
|
|
+ .setId(YitIdHelper.nextId())
|
|
|
+ .setCreateTime(LocalDateTime.now());
|
|
|
}
|
|
|
DeviceParamsConfig info = copy(deviceParamsConfig, save);
|
|
|
saveOrUpdate(info);
|