From baadc30727a26063fa964e600830ee24e560b802 Mon Sep 17 00:00:00 2001 From: "autumn.g@foxmail.com" Date: Fri, 15 Sep 2023 10:02:20 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E7=99=BB=E5=BD=95=E6=9B=B4=E6=96=B0si?= =?UTF-8?q?m=E5=8D=A1=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PileBasicInfoServiceImpl.java | 51 +++++++++---------- .../mapper/pile/PileSimInfoMapper.xml | 2 +- 2 files changed, 24 insertions(+), 29 deletions(-) diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java index 4749f4021..e6251a901 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileBasicInfoServiceImpl.java @@ -563,23 +563,11 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService { } // 去卡运营商查询流量等信息 List simCardVOS = simCardService.searchByLoop(Lists.newArrayList(iccid)); - // 查询数据库中是否有此卡 - PileSimInfo simInfo = pileSimInfoService.getBasicInfoByIccId(iccid); - - SimCardVO simCardVO = null; - if (CollectionUtils.isEmpty(simCardVOS)) { - // 已对接的卡商没有信息 - if (simInfo == null) { - // 数据库中也没有此卡信息,说明为新卡,新增一条卡数据 - simInfo = PileSimInfo.builder() - .iccid(iccid) - .build(); - pileSimInfoService.insertPileSimInfo(simInfo); - } - }else { + PileSimInfo simBasicInfo; + if (CollectionUtils.isNotEmpty(simCardVOS)) { // 卡商有信息,先获取最新信息 - simCardVO = simCardVOS.get(0); - PileSimInfo simBasicInfo = PileSimInfo.builder() + SimCardVO simCardVO = simCardVOS.get(0); + simBasicInfo = PileSimInfo.builder() .iccid(iccid) .name(simCardVO.getName()) .simSupplier(simCardVO.getSimCardFactory()) @@ -589,20 +577,27 @@ public class PileBasicInfoServiceImpl implements IPileBasicInfoService { .surplusData(String.valueOf(simCardVO.getResidualFlowRate())) .totalData(String.valueOf(simCardVO.getPackageCapacity())) .build(); - if (simInfo == null) { - // 数据库中没有此卡,新增 - pileSimInfoService.insertPileSimInfo(simBasicInfo); - }else { - // 更新 - pileSimInfoService.updatePileSimInfo(simBasicInfo); - } - // 再根据iccid查询当前卡id - String simId = pileSimInfoMapper.selectIdByIccId(iccid); - basicInfo.setSimId(Long.parseLong(simId)); + } else { + // 数据库中也没有此卡信息,说明为新卡,新增一条卡数据 + simBasicInfo = PileSimInfo.builder() + .iccid(iccid) + .build(); } - // 统一更新桩基本信息表 - updateSimInfo(basicInfo); + // 查询数据库中是否有此卡 + PileSimInfo simInfo = pileSimInfoService.getBasicInfoByIccId(iccid); + if (simInfo == null) { + // 数据库中没有此卡,新增 + pileSimInfoService.insertPileSimInfo(simBasicInfo); + }else { + // 更新 + simBasicInfo.setId(simInfo.getId()); + pileSimInfoService.updatePileSimInfo(simBasicInfo); + } + + // 统一更新桩基本信息表 + basicInfo.setSimId(simBasicInfo.getId()); + updateSimInfo(basicInfo); } @Override diff --git a/jsowell-pile/src/main/resources/mapper/pile/PileSimInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/PileSimInfoMapper.xml index 50a78174c..be2de0fee 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/PileSimInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/PileSimInfoMapper.xml @@ -46,7 +46,7 @@ where id = #{id} - + insert into pile_sim_info id,