Ver Fonte

添加设备日志查询页面

zhifei há 8 meses atrás
pai
commit
98ecc1af83
34 ficheiros alterados com 261 adições e 148 exclusões
  1. 169 114
      README.md
  2. BIN
      doc/JPG/0a9bcb9b54e0d1752a15332680377bb4.png
  3. BIN
      doc/JPG/0bc6f26c5f193bd827fe4c683ba14dc4.png
  4. BIN
      doc/JPG/0c4f4030db19740b6b5ec61a31cf8e2c.png
  5. BIN
      doc/JPG/0fc05cfb5b44cce3786c4e7cf09eb353.png
  6. BIN
      doc/JPG/107d83b23d23e88cb5b7ba22463a5e26.jpg
  7. BIN
      doc/JPG/1374189ca7adc8d6a4dd009f71120822.png
  8. BIN
      doc/JPG/2d094d391a389d8d20629c5418312d52.jpg
  9. BIN
      doc/JPG/472c3a04666ff3f01e3eac847ce7e027.png
  10. BIN
      doc/JPG/582d19df4f21873e88bf7960663c0cfc.jpg
  11. BIN
      doc/JPG/6bd886ffa2808a573b34acabd7afba80.png
  12. BIN
      doc/JPG/7231c5630d9040f896312dccd3b379f7.png
  13. BIN
      doc/JPG/75624c39157e011d403ec4f74ec53e27.jpg
  14. BIN
      doc/JPG/85bc3f3106387c042382e9e785819edf.png
  15. BIN
      doc/JPG/89dc3098c63ef01672e1ed1aa0f2b6f3.png
  16. BIN
      doc/JPG/a0679ff093fa2e4b1e9f4cd9ad22f5fc.png
  17. BIN
      doc/JPG/bdef66e6b575fde0a1aaf1702525dd16.jpg
  18. BIN
      doc/JPG/d200ff42e3f56d482ef44d9b0a195efd.jpg
  19. BIN
      doc/JPG/d5d2735bd58db060ebbb870cbe8100be.jpg
  20. BIN
      doc/JPG/d7a68a2ac8a410a14df1f264617927a0.png
  21. BIN
      doc/JPG/dcc77b1e47c524aaed4ce227497158a0.png
  22. BIN
      doc/JPG/df3d8506ad7b1acd6ea1d37d5442a72e.png
  23. BIN
      doc/JPG/e2aafb65517897167178b5ae7fd9c00c.jpg
  24. BIN
      doc/JPG/edbce68ad9a574f518a5bcc6bea2fc79.jpg
  25. 3 3
      warewms-admin/src/main/resources/application-test.yml
  26. 1 1
      warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java
  27. 13 0
      warewms-system/src/main/java/com/warewms/hailiang/controller/DeviceLogController.java
  28. 10 0
      warewms-system/src/main/java/com/warewms/hailiang/domain/DeviceLog.java
  29. 14 9
      warewms-system/src/main/java/com/warewms/hailiang/init/PlcConnectServiceRunner.java
  30. 11 11
      warewms-system/src/main/java/com/warewms/hailiang/init/TcpServiceRunner.java
  31. 4 0
      warewms-system/src/main/java/com/warewms/hailiang/service/DeviceLogService.java
  32. 17 2
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceLogServiceImpl.java
  33. 0 1
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java
  34. 19 7
      warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

Diff do ficheiro suprimidas por serem muito extensas
+ 169 - 114
README.md


BIN
doc/JPG/0a9bcb9b54e0d1752a15332680377bb4.png


BIN
doc/JPG/0bc6f26c5f193bd827fe4c683ba14dc4.png


BIN
doc/JPG/0c4f4030db19740b6b5ec61a31cf8e2c.png


BIN
doc/JPG/0fc05cfb5b44cce3786c4e7cf09eb353.png


BIN
doc/JPG/107d83b23d23e88cb5b7ba22463a5e26.jpg


BIN
doc/JPG/1374189ca7adc8d6a4dd009f71120822.png


BIN
doc/JPG/2d094d391a389d8d20629c5418312d52.jpg


BIN
doc/JPG/472c3a04666ff3f01e3eac847ce7e027.png


BIN
doc/JPG/582d19df4f21873e88bf7960663c0cfc.jpg


BIN
doc/JPG/6bd886ffa2808a573b34acabd7afba80.png


BIN
doc/JPG/7231c5630d9040f896312dccd3b379f7.png


BIN
doc/JPG/75624c39157e011d403ec4f74ec53e27.jpg


BIN
doc/JPG/85bc3f3106387c042382e9e785819edf.png


BIN
doc/JPG/89dc3098c63ef01672e1ed1aa0f2b6f3.png


BIN
doc/JPG/a0679ff093fa2e4b1e9f4cd9ad22f5fc.png


BIN
doc/JPG/bdef66e6b575fde0a1aaf1702525dd16.jpg


BIN
doc/JPG/d200ff42e3f56d482ef44d9b0a195efd.jpg


BIN
doc/JPG/d5d2735bd58db060ebbb870cbe8100be.jpg


BIN
doc/JPG/d7a68a2ac8a410a14df1f264617927a0.png


BIN
doc/JPG/dcc77b1e47c524aaed4ce227497158a0.png


BIN
doc/JPG/df3d8506ad7b1acd6ea1d37d5442a72e.png


BIN
doc/JPG/e2aafb65517897167178b5ae7fd9c00c.jpg


BIN
doc/JPG/edbce68ad9a574f518a5bcc6bea2fc79.jpg


+ 3 - 3
warewms-admin/src/main/resources/application-test.yml

@@ -67,9 +67,9 @@ spring:
     druid:
       # 主库数据源
       master:
-        url: jdbc:mysql://172.20.2.8:3306/trace_system?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
-        username: warewms
-        password: warewms123
+        url: jdbc:mysql://localhost:3306/ahhl_tarece?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true
+        username: root
+        password: root
       # 从库数据源
       slave:
         # 从数据源开关/默认关闭

+ 1 - 1
warewms-system/src/main/java/com/warewms/hailiang/MES/impl/MesServiceImpl.java

@@ -176,7 +176,7 @@ public class MesServiceImpl implements MesService {
         return null;
     }
 
-    /**
+        /**
      *  MES反馈重试
      * @param URl
      * @param body

+ 13 - 0
warewms-system/src/main/java/com/warewms/hailiang/controller/DeviceLogController.java

@@ -6,6 +6,7 @@ import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.common.utils.poi.ExcelUtil;
 import com.warewms.hailiang.domain.DTO.DeviceLogDTO;
+import com.warewms.hailiang.domain.DTO.RetroactiveHistoryDTO;
 import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.service.DeviceLogService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -15,7 +16,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author AD
@@ -42,4 +46,13 @@ public class DeviceLogController {
         ExcelUtil<DeviceLogDTO> util = new ExcelUtil<DeviceLogDTO>(DeviceLogDTO.class);
         util.exportExcel(response, transform, "设备日志");
     }
+
+    @PostMapping("/exportByIds")
+    public void exportByIds(HttpServletResponse response, String  ids)
+    {
+        List<Long> collect = Arrays.asList(ids.split(",")).stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+        List<DeviceLogDTO> historyList = deviceLogService.getByIds(collect);
+        ExcelUtil<DeviceLogDTO> util = new ExcelUtil<DeviceLogDTO>(DeviceLogDTO.class);
+        util.exportExcel(response, historyList, "设备日志");
+    }
 }

+ 10 - 0
warewms-system/src/main/java/com/warewms/hailiang/domain/DeviceLog.java

@@ -2,9 +2,12 @@ package com.warewms.hailiang.domain;
 
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.warewms.common.annotation.Excel;
 import com.warewms.common.core.domain.base.BaseEntity;
 import io.swagger.annotations.ApiModelProperty;
@@ -26,6 +29,7 @@ public class DeviceLog extends BaseEntity implements Serializable  {
      * 日志编号
      */
     @TableId(type = IdType.ASSIGN_ID)
