From 51a1786ef3e4e016d5f3f7bad8c2e2e8a84247a6 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 22 三月 2026 18:42:19 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/asrs/controller/BasCrnpErrLogController.java | 80 ++++++++++++++++++++++++++++++---------
1 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/zy/asrs/controller/BasCrnpErrLogController.java b/src/main/java/com/zy/asrs/controller/BasCrnpErrLogController.java
index 24349d3..002590c 100644
--- a/src/main/java/com/zy/asrs/controller/BasCrnpErrLogController.java
+++ b/src/main/java/com/zy/asrs/controller/BasCrnpErrLogController.java
@@ -2,11 +2,12 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.mapper.EntityWrapper;
-import com.baomidou.mybatisplus.mapper.Wrapper;
-import com.baomidou.mybatisplus.plugins.Page;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.core.common.DateUtils;
+import com.zy.asrs.entity.BasCrnpErr;
import com.zy.asrs.entity.BasCrnpErrLog;
+import com.zy.asrs.service.BasCrnpErrService;
import com.zy.asrs.service.BasCrnpErrLogService;
import com.core.annotations.ManagerAuth;
import com.core.common.BaseRes;
@@ -23,11 +24,15 @@
@Autowired
private BasCrnpErrLogService basCrnpErrLogService;
+ @Autowired
+ private BasCrnpErrService basCrnpErrService;
@RequestMapping(value = "/basCrnpErrLog/{id}/auth")
@ManagerAuth
public R get(@PathVariable("id") String id) {
- return R.ok(basCrnpErrLogService.selectById(String.valueOf(id)));
+ BasCrnpErrLog basCrnpErrLog = basCrnpErrLogService.getById(String.valueOf(id));
+ fillErrorName(Collections.singletonList(basCrnpErrLog));
+ return R.ok(basCrnpErrLog);
}
@RequestMapping(value = "/basCrnpErrLog/list/auth")
@@ -38,23 +43,26 @@
@RequestParam(required = false)String orderByType,
@RequestParam(required = false)String condition,
@RequestParam Map<String, Object> param){
- EntityWrapper<BasCrnpErrLog> wrapper = new EntityWrapper<>();
+ QueryWrapper<BasCrnpErrLog> wrapper = new QueryWrapper<>();
excludeTrash(param);
convert(param, wrapper);
allLike(BasCrnpErrLog.class, param.keySet(), wrapper, condition);
- if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
- return R.ok(basCrnpErrLogService.selectPage(new Page<>(curr, limit), wrapper));
+ if (!Cools.isEmpty(orderByField)){wrapper.orderBy(true, "asc".equals(orderByType), humpToLine(orderByField));}
+ Page<BasCrnpErrLog> page = basCrnpErrLogService.page(new Page<>(curr, limit), wrapper);
+ fillErrorName(page.getRecords());
+ return R.ok(page);
}
- private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
+ private <T> void convert(Map<String, Object> map, QueryWrapper<T> wrapper){
for (Map.Entry<String, Object> entry : map.entrySet()){
String val = String.valueOf(entry.getValue());
+ String column = humpToLine(entry.getKey());
if (val.contains(RANGE_TIME_LINK)){
String[] dates = val.split(RANGE_TIME_LINK);
- wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
- wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
+ wrapper.ge(column, DateUtils.convert(dates[0]));
+ wrapper.le(column, DateUtils.convert(dates[1]));
} else {
- wrapper.like(entry.getKey(), val);
+ wrapper.like(column, val);
}
}
}
@@ -62,7 +70,7 @@
@RequestMapping(value = "/basCrnpErrLog/add/auth")
@ManagerAuth
public R add(BasCrnpErrLog basCrnpErrLog) {
- basCrnpErrLogService.insert(basCrnpErrLog);
+ basCrnpErrLogService.save(basCrnpErrLog);
return R.ok();
}
@@ -80,7 +88,7 @@
@ManagerAuth
public R delete(@RequestParam(value="ids[]") Integer[] ids){
for (Integer id : ids){
- basCrnpErrLogService.deleteById(id);
+ basCrnpErrLogService.removeById(id);
}
return R.ok();
}
@@ -88,20 +96,54 @@
@RequestMapping(value = "/basCrnpErrLog/export/auth")
@ManagerAuth
public R export(@RequestBody JSONObject param){
- EntityWrapper<BasCrnpErrLog> wrapper = new EntityWrapper<>();
+ QueryWrapper<BasCrnpErrLog> wrapper = new QueryWrapper<>();
List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
Map<String, Object> map = excludeTrash(param.getJSONObject("basCrnpErrLog"));
convert(map, wrapper);
- List<BasCrnpErrLog> list = basCrnpErrLogService.selectList(wrapper);
+ List<BasCrnpErrLog> list = basCrnpErrLogService.list(wrapper);
+ fillErrorName(list);
return R.ok(exportSupport(list, fields));
+ }
+
+ private void fillErrorName(List<BasCrnpErrLog> list){
+ if (list == null || list.isEmpty()){
+ return;
+ }
+ Set<Integer> errCodes = new HashSet<>();
+ for (BasCrnpErrLog basCrnpErrLog : list){
+ if (basCrnpErrLog != null && basCrnpErrLog.getErrCode() != null){
+ errCodes.add(basCrnpErrLog.getErrCode());
+ }
+ }
+ if (errCodes.isEmpty()){
+ return;
+ }
+ Map<Integer, String> errNameMap = new HashMap<>();
+ List<BasCrnpErr> errList = basCrnpErrService.list(new QueryWrapper<BasCrnpErr>().in("error_code", errCodes));
+ for (BasCrnpErr basCrnpErr : errList){
+ if (basCrnpErr.getErrorCode() != null && !Cools.isEmpty(basCrnpErr.getErrName())){
+ errNameMap.put(basCrnpErr.getErrorCode().intValue(), basCrnpErr.getErrName());
+ }
+ }
+ for (BasCrnpErrLog basCrnpErrLog : list){
+ if (basCrnpErrLog == null || basCrnpErrLog.getErrCode() == null){
+ continue;
+ }
+ String errName = errNameMap.get(basCrnpErrLog.getErrCode());
+ if (!Cools.isEmpty(errName)){
+ basCrnpErrLog.setError(errName);
+ } else if (Cools.isEmpty(basCrnpErrLog.getError())){
+ basCrnpErrLog.setError("鏈煡寮傚父");
+ }
+ }
}
@RequestMapping(value = "/basCrnpErrLogQuery/auth")
@ManagerAuth
public R query(String condition) {
- EntityWrapper<BasCrnpErrLog> wrapper = new EntityWrapper<>();
+ QueryWrapper<BasCrnpErrLog> wrapper = new QueryWrapper<>();
wrapper.like("id", condition);
- Page<BasCrnpErrLog> page = basCrnpErrLogService.selectPage(new Page<>(0, 10), wrapper);
+ Page<BasCrnpErrLog> page = basCrnpErrLogService.page(new Page<>(0, 10), wrapper);
List<Map<String, Object>> result = new ArrayList<>();
for (BasCrnpErrLog basCrnpErrLog : page.getRecords()){
Map<String, Object> map = new HashMap<>();
@@ -115,8 +157,8 @@
@RequestMapping(value = "/basCrnpErrLog/check/column/auth")
@ManagerAuth
public R query(@RequestBody JSONObject param) {
- Wrapper<BasCrnpErrLog> wrapper = new EntityWrapper<BasCrnpErrLog>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
- if (null != basCrnpErrLogService.selectOne(wrapper)){
+ QueryWrapper<BasCrnpErrLog> wrapper = new QueryWrapper<BasCrnpErrLog>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
+ if (null != basCrnpErrLogService.getOne(wrapper)){
return R.parse(BaseRes.REPEAT).add(getComment(BasCrnpErrLog.class, String.valueOf(param.get("key"))));
}
return R.ok();
--
Gitblit v1.9.1