#
Junjie
昨天 3adcbff31fdece77269744c8741f237e7a57348e
src/main/java/com/zy/asrs/controller/BasCrnpErrLogController.java
@@ -3,10 +3,11 @@
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.getById(String.valueOf(id)));
        BasCrnpErrLog basCrnpErrLog = basCrnpErrLogService.getById(String.valueOf(id));
        fillErrorName(Collections.singletonList(basCrnpErrLog));
        return R.ok(basCrnpErrLog);
    }
    @RequestMapping(value = "/basCrnpErrLog/list/auth")
@@ -43,7 +48,9 @@
        convert(param, wrapper);
        allLike(BasCrnpErrLog.class, param.keySet(), wrapper, condition);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(true, "asc".equals(orderByType), humpToLine(orderByField));}
        return R.ok(basCrnpErrLogService.page(new Page<>(curr, limit), wrapper));
        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, QueryWrapper<T> wrapper){
@@ -94,9 +101,43 @@
        Map<String, Object> map = excludeTrash(param.getJSONObject("basCrnpErrLog"));
        convert(map, 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) {