| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Arith; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.dto.AxisBean; |
| | | import com.zy.asrs.domain.dto.WorkChartAxis; |
| | | import com.zy.asrs.domain.dto.LocChartPie; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasShuttle; |
| | | import com.zy.asrs.domain.dto.WorkChartAxis; |
| | | import com.zy.asrs.entity.BasShuttleErr; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.mapper.ReportQueryMapper; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasShuttleErrService; |
| | | import com.zy.asrs.service.BasShuttleService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.common.model.MatDto; |
| | | import com.zy.common.model.SearchLocParam; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.LedSlave; |
| | | import com.zy.core.model.ShuttleSlave; |
| | | import com.zy.core.model.command.LedCommand; |
| | | import com.zy.core.model.protocol.ShuttleProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.LedThread; |
| | | import com.zy.core.thread.ShuttleThread; |
| | | import com.zy.core.thread.impl.NormalLedThread; |
| | | 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.GetMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/11/16 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/monitor") |
| | | public class TVController { |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private BasShuttleErrService basShuttleErrService; |
| | | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Value("${asrs.wmsUrl}") |
| | | private String wmsUrl; |
| | | |
| | |
| | | */ |
| | | @GetMapping("/led") |
| | | public R monitorLed(@RequestParam("ledId") Integer ledId) { |
| | | int dev_no = 1012; |
| | | int dev_no1 = 1011; |
| | | int dev_no2 = 1012; |
| | | int dev_no3 = 0; |
| | | if (ledId == 1) { |
| | | dev_no = 1012; |
| | | dev_no1 = 1011; |
| | | dev_no2 = 1012; |
| | | } else if (ledId == 2) { |
| | | dev_no = 1014; |
| | | dev_no1 = 1013; |
| | | dev_no2 = 1014; |
| | | dev_no3 = 1015; |
| | | } else if (ledId == 3) { |
| | | dev_no = 1021; |
| | | dev_no1 = 1021; |
| | | dev_no2 = 1022; |
| | | dev_no3 = 1023; |
| | | } else if (ledId == 4) { |
| | | dev_no = 1024; |
| | | dev_no1 = 1024; |
| | | dev_no2 = 1025; |
| | | dev_no3 = 1026; |
| | | } |
| | | BasDevp basDevp = basDevpService.selectOne(new EntityWrapper<BasDevp>().eq("dev_no", dev_no)); |
| | | if (Cools.isEmpty(basDevp)) { |
| | | return R.ok(); |
| | | Object o1 = redisUtil.get("LED_" + dev_no1); |
| | | Object o2 = redisUtil.get("LED_" + dev_no2); |
| | | Object o3 = redisUtil.get("LED_" + dev_no3); |
| | | if (o1 != null) { |
| | | log.info("电视机显示1:{}", JSONObject.toJSONString(o1)); |
| | | return R.ok().add(o1); |
| | | } else if (o2 != null) { |
| | | log.info("电视机显示2:{}", JSONObject.toJSONString(o2)); |
| | | return R.ok().add(o2); |
| | | } else if (o3 != null) { |
| | | log.info("电视机显示3:{}", JSONObject.toJSONString(o3)); |
| | | return R.ok().add(o3); |
| | | } |
| | | if (Cools.isEmpty(basDevp.getWrkNo1())) { |
| | | return R.ok(); |
| | | } |
| | | if (basDevp.getWrkNo() == null || basDevp.getWrkNo() == 0) { |
| | | return R.ok(); |
| | | } |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("taskNo", basDevp.getWrkNo()); |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath("/rpc/led/getTask2") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | String data = jsonObject.getString("data"); |
| | | List<LedCommand> wrkDetls = JSONArray.parseArray(data, LedCommand.class); |
| | | commands.addAll(wrkDetls); |
| | | } else { |
| | | return R.ok(); |
| | | } |
| | | return R.ok().add(commands); |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | | /** |