This commit is contained in:
2023-03-29 10:25:59 +08:00
8 changed files with 269 additions and 106 deletions

View File

@@ -18,14 +18,6 @@ import java.sql.SQLException;
//@Configuration
@Slf4j
public class DataBaseConfig {
@Value("${erp.oracle.enabled}")
private boolean oracleIsConnect;
@Value("${erp.oracle.jdbcurl}")
private String oracleJdbcUrl;
@Value("${erp.oracle.username}")
private String oracleUserName;
@Value("${erp.oracle.password}")
private String oraclePassword;
@Primary
@Bean(name = "dataSource")
@@ -34,60 +26,4 @@ public class DataBaseConfig {
return new DruidDataSource();
}
@Bean(name = "dataSource1")
@ConditionalOnExpression("${erp.oracle.enabled:true}")
public DataSource dataSource1() {
System.out.println("是否连接oracle:"+oracleIsConnect);
System.out.println("erp.oracle.jdbcurl:"+oracleJdbcUrl);
System.out.println("erp.oracle.username:"+oracleUserName);
System.out.println("erp.oracle.password:"+oraclePassword);
log.info("是否连接oracle:"+oracleIsConnect);
log.info("erp.oracle.jdbcurl:"+oracleJdbcUrl);
log.info("erp.oracle.username:"+oracleUserName);
log.info("erp.oracle.password:"+oraclePassword);
String jdbcUrl = oracleJdbcUrl;
String userName = oracleUserName;
String password =oraclePassword;
DruidDataSource druidDataSource = new DruidDataSource();
String className;
try {
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
} catch (SQLException e) {
throw new RuntimeException("Get class name error: =" + jdbcUrl);
}
if (StrUtil.isEmpty(className)) {
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
if (null == dataTypeEnum) {
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
}
druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
} else {
druidDataSource.setDriverClassName(className);
}
druidDataSource.setUrl(jdbcUrl);
druidDataSource.setUsername(userName);
druidDataSource.setPassword(password);
// 配置获取连接等待超时的时间
druidDataSource.setMaxWait(3000);
// 配置初始化大小、最小、最大
druidDataSource.setInitialSize(5);
druidDataSource.setMinIdle(5);
druidDataSource.setMaxActive(10);
// 如果链接出现异常则直接判定为失败而不是一直重试
druidDataSource.setBreakAfterAcquireFailure(true);
try {
druidDataSource.init();
} catch (SQLException e) {
log.error("Exception during pool initialization", e);
throw new RuntimeException(e.getMessage());
}
return druidDataSource;
}
}

View File

@@ -331,6 +331,6 @@ public class MaterialbaseServiceImpl implements MaterialbaseService{
public void updateRedis() {
JSONArray materialJsonArray = WQL.getWO("PDA_QUERY").addParam("flag", "5").process().getResultJSONArray(0);
List<MaterialDto> finalMaterialList = materialJsonArray.toJavaList(MaterialDto.class);
redisUtils.set("materialList", finalMaterialList);
redisUtils.set("hl_one_wms:cacheLineHand:materialList", finalMaterialList);
}
}

View File

@@ -155,7 +155,7 @@ public class WmsToSapServiceImpl implements WmsToSapService {
} else {
sale_jo.put("qty_unit_id", unit_jo.getString("measure_unit_id"));
}
sale_jo.put("plandeliver_date", row.getString("Edaut"));
sale_jo.put("plandeliver_date", row.getString("Edatu"));
sale_jo.put("create_id", SecurityUtils.getCurrentUserId());
sale_jo.put("create_name", SecurityUtils.getCurrentNickName());
sale_jo.put("create_time", DateUtil.now());

View File

@@ -48,7 +48,7 @@ public class CacheLineHandController{
//任务类型和任务ID校验instruct_uuid为前端参数命名本来应为task_id
if(StringUtils.isNotEmpty(params)) {
//限制查询参数过短,模糊力度大
int length = params.length();
int length = params.getBytes().length;
if(length < 3) {
throw new BizCoreException("您输入的条件匹配的范围太大,请重新输入稍长一点的内容。");
}

View File

@@ -79,15 +79,15 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
List<MaterialDto> materialList;
ThreadPoolExecutor pool = ThreadPoolExecutorUtil.getPoll();
//12W种物料信息查本地缓存
materialList = cache.get("materialList");
materialList = cache.get("hl_one_wms:cacheLineHand:materialList");
if(null != materialList) {
return getMaterialDto(materialList, param);
}
//2.查reids
materialList = redisUtils.get("materialList", MaterialDto.class);
materialList = redisUtils.get("hl_one_wms:cacheLineHand:materialList", MaterialDto.class);
if(null != materialList) {
// //设置本地缓存
cache.setLocalCache("materialList", materialList);
cache.setLocalCache("hl_one_wms:cacheLineHand:materialList", materialList);
return getMaterialDto(materialList, param);
}
//3.查db
@@ -95,10 +95,10 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
materialList = materialJsonArray.toJavaList(MaterialDto.class);
//缓存到redis
List<MaterialDto> finalMaterialList1 = materialList;
CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> redisUtils.set("materialList", finalMaterialList1), pool);
CompletableFuture<Void> f1 = CompletableFuture.runAsync(() -> redisUtils.set("hl_one_wms:cacheLineHand:materialList", finalMaterialList1), pool);
//缓存到本地
List<MaterialDto> finalMaterialList = materialList;
CompletableFuture<Void> f2 = CompletableFuture.runAsync(() -> cache.setLocalCache("materialList", finalMaterialList), pool);
CompletableFuture<Void> f2 = CompletableFuture.runAsync(() -> cache.setLocalCache("hl_one_wms:cacheLineHand:materialList", finalMaterialList), pool);
f1.exceptionally((e) -> {
throw new BadRequestException("物料信息缓存redis失败");
});
@@ -162,8 +162,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
map.put("status", task_status.replace("-1", ""));
}
//任务编号
if(StrUtil.isNotEmpty(whereJson.getString("task_code"))) {
map.put("task_code", "%" + whereJson.getString("task_code") + "%");
if(StrUtil.isNotEmpty(whereJson.getString("inst_num"))) {
map.put("inst_num", "%" + whereJson.getString("inst_num") + "%");
}
//起点
if(StrUtil.isNotEmpty(whereJson.getString("start_point"))) {
@@ -448,7 +448,7 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
throw new BadRequestException("箱子【" + vehicle_code + "】已在库内,无法入空箱!");
}
// 3.判断是否可以放入空箱子
JSONObject json = positionTab.query("cacheLine_code = '" + cacheLine_code + "position_code = '" + position_code + "' and is_blank= '1'").uniqueResult(0);
JSONObject json = positionTab.query("cacheLine_code = '" + cacheLine_code + "' and position_code = '" + position_code + "' and is_empty= '1'").uniqueResult(0);
if(json == null) {
throw new BadRequestException("无法找到缓存线【" + position_code + "】的空位,无法入空箱!");
}
@@ -542,7 +542,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
* 料箱码 vehicle_code
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String inOutExceptionInstConfirm(JSONObject param) {
// 1 扫码异常-入箱扫码 2 扫码异常-出箱扫码
String inOut_type = param.getString("inOut_type");
@@ -560,17 +559,11 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
jsonObject.put("vehicle_code", vehicle_code);
jsonObject.put("position_code", position_code);
jsonArray.add(jsonObject);
try {
//TOFIX 等确定api后换成下发的url
return AcsUtil.notifyAcs("api", jsonArray).getString("status");
}
catch(Exception e) {
throw new BadRequestException(e.getMessage());
}
//TOFIX 等确定api后换成下发的url
return AcsUtil.notifyAcs("api", jsonArray).getString("status");
}
@Override
@Transactional(rollbackFor = Exception.class)
public String cacheLineExcepOpt(JSONObject param) {
// 缓存线编码
String wcsdevice_code = param.getString("wcsdevice_code");
@@ -586,13 +579,8 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
jsonObject.put("type", type);
jsonObject.put("wcsdevice_code", wcsdevice_code);
jsonArray.add(jsonObject);
try {
//TOFIX 等确定api后换成下发的url
return AcsUtil.notifyAcs("api", jsonArray).getString("status");
}
catch(Exception e) {
throw new BadRequestException(e.getMessage());
}
//TOFIX 等确定api后换成下发的url
return AcsUtil.notifyAcs("api", jsonArray).getString("status");
}
/**
@@ -840,10 +828,10 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
String pointCode = param.getString("wcsdevice_code");
String productArea = param.getString("product_area");
AtomicReference<JSONArray> res = new AtomicReference<>(new JSONArray());
RedissonUtils.lock(()->{
RedissonUtils.lock(() -> {
// 生产区域
res.set(WQL.getWO("PDA_QUERY").addParamMap(MapOf.of("flag", "8", "product_area", productArea, "cacheLine_code", pointCode)).process().getResultJSONArray(0));
},pointCode,3);
}, pointCode, 3);
return res.get();
}
@@ -854,7 +842,6 @@ public class CacheLineHandServiceImpl implements CacheLineHandService{
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteBox(JSONObject param) {
WQLObject cvTab = WQLObject.getWQLObject("SCH_CacheLine_VehileMaterial");
String vehicleCode = param.getString("vehicle_code");

View File

@@ -22,6 +22,7 @@
输入.start_point TYPEAS s_string
输入.end_point TYPEAS s_string
输入.start_date TYPEAS s_string
输入.vehicle_code TYPEAS s_string
输入.end_date TYPEAS s_string
输入.task_id TYPEAS s_string

View File

@@ -0,0 +1,200 @@
server:
port: 8011
#配置数据源
spring:
data:
elasticsearch:
repositories:
enabled: true
client:
reactive:
#endpoints: 172.31.185.110:9200,172.31.154.9:9200 #内网
# endpoints: 47.96.133.178:8200 #外网
endpoints: http://47.96.133.178:8200 #外网
elasticsearch:
rest:
#uris: 172.31.185.110:9200,172.31.154.9:9200 #内网
# uris: 47.96.133.178:8200 #外网
uris: http://47.96.133.178:8200 #外网
username: elastic
password: 123456
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
#url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:hl_one_mes}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true&useSSL=false
username: ${DB_USER:root}
#password: ${DB_PWD:P@ssw0rd}
#password: ${DB_PWD:root}
password: ${DB_PWD:Root.123456}
# 初始连接数
initial-size: 5
# 最小连接数
min-idle: 15
# 最大连接数
max-active: 30
# 是否自动回收超时连接
remove-abandoned: true
# 超时时间(以秒数为单位)
remove-abandoned-timeout: 180
# 获取连接超时时间
max-wait: 3000
# 连接有效性检测时间
time-between-eviction-runs-millis: 60000
# 连接在池中最小生存的时间
min-evictable-idle-time-millis: 300000
# 连接在池中最大生存的时间
max-evictable-idle-time-millis: 900000
# 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除
test-while-idle: true
# 指明是否在从池中取出连接前进行检验,如果检验失败, 则从池中去除连接并尝试取出另一个
test-on-borrow: true
# 是否在归还到池中前进行检验
test-on-return: false
# 检测连接是否有效
validation-query: select 1
# 配置监控统计
webStatFilter:
enabled: true
stat-view-servlet:
enabled: true
url-pattern: /druid/*
reset-enable: false
filters:
DruidFilter,stat
redis:
#数据库索引
database: ${REDIS_DB:1}
#host: ${REDIS_HOST:127.0.0.1}
host: ${REDIS_HOST:localhost}
port: ${REDIS_PORT:6379}
password: ${REDIS_PWD:}
#连接超时时间
timeout: 5000
redisson:
config: |
threads: 4
nettyThreads: 4
singleServerConfig:
connectionMinimumIdleSize: 8
connectionPoolSize: 8
address: redis://127.0.0.1:6379
idleConnectionTimeout: 10000
timeout: 3000
# 登录相关配置
login:
# 登录缓存
cache-enable: true
# 是否限制单用户登录
single-login: false
# 验证码
login-code:
# 验证码类型配置 查看 LoginProperties 类
code-type: arithmetic
# 登录图形验证码有效时间/分钟
expiration: 2
# 验证码高度
width: 111
# 验证码宽度
heigth: 36
# 内容长度
length: 2
# 字体名称,为空则使用默认字体
font-name:
# 字体大小
font-size: 25
#jwt
jwt:
header: Authorization
# 令牌前缀
token-start-with: Bearer
# 必须使用最少88位的Base64对该令牌进行编码
base64-secret: ZmQ0ZGI5NjQ0MDQwY2I4MjMxY2Y3ZmI3MjdhN2ZmMjNhODViOTg1ZGE0NTBjMGM4NDA5NzYxMjdjOWMwYWRmZTBlZjlhNGY3ZTg4Y2U3YTE1ODVkZDU5Y2Y3OGYwZWE1NzUzNWQ2YjFjZDc0NGMxZWU2MmQ3MjY1NzJmNTE0MzI=
# 令牌过期时间 此处单位/毫秒 默认4小时可在此网站生成 https://www.convertworld.com/zh-hans/time/milliseconds.html
token-validity-in-seconds: 14400000
# 在线用户key
online-key: online-token-
# 验证码
code-key: code-key-
# token 续期检查时间范围默认30分钟单位毫秒在token即将过期的一段时间内用户操作了则给用户的token续期
detect: 1800000
# 续期时间范围默认1小时单位毫秒
renew: 3600000
#是否允许生成代码生产环境设置为false
generator:
enabled: true
#是否开启 swagger-ui
swagger:
enabled: true
# IP 本地解析
ip:
local-parsing: true
# 文件存储路径
file:
mac:
path: ~/file/
avatar: ~/avatar/
linux:
path: /home/eladmin/file/
avatar: /home/eladmin/avatar/
windows:
path: C:\eladmin\file\
avatar: C:\eladmin\avatar\
# 文件大小 /M
maxSize: 100
avatarMaxSize: 5
sa-token:
# token 名称 (同时也是cookie名称)
token-name: Authorization
# token 有效期单位s 默认30天, -1代表永不过期
timeout: 2592000
# token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: -1
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# token风格
token-style: random-128
# 是否输出操作日志
is-log: false
jwt-secret-key: opsjajisdnnca0sdkksdfaaasdfwwq
# token 前缀
token-prefix:
cookie:
# 配置 Cookie 作用域:根据二级域名实现sso登入如lms.sso.com;acs.sso.com
domain:
#jetcache:
# defaultCacheType: LOCAL
# statIntervalMinutes: 15
# areaInCacheName: false
# hiddenPackages: com.yb
# local:
# default:
# type: caffeine
# limit: 100
# keyConvertor: fastjson
# expireAfterWriteInMillis: 60000
# remote:
# default:
# type: redis.lettuce
# keyConvertor: fastjson
# valueEncoder: kryo
# valueDecoder: kryo
# poolConfig:
# minIdle: 5
# maxIdle: 200
# maxTotal: 1000
# uri:
# - redis://127.0.0.1:6379
es:
index: mes_log

View File

@@ -2,6 +2,22 @@ server:
port: 8099
#配置数据源
spring:
data:
elasticsearch:
repositories:
enabled: true
client:
reactive:
#endpoints: 172.31.185.110:9200,172.31.154.9:9200 #内网
# endpoints: 47.96.133.178:8200 #外网
endpoints: http://47.96.133.178:8200 #外网
elasticsearch:
rest:
#uris: 172.31.185.110:9200,172.31.154.9:9200 #内网
# uris: 47.96.133.178:8200 #外网
uris: http://47.96.133.178:8200 #外网
username: elastic
password: 123456
datasource:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
@@ -43,16 +59,8 @@ spring:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-alagvslow: true
filters:
DruidFilter,stat
redis:
#数据库索引
database: ${REDIS_DB:6}
@@ -62,6 +70,16 @@ spring:
password: ${REDIS_PWD:}
#连接超时时间
timeout: 5000
redisson:
config: |
threads: 4
nettyThreads: 4
singleServerConfig:
connectionMinimumIdleSize: 8
connectionPoolSize: 8
address: redis://127.0.0.1:6379
idleConnectionTimeout: 10000
timeout: 3000
# 登录相关配置
login:
# 登录缓存
@@ -130,7 +148,27 @@ file:
maxSize: 100
avatarMaxSize: 5
sa-token:
# token 名称 (同时也是cookie名称)
token-name: Authorization
# token 有效期单位s 默认30天, -1代表永不过期
timeout: 2592000
# token 临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
activity-timeout: -1
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: true
# 在多人登录同一账号时是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# token风格
token-style: random-128
# 是否输出操作日志
is-log: false
jwt-secret-key: opsjajisdnnca0sdkksdfaaasdfwwq
# token 前缀
token-prefix:
cookie:
# 配置 Cookie 作用域:根据二级域名实现sso登入如lms.sso.com;acs.sso.com
domain:
jetcache:
defaultCacheType: LOCAL
@@ -155,4 +193,5 @@ jetcache:
maxTotal: 1000
uri:
- redis://127.0.0.1:6379
es:
index: mes_log