| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.core.properties.SystemProperties; |
| | | import com.zy.asrs.domain.enums.SiteStatusType; |
| | | import com.zy.asrs.domain.param.SystemSwitchParam; |
| | | import com.zy.asrs.domain.vo.*; |
| | | import com.zy.common.CodeRes; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.zy.asrs.entity.BasMap; |
| | | import com.zy.asrs.service.BasMapService; |
| | | 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.enums.RedisKeyType; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.properties.SystemProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Random; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 主控图接口 |
| | | * Created by vincent on 2020-06-01 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/console") |
| | | public class ConsoleController { |
| | | |
| | | public static AtomicInteger integer = new AtomicInteger(); |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private BasMapService basMapService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Value("${super.pwd}") |
| | | private String superPwd; |
| | | @Autowired |
| | | private NavigateMapData navigateMapData; |
| | | |
| | | @PostMapping("/system/running/status") |
| | | @ManagerAuth(memo = "系统运行状态") |
| | |
| | | return R.error("口令错误"); |
| | | } |
| | | } |
| | | Thread.sleep(2000L); |
| | | Thread.sleep(200L); |
| | | SystemProperties.WCS_RUNNING_STATUS.set(param.getOperatorType()==1?Boolean.TRUE:Boolean.FALSE); |
| | | return R.ok().add(Cools.add("status", SystemProperties.WCS_RUNNING_STATUS.get())); |
| | | } |
| | | |
| | | @PostMapping("/site/detail") |
| | | @ManagerAuth(memo = "输送设备数据详情") |
| | | public R siteDetail(@RequestParam String siteId){ |
| | | if (Cools.isEmpty(siteId)){ |
| | | return R.parse(CodeRes.EMPTY); |
| | | /** |
| | | * 获取地图楼层数据 |
| | | */ |
| | | @GetMapping("/map/lev/list") |
| | | @ManagerAuth |
| | | public R getMapLevList() { |
| | | List<BasMap> basMaps = basMapService.selectList(new EntityWrapper<BasMap>().orderBy("lev", true)); |
| | | ArrayList<Integer> levList = new ArrayList<>(); |
| | | for (BasMap basMap : basMaps) { |
| | | levList.add(basMap.getLev()); |
| | | } |
| | | SiteDetailVo vo = new SiteDetailVo(); |
| | | vo.setDevpNo(siteId); |
| | | vo.setWorkNo("9998"); |
| | | vo.setWorkStatus("2.设备上移动"); |
| | | vo.setAutoing("Y"); |
| | | vo.setLoading("Y"); |
| | | vo.setCanining("N"); |
| | | vo.setCanouting("Y"); |
| | | vo.setIoType("1.入库"); |
| | | vo.setSourceStaNo("2303"); |
| | | vo.setStaNo("2410"); |
| | | vo.setSourceStock(""); |
| | | vo.setStock(""); |
| | | return R.ok().add(vo); |
| | | return R.ok().add(levList); |
| | | } |
| | | |
| | | @PostMapping("/crn/detail") |
| | | @ManagerAuth(memo = "堆垛机设备数据详情") |
| | | public R crnDetail(@RequestParam String crnNo){ |
| | | if (Cools.isEmpty(crnNo)){ |
| | | return R.parse(CodeRes.EMPTY); |
| | | /** |
| | | * 获取地图数据 |
| | | */ |
| | | @GetMapping("/map/{lev}/auth") |
| | | @ManagerAuth |
| | | public R getMapFromRedis(@PathVariable Integer lev) { |
| | | Object data = redisUtil.get(RedisKeyType.MAP.key + lev); |
| | | if (data == null) { |
| | | return R.error(); |
| | | } |
| | | CrnDetailVo vo = new CrnDetailVo(); |
| | | vo.setCrnNo(crnNo); |
| | | vo.setWorkNo("3387"); |
| | | vo.setSourceStaNo("2303"); |
| | | vo.setStaNo("2410"); |
| | | vo.setWorkStatus("3.吊车入库中"); |
| | | vo.setIoType("1.入库"); |
| | | vo.setSourceStock(""); |
| | | vo.setStock("05050040"); |
| | | vo.setCrnStatus("取货中"); |
| | | vo.setError("0"); |
| | | return R.ok().add(vo); |
| | | |
| | | 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);//过滤地图数据 |
| | | return R.ok().add(lists); |
| | | } |
| | | |
| | | @Deprecated |
| | | @PostMapping("/site/update") |
| | | @ManagerAuth(memo = "输送设备数据修改") |
| | | public R updateSite(){ |
| | | /** |
| | | * 重置redis中的地图,将占用的库位全部解除 |
| | | */ |
| | | @GetMapping("/map/resetMap/auth") |
| | | @ManagerAuth |
| | | public R resetMapToRedis() { |
| | | for (int i = 1; i <= 10; i++) {//总共10层楼 |
| | | redisUtil.del(RedisKeyType.MAP.key + i); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @Deprecated |
| | | @PostMapping("/crn/update") |
| | | @ManagerAuth(memo = "堆垛机数据修改") |
| | | public R updateCrn(){ |
| | | /** |
| | | * 重置redis中的地图,将占用的库位全部解除 |
| | | */ |
| | | @GetMapping("/map/resetMap/{lev}") |
| | | @ManagerAuth(memo = "重置Redis地图") |
| | | public R resetMapToRedisByLev(@PathVariable Integer lev, HttpServletRequest request) { |
| | | redisUtil.del(RedisKeyType.MAP.key + lev); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /****************************************************************/ |
| | | /************************** 实时数据 ******************************/ |
| | | /****************************************************************/ |
| | | |
| | | @PostMapping("/latest/data/site") |
| | | @ManagerAuth(memo = "站点实时数据") |
| | | public R siteLatestData(){ |
| | | List<SiteLatestDataVo> vos = new ArrayList<>(); |
| | | for (int i = 1; i<=32; i++){ |
| | | SiteLatestDataVo vo = new SiteLatestDataVo(); |
| | | vo.setSiteId(String.valueOf(i)); |
| | | vo.setWorkNo("9998"); |
| | | SiteStatusType type = SiteStatusType.values()[new Random().nextInt(SiteStatusType.values().length)]; |
| | | vo.setSiteStatus(type); |
| | | vos.add(vo); |
| | | } |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PostMapping("/latest/data/crn") |
| | | @ManagerAuth(memo = "堆垛机实时数据") |
| | | public R crnLatestData(){ |
| | | List<CrnLatestDataVo> vos = new ArrayList<>(); |
| | | for (int i =1; i<=2; i++){ |
| | | CrnLatestDataVo vo = new CrnLatestDataVo(); |
| | | vo.setCrnId(i); |
| | | vo.setOffset((double) new Random().nextInt(560)); |
| | | vos.add(vo); |
| | | } |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PostMapping("/latest/data/barcode") |
| | | @ManagerAuth(memo = "条码扫描仪实时数据") |
| | | public R barcodeLatestData(){ |
| | | integer.getAndIncrement(); |
| | | List<BarcodeDataVo> list = new ArrayList<>(); |
| | | for (int i=1;i<=1;i++){ |
| | | BarcodeDataVo vo = new BarcodeDataVo(); |
| | | vo.setBarcodeId("1"); |
| | | if (integer.get()%5 != 0) { |
| | | vo.setCodeValue("0"); |
| | | } else { |
| | | vo.setCodeValue(String.valueOf(new Random().nextInt(5000))); |
| | | } |
| | | list.add(vo); |
| | | } |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | } |