zy-acs-common/pom.xml
@@ -17,11 +17,17 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <gson.version>2.11.0</gson.version> <fastjson.version>1.2.58</fastjson.version> </properties> <dependencies> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>${gson.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>${fastjson.version}</version> zy-acs-common/src/main/java/com/zy/acs/common/utils/GsonUtils.java
New file @@ -0,0 +1,37 @@ package com.zy.acs.common.utils; import com.google.gson.Gson; import com.google.gson.JsonSyntaxException; import com.google.gson.reflect.TypeToken; import java.lang.reflect.Type; import java.util.List; import java.util.Map; public class GsonUtils { // include cache private static final Gson gson = new Gson(); public static String toJson(Object object) { return gson.toJson(object); } public static <T> T fromJson(String json, Class<T> clazz) throws JsonSyntaxException { return gson.fromJson(json, clazz); } public static <T> T fromJson(String json, Type typeOfT) throws JsonSyntaxException { return gson.fromJson(json, typeOfT); } public static <T> List<T> fromJsonToList(String json, Class<T> clazz) throws JsonSyntaxException { Type type = TypeToken.getParameterized(List.class, clazz).getType(); return gson.fromJson(json, type); } public static <K, V> Map<K, V> fromJsonToMap(String json, Class<K> keyType, Class<V> valueType) throws JsonSyntaxException { Type type = TypeToken.getParameterized(Map.class, keyType, valueType).getType(); return gson.fromJson(json, type); } } zy-acs-flow/.env
@@ -1,5 +1,5 @@ COOL_BASE_IP = '10.242.136.69' # COOL_BASE_IP = '10.242.136.69' # COOL_BASE_IP = 'localhost' # COOL_BASE_IP = '192.168.4.36' COOL_BASE_IP = '192.168.4.36' COOL_BASE_PORT = 9090 zy-acs-flow/src/page/operationRecord/OperationDetail.jsx
@@ -12,7 +12,7 @@ const OperationDetail = (props) => { const { operation, ...rest } = props; return ( <> <Box width={{ xs: '100vW', sm: 400 }} mt={{ xs: 2, sm: 1 }}> @@ -25,7 +25,7 @@ variant="body2" flexWrap="nowrap" > {operation.namespace} {operation.namespace || ''} </Typography> </Labeled> </Grid> @@ -35,7 +35,7 @@ variant="body2" flexWrap="nowrap" > {operation.url} {operation.url || ''} </Typography> </Labeled> </Grid> @@ -55,14 +55,14 @@ variant="body2" flexWrap="nowrap" > {operation.userId$} {operation.userId$ || ''} </Typography> </Labeled> </Grid> <Grid item sm={12}> <TextField label="Request" value={operation.request} value={operation.request || ''} maxRows={15} multiline /> @@ -71,7 +71,7 @@ <Grid item sm={12}> <TextField label="Response" value={operation.response} value={operation.response || ''} maxRows={15} multiline /> @@ -82,7 +82,7 @@ variant="body2" flexWrap="nowrap" > {operation.clientIp} {operation.clientIp || ''} </Typography> </Labeled> </Grid> zy-acs-manager/src/main/java/com/zy/acs/manager/core/TestController.java
@@ -172,7 +172,7 @@ @Scheduled(cron = "0/1 * * * * ? ") private void demo() throws InterruptedException { if (!this.autoDemo) { return; } int busLimit = Integer.parseInt(configService.getVal("busLimit")); int busLimit = configService.getVal("busLimit", Integer.class); if (autoSize != null) { busLimit = autoSize; } @@ -246,7 +246,7 @@ @Scheduled(cron = "0/3 * * * * ? ") private void demo1() throws InterruptedException { if (!this.autoDemo1) { return; } int busLimit = Integer.parseInt(configService.getVal("busLimit")); int busLimit = configService.getVal("busLimit", Integer.class); if (autoSize != null) { busLimit = autoSize; } @@ -314,7 +314,7 @@ @Scheduled(cron = "0/3 * * * * ? ") private void demo2() throws InterruptedException { if (!this.autoDemo2) { return; } int busLimit = Integer.parseInt(configService.getVal("busLimit")); int busLimit = configService.getVal("busLimit", Integer.class); if (autoSize != null) { busLimit = autoSize; } zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MainService.java
@@ -255,7 +255,7 @@ throw new CoolException("generate [task] action fail, cause can not acquire lock ..."); } Date now = new Date(); final String sameGroupXy = configService.getVal( "sameGroupXy"); final String sameGroupXy = configService.getVal( "sameGroupXy", String.class); Agv agv = agvService.getById(agvId); if (!agvService.judgeEnable(agv.getId(), agvDetail -> agvDetail.getVol() > agv.getChargeLine())) { @@ -590,7 +590,7 @@ try { if (Cools.isEmpty(agvId, segmentList)) { return; } Date now = new Date(); JSONObject storeDirection = JSON.parseObject(configService.getVal("storeDirection")); JSONObject storeDirection = configService.getVal("storeDirection", JSONObject.class); Agv agv = agvService.getById(agvId); if (!agvService.judgeEnable(agv.getId())) { throw new CoolException("AGV[" + agv.getUuid() + "]当前不可用..."); zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MapService.java
@@ -133,7 +133,7 @@ double deltaX = x1 - x0; double deltaY = y1 - y0; double angle = Math.atan2(deltaX, deltaY); int offsetAngle = Integer.parseInt(configService.getVal("mapXoffset")); int offsetAngle = configService.getVal("mapXoffset", Integer.class); angle = angle + offsetAngle; angle = Math.toDegrees(angle); angle = (angle + 360) % 360; // 将角度转换为正值 zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/MockService.java
@@ -66,7 +66,7 @@ @Transactional public List<MockVo> submit(List<MockAgvDto> agvList, List<MockDto> taskList) { final String sameGroupXy = configService.getVal("sameGroupXy"); final String sameGroupXy = configService.getVal("sameGroupXy", String.class); List<MockVo> result = new ArrayList<>(); if (Cools.isEmpty(taskList)) { zy-acs-manager/src/main/java/com/zy/acs/manager/system/controller/ConfigController.java
@@ -1,5 +1,6 @@ package com.zy.acs.manager.system.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zy.acs.framework.common.Cools; zy-acs-manager/src/main/java/com/zy/acs/manager/system/enums/ConfigType.java
New file @@ -0,0 +1,29 @@ package com.zy.acs.manager.system.enums; import com.zy.acs.framework.exception.CoolException; public enum ConfigType { BOOLEAN(1), NUMBER(2), STRING(3), JSON(4), DATE(5), ; public int type; ConfigType(int type) { this.type = type; } public static ConfigType query(int type) { for (ConfigType value : ConfigType.values()) { if (type == value.type) { return value; } } throw new CoolException("ConfigType Error!"); } } zy-acs-manager/src/main/java/com/zy/acs/manager/system/service/ConfigService.java
@@ -5,6 +5,6 @@ public interface ConfigService extends IService<Config> { String getVal(String key); <T> T getVal(String key, Class<T> clazz); } zy-acs-manager/src/main/java/com/zy/acs/manager/system/service/impl/ConfigServiceImpl.java
@@ -1,11 +1,18 @@ package com.zy.acs.manager.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zy.acs.common.utils.GsonUtils; import com.zy.acs.framework.common.DateUtils; import com.zy.acs.manager.system.entity.Config; import com.zy.acs.manager.system.enums.ConfigType; import com.zy.acs.manager.system.mapper.ConfigMapper; import com.zy.acs.manager.system.service.ConfigService; import com.zy.acs.framework.exception.CoolException; import org.springframework.stereotype.Service; import java.util.Date; import java.util.List; /** * Created by vincent on 8/30/2024 @@ -14,8 +21,40 @@ public class ConfigServiceImpl extends ServiceImpl<ConfigMapper, Config> implements ConfigService { @Override public String getVal(String key) { throw new CoolException("Config还没做"); @SuppressWarnings("unchecked") public <T> T getVal(String key, Class<T> clazz) { List<Config> list = this.list(new LambdaQueryWrapper<Config>().eq(Config::getFlag, key)); Config config = list.stream().findFirst().orElse(null); if (null == config) { return null; } String val = config.getVal(); switch (ConfigType.query(config.getType())) { case BOOLEAN: if (val.equals("1") || val.trim().toUpperCase().equals("TRUE")) { return (T) Boolean.TRUE; } return (T) Boolean.FALSE; case NUMBER: if (clazz == Integer.class) { return (T) Integer.valueOf(val); } else if (clazz == Short.class) { return (T) Short.valueOf(val); } else if (clazz == Long.class) { return (T) Long.valueOf(val); } else if (clazz == Double.class) { return (T) Double.valueOf(val); } throw new UnsupportedOperationException("Unsupported type: " + clazz.getName()); case STRING: return (T) val; case JSON: return GsonUtils.fromJson(val, clazz); case DATE: return (T) DateUtils.convert(val); default: return null; } } }