Przeglądaj źródła

显示用户当天的所以报警内容

李天标 5 lat temu
rodzic
commit
da1f20b016

+ 13 - 1
src/main/java/com/shawn/model/dto/TEquipmentDTO.java

@@ -1,6 +1,7 @@
 package com.shawn.model.dto;
 
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.shawn.model.entity.TAlarmRecord;
 import com.shawn.model.entity.TEquipment;
 import com.shawn.util.DateUtils;
 import io.swagger.annotations.ApiModelProperty;
@@ -12,21 +13,32 @@ import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
 import java.util.Date;
+import java.util.List;
 
 @Accessors(chain = true)
 @NoArgsConstructor
 @ToString
 public class TEquipmentDTO extends TEquipment {
-
+    @ApiModelProperty(value="所以报警信息")
+    private List<TAlarmRecord> alarmList;
     @ApiModelProperty(value="最新报警信息")
     private String alarmContent = "暂无数据";
 
     @ApiModelProperty(value="当天是否存在告警")
     private boolean hasTodayAlarm= false;
 
+    public List<TAlarmRecord> getAlarmList() {
+        return alarmList;
+    }
+
+    public void setAlarmList(List<TAlarmRecord> alarmList) {
+        this.alarmList = alarmList;
+    }
+
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
     @ApiModelProperty(value="报警发生时间")
+
     private Date occurrenceTime;
 
     public String getAlarmContent() {

+ 1 - 0
src/main/java/com/shawn/repository/TAlarmRecordMapper.java

@@ -16,4 +16,5 @@ import java.util.List;
 public interface TAlarmRecordMapper extends BaseDaoInterface<TAlarmRecord,TAlarmRecordExample,TAlarmRecordParam, Long>{
 
     public List<TAlarmRecord> getLastAlarmRecord(@Param("adminId") Long adminId);
+    public List<TAlarmRecord> getAlarmList(@Param("equipmentId") Long equipmentId);
 }

+ 4 - 0
src/main/java/com/shawn/service/impl/TAlarmRecordServiceImpl.java

@@ -35,4 +35,8 @@ public class TAlarmRecordServiceImpl extends BaseService<TAlarmRecord,TAlarmReco
 	public List<TAlarmRecord> getLastAlarmRecord(Long adminId){
 		return tAlarmRecordMapper.getLastAlarmRecord(adminId);
 	}
+	@Override
+	public List<TAlarmRecord> getAlarmList(Long equipmentId){
+		return tAlarmRecordMapper.getAlarmList(equipmentId);
+	}
 }

+ 1 - 0
src/main/java/com/shawn/service/interfac/TAlarmRecordServiceInterface.java

@@ -14,4 +14,5 @@ import java.util.List;
 
 public interface TAlarmRecordServiceInterface extends BaseServiceInterface<TAlarmRecord,TAlarmRecordExample,TAlarmRecordParam,Long>{
     public List<TAlarmRecord> getLastAlarmRecord(Long clientId);
+    public List<TAlarmRecord> getAlarmList(Long clientId);
 }

+ 0 - 1
src/main/java/com/shawn/web/controller/TApkInfoController.java

@@ -39,6 +39,5 @@ public class TApkInfoController extends BaseController<TApkInfo,TApkInfoExample,
 	protected TApkInfoExample createNewExample() {
 		return new TApkInfoExample();
 	}
-	
     
 }

+ 6 - 2
src/main/java/com/shawn/web/controller/TEquipmentController.java

@@ -78,6 +78,9 @@ public class TEquipmentController extends BaseController<TEquipment,TEquipmentEx
 							if(op.isPresent()){
 								equipmentDTO.setAlarmContent(op.get().getAlarmContent());
 								equipmentDTO.setOccurrenceTime(op.get().getOccurrenceTime());
+								//获取当前用户今天所有机器的所以警报信息
+								List<TAlarmRecord> alarmList = tAlarmRecordService.getAlarmList(equipment.getId());
+								equipmentDTO.setAlarmList(alarmList);
 							}
 							return equipmentDTO;
 						}).collect(Collectors.toList());
@@ -92,7 +95,6 @@ public class TEquipmentController extends BaseController<TEquipment,TEquipmentEx
 			criteria.andAdminIdEqualTo(param.getId());
 			List<TEquipment> equipmentList = tEquipmentService.selectByOption(example);
 			List<TAlarmRecord> alarmRecordList = tAlarmRecordService.getLastAlarmRecord(param.getId());
-
 			List<TEquipmentDTO> equipmentDTOList = equipmentList.stream().map(equipment -> {
 				TEquipmentDTO equipmentDTO = new TEquipmentDTO();
 				BeanUtils.copyPropertiesIgnoreNull(equipment,equipmentDTO,true);
@@ -100,7 +102,9 @@ public class TEquipmentController extends BaseController<TEquipment,TEquipmentEx
 				if(op.isPresent()){
 					equipmentDTO.setAlarmContent(op.get().getAlarmContent());
 					equipmentDTO.setOccurrenceTime(op.get().getOccurrenceTime());
-
+					//获取当前用户今天所有机器的所以警报信息
+					List<TAlarmRecord> alarmList = tAlarmRecordService.getAlarmList(equipment.getId());
+					equipmentDTO.setAlarmList(alarmList);
 				}
 				return equipmentDTO;
 			}).collect(Collectors.toList());

+ 10 - 0
src/main/resources/com/shawn/repository/mybatis/TAlarmRecordMapper.xml

@@ -475,4 +475,14 @@
   tab1 where b.client_id = tab1.client_id and b.create_date = tab1.create_date
   )
   </select>
+  <!-- 获取今天所有机器全部警告-->
+  <select id="getAlarmList" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    SELECT * FROM
+	t_alarm_record a
+    where 1=1
+    <if test="equipmentId != null and equipmentId !=''">
+      and a.equipment_id = #{equipmentId}
+    </if>
+    AND date_format(a.create_date, '%Y-%m-%d') = date_format(now(), '%Y-%m-%d')
+  </select>
 </mapper>