From def4c65d0ed71a48374c8614fcc74820ce2b6d84 Mon Sep 17 00:00:00 2001 From: ZengTao <2773468879@qq.com> Date: 星期二, 16 一月 2024 15:01:14 +0800 Subject: [PATCH] 主界面添加玻璃id,设备状态等显示 --- springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java | 88 +++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 82 insertions(+), 6 deletions(-) diff --git a/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java b/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java index f6b9988..c296ec6 100644 --- a/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java +++ b/springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java @@ -1,10 +1,15 @@ package com.example.springboot.service; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.example.springboot.common.Result; +import com.example.springboot.component.S7control; import com.example.springboot.entity.StorageCage; import com.example.springboot.entity.StorageTask; import com.example.springboot.mapper.HomeMapper; @@ -21,10 +26,25 @@ private SpianService spianService; public void EndTask(int types) { + String A01glassid1 = spianService.queGlassid("DB103.128", 14).toString(); + String A01glassid2 = spianService.queGlassid("DB103.142", 14).toString(); + String A02glassid1 = spianService.queGlassid("DB103.156", 14).toString(); + String B01glassid = spianService.queGlassid("DB103.184", 14).toString(); + String B02glassid = spianService.queGlassid("DB103.198", 14).toString(); if (types == 0) {// 缁堟杩涚墖浠诲姟 List<StorageTask> cageList = homeMapper.SelectTaskByState(types); for (StorageTask storageTask : cageList) { - outSliceServive.StopTask(storageTask.getGlassId(), types); + // 鍒ゆ柇鍑虹墖浠诲姟浣嶇疆骞舵竻闄ゅ搴旂幓鐠僫d + if (storageTask.getGlassId() == A01glassid1 || storageTask.getGlassId() == A01glassid2) { + outSliceServive.StopTask(storageTask.getGlassId(), types); + ClearGlassId("DB101.10.0"); + } else if (storageTask.getGlassId() == B01glassid) { + outSliceServive.StopTask(storageTask.getGlassId(), types); + ClearGlassId("DB101.10.2"); + } else if (storageTask.getGlassId() == B02glassid) { + ClearGlassId("DB101.10.3"); + outSliceServive.StopTask(storageTask.getGlassId(), types); + } } // 鍙戦�佺粓姝㈣繘鐗囦换鍔′俊鍙� } else {// 缁堟鍑虹墖浠诲姟 @@ -37,22 +57,78 @@ } else {// 鍑虹墖 outSliceServive.StopTask(storageCagez.getGlassId(), types); } + // 鍒ゆ柇鍑虹墖浠诲姟浣嶇疆骞舵竻闄ゅ搴旂幓鐠僫d + if (storageCagez.getGlassId() == A02glassid1) { + outSliceServive.StopTask(storageCagez.getGlassId(), types); + ClearGlassId("DB101.10.1"); + } else if (storageCagez.getGlassId() == B01glassid) { + outSliceServive.StopTask(storageCagez.getGlassId(), types); + ClearGlassId("DB101.10.2"); + } else if (storageCagez.getGlassId() == B02glassid) { + ClearGlassId("DB101.10.3"); + outSliceServive.StopTask(storageCagez.getGlassId(), types); + } } } } } + //鎵嬪姩瀹屾垚浠诲姟 public void UpdateTask(Integer types, Integer shelfrack, String glassid) { if (types == 0) {// 瀹屾垚杩涚墖 spianService.overtask(glassid); } else if (types == 1) {// 瀹屾垚鍑虹墖 spianService.overtask(glassid); - } else if (types == 2) {// 缁堟杩涚墖浠诲姟 - outSliceServive.StopTask(glassid, 0); - // 鍙戦�佺粓姝㈣繘鐗囦换鍔′俊鍙� - } else {// 缁堟鍑虹墖浠诲姟 - outSliceServive.StopTask(glassid, 1); + } + // else if (types == 2) {// 缁堟杩涚墖浠诲姟 + // outSliceServive.StopTask(glassid, 0); + // // 鍙戦�佺粓姝㈣繘鐗囦换鍔′俊鍙� + // } else {// 缁堟鍑虹墖浠诲姟 + // outSliceServive.StopTask(glassid, 1); + // } + } + + //鍒ゆ柇浠诲姟绫诲瀷鍚庢竻闄ゅ搴旂幓鐠僫d + public Result ClearGlassId(String position, String glassid) { + Map<String, Object> map = new HashMap<>(); + if (S7control.getinstance().CheckConnected() == true) { + // 鍒ゆ柇杩涘嚭杩樻槸鍑虹墖浠诲姟 + Short type = homeMapper.SelectTaskByGlassId(glassid); + if (type == 0) { + // 杩涚墖 + outSliceServive.StopTask(glassid, 0); + } else if (type == 1) { + // 鍑虹墖 + outSliceServive.StopTask(glassid, 1); + } else { + // 璋冩嫧 + outSliceServive.StopTask(glassid, 0); + outSliceServive.StopTask(glassid, 1); + } + ClearGlassId(position); + map.put("message", "200"); + } else { + map.put("message", "300"); } + return Result.success(map); + } + + //娓呴櫎鐜荤拑id + public Result ClearGlassId(String position) { + Map<String, Object> map = new HashMap<>(); + if (S7control.getinstance().CheckConnected() == true) { + S7control.getinstance().WriteBit(position, true); + try { + TimeUnit.MILLISECONDS.sleep(300); + } catch (InterruptedException e) { + e.printStackTrace(); + } + S7control.getinstance().WriteBit(position, false); + map.put("message", "200"); + } else { + map.put("message", "300"); + } + return Result.success(map); } } -- Gitblit v1.8.0