diff --git a/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/ItemProtocol.java b/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/ItemProtocol.java index a666acd..b923e2e 100644 --- a/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/ItemProtocol.java +++ b/nladmin-system/src/main/java/org/nl/acs/device_driver/hailiang/hailiang_feeding_trunk/ItemProtocol.java @@ -389,8 +389,8 @@ public class ItemProtocol { list.add(new ItemDto(item_detail_labeling_qualified_qty, "当前工单明细号刻字数量", "DB600.D58")); list.add(new ItemDto(item_detail_labeling_qty, "当前贴标工单明细号贴标数", "DB600.D62")); list.add(new ItemDto(item_ready, "设备就绪", "DB600.D66")); - list.add(new ItemDto( item_clear, "清料", "DB600.D70")); - list.add(new ItemDto( item_pause, "暂停", "DB600.D74")); + list.add(new ItemDto(item_clear, "清料", "DB600.D70")); + list.add(new ItemDto(item_pause, "暂停", "DB600.D74")); list.add(new ItemDto(item_line_speed, "线体速度", "DB600.REAL78")); list.add(new ItemDto(item_feeding_mouth, "上料口", "DB600.D82")); list.add(new ItemDto(item_is_lettering, "是否刻字", "DB600.D86")); diff --git a/nladmin-system/src/main/java/org/nl/acs/log/service/impl/LogServerImpl.java b/nladmin-system/src/main/java/org/nl/acs/log/service/impl/LogServerImpl.java index 91c4c21..4d8cd12 100644 --- a/nladmin-system/src/main/java/org/nl/acs/log/service/impl/LogServerImpl.java +++ b/nladmin-system/src/main/java/org/nl/acs/log/service/impl/LogServerImpl.java @@ -125,6 +125,7 @@ public class LogServerImpl implements LogServer { String now = DateUtil.now(); JSONObject json = new JSONObject(); + json.put("device_code",device_code); json.put("vehicle_code",vehicle_code); json.put("inst_code",inst_code); json.put("message",message); diff --git a/nladmin-system/src/main/java/org/nl/modules/log/rest/RootLogController.java b/nladmin-system/src/main/java/org/nl/modules/log/rest/RootLogController.java index 5757799..63ade57 100644 --- a/nladmin-system/src/main/java/org/nl/modules/log/rest/RootLogController.java +++ b/nladmin-system/src/main/java/org/nl/modules/log/rest/RootLogController.java @@ -13,6 +13,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.text.ParseException; import java.util.Map; /** @@ -36,6 +37,14 @@ public class RootLogController { return new ResponseEntity<>(rootLogService.queryAll(whereJson, page), HttpStatus.OK); } + @GetMapping("/deviceLog") + @Log("查询设备日志") + @ApiOperation("查询设备日志") + //@PreAuthorize("@el.check('log:list')") + public ResponseEntity queryDeviceLog(@RequestParam Map whereJson, Pageable page) throws ParseException { + return new ResponseEntity<>(rootLogService.queryDeviceLog(whereJson, page), HttpStatus.OK); + } + @PostMapping( "/error") @Log("查询异常详情") @ApiOperation("查询异常详情") diff --git a/nladmin-system/src/main/java/org/nl/modules/log/service/RootLogService.java b/nladmin-system/src/main/java/org/nl/modules/log/service/RootLogService.java index 7363c97..4f860fc 100644 --- a/nladmin-system/src/main/java/org/nl/modules/log/service/RootLogService.java +++ b/nladmin-system/src/main/java/org/nl/modules/log/service/RootLogService.java @@ -2,6 +2,7 @@ package org.nl.modules.log.service; import org.springframework.data.domain.Pageable; +import java.text.ParseException; import java.util.Map; /** @@ -16,6 +17,15 @@ public interface RootLogService { */ Map queryAll(Map whereJson, Pageable page); + /** + * 查询设备日志 + * + * @param whereJson 条件 + * @param page 分页参数 + * @return Map + */ + Map queryDeviceLog(Map whereJson, Pageable page) throws ParseException; + /** * 查询异常详情 * diff --git a/nladmin-system/src/main/java/org/nl/modules/log/service/impl/RootLogServiceImpl.java b/nladmin-system/src/main/java/org/nl/modules/log/service/impl/RootLogServiceImpl.java index 75ef79a..be80d6c 100644 --- a/nladmin-system/src/main/java/org/nl/modules/log/service/impl/RootLogServiceImpl.java +++ b/nladmin-system/src/main/java/org/nl/modules/log/service/impl/RootLogServiceImpl.java @@ -1,9 +1,11 @@ package org.nl.modules.log.service.impl; import cn.hutool.core.util.StrUtil; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.nl.acs.device.service.DeviceService; import org.nl.modules.log.service.RootLogService; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -27,6 +29,8 @@ public class RootLogServiceImpl implements RootLogService { private final MongoTemplate mongoTemplate; + private final DeviceService deviceService; + @Override public Map queryAll(Map whereJson, Pageable page){ String log_type = (String) whereJson.get("log_type"); @@ -48,6 +52,8 @@ public class RootLogServiceImpl implements RootLogService { .lte(end_time)); } + query.with(Sort.by("date")); + //根据条件得到的总条数 long totalSize = mongoTemplate.count(query, Map.class, log_type); @@ -61,6 +67,38 @@ public class RootLogServiceImpl implements RootLogService { return result; } + @Override + public Map queryDeviceLog(Map whereJson, Pageable page){ + String device_code = (String) whereJson.get("device_code"); + String begin_time = (String) whereJson.get("begin_time"); + String end_time = (String) whereJson.get("end_time"); + + Query query = new Query().with(Sort.by("date")); + + if (StrUtil.isEmpty(device_code)) { + JSONArray array = deviceService.selectList(); + JSONObject json = array.getJSONObject(0); + device_code = json.getString("device_code"); + } + if (StrUtil.isNotEmpty(begin_time) && StrUtil.isNotEmpty(end_time)) { + query.addCriteria(Criteria.where("date") + .gte(begin_time) + .lte(end_time)); + } + + //根据条件得到的总条数 + long totalSize = mongoTemplate.count(query, Map.class, device_code); + + //处理分页 + query.skip(page.getPageNumber()).limit(page.getPageSize()); + List list = mongoTemplate.find(query,Map.class, device_code); + //封装前端分页查询结果 + JSONObject result = new JSONObject(); + result.put("content", list); + result.put("totalElements", totalSize); + return result; + } + @Override public String findError(Map map) { String message = (String) map.get("message"); diff --git a/qd/src/api/log.js b/qd/src/api/log.js index 9d740e3..0a8aa35 100644 --- a/qd/src/api/log.js +++ b/qd/src/api/log.js @@ -25,7 +25,6 @@ export function edit(data) { } export function findError(data) { - debugger return request({ url: 'api/rootLog/error', method: 'post', @@ -33,4 +32,11 @@ export function findError(data) { }) } -export default { add, edit, del, findError } +export function selectDeviceList() { + return request({ + url: 'api/device/selectList', + method: 'get' + }) +} + +export default { add, edit, del, findError, selectDeviceList } diff --git a/qd/src/views/log/deviceLog/index.vue b/qd/src/views/log/deviceLog/index.vue new file mode 100644 index 0000000..f344528 --- /dev/null +++ b/qd/src/views/log/deviceLog/index.vue @@ -0,0 +1,183 @@ + + + + +