自动化立体仓库 - WCS系统
*
lsh
8 天以前 7a7c50a1ecf82fe070cf4dd86b73ba7386b33da6
src/main/java/com/zy/asrs/controller/DeviceErrorController.java
@@ -1,6 +1,5 @@
package com.zy.asrs.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
@@ -13,11 +12,13 @@
import com.core.common.Cools;
import com.core.common.R;
import com.zy.common.web.BaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.*;
@Slf4j
@RestController
public class DeviceErrorController extends BaseController {
@@ -30,6 +31,20 @@
        return R.ok(deviceErrorService.selectById(String.valueOf(id)));
    }
//    @RequestMapping(value = "/deviceError/list/auth")
//    @ManagerAuth
//    public R list(@RequestParam(defaultValue = "1")Integer curr,
//                  @RequestParam(defaultValue = "10")Integer limit,
//                  @RequestParam(required = false)String orderByField,
//                  @RequestParam(required = false)String orderByType,
//                  @RequestParam Map<String, Object> param){
//        EntityWrapper<DeviceError> wrapper = new EntityWrapper<>();
//        excludeTrash(param);
//        convert(param, wrapper);
//        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
//        return R.ok(deviceErrorService.selectPage(new Page<>(curr, limit), wrapper));
//    }
    @RequestMapping(value = "/deviceError/list/auth")
    @ManagerAuth
    public R list(@RequestParam(defaultValue = "1")Integer curr,
@@ -37,11 +52,31 @@
                  @RequestParam(required = false)String orderByField,
                  @RequestParam(required = false)String orderByType,
                  @RequestParam Map<String, Object> param){
        EntityWrapper<DeviceError> wrapper = new EntityWrapper<>();
        excludeTrash(param);
        convert(param, wrapper);
        if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
        return R.ok(deviceErrorService.selectPage(new Page<>(curr, limit), wrapper));
        try {
            long id = 0;
            String device = null;
            Integer deviceId = null;
            for (Map.Entry<String, Object> entry : param.entrySet()) {
                String val = String.valueOf(entry.getValue());
                if (Cools.isEmpty(val)) {
                    continue;
                }
                if (entry.getKey().equals("id")) {
                    id = (long) Integer.parseInt(val);
                } else if (entry.getKey().equals("device")) {
                    device = val;
                } else if (entry.getKey().equals("device_id")) {
                    deviceId = Integer.valueOf(val);
                }
            }
            List<DeviceError> deviceErrorList = deviceErrorService.selectDeviceErrorList(id,device,deviceId, curr, limit);
            Page<DeviceError> page1 = new Page<DeviceError>(curr, limit).setRecords(deviceErrorList);
            page1.setTotal(deviceErrorService.selectDeviceErrorListTotal(id,device,deviceId));
            return R.ok(page1);
        } catch (Exception e) {
            log.error("异常" + e);
            return R.error("异常" + e);
        }
    }
    private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){