代码跟新:
1. 去掉多线程
This commit is contained in:
parent
f968c83ca1
commit
442bd2f9ee
|
|
@ -12,7 +12,6 @@ import java.util.concurrent.ThreadPoolExecutor;
|
|||
* 线程池配置
|
||||
*/
|
||||
@SpringBootConfiguration
|
||||
@EnableAsync
|
||||
public class ThreadPoolConfig {
|
||||
@Bean("myThreadPool")
|
||||
public TaskExecutor taskExecutor() {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ public enum VehicleStatus {
|
|||
IN(1, "入库中"),
|
||||
ON(2, "在库中"),
|
||||
OUT(3, "出库中"),
|
||||
MOVE(4, "移库中");
|
||||
MOVE(4, "移库中"),
|
||||
EXCEPTION(99, "异常");
|
||||
|
||||
private final Integer code;
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ import java.util.*;
|
|||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
|
||||
@EnableAsync
|
||||
public class JobComponent {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
/**
|
||||
|
|
@ -134,7 +133,6 @@ public class JobComponent {
|
|||
* 创建工作
|
||||
*/
|
||||
@Scheduled(fixedDelay = 2000)
|
||||
@Async("myThreadPool")
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public void createWork() {
|
||||
String createWork = configMap.get(ConfigMapKeyEnum.CREATE_WORK.getConfigKey());
|
||||
|
|
@ -161,7 +159,6 @@ public class JobComponent {
|
|||
* 执行工作
|
||||
*/
|
||||
@Scheduled(fixedDelay = 2000)
|
||||
@Async("myThreadPool")
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
public void doWork() {
|
||||
String startWork = configMap.get(ConfigMapKeyEnum.START_WORK.getConfigKey());
|
||||
|
|
|
|||
|
|
@ -1,23 +1,21 @@
|
|||
package com.wms.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.wms.annotation.MyLog;
|
||||
import com.wms.constants.enums.ResponseCode;
|
||||
import com.wms.constants.enums.StockUpdateReasonEnum;
|
||||
import com.wms.constants.enums.VehicleStatus;
|
||||
import com.wms.entity.app.ResponseEntity;
|
||||
import com.wms.entity.app.dto.PageDto;
|
||||
import com.wms.entity.app.dto.StockDto;
|
||||
import com.wms.entity.app.dto.extend.StockDetailInfo;
|
||||
import com.wms.entity.app.request.ExceptionStockHandleRequest;
|
||||
import com.wms.entity.app.request.StockQuery;
|
||||
import com.wms.entity.app.request.StockUpdateRecordQuery;
|
||||
import com.wms.entity.app.request.WorkSummaryQuery;
|
||||
import com.wms.entity.app.vo.StockUpdateRecordVo;
|
||||
import com.wms.entity.app.vo.StockVo;
|
||||
import com.wms.entity.app.vo.WorkSummaryVo;
|
||||
import com.wms.entity.table.*;
|
||||
import com.wms.service.IStockUpdateRecordService;
|
||||
import com.wms.service.LocationService;
|
||||
|
|
@ -40,9 +38,8 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.wms.constants.WmsConstants.MYSQL_JSON_CI;
|
||||
import static com.wms.utils.StringUtils.convertJsonString;
|
||||
|
|
@ -290,7 +287,7 @@ public class StockController {
|
|||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.info("新增库存发生异常:{}", e.getMessage());
|
||||
logger.error("新增库存发生异常:{}", e.getMessage());
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage(e.getMessage());
|
||||
|
|
@ -332,4 +329,72 @@ public class StockController {
|
|||
return convertJsonString(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理异常库存
|
||||
*
|
||||
* @param handleRequest 请求信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/handleExceptionStock")
|
||||
@ResponseBody
|
||||
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED)
|
||||
@MyLog(logTitle = "处理异常库存", logMethod = "handleExceptionStock")
|
||||
public String handleExceptionStock(@RequestBody ExceptionStockHandleRequest handleRequest) {
|
||||
logger.info("接收到处理异常库存请求:{},请求ip:{}", convertJsonString(handleRequest), HttpUtils.getIpAddr(servletRequest));
|
||||
// 创建响应信息
|
||||
ResponseEntity rsp = new ResponseEntity();
|
||||
try {
|
||||
if (handleRequest == null || StringUtils.isEmpty(handleRequest.getVehicleId())
|
||||
|| StringUtils.isEmpty(handleRequest.getGoodsId()) || StringUtils.isEmpty(handleRequest.getStandId())) {
|
||||
logger.error("请求参数必须参数。");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("请求参数必须参数。");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
// 查询到当前处理的料箱
|
||||
Vehicle currentVehicle = vehicleService.getOne(new LambdaQueryWrapper<Vehicle>()
|
||||
.eq(Vehicle::getVehicleId, handleRequest.getVehicleId())
|
||||
.last("limit 1"));
|
||||
if (currentVehicle == null) {
|
||||
logger.error("请求处理的箱子不在立体库记录中。");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("请求处理的箱子不在立体库记录中,请根据需要在入库界面入库。");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
// 查询到当前处理的库存
|
||||
List<Stock> currentStockList = stockService.list(new LambdaQueryWrapper<Stock>()
|
||||
.eq(Stock::getVehicleId, handleRequest.getVehicleId())
|
||||
.apply("goods_related ->> '$.goodsId' = {0}" + MYSQL_JSON_CI, handleRequest.getGoodsId()));
|
||||
if (currentStockList.isEmpty()) {
|
||||
logger.error("当前箱子中没有当前料号的库存。");
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage("当前箱子中没有当前料号的库存。");
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
// 标记料箱
|
||||
|
||||
// 删除库存
|
||||
for (Stock stock : currentStockList) {
|
||||
|
||||
}
|
||||
// 找到当前箱子当前料对应的拣选任务-->取消拣选任务
|
||||
// ----请求wcs接口
|
||||
// 将这个料的实际剩余库存数量减去outsideVehicles的剩余数量,得出这个料的分配数量
|
||||
// 回退goodsToStation
|
||||
// ----在请求回库时,需要增加箱子状态的判断。异常状态---允许回库,但是不生成回库任务
|
||||
// 添加库存更新记录
|
||||
|
||||
|
||||
return convertJsonString(rsp);
|
||||
} catch (Exception e) {
|
||||
// 回滚事务
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
logger.error("处理异常库存发生异常:{}", e.getMessage());
|
||||
// 返回其他异常
|
||||
rsp.setCode(ResponseCode.ERROR.getCode());
|
||||
rsp.setMessage(e.getMessage());
|
||||
return convertJsonString(rsp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.wms.entity.app.request;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class ExceptionStockHandleRequest extends PageQuery {
|
||||
/**
|
||||
* 箱号
|
||||
*/
|
||||
@JsonProperty("vehicleId")
|
||||
private String vehicleId;
|
||||
/**
|
||||
* 料号
|
||||
*/
|
||||
@JsonProperty("goodsId")
|
||||
private String goodsId;
|
||||
/**
|
||||
* 站台号
|
||||
*/
|
||||
@JsonProperty("standId")
|
||||
private String standId;
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
break;
|
||||
}
|
||||
if (runningTaskNumToEquipmentMap.containsKey(key)) {
|
||||
if (runningTaskNumToEquipmentMap.get(key) >= 4) {
|
||||
if (runningTaskNumToEquipmentMap.get(key) >= 3) {
|
||||
runningTaskNumToEquipmentMap.remove(key);
|
||||
} else {
|
||||
runningTaskNumToEquipmentMap.replace(key, runningTaskNumToEquipmentMap.get(key) + 1);
|
||||
|
|
@ -429,7 +429,7 @@ public class WmsJobServiceImplements implements IWmsJobService {
|
|||
// 剩余任务有没有这台堆垛机的
|
||||
List<Task> remainTasks = allTasks.stream().filter(task -> !skipVehicleIds.contains(task.getVehicleId()) && !pickVehicleIds.contains(task.getVehicleId())
|
||||
&& task.getIsPicking() == 1 && StringUtils.isNotEmpty(task.getPickStand())).toList();
|
||||
if (remainTasks.isEmpty() || runningTaskNumToEquipmentMap.get(equipmentId) >= 4) {
|
||||
if (remainTasks.isEmpty() || runningTaskNumToEquipmentMap.get(equipmentId) >= 3) {
|
||||
runningTaskNumToEquipmentMap.remove(equipmentId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user