| | |
| | | package com.zy.core.thread.fake; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.zy.common.Cools; |
| | | import com.zy.common.SpringUtils; |
| | |
| | | public class FakeNyLiftThread implements FakeThread { |
| | | |
| | | private RedisUtil redisUtil; |
| | | private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"plcTaskNo\":0,\"lev\":1,\"protocolStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"hasTray\":0,\"hasCar\":0,\"trayList\":[0,0,0,0],\"carList\":[0,0,0,0],\"extend\":{\"frontOverrun\":false,\"backOverrun\":false,\"leftOverrun\":false,\"rightOverrun\":false,\"overHeight\":false,\"overWeight\":false}}"); |
| | | private JSONObject fakeStatusDemo = JSONObject.parseObject("{\"model\":2,\"plcTaskNo\":0,\"lev\":1,\"deviceStatus\":0,\"taskMode\":0,\"pick\":0,\"put\":0,\"iOMode\":0,\"errorCode\":0,\"hasTray\":0,\"hasCar\":0,\"stationList\":[{\"siteId\":101,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":102,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":103,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":1001,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":1002,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"},{\"siteId\":1003,\"model\":1,\"busy\":0,\"hasTray\":0,\"deviceError\":0,\"taskNo\":0,\"staNo\":0,\"allowShuttleTake\":0,\"allowShuttlePut\":0,\"barcode\":\"\"}],\"extend\":{\"frontOverrun\":false,\"backOverrun\":false,\"leftOverrun\":false,\"rightOverrun\":false,\"overHeight\":false,\"overWeight\":false}}"); |
| | | private ConcurrentHashMap<String, Thread> fakeThreadMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeStatusMap = new ConcurrentHashMap(); |
| | | private ConcurrentHashMap<String, JSONObject> fakeCommandMap = new ConcurrentHashMap(); |
| | |
| | | if (commandType == 1) { |
| | | //取放货 |
| | | fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//任务号 |
| | | fakeStatus.put("protocolStatus", 1);//取货中 |
| | | fakeStatus.put("deviceStatus", 1);//取货中 |
| | | fakeStatus.put("taskMode", commandType);//任务类型 |
| | | fakeStatus.put("pick", commandBody.getInteger("pick"));//取货数据 |
| | | fakeStatus.put("put", commandBody.getInteger("put"));//放货数据 |
| | |
| | | //delay |
| | | Thread.sleep(5000); |
| | | |
| | | fakeStatus.put("protocolStatus", 0); |
| | | Integer put = commandBody.getInteger("put"); |
| | | int lev = put % 100; |
| | | |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | fakeStatus.put("lev", commandBody.getInteger("put")); |
| | | fakeStatus.put("lev", lev); |
| | | |
| | | JSONObject extend = fakeStatus.getJSONObject("extend"); |
| | | extend.put("plcTaskNoComplete", commandBody.getInteger("taskNo")); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 2) { |
| | | //小车换层 |
| | | fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//任务号 |
| | | fakeStatus.put("protocolStatus", 1);//取货中 |
| | | fakeStatus.put("deviceStatus", 1);//取货中 |
| | | fakeStatus.put("taskMode", commandType);//任务类型 |
| | | fakeStatus.put("pick", commandBody.getInteger("pick"));//取货数据 |
| | | fakeStatus.put("put", commandBody.getInteger("put"));//放货数据 |
| | |
| | | //delay |
| | | Thread.sleep(5000); |
| | | |
| | | fakeStatus.put("protocolStatus", 0); |
| | | Integer put = commandBody.getInteger("put"); |
| | | int lev = put % 100; |
| | | |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | fakeStatus.put("lev", commandBody.getInteger("put")); |
| | | fakeStatus.put("lev", lev); |
| | | |
| | | JSONObject extend = fakeStatus.getJSONObject("extend"); |
| | | extend.put("plcTaskNoComplete", commandBody.getInteger("taskNo")); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 3) { |
| | | //提升机移动 |
| | | fakeStatus.put("plcTaskNo", commandBody.getInteger("taskNo"));//任务号 |
| | | fakeStatus.put("protocolStatus", 1);//移动中 |
| | | fakeStatus.put("deviceStatus", 1);//移动中 |
| | | fakeStatus.put("taskMode", commandType);//任务类型 |
| | | fakeStatus.put("pick", commandBody.getInteger("pick"));//取货数据 |
| | | fakeStatus.put("put", commandBody.getInteger("put"));//放货数据 |
| | |
| | | //delay |
| | | Thread.sleep(5000); |
| | | |
| | | fakeStatus.put("protocolStatus", 0); |
| | | Integer put = commandBody.getInteger("put"); |
| | | int lev = put % 100; |
| | | |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | fakeStatus.put("lev", commandBody.getInteger("put")); |
| | | fakeStatus.put("lev", lev); |
| | | |
| | | JSONObject extend = fakeStatus.getJSONObject("extend"); |
| | | extend.put("plcTaskNoComplete", commandBody.getInteger("taskNo")); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 9996) { |
| | | //复位 |
| | | fakeStatus.put("plcTaskNo", 0);//任务号 |
| | | fakeStatus.put("protocolStatus", 0); |
| | | fakeStatus.put("deviceStatus", 0); |
| | | fakeStatus.put("taskMode", 0);//任务类型 |
| | | fakeStatus.put("pick", 0);//取货数据 |
| | | fakeStatus.put("put", 0);//放货数据 |
| | | |
| | | JSONObject extend = fakeStatus.getJSONObject("extend"); |
| | | extend.put("plcTaskNoComplete", 0); |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 9997) { |
| | | //切换入库模式 |
| | |
| | | } else if (commandType == 9998) { |
| | | //切换出库模式 |
| | | fakeStatus.put("iOMode", 2);//出入库模式 |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } else if (commandType == 10000) { |
| | | //写入输送线数据 |
| | | Integer siteId = commandBody.getInteger("siteId"); |
| | | Integer staNo = commandBody.getInteger("staNo"); |
| | | Integer taskNo = commandBody.getInteger("taskNo"); |
| | | String address = commandBody.getString("address"); |
| | | |
| | | short[] array = new short[2]; |
| | | array[0] = staNo.shortValue();//目标站 |
| | | array[1] = taskNo.shortValue();//任务号 |
| | | |
| | | JSONArray stationList = fakeStatus.getJSONArray("stationList"); |
| | | for (int i = 0; i < stationList.size(); i++) { |
| | | JSONObject staObj = stationList.getJSONObject(i); |
| | | if (staObj.getInteger("siteId").equals(siteId)) { |
| | | staObj.put("taskNo", taskNo); |
| | | staObj.put("staNo", staNo); |
| | | } |
| | | } |
| | | |
| | | fakeStatusMap.put(key, fakeStatus); |
| | | } |
| | | |
| | |
| | | //读取状态 |
| | | response = genereateFakeStatusResponse(fakeStatus); |
| | | deviceMsgType = "status"; |
| | | } else if (mode == 10000) { |
| | | //写入输送线数据 |
| | | fakeCommandMap.put(String.valueOf(SlaveType.Lift) + device.getDeviceNo(), fakeCommand); |
| | | response = genereateFakeCommandResponse(); |
| | | } |
| | | |
| | | fakeStatusMap.put(String.valueOf(SlaveType.Lift) + device.getDeviceNo(), fakeStatus); |
| | |
| | | |
| | | device.put("model", fakeStatus.getInteger("model")); |
| | | device.put("plcTaskNo", fakeStatus.getInteger("plcTaskNo")); |
| | | device.put("protocolStatus", fakeStatus.getInteger("protocolStatus")); |
| | | device.put("deviceStatus", fakeStatus.getInteger("deviceStatus")); |
| | | device.put("taskMode", fakeStatus.getInteger("taskMode")); |
| | | device.put("pick", fakeStatus.getInteger("pick")); |
| | | device.put("put", fakeStatus.getInteger("put")); |
| | |
| | | device.put("hasCar", fakeStatus.getInteger("hasCar")); |
| | | device.put("lev", fakeStatus.getInteger("lev")); |
| | | |
| | | Object trayListObj = fakeStatus.get("trayList"); |
| | | List<Integer> trayList = new ArrayList<>(); |
| | | if (trayListObj != null) { |
| | | trayList = JSON.parseArray(JSON.toJSONString(trayListObj), Integer.class); |
| | | } |
| | | |
| | | Object carListObj = fakeStatus.get("carList"); |
| | | List<Integer> carList = new ArrayList<>(); |
| | | if (carListObj != null) { |
| | | carList = JSON.parseArray(JSON.toJSONString(carListObj), Integer.class); |
| | | } |
| | | |
| | | device.put("trayList", trayList); |
| | | device.put("carList", carList); |
| | | JSONArray stationList = fakeStatus.getJSONArray("stationList"); |
| | | device.put("stationList", stationList); |
| | | |
| | | JSONObject extend = fakeStatus.getJSONObject("extend"); |
| | | device.put("frontOverrun", extend.getBoolean("frontOverrun")); |
| | |
| | | device.put("rightOverrun", extend.getInteger("rightOverrun")); |
| | | device.put("overHeight", extend.getInteger("overHeight")); |
| | | device.put("overWeight", extend.getInteger("overWeight")); |
| | | device.put("plcTaskNoComplete", extend.getInteger("plcTaskNoComplete")); |
| | | device.put("extend", extend); |
| | | return resultData; |
| | | } |
| | | |