6 changed files with 139 additions and 23 deletions
@ -0,0 +1,70 @@ |
|||
package org.nl.modules.quartz.task; |
|||
|
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.acs.agv.XgAgvEnum; |
|||
import org.nl.acs.agv.server.XianGongAgvService; |
|||
import org.nl.acs.device_driver.lamp_three_color.LampThreecolorDeviceDriver; |
|||
import org.nl.acs.ext.UnifiedResponse; |
|||
import org.nl.acs.opc.Device; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.nl.modules.wql.core.bean.WQLObject; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* 查询AGV互斥组状态 |
|||
*/ |
|||
@Slf4j |
|||
@Component("queryXGTGroupStatus") |
|||
@RequiredArgsConstructor |
|||
public class QueryXGTGroupStatus { |
|||
|
|||
@Autowired |
|||
private XianGongAgvService agvService; |
|||
|
|||
@Autowired |
|||
private DeviceAppService deviceAppService; |
|||
|
|||
public void run() { |
|||
try { |
|||
// 查询所有光栅设备
|
|||
List<JSONObject> deviceList = WQLObject.getWQLObject("acs_device").query("device_type = 'color' and device_code LIKE '%A2'") |
|||
.getResultJSONArray(0).toJavaList(JSONObject.class); |
|||
|
|||
// 组织数据查询
|
|||
List<String> deviceCodeList = deviceList.stream() |
|||
.map(row -> row.getString("device_code")) |
|||
.collect(Collectors.toList()); |
|||
|
|||
JSONObject param = new JSONObject(); |
|||
param.put("blockGroup", deviceCodeList); |
|||
|
|||
// 调用接口
|
|||
UnifiedResponse<List<JSONObject>> objectUnifiedResponse = agvService.blockGroupStatus(param); |
|||
List<JSONObject> dataList = objectUnifiedResponse.getData(); |
|||
|
|||
for (JSONObject json : dataList) { |
|||
// true 占用,false 没占用
|
|||
if (json.getBoolean("status")) { |
|||
// 下发光电颜色为红色
|
|||
Device device = deviceAppService.findDeviceByCode(json.getString("name")); |
|||
|
|||
LampThreecolorDeviceDriver driver = (LampThreecolorDeviceDriver) device.getDeviceDriver(); |
|||
// 给三色灯写入进入颜色红色-3
|
|||
String[] key = {"toColor"}; |
|||
Integer[] value = {XgAgvEnum.GS_COLOR_RED.getCode()}; |
|||
driver.writing(Arrays.asList(key),Arrays.asList(value)); |
|||
} |
|||
} |
|||
|
|||
} catch (Exception e) { |
|||
|
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue