优化
This commit is contained in:
@@ -20,13 +20,12 @@ public class Democontroller {
|
|||||||
@Autowired
|
@Autowired
|
||||||
RedissonClient redisLock;
|
RedissonClient redisLock;
|
||||||
@RequestMapping("/1")
|
@RequestMapping("/1")
|
||||||
|
|
||||||
public String demo() throws Exception {
|
public String demo() throws Exception {
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
RLock lock = redisLock.getLock("wqlcode" + "falg1");
|
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||||
if (lock.tryLock(1000, TimeUnit.SECONDS)){
|
if (lock.tryLock(1000, TimeUnit.SECONDS)){
|
||||||
try {
|
try {
|
||||||
System.out.println(Thread.currentThread().getName()+"获取到锁");
|
System.out.println(Thread.currentThread().getName()+"获取到锁");
|
||||||
@@ -46,7 +45,7 @@ public class Democontroller {
|
|||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
RLock lock = redisLock.getLock("wqlcode" + "falg1");
|
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||||
if (lock.tryLock(1000, TimeUnit.SECONDS)){
|
if (lock.tryLock(1000, TimeUnit.SECONDS)){
|
||||||
try {
|
try {
|
||||||
System.out.println(Thread.currentThread().getName()+"获取到锁");
|
System.out.println(Thread.currentThread().getName()+"获取到锁");
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import org.nl.wms.st.core.task.InTask;
|
|||||||
import org.nl.wms.st.instor.service.HandMoveStorService;
|
import org.nl.wms.st.instor.service.HandMoveStorService;
|
||||||
import org.nl.wql.WQL;
|
import org.nl.wql.WQL;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@@ -42,6 +46,9 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
|||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final HandMoveStorService handMoveStorService;
|
private final HandMoveStorService handMoveStorService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RedissonClient redisLock;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> scanPoint(Map<String, String> jsonObject) {
|
public Map<String, Object> scanPoint(Map<String, String> jsonObject) {
|
||||||
JSONObject returnjo = new JSONObject();
|
JSONObject returnjo = new JSONObject();
|
||||||
@@ -821,37 +828,57 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
|||||||
if (sect_rows.size() > 0) {
|
if (sect_rows.size() > 0) {
|
||||||
struct_map.put("sect_flag", "1");
|
struct_map.put("sect_flag", "1");
|
||||||
}
|
}
|
||||||
JSONObject struct_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR02").addParamMap(struct_map).process().uniqueResult(0);
|
//获取锁
|
||||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||||
throw new PdaRequestException("未找到合适的仓位!");
|
try {
|
||||||
}
|
// 尝试加锁,最多等待1000ms,上锁以后5s自动解锁
|
||||||
//总重量
|
boolean isLock = lock.tryLock(1000, 5000, TimeUnit.MILLISECONDS);
|
||||||
BigDecimal sum_qty = new BigDecimal(0);
|
if (isLock) {
|
||||||
HashMap map = new HashMap();
|
//获取锁成功,执行对应的业务逻辑
|
||||||
map.put("bill_type", "29");
|
|
||||||
map.put("biz_date", DateUtil.today());
|
//调用分配货位sql
|
||||||
map.put("stor_id", struct_jo.getString("stor_id"));
|
JSONObject struct_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR02").addParamMap(struct_map).process().uniqueResult(0);
|
||||||
map.put("stor_code", struct_jo.getString("stor_code"));
|
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||||
map.put("stor_name", struct_jo.getString("stor_name"));
|
throw new PdaRequestException("未找到合适的仓位!");
|
||||||
map.put("total_qty", sum_qty);
|
}
|
||||||
map.put("detail_count", seq_no - 1);
|
//总重量
|
||||||
map.put("bill_status", "30");
|
BigDecimal sum_qty = new BigDecimal(0);
|
||||||
map.put("remark", "手持生成");
|
HashMap map = new HashMap();
|
||||||
map.put("create_mode", "02");
|
map.put("bill_type", "29");
|
||||||
map.put("is_delete", "0");
|
map.put("biz_date", DateUtil.today());
|
||||||
|
map.put("stor_id", struct_jo.getString("stor_id"));
|
||||||
|
map.put("stor_code", struct_jo.getString("stor_code"));
|
||||||
|
map.put("stor_name", struct_jo.getString("stor_name"));
|
||||||
|
map.put("total_qty", sum_qty);
|
||||||
|
map.put("detail_count", seq_no - 1);
|
||||||
|
map.put("bill_status", "30");
|
||||||
|
map.put("remark", "手持生成");
|
||||||
|
map.put("create_mode", "02");
|
||||||
|
map.put("is_delete", "0");
|
||||||
|
|
||||||
|
ArrayList<HashMap> tableData = new ArrayList<HashMap>();
|
||||||
|
HashMap<String, String> row = new HashMap<>();
|
||||||
|
row.put("turnin_sect_id", struct_jo.getString("sect_id"));
|
||||||
|
row.put("turnin_sect_code", struct_jo.getString("sect_code"));
|
||||||
|
row.put("turnin_sect_name", struct_jo.getString("sect_name"));
|
||||||
|
row.put("turnin_struct_id", struct_jo.getString("struct_id"));
|
||||||
|
row.put("turnin_struct_code", struct_jo.getString("struct_code"));
|
||||||
|
row.put("turnin_struct_name", struct_jo.getString("struct_name"));
|
||||||
|
row.put("storagevehicle_code", storagevehicle_code);
|
||||||
|
tableData.add(row);
|
||||||
|
map.put("tableData", tableData);
|
||||||
|
//库存冻结、货位锁定、生成任务
|
||||||
|
handMoveStorService.insertDtl(map);
|
||||||
|
}else{
|
||||||
|
throw new PdaRequestException("分配货位并发锁获取失败,请稍后再试!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new PdaRequestException("分配货位并发锁获取失败,请稍后再试!");
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
ArrayList<HashMap> tableData = new ArrayList<HashMap>();
|
|
||||||
HashMap<String, String> row = new HashMap<>();
|
|
||||||
row.put("turnin_sect_id", struct_jo.getString("sect_id"));
|
|
||||||
row.put("turnin_sect_code", struct_jo.getString("sect_code"));
|
|
||||||
row.put("turnin_sect_name", struct_jo.getString("sect_name"));
|
|
||||||
row.put("turnin_struct_id", struct_jo.getString("struct_id"));
|
|
||||||
row.put("turnin_struct_code", struct_jo.getString("struct_code"));
|
|
||||||
row.put("turnin_struct_name", struct_jo.getString("struct_name"));
|
|
||||||
row.put("storagevehicle_code", storagevehicle_code);
|
|
||||||
tableData.add(row);
|
|
||||||
map.put("tableData", tableData);
|
|
||||||
handMoveStorService.insertDtl(map);
|
|
||||||
//调用下发按钮
|
//调用下发按钮
|
||||||
AbstractAcsTask intask = new InTask();
|
AbstractAcsTask intask = new InTask();
|
||||||
//调用ACS接受任务接口
|
//调用ACS接受任务接口
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ import org.nl.wms.st.vehicle.task.ReplenishVehicleTask;
|
|||||||
import org.nl.wql.WQL;
|
import org.nl.wql.WQL;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
import org.nl.wql.util.WqlUtil;
|
import org.nl.wql.util.WqlUtil;
|
||||||
|
import org.redisson.api.RLock;
|
||||||
|
import org.redisson.api.RedissonClient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -47,6 +49,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ZZ on 2021/12/27.
|
* Created by ZZ on 2021/12/27.
|
||||||
@@ -73,7 +76,8 @@ public abstract class AbstractInManage {
|
|||||||
private PointService pointService = SpringContextHolder.getBean(PointService.class);
|
private PointService pointService = SpringContextHolder.getBean(PointService.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
private MaterialbaseService materialbaseService = SpringContextHolder.getBean(MaterialbaseService.class);
|
private MaterialbaseService materialbaseService = SpringContextHolder.getBean(MaterialbaseService.class);
|
||||||
|
@Autowired
|
||||||
|
RedissonClient redisLock;
|
||||||
|
|
||||||
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
|
public Map<String, Object> pageQuery(Map whereJson, Pageable page) {
|
||||||
HashMap<String, String> map = new HashMap<>();
|
HashMap<String, String> map = new HashMap<>();
|
||||||
@@ -705,27 +709,52 @@ public abstract class AbstractInManage {
|
|||||||
if (StrUtil.isNotEmpty((String) whereJson.get("stor_id"))) {
|
if (StrUtil.isNotEmpty((String) whereJson.get("stor_id"))) {
|
||||||
struct_map.put("stor_id", (String) whereJson.get("stor_id"));
|
struct_map.put("stor_id", (String) whereJson.get("stor_id"));
|
||||||
}
|
}
|
||||||
//struct_map.put("height", height + "");
|
|
||||||
struct_map.put("material_type_id", material_type_id + "");
|
struct_map.put("material_type_id", material_type_id + "");
|
||||||
struct_map.put("flag", "7");
|
struct_map.put("flag", "7");
|
||||||
JSONArray sect_rows = WQLObject.getWQLObject("st_ivt_structrelamaterial").query("material_type_id = '" + material_type_id + "'").getResultJSONArray(0);
|
JSONArray sect_rows = WQLObject.getWQLObject("st_ivt_structrelamaterial").query("material_type_id = '" + material_type_id + "'").getResultJSONArray(0);
|
||||||
if (sect_rows.size() > 0) {
|
if (sect_rows.size() > 0) {
|
||||||
struct_map.put("sect_flag", "1");
|
struct_map.put("sect_flag", "1");
|
||||||
}
|
}
|
||||||
JSONObject struct_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR02").addParamMap(struct_map).process().uniqueResult(0);
|
//获取锁
|
||||||
if (ObjectUtil.isEmpty(struct_jo)){
|
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||||
if (ObjectUtil.isNotEmpty(whereJson.get("is_pc"))){
|
try {
|
||||||
throw new BadRequestException("未查询到适用仓位!");
|
// 尝试加锁,最多等待1000ms,上锁以后5s自动解锁
|
||||||
|
boolean isLock = lock.tryLock(1000, 5000, TimeUnit.MILLISECONDS);
|
||||||
|
if (isLock) {//获取锁成功,执行对应的业务逻辑
|
||||||
|
//调用分配货位sql
|
||||||
|
JSONObject struct_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR02").addParamMap(struct_map).process().uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(struct_jo)){
|
||||||
|
if (ObjectUtil.isNotEmpty(whereJson.get("is_pc"))){
|
||||||
|
throw new BadRequestException("未查询到适用仓位!");
|
||||||
|
}else{
|
||||||
|
throw new PdaRequestException("未查询到适用仓位!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sect_id = struct_jo.getString("sect_id");
|
||||||
|
sect_code = struct_jo.getString("sect_code");
|
||||||
|
sect_name = struct_jo.getString("sect_name");
|
||||||
|
struct_id = struct_jo.getString("struct_id");
|
||||||
|
struct_code = struct_jo.getString("struct_code");
|
||||||
|
struct_name = struct_jo.getString("struct_name");
|
||||||
|
|
||||||
|
//锁定货位
|
||||||
|
JSONObject lock_map = new JSONObject();
|
||||||
|
lock_map.put("end_point", struct_code);
|
||||||
|
//查询主表信息
|
||||||
|
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
||||||
|
lock_map.put("inv_type", mst.get("bill_type"));
|
||||||
|
lock_map.put("inv_id", mst.get("iostorinv_id"));
|
||||||
|
lock_map.put("inv_code", mst.get("bill_code"));
|
||||||
|
inbillService.operatePoint("0", lock_map);
|
||||||
}else{
|
}else{
|
||||||
throw new PdaRequestException("未查询到适用仓位!");
|
throw new PdaRequestException("分配货位并发锁获取失败,请稍后再试!");
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new PdaRequestException("分配货位并发锁获取失败,请稍后再试!");
|
||||||
|
} finally {
|
||||||
|
lock.unlock();
|
||||||
}
|
}
|
||||||
sect_id = struct_jo.getString("sect_id");
|
|
||||||
sect_code = struct_jo.getString("sect_code");
|
|
||||||
sect_name = struct_jo.getString("sect_name");
|
|
||||||
struct_id = struct_jo.getString("struct_id");
|
|
||||||
struct_code = struct_jo.getString("struct_code");
|
|
||||||
struct_name = struct_jo.getString("struct_name");
|
|
||||||
} else {
|
} else {
|
||||||
//更新入库分配表仓位相关字段
|
//更新入库分配表仓位相关字段
|
||||||
sect_id = map.get("sect_id");
|
sect_id = map.get("sect_id");
|
||||||
@@ -734,6 +763,16 @@ public abstract class AbstractInManage {
|
|||||||
struct_id = map.get("struct_id");
|
struct_id = map.get("struct_id");
|
||||||
struct_code = map.get("struct_code");
|
struct_code = map.get("struct_code");
|
||||||
struct_name = map.get("struct_name");
|
struct_name = map.get("struct_name");
|
||||||
|
|
||||||
|
//锁定货位
|
||||||
|
JSONObject lock_map = new JSONObject();
|
||||||
|
lock_map.put("end_point", struct_code);
|
||||||
|
//查询主表信息
|
||||||
|
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
||||||
|
lock_map.put("inv_type", mst.get("bill_type"));
|
||||||
|
lock_map.put("inv_id", mst.get("iostorinv_id"));
|
||||||
|
lock_map.put("inv_code", mst.get("bill_code"));
|
||||||
|
inbillService.operatePoint("0", lock_map);
|
||||||
}
|
}
|
||||||
HashMap<String, String> dis_map = new HashMap();
|
HashMap<String, String> dis_map = new HashMap();
|
||||||
dis_map.put("sect_id", sect_id);
|
dis_map.put("sect_id", sect_id);
|
||||||
@@ -743,16 +782,6 @@ public abstract class AbstractInManage {
|
|||||||
dis_map.put("struct_code", struct_code);
|
dis_map.put("struct_code", struct_code);
|
||||||
dis_map.put("struct_name", struct_name);
|
dis_map.put("struct_name", struct_name);
|
||||||
|
|
||||||
//锁定货位
|
|
||||||
JSONObject lock_map = new JSONObject();
|
|
||||||
lock_map.put("end_point", struct_code);
|
|
||||||
//查询主表信息
|
|
||||||
JSONObject mst = WQLObject.getWQLObject("st_ivt_iostorinv").query("iostorinv_id = '" + map.get("iostorinv_id") + "'").uniqueResult(0);
|
|
||||||
lock_map.put("inv_type", mst.get("bill_type"));
|
|
||||||
lock_map.put("inv_id", mst.get("iostorinv_id"));
|
|
||||||
lock_map.put("inv_code", mst.get("bill_code"));
|
|
||||||
inbillService.operatePoint("0", lock_map);
|
|
||||||
|
|
||||||
//判断起点是否不为空
|
//判断起点是否不为空
|
||||||
JSONObject ios_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + map.get("iostorinv_id") + "' AND storagevehicle_code = '" + map.get("storagevehicle_code") + "'").uniqueResult(0);
|
JSONObject ios_dis = WQLObject.getWQLObject("ST_IVT_IOStorInvDis").query("iostorinv_id = '" + map.get("iostorinv_id") + "' AND storagevehicle_code = '" + map.get("storagevehicle_code") + "'").uniqueResult(0);
|
||||||
if (StrUtil.isNotEmpty(ios_dis.getString("point_code"))) {
|
if (StrUtil.isNotEmpty(ios_dis.getString("point_code"))) {
|
||||||
|
|||||||
@@ -71,6 +71,23 @@ spring:
|
|||||||
password: ${REDIS_PWD:}
|
password: ${REDIS_PWD:}
|
||||||
#连接超时时间
|
#连接超时时间
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
|
redisson:
|
||||||
|
# redis key前缀
|
||||||
|
keyPrefix:
|
||||||
|
# 线程池数量
|
||||||
|
threads: 4
|
||||||
|
# Netty线程池数量
|
||||||
|
nettyThreads: 8
|
||||||
|
# 单节点配置
|
||||||
|
singleServerConfig:
|
||||||
|
# 最小空闲连接数
|
||||||
|
connectionMinimumIdleSize: 8
|
||||||
|
# 连接池大小
|
||||||
|
connectionPoolSize: 32
|
||||||
|
# 连接空闲超时,单位:毫秒
|
||||||
|
idleConnectionTimeout: 10000
|
||||||
|
# 命令等待超时,单位:毫秒
|
||||||
|
timeout: 3000
|
||||||
# 登录相关配置
|
# 登录相关配置
|
||||||
login:
|
login:
|
||||||
# 登录缓存
|
# 登录缓存
|
||||||
|
|||||||
Reference in New Issue
Block a user