| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.service.AgvBasDevpService; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.core.News; |
| | | import com.zy.core.Slave; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.io.DataInputStream; |
| | | import java.io.DataOutputStream; |
| | |
| | | this.barcode.delete(0, this.barcode.length()); |
| | | this.barcode.append(barcode); |
| | | if(!Cools.isEmpty(barcode)) { |
| | | AgvBasDevpService agvBasDevpService = SpringUtils.getBean(AgvBasDevpService.class); |
| | | News.info("{}号条码器,检索数据:{}", slave.getId(), this.barcode); |
| | | |
| | | String devNo = slave.getId() == 13 ? "310-1" : slave.getId() == 15 ? "312-2" : slave.getId() == 17 ? "314-1" : slave.getId() == 19 ? "316-1" : null; |
| | | if(!Cools.isEmpty(devNo)){ |
| | | barcode = barcode.substring(3,barcode.length()); |
| | | int updateBarcode = agvBasDevpService.updateBarcode(devNo, barcode); |
| | | if (updateBarcode <= 0) { |
| | | News.info("{}号条码器,检索数据:{},更新站点条码失败", slave.getId(), this.barcode); |
| | | } |
| | | } |
| | | News.info("{}号条码器,更新成功", slave.getId()); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F)); |
| | | jsonObject.put("barcode", barcode); |
| | |
| | | OutputQueue.BARCODE.poll(); |
| | | } |
| | | OutputQueue.BARCODE.offer(jsonObject); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | close(); //1.主动释放连接 //2.某些服务器对指定ip有链路数限制 |
| | | socket = new Socket(); |
| | | SocketAddress socketAddress = new InetSocketAddress(slave.getIp(), slave.getPort()); |
| | | socket.connect(socketAddress, 1000); //某些服务器ping延迟高时要增加,否则会报错connect timeout |
| | | socket.connect(socketAddress, 10000); //某些服务器ping延迟高时要增加,否则会报错connect timeout |
| | | dataOutputStream = new DataOutputStream(socket.getOutputStream()); |
| | | dataInputStream = new DataInputStream(socket.getInputStream()); |
| | | // log.info("条码扫描仪连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |