启用禁用货位及货位移动

main
judy 1 year ago
parent 86412110dc
commit bbd1a0f560
  1. 2
      shkj-wms/src/main/java/com/shkj/wms/controller/base/BaseLocationController.java
  2. 270
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java
  3. 1
      shkj-wms/src/main/resources/mapper/wms/BaseLocationMapper.xml

@ -89,7 +89,7 @@ public class BaseLocationController extends BaseController {
* 禁用启用货位
*/
@PostMapping("/enableDisableLocation")
public Result<Boolean> enableDisableLocation(@Valid @RequestBody BaseLocationRemoveBo bo) {
public Result<Boolean> enableDisableLocation(@RequestBody BaseLocationRemoveBo bo) {
return iBaseLocationService.deleteWithValidById(bo.getIds(), bo.getStatus());
}

@ -30,13 +30,16 @@ import com.shkj.wms.third.rcs.enums.RCSTaskTypeEnum;
import com.shkj.wms.utils.JsonUtil;
import com.shkj.wms.utils.TunnelTaskUtil;
import com.shkj.wms.vo.*;
import io.lettuce.core.api.async.RedisTransactionalAsyncCommands;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.math3.linear.ConjugateGradient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import javax.validation.Valid;
@ -1919,150 +1922,165 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
* 2.4 堆垛机放货完成时处理库存
*/
// 查询移出货位是否有库存
Long outLocationId = bo.getOutLocationId();
SysStockDetailQueryBo stockDetailQueryBo = new SysStockDetailQueryBo();
stockDetailQueryBo.setLocationId(outLocationId);
List<SysStockDetailVo> sysStockDetailVos = iSysStockDetailService.queryList(stockDetailQueryBo);
if (sysStockDetailVos == null && sysStockDetailVos.size() == 0) {
return Result.err().msg("移出货位无保险杠库存");
}
try {
// 查询移出货位是否有库存
Long outLocationId = bo.getOutLocationId();
SysStockDetailQueryBo stockDetailQueryBo = new SysStockDetailQueryBo();
stockDetailQueryBo.setLocationId(outLocationId);
List<SysStockDetailVo> sysStockDetailVos = iSysStockDetailService.queryList(stockDetailQueryBo);
if (sysStockDetailVos == null && sysStockDetailVos.size() == 0) {
return Result.err().msg("移出货位无保险杠库存");
}
BaseLocation outBaseLocation = iBaseLocationService.getById(outLocationId);
//查看是否时双深位,如果是则判断单深位是否有库存
Result<Boolean> booleanResult = checkIsSleep(outBaseLocation);
if (!Result.isOk(booleanResult)) {
return booleanResult;
}
// 查询移出货位是否有未完成的任务
LambdaQueryWrapper<BusinDataTask> wrapper = new LambdaQueryWrapper<BusinDataTask>()
.notIn(BusinDataTask::getTaskStatus, Arrays.asList("2", "3"))
.in(BusinDataTask::getTaskType, Arrays.asList("9", "16"))
.eq(BusinDataTask::getFromLayer, outBaseLocation.getLayer())
.eq(BusinDataTask::getFromColumn, outBaseLocation.getLocationColumn())
.eq(BusinDataTask::getFromRow, outBaseLocation.getLocationRow()).last("limit 1");
BusinDataTask businDataTask = getOne(wrapper);
if (businDataTask != null) {
return Result.err().msg("移出货位有未完成的货位移动任务,不可重复移动");
}
BaseLocation outBaseLocation = iBaseLocationService.getById(outLocationId);
//查看是否时双深位,如果是则判断单深位是否有库存
Result<Boolean> booleanResult = checkIsSleep(outBaseLocation);
if (!Result.isOk(booleanResult)) {
return booleanResult;
}
// 查询移出货位是否有未完成的任务
LambdaQueryWrapper<BusinDataTask> wrapper = new LambdaQueryWrapper<BusinDataTask>()
.notIn(BusinDataTask::getTaskStatus, Arrays.asList("2", "3"))
.in(BusinDataTask::getTaskType, Arrays.asList("9", "16"))
.eq(BusinDataTask::getFromLayer, outBaseLocation.getLayer())
.eq(BusinDataTask::getFromColumn, outBaseLocation.getLocationColumn())
.eq(BusinDataTask::getFromRow, outBaseLocation.getLocationRow()).last("limit 1");
BusinDataTask businDataTask = getOne(wrapper);
if (businDataTask != null) {
return Result.err().msg("移出货位有未完成的货位移动任务,不可重复移动");
}
//查询目标货位,并预占
Long inLocationId = bo.getInLocationId();
BaseLocation inBaseLocation = iBaseLocationService.getById(inLocationId);
if (inBaseLocation == null) {
return Result.err().msg("未获取到移入货位信息");
}
//查询目标货位,并预占
Long inLocationId = bo.getInLocationId();
BaseLocation inBaseLocation = iBaseLocationService.getById(inLocationId);
if (inBaseLocation == null) {
return Result.err().msg("未获取到移入货位信息");
}
if (!inBaseLocation.getLocationStatus().equals("0")) {
return Result.err().msg("移入货位已被占用:" + inBaseLocation.getLocationCode());
}
if (!inBaseLocation.getLocationStatus().equals("0")) {
return Result.err().msg("移入货位已被占用:" + inBaseLocation.getLocationCode());
}
inBaseLocation.setLocationStatus("4");
iBaseLocationService.updateById(inBaseLocation);
//更改货位状态未移库中,此货位不可在出库
outBaseLocation.setLocationStatus("5");
iBaseLocationService.updateById(outBaseLocation);
inBaseLocation.setLocationStatus("4");
iBaseLocationService.updateById(inBaseLocation);
//更改货位状态未移库中,此货位不可在出库
outBaseLocation.setLocationStatus("5");
iBaseLocationService.updateById(outBaseLocation);
//生成移库出库任务
int index = 0;
List<BusinDataTaskGoods> taskGoodsList = new ArrayList<>();
List<SysStockDetail> sysStockDetails = new ArrayList<>();
String inTunnel = inBaseLocation.getTunnel();
String outTunnel = outBaseLocation.getTunnel();
BusinDataTask dataTaskAdd = new BusinDataTask();
BusinDataTask dataTaskOut = new BusinDataTask();
BusinDataTask dataTaskIn = new BusinDataTask();
if (!inTunnel.equals(outTunnel)) {
dataTaskOut.setTaskStatus("0");
dataTaskOut.setBatch(DateUtils.getDate());
dataTaskOut.setIsUrgent("0");//非紧急任务
dataTaskOut.setIsTop("0");
dataTaskOut.setPriority("0");
dataTaskOut.setFromColumn(outBaseLocation.getLocationColumn());
dataTaskOut.setFromLayer(outBaseLocation.getLayer());
dataTaskOut.setFromRow(outBaseLocation.getLocationRow());
dataTaskOut.setTaskType(TaskTypeEnum.relocation_out.getValue());
dataTaskIn.setTaskStatus("0");
dataTaskIn.setBatch(DateUtils.getDate());
dataTaskIn.setIsUrgent("0");//非紧急任务
dataTaskIn.setIsTop("0");
dataTaskIn.setPriority("0");
dataTaskIn.setToLayer(inBaseLocation.getLayer());
dataTaskIn.setToRow(inBaseLocation.getLocationRow());
dataTaskIn.setToColumn(inBaseLocation.getLocationColumn());
dataTaskIn.setTaskType(TaskTypeEnum.relocation_in.getValue());
//生成移库出库任务
int index = 0;
List<BusinDataTaskGoods> taskGoodsList = new ArrayList<>();
List<SysStockDetail> sysStockDetails = new ArrayList<>();
} else {
dataTaskAdd.setTaskStatus("0");
dataTaskAdd.setBatch(DateUtils.getDate());
dataTaskAdd.setIsUrgent("0");//非紧急任务
dataTaskAdd.setIsTop("0");
dataTaskAdd.setPriority("0");
dataTaskAdd.setToLayer(inBaseLocation.getLayer());
dataTaskAdd.setToRow(inBaseLocation.getLocationRow());
dataTaskAdd.setToColumn(inBaseLocation.getLocationColumn());
dataTaskAdd.setTaskType(TaskTypeEnum.seat_adjustment.getValue());
}
for (SysStockDetailVo sysStockDetailVo : sysStockDetailVos) {
Long taskInId = 0L;
Long taskOutId = 0L;
if (index == 0) {
if (!inTunnel.equals(outTunnel)) {
//根据巷道获取目标货位的输送线的agv接驳点
BasePointQueryBo pointQueryBo = new BasePointQueryBo();
pointQueryBo.setTunnel(inTunnel);
pointQueryBo.setGroupNo("4");
BasePointVo basePointVo = iBasePointService.selectBasePointByQuery(pointQueryBo);
String pointNo = basePointVo.getPointNo();
Long plcId = basePointVo.getPlcId();
String devCode = basePointVo.getDevCode();
dataTaskOut.setIsDown(basePointVo.getIsDown());
dataTaskOut.setTaskPath(pointNo);
dataTaskOut.setPlcId(plcId);
dataTaskOut.setDpsNoOne(Long.valueOf(devCode));
dataTaskOut.setLocationId(inLocationId);
this.save(dataTaskIn);
taskInId = dataTaskIn.getId();
dataTaskOut.setAssociatedTasksId(dataTaskIn.getId().toString());
this.save(dataTaskOut);
taskOutId = dataTaskOut.getId();
} else {
this.save(dataTaskAdd);
}
index++;
}
String inTunnel = inBaseLocation.getTunnel();
String outTunnel = outBaseLocation.getTunnel();
BusinDataTask dataTaskAdd = new BusinDataTask();
BusinDataTask dataTaskOut = new BusinDataTask();
BusinDataTask dataTaskIn = new BusinDataTask();
//保险杠信息
if (!inTunnel.equals(outTunnel)) {
BusinDataTaskGoods taskGoodsIn = new BusinDataTaskGoods();
taskGoodsIn.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoodsIn.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoodsIn.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoodsIn.setTaskCode(taskInId);
taskGoodsList.add(taskGoodsIn);
BusinDataTaskGoods taskGoodsOut = new BusinDataTaskGoods();
taskGoodsOut.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoodsOut.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoodsOut.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoodsOut.setTaskCode(taskOutId);
taskGoodsList.add(taskGoodsOut);
dataTaskOut.setTaskStatus("0");
dataTaskOut.setBatch(DateUtils.getDate());
dataTaskOut.setIsUrgent("0");//非紧急任务
dataTaskOut.setIsTop("0");
dataTaskOut.setPriority("0");
dataTaskOut.setFromColumn(outBaseLocation.getLocationColumn());
dataTaskOut.setFromLayer(outBaseLocation.getLayer());
dataTaskOut.setFromRow(outBaseLocation.getLocationRow());
dataTaskOut.setTaskType(TaskTypeEnum.relocation_out.getValue());
dataTaskIn.setTaskStatus("0");
dataTaskIn.setBatch(DateUtils.getDate());
dataTaskIn.setIsUrgent("0");//非紧急任务
dataTaskIn.setIsTop("0");
dataTaskIn.setPriority("0");
dataTaskIn.setToLayer(inBaseLocation.getLayer());
dataTaskIn.setToRow(inBaseLocation.getLocationRow());
dataTaskIn.setToColumn(inBaseLocation.getLocationColumn());
dataTaskIn.setTaskType(TaskTypeEnum.relocation_in.getValue());
} else {
dataTaskAdd.setTaskStatus("0");
dataTaskAdd.setBatch(DateUtils.getDate());
dataTaskAdd.setIsUrgent("0");//非紧急任务
dataTaskAdd.setIsTop("0");
dataTaskAdd.setPriority("0");
dataTaskAdd.setToLayer(inBaseLocation.getLayer());
dataTaskAdd.setToRow(inBaseLocation.getLocationRow());
dataTaskAdd.setToColumn(inBaseLocation.getLocationColumn());
dataTaskAdd.setTaskType(TaskTypeEnum.seat_adjustment.getValue());
}
for (SysStockDetailVo sysStockDetailVo : sysStockDetailVos) {
Long taskInId = 0L;
Long taskOutId = 0L;
if (index == 0) {
if (!inTunnel.equals(outTunnel)) {
//根据巷道获取目标货位的输送线的agv接驳点
BasePointQueryBo pointQueryBo = new BasePointQueryBo();
pointQueryBo.setTunnel(inTunnel);
pointQueryBo.setGroupNo("4");
BasePointVo basePointVo = iBasePointService.selectBasePointByQuery(pointQueryBo);
String pointNo = basePointVo.getPointNo();
Long plcId = basePointVo.getPlcId();
String devCode = basePointVo.getDevCode();
dataTaskOut.setIsDown(basePointVo.getIsDown());
dataTaskOut.setTaskPath(pointNo);
dataTaskOut.setPlcId(plcId);
dataTaskOut.setDpsNoOne(Long.valueOf(devCode));
dataTaskOut.setLocationId(inLocationId);
this.save(dataTaskIn);
taskInId = dataTaskIn.getId();
dataTaskOut.setAssociatedTasksId(dataTaskIn.getId().toString());
this.save(dataTaskOut);
taskOutId = dataTaskOut.getId();
} else {
this.save(dataTaskAdd);
}
index++;
}
//保险杠信息
if (!inTunnel.equals(outTunnel)) {
BusinDataTaskGoods taskGoodsIn = new BusinDataTaskGoods();
taskGoodsIn.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoodsIn.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoodsIn.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoodsIn.setTaskCode(taskInId);
taskGoodsList.add(taskGoodsIn);
BusinDataTaskGoods taskGoodsOut = new BusinDataTaskGoods();
taskGoodsOut.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoodsOut.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoodsOut.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoodsOut.setTaskCode(taskOutId);
taskGoodsList.add(taskGoodsOut);
}else{
BusinDataTaskGoods taskGoodsAdd = new BusinDataTaskGoods();
taskGoodsAdd.setGoodsNo(sysStockDetailVo.getGoodsNo());
taskGoodsAdd.setIsPunching(sysStockDetailVo.getIsPuch());
taskGoodsAdd.setBranchId(SecurityUtils.getCurrentBranchId());
taskGoodsAdd.setTaskCode(taskOutId);
taskGoodsList.add(taskGoodsAdd);
taskGoodsList.add(taskGoodsAdd);
}
// //出库预占
// sysStockDetailVo.setOutQty(sysStockDetailVo.getQty().intValue());
// SysStockDetail sysStockDetail = BeanUtil.toBean(sysStockDetailVo, SysStockDetail.class);
// sysStockDetail.setOutTime(DateUtils.getNowDate());
// sysStockDetails.add(sysStockDetail);
}
}
// iSysStockDetailService.updateBatchById(sysStockDetails);
return iBusinDataTaskGoodsService.saveBatch(taskGoodsList) ? Result.ok() : Result.err().msg("移库任务失败");
// iSysStockDetailService.updateBatchById(sysStockDetails);
iBusinDataTaskGoodsService.saveBatch(taskGoodsList);
return Result.ok().msg("移库任务成功");
}catch (Exception e){
log.info("移库任务失败:"+e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.err().msg("移库任务失败");
}
}

@ -555,6 +555,7 @@
JOIN base_storage s ON a.storage_id = s.id
WHERE
l.is_del = '0' AND a.is_del = '0'
and l.location_status='0'
and l.id not in (select distinct location_id from sys_stock_detail)
<if test="locationName != null and locationName != ''">
and l.location_name like concat('%', #{locationName},'%')

Loading…
Cancel
Save