+    @JsonSerialize(using= ToStringSerializer.class)
     private Long deviceLogId;
 
     /**
@@ -52,6 +56,12 @@ public class DeviceLog extends BaseEntity implements Serializable  {
     @Excel(name = "类型",readConverterExp="1=信息,2=报警")
     private String status;
 
+    @TableField(exist = false)
+    private String beginTime;
+
+    @TableField(exist = false)
+    private String endTime;
+
 
     private static final long serialVersionUID = 1L;
 

+ 14 - 9
warewms-system/src/main/java/com/warewms/hailiang/init/PlcConnectServiceRunner.java

@@ -21,10 +21,7 @@ import org.springframework.stereotype.Component;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.*;
 
 /**
  * plc连接
@@ -57,6 +54,8 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
 
     private ArrayList<String> reTryPlc = new ArrayList<>();
 
+    private HashMap<String, ScheduledFuture<?>> heartbeatThreads = new HashMap<>();
+
     /**
      * 初始化
      */
@@ -70,6 +69,7 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
                     if (s7PLC.checkConnected()){
                         plcToolsMap.put(plcConfig.getName(),s7PLC);
                         SpringUtil.getApplicationContext().publishEvent(new Device(plcConfig.getName(), "1"));
+                        plcConnectsTheHeartbeat(plcConfig,s7PLC);
                         log.info("plc:{},ip:{},连接成功",plcConfig.getName(),plcConfig.getIp());
                     }
                 }catch (Exception e){
@@ -83,6 +83,10 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
 
     public void retry(PlcConfig plcConfig) {
         reTryPlc.add(plcConfig.getName());
+        ScheduledFuture<?> scheduledFuture = heartbeatThreads.get(plcConfig.getName());
+        if (ObjectUtil.isNotNull(scheduledFuture)){
+            scheduledFuture.cancel(true);
+        }
         threadPoolTaskExecutor.execute (() -> {
             Retryer<Boolean> retryer = RetryerBuilder.<Boolean>newBuilder()
                     .retryIfResult(Boolean.FALSE::equals)
@@ -124,17 +128,18 @@ public class PlcConnectServiceRunner implements CommandLineRunner {
     private void plcConnectsTheHeartbeat(PlcConfig plcConfig,S7PLC s7PLC){
         String heartbeatAdd = plcConfig.getHeartbeat();
         if (StringUtils.isNotEmpty(heartbeatAdd)){
-            scheduledExecutorService.scheduleWithFixedDelay(()->{
-                if (!reTryPlc.contains(plcConfig.getName())){
+            ScheduledFuture<?> scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(() -> {
+                if (!reTryPlc.contains(plcConfig.getName())) {
                     try {
                         s7PLC.readBoolean(plcConfig.getHeartbeat());
-                    }catch (Exception e){
-                        log.error("设备:{},连接中断",plcConfig.getName());
+                    } catch (Exception e) {
+                        log.error("设备:{},连接中断", plcConfig.getName());
                         SpringUtil.getApplicationContext().publishEvent(new Device(plcConfig.getName(), "2"));
                         retry(plcConfig);
                     }
                 }
-            },0,3,TimeUnit.SECONDS);
+            }, 0, 3, TimeUnit.SECONDS);
+            heartbeatThreads.put(plcConfig.getName(),scheduledFuture);
         }
     }
 

+ 11 - 11
warewms-system/src/main/java/com/warewms/hailiang/init/TcpServiceRunner.java

@@ -47,17 +47,17 @@ public class TcpServiceRunner implements CommandLineRunner {
             Object o = aClass.newInstance();
             if (o instanceof TCPConnectBase) {
                 TCPConnectBase nodeModel = (TCPConnectBase) o;
-                threadPoolTaskExecutor.execute(() -> {
-                    try {
-                        nodeModel.init();
-                        TCPInstanceList.put(nodeModel.getDeviceName(),nodeModel);
-                    } catch (IOException e) {
-                        nodeModel.close();
-                        throw new RuntimeException(e);
-                    } catch (InterruptedException e) {
-                        throw new RuntimeException(e);
-                    }
-                });
+//                threadPoolTaskExecutor.execute(() -> {
+//                    try {
+//                        nodeModel.init();
+//                        TCPInstanceList.put(nodeModel.getDeviceName(),nodeModel);
+//                    } catch (IOException e) {
+//                        nodeModel.close();
+//                        throw new RuntimeException(e);
+//                    } catch (InterruptedException e) {
+//                        throw new RuntimeException(e);
+//                    }
+//                });
             }
         }
     }

+ 4 - 0
warewms-system/src/main/java/com/warewms/hailiang/service/DeviceLogService.java

@@ -4,6 +4,8 @@ package com.warewms.hailiang.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
+import com.warewms.hailiang.domain.DTO.DeviceLogDTO;
+import com.warewms.hailiang.domain.DTO.RetroactiveHistoryDTO;
 import com.warewms.hailiang.domain.DeviceLog;
 
 import java.util.List;
@@ -22,4 +24,6 @@ public interface DeviceLogService extends IService<DeviceLog> {
     List<DeviceLog> getList(DeviceLog deviceLog);
 
     int cleanUpDataFromAWeekAgo();
+
+    List<DeviceLogDTO> getByIds( List<Long> idList);
 }

+ 17 - 2
warewms-system/src/main/java/com/warewms/hailiang/service/impl/DeviceLogServiceImpl.java

@@ -10,11 +10,14 @@ import com.warewms.common.core.domain.base.page.PageDomain;
 import com.warewms.common.core.domain.base.page.TableDataInfo;
 import com.warewms.common.utils.StringUtils;
 import com.warewms.hailiang.config.DeviceMessageSocket;
+import com.warewms.hailiang.domain.DTO.DeviceLogDTO;
+import com.warewms.hailiang.domain.DTO.RetroactiveHistoryDTO;
 import com.warewms.hailiang.domain.Device;
 import com.warewms.hailiang.domain.DeviceLog;
 import com.warewms.hailiang.mapper.DeviceLogMapper;
 import com.warewms.hailiang.service.DeviceLogService;
 import com.warewms.hailiang.service.DeviceService;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
@@ -46,12 +49,13 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
     @Override
     public TableDataInfo<DeviceLog> getList(DeviceLog deviceLog, PageDomain pageDomain) {
         Map<String, Object> params = deviceLog.getParams();
+        System.out.println(params);
         IPage<DeviceLog> deviceLogIPage = deviceLogMapper.selectPage(pageDomain.build(), new LambdaQueryWrapper<DeviceLog>()
                 .eq(StringUtils.isNotEmpty(deviceLog.getDeviceId()), DeviceLog::getDeviceId, deviceLog.getDeviceId())
                 .eq(StringUtils.isNotEmpty(deviceLog.getDeviceName()), DeviceLog::getDeviceName, deviceLog.getDeviceName())
                 .eq(StringUtils.isNotEmpty(deviceLog.getStatus()), DeviceLog::getStatus, deviceLog.getStatus())
-                .between(params.get("beginTime") != null && params.get("endTime") != null,
-                        DeviceLog::getCreateTime, params.get("beginTime"), params.get("endTime"))
+                .between(StringUtils.isNotEmpty(deviceLog.getBeginTime()) &&StringUtils.isNotEmpty(deviceLog.getEndTime()),
+                        DeviceLog::getCreateTime,deviceLog.getBeginTime(),deviceLog.getEndTime())
                 .orderByDesc(DeviceLog::getCreateTime));
         return TableDataInfo.build(deviceLogIPage);
     }
@@ -99,6 +103,17 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog
     public int cleanUpDataFromAWeekAgo() {
         return  deviceLogMapper.cleanUpDataFromAWeekAgo();
     }
+
+    @Override
+    public List<DeviceLogDTO> getByIds(List<Long> IdList) {
+        List<DeviceLog> deviceLogs = deviceLogMapper.selectBatchIds(IdList);
+        List<DeviceLogDTO> collect = deviceLogs.stream().map(item -> {
+            DeviceLogDTO deviceLogDTO = new DeviceLogDTO();
+            BeanUtils.copyProperties(item, deviceLogDTO);
+            return deviceLogDTO;
+        }).collect(Collectors.toList());
+        return collect;
+    }
 }
 
 

+ 0 - 1
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveHistoryServiceImpl.java

@@ -96,7 +96,6 @@ public class RetroactiveHistoryServiceImpl extends ServiceImpl<RetroactiveHistor
                 longs.add(ids);
             } else {
                 longs = Arrays.asList(split);
-                System.out.println(longs);
                 retroactiveHistoryLambdaQueryWrapper.in(RetroactiveHistory::getHistoryId, longs)
                         .orderByAsc(RetroactiveHistory::getCreateTime);
             }

+ 19 - 7
warewms-system/src/main/java/com/warewms/hailiang/service/impl/RetroactiveNowServiceImpl.java

@@ -111,10 +111,13 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
         baseData.setDeviceId(retroactiveNow.getDeviceId());
         baseData.setUpdateBy("system");
         baseData.setUpdateTime(new Date());
-        retroactiveNowMapper.updateById(baseData);
-        RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
-        retroactiveHistory.setCreateTime(baseData.getUpdateTime());
-        return retroactiveHistoryMapper.insert(retroactiveHistory);
+        int i = retroactiveNowMapper.updateById(baseData);
+        if (!"6".equals(baseData.getStatus())){
+            RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
+            retroactiveHistory.setCreateTime(baseData.getUpdateTime());
+             retroactiveHistoryMapper.insert(retroactiveHistory);
+        }
+        return i;
     }
 
     @Override
@@ -129,7 +132,6 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
         int delete = retroactiveNowMapper.delete(new LambdaQueryWrapper<RetroactiveNow>().eq(RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo()));
         if (delete == 1) {
             retroactiveHistoryMapper.insert(retroactiveHistory);
-
         }
         return delete;
     }
@@ -188,20 +190,30 @@ public class RetroactiveNowServiceImpl extends ServiceImpl<RetroactiveNowMapper,
     }
 
     @Override
