单网卡总流量、ipv4流量、ipv6流量合并到一个图
pppoe状态上报增加
This commit is contained in:
+2
@@ -17,6 +17,8 @@ public enum MsgEnum {
|
||||
|
||||
修改frp配置文件应答("UPDATE_FRP_RSP"),
|
||||
|
||||
macvlan状态上报("MACVLAN_STATUS_RSP"),
|
||||
|
||||
获取最新策略("GET_POLICY"),
|
||||
|
||||
获取最新策略应答("GET_POLICY_RSP"),
|
||||
|
||||
+7
@@ -92,4 +92,11 @@ public interface AllInterfaceNameMapper
|
||||
* @param records
|
||||
*/
|
||||
void batchUpdate(List<AllInterfaceName> records);
|
||||
|
||||
/**
|
||||
* 查询该服务器是否有子网卡
|
||||
* @param allInterfaceName
|
||||
* @return
|
||||
*/
|
||||
Integer countNetChild(AllInterfaceName allInterfaceName);
|
||||
}
|
||||
|
||||
+8
-2
@@ -93,7 +93,12 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
|
||||
|
||||
// 只设置服务器类型的businessFlag
|
||||
if ("1".equals(interfaceName.getResourceType())) {
|
||||
interfaceName.setBusinessFlag(isMatched);
|
||||
int count = allInterfaceNameMapper.countNetChild(interfaceName);
|
||||
boolean hasSub = false;
|
||||
if(count > 0){
|
||||
hasSub = true;
|
||||
}
|
||||
interfaceName.setBusinessFlag(isMatched && hasSub);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +138,13 @@ public class AllInterfaceNameServiceImpl implements IAllInterfaceNameService
|
||||
}
|
||||
|
||||
List<RmNetworkInterfaceRemote> interfaceRemoteList = netWorkListR.getData();
|
||||
return interfaceRemoteList.stream()
|
||||
boolean isBusiness = interfaceRemoteList.stream()
|
||||
.filter(info -> "1".equals(info.getBindIp()) || "3".equals(info.getBindIp()))
|
||||
.anyMatch(internet ->
|
||||
interfaceName.getServerIp() != null && internet.getMacAddress() != null &&
|
||||
interfaceName.getServerIp().equalsIgnoreCase(internet.getMacAddress())
|
||||
);
|
||||
return isBusiness;
|
||||
|
||||
} else if ("2".equals(resourceType)) {
|
||||
// 交换机类型匹配逻辑
|
||||
|
||||
-1
@@ -532,7 +532,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
}
|
||||
if(memUtilList != null && !memUtilList.isEmpty()){
|
||||
registration.setMemUtil(memUtilList.get(0).getMemUtil());
|
||||
registration.setMemTotalSize(memUtilList.get(0).getMemTotalSize());
|
||||
}
|
||||
if(rmResourceRegistration != null){
|
||||
registration.setMaxAgentVersion(rmResourceRegistration.getMaxAgentVersion());
|
||||
|
||||
+5
@@ -313,4 +313,9 @@
|
||||
WHERE id = #{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="countNetChild" parameterType="AllInterfaceName" resultType="java.lang.Integer">
|
||||
select count(1) from rm_network_interface_child
|
||||
where client_id = #{clientId} and parent_interface = SUBSTRING_INDEX(#{interfaceName}, '(', 1)
|
||||
</select>
|
||||
</mapper>
|
||||
+4
-5
@@ -314,17 +314,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND d.create_time = latest.latest_time
|
||||
</select>
|
||||
<select id="getMemUtil" resultType="RmResourceRegistration">
|
||||
select
|
||||
SELECT
|
||||
d.client_id as clientId,
|
||||
max(CASE WHEN d.collect_type = 'memorySizeTotalCollect' THEN floor(d.collect_value/(1024 * 1024)) END) as memTotalSize,
|
||||
max(CASE WHEN d.collect_type = 'memoryUtilizationCollect' THEN ROUND(d.collect_value, 1) END) as memUtil
|
||||
ROUND(d.collect_value, 1) as memUtil
|
||||
FROM initial_system_other_collect_data d
|
||||
INNER JOIN (
|
||||
SELECT
|
||||
client_id,
|
||||
MAX(create_time) as max_time
|
||||
FROM initial_system_other_collect_data
|
||||
WHERE (collect_type='memoryUtilizationCollect' or collect_type='memorySizeTotalCollect')
|
||||
WHERE collect_type='memoryUtilizationCollect'
|
||||
AND client_id in
|
||||
<foreach collection="clientIdsStr.split(',')" item="clientId" open="(" separator="," close=")">
|
||||
#{clientId}
|
||||
@@ -332,7 +331,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
GROUP BY client_id
|
||||
) latest ON d.client_id = latest.client_id
|
||||
AND d.create_time = latest.max_time
|
||||
AND (d.collect_type='memoryUtilizationCollect' or d.collect_type='memorySizeTotalCollect')
|
||||
AND d.collect_type='memoryUtilizationCollect'
|
||||
</select>
|
||||
<update id="removeAlarmFlag" parameterType="RmResourceRegistration">
|
||||
update rm_resource_registration set del_alarm_time = now()
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.tongran.common.core.web.domain.BaseEntity;
|
||||
import com.tongran.rocketmq.domain.vo.RmPppoeConfigSubVo;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* PPPoE配置子表对象 rm_pppoe_config_sub
|
||||
*
|
||||
@@ -19,10 +21,6 @@ public class RmPppoeConfigSub extends BaseEntity
|
||||
/** 主键ID */
|
||||
private Long id;
|
||||
|
||||
/** 主表ID */
|
||||
@Excel(name = "主表ID")
|
||||
private Long mainId;
|
||||
|
||||
/** 序号 */
|
||||
@Excel(name = "序号")
|
||||
private Long serialNumber;
|
||||
@@ -42,6 +40,14 @@ public class RmPppoeConfigSub extends BaseEntity
|
||||
/** IPv4网关 */
|
||||
@Excel(name = "IPv4网关")
|
||||
private String ipv4Gateway;
|
||||
/** 状态(0未连通,1连通) */
|
||||
private String status;
|
||||
/** 上报带宽 */
|
||||
private BigDecimal bandwidthResult;
|
||||
/** MAC地址 */
|
||||
private String macAddress;
|
||||
/** 客户端id */
|
||||
private String clientId;
|
||||
|
||||
public RmPppoeConfigSubVo toVo() {
|
||||
RmPppoeConfigSubVo vo = new RmPppoeConfigSubVo();
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.tongran.rocketmq.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MacVlanRspVo {
|
||||
@JsonProperty("clientId")
|
||||
private String clientId;
|
||||
|
||||
@JsonProperty("macVlans")
|
||||
private List<MacVlanVo> macVlans;
|
||||
|
||||
@JsonProperty("timestamp")
|
||||
private long timestamp;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class MacVlanVo {
|
||||
/** 虚拟网卡id */
|
||||
private String vlanId;
|
||||
|
||||
/** 编号 */
|
||||
private String mid;
|
||||
|
||||
/** 状态 */
|
||||
private String status;
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,8 @@ public class MessageHandler {
|
||||
private IRmAlarmPushConfigService rmAlarmPushConfigService;
|
||||
@Autowired
|
||||
private IRmFrpcConfigManageService rmFrpcConfigManageService;
|
||||
@Autowired
|
||||
private IRmPppoeConfigSubService rmPppoeConfigSubService;
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,6 +126,28 @@ public class MessageHandler {
|
||||
registerHandler(MsgEnum.心跳上报.getValue(), this::handleHeartbeatMessage);
|
||||
registerHandler(MsgEnum.多公网IP探测.getValue(), this::handleNetWorkDelectMessage);
|
||||
registerHandler(MsgEnum.修改frp配置文件应答.getValue(), this::handleUpdateFrpMessage);
|
||||
registerHandler(MsgEnum.macvlan状态上报.getValue(), this::handleMacvlanMessage);
|
||||
}
|
||||
|
||||
private void handleMacvlanMessage(DeviceMessage message) {
|
||||
List<MacVlanRspVo> macVlanRspVoList = JsonDataParser.parseJsonData(message.getData(), MacVlanRspVo.class);
|
||||
if(!macVlanRspVoList.isEmpty()){
|
||||
MacVlanRspVo macVlanRspVo = macVlanRspVoList.get(0);
|
||||
// 时间戳转换
|
||||
long timestamp = macVlanRspVo.getTimestamp();
|
||||
long millis = timestamp * 1000;
|
||||
Date createTime = new Date(millis / 1000 * 1000); // 去除毫秒
|
||||
List<MacVlanRspVo.MacVlanVo> list = macVlanRspVo.getMacVlans();
|
||||
for (MacVlanRspVo.MacVlanVo macVlanVo : list) {
|
||||
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
|
||||
rmPppoeConfigSub.setVlanId(Long.valueOf(macVlanVo.getVlanId()));
|
||||
rmPppoeConfigSub.setSerialNumber(Long.valueOf(macVlanVo.getMid()));
|
||||
rmPppoeConfigSub.setClientId(message.getClientId());
|
||||
rmPppoeConfigSub.setStatus(macVlanVo.getStatus());
|
||||
rmPppoeConfigSub.setUpdateTime(createTime);
|
||||
rmPppoeConfigSubService.updateRmPppoeConfigSubByVlan(rmPppoeConfigSub);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleUpdateFrpMessage(DeviceMessage message) {
|
||||
@@ -1143,6 +1167,7 @@ public class MessageHandler {
|
||||
}
|
||||
rmNetworkInterfaceService.insertRmNetworkInterface(insertData);
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
rmNetworkInterfaceChildService.deleteRmNetworkInterfaceChildByClientId(clientId);
|
||||
for (NetworkInfo info : childList) {
|
||||
RmNetworkInterfaceChild insertChild = new RmNetworkInterfaceChild();
|
||||
setNetworkInterfaceChildData(insertChild, info, clientId, networkInfo.getName());
|
||||
@@ -1168,6 +1193,7 @@ public class MessageHandler {
|
||||
boolean needCreateNew = (!StringUtils.equals(networkInfo.getName(), oldInterfaceMsg.getInterfaceName())
|
||||
|| !StringUtils.equals(networkInfo.getGateway(), oldInterfaceMsg.getGateway())) && StringUtils.equals(networkInfo.getMac(), oldInterfaceMsg.getMacAddress());
|
||||
if(childList != null && !childList.isEmpty()){
|
||||
rmNetworkInterfaceChildService.deleteRmNetworkInterfaceChildByClientId(clientId);
|
||||
for (NetworkInfo info : childList) {
|
||||
RmNetworkInterfaceChild insertChild = new RmNetworkInterfaceChild();
|
||||
setNetworkInterfaceChildData(insertChild, info, clientId, networkInfo.getName());
|
||||
|
||||
+4
-1
@@ -1,8 +1,9 @@
|
||||
package com.tongran.rocketmq.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Mapper接口
|
||||
*
|
||||
@@ -58,4 +59,6 @@ public interface RmNetworkInterfaceChildMapper
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildByIds(Long[] ids);
|
||||
|
||||
void deleteRmNetworkInterfaceChildByClientId(String clientId);
|
||||
}
|
||||
|
||||
+5
-3
@@ -68,9 +68,11 @@ public interface RmPppoeConfigSubMapper
|
||||
int batchInsertRmPppoeConfigSub(List<RmPppoeConfigSub> subList);
|
||||
|
||||
/**
|
||||
* 根据主表id删除子表信息
|
||||
* @param mainId
|
||||
* 根据clientId删除子表信息
|
||||
* @param clientId
|
||||
* @return
|
||||
*/
|
||||
int deleteRmPppoeConfigSubByMainId(Long mainId);
|
||||
int deleteRmPppoeConfigSubByClientId(String clientId);
|
||||
|
||||
int updateRmPppoeConfigSubByVlan(RmPppoeConfigSub rmPppoeConfigSub);
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,8 +1,9 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Service接口
|
||||
*
|
||||
@@ -58,4 +59,6 @@ public interface IRmNetworkInterfaceChildService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmNetworkInterfaceChildById(Long id);
|
||||
|
||||
void deleteRmNetworkInterfaceChildByClientId(String clientId);
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,8 +1,9 @@
|
||||
package com.tongran.rocketmq.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PPPoE配置子表Service接口
|
||||
*
|
||||
@@ -58,4 +59,6 @@ public interface IRmPppoeConfigSubService
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteRmPppoeConfigSubById(Long id);
|
||||
|
||||
int updateRmPppoeConfigSubByVlan(RmPppoeConfigSub rmPppoeConfigSub);
|
||||
}
|
||||
|
||||
+79
-1
@@ -251,6 +251,8 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
showRealation.put(name+"netInTraffic", name+"入站流量");
|
||||
showRealation.put(name+"netOutTraffic", name+"出站流量");
|
||||
boolean hasSubInterface = false;
|
||||
boolean needAddIpv4Ipv6 = false; // 标记是否需要添加IPv4和IPv6数据
|
||||
|
||||
// 如果是Ethernet类型,查询子网卡
|
||||
if(isEthernetInterface(name)){
|
||||
RmNetworkInterfaceChild query = new RmNetworkInterfaceChild();
|
||||
@@ -271,6 +273,13 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
showRealation.put(child.getInterfaceName()+"netOutTraffic", child.getInterfaceName()+"出站流量");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 将ipv4和ipv6的线也集合过来 - 只有在没有子网卡时才添加
|
||||
needAddIpv4Ipv6 = true;
|
||||
showRealation.put(name+"netInTrafficIPv4", name+"IPv4入站流量");
|
||||
showRealation.put(name+"netOutTrafficIPv4", name+"IPv4出站流量");
|
||||
showRealation.put(name+"netInTrafficIPv6", name+"IPv6入站流量");
|
||||
showRealation.put(name+"netOutTrafficIPv6", name+"IPv6出站流量");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +291,7 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
}
|
||||
BigDecimal divisor = SpeedUtils.getDivisor(unit);
|
||||
|
||||
// 使用工具类构建多网卡图表数据
|
||||
// 获取总流量图表数据
|
||||
Map<String, Object> resultMap = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
@@ -294,10 +303,79 @@ public class InitialBandwidthTrafficServiceImpl implements IInitialBandwidthTraf
|
||||
);
|
||||
|
||||
resultMap.put("unit", unit);
|
||||
|
||||
// 如果没有子网卡,添加IPv4和IPv6的数据
|
||||
if (needAddIpv4Ipv6) {
|
||||
// 获取总流量yData
|
||||
Map<String, Object> yData = (Map<String, Object>) resultMap.get("yData");
|
||||
List<String> xAxisData = (List<String>) resultMap.get("xData");
|
||||
|
||||
// 获取IPv4流量图表数据
|
||||
Map<String, Object> ipv4Result = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
info -> info != null && info.getIpv4InSpeed() != null ?
|
||||
new BigDecimal(info.getIpv4InSpeed()) : null,
|
||||
info -> info != null && info.getIpv4OutSpeed() != null ?
|
||||
new BigDecimal(info.getIpv4OutSpeed()) : null,
|
||||
initialBandwidthTraffic.getStartTime(),
|
||||
initialBandwidthTraffic.getEndTime(),
|
||||
divisor
|
||||
);
|
||||
|
||||
// 获取IPv6流量图表数据
|
||||
Map<String, Object> ipv6Result = EchartsMoreDataUtils.buildMultiInterfaceEchartsDataWithTotal(
|
||||
interfaceDataMap,
|
||||
InitialBandwidthTraffic::getCreateTime,
|
||||
info -> info != null && info.getIpv6InSpeed() != null ?
|
||||
new BigDecimal(info.getIpv6InSpeed()) : null,
|
||||
info -> info != null && info.getIpv6OutSpeed() != null ?
|
||||
new BigDecimal(info.getIpv6OutSpeed()) : null,
|
||||
initialBandwidthTraffic.getStartTime(),
|
||||
initialBandwidthTraffic.getEndTime(),
|
||||
divisor
|
||||
);
|
||||
|
||||
// 合并IPv4的yData
|
||||
Map<String, Object> ipv4YData = (Map<String, Object>) ipv4Result.get("yData");
|
||||
for (Map.Entry<String, Object> entry : ipv4YData.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
||||
// 重命名key,添加IPv4后缀
|
||||
String newKey = key;
|
||||
if (key.endsWith("netInTraffic")) {
|
||||
newKey = key.replace("netInTraffic", "netInTrafficIPv4");
|
||||
} else if (key.endsWith("netOutTraffic")) {
|
||||
newKey = key.replace("netOutTraffic", "netOutTrafficIPv4");
|
||||
}
|
||||
yData.put(newKey, value);
|
||||
}
|
||||
|
||||
// 合并IPv6的yData
|
||||
Map<String, Object> ipv6YData = (Map<String, Object>) ipv6Result.get("yData");
|
||||
for (Map.Entry<String, Object> entry : ipv6YData.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
|
||||
// 重命名key,添加IPv6后缀
|
||||
String newKey = key;
|
||||
if (key.endsWith("netInTraffic")) {
|
||||
newKey = key.replace("netInTraffic", "netInTrafficIPv6");
|
||||
} else if (key.endsWith("netOutTraffic")) {
|
||||
newKey = key.replace("netOutTraffic", "netOutTrafficIPv6");
|
||||
}
|
||||
yData.put(newKey, value);
|
||||
}
|
||||
|
||||
resultMap.put("yData", yData);
|
||||
}
|
||||
|
||||
if(!showRealation.isEmpty() && hasSubInterface){
|
||||
showRealation.put("totalNetInTraffic", name+"总入站流量");
|
||||
showRealation.put("totalNetOutTraffic", name+"总出站流量");
|
||||
}
|
||||
|
||||
Map<String, String> sortedShowRealation = EchartsMoreDataUtils.sortInterfaceMap(showRealation, name, hasSubInterface);
|
||||
resultMap.put("showRealation", sortedShowRealation);
|
||||
return resultMap;
|
||||
|
||||
+10
-4
@@ -1,12 +1,13 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.service.IRmNetworkInterfaceChildService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.tongran.rocketmq.mapper.RmNetworkInterfaceChildMapper;
|
||||
import com.tongran.rocketmq.domain.RmNetworkInterfaceChild;
|
||||
import com.tongran.rocketmq.service.IRmNetworkInterfaceChildService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户端网络接口子接口信息Service业务层处理
|
||||
@@ -93,4 +94,9 @@ public class RmNetworkInterfaceChildServiceImpl implements IRmNetworkInterfaceCh
|
||||
{
|
||||
return rmNetworkInterfaceChildMapper.deleteRmNetworkInterfaceChildById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteRmNetworkInterfaceChildByClientId(String clientId) {
|
||||
rmNetworkInterfaceChildMapper.deleteRmNetworkInterfaceChildByClientId(clientId);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -49,7 +49,7 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
RmPppoeConfigMain rmPppoeConfigMain = rmPppoeConfigMainMapper.selectRmPppoeConfigMainById(id);
|
||||
// 查询子表信息
|
||||
RmPppoeConfigSub rmPppoeConfigSub = new RmPppoeConfigSub();
|
||||
rmPppoeConfigSub.setMainId(id);
|
||||
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
|
||||
List<RmPppoeConfigSub> subList = rmPppoeConfigSubMapper.selectRmPppoeConfigSubList(rmPppoeConfigSub);
|
||||
rmPppoeConfigMain.setSubList(subList);
|
||||
return rmPppoeConfigMain;
|
||||
@@ -81,12 +81,12 @@ public class RmPppoeConfigMainServiceImpl implements IRmPppoeConfigMainService
|
||||
List<RmPppoeConfigSub> subList = rmPppoeConfigMain.getSubList();
|
||||
if(subList != null && !subList.isEmpty()){
|
||||
for (RmPppoeConfigSub rmPppoeConfigSub : subList) {
|
||||
rmPppoeConfigSub.setMainId(rmPppoeConfigMain.getId());
|
||||
rmPppoeConfigSub.setClientId(rmPppoeConfigMain.getClientId());
|
||||
rmPppoeConfigSub.setCreateTime(DateUtils.getNowDate());
|
||||
rmPppoeConfigSub.setUpdateTime(DateUtils.getNowDate());
|
||||
}
|
||||
// 删除子表信息
|
||||
rmPppoeConfigSubMapper.deleteRmPppoeConfigSubByMainId(rmPppoeConfigMain.getId());
|
||||
rmPppoeConfigSubMapper.deleteRmPppoeConfigSubByClientId(rmPppoeConfigMain.getClientId());
|
||||
// 批量新增
|
||||
rmPppoeConfigSubMapper.batchInsertRmPppoeConfigSub(subList);
|
||||
}
|
||||
|
||||
+10
-4
@@ -1,12 +1,13 @@
|
||||
package com.tongran.rocketmq.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.tongran.common.core.utils.DateUtils;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
import com.tongran.rocketmq.mapper.RmPppoeConfigSubMapper;
|
||||
import com.tongran.rocketmq.service.IRmPppoeConfigSubService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.tongran.rocketmq.mapper.RmPppoeConfigSubMapper;
|
||||
import com.tongran.rocketmq.domain.RmPppoeConfigSub;
|
||||
import com.tongran.rocketmq.service.IRmPppoeConfigSubService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* PPPoE配置子表Service业务层处理
|
||||
@@ -93,4 +94,9 @@ public class RmPppoeConfigSubServiceImpl implements IRmPppoeConfigSubService
|
||||
{
|
||||
return rmPppoeConfigSubMapper.deleteRmPppoeConfigSubById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRmPppoeConfigSubByVlan(RmPppoeConfigSub rmPppoeConfigSub) {
|
||||
return rmPppoeConfigSubMapper.updateRmPppoeConfigSubByVlan(rmPppoeConfigSub);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,4 +146,7 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
<delete id="deleteRmNetworkInterfaceChildByClientId" parameterType="String">
|
||||
delete from rm_network_interface_child where client_id = #{clientId}
|
||||
</delete>
|
||||
</mapper>
|
||||
@@ -58,13 +58,21 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
</trim>
|
||||
ON DUPLICATE KEY UPDATE
|
||||
<trim suffixOverrides=",">
|
||||
<if test="pppoeEnabled != null">pppoe_enabled = VALUES(pppoe_enabled),</if>
|
||||
<if test="pppoeConfigMode != null">pppoe_config_mode = VALUES(pppoe_config_mode),</if>
|
||||
<if test="pppoeInterface != null">pppoe_interface = VALUES(pppoe_interface),</if>
|
||||
<if test="updateTime != null">update_time = VALUES(update_time),</if>
|
||||
<if test="updateBy != null">update_by = VALUES(update_by),</if>
|
||||
</trim>
|
||||
pppoe_enabled = CASE
|
||||
WHEN pppoe_enabled = VALUES(pppoe_enabled) THEN pppoe_enabled
|
||||
WHEN VALUES(pppoe_enabled) IS NULL THEN pppoe_enabled
|
||||
ELSE VALUES(pppoe_enabled)
|
||||
END,
|
||||
pppoe_config_mode = CASE
|
||||
WHEN pppoe_config_mode = VALUES(pppoe_config_mode) THEN pppoe_config_mode
|
||||
WHEN VALUES(pppoe_config_mode) IS NULL THEN pppoe_config_mode
|
||||
ELSE VALUES(pppoe_config_mode)
|
||||
END,
|
||||
pppoe_interface = CASE
|
||||
WHEN pppoe_interface = VALUES(pppoe_interface) THEN pppoe_interface
|
||||
WHEN VALUES(pppoe_interface) IS NULL THEN pppoe_interface
|
||||
ELSE VALUES(pppoe_interface)
|
||||
END
|
||||
</insert>
|
||||
|
||||
<update id="updateRmPppoeConfigMain" parameterType="RmPppoeConfigMain">
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.tongran.rocketmq.mapper.RmPppoeConfigSubMapper">
|
||||
|
||||
|
||||
<resultMap type="RmPppoeConfigSub" id="RmPppoeConfigSubResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="mainId" column="main_id" />
|
||||
<result property="clientId" column="client_id" />
|
||||
<result property="serialNumber" column="serial_number" />
|
||||
<result property="vlanId" column="vlan_id" />
|
||||
<result property="ipv4Address" column="ipv4_address" />
|
||||
@@ -16,24 +16,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="status" column="status" />
|
||||
<result property="macAddress" column="mac_address" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRmPppoeConfigSubVo">
|
||||
select id, main_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, create_time, update_time, create_by, update_by from rm_pppoe_config_sub
|
||||
select id, client_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, create_time, update_time, create_by, update_by, status from rm_pppoe_config_sub
|
||||
</sql>
|
||||
|
||||
<select id="selectRmPppoeConfigSubList" parameterType="RmPppoeConfigSub" resultMap="RmPppoeConfigSubResult">
|
||||
<include refid="selectRmPppoeConfigSubVo"/>
|
||||
<where>
|
||||
<if test="mainId != null "> and main_id = #{mainId}</if>
|
||||
<if test="serialNumber != null "> and serial_number = #{serialNumber}</if>
|
||||
<if test="vlanId != null "> and vlan_id = #{vlanId}</if>
|
||||
<if test="ipv4Address != null and ipv4Address != ''"> and ipv4_address = #{ipv4Address}</if>
|
||||
<if test="ipv4MaskBits != null "> and ipv4_mask_bits = #{ipv4MaskBits}</if>
|
||||
<if test="ipv4Gateway != null and ipv4Gateway != ''"> and ipv4_gateway = #{ipv4Gateway}</if>
|
||||
SELECT
|
||||
a.id,
|
||||
a.client_id,
|
||||
a.serial_number,
|
||||
a.vlan_id,
|
||||
a.ipv4_address,
|
||||
a.ipv4_mask_bits,
|
||||
a.ipv4_gateway,
|
||||
a.create_time,
|
||||
a.update_time,
|
||||
a.create_by,
|
||||
a.update_by,
|
||||
a.status,
|
||||
b.mac_address
|
||||
FROM
|
||||
rm_pppoe_config_sub a
|
||||
LEFT JOIN
|
||||
rm_network_interface_child b
|
||||
ON a.client_id = b.client_id
|
||||
AND a.ipv4_address = b.ipv4_address
|
||||
<where>
|
||||
<if test="clientId != null and clientId != ''"> and a.client_id = #{clientId}</if>
|
||||
<if test="serialNumber != null "> and a.serial_number = #{serialNumber}</if>
|
||||
<if test="vlanId != null "> and a.vlan_id = #{vlanId}</if>
|
||||
<if test="ipv4Address != null and ipv4Address != ''"> and a.ipv4_address = #{ipv4Address}</if>
|
||||
<if test="ipv4MaskBits != null "> and a.ipv4_mask_bits = #{ipv4MaskBits}</if>
|
||||
<if test="ipv4Gateway != null and ipv4Gateway != ''"> and a.ipv4_gateway = #{ipv4Gateway}</if>
|
||||
<if test="status != null and status != ''"> and a.status = #{status}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectRmPppoeConfigSubById" parameterType="Long" resultMap="RmPppoeConfigSubResult">
|
||||
<include refid="selectRmPppoeConfigSubVo"/>
|
||||
where id = #{id}
|
||||
@@ -42,7 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<insert id="insertRmPppoeConfigSub" parameterType="RmPppoeConfigSub" useGeneratedKeys="true" keyProperty="id">
|
||||
insert into rm_pppoe_config_sub
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="mainId != null">main_id,</if>
|
||||
<if test="clientId != null">client_id,</if>
|
||||
<if test="serialNumber != null">serial_number,</if>
|
||||
<if test="vlanId != null">vlan_id,</if>
|
||||
<if test="ipv4Address != null">ipv4_address,</if>
|
||||
@@ -52,9 +74,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
</trim>
|
||||
<if test="status != null">status,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="mainId != null">#{mainId},</if>
|
||||
<if test="clientId != null">#{clientId},</if>
|
||||
<if test="serialNumber != null">#{serialNumber},</if>
|
||||
<if test="vlanId != null">#{vlanId},</if>
|
||||
<if test="ipv4Address != null">#{ipv4Address},</if>
|
||||
@@ -64,13 +87,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
</trim>
|
||||
<if test="status != null">#{status},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateRmPppoeConfigSub" parameterType="RmPppoeConfigSub">
|
||||
update rm_pppoe_config_sub
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="mainId != null">main_id = #{mainId},</if>
|
||||
<if test="clientId != null">client_id = #{clientId},</if>
|
||||
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||
<if test="vlanId != null">vlan_id = #{vlanId},</if>
|
||||
<if test="ipv4Address != null">ipv4_address = #{ipv4Address},</if>
|
||||
@@ -80,6 +104,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
@@ -96,11 +121,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
<insert id="batchInsertRmPppoeConfigSub" parameterType="java.util.List">
|
||||
insert into rm_pppoe_config_sub
|
||||
(main_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, create_time, update_time, create_by, update_by)
|
||||
(client_id, serial_number, vlan_id, ipv4_address, ipv4_mask_bits, ipv4_gateway, create_time, update_time, create_by, update_by)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.mainId},
|
||||
#{item.clientId},
|
||||
#{item.serialNumber},
|
||||
#{item.vlanId},
|
||||
#{item.ipv4Address},
|
||||
@@ -113,7 +138,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="deleteRmPppoeConfigSubByMainId" parameterType="Long">
|
||||
delete from rm_pppoe_config_sub where main_id = #{mainId}
|
||||
<delete id="deleteRmPppoeConfigSubByClientId" parameterType="String">
|
||||
delete from rm_pppoe_config_sub where client_id = #{clientId}
|
||||
</delete>
|
||||
<update id="updateRmPppoeConfigSubByVlan" parameterType="RmPppoeConfigSub">
|
||||
update rm_pppoe_config_sub
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="status != null">status = #{status},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
<where>
|
||||
<choose>
|
||||
<when test="clientId!=null and vlanId!=null and serialNumber != null">
|
||||
and client_id=#{clientId} and vlan_id=#{vlanId} and serial_number=#{serialNumber}
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1=0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</where>
|
||||
</update>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user