rev:修改货位分配代码
This commit is contained in:
@@ -1,68 +0,0 @@
|
||||
package org.nl.config;
|
||||
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/*
|
||||
* @author ZZQ
|
||||
* @Date 2022/12/15 4:39 下午
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/lockdemo")
|
||||
public class Democontroller {
|
||||
|
||||
|
||||
@Autowired
|
||||
RedissonClient redisLock;
|
||||
@RequestMapping("/1")
|
||||
public String demo() throws Exception {
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
||||
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||
if (lock.tryLock(1000, TimeUnit.SECONDS)){
|
||||
try {
|
||||
System.out.println(Thread.currentThread().getName()+"获取到锁");
|
||||
Thread.sleep(3000);
|
||||
} finally {
|
||||
System.out.println("释放");
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}).start();
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
||||
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||
if (lock.tryLock(1000, TimeUnit.SECONDS)){
|
||||
try {
|
||||
System.out.println(Thread.currentThread().getName()+"获取到锁");
|
||||
Thread.sleep(3000);
|
||||
} finally {
|
||||
System.out.println("释放");
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}).start();
|
||||
|
||||
|
||||
return "sucess";
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,15 @@
|
||||
package org.nl.pda.st.out.rest;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.annotation.Log;
|
||||
import org.nl.modules.system.util.MapOf;
|
||||
import org.nl.pda.st.out.service.HandPFOutIvtService;
|
||||
import org.nl.wms.common.util.RedissonUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -46,7 +49,10 @@ public class HandPFOutIvtController {
|
||||
@Log("回库")
|
||||
@ApiOperation("回库")
|
||||
public ResponseEntity<Object> backStore(@RequestBody Map<String, String> whereJson) {
|
||||
return new ResponseEntity<>(handPFOutIvtService.backStore(whereJson), HttpStatus.OK);
|
||||
RedissonUtils.lock(a->{
|
||||
handPFOutIvtService.backStore(whereJson);
|
||||
},"QST_IVT_RAWASSISTISTOR02",5);
|
||||
return new ResponseEntity<>(MapOf.of("code", "1","desc", "回库成功!"), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/queryStoragevehicle")
|
||||
|
||||
@@ -836,15 +836,9 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
||||
if (sect_rows.size() > 0) {
|
||||
struct_map.put("sect_flag", "1");
|
||||
}
|
||||
RedissonClient redisLock= SpringContextHolder.getBean(RedissonClient.class);
|
||||
//获取锁
|
||||
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||
try {
|
||||
// 尝试加锁,最多等待1000ms,上锁以后5s自动解锁
|
||||
boolean isLock = lock.tryLock(5, 10, TimeUnit.SECONDS);
|
||||
if (isLock) {
|
||||
//获取锁成功,执行对应的业务逻辑
|
||||
|
||||
//调用分配货位sql
|
||||
JSONObject struct_jo = WQL.getWO("QST_IVT_RAWASSISTISTOR02").addParamMap(struct_map).process().uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(struct_jo)) {
|
||||
@@ -878,9 +872,7 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
||||
map.put("tableData", tableData);
|
||||
//库存冻结、货位锁定、生成任务
|
||||
handMoveStorService.insertDtl(map);
|
||||
}else{
|
||||
throw new PdaRequestException("分配货位并发锁获取失败,请稍后再试!");
|
||||
}
|
||||
|
||||
//调用下发按钮
|
||||
AbstractAcsTask intask = new InTask();
|
||||
//调用ACS接受任务接口
|
||||
@@ -905,8 +897,6 @@ public class HandPFOutIvtServiceImpl implements HandPFOutIvtService {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new PdaRequestException("逻辑分配错误:"+e.getMessage());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
JSONObject returnjo = new JSONObject();
|
||||
|
||||
@@ -417,7 +417,7 @@ public class PerformancemstServiceImpl implements PerformancemstService {
|
||||
JSONObject jsonUser = WQLObject.getWQLObject("sys_user").query("user_id = '" + (String) json.getString("assessor_id") + "'").uniqueResult(0);
|
||||
JSONObject jsonResult2 = new JSONObject();
|
||||
jsonResult2.put("prop", String.valueOf(json.getString("assessor_id"))); // 对应数据中的id 必须一致
|
||||
jsonResult2.put("label", jsonUser.getString("nick_name"));
|
||||
jsonResult2.put("label", jsonUser!=null?jsonUser.getString("nick_name"):String.valueOf(json.getString("assessor_id")));
|
||||
jsonArrResult.add(jsonResult2);
|
||||
}
|
||||
|
||||
|
||||
@@ -718,49 +718,37 @@ public abstract class AbstractInManage {
|
||||
struct_map.put("sect_flag", "1");
|
||||
}
|
||||
|
||||
|
||||
RedissonClient redisLock=SpringContextHolder.getBean(RedissonClient.class);
|
||||
|
||||
//获取锁
|
||||
RLock lock = redisLock.getLock("QST_IVT_RAWASSISTISTOR02");
|
||||
|
||||
try {
|
||||
// 尝试加锁,最多等待1000ms,上锁以后5s自动解锁
|
||||
boolean isLock = lock.tryLock(5, 10, TimeUnit.SECONDS);
|
||||
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 BadRequestException("未查询到适用仓位!");
|
||||
}
|
||||
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 BadRequestException("未查询到适用仓位!");
|
||||
}
|
||||
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{
|
||||
throw new BadRequestException("分配货位并发锁获取失败,请稍后再试!");
|
||||
}
|
||||
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);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new PdaRequestException("逻辑分配错误:"+e.getMessage());
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
} else {
|
||||
//更新入库分配表仓位相关字段
|
||||
|
||||
@@ -64,8 +64,8 @@
|
||||
|
||||
IF 输入.flag = "7"
|
||||
QUERY
|
||||
SELECT DISTINCT
|
||||
sa.*
|
||||
SELECT
|
||||
sa.sect_id,sa.sect_code,sa.sect_name,sa.stor_id,sa.stor_code,sa.stor_name
|
||||
FROM
|
||||
st_ivt_structattr sa
|
||||
LEFT JOIN st_ivt_sectattr se ON se.sect_id = sa.sect_id
|
||||
@@ -86,7 +86,7 @@
|
||||
OPTION 输入.stor_id <> ""
|
||||
sa.stor_id = 输入.stor_id
|
||||
ENDOPTION
|
||||
order by sa.struct_code
|
||||
order by sa.struct_code for update
|
||||
ENDSELECT
|
||||
ENDQUERY
|
||||
ENDIF
|
||||
|
||||
Reference in New Issue
Block a user