From 58d7b0e12ccd92cf3934f6582b51b5fbcecaa39a Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 09 五月 2024 09:42:41 +0800
Subject: [PATCH] 修改注入方式
---
springboot-vue3/src/main/java/com/example/springboot/service/StorageCageService.java | 184 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 147 insertions(+), 37 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 c296ec6..8cc5317 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,5 +1,6 @@
package com.example.springboot.service;
+import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -9,11 +10,16 @@
import org.springframework.stereotype.Service;
import com.example.springboot.common.Result;
+import com.example.springboot.component.Plchome;
import com.example.springboot.component.S7control;
+import com.example.springboot.entity.Queue;
import com.example.springboot.entity.StorageCage;
import com.example.springboot.entity.StorageTask;
+import com.example.springboot.entity.north_glass_buffer1;
import com.example.springboot.mapper.HomeMapper;
+import lombok.extern.slf4j.Slf4j;
+@Slf4j
@Service
public class StorageCageService {
@Autowired
@@ -25,85 +31,140 @@
@Autowired
private SpianService spianService;
+ @Autowired
+ private JdbcConnections jdbcConnections;
+
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();
+ String B02glassid = spianService.queGlassid("DB103.212", 14).toString();
+ String D02glassid = spianService.queGlassid("DB103.58", 14).toString();
+ List<Short> DeviceList = S7control.getinstance().ReadWord("DB103.0", 10);
if (types == 0) {// 缁堟杩涚墖浠诲姟
List<StorageTask> cageList = homeMapper.SelectTaskByState(types);
for (StorageTask storageTask : cageList) {
// 鍒ゆ柇鍑虹墖浠诲姟浣嶇疆骞舵竻闄ゅ搴旂幓鐠僫d
- if (storageTask.getGlassId() == A01glassid1 || storageTask.getGlassId() == A01glassid2) {
+ if ((storageTask.getGlassId().equals(A01glassid1) || storageTask.getGlassId().equals(A01glassid2))
+ && DeviceList.get(4) == 0) {
outSliceServive.StopTask(storageTask.getGlassId(), types);
ClearGlassId("DB101.10.0");
- } else if (storageTask.getGlassId() == B01glassid) {
+ }
+ if (storageTask.getGlassId().equals(B01glassid) && DeviceList.get(2) == 0) {
outSliceServive.StopTask(storageTask.getGlassId(), types);
ClearGlassId("DB101.10.2");
- } else if (storageTask.getGlassId() == B02glassid) {
+ }
+ if (storageTask.getGlassId().equals(B02glassid) && DeviceList.get(3) == 0) {
ClearGlassId("DB101.10.3");
+ outSliceServive.StopTask(storageTask.getGlassId(), types);
+ }
+ log.info("stopfeedid:"+storageTask.getGlassId()+"D02id:"+D02glassid+"devicestate:"+DeviceList.get(1));
+ if (storageTask.getGlassId().equals(D02glassid) && DeviceList.get(1) == 0) {
+ ClearGlassId("DB101.9.3");
outSliceServive.StopTask(storageTask.getGlassId(), types);
}
}
// 鍙戦�佺粓姝㈣繘鐗囦换鍔′俊鍙�
} else {// 缁堟鍑虹墖浠诲姟
- List<StorageCage> storageCages = homeMapper.selectinout(3);
- for (StorageCage storageCage : storageCages) {
- List<StorageCage> storageCagess = homeMapper.SelectStoragesGlassById(storageCage.getGlassId());
- for (StorageCage storageCagez : storageCagess) {
- if (storageCagez.getState().equals("2")) {// 璋冩嫧杩涚墖
- outSliceServive.StopTask(storageCagez.getGlassId(), 0);
- } else {// 鍑虹墖
- outSliceServive.StopTask(storageCagez.getGlassId(), types);
- }
- // 鍒ゆ柇鍑虹墖浠诲姟浣嶇疆骞舵竻闄ゅ搴旂幓鐠僫d
- if (storageCagez.getGlassId() == A02glassid1) {
- outSliceServive.StopTask(storageCagez.getGlassId(), types);
+ List<StorageTask> cageLists = homeMapper.SelectTaskByState(types);
+ List<StorageTask> cageList2 = homeMapper.SelectTaskByState(2);
+ if (cageList2.size() > 0) {
+ cageLists.add(cageList2.get(0));
+ }
+ for (StorageTask cageList : cageLists) {
+ if (cageList.getTaskType().equals("1")) {
+ System.out.println(DeviceList.get(5));
+ if (cageList.getGlassId().equals(A02glassid1) && DeviceList.get(5) == 0) {
+ outSliceServive.StopTask(cageList.getGlassId(), types);
ClearGlassId("DB101.10.1");
- } else if (storageCagez.getGlassId() == B01glassid) {
- outSliceServive.StopTask(storageCagez.getGlassId(), types);
+ }
+ if (cageList.getGlassId().equals(B01glassid) && DeviceList.get(2) == 0) {
+ outSliceServive.StopTask(cageList.getGlassId(), types);
ClearGlassId("DB101.10.2");
- } else if (storageCagez.getGlassId() == B02glassid) {
+ }
+ if (cageList.getGlassId().equals(B02glassid) && DeviceList.get(3) == 0) {
+ outSliceServive.StopTask(cageList.getGlassId(), types);
ClearGlassId("DB101.10.3");
- outSliceServive.StopTask(storageCagez.getGlassId(), types);
+ }
+ } else if (cageList.getTaskType().equals("2")) {
+ if (cageList.getGlassId().equals(A02glassid1) && DeviceList.get(5) == 0) {
+ outSliceServive.StopTask(cageList.getGlassId(), 2);
+ ClearGlassId("DB101.10.1");
+ }
+ if (cageList.getGlassId().equals(B01glassid) && DeviceList.get(2) == 0) {
+ outSliceServive.StopTask(cageList.getGlassId(), 2);
+ ClearGlassId("DB101.10.2");
+ }
+ if (cageList.getGlassId().equals(B02glassid) && DeviceList.get(3) == 0) {
+ outSliceServive.StopTask(cageList.getGlassId(), 2);
+ ClearGlassId("DB101.10.3");
}
}
}
+
+ // List<StorageCage> storageCages = homeMapper.selectinout(3);
+ // for (StorageCage storageCage : storageCages) {
+ // List<StorageCage> storageCagess =
+ // homeMapper.SelectStoragesGlassById(storageCage.getGlassId());
+
+ // for (StorageCage storageCagez : storageCagess) {
+
+ // if (storageCagez.getState().equals("2")) {// 璋冩嫧杩涚墖
+ // outSliceServive.StopTask(storageCagez.getGlassId(), 0);
+ // } else {// 鍑虹墖
+ // outSliceServive.StopTask(storageCagez.getGlassId(), types);
+ // }
+
+ // // 鍒ゆ柇鍑虹墖浠诲姟浣嶇疆骞舵竻闄ゅ搴旂幓鐠僫d
+ // if (storageCagez.getGlassId() == A02glassid1&&DeviceList.get(5)==0) {
+ // outSliceServive.StopTask(storageCagez.getGlassId(), types);
+ // ClearGlassId("DB101.10.1");
+ // } else if (storageCagez.getGlassId() == B01glassid&&DeviceList.get(2)==0) {
+ // outSliceServive.StopTask(storageCagez.getGlassId(), types);
+ // ClearGlassId("DB101.10.2");
+ // } else if (storageCagez.getGlassId() == B02glassid&&DeviceList.get(3)==0) {
+ // 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);
- // // 鍙戦�佺粓姝㈣繘鐗囦换鍔′俊鍙�
+ // outSliceServive.StopTask(glassid, 0);
+ // // 鍙戦�佺粓姝㈣繘鐗囦换鍔′俊鍙�
// } else {// 缁堟鍑虹墖浠诲姟
- // outSliceServive.StopTask(glassid, 1);
+ // outSliceServive.StopTask(glassid, 1);
// }
}
- //鍒ゆ柇浠诲姟绫诲瀷鍚庢竻闄ゅ搴旂幓鐠僫d
+ // 鍒ゆ柇浠诲姟绫诲瀷鍚庢竻闄ゅ搴旂幓鐠僫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);
+ if (type != null) {
+ 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");
@@ -113,7 +174,7 @@
return Result.success(map);
}
- //娓呴櫎鐜荤拑id
+ // 娓呴櫎鐜荤拑id
public Result ClearGlassId(String position) {
Map<String, Object> map = new HashMap<>();
if (S7control.getinstance().CheckConnected() == true) {
@@ -131,4 +192,53 @@
return Result.success(map);
}
+ public Result InsertQueueGlassId(Short id, Queue queue) throws SQLException {
+ Map<String, Object> map = new HashMap<>();
+
+ Short zhi = 200;
+ short result = homeMapper.SelectStorageByGlassId(queue.getglassId());
+ if (result > 0) {
+ map.put("message", "500");
+ } else {
+ if (id == 1) {
+ // 璋冪敤浼嶅瓨鍌ㄨ繃绋�
+ north_glass_buffer1 north_glass_buffer1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queue.getglassId(), "", "");
+ zhi = spianService.selectAll(north_glass_buffer1);
+ if (zhi == 200) {
+ homeMapper.InsertQueueGlassId(queue, id);
+ }
+ }
+ map.put("message", zhi);
+ }
+ if (zhi != 200) {
+ Plchome.FeedState = true;
+ }
+ return Result.success(map);
+ }
+
+ public Short InsertQueueGlassIds(Short id, Queue queue) throws SQLException {
+ Map<String, Object> map = new HashMap<>();
+
+ Short zhi = 0;
+ short result = homeMapper.SelectStorageByGlassId(queue.getglassId());
+ if (result > 0) {
+ zhi=500;
+ map.put("message", "500");
+ } else {
+ if (id == 1) {
+ // 璋冪敤浼嶅瓨鍌ㄨ繃绋�
+ north_glass_buffer1 north_glass_buffer1 = jdbcConnections.SelectGlassByGlassIdOrderIdFrameId(queue.getglassId(), "", "");
+ zhi = spianService.selectAll(north_glass_buffer1);
+ if (zhi == 200) {
+ homeMapper.InsertQueueGlassId(queue, id);
+ }
+ }
+ map.put("message", zhi);
+ }
+ if (zhi != 200) {
+ Plchome.FeedState = true;
+ }
+ return zhi;
+ }
+
}
--
Gitblit v1.8.0