opt:优化现场联调产生的一些问题

This commit is contained in:
2024-06-12 18:49:27 +08:00
parent 1aa9a90372
commit 5ed5153bb4
46 changed files with 1033 additions and 402 deletions

View File

@@ -0,0 +1,264 @@
package org.nl.init;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.nl.b_lms.pdm.bi.slittingproductionplan.service.dao.mapper.PdmBiSlittingproductionplanMapper;
import org.nl.b_lms.pdm.subpackagerelation.dao.PdmBiSubpackagerelation;
import org.nl.b_lms.pdm.subpackagerelation.dao.mapper.PdmBiSubpackagerelationMapper;
import org.nl.b_lms.sch.point.dao.BstIvtPackageinfoivt;
import org.nl.b_lms.sch.point.dao.mapper.BstIvtPackageinfoivtMapper;
import org.nl.b_lms.sch.point.service.IbstIvtPackageinfoivtService;
import org.nl.b_lms.sch.tasks.first_floor_area.*;
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.OutBoxManageService;
import org.nl.common.enums.ContainerLevelEnum;
import org.nl.common.enums.PackageInfoIvtEnum;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
@ExtendWith(SpringExtension.class)
@SpringBootTest
@DisplayName("event test")
public class EventTest {
@Resource
private ZxqTask zxqTask;
@Resource
private ZxDjwTask zxDjwTask;
@Resource
private ISysParamService iSysParamService;
@Resource
private DjqTask djqTask;
@Resource
private GzqTask gzqTask;
@Resource
private KzjhcwTask kzjhcwTask;
@Resource
private OutBoxManageService outBoxManageService;
@Resource
private IbstIvtPackageinfoivtService packageinfoivtService;
@Resource
private PdmBiSubpackagerelationMapper pdmBiSubpackagerelationMapper;
/**
* 装箱区->空载具缓存位补空
*/
@Test
public void zxToKzjHcw() {
kzjhcwTask.toKzjHcw("");
}
/**
* 满轴->待检
*/
@Test
public void mzToDj() {
//子卷成色等级
String level = "1";
//子卷号
String containerName = "1";
//起点
String pointCode1 = "2";
//查询库位信息
List<BstIvtPackageinfoivt> bstIvtPackageinfoivtList = packageinfoivtService
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
.eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
JSONObject toDjqTask = new JSONObject();
//获取子卷号
toDjqTask.put("vehicle_code", containerName);
// 判断子卷等级属于待检区还是管制区,创建满轴缓存位到待检区或管制区的agv任务
if (Stream.of(ContainerLevelEnum.BEST, ContainerLevelEnum.WELL, ContainerLevelEnum.COMMON).anyMatch(enumItem -> enumItem.getCode().equals(level))) {
List<BstIvtPackageinfoivt> djqPointList = bstIvtPackageinfoivtList.stream()
.filter(r -> PackageInfoIvtEnum.POINT_STATUS.code("待检区").equals(r.getPoint_status())
&& PackageInfoIvtEnum.IVT_STATUS.code("").equals(r.getIvt_status())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(djqPointList)) {
throw new BadRequestException("待检区暂无空余库位!");
}
toDjqTask.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("满轴缓存位->待检区"));
toDjqTask.put("point_code1", pointCode1);
toDjqTask.put("point_code2", djqPointList.get(0).getPoint_code());
djqTask.createTask(toDjqTask);
} else if (Stream.of(ContainerLevelEnum.REWORK, ContainerLevelEnum.CONTROL).anyMatch(enumItem -> enumItem.getCode().equals(level))) {
List<BstIvtPackageinfoivt> gkqPointList = bstIvtPackageinfoivtList.stream()
.filter(r -> PackageInfoIvtEnum.POINT_STATUS.code("管制区").equals(r.getPoint_status())
&& PackageInfoIvtEnum.IVT_STATUS.code("").equals(r.getIvt_status())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(gkqPointList)) {
throw new BadRequestException("管控区暂无空余库位!");
}
toDjqTask.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("满轴缓存位->管制区"));
toDjqTask.put("point_code1", pointCode1);
toDjqTask.put("point_code2", gkqPointList.get(0).getPoint_code());
gzqTask.createTask(toDjqTask);
}
}
/**
* 待检->装箱
*/
@Test
public void djToZx() {
//子卷号
String containerName = "";
//起点
String pointCode1 = "";
//木箱
String boxSn = "";
//装箱区点位
List<BstIvtPackageinfoivt> zxqPointList = packageinfoivtService
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
.eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("装箱区"))
.eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code(""))
//装箱区1
.eq(BstIvtPackageinfoivt::getBlock, "1")
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
JSONObject jo = new JSONObject();
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"));
jo.put("vehicle_code", containerName);
jo.put("point_code1", pointCode1);
//木箱号
jo.put("vehicle_code2", boxSn);
//装箱区没满,则确定起点与终点,如果满了则只确定起点
if (CollectionUtils.isNotEmpty(zxqPointList)) {
jo.put("point_code2", zxqPointList.get(0).getPoint_code());
}
zxqTask.createTask(jo);
}
/**
* 空木箱出库
*/
@Test
public void outBox() {
JSONObject boxInfo = new JSONObject();
boxInfo.put("device_code", "ZXQ_1_1");
boxInfo.put("material_code", "MX61102");
String workorderId = "1597797877554483218";
//子卷个数
boxInfo.put("num", "1");
String boxSn = outBoxManageService.outBox(boxInfo);
if (StringUtils.isBlank(boxSn)) {
throw new BadRequestException("库位 -> 装箱对接位,木箱码不能为空!");
}
//更新子卷包装关系更新木箱号
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper1 = new UpdateWrapper<>();
updateWrapper1.set("package_box_sn", boxSn);
updateWrapper1.eq("workorder_id", workorderId);
pdmBiSubpackagerelationMapper.update(null, updateWrapper1);
}
/**
* 装箱区->装箱对接位桁架任务
*/
@Test
public void transferToPacking() {
JSONObject jo = new JSONObject();
//子卷号
String containerName = "A1642211060505E2";
//获取纸管长度
String frpDescription = "1300";
//获取木箱高度等级
String height = "730";
//起点
String point_code1 = "ZXQ_1_9";
//终点
String point_code2 = "ZXQ_1_1";
//托盘类型 1小托盘 2大托盘
String containerType = "2";
//木箱高度等级
String heightLevel = "";
String heightLevel1 = iSysParamService.findByCode("height_level_1").getValue();
String heightLevel2 = iSysParamService.findByCode("height_level_2").getValue();
if (Integer.parseInt(height) <= Integer.parseInt(heightLevel1)) {
heightLevel = "1";
} else if (Integer.parseInt(height) > Integer.parseInt(heightLevel1) && Integer.parseInt(height) <= Integer.parseInt(heightLevel2)) {
heightLevel = "2";
} else {
heightLevel = "3";
}
jo.put("point_code1", point_code1);
jo.put("point_code2", point_code2);
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位"));
jo.put("vehicle_code", containerName);
jo.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
jo.put("is_send", "1");
JSONObject param = new JSONObject();
//木箱最大数量
param.put("maxNo", "1");
//木箱放入子卷数量
param.put("boxNo", "1");
//是否最后子卷
param.put("lastOne", "1");
//子卷号
param.put("barcode", containerName);
//子卷长度
param.put("len", frpDescription);
//木箱高度等级
param.put("heightLevel", heightLevel);
//托盘类型 1小托盘 2大托盘
param.put("containerType", containerType);
jo.put("request_param", param.toString());
zxDjwTask.createTask(jo);
}
/**
* 装箱区->装箱对接位桁架任务2
*/
@Test
public void transferToPacking1() {
//下发装箱区->装箱对接位桁架任务
JSONObject jo = new JSONObject();
//子卷号
String containerName = "";
//获取纸管长度
String frpDescription = "";
//起点
String point_code1 = "ZXQ_1_8";
//终点
String point_code2 = "ZXQ_1_1";
jo.put("point_code1", point_code1);
jo.put("point_code2", point_code2);
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位"));
jo.put("vehicle_code", containerName);
jo.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
jo.put("is_send", "1");
JSONObject param = new JSONObject();
//木箱最大数量
param.put("maxNo", "1");
//木箱放入子卷数量
param.put("boxNo", "1");
//是否最后子卷
param.put("lastOne", "1");
//子卷号
param.put("barcode", containerName);
//子卷长度
param.put("len", frpDescription);
//托盘类型 1小托盘 2大托盘
param.put("containerType", "1");
jo.put("request_param", param.toString());
zxDjwTask.createTask(jo);
}
}