From 25b3da033a6e416ac745676552a1fc03a1428d86 Mon Sep 17 00:00:00 2001 From: guofeihu <3347277866@qq.com> Date: Fri, 14 Jun 2024 10:02:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E6=B3=A8=E5=86=8C=E5=90=8E?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=E6=A8=A1=E6=9D=BF=E5=8F=82=E6=95=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=8F=8A=E6=B3=A8=E5=86=8C=E5=90=8E=E6=8F=92=E5=85=A5?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E7=82=B9cs=5Fline=E9=87=8D=E5=A4=8D=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/CsDeviceServiceImpl.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java index 38cf6d5..817ab7b 100644 --- a/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java +++ b/iot-access/access-boot/src/main/java/com/njcn/access/service/impl/CsDeviceServiceImpl.java @@ -378,7 +378,11 @@ public class CsDeviceServiceImpl implements ICsDeviceService { Thread.sleep(1000); List modelList = objectToList(redisUtil.getObjectByKey(AppRedisKey.MODEL + nDid)); if (CollUtil.isEmpty(modelList)){ - throwExceptionAndLog(AccessResponseEnum.MODEL_ERROR, logDto); + try { + throwExceptionAndLog(AccessResponseEnum.MODEL_ERROR, logDto); + } catch (Exception e) { + throw new BusinessException(e.getMessage()); + } } List list = csDataSetService.getDataSetData(modelList.get(0).getModelId()); list.forEach(item->{ @@ -388,7 +392,12 @@ public class CsDeviceServiceImpl implements ICsDeviceService { po.setStatus(1); po.setClDid(item.getClDev()); po.setDeviceId(vo.getId()); - csLinePoList.add(po); + //防止主键重复 + QueryWrapper qw = new QueryWrapper(); + qw.eq("line_id",po.getLineId()); + if(csLineService.getBaseMapper().selectList(qw).isEmpty()){ + csLinePoList.add(po); + } }); csLineService.saveBatch(csLinePoList); //2.生成装置和模板的关系表 @@ -419,7 +428,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { logDto.setResult(0); logDto.setFailReason(e.getMessage()); csLogsFeignClient.addUserLog(logDto); - throw new BusinessException(e.getMessage()); + throw new BusinessException(CommonResponseEnum.FAIL); } return "success"; } catch (BusinessException e) { @@ -469,7 +478,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService { throwExceptionAndLog(AccessResponseEnum.DEV_MODEL_NOT_FIND, logDto); } String devModel = dictData.getCode(); - zhiLianRegister(nDid,"PQV-500"); + zhiLianRegister(nDid,devModel); } private DeviceLogDTO createLogDto(String operate) {