package com.yutou.nas.Controllers; import com.alibaba.fastjson2.JSONObject; import com.yutou.nas.utils.QQBotManager; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import java.util.regex.Matcher; import java.util.regex.Pattern; @Controller public class HHDController { @ResponseBody @RequestMapping("/nas/hhd.do") public String hddSMART(@RequestBody JSONObject json){ Pattern pattern=Pattern.compile(".(?<=(result: )).*"); for (String key : json.keySet()) { Matcher matcher=pattern.matcher(json.getString(key)); if(matcher.find()){ String result=matcher.group(0).trim(); if(!"PASSED".equals(result)){ QQBotManager.getInstance().sendMessage("硬盘异常警告:"+key+":"+result); } } } return "服务已接收"; } }