kongdeqiang
2026-04-13 e7d90fd46364afb25c9c0cb9c1a5784f7aac6bf9
推送修改
15个文件已修改
151 ■■■■■ 已修改文件
src/main/java/com/wgcloud/WgcloudServiceApplication.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/controller/MailSetController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/controller/OspfInfoController.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/entity/OspfInfo.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/entity/OspfMonitor.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/OspfInfoService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/task/ScheduledTask.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/util/PingUtil.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/util/msg/WarnMailUtil.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mybatis/mapper/OspfInfoMapper.xml 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mybatis/mapper/OspfMonitorMapper.xml 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/templates/mail/view.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/templates/ospfMonitor/add.html 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/templates/ospfMonitor/list.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/WgcloudServiceApplication.java
@@ -31,7 +31,7 @@
@ServletComponentScan("com.wgcloud.filter")
@ComponentScan(basePackages = "com.wgcloud")
@EnableCaching
//@EnableScheduling
@EnableScheduling
public class WgcloudServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(WgcloudServiceApplication.class, args);
src/main/java/com/wgcloud/controller/MailSetController.java
@@ -118,7 +118,7 @@
                mailSetService.saveLog(request, StaticKeys.LOG_UPDATE, mailSet);
            }
            StaticKeys.mailSet = mailSet;
            result = WarnMailUtil.sendMail(mailSet.getToMail(), "WGCLOUD测试邮件发送", "WGCLOUD测试邮件发送");
            result = WarnMailUtil.sendMail(mailSet.getToMail(), "系统测试邮件发送", "系统测试邮件发送");
        } catch (Exception e) {
            logger.error("测试邮件设置信息错误", e);
            logInfoService.save("测试邮件设置信息错误", e.toString(), StaticKeys.LOG_XTCZ);
src/main/java/com/wgcloud/controller/OspfInfoController.java
@@ -133,12 +133,14 @@
                ospfInfo.setMonitorIp(ospfMonitor.getHostname());
                ospfInfo.setMonitorUsername(ospfMonitor.getUsername());
                ospfInfo.setMonitorPassword(ospfMonitor.getPassword());
                ospfInfo.setMonitorRemoteType(ospfMonitor.getRemoteType());
                OspfInfoService.save(ospfInfo);
            } else {
                OspfMonitor ospfMonitor = ospfMonitorService.selectById(ospfInfo.getMonitorId());
                ospfInfo.setMonitorIp(ospfMonitor.getHostname());
                ospfInfo.setMonitorUsername(ospfMonitor.getUsername());
                ospfInfo.setMonitorPassword(ospfMonitor.getPassword());
                ospfInfo.setMonitorRemoteType(ospfMonitor.getRemoteType());
                OspfInfoService.updateById(ospfInfo);
            }
