|  |  |  | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.domain.param.SystemSwitchParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.BasMap; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.service.BasMapService; | 
|---|
|  |  |  | import com.zy.asrs.service.WrkMastService; | 
|---|
|  |  |  | import com.zy.common.model.MapNode; | 
|---|
|  |  |  | import com.zy.common.model.enums.NavigationMapType; | 
|---|
|  |  |  | import com.zy.common.utils.NavigateMapData; | 
|---|
|  |  |  | import com.zy.common.utils.RedisUtil; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.RedisKeyType; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.ForkLiftSlave; | 
|---|
|  |  |  | import com.zy.core.model.ShuttleSlave; | 
|---|
|  |  |  | import com.zy.core.model.protocol.ForkLiftProtocol; | 
|---|
|  |  |  | import com.zy.core.model.protocol.ShuttleProtocol; | 
|---|
|  |  |  | import com.zy.core.properties.SlaveProperties; | 
|---|
|  |  |  | import com.zy.core.properties.SystemProperties; | 
|---|
|  |  |  | import com.zy.core.thread.ForkLiftThread; | 
|---|
|  |  |  | import com.zy.core.thread.ShuttleThread; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | 
|---|
|  |  |  | private RedisUtil redisUtil; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private NavigateMapData navigateMapData; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SlaveProperties slaveProperties; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("/system/running/status") | 
|---|
|  |  |  | @ManagerAuth(memo = "系统运行状态") | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BasMap basMap = JSON.parseObject(data.toString(), BasMap.class); | 
|---|
|  |  |  | //解析json地图数据 | 
|---|
|  |  |  | ArrayList arrayList = JSON.parseObject(basMap.getData(), ArrayList.class); | 
|---|
|  |  |  | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.NONE.id, arrayList, lev, null, null);//过滤地图数据 | 
|---|
|  |  |  | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; | 
|---|
|  |  |  | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE, NavigationMapType.PATH_LOCK), arrayList, lev, null, null);//过滤地图数据 | 
|---|
|  |  |  | return R.ok().add(lists); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 获取库位地图数据 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/locMap/{lev}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R getLocMap(@PathVariable Integer lev) { | 
|---|
|  |  |  | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); | 
|---|
|  |  |  | if (data == null) { | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<List<MapNode>> arrayList = (List<List<MapNode>>) data; | 
|---|
|  |  |  | List<List<MapNode>> lists = navigateMapData.filterMap(NavigationMapType.getMapTypes(NavigationMapType.NONE), arrayList, lev, null, null);//过滤地图数据 | 
|---|
|  |  |  | return R.ok().add(lists); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | @GetMapping("/map/resetMap/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R resetMapToRedis() { | 
|---|
|  |  |  | for (int i = 1; i <= 10; i++) {//总共10层楼 | 
|---|
|  |  |  | redisUtil.del(RedisKeyType.MAP.key + i); | 
|---|
|  |  |  | List<BasMap> basMaps = basMapService.selectList(new EntityWrapper<BasMap>().orderBy("lev", true)); | 
|---|
|  |  |  | for (BasMap basMap : basMaps) { | 
|---|
|  |  |  | Integer lev = basMap.getLev(); | 
|---|
|  |  |  | redisUtil.del(RedisKeyType.MAP.key + lev); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth(memo = "重置Redis地图") | 
|---|
|  |  |  | public R resetMapToRedisByLev(@PathVariable Integer lev, HttpServletRequest request) { | 
|---|
|  |  |  | redisUtil.del(RedisKeyType.MAP.key + lev); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 任务检测 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @GetMapping("/checkTask") | 
|---|
|  |  |  | @ManagerAuth(memo = "任务检测") | 
|---|
|  |  |  | public R checkTask() { | 
|---|
|  |  |  | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<>()); | 
|---|
|  |  |  | if (!wrkMasts.isEmpty()) { | 
|---|
|  |  |  | return R.error("存在未结束任务"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (ShuttleSlave slave : slaveProperties.getShuttle()) { | 
|---|
|  |  |  | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId()); | 
|---|
|  |  |  | if (shuttleThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); | 
|---|
|  |  |  | if (shuttleProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (shuttleProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | return R.error(slave.getId() + "号小车存在工作号"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (ForkLiftSlave slave : slaveProperties.getForkLift()) { | 
|---|
|  |  |  | ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId()); | 
|---|
|  |  |  | if (forkLiftThread == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ForkLiftProtocol forkLiftProtocol = forkLiftThread.getStatus(); | 
|---|
|  |  |  | if (forkLiftProtocol == null) { | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (forkLiftProtocol.getTaskNo() > 0) { | 
|---|
|  |  |  | return R.error(slave.getId() + "号货叉提升机存在工作号"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|