Browse Source

1.限制重复提交

training
0.0 1 year ago
parent
commit
063d3319e5
  1. 56
      blade-biz-common/src/main/java/org/springblade/common/utils/HttpHelper.java
  2. 1
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionStockupAppController.java
  3. 47
      blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/WarehouseGoodsAllocationController.java

56
blade-biz-common/src/main/java/org/springblade/common/utils/HttpHelper.java

@ -0,0 +1,56 @@
package org.springblade.common.utils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
/**
* 通用http工具封装
*
* @author lmy
*/
public class HttpHelper
{
private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class);
public static String getBodyString(ServletRequest request)
{
StringBuilder sb = new StringBuilder();
BufferedReader reader = null;
try (InputStream inputStream = request.getInputStream())
{
reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8")));
String line = "";
while ((line = reader.readLine()) != null)
{
sb.append(line);
}
}
catch (IOException e)
{
LOGGER.warn("getBodyString出现问题!");
}
finally
{
if (reader != null)
{
try
{
reader.close();
}
catch (IOException e)
{
LOGGER.error(ExceptionUtils.getMessage(e));
}
}
}
return sb.toString();
}
}

1
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/appcontroller/DistributionStockupAppController.java

@ -24,6 +24,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.basicdata.feign.IBasicdataGoodsAreaClient;
import com.logpm.distribution.bean.Resp;
import com.logpm.distribution.config.RedissonConfig;
import com.logpm.distribution.dto.app.StockupDTO;
import com.logpm.distribution.entity.*;

47
blade-service/logpm-warehouse/src/main/java/com/logpm/warehouse/controller/WarehouseGoodsAllocationController.java

@ -21,6 +21,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.logpm.basicdata.entity.BasicdataWarehouseEntity;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.warehouse.config.RedissonConfig;
import com.logpm.warehouse.dto.*;
import com.logpm.warehouse.entity.WarehouseGoodsAllocationEntity;
import com.logpm.warehouse.excel.WarehouseGoodsAllocationExcel;
@ -35,6 +37,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.redisson.api.RLock;
import org.springblade.common.exception.CustomerException;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.excel.util.ExcelUtil;
@ -55,6 +58,7 @@ import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -207,6 +211,13 @@ public class WarehouseGoodsAllocationController extends BladeController {
public R uporder(@RequestBody UpdownTypeDTO updownTypeDTO) {
List<UpShelfOrderDTO> upShelfOrderList = updownTypeDTO.getUpShelfOrderList();
Long allocationId = updownTypeDTO.getAllocationId();
//设置lockey
String lockKey ="lock:upPackage:" + allocationId;
RLock lock = new RedissonConfig().redisson().getLock(lockKey);
if(lock.isLocked()){
return R.fail("该货位还在上架中!!!");
}
lock.lock(5, TimeUnit.SECONDS);
if (upShelfOrderList.size() == 0 || Objects.isNull(allocationId)) {
return R.fail("参数不全");
}
@ -239,6 +250,13 @@ public class WarehouseGoodsAllocationController extends BladeController {
//取出服务号
List<UpShelfOrderDTO> upShelfOrderList = updownTypeDTO.getUpShelfOrderList();
Long allocationId = updownTypeDTO.getAllocationId();
//设置lockey
String lockKey ="lock:upPackage:" + allocationId;
RLock lock = new RedissonConfig().redisson().getLock(lockKey);
if(lock.isLocked()){
return R.fail("该货位还在上架中!!!");
}
lock.lock(5, TimeUnit.SECONDS);
Boolean b = warehouseGoodsAllocationService.selectIsStocking(allocationId);
if (b){
return R.fail("备货区不可上架");
@ -274,6 +292,13 @@ public class WarehouseGoodsAllocationController extends BladeController {
//取出包条Id
List<UpShelfPackageDTO> upShelfPackageList = updownTypeDTO.getUpShelfPackageList();
Long allocationId = updownTypeDTO.getAllocationId();
//设置lockey
String lockKey ="lock:upPackage:" + allocationId;
RLock lock = new RedissonConfig().redisson().getLock(lockKey);
if(lock.isLocked()){
return R.fail("该货位还在上架中!!!");
}
lock.lock(3, TimeUnit.SECONDS);
if (upShelfPackageList.size() == 0 || Objects.isNull(allocationId)) {
return R.fail("参数不全");
}
@ -287,6 +312,7 @@ public class WarehouseGoodsAllocationController extends BladeController {
}
R r = warehouseUpdownTypeService.upShelfPackage(upShelfPackageList, allocationId,myCurrentWarehouse.getId());
// if (r.getCode() == 200) {
// warehouseGoodsAllocationService.updateAllocationCache(allocationId.toString());
// }
@ -302,6 +328,13 @@ public class WarehouseGoodsAllocationController extends BladeController {
public R upTray(@RequestBody UpdownTypeDTO updownTypeDTO) {
String trayCode = updownTypeDTO.getCode();//托盘码
Long allocationId = updownTypeDTO.getAllocationId();
//设置lockey
String lockKey ="lock:upPackage:" + allocationId;
RLock lock = new RedissonConfig().redisson().getLock(lockKey);
if(lock.isLocked()){
return R.fail("该货位还在上架中!!!");
}
lock.lock(5, TimeUnit.SECONDS);
if (null == allocationId || StringUtil.isBlank(trayCode)) {
return R.fail("参数不全");
}
@ -330,6 +363,13 @@ public class WarehouseGoodsAllocationController extends BladeController {
public R upStock(@RequestBody UpdownTypeDTO updownTypeDTO) {
Long allocationId = updownTypeDTO.getAllocationId();//库位Id
List<UpShelfStockDTO> upShelfStockList = updownTypeDTO.getUpShelfStockList();
//设置lockey
String lockKey ="lock:upPackage:" + allocationId;
RLock lock = new RedissonConfig().redisson().getLock(lockKey);
if(lock.isLocked()){
return R.fail("该货位还在上架中!!!");
}
lock.lock(5, TimeUnit.SECONDS);
if (null == allocationId || upShelfStockList.size() == 0) {
return R.fail("参数不全");
}
@ -360,6 +400,13 @@ public class WarehouseGoodsAllocationController extends BladeController {
public R upZeroOrder(@RequestBody UpdownTypeDTO updownTypeDTO) {
Long allocationId = updownTypeDTO.getAllocationId();//库位编码
List<UpShelfZeroOrderDTO> upShelfZeroOrderList = updownTypeDTO.getUpShelfZeroOrderList();
//设置lockey
String lockKey ="lock:upPackage:" + allocationId;
RLock lock = new RedissonConfig().redisson().getLock(lockKey);
if(lock.isLocked()){
return R.fail("该货位还在上架中!!!");
}
lock.lock(5, TimeUnit.SECONDS);
if (null == allocationId || upShelfZeroOrderList.size() == 0) {
return R.fail("参数不全");
}

Loading…
Cancel
Save