src/main/java/com/wgcloud/entity/OspfInfo.java
@@ -51,6 +51,7 @@
    private String monitorUsername;
    private String monitorPassword;
    private String monitorRemoteType;
    public String getHostname() {
@@ -62,6 +63,16 @@
        this.hostname = hostname;
    }
    public String getMonitorRemoteType() {
        return monitorRemoteType;
    }
    public void setMonitorRemoteType(String monitorRemoteType) {
        this.monitorRemoteType = monitorRemoteType;
    }
    public String getInfoContent() {
        return infoContent;
src/main/java/com/wgcloud/entity/OspfMonitor.java
@@ -41,13 +41,21 @@
    private String password;
    private String remoteType;
    public String getUsername() {
        return username;
    }
    public String getRemoteType() {
        return remoteType;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    public void setRemoteType(String remoteType) {
        this.remoteType = remoteType;
    }
    public String getPassword() {
        return password;
src/main/java/com/wgcloud/service/OspfInfoService.java
@@ -142,6 +142,11 @@
            map.put("username",ospfInfo.getMonitorUsername());
            map.put("password",ospfInfo.getMonitorPassword());
            map.put("monitorIp",ospfInfo.getMonitorIp());
            if(ospfInfo.getMonitorRemoteType().equals("TELNET")){
                map.put("type","0");
            }else if(ospfInfo.getMonitorRemoteType().equals("SSH")){
                map.put("type","1");
            }
            String str = JSON.toJSONString(map);
            System.out.println(str);
            try {
src/main/java/com/wgcloud/task/ScheduledTask.java
@@ -126,7 +126,7 @@
     * 20秒后执行,之后每6分钟刷新一次
     * 初始化一些任务
     */
    //@Scheduled(initialDelay = 20000L, fixedRate = 6 * 60 * 1000)
    @Scheduled(initialDelay = 20000L, fixedRate = 6 * 60 * 1000)
    public void initTask() {
        logger.info("initTask------------" + DateUtil.getDateTimeString(new Date()));
        try {
@@ -249,7 +249,7 @@
     * 90秒后执行,之后每隔15分钟执行, 单位:ms。
     * 检测数通PING设备
     */
    //@Scheduled(initialDelay = 90000L, fixedRateString = "${base.dceTimes}" + "000")
    @Scheduled(initialDelay = 90000L, fixedRateString = "${base.dceTimes}" + "000")
    public void dceInfoTask() {
        if (!StaticKeys.NODE_MASTER.equals(commonConfig.getNodeType())) {
            logger.info("slave节点不执行检测数通设备PING任务");
src/main/java/com/wgcloud/util/PingUtil.java
@@ -37,10 +37,11 @@
        String pingCommand;
        Runtime r = Runtime.getRuntime();
        String osName = System.getProperty("os.name");
        System.out.println( "osName:"+osName);
        if (osName.contains("Windows")) {
            pingCommand = "ping " + ipAddress + " -n " + count + " -w " + (timeOut * 1000);
        } else {
            pingCommand = "ping " + " -c " + count + " -w " + timeOut + " " + ipAddress;
            pingCommand = "ping " + " -c " + count +  " "  + ipAddress;
        }
        Integer diffTimes = StaticKeys.OUT_TIME_MARK;
        try {
@@ -87,6 +88,7 @@
            //查找整数的正则 begin
            String regInt = "(=\\d+ms)";
            Pattern patternInt = Pattern.compile(regInt);
            Matcher matcherInt = patternInt.matcher(line);
            while (matcherInt.find()) {
                String groupStr = matcherInt.group(1);
@@ -105,6 +107,7 @@
            String regDouble = "(=\\d+.\\d+ms)";
            Pattern patternDouble = Pattern.compile(regDouble);
            Matcher matcherDouble = patternDouble.matcher(line);
            while (matcherDouble.find()) {
                String groupStr = matcherDouble.group(1);
                logger.debug(line + "--------------" + groupStr);
src/main/java/com/wgcloud/util/msg/WarnMailUtil.java
@@ -1118,8 +1118,8 @@
            mails = mails.substring(1);
        }
        try {
            String mailTitlePrefix = "[WGCLOUD]";
            String mailContentSuffix = "<p><p><p><a target='_blank' href='http://www.wgstart.com'>WGCLOUD</a>敬上";
            String mailTitlePrefix = "[TSSW]";
            String mailContentSuffix = "<p><p><p><a target='_blank' href='http://www.wgstart.com'>tssw</a>敬上";
            mailTitlePrefix = commonConfig.getMailTitlePrefix();
            mailContentSuffix = commonConfig.getMailContentSuffix();
            HtmlEmail email = new HtmlEmail();
src/main/resources/application.yml
@@ -14,7 +14,7 @@
    name: wgcloud-server
  datasource:
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://127.0.0.1:3306/wgcloud?characterEncoding=utf-8&characterSetResults=utf8&autoReconnect=true&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true
    url: jdbc:mysql://localhost:3306/wgcloud?characterEncoding=utf-8&characterSetResults=utf8&autoReconnect=true&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true
    username: root
    password: rootroot
    # hikari连接池的参数 相关设置
@@ -86,7 +86,7 @@
  #服务接口监控间隔,单位秒,默认10分钟
  heathTimes: 600
  #数通设备监控间隔,单位秒,默认15分钟
  dceTimes: 900
  dceTimes: 300
  #snmp设备监测间隔,单位秒,默认20分钟
  snmpTimes: 1200
  #告警缓存时间间隔(此时间段内同一告警通知不再重复发),单位秒,默认120分钟
@@ -108,9 +108,9 @@
  #系统简称,如wgcloud,此功能需升级到专业版
  wgShortName:
  #告警邮件标题前缀,此功能需升级到专业版
  mailTitlePrefix: '[WGCLOUD]'
  mailTitlePrefix: '[KDQ]'
  #告警邮件内容后缀,此功能需升级到专业版
  mailContentSuffix: '<p><p><p>WGCLOUD敬上'
  mailContentSuffix: '<p><p><p>KDQ敬上'
  #是否显示页面底部版权、网址信息,yes显示,no不显示,此功能需升级到专业版
  copyRight: yes
  year: 1
src/main/resources/mybatis/mapper/OspfInfoMapper.xml
@@ -12,12 +12,13 @@
        <result column="MONITOR_USERNAME" property="monitorUsername" jdbcType="CHAR" />
        <result column="MONITOR_PASSWORD" property="monitorPassword" jdbcType="CHAR" />
        <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
        <result column="MONITOR_REMOTE_TYPE" property="monitorRemoteType" jdbcType="CHAR" />
    </resultMap>
    <sql id="tableColumnList">
        ID,HOST_NAME, INFO_CONTENT, STATE,AREA_NUM,CREATE_TIME,MONITOR_ID,MONITOR_IP,MONITOR_USERNAME,MONITOR_PASSWORD
        ID,HOST_NAME, INFO_CONTENT, STATE,AREA_NUM,CREATE_TIME,MONITOR_ID,MONITOR_IP,MONITOR_USERNAME,MONITOR_PASSWORD,MONITOR_REMOTE_TYPE
    </sql>
    <sql id="queryByParams">
        <if test="hostname != null">
            <choose>
@@ -57,19 +58,19 @@
            <![CDATA[ AND AREA_NUM = #{areaNum} ]]>
        </if>
    </sql>
    <select id="selectById" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
        <include refid="tableColumnList" />
        FROM OSPF_INFO WHERE ID=#{id}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        DELETE FROM OSPF_INFO WHERE ID = #{id}
    </delete>
    <delete id="deleteByDate"  parameterType="map">
        DELETE FROM OSPF_INFO WHERE
        <if test="_databaseId == 'mysql'">
@@ -82,12 +83,12 @@
            <![CDATA[  CREATE_TIME <=  to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]>
        </if>
    </delete>
    <delete id="deleteByAccHname"  parameterType="map">
        DELETE FROM OSPF_INFO WHERE ACCOUNT = #{account} AND HOST_NAME = #{hostname}
    </delete>
    <delete id="deleteById" parameterType="java.lang.String">
        DELETE FROM OSPF_INFO WHERE ID IN
        <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
@@ -100,15 +101,15 @@
            <when test="_databaseId == 'oracle'">
                begin
                <foreach collection="list" item="item" index="index">
                    INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_USERNAME,MONITOR_PASSWORD)  VALUES
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorUsername},#{item.monitorPassword});
                    INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_REMOTE_TYPE,MONITOR_USERNAME,MONITOR_PASSWORD,CREATE_TIME)  VALUES
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorRemoteType},#{item.monitorUsername},#{item.monitorPassword},#{item.createTime});
                </foreach>
                end;
            </when>
            <otherwise>
                INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_USERNAME,MONITOR_PASSWORD)  VALUES
                INSERT INTO OSPF_INFO (ID,HOST_NAME,INFO_CONTENT,STATE,AREA_NUM,CREATE_TIME,MONITOR_IP,MONITOR_ID,MONITOR_REMOTE_TYPE,MONITOR_USERNAME,MONITOR_PASSWORD,CREATE_TIME)  VALUES
                <foreach collection="list" item="item" index="index" separator="," >
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorUsername},#{item.monitorPassword})
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.areaNum},#{item.createTime},#{item.monitorIp},#{item.monitorId},#{item.monitorRemoteType},#{item.monitorUsername},#{item.monitorPassword},#{item.createTime})
                </foreach>
            </otherwise>
        </choose>
@@ -124,6 +125,7 @@
              <if test="areaNum != null" >AREA_NUM,</if>
              <if test="monitorIp != null" >MONITOR_IP,</if>
              <if test="monitorId != null" >MONITOR_ID,</if>
              <if test="monitorRemoteType != null" >MONITOR_REMOTE_TYPE,</if>
              <if test="monitorUsername != null" >MONITOR_USERNAME,</if>
              <if test="monitorPassword != null" >MONITOR_PASSWORD,</if>
              <if test="createTime != null" >CREATE_TIME</if>
@@ -136,6 +138,7 @@
            <if test="areaNum != null" >#{areaNum},</if>
            <if test="monitorIp != null" >#{monitorIp},</if>
            <if test="monitorId != null" >#{monitorId},</if>
            <if test="monitorRemoteType != null" >#{monitorRemoteType},</if>
            <if test="monitorUsername != null" >#{monitorUsername},</if>
            <if test="monitorPassword != null" >#{monitorPassword},</if>
              <if test="createTime != null" >#{createTime}</if>
@@ -160,7 +163,7 @@
        </where>
         ORDER BY CREATE_TIME DESC
    </select>
    <select id="selectByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
@@ -202,9 +205,12 @@
            <if test="monitorPassword != null">
                MONITOR_PASSWORD = #{monitorPassword},
            </if>
            <if test="monitorRemoteType != null">
                MONITOR_REMOTE_TYPE = #{monitorRemoteType},
            </if>
        </set>
        WHERE ID = #{id}
    </update>
</mapper>
</mapper>
src/main/resources/mybatis/mapper/OspfMonitorMapper.xml
@@ -9,12 +9,13 @@
        <result column="USERNAME" property="username" jdbcType="CHAR" />
        <result column="PASSWORD" property="password" jdbcType="CHAR" />
        <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
        <result column="REMOTE_TYPE" property="remoteType" jdbcType="CHAR" />
    </resultMap>
    <sql id="tableColumnList">
        ID,HOST_NAME, INFO_CONTENT, STATE,USERNAME,PASSWORD,CREATE_TIME
        ID,HOST_NAME, INFO_CONTENT, STATE,USERNAME,PASSWORD,CREATE_TIME,REMOTE_TYPE
    </sql>
    <sql id="queryByParams">
        <if test="hostname != null">
            <choose>
@@ -54,19 +55,19 @@
            <![CDATA[ AND AREA_NUM = #{areaNum} ]]>
        </if>
    </sql>
    <select id="selectById" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
        <include refid="tableColumnList" />
        FROM OSPF_MONITOR WHERE ID=#{id}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        DELETE FROM OSPF_MONITOR WHERE ID = #{id}
    </delete>
    <delete id="deleteByDate"  parameterType="map">
        DELETE FROM OSPF_MONITOR WHERE
        <if test="_databaseId == 'mysql'">
@@ -79,12 +80,12 @@
            <![CDATA[  CREATE_TIME <=  to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]>
        </if>
    </delete>
    <delete id="deleteByAccHname"  parameterType="map">
        DELETE FROM OSPF_MONITOR WHERE ACCOUNT = #{account} AND HOST_NAME = #{hostname}
    </delete>
    <delete id="deleteById" parameterType="java.lang.String">
        DELETE FROM OSPF_MONITOR WHERE ID IN
        <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
@@ -103,9 +104,9 @@
                end;
            </when>
            <otherwise>
                INSERT INTO OSPF_MONITOR (ID,HOST_NAME,INFO_CONTENT,STATE,USERNAME,PASSWORD,CREATE_TIME)  VALUES
                INSERT INTO OSPF_MONITOR (ID,HOST_NAME,INFO_CONTENT,STATE,USERNAME,PASSWORD,CREATE_TIME,REMOTE_TYPE)  VALUES
                <foreach collection="list" item="item" index="index" separator="," >
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.username},#{item.password},#{item.createTime})
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.username},#{item.password},#{item.createTime},#{item.remoteType})
                </foreach>
            </otherwise>
        </choose>
@@ -120,7 +121,8 @@
              <if test="state != null" >STATE,</if>
              <if test="username != null" >USERNAME,</if>
              <if test="password != null" >PASSWORD,</if>
              <if test="createTime != null" >CREATE_TIME</if>
              <if test="createTime != null" >CREATE_TIME,</if>
            <if test="remoteType != null" >REMOTE_TYPE</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
              <if test="id != null" >#{id},</if>
@@ -129,7 +131,8 @@
              <if test="state != null" >#{state},</if>
            <if test="username != null" >#{username},</if>
            <if test="password != null" >#{password},</if>
              <if test="createTime != null" >#{createTime}</if>
              <if test="createTime != null" >#{createTime},</if>
            <if test="remoteType != null" >#{remoteType}</if>
        </trim>
    </insert>
@@ -151,7 +154,7 @@
        </where>
         ORDER BY CREATE_TIME DESC
    </select>
    <select id="selectByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
@@ -184,9 +187,12 @@
            <if test="createTime != null">
                CREATE_TIME = #{createTime},
            </if>
            <if test="remoteType != null">
                REMOTE_TYPE = #{remoteType},
            </if>
        </set>
        WHERE ID = #{id}
    </update>
</mapper>
</mapper>
src/main/resources/templates/mail/view.html
@@ -57,7 +57,7 @@
                    <input type="text"  th:value="${mailSet.fromMailName}" autocomplete="off" class="validate[required,maxSize[40],custom[email]] form-control" name="fromMailName" id="fromMailName" placeholder="123456@qq.com">
                </div>
                <div class="form-group">
                    <label for="fromPwd"><font color="red">*</font>发送邮箱密码 <span  data-trigger="hover"  data-container="body" data-toggle="popover" data-placement="top" data-content="显示密码" onclick="javascript:showPasswd();" style="cursor:pointer;margin-left: 5px"><i id="eyeSwitch" class="fa fa-eye"></i></span></label>
                    <label for="fromPwd"><font color="red">*</font>发送邮箱授权码 <span  data-trigger="hover"  data-container="body" data-toggle="popover" data-placement="top" data-content="显示密码" onclick="javascript:showPasswd();" style="cursor:pointer;margin-left: 5px"><i id="eyeSwitch" class="fa fa-eye"></i></span></label>
                    <input type="password"  th:value="${mailSet.fromPwd}"  class="validate[required,maxSize[20]] form-control" name="fromPwd" id="fromPwd" placeholder="">
                </div>
                <div class="form-group">
src/main/resources/templates/ospfMonitor/add.html
@@ -66,6 +66,14 @@
                    <label>密码</label>
                    <input type="text" autocomplete="off"  th:value="${ospfMonitor.password}" class="validate[required,maxSize[50]] form-control" name="password" id="password" placeholder="">
                </div>
                <div class="form-group">
                    <label><font color="red">*</font>连接类型</label>
                    <select class="validate[required] form-control" name="remoteType" id="remoteType">
                        <option value="">请选择</option>
                        <option value="TELNET" th:selected="${ospfMonitor.remoteType == 'TELNET'}">TELNET</option>
                        <option value="SSH" th:selected="${ospfMonitor.remoteType == 'SSH'}">SSH</option>
                    </select>
                </div>
            </div>
            <!-- /.card-body -->
src/main/resources/templates/ospfMonitor/list.html
@@ -67,6 +67,7 @@
            <th title="设备IP">设备IP</th>
            <th title="用户名">用户名</th>
            <th title="密码">密码</th>
            <th title="连接方式">连接方式</th>
            </tr>
          </th:block>
          </thead>
@@ -79,6 +80,7 @@
              <td th:text="${item.hostname}"></td>
              <td th:text="${item.username}"></td>
              <td th:text="${item.password}"></td>
              <td th:text="${item.remoteType}"></td>
              <td>
                <th:block th:if="${session.LOGIN_KEY.role != 'guest'}">
                    <button type="button"  th:onclick="del([[${item.id}]])"  class="btn bg-gradient-danger btn-sm">删除</button>