fix:新增装箱桁架

This commit is contained in:
zhouz
2026-01-12 19:26:26 +08:00
parent d260cdbf73
commit b43002396b

View File

@@ -0,0 +1,97 @@
package org.nl.b_lms.sch.tasks.first_floor_area.auto;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.sch.point.dao.BstIvtPackageinfoivt;
import org.nl.b_lms.sch.point.dao.mapper.BstIvtPackageinfoivtMapper;
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
import org.nl.common.enums.PackageInfoIvtEnum;
import org.nl.modules.common.utils.RedisUtils;
import org.redisson.api.RList;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
@Slf4j
@Component
@RequiredArgsConstructor
public class AutobindZxqBox extends Prun {
private final String THIS_CLASS = AutobindZxqBox.class.getName();
@Resource
private RedissonClient redissonClient;
@Autowired
private RedisUtils redisUtils;
@Resource
private BstIvtPackageinfoivtMapper bstIvtPackageinfoivtMapper;
//待检区->装箱区agv自动搬运任务
@Autowired
public void run() {
try {
this.bindZxqBox();
} catch (Exception ex) {
log.error(ex.getMessage());
}
}
/**
* 二次分配任务
*/
@SneakyThrows
public void bindZxqBox() {
log.info(THIS_CLASS + "-装箱对接位绑定木箱开始扫描。");
RLock lock = redissonClient.getLock(THIS_CLASS);
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
try {
if (tryLock) {
//获取当前启用的装箱对接位
//装箱区对接位
List<BstIvtPackageinfoivt> bstIvtPackageinfoivtList = bstIvtPackageinfoivtMapper.selectList(new LambdaQueryWrapper<BstIvtPackageinfoivt>()
.eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("装箱位"))
.eq(BstIvtPackageinfoivt::getIs_used, IOSEnum.IS_NOTANDYES.code(""))
.eq(BstIvtPackageinfoivt::getPlan, IOSEnum.IS_NOTANDYES.code(""))
.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code(""))
.orderByAsc(BstIvtPackageinfoivt::getPoint_code));
bstIvtPackageinfoivtList.forEach(bstIvtPackage -> {
//判断当前装箱对接位的木箱队列是否有值,有值则取第一个进行赋值
Object o = redisUtils.lGetIndex(bstIvtPackage.getPoint_code(), 0);
if (ObjectUtil.isNotEmpty(o)) {
String firstElement = o.toString();
bstIvtPackage.setIvt_status(PackageInfoIvtEnum.IVT_STATUS.code("空载具"));
bstIvtPackage.setContainer_name(firstElement);
bstIvtPackage.setUpdate_time(DateUtil.now());
bstIvtPackageinfoivtMapper.updateById(bstIvtPackage);
log.info(bstIvtPackage.getPoint_code() + "绑定了木箱" + firstElement);
redisUtils.lRemove(bstIvtPackage.getPoint_code(), 1, firstElement);
} else {
log.info("列表为空,无木箱可绑定。");
}
});
} else {
log.info("满轴->待检区agv自动搬运任务正在创建被锁住。");
}
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {
lock.unlock();
}
}
}
}