添加了根据报警编码查询报警类型的功能模块

This commit is contained in:
XinYi Song 2022-02-18 14:19:57 +08:00
parent 8b78e05d27
commit 1790e32ecf
3 changed files with 113 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tools.GetTokenTool; import com.xkrs.common.tools.GetTokenTool;
import com.xkrs.common.tools.GetVideoTool; import com.xkrs.common.tools.GetVideoTool;
import com.xkrs.common.tools.JackSonTool; import com.xkrs.common.tools.JackSonTool;
import com.xkrs.dao.AlarmDao;
import com.xkrs.dao.EquipmentDao; import com.xkrs.dao.EquipmentDao;
import com.xkrs.model.entity.Equipment; import com.xkrs.model.entity.Equipment;
import com.xkrs.util.DateTimeUtil; import com.xkrs.util.DateTimeUtil;
@ -28,6 +29,9 @@ public class EquipmentController {
@Resource @Resource
private EquipmentDao equipmentDao; private EquipmentDao equipmentDao;
@Resource
private AlarmDao alarmDao;
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
/*@GetMapping("/getEquipment") /*@GetMapping("/getEquipment")
@ -192,4 +196,18 @@ public class EquipmentController {
} }
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS, maps, locale);
} }
/**
* 根据报警编码查询报警类型
* @param alarmCode
* @return
*/
@GetMapping("/findAlarmTypeByCode")
public String findAlarmTypeByCode(@RequestParam("alarmCode") String alarmCode){
String alarmTypeByCode = alarmDao.findAlarmTypeByCode(alarmCode);
if(alarmTypeByCode == null || "".equals(alarmTypeByCode)){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时没有该编号的报警类型!", locale);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, alarmTypeByCode, locale);
}
} }

View File

@ -0,0 +1,22 @@
package com.xkrs.dao;
import com.xkrs.model.entity.Alarm;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;
/**
* @Author: XinYi Song
* @Date: 2022/2/18 11:58
*/
@Component
public interface AlarmDao extends JpaRepository<Alarm,Long> {
/**
* 根据报警编号查询报警类型
* @param code
* @return
*/
@Query(value = "select alarm_type from alarm where alarm_code = ?",nativeQuery = true)
String findAlarmTypeByCode(String code);
}

View File

@ -0,0 +1,73 @@
package com.xkrs.model.entity;
import javax.persistence.*;
/**
* @Author: XinYi Song
* @Date: 2022/2/18 11:37
*/
@Entity
@Table(name = "alarm")
public class Alarm {
/**
* 主键id
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "alarm_seq_gen")
@SequenceGenerator(name = "alarm_seq_gen", sequenceName = "alarm_id_seq",allocationSize = 1)
private Integer id;
/**
* 报警类型
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String alarmType;
/**
* 报警编码
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String alarmCode;
public Alarm() {
}
public Alarm(Integer id, String alarmType, String alarmCode) {
this.id = id;
this.alarmType = alarmType;
this.alarmCode = alarmCode;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getAlarmType() {
return alarmType;
}
public void setAlarmType(String alarmType) {
this.alarmType = alarmType;
}
public String getAlarmCode() {
return alarmCode;
}
public void setAlarmCode(String alarmCode) {
this.alarmCode = alarmCode;
}
@Override
public String toString() {
return "Alarm{" +
"id=" + id +
", alarmType='" + alarmType + '\'' +
", alarmCode='" + alarmCode + '\'' +
'}';
}
}