wangxiaofei 2 недель назад
Родитель
Сommit
db78a57587

+ 24 - 3
taphole-iron/src/main/java/com/sckj/iron/controller/TIronVisualScreenController.java

@@ -1,11 +1,14 @@
 package com.sckj.iron.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.sckj.common.aop.Log;
 import com.sckj.common.aop.NotLogin;
 import com.sckj.common.aop.NotPower;
 import com.sckj.common.core.AjaxResult;
+import com.sckj.common.entity.setting.DictData;
+import com.sckj.common.mapper.setting.DictDataMapper;
 import com.sckj.device.validate.TCameraUpdateDTO;
 import com.sckj.iron.dto.*;
 import com.sckj.iron.entity.TIronParam;
@@ -85,6 +88,10 @@ public class TIronVisualScreenController {
     TIronVisualScreenServiceImpl tIronVisualScreenService;
 
 
+    @Resource
+    DictDataMapper dictDataMapper;
+
+
     private static final int DATA_COUNT = 6;
     @Autowired
     private L2Properties l2Properties;
@@ -269,7 +276,15 @@ public class TIronVisualScreenController {
     @PostMapping("/queryIronExceptionData")
     @ApiOperation(value = "查询告警列表数据")
     public AjaxResult<TableDataInfo<TExceptionLogDTO>> queryIronExceptionData(@RequestBody TIronExceptionSearchScreenValidate ironDataSearchScreenValidate) {
-        List<TExceptionLogDTO> ironDataList = exceptionLogService.queryIronExceptionData(ironDataSearchScreenValidate);
+        List<DictData> dictDataList = dictDataMapper.selectList((new QueryWrapper<DictData>().lambda().eq(DictData::getTypeId, 12).eq(DictData::getIsDelete, 0)));
+        Map<String,String>  map = dictDataList.stream().collect((Collectors.toMap(
+                DictData::getValue, // 键映射函数
+                DictData::getName, // 键映射函数
+                (existingValue, newValue) -> existingValue  // 合并策略:保留第一个值
+        )));
+
+        PageHelper.startPage(ironDataSearchScreenValidate.getPageNo(), ironDataSearchScreenValidate.getPageSize());
+        List<TExceptionLogDTO> ironDataList = exceptionLogService.queryIronExceptionData(ironDataSearchScreenValidate,map);
         PageInfo pageInfo = new PageInfo(ironDataList);
         TableDataInfo<TExceptionLogDTO> tableDataInfo = new TableDataInfo<>();
         BeanUtils.copyProperties(pageInfo, tableDataInfo);
@@ -280,14 +295,20 @@ public class TIronVisualScreenController {
     @PostMapping("/exportExceptionData")
     @ApiOperation(value = "导出告警列表数据")
     public void exportIronExceptionData(@RequestBody TIronExceptionSearchScreenValidate ironDataSearchScreenValidate, HttpServletResponse response) throws IOException {
-        exceptionLogService.exportIronExceptionData(ironDataSearchScreenValidate, response);
+        List<DictData> dictDataList = dictDataMapper.selectList((new QueryWrapper<DictData>().lambda().eq(DictData::getTypeId, 12).eq(DictData::getIsDelete, 0)));
+        Map<String,String>  map = dictDataList.stream().collect((Collectors.toMap(
+                DictData::getValue, // 键映射函数
+                DictData::getName, // 键映射函数
+                (existingValue, newValue) -> existingValue  // 合并策略:保留第一个值
+        )));
+        exceptionLogService.exportIronExceptionData(ironDataSearchScreenValidate,map, response);
     }
 
     @NotPower
     @PostMapping("/queryIronTestData")
     @ApiOperation(value = "查询诊断数据")
     public AjaxResult<TableDataInfo<TIronTestDTO>> queryIronTestData(@RequestBody TIronTestSearchScreenValidate ironDataSearchScreenValidate) {
-
+        PageHelper.startPage(ironDataSearchScreenValidate.getPageNo(), ironDataSearchScreenValidate.getPageSize());
         List<TIronTestDTO> ironDataList = iTIronTestService.queryIronTestData(ironDataSearchScreenValidate);
         PageInfo pageInfo = new PageInfo(ironDataList);
         TableDataInfo<TIronTestDTO> tableDataInfo = new TableDataInfo<>();

+ 1 - 0
taphole-iron/src/main/java/com/sckj/iron/entity/TIronTest.java

@@ -90,6 +90,7 @@ public class TIronTest implements Serializable {
     private String createTime;
 
     @ApiModelProperty(value = "实时出铁编号")
+    @ExcelIgnore
     private String ironDataId;
 
 }

+ 6 - 4
taphole-iron/src/main/java/com/sckj/iron/service/impl/TIronTestServiceImpl.java

@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.github.pagehelper.PageHelper;
 import com.sckj.common.core.PageResult;
 import com.sckj.common.exception.OperateException;
-import com.sckj.common.util.*;
+import com.sckj.common.util.ExcelUtils;
+import com.sckj.common.util.GsonUtils;
+import com.sckj.common.util.LocalDateUtils;
+import com.sckj.common.util.StringUtils;
 import com.sckj.common.validate.commons.PageValidate;
 import com.sckj.iron.constant.ParamsConstants;
 import com.sckj.iron.dto.IronTestItem;
@@ -188,7 +190,7 @@ public class TIronTestServiceImpl extends ServiceImpl<TIronTestMapper, TIronTest
         if (StringUtils.isNotBlank(tl2Data.getCreateTimeStart()) && StringUtils.isNotBlank(tl2Data.getCreateTimeEnd())) {
             queryWrapper.lambda().between(TIronTest::getCreateTime, tl2Data.getCreateTimeStart(), tl2Data.getCreateTimeEnd());
         }
-        PageHelper.startPage(tl2Data.getPageNo(), tl2Data.getPageSize());
+
         // 使用Java 8 lambda表达式进行数据转换
         return list(queryWrapper)
                 .stream()
@@ -211,7 +213,7 @@ public class TIronTestServiceImpl extends ServiceImpl<TIronTestMapper, TIronTest
             throw new OperateException("导出请选择开始时间和结束时间!");
         }
         List<TIronTestDTO> tl2DataList = queryIronTestData(tl2Data);
-        ExcelUtils.exportExcel(tl2DataList, TIronTest.class, "诊断列表数据", "诊断列表数据", response);
+        ExcelUtils.exportExcel(tl2DataList, TIronTestDTO.class, "诊断列表数据", "诊断列表数据", response);
     }
 
 

+ 5 - 8
taphole-iron/src/main/java/com/sckj/iron/socketio/DeviceEventListener.java

@@ -54,7 +54,6 @@ import java.io.File;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
-import java.time.ZoneId;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
@@ -1596,7 +1595,7 @@ public class DeviceEventListener extends AbstractEventListener { //
                 log.info("📊 诊断结果汇总:");
                 log.info("   正常指标数: {}/4", ironNormalCount);
                 log.info("   整体状态: {}", "1".equals(testStatus) ? "优秀" : "异常");
-                log.info("   详细诊断: {}", sb.toString());
+                log.info("   详细诊断: {}", sb);
 
                 boolean saveResult = iTIronTestService.save(ironTest);
                 log.info("💾 诊断结果保存{} - 记录ID: {}", saveResult ? "成功" : "失败", ironTest.getId());
@@ -1712,12 +1711,10 @@ public class DeviceEventListener extends AbstractEventListener { //
                                     mTIronData.setId(tappingInfo.getIronDataId());
 
                                     LocalDateTime now = LocalDateTime.now();
-                                    long localDateTimeMillis = now
-                                            .atZone(ZoneId.systemDefault())
-                                            .toInstant()
-                                            .toEpochMilli();
-                                    long diffInSeconds = (localDateTimeMillis - tappingInfo.getSourceTime().getTime()) / 1000;
-                                    mSecondsElapsed.addAndGet((int) diffInSeconds);
+                                    long currentTimeMillis = System.currentTimeMillis();
+                                    long diffInSeconds = (currentTimeMillis - tappingInfo.getSourceTime().getTime()) / 1000;
+                                    //长整数到整数的转换,防止溢出
+                                    mSecondsElapsed.addAndGet(Math.toIntExact(diffInSeconds));
 
                                     try {
                                         mTotalCloseTime = (int) RedisUtils.getFixedLatestElement(RedisConstants.TOTAL_CLOSE_TIME);

+ 7 - 8
taphole-l2/src/main/java/com/sckj/l2/service/impl/TL2DataServiceImpl.java

@@ -50,9 +50,9 @@ public class TL2DataServiceImpl extends ServiceImpl<TL2DataMapper, TL2Data> {
         Integer limit = pageValidate.getPageSize();
 
         QueryWrapper<TL2Data> queryWrapper = new QueryWrapper<>();
-        if(ObjectUtils.isNotEmpty(searchValidate.getIronStarttime()) && ObjectUtils.isNotEmpty(searchValidate.getIronEndtime())){
-            queryWrapper.ge("iron_starttime", searchValidate.getIronStarttime().replace("-","").replace(":","").replace(" ",""));
-            queryWrapper.le("iron_endtime",  searchValidate.getIronEndtime().replace("-","").replace(":","").replace(" ",""));
+        if (ObjectUtils.isNotEmpty(searchValidate.getIronStarttime()) && ObjectUtils.isNotEmpty(searchValidate.getIronEndtime())) {
+            queryWrapper.ge("iron_starttime", searchValidate.getIronStarttime().replace("-", "").replace(":", "").replace(" ", ""));
+            queryWrapper.le("iron_endtime", searchValidate.getIronEndtime().replace("-", "").replace(":", "").replace(" ", ""));
         }
         queryWrapper.lambda().orderByDesc(TL2Data::getIronNo);
 
@@ -100,9 +100,9 @@ public class TL2DataServiceImpl extends ServiceImpl<TL2DataMapper, TL2Data> {
      * @param tapholeId 铁口号(1 2 3 4),传空表示最新2条数据
      * @return
      */
-    public List<TL2Data> getLatestTwoDatas(String...tapholeId) {
+    public List<TL2Data> getLatestTwoDatas(String... tapholeId) {
         LambdaQueryWrapper<TL2Data> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(ObjectUtils.isNotEmpty(tapholeId),TL2Data::getTapholeId,tapholeId[0]).isNotNull(TL2Data::getIronNo).isNotNull(TL2Data::getIronWeight).isNotNull(TL2Data::getCalcWeight).orderByDesc(TL2Data::getIronNo).last("limit 2");
+        queryWrapper.eq(ObjectUtils.isNotEmpty(tapholeId) && tapholeId.length > 0, TL2Data::getTapholeId, ObjectUtils.isNotEmpty(tapholeId) && tapholeId.length > 0 ? tapholeId[0] : null).isNotNull(TL2Data::getIronNo).isNotNull(TL2Data::getIronWeight).isNotNull(TL2Data::getCalcWeight).orderByDesc(TL2Data::getIronNo).last("limit 2");
         List<TL2Data> list = list(queryWrapper);
         return list;
     }
@@ -113,9 +113,9 @@ public class TL2DataServiceImpl extends ServiceImpl<TL2DataMapper, TL2Data> {
      * @param tapholeId 铁口号(1 2 3 4),传空表示最新数据
      * @return
      */
-    public TL2Data getLatestData(String...tapholeId) {
+    public TL2Data getLatestData(String... tapholeId) {
         LambdaQueryWrapper<TL2Data> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(ObjectUtils.isNotEmpty(tapholeId),TL2Data::getTapholeId,tapholeId[0]).isNotNull(TL2Data::getIronNo).orderByDesc(TL2Data::getIronNo).last("limit 1");
+        queryWrapper.eq(ObjectUtils.isNotEmpty(tapholeId) && tapholeId.length > 0, TL2Data::getTapholeId, ObjectUtils.isNotEmpty(tapholeId) && tapholeId.length > 0 ? tapholeId[0] : null).isNotNull(TL2Data::getIronNo).orderByDesc(TL2Data::getIronNo).last("limit 1");
         List<TL2Data> list = list(queryWrapper);
         return ObjectUtils.isEmpty(list) ? null : list.get(0);
     }
@@ -156,7 +156,6 @@ public class TL2DataServiceImpl extends ServiceImpl<TL2DataMapper, TL2Data> {
     }
 
 
-
     /**
      * 数据统计
      *

+ 34 - 45
taphole-warn/src/main/java/com/sckj/warn/service/impl/TExceptionLogServiceImpl.java

@@ -4,12 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.github.pagehelper.PageHelper;
 import com.sckj.common.core.AjaxResult;
 import com.sckj.common.core.PageResult;
-import com.sckj.common.entity.setting.DictData;
 import com.sckj.common.exception.OperateException;
-import com.sckj.common.mapper.setting.DictDataMapper;
 import com.sckj.common.util.ExcelUtils;
 import com.sckj.common.util.StringUtils;
 import com.sckj.common.validate.commons.PageValidate;
@@ -44,10 +41,10 @@ import java.text.SimpleDateFormat;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 /**
  * 异常情况记录实现类
+ *
  * @author zhanghao
  */
 @Service
@@ -56,28 +53,25 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
     @Resource
     TExceptionLogMapper tExceptionLogMapper;
 
-    @Resource
-    DictDataMapper dictDataMapper;
-
 
     /**
      * 异常情况记录列表
      *
-     * @author zhanghao
-     * @param pageValidate 分页参数
+     * @param pageValidate   分页参数
      * @param searchValidate 搜索参数
      * @return PageResult<TExceptionLogListedVo>
+     * @author zhanghao
      */
-    
+
     public PageResult<TExceptionLogListedVo> list(PageValidate pageValidate, TExceptionLogSearchValidate searchValidate) {
-        Integer page  = pageValidate.getPageNo();
+        Integer page = pageValidate.getPageNo();
         Integer limit = pageValidate.getPageSize();
 
         QueryWrapper<TExceptionLog> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("del_flag", "1");
         queryWrapper.orderByDesc("id");
 
-        if(ObjectUtils.isNotEmpty(searchValidate.getCreateTimeStart()) && ObjectUtils.isNotEmpty(searchValidate.getCreateTimeEnd())){
+        if (ObjectUtils.isNotEmpty(searchValidate.getCreateTimeStart()) && ObjectUtils.isNotEmpty(searchValidate.getCreateTimeEnd())) {
             queryWrapper.between("create_time", searchValidate.getCreateTimeStart(), searchValidate.getCreateTimeEnd());
         }
 
@@ -92,15 +86,15 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
         "datetime:updateTimeStart-updateTimeEnd@update_time:str",*/
 
         tExceptionLogMapper.setSearch(queryWrapper, searchValidate, new String[]{
-            "=:exceptionType@exception_type:int",
-            "=:exceptionArea@exception_area:str",
-            "=:exceptionLevel@exception_level:str",
+                "=:exceptionType@exception_type:int",
+                "=:exceptionArea@exception_area:str",
+                "=:exceptionLevel@exception_level:str",
         });
 
         IPage<TExceptionLog> iPage = tExceptionLogMapper.selectPage(new Page<>(page, limit), queryWrapper);
 
         List<TExceptionLogListedVo> list = new LinkedList<>();
-        for(TExceptionLog item : iPage.getRecords()) {
+        for (TExceptionLog item : iPage.getRecords()) {
             TExceptionLogListedVo vo = new TExceptionLogListedVo();
             BeanUtils.copyProperties(item, vo);
             vo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(item.getCreateTime())); //由于QueryWrapper或IPage的原因导致JsonFormat注解未生效,此处手动转换格式
@@ -113,16 +107,16 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
     /**
      * 异常情况记录详情
      *
-     * @author zhanghao
      * @param id 主键参数
      * @return TExceptionLog
+     * @author zhanghao
      */
-    
+
     public TExceptionLogDetailVo detail(Integer id) {
         TExceptionLog model = tExceptionLogMapper.selectOne(
                 new QueryWrapper<TExceptionLog>()
-                    .eq("id", id).eq("del_flag", "1")
-                    .last("limit 1"));
+                        .eq("id", id).eq("del_flag", "1")
+                        .last("limit 1"));
 
         Assert.notNull(model, "数据不存在");
 
@@ -134,10 +128,10 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
     /**
      * 异常情况记录新增
      *
-     * @author zhanghao
      * @param createValidate 参数
+     * @author zhanghao
      */
-    
+
     public void add(TExceptionLogCreateValidate createValidate) {
         TExceptionLog model = new TExceptionLog();
         model.setExceptionType(createValidate.getExceptionType());
@@ -153,15 +147,15 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
     /**
      * 异常情况记录编辑
      *
-     * @author zhanghao
      * @param updateValidate 参数
+     * @author zhanghao
      */
-    
+
     public void edit(TExceptionLogUpdateValidate updateValidate) {
         TExceptionLog model = tExceptionLogMapper.selectOne(
                 new QueryWrapper<TExceptionLog>()
-                    .eq("id",  updateValidate.getId())
-                    .last("limit 1"));
+                        .eq("id", updateValidate.getId())
+                        .last("limit 1"));
 
         Assert.notNull(model, "数据不存在!");
 
@@ -171,10 +165,10 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
     /**
      * 异常情况记录删除
      *
-     * @author zhanghao
      * @param id 主键ID
+     * @author zhanghao
      */
-    
+
     public void del(Integer id) {
         TExceptionLog model = tExceptionLogMapper.selectOne(
                 new QueryWrapper<TExceptionLog>()
@@ -188,13 +182,13 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
         tExceptionLogMapper.updateById(model);
     }
 
-    
+
     public AjaxResult<Object> del_ex(List<Long> ids) {
         List<TExceptionLog> models = tExceptionLogMapper.selectList(
                 new QueryWrapper<TExceptionLog>()
                         .in("id", ids));
 
-        if (CollectionUtils.isEmpty(models)){
+        if (CollectionUtils.isEmpty(models)) {
             return AjaxResult.failed("数据不存在");
         }
         TExceptionLog model = new TExceptionLog();
@@ -206,8 +200,8 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
     /**
      * 异常情况记录导出
      *
-     * @author zhanghao
      * @param searchValidate 搜索参数·
+     * @author zhanghao
      */
     public ByteArrayOutputStream exportTExceptionLog(TExceptionLogSearchValidate searchValidate) {
         Workbook workbook = new XSSFWorkbook();
@@ -256,16 +250,17 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
      * 查询预警统计
      * @return
      */
-    public List<WarnDTO> selectWarnStats(){
+    public List<WarnDTO> selectWarnStats() {
         return tExceptionLogMapper.selectWarnStats();
     }
 
     /**
      * 异常统计
+     *
      * @param searchValidate
      * @param response
      */
-    public void exportExceptionLogList(TExceptionLogSearchValidate searchValidate, HttpServletResponse response){
+    public void exportExceptionLogList(TExceptionLogSearchValidate searchValidate, HttpServletResponse response) {
         List<TExceptionLogExportVo> tExceptionLogExportVos = tExceptionLogMapper.exportExceptionLogList();
         try {
             ExcelUtils.exportExcel(tExceptionLogExportVos, TExceptionLogExportVo.class, "异常统计", "异常统计", response);
@@ -279,7 +274,7 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
      * @return
      */
     public TExceptionLog getLatest() {
-        return this.lambdaQuery().orderByDesc(TExceptionLog::getCreateTime).list().stream().findFirst().orElseThrow(()->new OperateException("未查询到数据"));
+        return this.lambdaQuery().orderByDesc(TExceptionLog::getCreateTime).list().stream().findFirst().orElseThrow(() -> new OperateException("未查询到数据"));
     }
 
 
@@ -297,7 +292,7 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
      * 查询出铁数据
      * @return
      */
-    public List<TExceptionLogDTO> queryIronExceptionData(TIronExceptionSearchScreenValidate tl2Data) {
+    public List<TExceptionLogDTO> queryIronExceptionData(TIronExceptionSearchScreenValidate tl2Data, Map<String, String> map) {
         QueryWrapper<TExceptionLog> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda()
                 .like(ObjectUtils.isNotEmpty(tl2Data.getExceptionDesc()), TExceptionLog::getExceptionDesc, tl2Data.getExceptionDesc())
@@ -308,13 +303,7 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
         if (StringUtils.isNotBlank(tl2Data.getCreateTimeStart()) && StringUtils.isNotBlank(tl2Data.getCreateTimeEnd())) {
             queryWrapper.lambda().between(TExceptionLog::getCreateTime, tl2Data.getCreateTimeStart(), tl2Data.getCreateTimeEnd());
         }
-        List<DictData> dictDataList = dictDataMapper.selectList((new QueryWrapper<DictData>().lambda().eq(DictData::getTypeId, 12).eq(DictData::getIsDelete, 0)));
-        Map<String,String>  map = dictDataList.stream().collect((Collectors.toMap(
-               DictData::getValue, // 键映射函数
-               DictData::getName, // 键映射函数
-            (existingValue, newValue) -> existingValue  // 合并策略:保留第一个值
-       )));
-        PageHelper.startPage(tl2Data.getPageNo(), tl2Data.getPageSize());
+
         // 使用Java 8 lambda表达式进行数据转换
         return list(queryWrapper)
                 .stream()
@@ -333,14 +322,14 @@ public class TExceptionLogServiceImpl extends ServiceImpl<TExceptionLogMapper, T
      * @param response
      * @throws IOException
      */
-    public void exportIronExceptionData(TIronExceptionSearchScreenValidate tl2Data, HttpServletResponse response) throws IOException {
+    public void exportIronExceptionData(TIronExceptionSearchScreenValidate tl2Data, Map<String, String> map, HttpServletResponse response) throws IOException {
         if (ObjectUtils.isEmpty(tl2Data.getCreateTimeStart()) || ObjectUtils.isEmpty(tl2Data.getCreateTimeEnd())) {
             throw new OperateException("导出请选择开始时间和结束时间!");
         }
-        List<TExceptionLogDTO> tl2DataList = queryIronExceptionData(tl2Data);
+
+        List<TExceptionLogDTO> tl2DataList = queryIronExceptionData(tl2Data, map);
         ExcelUtils.exportExcel(tl2DataList, TExceptionLogDTO.class, "告警列表数据", "告警列表数据", response);
     }
 
 
-
 }