| | |
| | | package com.zy.acs.conveyor.controller; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.conveyor.controller.vo.SiteTableVo; |
| | | import com.zy.acs.conveyor.core.DevpThread; |
| | | import com.zy.acs.conveyor.core.cache.MessageQueue; |
| | | import com.zy.acs.conveyor.core.cache.OutputQueue; |
| | | import com.zy.acs.conveyor.core.cache.SlaveConnection; |
| | | import com.zy.acs.conveyor.core.enums.SlaveType; |
| | | import com.zy.acs.conveyor.core.enums.TaskType; |
| | | import com.zy.acs.conveyor.core.model.Task; |
| | | import com.zy.acs.conveyor.core.model.protocol.StaProtocol; |
| | | import com.zy.acs.conveyor.core.constant.RedisConveyorConstant; |
| | | import com.zy.acs.conveyor.core.model.StaProtocol; |
| | | import com.zy.acs.conveyor.core.properties.DevpSlave; |
| | | import com.zy.acs.conveyor.core.properties.OutputQueue; |
| | | import com.zy.acs.conveyor.core.properties.SlaveProperties; |
| | | import com.zy.acs.conveyor.core.service.StationService; |
| | | import com.zy.acs.conveyor.entity.Devp; |
| | | import com.zy.acs.conveyor.service.DevpService; |
| | | import com.zy.acs.framework.annotations.ManagerAuth; |
| | |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | |
| | | @Autowired |
| | | private DevpService devpService; |
| | | |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | |
| | | private final RedisSupport redis = RedisSupport.defaultRedisSupport; |
| | | |
| | | |
| | | @PostMapping("/table/site") |
| | |
| | | // 内存数据 |
| | | Map<Integer, StaProtocol> station = new HashMap<>(); |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | station.putAll(devpThread.getStation()); |
| | | Map<Integer, StaProtocol> stationMap = stationService.getStationMap(devp.getId()); |
| | | station.putAll(stationMap); |
| | | } |
| | | // 持久数据 |
| | | List<Devp> devps = devpService.selectList(new EntityWrapper<Devp>().orderBy("dev_no")); |
| | |
| | | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出 |
| | | vo.setPakMk(staProtocol.isPakMk() ? "Y" : "N"); // 入库标记 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() ? "Y" : "N"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | // vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高"); //高低库位 |
| | |
| | | public R siteDetl(@PathVariable("siteId") Integer siteId) { |
| | | SiteTableVo vo = new SiteTableVo(); |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | Map<Integer, StaProtocol> station = stationService.getStationMap(devp.getId()); |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | if (siteId.equals(entry.getKey())) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | |
| | | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出 |
| | | vo.setPakMk(staProtocol.isPakMk() ? "Y" : "N"); // 需求1 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() ? "Y" : "N"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高"); //高低库位 |
| | |
| | | @RequestParam Integer staNo, |
| | | @RequestParam String pakMk) { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | Map<Integer, StaProtocol> station = stationService.getStationMap(devp.getId()); |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | if (siteId.equals(entry.getKey())) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | |
| | | if (staNo != null) { |
| | | staProtocol.setStaNo(staNo); |
| | | } |
| | | if (pakMk != null) { |
| | | staProtocol.setPakMk(pakMk.equals("Y")); |
| | | } |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(TaskType.WRITE, staProtocol)); |
| | | if (result) { |
| | | redis.push(RedisConveyorConstant.CONVEYOR_TASK_FLAG, staProtocol); |
| | | return R.ok(); |
| | | } else { |
| | | return R.error("下发命令失败"); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |