| | |
| | | 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; |
| | |
| | | |
| | | @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") |
| | |
| | | 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){ |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | 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) { |