源数据接口修改,解决接口名称表数据重复bug,增加资源名称同步修改逻辑。

This commit is contained in:
gaoyutao
2025-09-04 23:18:08 +08:00
parent ec3fb074e1
commit 8aaa60d7ef
29 changed files with 396 additions and 571 deletions

View File

@@ -25,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
import org.webjars.NotFoundException;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
@@ -197,6 +198,15 @@ public class EpsNodeBandwidthController extends BaseController
if ("1".equals(resourceType)) {
// 处理服务器流量数据
PageInfo<EpsInitialTrafficData> pageInfo = epsNodeBandwidthService.relatedData(epsNodeBandwidth, dailyStartTime, dailyEndTime);;
for (EpsInitialTrafficData epsInitialTrafficData : pageInfo.getList()) {
if("2".equals(epsInitialTrafficData.getRevenueMethod())){
BigDecimal packageBandwidth = epsInitialTrafficData.getPackageBandwidth();
BigDecimal outSpeed = (packageBandwidth != null)
? packageBandwidth.multiply(new BigDecimal("1000000"))
: BigDecimal.ZERO;
epsInitialTrafficData.setOutSpeed(outSpeed.toString());
}
}
return getDataTable(pageInfo.getList(), pageInfo.getTotal());
} else{
// 4. 设置分页参数

View File

@@ -36,7 +36,7 @@ public class EpsServerRevenueConfigController extends BaseController
*/
@RequiresPermissions("system:config:list")
@PostMapping("/list")
public TableDataInfo list(EpsServerRevenueConfig epsServerRevenueConfig)
public TableDataInfo list(@RequestBody EpsServerRevenueConfig epsServerRevenueConfig)
{
PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(epsServerRevenueConfig.getPageNum());

View File

@@ -129,6 +129,9 @@ public class EpsNodeBandwidth extends BaseEntity
private String monthTime;
/** 备注 */
private String remark1;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createDatetime;
private List<String> nodeNames;

View File

@@ -81,4 +81,6 @@ public interface EpsNodeBandwidthMapper
* @return 节点带宽信息
*/
public int countByAvgMsg(EpsNodeBandwidth epsNodeBandwidth);
int updateEpsNodeBandwidthByServerSn(EpsNodeBandwidth epsNodeBandwidth);
}

View File

@@ -77,4 +77,6 @@ public interface EpsServerRevenueConfigMapper
* @return 服务器收益方式配置
*/
public Map getNodeMsgByIp(@Param("ipAddress") String ipAddress);
int updateEpsServerRevenueConfigByServerSn(EpsServerRevenueConfig epsServerRevenueConfig);
}

View File

@@ -59,4 +59,6 @@ public interface RmEpsTopologyManagementMapper
* @return 结果
*/
public int deleteRmEpsTopologyManagementByIds(Long[] ids);
int updateRmEpsTopologyManagementByServerSn(RmEpsTopologyManagement rmEpsTopologyManagement);
}

View File

