| | |
| | | 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.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; |
| | |
| | | /** |
| | | * 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 = 1015; |
| | | 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 = 1022; |
| | | dev_no1 = 1021; |
| | | dev_no2 = 1022; |
| | | dev_no3 = 1023; |
| | | } else if (ledId == 4) { |
| | | dev_no = 1025; |
| | | 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); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wms_wrk_no", basDevp.getWrkNo())); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | return R.ok(); |
| | | } |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | return R.ok(); |
| | | |
| | | // 组装命令 |
| | | LedCommand ledCommand = new LedCommand(); |
| | | ledCommand.setWorkNo(wrkMast.getWmsWrkNo()); |
| | | ledCommand.setIoType(wrkMast.getIoType()); |
| | | // 出库模式 |
| | | switch (wrkMast.getIoType()) { |
| | | case 1: |
| | | ledCommand.setTitle("全板入库"); |
| | | break; |
| | | case 10: |
| | | ledCommand.setTitle("空板入库"); |
| | | break; |
| | | case 101: |
| | | ledCommand.setTitle("全板出库"); |
| | | break; |
| | | case 103: |
| | | ledCommand.setTitle("拣料出库"); |
| | | break; |
| | | case 104: |
| | | ledCommand.setTitle("并板出库"); |
| | | break; |
| | | case 107: |
| | | ledCommand.setTitle("盘点出库"); |
| | | break; |
| | | case 110: |
| | | ledCommand.setTitle("空板出库"); |
| | | ledCommand.setEmptyMk(true); |
| | | break; |
| | | case 53: |
| | | ledCommand.setTitle("拣料入库"); |
| | | break; |
| | | case 57: |
| | | ledCommand.setTitle("盘点入库"); |
| | | break; |
| | | case 54: |
| | | ledCommand.setTitle("并板入库"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | ledCommand.setSourceLocNo(wrkMast.getSourceLocNo()); |
| | | ledCommand.setLocNo(wrkMast.getLocNo()); |
| | | ledCommand.setStaNo(wrkMast.getStaNo()); |
| | | if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) { |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("taskNo", wrkMast.getWmsWrkNo()); |
| | | param.put("sta", wrkMast.getStaNo()); |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | return R.ok().add(commands); |
| | | } |
| | | |
| | | /** |
| | |
| | | continue; |
| | | } |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if (Cools.isEmpty(shuttleProtocol.getErrorCode())) { |
| | | continue; |
| | | } |
| | | int i = Integer.parseInt(shuttleProtocol.getErrorCode()); |
| | | if (i > 0) { |
| | | BasShuttleErr basShuttleErr = basShuttleErrService.queryByCode(i); |