From 46054fc49e33fe4f1aba8da23b74b8f14664bdfe Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期日, 28 四月 2024 09:06:42 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java | 76 +++++++++++++++++++++++++------------- 1 files changed, 50 insertions(+), 26 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java index 6901e42..741bed4 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.common.SnowflakeIdWorker; +import com.zy.asrs.wcs.core.domain.dto.RedisMapDto; import com.zy.asrs.wcs.core.entity.*; import com.zy.asrs.wcs.core.kernel.AnalyzeService; import com.zy.asrs.wcs.core.model.MapNode; @@ -20,13 +21,11 @@ import com.zy.asrs.wcs.rcs.cache.SlaveConnection; import com.zy.asrs.wcs.rcs.constant.DeviceRedisConstant; import com.zy.asrs.wcs.rcs.entity.Device; -import com.zy.asrs.wcs.rcs.entity.DeviceType; import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; import com.zy.asrs.wcs.rcs.service.DeviceService; -import com.zy.asrs.wcs.rcs.service.DeviceTypeService; import com.zy.asrs.wcs.rcs.thread.DevpThread; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; import com.zy.asrs.wcs.system.entity.Dict; @@ -55,8 +54,6 @@ private MotionService motionService; @Autowired private DeviceService deviceService; - @Autowired - private DeviceTypeService deviceTypeService; @Autowired private LocCtgService locCtgService; @Autowired @@ -117,7 +114,7 @@ ArrayList<MapNode> nodes = new ArrayList<>(); for (JSONObject object : entry.getValue()) { MapNode mapNode = new MapNode(); - mapNode.setValue(object.getInteger("value")); + mapNode.setValue(object.getInteger("shelfType")); mapNode.setTop(object.getInteger("top")); mapNode.setBottom(object.getInteger("bottom")); mapNode.setLeft(object.getInteger("left")); @@ -144,13 +141,45 @@ for (Map.Entry<Integer, ArrayList<ArrayList<MapNode>>> entry : levData.entrySet()) { ArrayList<ArrayList<MapNode>> lists = entry.getValue();//鑾峰彇鍦板浘 + MapNode mapNode = new MapNode(); + mapNode.setValue(-1); + mapNode.setTop(1000); + mapNode.setBottom(1000); + mapNode.setLeft(1000); + mapNode.setRight(1000); + mapNode.setRow(0); + mapNode.setBay(0); + mapNode.setNo("0-0"); + + //鑾峰彇鏈�闀縭ow + int row = 0; + //缁欐瘡涓猺ow棣栧熬澧炲姞-1鑺傜偣 + for (ArrayList<MapNode> list : lists) { + if (list.size() > row) { + row = list.size(); + } + + list.add(0, mapNode.clone()); + list.add(mapNode.clone()); + } + + ArrayList<MapNode> headNodes = new ArrayList<>(); + ArrayList<MapNode> footerNodes = new ArrayList<>(); + for (int i = 0; i < row+2; i++) { + headNodes.add(mapNode.clone()); + footerNodes.add(mapNode.clone()); + } + + lists.add(0, headNodes); + lists.add(footerNodes); + Integer lev = entry.getKey(); Date now = new Date(); - HashMap<String, Object> map = new HashMap<>(); - map.put("data", JSON.toJSONString(lists)); - map.put("create_time", now); - map.put("update_time", now); - map.put("lev", lev); + RedisMapDto map = new RedisMapDto(); + map.setData(JSON.toJSONString(lists)); + map.setCreateTime(now); + map.setUpdateTime(now); + map.setLev(lev); //灏嗗湴鍥炬暟鎹瓨鍏edis redisUtil.set(DeviceRedisConstant.MAP + lev, JSON.toJSONString(map)); @@ -259,15 +288,8 @@ return; } - DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() - .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) - .eq(DeviceType::getStatus, 1)); - if (deviceType == null) { - return; - } - List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() - .eq(Device::getDeviceType, deviceType.getId()) + .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) .eq(Device::getStatus, 1)); for (Device device : list) { //鑾峰彇鍥涘悜绌挎杞︾嚎绋� @@ -282,6 +304,10 @@ } if (!shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.IDLE)) { + continue; + } + + if (!shuttleThread.isRequireCharge()) { continue; } @@ -406,15 +432,8 @@ return; } - DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() - .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) - .eq(DeviceType::getStatus, 1)); - if (deviceType == null) { - return; - } - List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() - .eq(Device::getDeviceType, deviceType.getId()) + .eq(Device::getDeviceType, DeviceCtgType.SHUTTLE.val()) .eq(Device::getStatus, 1)); for (Device device : list) { //鑾峰彇鍥涘悜绌挎杞︾嚎绋� @@ -423,6 +442,11 @@ continue; } + ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); + if (shuttleProtocol == null) { + continue; + } + if (!shuttleThread.isCharging()) { continue; } -- Gitblit v1.9.1