| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.acs.common.domain.AgvProtocol; |
| | | import com.zy.acs.common.domain.protocol.*; |
| | | import com.zy.acs.common.enums.AgvStatusType; |
| | | import com.zy.acs.common.enums.error.AgvErrorType; |
| | | import com.zy.acs.common.utils.GsonUtils; |
| | | import com.zy.acs.common.utils.RedisSupport; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.DateUtils; |
| | | import com.zy.acs.manager.core.constant.MapDataConstant; |
| | | import com.zy.acs.manager.core.domain.BackpackDto; |
| | | import com.zy.acs.manager.manager.entity.Agv; |
| | | import com.zy.acs.manager.core.domain.VehicleFaultDto; |
| | | import com.zy.acs.manager.manager.entity.AgvDetail; |
| | | import com.zy.acs.manager.manager.entity.Code; |
| | | import com.zy.acs.manager.manager.service.*; |
| | |
| | | IMessageBody msgBody = protocol.getMessageBody(); |
| | | assert msgBody != null; |
| | | |
| | | Agv agv = agvService.selectByUuid(protocol.getAgvNo()); |
| | | if (null == agv) { |
| | | Long agvId = agvService.getAgvId(protocol.getAgvNo()); |
| | | if (null == agvId) { |
| | | log.warn("Agv [{}] 尚未鉴权 !!!", protocol.getAgvNo()); |
| | | return; |
| | | } |
| | | AgvDetail detail = agvDetailService.selectByAgvId(agv.getId()); |
| | | AgvDetail detail = agvDetailService.selectByAgvId(agvId); |
| | | if (null == detail) { |
| | | detail = new AgvDetail(); |
| | | detail.setAgvId(agv.getId()); |
| | | detail.setAgvId(agvId); |
| | | if (!agvDetailService.save(detail)) { |
| | | log.error("Agv [{}] 详情更新失败 !!!", protocol.getAgvNo()); |
| | | return; |
| | |
| | | AGV_12_UP agv_12_up = (AGV_12_UP) msgBody; |
| | | |
| | | // unlock path |
| | | threadPoolRegulator.getInstance().execute(() -> { |
| | | mapService.unlockPath(protocol.getAgvNo(), agv_12_up.getQrCode()); |
| | | }); |
| | | mapService.unlockPath(protocol.getAgvNo(), agv_12_up.getQrCode()); |
| | | // threadPoolRegulator.getInstance().execute(() -> { |
| | | // |
| | | // }); |
| | | // finish jam |
| | | threadPoolRegulator.getInstance().execute(() -> jamService.checkIfFinish(agv.getId(), agv_12_up.getQrCode())); |
| | | threadPoolRegulator.getInstance().execute(() -> jamService.checkIfFinish(agvId, agv_12_up.getQrCode())); |
| | | |
| | | // websocketService.agvInfoBroadcastOnPos(new WebsocketDto<AGV_12_UP>("agv", agv.getUuid(), agv_12_up)); |
| | | this.sync(agv_12_up, detail); |
| | |
| | | // 故障数据包 |
| | | if (msgBody instanceof AGV_04_UP) { |
| | | AGV_04_UP agv_04_up = (AGV_04_UP) msgBody; |
| | | AgvErrorType errorType = AgvErrorType.query(agv_04_up.getHexFaultId()); |
| | | log.info("Agv [{}] 故障数据包 ===>> {}", protocol.getAgvNo(), JSON.toJSONString(agv_04_up)); |
| | | // faultProcessor.execute(new VehicleFaultDto()); |
| | | |
| | | // save |
| | | faultProcessor.execute(new VehicleFaultDto<>(protocol.getAgvNo(), protocol.getTimestamp(), agv_04_up)); |
| | | |
| | | // detail |
| | | String errorMSg = errorType != null ? errorType.getMsg() : agv_04_up.getHexFaultId(); |
| | | detail.setError(errorMSg); |
| | | detail.setErrorTime(new Date()); |
| | | } |
| | | |
| | | // 故障复位 |
| | | if (!Cools.isEmpty(detail.realError())) { |
| | | assert detail.getErrorTime() != null; |
| | | if (DateUtils.diffToSeconds(detail.getErrorTime(), new Date()) > 20) { |
| | | detail.setError(MapDataConstant.EMPTY_OF_ERROR); |
| | | } |
| | | } |
| | | if (!agvDetailService.updateById(detail)) { |
| | | log.error("Agv [{}] 详情更新失败 !!!", protocol.getAgvNo()); |
| | | } |
| | |
| | | |
| | | // 有码实时数据包 |
| | | private void sync(AGV_12_UP mesBody, AgvDetail detail) { |
| | | Code code = codeService.selectByData(mesBody.getQrCode()); |
| | | detail.setStatus(mesBody.getStatus()); |
| | | |
| | | Code code = codeService.getCacheByData(mesBody.getQrCode()); |
| | | if (null != code) { |
| | | detail.setCode(code.getId()); |
| | | detail.setLastCode(null); |
| | |
| | | } else { |
| | | log.error("Agv [{}] 更新定位数据失败 !!!上传条码:{}", agvService.getById(detail.getAgvId()).getUuid(), mesBody.getQrCode()); |
| | | } |
| | | |
| | | detail.setStatus(mesBody.getStatus()); |
| | | |
| | | // 地面码偏移 |
| | | detail.setCodeOffsert(JSON.toJSONString(Cools |
| | |
| | | |
| | | // 无码实时数据包 |
| | | private void sync(AGV_13_UP mesBody, AgvDetail detail) { |
| | | Code code = codeService.selectByData(mesBody.getQrCode()); |
| | | detail.setStatus(mesBody.getStatus()); |
| | | |
| | | Code code = codeService.getCacheByData(mesBody.getQrCode()); |
| | | if (null != code) { |
| | | detail.setCode(null); |
| | | detail.setLastCode(code.getId()); |
| | | detail.setPos(0); |
| | | // if (!agvDetailService.updateUnPosCode(detail.getId(), code.getId())) { |
| | | // log.error("Agv [{}] 更新定位数据失败 !!!", agvService.getById(detail.getAgvId()).getUuid()); |
| | | // } |
| | | |
| | | if (!detail.getAgvStatus().equals(AgvStatusType.CHARGE)) { |
| | | detail.setCode(null); |
| | | detail.setLastCode(code.getId()); |
| | | detail.setPos(0); |
| | | } else { |
| | | detail.setCode(code.getId()); |
| | | detail.setLastCode(null); |
| | | detail.setPos(1); |
| | | } |
| | | |
| | | |
| | | } else { |
| | | log.error("Agv [{}] 更新定位数据失败 !!!上传条码:{}", agvService.getById(detail.getAgvId()).getUuid(), mesBody.getQrCode()); |
| | | } |