#
taisheng
3 天以前 bc48a855d98e360042a7e2fff5594a91a82578c6
src/main/java/com/zy/asrs/controller/ConsoleController.java
@@ -13,14 +13,13 @@
import com.zy.asrs.domain.enums.SiteStatusType;
import com.zy.asrs.domain.param.SystemSwitchParam;
import com.zy.asrs.domain.vo.*;
import com.zy.asrs.entity.BasCrnError;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.ChartBean;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.entity.*;
import com.zy.asrs.mapper.BasCrnErrorMapper;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ReportQueryMapper;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.DeviceErrorService;
import com.zy.asrs.service.WrkMastService;
import com.zy.common.CodeRes;
import com.zy.core.CrnThread;
@@ -39,6 +38,8 @@
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.ScaleThread;
import com.zy.core.thread.SiemensCrnThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -67,6 +68,12 @@
    private BasCrnErrorMapper basCrnErrorMapper;
    @Autowired
    private ReportQueryMapper reportQueryMapper;
    @Autowired
    private DeviceErrorService deviceErrorService;
    @Autowired
    private BasCrnpService basCrnpService;
    @Autowired
    private ConfigService configService;
    @PostMapping("/system/running/status")
    @ManagerAuth(memo = "系统运行状态")
@@ -91,6 +98,48 @@
        Thread.sleep(200L);
        SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType()==1?Boolean.TRUE:Boolean.FALSE);
        return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get()));
    }
    @GetMapping("/switchDemo")
    public R switchDemo() {
        //切换演示模式
        Config demoEnableConfig = configService.selectByCode("demoEnable");
        if(demoEnableConfig == null){
            return R.error("演示模式参数不存在");
        }
        HashMap<String, Object> map = new HashMap<>();
        if (demoEnableConfig.getValue().equals("true")) {
            //开启状态,变更关闭
            demoEnableConfig.setValue("false");
            configService.updateById(demoEnableConfig);
            map.put("status", false);
        }else {
            //关闭状态,变更开启
            demoEnableConfig.setValue("true");
            configService.updateById(demoEnableConfig);
            map.put("status", true);
        }
        return R.ok().add(map);
    }
    @GetMapping("/getDemoStatus")
    public R getDemoStatus() {
        //切换演示模式
        Config demoEnableConfig = configService.selectByCode("demoEnable");
        if(demoEnableConfig == null){
            return R.error("演示模式参数不存在");
        }
        HashMap<String, Object> map = new HashMap<>();
        boolean status = false;
        if(demoEnableConfig.getValue().equals("true")){
            status = true;
        }
        map.put("status", status);
        return R.ok().add(map);
    }
    /****************************************************************/
@@ -198,6 +247,60 @@
        return R.ok().add(list);
    }
    /**
     * 获取设备详情
     */
    @GetMapping("/deviceInfo")
    @ManagerAuth
    public R getDeviceInfo() {
        ArrayList<HashMap<String, Object>> list = new ArrayList<>();
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
            if (crnThread == null) {
                continue;
            }
            CrnProtocol crnProtocol = crnThread.getCrnProtocol();
            if (crnProtocol == null) {
                continue;
            }
            HashMap<String, Object> map = new HashMap<>();
            map.put("device", "堆垛机");
            map.put("deviceId", crn.getId());
            map.put("battery", "");
            map.put("error", crnProtocol.getFault());
            map.put("status", crnProtocol.getStatusType().desc);
            list.add(map);
        }
        for (DevpSlave devp : slaveProperties.getDevp()) {
            DeviceError deviceError = deviceErrorService.selectByDeviceAndDeviceId("devp", devp.getId());
            HashMap<String, Object> map = new HashMap<>();
            map.put("device", "输送线");
            map.put("deviceId", devp.getId());
            map.put("battery", "");
            map.put("error", deviceError != null);
            map.put("status", deviceError == null ? "" : deviceError.getMsg());
            list.add(map);
        }
        for (Slave scale : slaveProperties.getScale()) {
            DeviceError deviceError = deviceErrorService.selectByDeviceAndDeviceId("scale", scale.getId());
            HashMap<String, Object> map = new HashMap<>();
            map.put("device", "磅秤");
            map.put("deviceId", scale.getId());
            map.put("battery", "");
            map.put("error", deviceError != null);
            map.put("status", deviceError == null ? "" : deviceError.getMsg());
            list.add(map);
        }
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("records", list);
        return R.ok().add(hashMap);
    }
    /****************************************************************/
    /************************** 详情操作 ******************************/
    /****************************************************************/
@@ -256,6 +359,11 @@
        CrnDetailVo vo = new CrnDetailVo();
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            if (crnSlave.getId().equals(crnNo)) {
                BasCrnp basCrnp = basCrnpService.selectById(crnNo);
                if (basCrnp == null) {
                    return R.error("数据库维护异常");
                }
                SiemensCrnThread crnThread = (SiemensCrnThread) SlaveConnection.get(SlaveType.Crn, crnSlave.getId());
                CrnProtocol crnProtocol = crnThread.getCrnProtocol();
                vo.setCrnNo(crnNo);
@@ -280,6 +388,8 @@
                        vo.setError("");    // todo
                    }
                }
                vo.setInEnable(basCrnp.getInEnable());//可入
                vo.setOutEnable(basCrnp.getOutEnable());//可出
                return R.ok().add(vo);
            }
        }