From b99858aa6d24d6e5f0c300701bcf3f5fa8f05a23 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期三, 29 十二月 2021 16:22:58 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/CrnThread.java | 38 +++++++++++++++++++++++++++++--------- 1 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/zy/core/thread/CrnThread.java b/src/main/java/com/zy/core/thread/CrnThread.java index e054bfd..868a52f 100644 --- a/src/main/java/com/zy/core/thread/CrnThread.java +++ b/src/main/java/com/zy/core/thread/CrnThread.java @@ -7,7 +7,9 @@ import com.core.common.DateUtils; import com.core.common.SpringUtils; import com.core.exception.CoolException; +import com.zy.asrs.entity.BasCrnOpt; import com.zy.asrs.entity.BasCrnp; +import com.zy.asrs.service.BasCrnOptService; import com.zy.asrs.service.BasCrnpService; import com.zy.core.ThreadHandler; import com.zy.core.cache.MessageQueue; @@ -115,7 +117,7 @@ try { /* 鏂规硶1 */ - OperateResultExOne<byte[]> result = melsecMcNet.Read("D2231", (short) 62); + OperateResultExOne<byte[]> result = melsecMcNet.Read("D2231", (short) 70); if (result.IsSuccess) { if (null == crnProtocol) { crnProtocol = new CrnProtocol(); @@ -142,12 +144,13 @@ crnProtocol.setXDistance(melsecMcNet.getByteTransform().TransSingle(result.Content, 46)); crnProtocol.setYDistance(melsecMcNet.getByteTransform().TransSingle(result.Content, 50)); crnProtocol.setXDuration(melsecMcNet.getByteTransform().TransSingle(result.Content, 54)); - crnProtocol.setYDuration(melsecMcNet.getByteTransform().TransSingle(result.Content, 58)); + crnProtocol.setYDuration(melsecMcNet.getByteTransform().TransSingle(result.Content, 62)); OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId())); // 澶嶄綅淇″彿 if (crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) { + log.error("-------------------------------------------绗竴姝ャ�乕鍫嗗灈鏈哄彿锛歿}][宸ヤ綔鍙凤細{}]==>> 鐘舵�佷负90锛岀瓑寰呯‘璁わ紒锛�",slave.getId(),crnProtocol.getTaskNo()); if (resetFlag) { if (melsecMcNet.Write("D2218", (short) 1).IsSuccess) { resetFlag = false; @@ -158,6 +161,7 @@ // 鏍规嵁瀹炴椂淇℃伅鏇存柊鏁版嵁搴� BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); BasCrnp basCrnp = new BasCrnp(); + basCrnp.setCrnErr(crnProtocol.getAlarm()==null?0:crnProtocol.getAlarm().longValue()); basCrnp.setCrnNo(slave.getId()); if (!basCrnpService.updateById(crnProtocol.toSqlModel(basCrnp))){ log.error("鍫嗗灈鏈簆lc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); @@ -238,6 +242,29 @@ if (!melsecMcNet.Write("D2218", command.getAckFinish()).IsSuccess) { break; } } + try { + // 鏃ュ織璁板綍 + BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class); + BasCrnOpt basCrnOpt = new BasCrnOpt( + command.getTaskNo().intValue(), // 浠诲姟鍙� + command.getCrnNo(), // 鍫嗗灈鏈篬闈炵┖] + new Date(), // 涓嬪彂鏃堕棿 + command.getTaskModeType().toString(), // 妯″紡 + command.getSourcePosX().intValue(), // 婧愭帓 + command.getSourcePosY().intValue(), // 婧愬垪 + command.getSourcePosZ().intValue(), // 婧愬眰 + null, // 婧愮珯 + command.getDestinationPosX().intValue(), // 鐩爣鎺� + command.getDestinationPosY().intValue(), // 鐩爣鍒� + command.getDestinationPosZ().intValue(), // 鐩爣灞� + null, // 鐩爣绔� + null, // 鍝嶅簲缁撴灉 + null, // 淇敼鏃堕棿 + null // 淇敼浜哄憳 + ); + bean.insert(basCrnOpt); + } catch (Exception ignore) {} + log.info("鍫嗗灈鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); @@ -267,13 +294,6 @@ @Override public void close() { melsecMcNet.ConnectClose(); - } - - public CrnProtocol getCrnProtocol(){ - if (crnProtocol == null) { - throw new CoolException(slave.getId() + "鍙峰爢鍨涙満杩炴帴澶辫触"); - } - return this.crnProtocol; } -- Gitblit v1.9.1