车辆重置
This commit is contained in:
		@@ -1,11 +1,14 @@
 | 
			
		||||
package com.mt.wms.basic.controller;
 | 
			
		||||
 | 
			
		||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
			
		||||
import com.mt.wms.basic.params.VehicleParam;
 | 
			
		||||
import com.mt.wms.basic.params.VehicleQueryParam;
 | 
			
		||||
import com.mt.wms.basic.service.VehicleService;
 | 
			
		||||
import com.mt.wms.basic.vo.VehicleVo;
 | 
			
		||||
import com.mt.wms.core.base.BaseController;
 | 
			
		||||
import com.mt.wms.core.constants.CommonConstant;
 | 
			
		||||
import com.mt.wms.core.dal.entity.VehicleInfo;
 | 
			
		||||
import com.mt.wms.core.dal.service.VehicleInfoServiceBiz;
 | 
			
		||||
import com.mt.wms.core.params.IdParam;
 | 
			
		||||
import com.mt.wms.core.utils.IDGenerator;
 | 
			
		||||
import com.mt.wms.core.validator.groups.AddGroup;
 | 
			
		||||
@@ -40,6 +43,8 @@ public class VehicleController extends BaseController {
 | 
			
		||||
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private VehicleService vehicleService;
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private VehicleInfoServiceBiz vehicleInfoServiceBiz;
 | 
			
		||||
    @PostMapping(value = "get")
 | 
			
		||||
    @ApiOperation(value = "获取车辆信息")
 | 
			
		||||
    private R<VehicleVo> get(@Validated @RequestBody IdParam idParam) {
 | 
			
		||||
@@ -82,4 +87,13 @@ public class VehicleController extends BaseController {
 | 
			
		||||
        return successful(IDGenerator.gen("CL", "yyyyMMddHHmm", 2, "VEHICLE_CODE"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private R<String> reset(){
 | 
			
		||||
        List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>().eq(VehicleInfo.STATUS, 1));
 | 
			
		||||
        for (VehicleInfo vehicleInfo:vehicleInfoList
 | 
			
		||||
             ) {
 | 
			
		||||
            vehicleInfo.setStatus(0);
 | 
			
		||||
            vehicleInfoServiceBiz.updateById(vehicleInfo);
 | 
			
		||||
        }
 | 
			
		||||
        return successful("操作成功,车辆状态已重置为空闲!");
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -423,6 +423,15 @@ public class ScheduledTask extends BaseService {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //监听车辆是否在线
 | 
			
		||||
    public void listenVehicleOnline() throws IOException {
 | 
			
		||||
        List<VehicleInfo> vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper<VehicleInfo>()
 | 
			
		||||
                .eq(VehicleInfo.STATUS, 2));
 | 
			
		||||
        for (VehicleInfo vehicleInfo:vehicleInfoList
 | 
			
		||||
             ) {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    /**
 | 
			
		||||
     * 获取变量值
 | 
			
		||||
     * @param nameSpace nameSpace前缀
 | 
			
		||||
@@ -465,4 +474,33 @@ public class ScheduledTask extends BaseService {
 | 
			
		||||
        }
 | 
			
		||||
        return Double.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private Boolean rgvOnline(Long vehicleId) throws IOException {
 | 
			
		||||
        VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId);
 | 
			
		||||
        // TODO: 2022/3/19 小车的命名空间
 | 
			
		||||
        String identifier=null;
 | 
			
		||||
        if (vehicleId==1){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
 | 
			
		||||
        }
 | 
			
		||||
        if (vehicleId==2){
 | 
			
		||||
            identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS.";
 | 
			
		||||
        }
 | 
			
		||||
        Map<String, Object> json = new HashMap();
 | 
			
		||||
        json.put("nameSpace", 6);
 | 
			
		||||
        json.put("plcName", "plc1");
 | 
			
		||||
        json.put("identifier",identifier+"Online");
 | 
			
		||||
        String result = null;
 | 
			
		||||
        try {
 | 
			
		||||
            result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json));
 | 
			
		||||
        } catch (IOException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
            logger.info("获取小车1当前是否在线失败");
 | 
			
		||||
        }
 | 
			
		||||
        Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString());
 | 
			
		||||
        if (!aBoolean){
 | 
			
		||||
            webSocketServer.sendtoAll(vehicleInfo.getVehicleName()+"当前不在线,请人工确认车辆状态,如不能恢复未在线状态,请尽快手动移动车辆到轨道尽头,以避免车辆阻碍任务执行!");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user