@@ -167,7 +167,6 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
return 0;
}
// 3. 获取计算数据(防止空指针)
EpsNodeBandwidth calculatedData = epsNodeBandwidthMapper.calculateAvg(epsNodeBandwidth);
if (calculatedData == null) {
@@ -182,8 +181,12 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
// 5. 计算当月天数
LocalDate monthTime;
try {
monthTime = LocalDate.parse(epsNodeBandwidth.getMonthTime() == null
? epsNodeBandwidth.getStartTime().substring(0,10) : epsNodeBandwidth.getMonthTime());
String monthStr = epsNodeBandwidth.getMonthTime() == null
? epsNodeBandwidth.getStartTime().substring(0, 7)
: epsNodeBandwidth.getMonthTime();
YearMonth yearMonth = YearMonth.parse(monthStr);
monthTime = yearMonth.atDay(1); // 转换为当月第一天
} catch (Exception e) {
log.error("月份时间格式错误: {}", epsNodeBandwidth.getMonthTime() == null
? epsNodeBandwidth.getStartTime() : epsNodeBandwidth.getMonthTime(), e);
@@ -224,7 +227,11 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
epsNodeBandwidth.setId(existingRecords.get(0).getId());
epsNodeBandwidth.setUpdateTime(DateUtils.getNowDate());
}else{
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(epsNodeBandwidth.getStartTime()));
if(epsNodeBandwidth.getStartTime() == null){
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(monthTime));
}else{
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(epsNodeBandwidth.getStartTime()));
}
}
// 有效-月均日95值
BigDecimal effectiveAvg = sumEffectiveBandwidth95Daily.divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP);
@@ -242,7 +249,11 @@ public class EpsNodeBandwidthServiceImpl implements IEpsNodeBandwidthService
epsNodeBandwidth.setId(existingRecords.get(0).getId());
epsNodeBandwidth.setUpdateTime(DateUtils.getNowDate());
}else{
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(epsNodeBandwidth.getStartTime()));
if(epsNodeBandwidth.getStartTime() == null){
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(monthTime));
}else{
epsNodeBandwidth.setCreateTime(DateUtils.parseDate(epsNodeBandwidth.getStartTime()));
}
}
// 月均日95值
BigDecimal avgMonthly = sum95Daily.divide(BigDecimal.valueOf(daysInMonth), 2, RoundingMode.HALF_UP);

View File