+    @Transactional
     public R update(RetroactiveNow retroactiveNow) {
         RetroactiveNow baseData = retroactiveNowMapper.selectOne(new LambdaQueryWrapper<RetroactiveNow>()
                 .eq(StringUtils.isNotEmpty(retroactiveNow.getBatchNo()), RetroactiveNow::getBatchNo, retroactiveNow.getBatchNo())
-                .eq (RetroactiveNow::getStatus, "6")
         );
         if (ObjectUtil.isNull(baseData)) {
             throw new ServiceException("数据库中不存在该批次号," + retroactiveNow.getBatchNo());
         }
+        if (!"6".equals(baseData.getStatus())){
+            baseData.setStatus("6");
+            baseData.setDeviceId("Z1_TuiHuoShangLiao_DMQ-1-27.13");
+        }
         baseData.setUniuCode(retroactiveNow.getUniuCode());
         baseData.setShelfNumber(retroactiveNow.getShelfNumber());
         baseData.setLotAddress(retroactiveNow.getLotAddress());
         baseData.setNumberOfLayers(retroactiveNow.getNumberOfLayers());
         retroactiveNowMapper.updateById(baseData);
-        mesService .tuiHuoShangLiao(baseData);
+        if (!"6".equals(baseData.getStatus())){
+            baseData.setRemark("PDA手动补码");
+        }
+        RetroactiveHistory retroactiveHistory = BeanUtil.copyProperties(baseData, RetroactiveHistory.class);
+        retroactiveHistory.setCreateTime(baseData.getUpdateTime());
+        retroactiveHistoryMapper.insert(retroactiveHistory);
+        mesService.tuiHuoShangLiao(baseData);
         return R.ok();
     }