diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java index b91b2a11..6079c246 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcChargingPileMapper.java @@ -103,4 +103,7 @@ public interface XhpcChargingPileMapper { */ int pileCount(@Param("chargingStationId") Long chargingStationId); + + + XhpcChargingPile getXhpcChargingPileBySerialNumber(@Param("serialNumber") String serialNumber); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java index 49b5f2e5..7856fd5c 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcChargingPileServiceImpl.java @@ -1,6 +1,7 @@ package com.xhpc.charging.station.service; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.util.StrUtil; import com.aliyun.oss.OSSClient; import com.aliyun.oss.model.*; import com.xhpc.charging.station.mapper.XhpcChargingPileMapper; @@ -322,21 +323,21 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { for (XhpcChargingPile pile : pileList) { try { // 所有表格字段数据必须非空且有效 - if("".equals(pile.getChargingStationName()) || "".equals(pile.getName()) - || "".equals(pile.getBrandModel()) || "".equals(pile.getNationalStandard()) + if(StrUtil.hasBlank(pile.getChargingStationName()) || StrUtil.hasBlank(pile.getName()) + || StrUtil.hasBlank(pile.getBrandModel()) || StrUtil.hasBlank(pile.getNationalStandard()) || pile.getPower() == null || pile.getPower()<0 || pile.getAuxiliaryPowerSupply() == null || pile.getAuxiliaryPowerSupply()<0 || pile.getInputVoltage() ==null || pile.getInputVoltage()<0 || pile.getMaxVoltage() ==null || pile.getMaxVoltage()<0 || pile.getMinVoltage() == null || pile.getMinVoltage() < 0 || pile.getMaxElectricCurrent() == null || pile.getMaxElectricCurrent() < 0 - || pile.getMinElectriCurrent() == null || pile.getMinElectriCurrent() <0 - || "".equals(pile.getSerialNumber()) - || "".equals(pile.getTypeName()) + || pile.getMinElectriCurrent() == null || pile.getMinElectriCurrent() < 0 + || StrUtil.hasBlank(pile.getSerialNumber()) + || StrUtil.hasBlank(pile.getTypeName()) || pile.getGunNumber() == null || pile.getGunNumber() <0 - || "".equals(pile.getCommunicationProtocolVersion()) || "".equals(pile.getNetworkLinkType()) - || "".equals(pile.getProductionDate()) || "".equals(pile.getManufactureName()) - || "".equals(pile.getConnectorTypeName()) || "".equals(pile.getEquipmentTypeName())){ + || StrUtil.hasBlank(pile.getCommunicationProtocolVersion()) || StrUtil.hasBlank(pile.getNetworkLinkType()) + || StrUtil.hasBlank(pile.getProductionDate()) || StrUtil.hasBlank(pile.getManufactureName()) + || StrUtil.hasBlank(pile.getConnectorTypeName())|| StrUtil.hasBlank(pile.getEquipmentTypeName())){ failureNum ++; failureMsg.append("
电站名称: ").append(pile.getChargingStationName()).append(" ,电桩名称: ").append(pile.getName()).append(" 导入失败; 失败原因: 必填字段为空。"); continue; @@ -353,7 +354,26 @@ public class XhpcChargingPileServiceImpl implements IXhpcChargingPileService { continue; } pile.setChargingStationId(station.getChargingStationId()); - AjaxResult result = addXhpcChargingPile(pile); + + String serialNumber = pile.getSerialNumber(); + XhpcChargingPile chargingPile = xhpcChargingPileMapper.getXhpcChargingPileBySerialNumber(serialNumber); + AjaxResult result = null; + + if(isUpdateSupport){ + if(chargingPile != null){ + pile.setChargingPileId(chargingPile.getChargingPileId()); + result = updateXhpcChargingPile(pile); + }else { + result = addXhpcChargingPile(pile); + } + } else { + if(chargingPile != null) { + result = AjaxResult.error("桩编号重复"); + } else { + result = addXhpcChargingPile(pile); + } + } + if(!result.get(AjaxResult.CODE_TAG).equals(HttpStatus.SUCCESS)){ failureNum ++; failureMsg.append("
电站名称: ").append(pile.getChargingStationName()).append(" ,电桩名称: ").append(pile.getName()).append(" 导入失败; 失败原因: ").append(result.get(AjaxResult.MSG_TAG)); diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml index 02d99531..c3ad97eb 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcChargingPileMapper.xml @@ -447,4 +447,44 @@ + +