@@ -15,12 +15,11 @@ import com.ruoyi.system.service.EpsInitialTrafficDataService;
import com.ruoyi.system.service.IEpsServerRevenueConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 服务器收益方式配置Service业务层处理
@@ -176,7 +175,11 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
for (EpsInitialTrafficData initialTrafficData : dataList) {
// 根据ip查询节点名称
String ip = initialTrafficData.getIpV4() == null ? "" : initialTrafficData.getIpV4();
String mac = initialTrafficData.getMac() == null ? "" : initialTrafficData.getMac();
Map nodeMsg = epsServerRevenueConfigMapper.getNodeMsgByIp(ip);
if(nodeMsg == null){
nodeMsg = epsServerRevenueConfigMapper.getNodeMsgByIp(mac);
}
// 赋值
if(nodeMsg != null){
initialTrafficData.setServiceSn(getNullableString(nodeMsg, "hardwareSn"));
@@ -221,67 +224,97 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
* 批量处理接口名称
*/
private void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
// 收集所有需要检查的接口名称
Set<String> interfaceNames = trafficDataList.stream()
.map(EpsInitialTrafficData::getName)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
if (interfaceNames.isEmpty()) {
return;
}
// 批量查询已存在的接口名称
AllInterfaceName allInterfaceName = new AllInterfaceName();
if(!trafficDataList.isEmpty()){
allInterfaceName.setClientId(trafficDataList.get(0).getClientId());
allInterfaceName.setInterfaceNames(interfaceNames);
}
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(allInterfaceName);
// 转为 Map<接口名称, 数据库记录> 便于快速查找
Map<String, AllInterfaceName> existingNameMap = existingNames.stream()
.collect(Collectors.toMap(
item -> item.getClientId() + "|" + item.getInterfaceName(), // 关键修改点
Function.identity(),
(oldValue, newValue) -> oldValue // 重复时保留旧记录
));
// 分类处理:新增列表 vs 更新列表
List<AllInterfaceName> namesToInsert = new ArrayList<>();
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
// 用于去重的临时集合,防止同一批数据中的重复
Set<String> processedKeys = new HashSet<>();
trafficDataList.forEach(data -> {
String name = data.getName();
if (StringUtils.isBlank(name)) {
String ip = data.getMac();
String clientId = data.getClientId();
if (StringUtils.isBlank(name) || StringUtils.isBlank(ip) || StringUtils.isBlank(clientId)) {
return;
}
// 构造新记录(需更新的字段)
// 生成唯一键,防止同一批数据中的重复处理
String uniqueKey = name + "|" + clientId + "|" + ip;
if (processedKeys.contains(uniqueKey)) {
return;
}
processedKeys.add(uniqueKey);
// 构造新记录
AllInterfaceName newRecord = new AllInterfaceName();
newRecord.setInterfaceName(name);
newRecord.setClientId(data.getClientId());
newRecord.setResourceType("1"); // 固定值
newRecord.setResourceType("1");
newRecord.setDeviceSn(data.getServiceSn());
newRecord.setNodeName(data.getNodeName());
newRecord.setBusinessCode(data.getBusinessId());
newRecord.setBusinessName(data.getBusinessName());
newRecord.setServerIp(data.getIpV4());
// 判断是否需要更新
String compositeKey = data.getClientId() + "|" + name;
if (existingNameMap.containsKey(compositeKey)) {
AllInterfaceName oldRecord = existingNameMap.get(compositeKey);
if (isRecordChanged(oldRecord, newRecord)) {
newRecord.setId(oldRecord.getId()); // 保留原ID
namesToUpdate.add(newRecord);
newRecord.setServerIp(data.getMac());
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(newRecord);
if (!existingNames.isEmpty()) {
for (AllInterfaceName existingName : existingNames) {
if (isRecordChanged(existingName, newRecord)) {
newRecord.setId(existingName.getId());
newRecord.setUpdateTime(DateUtils.getNowDate());
// 检查是否已经存在于更新列表中
boolean alreadyInUpdateList = namesToUpdate.stream()
.anyMatch(item -> item.getId() != null && item.getId().equals(existingName.getId()));
if (!alreadyInUpdateList) {
namesToUpdate.add(newRecord);
}
}
}
} else {
namesToInsert.add(newRecord);
newRecord.setCreateTime(DateUtils.getNowDate());
newRecord.setUpdateTime(DateUtils.getNowDate());
// 检查namesToInsert中是否已有相同记录
boolean alreadyInInsertList = namesToInsert.stream()
.anyMatch(item -> item.getInterfaceName().equals(name)
&& item.getClientId().equals(clientId)
&& item.getServerIp().equals(ip));
if (!alreadyInInsertList) {
namesToInsert.add(newRecord);
}
}
});
// 批量操作数据库
if (!namesToInsert.isEmpty()) {
allInterfaceNameMapper.batchInsert(namesToInsert);
log.info("新增接口名称数量:{}", namesToInsert.size());
try {
allInterfaceNameMapper.batchInsert(namesToInsert);
log.info("新增接口名称数量:{}", namesToInsert.size());
} catch (DuplicateKeyException e) {
// 如果批量插入出现重复,转为逐条插入(带异常处理)
log.warn("批量插入出现重复,转为逐条处理");
namesToInsert.forEach(record -> {
try {
allInterfaceNameMapper.insertAllInterfaceName(record);
} catch (DuplicateKeyException ex) {
// 重复记录转为更新
AllInterfaceName query = new AllInterfaceName();
query.setInterfaceName(record.getInterfaceName());
query.setClientId(record.getClientId());
query.setServerIp(record.getServerIp());
List<AllInterfaceName> existing = allInterfaceNameMapper.selectByNames(query);
if (!existing.isEmpty()) {
record.setId(existing.get(0).getId());
allInterfaceNameMapper.updateAllInterfaceName(record);
}
}
});
}
}
if (!namesToUpdate.isEmpty()) {
@@ -289,10 +322,10 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
log.info("更新接口名称数量:{}", namesToUpdate.size());
}
}
// 辅助方法:检查记录是否有变化
private boolean isRecordChanged(AllInterfaceName oldRecord, AllInterfaceName newRecord) {
return !Objects.equals(oldRecord.getClientId(), newRecord.getClientId()) ||
!Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
return !Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
!Objects.equals(oldRecord.getNodeName(), newRecord.getNodeName()) ||
!Objects.equals(oldRecord.getBusinessCode(), newRecord.getBusinessCode()) ||
!Objects.equals(oldRecord.getBusinessName(), newRecord.getBusinessName()) ||

View File

@@ -9,13 +9,14 @@ import com.ruoyi.system.service.IInitialSwitchInfoDetailsService;
import com.ruoyi.system.util.CalculateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -28,7 +29,6 @@ import java.util.stream.Collectors;
@Slf4j
public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDetailsService
{
private static final DateTimeFormatter TIME_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
@Autowired
private InitialSwitchInfoDetailsMapper initialSwitchInfoDetailsMapper;
@Autowired
@@ -134,31 +134,37 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
List<RmEpsTopologyManagement> managements = rmEpsTopologyManagementMapper.selectRmEpsTopologyManagementList(rmEpsTopologyManagement);
// 赋值
if(!managements.isEmpty()){
RmEpsTopologyManagement management = managements.get(0);
details.setSwitchSn(management.getSwitchSn());
details.setSwitchName(management.getSwitchName());
details.setInterfaceDeviceType(management.getConnectedDeviceType());
details.setServerName(management.getServerName());
details.setServerPort(management.getServerPort());
details.setServerSn(management.getServerSn());
// 根据服务器sn查询业务
if(management.getServerSn() != null){
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(management.getServerSn());
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
if(!businessList.isEmpty()){
EpsServerRevenueConfig revenueConfig = businessList.get(0);
details.setBusinessName(revenueConfig.getBusinessName());
details.setBusinessCode(revenueConfig.getBusinessCode());
for (RmEpsTopologyManagement management : managements) {
if("1".equals(management.getConnectedDeviceType())){
details.setOutSpeed(null);
}else{
details.setInSpeed(null);
}
}else {
details.setBusinessCode(null);
details.setBusinessName(null);
details.setSwitchSn(management.getSwitchSn());
details.setSwitchName(management.getSwitchName());
details.setInterfaceDeviceType(management.getConnectedDeviceType());
details.setServerName(management.getServerName());
details.setServerPort(management.getServerPort());
details.setServerSn(management.getServerSn());
// 根据服务器sn查询业务
if(management.getServerSn() != null){
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(management.getServerSn());
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
if(!businessList.isEmpty()){
EpsServerRevenueConfig revenueConfig = businessList.get(0);
details.setBusinessName(revenueConfig.getBusinessName());
details.setBusinessCode(revenueConfig.getBusinessCode());
}
}else {
details.setBusinessCode(null);
details.setBusinessName(null);
}
// id自增
details.setId(null);
batchList.add(details);
}
}
// id自增
details.setId(null);
batchList.add(details);
}
}
initialSwitchInfoDetails.setDataList(batchList);
@@ -183,38 +189,23 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
* 批量处理接口名称
*/
private void processSwitchInterfaceNames(List<InitialSwitchInfoDetails> initialSwitchInfoDetails) {
// 收集所有需要检查的接口名称
Set<String> interfaceNames = initialSwitchInfoDetails.stream()
.map(InitialSwitchInfoDetails::getName)
.filter(StringUtils::isNotBlank)
.collect(Collectors.toSet());
if (interfaceNames.isEmpty()) {
return;
}
AllInterfaceName allInterfaceName = new AllInterfaceName();
if(!initialSwitchInfoDetails.isEmpty()){
allInterfaceName.setClientId(initialSwitchInfoDetails.get(0).getClientId());
allInterfaceName.setInterfaceNames(interfaceNames);
}
// 批量查询已存在的接口名称
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(allInterfaceName);
Map<String, AllInterfaceName> existingNameMap = existingNames.stream()
.collect(Collectors.toMap(
item -> item.getClientId() + "|" + item.getInterfaceName(), // 关键修改点
Function.identity(),
(oldValue, newValue) -> oldValue // 重复时保留旧记录
));
// 分类处理:新增列表 vs 更新列表
List<AllInterfaceName> namesToInsert = new ArrayList<>();
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
initialSwitchInfoDetails.forEach(data -> {
String name = data.getName();
if (StringUtils.isBlank(name)) {
String ip = data.getSwitchIp();
String clientId = data.getClientId();
if (StringUtils.isBlank(name) || StringUtils.isBlank(ip) || StringUtils.isBlank(clientId)) {
return;
}
AllInterfaceName allInterfaceName = new AllInterfaceName();
allInterfaceName.setClientId(clientId);
allInterfaceName.setSwitchIp(ip);
allInterfaceName.setInterfaceName(name);
allInterfaceName.setResourceType("2");
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(allInterfaceName);
AllInterfaceName record = new AllInterfaceName();
record.setInterfaceName(name);
record.setClientId(data.getClientId());
@@ -241,22 +232,57 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
record.setBusinessName(null);
}
// 判断是否需要更新
String compositeKey = data.getClientId() + "|" + name;
if (existingNameMap.containsKey(compositeKey)) {
AllInterfaceName existingRecord = existingNameMap.get(compositeKey);
if (isRecordChanged(existingRecord, record)) {
record.setId(existingRecord.getId()); // 保留原ID
namesToUpdate.add(record);
if (!existingNames.isEmpty()) {
for (AllInterfaceName existingName : existingNames) {
if(isRecordChanged(existingName,record)){
record.setId(existingName.getId()); // 保留原ID
// 检查是否已经存在于更新列表中
boolean alreadyInUpdateList = namesToUpdate.stream()
.anyMatch(item -> item.getId() != null && item.getId().equals(existingName.getId()));
if (!alreadyInUpdateList) {
namesToUpdate.add(record);
}
}
}
} else {
namesToInsert.add(record);
// 检查namesToInsert中是否已有相同记录
boolean alreadyInInsertList = namesToInsert.stream()
.anyMatch(item -> item.getInterfaceName().equals(name)
&& item.getClientId().equals(clientId)
&& item.getSwitchIp().equals(ip));
if (!alreadyInInsertList) {
namesToInsert.add(record);
}
}
});
// 批量操作数据库
if (!namesToInsert.isEmpty()) {
allInterfaceNameMapper.batchInsert(namesToInsert);
log.info("新增接口名称数量:{}", namesToInsert.size());
try {
allInterfaceNameMapper.batchInsert(namesToInsert);
log.info("新增接口名称数量:{}", namesToInsert.size());
} catch (DuplicateKeyException e) {
// 如果批量插入出现重复,转为逐条插入(带异常处理)
log.warn("批量插入出现重复,转为逐条处理");
namesToInsert.forEach(record -> {
try {
allInterfaceNameMapper.insertAllInterfaceName(record);
} catch (DuplicateKeyException ex) {
// 重复记录转为更新
AllInterfaceName query = new AllInterfaceName();
query.setInterfaceName(record.getInterfaceName());
query.setClientId(record.getClientId());
query.setServerIp(record.getServerIp());
List<AllInterfaceName> existing = allInterfaceNameMapper.selectByNames(query);
if (!existing.isEmpty()) {
record.setId(existing.get(0).getId());
allInterfaceNameMapper.updateAllInterfaceName(record);
}
}
});
}
}
if (!namesToUpdate.isEmpty()) {
@@ -267,8 +293,7 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
// 辅助方法:检查记录是否有变化
private boolean isRecordChanged(AllInterfaceName oldRecord, AllInterfaceName newRecord) {
return !Objects.equals(oldRecord.getClientId(), newRecord.getClientId()) ||
!Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
return !Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
!Objects.equals(oldRecord.getNodeName(), newRecord.getNodeName()) ||
!Objects.equals(oldRecord.getServerPort(), newRecord.getServerPort()) ||
!Objects.equals(oldRecord.getInterfaceDeviceType(), newRecord.getInterfaceDeviceType()) ||

View File

@@ -2,9 +2,13 @@ package com.ruoyi.system.service.impl;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.domain.EpsNodeBandwidth;
import com.ruoyi.system.domain.EpsServerRevenueConfig;
import com.ruoyi.system.domain.RmEpsTopologyManagement;
import com.ruoyi.system.domain.RmResourceRegistration;
import com.ruoyi.system.mapper.EpsNodeBandwidthMapper;
import com.ruoyi.system.mapper.EpsServerRevenueConfigMapper;
import com.ruoyi.system.mapper.RmEpsTopologyManagementMapper;
import com.ruoyi.system.mapper.RmResourceRegistrationMapper;
import com.ruoyi.system.service.IRmResourceRegistrationService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +30,10 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
private RmResourceRegistrationMapper rmResourceRegistrationMapper;
@Autowired
private EpsServerRevenueConfigMapper epsServerRevenueConfigMapper;
@Autowired
private RmEpsTopologyManagementMapper rmEpsTopologyManagementMapper;
@Autowired
private EpsNodeBandwidthMapper epsNodeBandwidthMapper;
/**
* 查询资源注册
@@ -84,12 +92,34 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
rmResourceRegistration.setUpdateTime(DateUtils.getNowDate());
rmResourceRegistration.setUpdaterId(SecurityUtils.getUserId());
rmResourceRegistration.setUpdaterName(SecurityUtils.getUsername());
// 拿到需要修改的id
Long id = rmResourceRegistration.getId();
// 根据id查询sn信息
RmResourceRegistration resourceRegistration = rmResourceRegistrationMapper.selectRmResourceRegistrationById(id);
// sn
String hardwareSn = resourceRegistration.getHardwareSn();
// 如果资源名称有修改,同步修改其他表的资源名称
if (!resourceRegistration.getResourceName().equals(rmResourceRegistration.getResourceName())){
// 拓扑管理配置
RmEpsTopologyManagement rmEpsTopologyManagement = new RmEpsTopologyManagement();
rmEpsTopologyManagement.setServerSn(hardwareSn);
rmEpsTopologyManagement.setServerName(rmResourceRegistration.getResourceName());
rmEpsTopologyManagementMapper.updateRmEpsTopologyManagementByServerSn(rmEpsTopologyManagement);
// 服务器收益配置表
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
epsServerRevenueConfig.setHardwareSn(hardwareSn);
epsServerRevenueConfig.setNodeName(rmResourceRegistration.getResourceName());
epsServerRevenueConfigMapper.updateEpsServerRevenueConfigByServerSn(epsServerRevenueConfig);
// 95收益信息表
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
epsNodeBandwidth.setHardwareSn(hardwareSn);
epsNodeBandwidth.setNodeName(rmResourceRegistration.getResourceName());
epsNodeBandwidthMapper.updateEpsNodeBandwidthByServerSn(epsNodeBandwidth);
}
// 禁止修改sn序列号
rmResourceRegistration.setHardwareSn(null);
// 已注册状态修改--仅可修改资源名称,描述
if ("1".equals(rmResourceRegistration.getRegistrationStatus())){
// 拿到需要修改的id
Long id = rmResourceRegistration.getId();
// 拿到需要修改的资源名称
String resourceName = rmResourceRegistration.getResourceName();
// 拿到需要修改的描述

View File

@@ -148,12 +148,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
server_ip AS serverIp
FROM
all_interface_name
WHERE
client_id = #{clientId} and
interface_name IN
<foreach collection="interfaceNames" item="name" open="(" separator="," close=")">
#{name}
</foreach>
<where>
<if test="clientId != null and clientId != ''"> and client_id = #{clientId}</if>
<if test="interfaceName != null and interfaceName != ''"> and interface_name = #{interfaceName}</if>
<if test="deviceSn != null and deviceSn != ''"> and device_sn = #{deviceSn}</if>
<if test="nodeName != null and nodeName != ''"> and node_name = #{nodeName}</if>
<if test="businessCode != null and businessCode != ''"> and business_code = #{businessCode}</if>
<if test="resourceType != null and resourceType != ''"> and resource_type = #{resourceType}</if>
<if test="switchName != null and switchName != ''"> and switch_name = #{switchName}</if>
<if test="interfaceDeviceType != null and interfaceDeviceType != ''"> and interface_device_type = #{interfaceDeviceType}</if>
<if test="serverPort != null and serverPort != ''"> and server_port = #{serverPort}</if>
<if test="switchSn != null and switchSn != ''"> and switch_sn = #{switchSn}</if>
<if test="switchIp != null and switchIp != ''"> and switch_ip = #{switchIp}</if>
<if test="serverIp != null and serverIp != ''"> and server_ip = #{serverIp}</if>
</where>
</select>
<!-- 批量插入接口名称 -->

View File

@@ -32,10 +32,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="businessName" column="business_name" />
<result property="businessId" column="business_id" />
<result property="remark1" column="remark1" />
<result property="createDatetime" column="create_datetime" />
</resultMap>
<sql id="selectEpsNodeBandwidthVo">
select id, node_name, hardware_sn, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id, remark1 from eps_node_bandwidth
select id, node_name, hardware_sn, bandwidth_type, bandwidth_result, bandwidth_95_daily, bandwidth_95_monthly, avg_monthly_bandwidth_95, package_bandwidth_daily, customer_id, customer_name, service_number, uplink_switch, create_time, update_time, creator_id, creator_name, switch_sn, interface_name, resource_type, interface_link_device_type, effective_bandwidth_95_daily, effective_bandwidth_95_monthly, effective_avg_monthly_bandwidth_95, business_name, business_id, remark1, create_datetime from eps_node_bandwidth
</sql>
<select id="selectEpsNodeBandwidthList" parameterType="EpsNodeBandwidth" resultMap="EpsNodeBandwidthResult">
@@ -80,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</if>
</where>
<if test="createDatetime != null "> and create_datetime = #{createDatetime}</if>
</select>
<select id="selectEpsNodeBandwidthById" parameterType="Long" resultMap="EpsNodeBandwidthResult">
@@ -116,6 +118,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessName != null">business_name,</if>
<if test="businessId != null">business_id,</if>
<if test="remark1 != null">remark1,</if>
create_datetime,
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="nodeName != null">#{nodeName},</if>
@@ -144,6 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessName != null">#{businessName},</if>
<if test="businessId != null">#{businessId},</if>
<if test="remark1 != null">#{remark1},</if>
NOW(),
</trim>
</insert>
@@ -176,9 +180,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="businessName != null">business_name = #{businessName},</if>
<if test="businessId != null">business_id = #{businessId},</if>
<if test="remark1 != null">remark1 = #{remark1},</if>
<if test="createDatetime != null">create_datetime = #{createDatetime},</if>
</trim>
where id = #{id}
</update>
<update id="updateEpsNodeBandwidthByServerSn" parameterType="EpsNodeBandwidth">
update eps_node_bandwidth
<trim prefix="SET" suffixOverrides=",">
<if test="nodeName != null">node_name = #{nodeName},</if>
</trim>
where hardware_sn = #{hardwareSn}
</update>
<delete id="deleteEpsNodeBandwidthById" parameterType="Long">
delete from eps_node_bandwidth where id = #{id}

View File

@@ -110,6 +110,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="updateEpsServerRevenueConfigByServerSn" parameterType="EpsServerRevenueConfig">
update eps_server_revenue_config
<trim prefix="SET" suffixOverrides=",">
<if test="nodeName != null">node_name = #{nodeName},</if>
</trim>
where hardware_sn = #{hardwareSn}
</update>
<delete id="deleteEpsServerRevenueConfigById" parameterType="Long">
delete from eps_server_revenue_config where id = #{id}

View File

@@ -105,6 +105,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update id="updateRmEpsTopologyManagementByServerSn" parameterType="RmEpsTopologyManagement">
update rm_eps_topology_management
<trim prefix="SET" suffixOverrides=",">
<if test="serverName != null">`server_name` = #{serverName},</if>
</trim>
where server_sn = #{serverSn}
</update>
<delete id="deleteRmEpsTopologyManagementById" parameterType="Long">
delete from rm_eps_topology_management where id = #{id}