|
@@ -1,9 +1,15 @@
|
|
|
package com.slibra.web.controller.business;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import com.slibra.common.utils.DateUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
@@ -21,12 +27,15 @@ import com.slibra.business.service.ITXinyiWarningRecordService;
|
|
|
import com.slibra.common.utils.poi.ExcelUtil;
|
|
|
import com.slibra.common.core.page.TableDataInfo;
|
|
|
|
|
|
+import static com.slibra.common.constant.MyConstants.MAX_COUNT;
|
|
|
+
|
|
|
/**
|
|
|
* 信义告警记录Controller
|
|
|
*
|
|
|
* @author slibra
|
|
|
* @date 2024-05-17
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/business/record")
|
|
|
public class TXinyiWarningRecordController extends BaseController
|
|
@@ -43,6 +52,7 @@ public class TXinyiWarningRecordController extends BaseController
|
|
|
{
|
|
|
startPage();
|
|
|
List<TXinyiWarningRecord> list = tXinyiWarningRecordService.selectTXinyiWarningRecordList(tXinyiWarningRecord);
|
|
|
+ handleWarningCounts(list);
|
|
|
return getDataTable(list);
|
|
|
}
|
|
|
|
|
@@ -55,6 +65,7 @@ public class TXinyiWarningRecordController extends BaseController
|
|
|
public void export(HttpServletResponse response, TXinyiWarningRecord tXinyiWarningRecord)
|
|
|
{
|
|
|
List<TXinyiWarningRecord> list = tXinyiWarningRecordService.selectTXinyiWarningRecordList(tXinyiWarningRecord);
|
|
|
+ handleWarningCounts(list);
|
|
|
ExcelUtil<TXinyiWarningRecord> util = new ExcelUtil<TXinyiWarningRecord>(TXinyiWarningRecord.class);
|
|
|
util.exportExcel(response, list, "信义告警记录数据");
|
|
|
}
|
|
@@ -103,4 +114,24 @@ public class TXinyiWarningRecordController extends BaseController
|
|
|
{
|
|
|
return toAjax(tXinyiWarningRecordService.deleteTXinyiWarningRecordByIds(ids));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void handleWarningCounts(List<TXinyiWarningRecord> tXinyiWarningRecords) {
|
|
|
+ if(!CollectionUtils.isEmpty(tXinyiWarningRecords)){
|
|
|
+ for (TXinyiWarningRecord tXinyiWarningRecord : tXinyiWarningRecords) {
|
|
|
+ Date endDate = null;
|
|
|
+ //判断类型 如果结束了 截止时间就是告警截止时间; 如果正在报警 截止时间就是当前时间
|
|
|
+ if(0 == tXinyiWarningRecord.getStatus() || 3 == tXinyiWarningRecord.getStatus())
|
|
|
+ endDate = DateUtils.getNowDate();
|
|
|
+ else
|
|
|
+ endDate = tXinyiWarningRecord.getOffTime();
|
|
|
+ //防止 之前程序处理错误 理论上不再报警了,一定有截止时间的
|
|
|
+ if(Objects.isNull(endDate)){
|
|
|
+ log.error("xxxxxxxxx:之前处理告警结束的逻辑异常,没有更新截止时间");
|
|
|
+ endDate = DateUtils.getNowDate();
|
|
|
+ }
|
|
|
+ tXinyiWarningRecord.setCounts(Math.min(DateUtils.differentHoursByMillisecond(tXinyiWarningRecord.getTime(), endDate) + 1, MAX_COUNT));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|