Răsfoiți Sursa

Merge remote-tracking branch 'origin/master-碰一下' into test

tanbin 9 luni în urmă
părinte
comite
91169c2900

+ 18 - 1
device-api-service/src/main/java/com/xy/service/DevicePartServiceImpl.java

@@ -1,10 +1,14 @@
 package com.xy.service;
 
+import cn.hutool.core.util.BooleanUtil;
+import cn.hutool.json.JSONObject;
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.yitter.idgen.YitIdHelper;
 import com.xy.dto.DevicePartDto;
 import com.xy.entity.DevicePart;
+import com.xy.entity.DeviceSysinfo;
 import com.xy.mapper.DevicePartMapper;
 import com.xy.utils.Emptys;
 import com.xy.utils.MybatisPlusQuery;
@@ -35,6 +39,8 @@ import static com.xy.utils.Beans.copy;
 @Api(tags = "设备配件表")
 public class DevicePartServiceImpl extends ServiceImpl<DevicePartMapper, DevicePart> implements DevicePartService {
 
+    private final DeviceSysinfoServiceImpl deviceSysinfoService;
+
     @ApiOperation("集合查询")
     @PostMapping("list")
     public R<List<DevicePartDto.Vo>> list(@RequestBody DevicePartDto.SelectList selectList) {
@@ -49,8 +55,9 @@ public class DevicePartServiceImpl extends ServiceImpl<DevicePartMapper, DeviceP
         LocalDateTime now = LocalDateTime.now();
         //循环处理
         saveOrUpdates.forEach(saveOrUpdate -> {
+            Long deviceId = saveOrUpdate.getDeviceId();
             DevicePart devicePart = getOne(new LambdaQueryWrapper<DevicePart>()
-                    .eq(DevicePart::getDeviceId, saveOrUpdate.getDeviceId())
+                    .eq(DevicePart::getDeviceId, deviceId)
                     .eq(DevicePart::getCode, saveOrUpdate.getCode())
             );
             //删除
@@ -58,6 +65,15 @@ public class DevicePartServiceImpl extends ServiceImpl<DevicePartMapper, DeviceP
                 removeById(devicePart.getId());
                 return;
             }
+
+            String code = saveOrUpdate.getCode();
+            //nfc 系统信息表更新
+            if (Emptys.check(code) && "zfbNfc".equals(code)) {
+                String value = saveOrUpdate.getValue();
+                JSONObject jsonObject = JSONUtil.parseObj(value);
+                boolean haveNfc = BooleanUtil.isTrue(jsonObject.getBool("is"));
+                deviceSysinfoService.updateById(new DeviceSysinfo().setDeviceId(deviceId).setIsHaveAlipayNpad(haveNfc));
+            }
             //新增
             if (devicePart == null) {
                 DevicePart info = copy(DevicePart.class, saveOrUpdate)
@@ -71,6 +87,7 @@ public class DevicePartServiceImpl extends ServiceImpl<DevicePartMapper, DeviceP
             if (Emptys.check(saveOrUpdate.getValue())) {
                 updateById(devicePart.setValue(saveOrUpdate.getValue()));
             }
+
         });
         return R.ok();
     }