已添加9个文件
已重命名1个文件
已修改12个文件
| | |
| | | <artifactId>forest-spring-boot-starter</artifactId> |
| | | <version>1.5.22</version> |
| | | </dependency> |
| | | <!--mqtt--> |
| | | <dependency> |
| | | <groupId>org.springframework.integration</groupId> |
| | | <artifactId>spring-integration-mqtt</artifactId> |
| | | <version>6.0.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-system</artifactId> |
| | |
| | | package com.ruoyi.alarm.globalAlarm.service; |
| | | |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.ruoyi.alarm.globalAlarm.domain.GlobalAlarmCondition; |
| | | import com.ruoyi.alarm.stealAlarm.domain.ArdAlarmStealelec; |
| | | import com.ruoyi.alarm.stealAlarm.mapper.ArdAlarmStealelecMapper; |
| | | import com.ruoyi.alarm.tubeAlarm.domain.ArdAlarmTube; |
| | | import com.ruoyi.alarm.tubeAlarm.mapper.ArdAlarmTubeMapper; |
| | | import com.ruoyi.alarm.tubeAlarm.service.IArdAlarmTubeService; |
| | | import com.ruoyi.alarmpoints.tube.domain.ArdTubes; |
| | | import com.ruoyi.alarmpoints.tube.domain.ArdTubesDetails; |
| | | import com.ruoyi.alarmpoints.tube.mapper.ArdTubesDetailsMapper; |
| | | import com.ruoyi.alarmpoints.tube.mapper.ArdTubesMapper; |
| | | import com.ruoyi.common.utils.uuid.UUID; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | public class GlobalAlarmServiceImpl implements IGlobalAlarmService { |
| | | @Resource |
| | | ArdAlarmStealelecMapper ardAlarmStealelecMapper; |
| | | |
| | | @Resource |
| | | IArdAlarmTubeService ardAlarmTubeService; |
| | | @Resource |
| | | ArdTubesMapper ardTubesMapper; |
| | | @Resource |
| | | ArdTubesDetailsMapper ardTubesDetailsMapper; |
| | | @Override |
| | | public List<Object> selectAlarmLogs(GlobalAlarmCondition condition) { |
| | | switch (condition.getCommand()) { |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Async("alarmExecutor") |
| | | public void receiveAlarm(String topic,String message) |
| | | { |
| | | switch (topic) |
| | | { |
| | | case "tube": |
| | | ArdAlarmTube ardAlarmTube = JSONObject.parseObject(message,ArdAlarmTube.class); |
| | | ardAlarmTube.setId(UUID.randomUUID().toString().replace("-","")); |
| | | ArdTubesDetails atd=new ArdTubesDetails(); |
| | | atd.setReelNumber(ardAlarmTube.getTubeId()); |
| | | List<ArdTubesDetails> ardTubesDetails = ardTubesDetailsMapper.selectArdTubesDetailsList(atd); |
| | | if(ardTubesDetails.size()>0) |
| | | { |
| | | String tubeId = ardTubesDetails.get(0).getTubeId(); |
| | | ArdTubes ardTubes = ardTubesMapper.selectArdTubesById(tubeId); |
| | | ardAlarmTube.setTubeName(ardTubes.getName()); |
| | | ardAlarmTube.setColor(ardTubes.getColor()); |
| | | ardAlarmTube.setPipeDiameter(ardTubes.getPipeDiameter()); |
| | | ardAlarmTube.setTubeType(ardTubes.getType()); |
| | | } |
| | | int i = ardAlarmTubeService.insertArdAlarmTube(ardAlarmTube); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | |
| | | **/ |
| | | public interface IGlobalAlarmService { |
| | | public List<Object> selectAlarmLogs(GlobalAlarmCondition condition); |
| | | |
| | | public void receiveAlarm(String topic,String message); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.alarm.tubeAlarm.controller; |
| | | |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.ruoyi.alarm.tubeAlarm.domain.ArdAlarmTube; |
| | | import com.ruoyi.alarm.tubeAlarm.service.IArdAlarmTubeService; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | | /** |
| | | * 管线æ³é²æ¥è¦Controller |
| | | * |
| | | * @author åèä¹ |
| | | * @date 2023-06-06 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/alarm/tubeAlarm") |
| | | public class ArdAlarmTubeController extends BaseController |
| | | { |
| | | @Autowired |
| | | private IArdAlarmTubeService ardAlarmTubeService; |
| | | |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(ArdAlarmTube ardAlarmTube) |
| | | { |
| | | startPage(); |
| | | List<ArdAlarmTube> list = ardAlarmTubeService.selectArdAlarmTubeList(ardAlarmTube); |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | /** |
| | | * 导åºç®¡çº¿æ³é²æ¥è¦å表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:export')") |
| | | @Log(title = "管线æ³é²æ¥è¦", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, ArdAlarmTube ardAlarmTube) |
| | | { |
| | | List<ArdAlarmTube> list = ardAlarmTubeService.selectArdAlarmTubeList(ardAlarmTube); |
| | | ExcelUtil<ArdAlarmTube> util = new ExcelUtil<ArdAlarmTube>(ArdAlarmTube.class); |
| | | util.exportExcel(response, list, "管线æ³é²æ¥è¦æ°æ®"); |
| | | } |
| | | |
| | | /** |
| | | * è·å管线æ³é²æ¥è¦è¯¦ç»ä¿¡æ¯ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:query')") |
| | | @GetMapping(value = "/{id}") |
| | | public AjaxResult getInfo(@PathVariable("id") String id) |
| | | { |
| | | return success(ardAlarmTubeService.selectArdAlarmTubeById(id)); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ç®¡çº¿æ³é²æ¥è¦ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:add')") |
| | | @Log(title = "管线æ³é²æ¥è¦", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ArdAlarmTube ardAlarmTube) |
| | | { |
| | | return toAjax(ardAlarmTubeService.insertArdAlarmTube(ardAlarmTube)); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç®¡çº¿æ³é²æ¥è¦ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:edit')") |
| | | @Log(title = "管线æ³é²æ¥è¦", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ArdAlarmTube ardAlarmTube) |
| | | { |
| | | return toAjax(ardAlarmTubeService.updateArdAlarmTube(ardAlarmTube)); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ç®¡çº¿æ³é²æ¥è¦ |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('alarm:tubeAlarm:remove')") |
| | | @Log(title = "管线æ³é²æ¥è¦", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) |
| | | { |
| | | return toAjax(ardAlarmTubeService.deleteArdAlarmTubeByIds(ids)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.alarm.tubeAlarm.domain; |
| | | |
| | | import java.util.Date; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | | import org.apache.commons.lang3.builder.ToStringStyle; |
| | | import com.ruoyi.common.annotation.Excel; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | |
| | | /** |
| | | * 管线æ³é²æ¥è¦å¯¹è±¡ ard_alarm_tube |
| | | * |
| | | * @author åèä¹ |
| | | * @date 2023-06-06 |
| | | */ |
| | | public class ArdAlarmTube extends BaseEntity |
| | | { |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** ä¸»é® */ |
| | | private String id; |
| | | |
| | | /** æ¥è¦ä¸»æº */ |
| | | @Excel(name = "æ¥è¦ä¸»æº") |
| | | private String host; |
| | | |
| | | /** 管线id */ |
| | | @Excel(name = "管线id") |
| | | private String tubeId; |
| | | |
| | | /** 管线åç§° */ |
| | | @Excel(name = "管线åç§°") |
| | | private String tubeName; |
| | | |
| | | /** 管线类å-油管-水管 */ |
| | | @Excel(name = "管线类å-油管-水管") |
| | | private String tubeType; |
| | | |
| | | /** ç®¡å¾ */ |
| | | @Excel(name = "管å¾") |
| | | private String pipeDiameter; |
| | | |
| | | /** é¢è² */ |
| | | @Excel(name = "é¢è²") |
| | | private String color; |
| | | |
| | | /** ä½ç½® */ |
| | | @Excel(name = "ä½ç½®") |
| | | private String position; |
| | | |
| | | /** ç±»åGXALARM */ |
| | | @Excel(name = "ç±»åGXALARM") |
| | | private String type; |
| | | |
| | | /** ç±»å䏿 */ |
| | | @Excel(name = "ç±»å䏿") |
| | | private String alarmType; |
| | | |
| | | /** æ¥è¦æ¶é´ */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "æ¥è¦æ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date alarmTime; |
| | | |
| | | /** ç¨æ·å */ |
| | | @Excel(name = "ç¨æ·å") |
| | | private String watcher; |
| | | |
| | | /** æ¥çæ¶é´ */ |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @Excel(name = "æ¥çæ¶é´", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") |
| | | private Date viewTime; |
| | | |
| | | public void setId(String id) |
| | | { |
| | | this.id = id; |
| | | } |
| | | |
| | | public String getId() |
| | | { |
| | | return id; |
| | | } |
| | | public void setHost(String host) |
| | | { |
| | | this.host = host; |
| | | } |
| | | |
| | | public String getHost() |
| | | { |
| | | return host; |
| | | } |
| | | public void setTubeId(String tubeId) |
| | | { |
| | | this.tubeId = tubeId; |
| | | } |
| | | |
| | | public String getTubeId() |
| | | { |
| | | return tubeId; |
| | | } |
| | | public void setTubeName(String tubeName) |
| | | { |
| | | this.tubeName = tubeName; |
| | | } |
| | | |
| | | public String getTubeName() |
| | | { |
| | | return tubeName; |
| | | } |
| | | public void setTubeType(String tubeType) |
| | | { |
| | | this.tubeType = tubeType; |
| | | } |
| | | |
| | | public String getTubeType() |
| | | { |
| | | return tubeType; |
| | | } |
| | | public void setPipeDiameter(String pipeDiameter) |
| | | { |
| | | this.pipeDiameter = pipeDiameter; |
| | | } |
| | | |
| | | public String getPipeDiameter() |
| | | { |
| | | return pipeDiameter; |
| | | } |
| | | public void setColor(String color) |
| | | { |
| | | this.color = color; |
| | | } |
| | | |
| | | public String getColor() |
| | | { |
| | | return color; |
| | | } |
| | | public void setPosition(String position) |
| | | { |
| | | this.position = position; |
| | | } |
| | | |
| | | public String getPosition() |
| | | { |
| | | return position; |
| | | } |
| | | public void setType(String type) |
| | | { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getType() |
| | | { |
| | | return type; |
| | | } |
| | | public void setAlarmType(String alarmType) |
| | | { |
| | | this.alarmType = alarmType; |
| | | } |
| | | |
| | | public String getAlarmType() |
| | | { |
| | | return alarmType; |
| | | } |
| | | public void setAlarmTime(Date alarmTime) |
| | | { |
| | | this.alarmTime = alarmTime; |
| | | } |
| | | |
| | | public Date getAlarmTime() |
| | | { |
| | | return alarmTime; |
| | | } |
| | | public void setWatcher(String watcher) |
| | | { |
| | | this.watcher = watcher; |
| | | } |
| | | |
| | | public String getWatcher() |
| | | { |
| | | return watcher; |
| | | } |
| | | public void setViewTime(Date viewTime) |
| | | { |
| | | this.viewTime = viewTime; |
| | | } |
| | | |
| | | public Date getViewTime() |
| | | { |
| | | return viewTime; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) |
| | | .append("id", getId()) |
| | | .append("host", getHost()) |
| | | .append("tubeId", getTubeId()) |
| | | .append("tubeName", getTubeName()) |
| | | .append("tubeType", getTubeType()) |
| | | .append("pipeDiameter", getPipeDiameter()) |
| | | .append("color", getColor()) |
| | | .append("position", getPosition()) |
| | | .append("type", getType()) |
| | | .append("alarmType", getAlarmType()) |
| | | .append("alarmTime", getAlarmTime()) |
| | | .append("watcher", getWatcher()) |
| | | .append("createTime", getCreateTime()) |
| | | .append("viewTime", getViewTime()) |
| | | .toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.alarm.tubeAlarm.mapper; |
| | | |
| | | import java.util.List; |
| | | import com.ruoyi.alarm.tubeAlarm.domain.ArdAlarmTube; |
| | | |
| | | |
| | | /** |
| | | * 管线æ³é²æ¥è¦Mapperæ¥å£ |
| | | * |
| | | * @author åèä¹ |
| | | * @date 2023-06-06 |
| | | */ |
| | | public interface ArdAlarmTubeMapper |
| | | { |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param id 管线æ³é²æ¥è¦ä¸»é® |
| | | * @return 管线æ³é²æ¥è¦ |
| | | */ |
| | | public ArdAlarmTube selectArdAlarmTubeById(String id); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦å表 |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return 管线æ³é²æ¥è¦éå |
| | | */ |
| | | public List<ArdAlarmTube> selectArdAlarmTubeList(ArdAlarmTube ardAlarmTube); |
| | | |
| | | /** |
| | | * æ°å¢ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertArdAlarmTube(ArdAlarmTube ardAlarmTube); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateArdAlarmTube(ArdAlarmTube ardAlarmTube); |
| | | |
| | | /** |
| | | * å é¤ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param id 管线æ³é²æ¥è¦ä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteArdAlarmTubeById(String id); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ids éè¦å é¤çæ°æ®ä¸»é®éå |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteArdAlarmTubeByIds(String[] ids); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.alarm.tubeAlarm.service; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.ruoyi.alarm.tubeAlarm.domain.ArdAlarmTube; |
| | | |
| | | /** |
| | | * 管线æ³é²æ¥è¦Serviceæ¥å£ |
| | | * |
| | | * @author åèä¹ |
| | | * @date 2023-06-06 |
| | | */ |
| | | public interface IArdAlarmTubeService |
| | | { |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param id 管线æ³é²æ¥è¦ä¸»é® |
| | | * @return 管线æ³é²æ¥è¦ |
| | | */ |
| | | public ArdAlarmTube selectArdAlarmTubeById(String id); |
| | | |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦å表 |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return 管线æ³é²æ¥è¦éå |
| | | */ |
| | | public List<ArdAlarmTube> selectArdAlarmTubeList(ArdAlarmTube ardAlarmTube); |
| | | |
| | | /** |
| | | * æ°å¢ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return ç»æ |
| | | */ |
| | | public int insertArdAlarmTube(ArdAlarmTube ardAlarmTube); |
| | | |
| | | /** |
| | | * ä¿®æ¹ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return ç»æ |
| | | */ |
| | | public int updateArdAlarmTube(ArdAlarmTube ardAlarmTube); |
| | | |
| | | /** |
| | | * æ¹éå é¤ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ids éè¦å é¤ç管线æ³é²æ¥è¦ä¸»é®éå |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteArdAlarmTubeByIds(String[] ids); |
| | | |
| | | /** |
| | | * å é¤ç®¡çº¿æ³é²æ¥è¦ä¿¡æ¯ |
| | | * |
| | | * @param id 管线æ³é²æ¥è¦ä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | | public int deleteArdAlarmTubeById(String id); |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.alarm.tubeAlarm.service.impl; |
| | | |
| | | import com.ruoyi.alarm.tubeAlarm.domain.ArdAlarmTube; |
| | | import com.ruoyi.alarm.tubeAlarm.mapper.ArdAlarmTubeMapper; |
| | | import com.ruoyi.alarm.tubeAlarm.service.IArdAlarmTubeService; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 管线æ³é²æ¥è¦Serviceä¸å¡å±å¤ç |
| | | * |
| | | * @author åèä¹ |
| | | * @date 2023-06-06 |
| | | */ |
| | | @Service |
| | | public class ArdAlarmTubeServiceImpl implements IArdAlarmTubeService { |
| | | @Autowired |
| | | private ArdAlarmTubeMapper ardAlarmTubeMapper; |
| | | |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param id 管线æ³é²æ¥è¦ä¸»é® |
| | | * @return 管线æ³é²æ¥è¦ |
| | | */ |
| | | @Override |
| | | public ArdAlarmTube selectArdAlarmTubeById(String id) { |
| | | return ardAlarmTubeMapper.selectArdAlarmTubeById(id); |
| | | } |
| | | |
| | | /** |
| | | * æ¥è¯¢ç®¡çº¿æ³é²æ¥è¦å表 |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return 管线æ³é²æ¥è¦ |
| | | */ |
| | | @Override |
| | | public List<ArdAlarmTube> selectArdAlarmTubeList(ArdAlarmTube ardAlarmTube) { |
| | | return ardAlarmTubeMapper.selectArdAlarmTubeList(ardAlarmTube); |
| | | } |
| | | |
| | | /** |
| | | * æ°å¢ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int insertArdAlarmTube(ArdAlarmTube ardAlarmTube) { |
| | | ardAlarmTube.setCreateTime(DateUtils.getNowDate()); |
| | | return ardAlarmTubeMapper.insertArdAlarmTube(ardAlarmTube); |
| | | } |
| | | |
| | | /** |
| | | * ä¿®æ¹ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ardAlarmTube 管线æ³é²æ¥è¦ |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int updateArdAlarmTube(ArdAlarmTube ardAlarmTube) { |
| | | return ardAlarmTubeMapper.updateArdAlarmTube(ardAlarmTube); |
| | | } |
| | | |
| | | /** |
| | | * æ¹éå é¤ç®¡çº¿æ³é²æ¥è¦ |
| | | * |
| | | * @param ids éè¦å é¤ç管线æ³é²æ¥è¦ä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteArdAlarmTubeByIds(String[] ids) { |
| | | return ardAlarmTubeMapper.deleteArdAlarmTubeByIds(ids); |
| | | } |
| | | |
| | | /** |
| | | * å é¤ç®¡çº¿æ³é²æ¥è¦ä¿¡æ¯ |
| | | * |
| | | * @param id 管线æ³é²æ¥è¦ä¸»é® |
| | | * @return ç»æ |
| | | */ |
| | | @Override |
| | | public int deleteArdAlarmTubeById(String id) { |
| | | return ardAlarmTubeMapper.deleteArdAlarmTubeById(id); |
| | | } |
| | | } |
ÎļþÃû´Ó ard-work/src/main/java/com/ruoyi/device/hiksdk/config/AsyncConfiguration.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.device.hiksdk.config; |
| | | package com.ruoyi.config; |
| | | |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | executor.initialize(); |
| | | return executor; |
| | | } |
| | | @Bean("alarmExecutor") |
| | | public Executor alarmExecutor(){ |
| | | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
| | | //é
ç½®æ ¸å¿çº¿ç¨æ° |
| | | executor.setCorePoolSize(15); |
| | | //é
ç½®æå¤§çº¿ç¨æ° |
| | | executor.setMaxPoolSize(30); |
| | | //é
ç½®éåå¤§å° |
| | | executor.setQueueCapacity(1000); |
| | | //线ç¨çåç§°åç¼ |
| | | executor.setThreadNamePrefix("alarmExecutor-"); |
| | | //çº¿ç¨æ´»è·æ¶é´ï¼ç§ï¼ |
| | | //executor.setKeepAliveSeconds(60); |
| | | //çå¾
ææä»»å¡ç»æååå
³éçº¿ç¨æ± |
| | | executor.setWaitForTasksToCompleteOnShutdown(true); |
| | | //设置æç»çç¥ |
| | | //executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); |
| | | //æ§è¡åå§å |
| | | executor.initialize(); |
| | | return executor; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.inspect.domain.ArdVideoInspectTaskStep; |
| | | import com.ruoyi.inspect.service.IArdVideoInspectTaskStepService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * è§é¢å·¡æ£æ¥éª¤Serviceä¸å¡å±å¤ç |
| | | * |
| | |
| | | */ |
| | | @Service |
| | | public class ArdVideoInspectTaskStepServiceImpl implements IArdVideoInspectTaskStepService { |
| | | @Autowired |
| | | @Resource |
| | | private ArdVideoInspectTaskStepMapper ardVideoInspectTaskStepMapper; |
| | | |
| | | /** |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.utils.mqtt; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.*; |
| | | import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence; |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | import java.io.UnsupportedEncodingException; |
| | | /** |
| | | * @Description: mqttæ¶è´¹å®¢æ·ç«¯ |
| | | * @ClassName: MqttConsumer |
| | | * @Author: åèä¹ |
| | | * @Date: 2023å¹´05æ29æ¥9:55 |
| | | * @Version: 1.0 |
| | | **/ |
| | | @Component |
| | | @Slf4j(topic = "mqtt") |
| | | public class MqttConsumer implements ApplicationRunner { |
| | | |
| | | private static MqttClient client; |
| | | |
| | | @Override |
| | | public void run(ApplicationArguments args) { |
| | | log.info("åå§åå¹¶å¯å¨mqtt......"); |
| | | if(PropertiesUtil.MQTT_ENABLED) |
| | | { |
| | | this.connect(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è¿æ¥mqttæå¡å¨ |
| | | */ |
| | | private void connect() { |
| | | try { |
| | | // 1 å建客æ·ç«¯ |
| | | getClient(); |
| | | // 2 设置é
ç½® |
| | | MqttConnectOptions options = getOptions(); |
| | | String[] topic = PropertiesUtil.MQTT_TOPIC.split(","); |
| | | // 3 æ¶æ¯åå¸è´¨é |
| | | int[] qos = getQos(topic.length); |
| | | // 4 æå设置 |
| | | create(options, topic, qos); |
| | | } catch (Exception e) { |
| | | log.error("mqttè¿æ¥å¼å¸¸ï¼" + e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * å建客æ·ç«¯ --- 1 --- |
| | | */ |
| | | public void getClient() { |
| | | try { |
| | | if (null == client) { |
| | | client = new MqttClient(PropertiesUtil.MQTT_HOST, PropertiesUtil.MQTT_CLIENT_ID, new MemoryPersistence()); |
| | | } |
| | | log.info("--å建mqtt客æ·ç«¯"); |
| | | } catch (Exception e) { |
| | | log.error("å建mqtt客æ·ç«¯å¼å¸¸ï¼" + e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * çæé
置对象ï¼ç¨æ·åï¼å¯ç ç --- 2 --- |
| | | */ |
| | | public MqttConnectOptions getOptions() { |
| | | MqttConnectOptions options = new MqttConnectOptions(); |
| | | //è®¾ç½®ç¨æ·åå¯ç |
| | | options.setUserName(PropertiesUtil.MQTT_USER_NAME); |
| | | options.setPassword(PropertiesUtil.MQTT_PASSWORD.toCharArray()); |
| | | // 设置è¶
æ¶æ¶é´ |
| | | options.setConnectionTimeout(PropertiesUtil.MQTT_TIMEOUT); |
| | | // 设置ä¼è¯å¿è·³æ¶é´ |
| | | options.setKeepAliveInterval(PropertiesUtil.MQTT_KEEP_ALIVE); |
| | | // æ¯å¦æ¸
é¤session |
| | | options.setCleanSession(false); |
| | | log.info("--çæmqtté
置对象"); |
| | | return options; |
| | | } |
| | | |
| | | /** |
| | | * qos --- 3 --- |
| | | */ |
| | | public int[] getQos(int length) { |
| | | |
| | | int[] qos = new int[length]; |
| | | for (int i = 0; i < length; i++) { |
| | | /** |
| | | * MQTTåè®®ä¸æä¸ç§æ¶æ¯å叿å¡è´¨é: |
| | | * |
| | | * QOS0ï¼ âè³å¤ä¸æ¬¡âï¼æ¶æ¯åå¸å®å
¨ä¾èµåºå± TCP/IP ç½ç»ãä¼åçæ¶æ¯ä¸¢å¤±æéå¤ãè¿ä¸çº§å«å¯ç¨äºå¦ä¸æ
åµï¼ç¯å¢ä¼ æå¨æ°æ®ï¼ä¸¢å¤±ä¸æ¬¡è¯»è®°å½æ æè°ï¼å 为ä¸ä¹
åè¿ä¼æç¬¬äºæ¬¡åéã |
| | | * QOS1ï¼ âè³å°ä¸æ¬¡âï¼ç¡®ä¿æ¶æ¯å°è¾¾ï¼ä½æ¶æ¯éå¤å¯è½ä¼åçã |
| | | * QOS2ï¼ âåªæä¸æ¬¡âï¼ç¡®ä¿æ¶æ¯å°è¾¾ä¸æ¬¡ãè¿ä¸çº§å«å¯ç¨äºå¦ä¸æ
åµï¼å¨è®¡è´¹ç³»ç»ä¸ï¼æ¶æ¯é夿䏢失ä¼å¯¼è´ä¸æ£ç¡®çç»æï¼èµæºå¼é大 |
| | | */ |
| | | qos[i] = 1; |
| | | } |
| | | log.info("--è®¾ç½®æ¶æ¯åå¸è´¨é"); |
| | | return qos; |
| | | } |
| | | |
| | | /** |
| | | * è£
è½½åç§å®ä¾å订é
ä¸»é¢ --- 4 --- |
| | | */ |
| | | public void create(MqttConnectOptions options, String[] topic, int[] qos) { |
| | | try { |
| | | client.setCallback(new MqttConsumerCallback(client, options, topic, qos)); |
| | | log.info("--æ·»å åè°å¤çç±»"); |
| | | client.connect(options); |
| | | } catch (Exception e) { |
| | | log.info("è£
è½½å®ä¾æè®¢é
主é¢å¼å¸¸ï¼" + e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 订é
æä¸ªä¸»é¢ |
| | | * |
| | | * @param topic |
| | | * @param qos |
| | | */ |
| | | public void subscribe(String topic, int qos) { |
| | | try { |
| | | log.info("topic:" + topic); |
| | | client.subscribe(topic, qos); |
| | | } catch (MqttException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åå¸ï¼éæä¹
å |
| | | * |
| | | * qosæ ¹æ®ææ¡£è®¾ç½®ä¸º1 |
| | | * |
| | | * @param topic |
| | | * @param msg |
| | | */ |
| | | public static void publish(String topic, String msg) { |
| | | publish(1, false, topic, msg); |
| | | } |
| | | |
| | | /** |
| | | * åå¸ |
| | | */ |
| | | public static void publish(int qos, boolean retained, String topic, String pushMessage) { |
| | | log.info("ã主é¢ã:" + topic + "ãqosã:" + qos + "ãpushMessageã:" + pushMessage); |
| | | MqttMessage message = new MqttMessage(); |
| | | message.setQos(qos); |
| | | message.setRetained(retained); |
| | | try { |
| | | message.setPayload(pushMessage.getBytes("UTF-8")); |
| | | } catch (UnsupportedEncodingException e) { |
| | | log.error("mqttç¼ç å¼å¸¸ï¼" + e.getMessage()); |
| | | } |
| | | MqttTopic mTopic = client.getTopic(topic); |
| | | if (null == mTopic) { |
| | | log.error("topicï¼" + topic + " ä¸åå¨"); |
| | | } |
| | | MqttDeliveryToken token; |
| | | try { |
| | | token = mTopic.publish(message); |
| | | token.waitForCompletion(); |
| | | if (token.isComplete()) { |
| | | log.info("æ¶æ¯åéæå"); |
| | | } |
| | | } catch (MqttPersistenceException e) { |
| | | e.printStackTrace(); |
| | | } catch (MqttException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.utils.mqtt; |
| | | |
| | | import com.ruoyi.alarm.globalAlarm.service.GlobalAlarmServiceImpl; |
| | | import com.ruoyi.common.utils.spring.SpringUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.paho.client.mqttv3.*; |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * @Description: mqttåè°å¤çç±» |
| | | * @ClassName: MqttConsumerCallback |
| | | * @Author: åèä¹ |
| | | * @Date: 2023å¹´05æ29æ¥9:55 |
| | | * @Version: 1.0 |
| | | **/ |
| | | @Slf4j(topic = "mqtt") |
| | | public class MqttConsumerCallback implements MqttCallbackExtended { |
| | | |
| | | private MqttClient client; |
| | | private MqttConnectOptions options; |
| | | private String[] topic; |
| | | private int[] qos; |
| | | |
| | | public MqttConsumerCallback(MqttClient client, MqttConnectOptions options, String[] topic, int[] qos) { |
| | | this.client = client; |
| | | this.options = options; |
| | | this.topic = topic; |
| | | this.qos = qos; |
| | | } |
| | | |
| | | /** |
| | | * æå¼éè¿ |
| | | */ |
| | | @Override |
| | | public void connectionLost(Throwable cause) { |
| | | log.info("MQTTè¿æ¥æå¼ï¼åèµ·éè¿......"); |
| | | try { |
| | | while (!client.isConnected()) { |
| | | Thread.sleep(5000); |
| | | if (null != client && !client.isConnected()) { |
| | | client.reconnect(); |
| | | log.error("å°è¯éæ°è¿æ¥"); |
| | | } else { |
| | | client.connect(options); |
| | | log.error("å°è¯å»ºç«æ°è¿æ¥"); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * æ¥æ¶å°æ¶æ¯è°ç¨ä»¤çä¸è°ç¨ |
| | | */ |
| | | @Override |
| | | public void deliveryComplete(IMqttDeliveryToken token) { |
| | | |
| | | //log.info("deliveryComplete---------" + Arrays.toString(topic)); |
| | | } |
| | | |
| | | /** |
| | | * æ¶æ¯å¤ç |
| | | */ |
| | | @Override |
| | | public void messageArrived(String topic, MqttMessage message) { |
| | | try { |
| | | // subscribeåå¾å°çæ¶æ¯ä¼æ§è¡å°è¿éé¢ |
| | | log.info("æ¥æ¶æ¶æ¯ ã主é¢ã:" + topic + " ãå
容ã:" + new String(message.getPayload())); |
| | | //è¿è¡ä¸å¡å¤ç(æ¥æ¶æ¥è¦æ°æ®) |
| | | GlobalAlarmServiceImpl globalAlarmService = SpringUtils.getBean(GlobalAlarmServiceImpl.class); |
| | | globalAlarmService.receiveAlarm(topic, new String(message.getPayload(), StandardCharsets.UTF_8)); |
| | | } catch (Exception e) { |
| | | log.info("å¤çmqttæ¶æ¯å¼å¸¸:" + e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * mqttè¿æ¥å订é
ä¸»é¢ |
| | | */ |
| | | @Override |
| | | public void connectComplete(boolean b, String s) { |
| | | try { |
| | | if (null != topic && null != qos) { |
| | | if (client.isConnected()) { |
| | | client.subscribe(topic, qos); |
| | | log.info("mqttè¿æ¥æåï¼å®¢æ·ç«¯IDï¼" + PropertiesUtil.MQTT_CLIENT_ID); |
| | | log.info("--订é
主é¢:ï¼" + Arrays.toString(topic)); |
| | | } else { |
| | | log.info("mqttè¿æ¥å¤±è´¥ï¼å®¢æ·ç«¯IDï¼" + PropertiesUtil.MQTT_CLIENT_ID); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.info("mqtt订é
主é¢å¼å¸¸:" + e); |
| | | } |
| | | } |
| | | } |
| | | |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.utils.mqtt; |
| | | |
| | | import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Objects; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * @Description: è·åé
ç½®ä¿¡æ¯ |
| | | * @ClassName: PropertiesUtil |
| | | * @Author: åèä¹ |
| | | * @Date: 2023å¹´06æ06æ¥9:40 |
| | | * @Version: 1.0 |
| | | **/ |
| | | @Component |
| | | public class PropertiesUtil { |
| | | |
| | | public static String MQTT_HOST; |
| | | public static String MQTT_CLIENT_ID; |
| | | public static String MQTT_USER_NAME; |
| | | public static String MQTT_PASSWORD; |
| | | public static String MQTT_TOPIC; |
| | | public static Integer MQTT_TIMEOUT; |
| | | public static Integer MQTT_KEEP_ALIVE; |
| | | public static Boolean MQTT_ENABLED; |
| | | static { |
| | | MQTT_HOST = getYmlNew("mqtt.host"); |
| | | MQTT_CLIENT_ID = getYmlNew("mqtt.clientId"); |
| | | MQTT_USER_NAME = getYmlNew("mqtt.username"); |
| | | MQTT_PASSWORD = getYmlNew("mqtt.password"); |
| | | MQTT_TOPIC = getYmlNew("mqtt.topic"); |
| | | MQTT_TIMEOUT = Integer.valueOf(Objects.requireNonNull(getYmlNew("mqtt.timeout"))); |
| | | MQTT_KEEP_ALIVE = Integer.valueOf(Objects.requireNonNull(getYmlNew("mqtt.keepalive"))); |
| | | MQTT_ENABLED = Boolean.valueOf(getYmlNew("mqtt.enabled")); |
| | | } |
| | | |
| | | public static String getYmlNew(String key) { |
| | | Resource resource = new ClassPathResource("application-ard.yml"); |
| | | Properties properties; |
| | | try { |
| | | YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean(); |
| | | yamlFactory.setResources(resource); |
| | | properties = yamlFactory.getObject(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | assert properties != null; |
| | | return properties.get(key).toString(); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper |
| | | PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
| | | "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.ruoyi.alarm.tubeAlarm.mapper.ArdAlarmTubeMapper"> |
| | | |
| | | <resultMap type="ArdAlarmTube" id="ArdAlarmTubeResult"> |
| | | <result property="id" column="id" /> |
| | | <result property="host" column="host" /> |
| | | <result property="tubeId" column="tube_id" /> |
| | | <result property="tubeName" column="tube_name" /> |
| | | <result property="tubeType" column="tube_type" /> |
| | | <result property="pipeDiameter" column="pipe_diameter" /> |
| | | <result property="color" column="color" /> |
| | | <result property="position" column="position" /> |
| | | <result property="type" column="type" /> |
| | | <result property="alarmType" column="alarm_type" /> |
| | | <result property="alarmTime" column="alarm_time" /> |
| | | <result property="watcher" column="watcher" /> |
| | | <result property="createTime" column="create_time" /> |
| | | <result property="viewTime" column="view_time" /> |
| | | </resultMap> |
| | | |
| | | <sql id="selectArdAlarmTubeVo"> |
| | | select id, host, tube_id, tube_name, tube_type, pipe_diameter, color, position, type, alarm_type, alarm_time, watcher, create_time, view_time from ard_alarm_tube |
| | | </sql> |
| | | |
| | | <select id="selectArdAlarmTubeList" parameterType="ArdAlarmTube" resultMap="ArdAlarmTubeResult"> |
| | | <include refid="selectArdAlarmTubeVo"/> |
| | | <where> |
| | | <if test="host != null and host != ''"> and host = #{host}</if> |
| | | <if test="tubeId != null "> and tube_id = #{tubeId}</if> |
| | | <if test="tubeName != null and tubeName != ''"> and tube_name like '%'||#{tubeName}||'%'</if> |
| | | <if test="tubeType != null and tubeType != ''"> and tube_type = #{tubeType}</if> |
| | | <if test="pipeDiameter != null and pipeDiameter != ''"> and pipe_diameter = #{pipeDiameter}</if> |
| | | <if test="color != null and color != ''"> and color = #{color}</if> |
| | | <if test="position != null and position != ''"> and position = #{position}</if> |
| | | <if test="type != null and type != ''"> and type = #{type}</if> |
| | | <if test="alarmType != null and alarmType != ''"> and alarm_type = #{alarmType}</if> |
| | | <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if> |
| | | <if test="watcher != null and watcher != ''"> and watcher = #{watcher}</if> |
| | | <if test="viewTime != null "> and view_time = #{viewTime}</if> |
| | | </where> |
| | | </select> |
| | | |
| | | <select id="selectArdAlarmTubeById" parameterType="String" resultMap="ArdAlarmTubeResult"> |
| | | <include refid="selectArdAlarmTubeVo"/> |
| | | where id = #{id} |
| | | </select> |
| | | |
| | | <insert id="insertArdAlarmTube" parameterType="ArdAlarmTube"> |
| | | insert into ard_alarm_tube |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">id,</if> |
| | | <if test="host != null">host,</if> |
| | | <if test="tubeId != null">tube_id,</if> |
| | | <if test="tubeName != null">tube_name,</if> |
| | | <if test="tubeType != null">tube_type,</if> |
| | | <if test="pipeDiameter != null">pipe_diameter,</if> |
| | | <if test="color != null">color,</if> |
| | | <if test="position != null">position,</if> |
| | | <if test="type != null">type,</if> |
| | | <if test="alarmType != null">alarm_type,</if> |
| | | <if test="alarmTime != null">alarm_time,</if> |
| | | <if test="watcher != null">watcher,</if> |
| | | <if test="createTime != null">create_time,</if> |
| | | <if test="viewTime != null">view_time,</if> |
| | | </trim> |
| | | <trim prefix="values (" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id},</if> |
| | | <if test="host != null">#{host},</if> |
| | | <if test="tubeId != null">#{tubeId},</if> |
| | | <if test="tubeName != null">#{tubeName},</if> |
| | | <if test="tubeType != null">#{tubeType},</if> |
| | | <if test="pipeDiameter != null">#{pipeDiameter},</if> |
| | | <if test="color != null">#{color},</if> |
| | | <if test="position != null">#{position},</if> |
| | | <if test="type != null">#{type},</if> |
| | | <if test="alarmType != null">#{alarmType},</if> |
| | | <if test="alarmTime != null">#{alarmTime},</if> |
| | | <if test="watcher != null">#{watcher},</if> |
| | | <if test="createTime != null">#{createTime},</if> |
| | | <if test="viewTime != null">#{viewTime},</if> |
| | | </trim> |
| | | </insert> |
| | | |
| | | <update id="updateArdAlarmTube" parameterType="ArdAlarmTube"> |
| | | update ard_alarm_tube |
| | | <trim prefix="SET" suffixOverrides=","> |
| | | <if test="host != null">host = #{host},</if> |
| | | <if test="tubeId != null">tube_id = #{tubeId},</if> |
| | | <if test="tubeName != null">tube_name = #{tubeName},</if> |
| | | <if test="tubeType != null">tube_type = #{tubeType},</if> |
| | | <if test="pipeDiameter != null">pipe_diameter = #{pipeDiameter},</if> |
| | | <if test="color != null">color = #{color},</if> |
| | | <if test="position != null">position = #{position},</if> |
| | | <if test="type != null">type = #{type},</if> |
| | | <if test="alarmType != null">alarm_type = #{alarmType},</if> |
| | | <if test="alarmTime != null">alarm_time = #{alarmTime},</if> |
| | | <if test="watcher != null">watcher = #{watcher},</if> |
| | | <if test="createTime != null">create_time = #{createTime},</if> |
| | | <if test="viewTime != null">view_time = #{viewTime},</if> |
| | | </trim> |
| | | where id = #{id} |
| | | </update> |
| | | |
| | | <delete id="deleteArdAlarmTubeById" parameterType="String"> |
| | | delete from ard_alarm_tube where id = #{id} |
| | | </delete> |
| | | |
| | | <delete id="deleteArdAlarmTubeByIds" parameterType="String"> |
| | | delete from ard_alarm_tube where id in |
| | | <foreach item="id" collection="array" open="(" separator="," close=")"> |
| | | #{id} |
| | | </foreach> |
| | | </delete> |
| | | </mapper> |
| | |
| | | </select> |
| | | <select id="selectArdTubesDetailsByReelNumber" parameterType="String" resultMap="ArdTubesDetailsResult"> |
| | | <include refid="selectArdTubesDetailsVo"/> |
| | | where reel_number = #{reelNumber} and tube_id=#{tubeId} |
| | | where reel_number = #{reelNumber} |
| | | </select> |
| | | <insert id="insertArdTubesDetails" parameterType="ArdTubesDetails"> |
| | | insert into ard_tubes_details |
| | |
| | | </resultMap> |
| | | |
| | | <sql id="selectArdVideoInspectRecordVo"> |
| | | select id, start_time, end_time, record_file_path, step_id, dept_id, user_id from ard_video_inspect_record |
| | | select id, start_time, end_time, record_file_path, step_id, dept_id, user_id,well_name from ard_video_inspect_record |
| | | </sql> |
| | | |
| | | <select id="selectArdVideoInspectRecordList" parameterType="ArdVideoInspectRecord" resultMap="ArdVideoInspectRecordResult"> |
| | |
| | | <if test="startTime != null and startTime != ''">and start_time like ('${startTime}%')</if> |
| | | <if test="stepId != null and stepId != ''">and step_id = #{stepId}</if> |
| | | </where> |
| | | |
| | | order by start_time desc |
| | | </select> |
| | | <!--ææä»½ç»è®¡æä»¶æ°é--> |
| | | <select id="selectArdVideoInspectRecordCountByStartMonth" parameterType="String" resultType="java.util.HashMap"> |
| | |
| | | connect-timeout: 3000 # è¿æ¥è¶
æ¶æ¶é´ï¼åä½ä¸ºæ¯«ç§, é»è®¤å¼ä¸º2000 |
| | | retry-count: 0 # 请æ±å¤±è´¥åéè¯æ¬¡æ°ï¼é»è®¤ä¸º0次ä¸éè¯ |
| | | ssl-protocol: SSLv3 # ååéªè¯çHTTPSçé»è®¤SSLåè®®ï¼é»è®¤ä¸ºSSLv3 |
| | | logEnabled: true # æå¼æå
³éæ¥å¿ï¼é»è®¤ä¸ºtrue |
| | | logEnabled: true # æå¼æå
³éæ¥å¿ï¼é»è®¤ä¸ºtrue |
| | | #mqtt |
| | | mqtt: |
| | | host: tcp://192.168.1.15:1883 |
| | | clientId: m3 |
| | | username: admin |
| | | password: xzx12345 |
| | | topic: tube |
| | | timeout: 100 |
| | | keepalive: 60 |
| | | enabled: true |
| | |
| | | druid: |
| | | # ä¸»åºæ°æ®æº |
| | | master: |
| | | url: jdbc:postgresql://111.40.46.199:15432/ry-vue?stringtype=unspecified |
| | | username: postgres |
| | | password: Yykj.2021 |
| | | # url: jdbc:postgresql://127.0.0.1:5432/ry-vue?stringtype=unspecified |
| | | # url: jdbc:postgresql://111.40.46.199:15432/ry-vue?stringtype=unspecified |
| | | # username: postgres |
| | | # password: postgres |
| | | # password: Yykj.2021 |
| | | url: jdbc:postgresql://192.168.1.15:5432/ry-vue?stringtype=unspecified |
| | | username: postgres |
| | | password: postgres |
| | | # ä»åºæ°æ®æº |
| | | slave: |
| | | # 仿°æ®æºå¼å
³/é»è®¤å
³é |
| | |
| | | # æ¥å¿é
ç½® |
| | | logging: |
| | | level: |
| | | com.ruoyi.inspect: debug |
| | | com.ruoyi.inspect: info |
| | | org.springframework: warn |
| | | |
| | | # ç¨æ·é
ç½® |
| | |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | <!--mqttæ¥å¿è¾åº--> |
| | | <appender name="mqtt" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/mqtt.log</file> |
| | | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> |
| | | <!--æå¤©åæ»daily--> |
| | | <fileNamePattern>${log.path}/mqtt.%d{yyyy-MM-dd}.log</fileNamePattern> |
| | | <!--æ¥å¿æå¤§çåå²60天--> |
| | | <maxHistory>60</maxHistory> |
| | | </rollingPolicy> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | </encoder> |
| | | </appender> |
| | | <!--PatrolInspectionTaskæ¥å¿è¾åº--> |
| | | <appender name="PatrolInspectionTask" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | | <file>${log.path}/PatrolInspectionTask.log</file> |
| | |
| | | <logger name="websocket" level="INFO"> |
| | | <appender-ref ref="websocket"/> |
| | | </logger> |
| | | <!--websocketæ¥å¿æå°ç级--> |
| | | <!--å
çµå·¡æ£æ¥å¿æå°ç级--> |
| | | <logger name="PatrolInspectionTask" level="INFO"> |
| | | <appender-ref ref="PatrolInspectionTask"/> |
| | | </logger> |
| | | <!--mqttæ¥å¿æå°ç级--> |
| | | <logger name="mqtt" level="INFO"> |
| | | <appender-ref ref="mqtt"/> |
| | | </logger> |
| | | </configuration> |
| | |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.AfterReturning; |
| | | import org.aspectj.lang.annotation.AfterThrowing; |
| | |
| | | |
| | | /** |
| | | * æä½æ¥å¿è®°å½å¤ç |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Aspect |
| | | @Component |
| | | public class LogAspect |
| | | { |
| | | public class LogAspect { |
| | | private static final Logger log = LoggerFactory.getLogger(LogAspect.class); |
| | | |
| | | /** æé¤ææå±æ§å段 */ |
| | | public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" }; |
| | | /** |
| | | * æé¤ææå±æ§å段 |
| | | */ |
| | | public static final String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"}; |
| | | |
| | | /** |
| | | * å¤çå®è¯·æ±åæ§è¡ |
| | |
| | | * @param joinPoint åç¹ |
| | | */ |
| | | @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult") |
| | | public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) |
| | | { |
| | | public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) { |
| | | handleLog(joinPoint, controllerLog, null, jsonResult); |
| | | } |
| | | |
| | | /** |
| | | * æ¦æªå¼å¸¸æä½ |
| | | * |
| | | * |
| | | * @param joinPoint åç¹ |
| | | * @param e å¼å¸¸ |
| | | * @param e å¼å¸¸ |
| | | */ |
| | | @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e") |
| | | public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) |
| | | { |
| | | public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) { |
| | | handleLog(joinPoint, controllerLog, e, null); |
| | | } |
| | | |
| | | protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) |
| | | { |
| | | try |
| | | { |
| | | protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) { |
| | | try { |
| | | // è·åå½åçç¨æ· |
| | | LoginUser loginUser = SecurityUtils.getLoginUser(); |
| | | |
| | |
| | | String ip = IpUtils.getIpAddr(ServletUtils.getRequest()); |
| | | operLog.setOperIp(ip); |
| | | operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255)); |
| | | if (loginUser != null) |
| | | { |
| | | if (loginUser != null) { |
| | | operLog.setOperName(loginUser.getUsername()); |
| | | } |
| | | |
| | | if (e != null) |
| | | { |
| | | if (e != null) { |
| | | operLog.setStatus(BusinessStatus.FAIL.ordinal()); |
| | | operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000)); |
| | | } |
| | |
| | | // å¤ç设置注解ä¸çåæ° |
| | | getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult); |
| | | //å¤æç¶æç |
| | | Map resultMap=(Map)jsonResult; |
| | | if(resultMap.get("code").equals(500)) |
| | | { |
| | | operLog.setStatus(BusinessStatus.FAIL.ordinal()); |
| | | Map resultMap = (Map) jsonResult; |
| | | if (StringUtils.isNotNull(resultMap)) { |
| | | if (resultMap.get("code").equals(500)) { |
| | | operLog.setStatus(BusinessStatus.FAIL.ordinal()); |
| | | } |
| | | } |
| | | // ä¿åæ°æ®åº |
| | | AsyncManager.me().execute(AsyncFactory.recordOper(operLog)); |
| | | } |
| | | catch (Exception exp) |
| | | { |
| | | } catch (Exception exp) { |
| | | // è®°å½æ¬å°å¼å¸¸æ¥å¿ |
| | | log.error("å¼å¸¸ä¿¡æ¯:{}", exp.getMessage()); |
| | | exp.printStackTrace(); |
| | |
| | | |
| | | /** |
| | | * è·å注解ä¸å¯¹æ¹æ³çæè¿°ä¿¡æ¯ ç¨äºController屿³¨è§£ |
| | | * |
| | | * @param log æ¥å¿ |
| | | * |
| | | * @param log æ¥å¿ |
| | | * @param operLog æä½æ¥å¿ |
| | | * @throws Exception |
| | | */ |
| | | public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception |
| | | { |
| | | public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception { |
| | | // 设置actionå¨ä½ |
| | | operLog.setBusinessType(log.businessType().ordinal()); |
| | | // 设置æ é¢ |
| | |
| | | // 设置æä½äººç±»å« |
| | | operLog.setOperatorType(log.operatorType().ordinal()); |
| | | // æ¯å¦éè¦ä¿årequestï¼åæ°åå¼ |
| | | if (log.isSaveRequestData()) |
| | | { |
| | | if (log.isSaveRequestData()) { |
| | | // è·ååæ°çä¿¡æ¯ï¼ä¼ å
¥å°æ°æ®åºä¸ã |
| | | setRequestValue(joinPoint, operLog); |
| | | } |
| | | // æ¯å¦éè¦ä¿åresponseï¼åæ°åå¼ |
| | | if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) |
| | | { |
| | | if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) { |
| | | operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * è·å请æ±çåæ°ï¼æ¾å°logä¸ |
| | | * |
| | | * |
| | | * @param operLog æä½æ¥å¿ |
| | | * @throws Exception å¼å¸¸ |
| | | */ |
| | | private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception |
| | | { |
| | | private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog) throws Exception { |
| | | String requestMethod = operLog.getRequestMethod(); |
| | | if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) |
| | | { |
| | | if (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)) { |
| | | String params = argsArrayToString(joinPoint.getArgs()); |
| | | operLog.setOperParam(StringUtils.substring(params, 0, 2000)); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest()); |
| | | operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter()), 0, 2000)); |
| | | } |
| | |
| | | /** |
| | | * åæ°æ¼è£
|
| | | */ |
| | | private String argsArrayToString(Object[] paramsArray) |
| | | { |
| | | private String argsArrayToString(Object[] paramsArray) { |
| | | String params = ""; |
| | | if (paramsArray != null && paramsArray.length > 0) |
| | | { |
| | | for (Object o : paramsArray) |
| | | { |
| | | if (StringUtils.isNotNull(o) && !isFilterObject(o)) |
| | | { |
| | | try |
| | | { |
| | | if (paramsArray != null && paramsArray.length > 0) { |
| | | for (Object o : paramsArray) { |
| | | if (StringUtils.isNotNull(o) && !isFilterObject(o)) { |
| | | try { |
| | | String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter()); |
| | | params += jsonObj.toString() + " "; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | } |
| | |
| | | /** |
| | | * å¿½ç¥ææå±æ§ |
| | | */ |
| | | public PropertyPreExcludeFilter excludePropertyPreFilter() |
| | | { |
| | | public PropertyPreExcludeFilter excludePropertyPreFilter() { |
| | | return new PropertyPreExcludeFilter().addExcludes(EXCLUDE_PROPERTIES); |
| | | } |
| | | |
| | | /** |
| | | * 夿æ¯å¦éè¦è¿æ»¤ç对象ã |
| | | * |
| | | * |
| | | * @param o 对象信æ¯ã |
| | | * @return 妿æ¯éè¦è¿æ»¤ç对象ï¼åè¿åtrueï¼å¦åè¿åfalseã |
| | | */ |
| | | @SuppressWarnings("rawtypes") |
| | | public boolean isFilterObject(final Object o) |
| | | { |
| | | public boolean isFilterObject(final Object o) { |
| | | Class<?> clazz = o.getClass(); |
| | | if (clazz.isArray()) |
| | | { |
| | | if (clazz.isArray()) { |
| | | return clazz.getComponentType().isAssignableFrom(MultipartFile.class); |
| | | } |
| | | else if (Collection.class.isAssignableFrom(clazz)) |
| | | { |
| | | } else if (Collection.class.isAssignableFrom(clazz)) { |
| | | Collection collection = (Collection) o; |
| | | for (Object value : collection) |
| | | { |
| | | for (Object value : collection) { |
| | | return value instanceof MultipartFile; |
| | | } |
| | | } |
| | | else if (Map.class.isAssignableFrom(clazz)) |
| | | { |
| | | } else if (Map.class.isAssignableFrom(clazz)) { |
| | | Map map = (Map) o; |
| | | for (Object value : map.entrySet()) |
| | | { |
| | | for (Object value : map.entrySet()) { |
| | | Map.Entry entry = (Map.Entry) value; |
| | | return entry.getValue() instanceof MultipartFile; |
| | | } |