add:增加不对接MES包装关系逻辑

This commit is contained in:
2024-07-02 23:41:09 +08:00
parent 71f320e158
commit c1b47da9f0
4 changed files with 380 additions and 16 deletions

View File

@@ -23,12 +23,14 @@ 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.task.dao.SchBaseTask;
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
import org.nl.b_lms.sch.tasks.first_floor_area.DjqTask;
import org.nl.b_lms.sch.tasks.first_floor_area.ZxDjwTask;
import org.nl.b_lms.sch.tasks.first_floor_area.ZxqTask;
import org.nl.b_lms.sch.tasks.first_floor_area.auto.TaskQueue;
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo;
import org.nl.b_lms.storage_manage.database.service.dao.mapper.BstIvtBoxinfoMapper;
import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
import org.nl.b_lms.storage_manage.ios.service.iostorInv.util.service.OutBoxManageService;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.enums.PackageInfoIvtEnum;
@@ -64,7 +66,8 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
private ZxqTask zxqTask;
@Resource
private ZxDjwTask zxDjwTask;
@Resource
private IschBaseTaskService taskService;
@Resource
private ISysParamService iSysParamService;
@@ -251,15 +254,19 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
*
* @param whereJson 分配信息
*/
@Override
//@Override
@Transactional(rollbackFor = Exception.class)
public void updateEntityList(JSONObject whereJson) {
public void updateEntityList8(JSONObject whereJson) {
//todo 正式环境代码,需恢复
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<PdmBiSubpackagerelation> packagerelationList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class);
if (CollectionUtils.isEmpty(packagerelationList)) {
throw new BadRequestException("无选中子卷信息");
}
if (packagerelationList.size() > 1) {
throw new BadRequestException("暂时只能选择一个子卷");
}
//检查是否存在已分配规格的子卷号
List<PdmBiSubpackagerelation> isOutBox = packagerelationList.stream().filter(r -> r.getStatus().equals("0")).collect(Collectors.toList());
if (isOutBox.size() > 0) {
@@ -306,12 +313,21 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
.filter(r -> !r.isEmpty())
.map(BigDecimal::new)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (totalWeight.compareTo(new BigDecimal(0)) == 0) {
throw new BadRequestException("分切计划的子卷重量不能为0");
}
BigDecimal boxWeight = new BigDecimal(whereJson.getString("box_weight"));
if (boxWeight.compareTo(new BigDecimal(0)) == 0) {
throw new BadRequestException("木箱的重量不能0");
}
totalWeight = totalWeight.add(boxWeight);
if (totalWeight.compareTo(new BigDecimal(0)) == 0) {
throw new BadRequestException("理论毛重不能为0");
}
stopWatch.stop();
System.out.println("子卷装箱代码1装箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("子卷装箱代码1箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson.getString("checked"), totalWeight.toString());
outBox8(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson.getString("checked"), totalWeight.toString());
} catch (Exception e) {
throw new BadRequestException(e.getMessage());
}
@@ -321,7 +337,8 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
/**
* 空木箱出库
*/
private void outBox(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer maxBoxGroup, String boxType, String totalWeight) {
private void outBox8(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer maxBoxGroup, String boxType, String totalWeight) {
//todo 正式环境代码,需恢复
//均衡获取装箱对接位
//String deviceCode = "ZXQ_1_1";
StopWatch stopWatch = new StopWatch();
@@ -341,7 +358,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
//更新及子卷包装状态已分配规格及木箱规格组
CompletableFuture.runAsync(() -> {
try {
updateBoxGroup(maxBoxGroup, workIdList, boxSn, boxType, totalWeight);
//updateBoxGroup(maxBoxGroup, workIdList, boxSn, boxType, totalWeight);
} catch (Exception e) {
log.error("异常信息:" + e);
}
@@ -367,13 +384,12 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
log.info("子卷装箱代码2装箱信息更新执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch1.getTotalTimeMillis());
}
private void updateBoxGroup(Integer maxBoxGroup, List<String> entityList, String boxSn, String boxType, String totalWeight) {
private void updateBoxGroup(Integer maxBoxGroup, List<String> entityList, String boxSn, String boxType) {
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("package_box_sn", boxSn);
updateWrapper.set("quanlity_in_box", entityList.size());
updateWrapper.set("box_type", boxType);
updateWrapper.set("box_group", maxBoxGroup);
updateWrapper.set("box_weight", totalWeight);
updateWrapper.set("status", "0");
updateWrapper.in("workorder_id", entityList);
pdmBiSubpackagerelationMapper.update(null, updateWrapper);
@@ -410,7 +426,8 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
}
protected void agvTransfer(Set<String> containerNameList, String deviceCode, String boxSn) {
protected void agvTransfer8(Set<String> containerNameList, String deviceCode, String boxSn) {
//todo 正式环境代码,需恢复
//待检区点位
List<BstIvtPackageinfoivt> djqPointList = packageinfoivtService
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
@@ -719,5 +736,146 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
}
/**
* 子卷装箱
*
* @param whereJson 分配信息
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateEntityList(JSONObject whereJson) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
List<PdmBiSubpackagerelation> packagerelationList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class);
if (CollectionUtils.isEmpty(packagerelationList)) {
throw new BadRequestException("无选中子卷信息");
}
if (packagerelationList.size() > 1) {
throw new BadRequestException("暂时只能选择一个子卷");
}
//检查是否存在已分配规格的子卷号
List<PdmBiSubpackagerelation> isOutBox = packagerelationList.stream().filter(r -> r.getStatus().equals("0")).collect(Collectors.toList());
if (isOutBox.size() > 0) {
throw new BadRequestException("标记为黄色的子卷号已分配且对应的木箱已出库,请重新选择未分配木箱规格的子卷");
}
//均衡获取木箱出库装箱区对接位
String deviceCode = getPointCode();
Integer taskCount = bstIvtPackageinfoivtMapper.getZxqTaskCount(deviceCode.substring(deviceCode.lastIndexOf("_") + 1));
if (taskCount + packagerelationList.size() > 10) {
throw new BadRequestException("子卷搬运任务数已达上限!");
}
List<PdmBiSubpackagerelation> pdmBiSubpackagerelationList = pdmBiSubpackagerelationMapper
.selectList(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getSale_order_name, packagerelationList.get(0).getSale_order_name()));
Integer maxBoxGroup = pdmBiSubpackagerelationList.stream()
.map(PdmBiSubpackagerelation::getBox_group)
.filter(Objects::nonNull)
.map(Integer::parseInt)
.max(Integer::compareTo)
.orElse(0) + 1;
try {
List<String> workIdList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
.map(PdmBiSubpackagerelation::getWorkorder_id)
.map(String::valueOf)
.collect(Collectors.toList());
if (workIdList.isEmpty()) {
return;
}
//根据分切计划获取子卷重量计算理论毛重
Set<String> containerNameList = packagerelationList.stream()
.map(PdmBiSubpackagerelation::getContainer_name)
.collect(Collectors.toSet());
stopWatch.stop();
System.out.println("子卷装箱代码1装箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("子卷装箱代码1箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson.getString("checked"));
} catch (Exception e) {
log.error("子卷装箱updateEntityList接口捕获异常信息" + e);
}
}
/**
* 空木箱出库
*/
private void outBox(List<String> workIdList, Set<String> containerNameList, String deviceCode, Integer maxBoxGroup, String boxType) {
//均衡获取装箱对接位
//String deviceCode = "ZXQ_1_1";
StopWatch stopWatch = new StopWatch();
stopWatch.start();
JSONObject boxInfo = new JSONObject();
//确定装箱区终点
boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", boxType);
boxInfo.put("num", workIdList.size());
//String boxSn = outBoxManageService.outBox(boxInfo);
stopWatch.stop();
System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
String boxSn = "MX230118000013";
StopWatch stopWatch1 = new StopWatch();
stopWatch1.start();
//更新及子卷包装状态已分配规格及木箱规格组
CompletableFuture.runAsync(() -> {
try {
updateBoxGroup(maxBoxGroup, workIdList, boxSn, boxType);
} catch (Exception e) {
log.error("异常信息:" + e);
}
}, pool);
//待检区->装箱区agv任务
CompletableFuture.runAsync(() -> {
try {
agvTransfer(containerNameList, deviceCode, boxSn);
} catch (Exception e) {
log.error("异常信息:" + e);
}
}, pool);
stopWatch1.stop();
System.out.println("子卷装箱代码2装箱信息更新执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch1.getTotalTimeMillis());
log.info("子卷装箱代码2装箱信息更新执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch1.getTotalTimeMillis());
}
protected void agvTransfer(Set<String> containerNameList, String deviceCode, String boxSn) {
//待检区点位
List<BstIvtPackageinfoivt> djqPointList = 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("合格品"))
//.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("有子卷"))
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
List<BstIvtPackageinfoivt> djqPoints = djqPointList.stream()
.filter(r -> containerNameList.contains(r.getContainer_name()))
.collect(Collectors.toList());
//任务组id
String groupId = deviceCode.substring(deviceCode.lastIndexOf("_") + 1);
List<SchBaseTask> schBaseTaskList = new ArrayList<>();
//确定起点,安装装箱组标识加入任务队列
djqPoints.forEach(r -> {
//校验重复任务
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, r.getContainer_name()).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))
.eq(SchBaseTask::getIs_delete, IOSEnum.IS_NOTANDYES.code("")));
if (CollectionUtils.isEmpty(taskList)) {
JSONObject jo = new JSONObject();
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"));
jo.put("vehicle_code", r.getContainer_name());
jo.put("point_code1", r.getPoint_code());
jo.put("task_status", TaskStatusEnum.SURE_START.getCode());
//木箱号
jo.put("vehicle_code2", groupId);
//任务组id
SchBaseTask task = new SchBaseTask();
SchBaseTask taskDto = zxqTask.createTaskReturnTask(jo);
task.setTask_id(taskDto.getTask_id());
task.setVehicle_code(taskDto.getVehicle_code());
//增加任务到队列
schBaseTaskList.add(task);
}
});
if (CollectionUtils.isNotEmpty(schBaseTaskList)) {
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
}
}
}

View File

@@ -284,6 +284,58 @@ public class ZxqTask extends AbstractAcsTask {
return task.getTask_id();
}
public SchBaseTask createTaskReturnTask(JSONObject form) {
Assert.notNull(form, "请求参数不能为空");
String taskType = form.getString("task_type");
if (StrUtil.isBlank(taskType)) {
throw new BadRequestException("业务类型不能为空");
}
String vehicleCode = form.getString("vehicle_code");
if (StrUtil.isBlank(vehicleCode)) {
throw new BadRequestException("载具号不能为空");
}
String pointCode1 = form.getString("point_code1");
if (StrUtil.isBlank(pointCode1)) {
throw new BadRequestException("起点不能为空");
}
String pointCode2 = form.getString("point_code2");
// if (StrUtil.isBlank(pointCode2)) {
// throw new BadRequestException("下一点不能为空");
// }
//是否立即下发
boolean isSend = !StrUtil.isNotBlank(form.getString("is_send")) || BooleanUtil.toBoolean(form.getString("is_send"));
SchBaseTaskVO schBaseTaskVo = SchBaseTaskVO.builder()
.task_type(taskType)
.vehicle_code(vehicleCode)
.vehicle_code2(form.getString("vehicle_code2"))
.point_code1(pointCode1)
.point_code2(pointCode2)
.point_code3(form.getString("point_code3"))
.point_code4(form.getString("point_code4"))
.task_id(org.nl.common.utils.IdUtil.getStringId())
.task_code(org.nl.common.utils.IdUtil.getStringId())
.handle_class(THIS_CLASS)
.car_no(form.getString("car_no"))
.create_id(SecurityUtils.getCurrentUserId())
.create_name(SecurityUtils.getCurrentUsername())
.create_time(DateUtil.now())
.is_send(isSend ? "1" : "0")
.request_param(form.getString("request_param"))
.acs_task_type(StrUtil.isEmpty(form.getString("acs_task_type")) ? PackageInfoIvtEnum.ACS_TASK_TYPE.code("agv任务") : form.getString("acs_task_type"))
.task_status(StrUtil.isEmpty(form.getString("task_status")) ? TaskStatusEnum.START_AND_POINT.getCode() : form.getString("task_status"))
.product_area(StrUtil.isEmpty(form.getString("product_area")) ? "BLK" : form.getString("product_area"))
.build();
SchBaseTask task = new SchBaseTask();
BeanUtils.copyProperties(schBaseTaskVo, task);
taskService.save(task);
//如果目标点位没有空位先创建不下发
if (isSend) {
this.immediateNotifyAcs(null);
}
return task;
}
@Override
@Transactional
public void forceFinish(String taskId) {

View File

@@ -1,18 +1,24 @@
package org.nl.b_lms.sch.tasks.first_floor_area.auto;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.nl.b_lms.pdm.bi.slittingproductionplan.service.IPdmBiSlittingproductionplanService;
import org.nl.b_lms.pdm.bi.slittingproductionplan.service.dao.PdmBiSlittingproductionplan;
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.pdm.subpackagerelation.service.IpdmBiSubpackagerelationService;
import org.nl.b_lms.sch.point.dao.BstIvtPackageinfoivt;
import org.nl.b_lms.sch.point.service.IbstIvtPackageinfoivtService;
import org.nl.b_lms.sch.task.dao.SchBaseTask;
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
import org.nl.b_lms.sch.tasks.first_floor_area.ZxDjwTask;
import org.nl.b_lms.storage_manage.database.service.dao.BstIvtBoxinfo;
import org.nl.b_lms.storage_manage.database.service.dao.mapper.BstIvtBoxinfoMapper;
@@ -20,10 +26,14 @@ import org.nl.b_lms.storage_manage.ios.enums.IOSEnum;
import org.nl.common.enums.PackageInfoIvtEnum;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.system.service.param.ISysParamService;
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static org.nl.wms.util.TaskUtil.getMaxNum;
@@ -34,11 +44,18 @@ import static org.nl.wms.util.TaskUtil.getMaxNum;
@RequiredArgsConstructor
public class AutoSendZxToDjw {
@Resource
private IschBaseTaskService taskService;
@Resource
private ZxDjwTask zxDjwTask;
@Resource
private LmsToMesServiceImpl lmsToMesServiceImpl;
@Resource
private PdmBiSubpackagerelationMapper pdmBiSubpackagerelationMapper;
@Resource
private IPdmBiSlittingproductionplanService iPdmBiSlittingproductionplanService;
@Resource
private IbstIvtPackageinfoivtService packageinfoivtService;
@Resource
@@ -65,7 +82,134 @@ public class AutoSendZxToDjw {
return;
}
//装箱区有子卷且没有正在进行的装箱任务
List<BstIvtPackageinfoivt> zxqPackageinfoivtList = packageinfoivtService.checkEndPointTask(PackageInfoIvtEnum.POINT_STATUS.code("装箱区"), PackageInfoIvtEnum.IVT_STATUS.code("有子卷"),"", "", "");
List<BstIvtPackageinfoivt> zxqPackageinfoivtList = packageinfoivtService.checkEndPointTask(PackageInfoIvtEnum.POINT_STATUS.code("装箱区"), PackageInfoIvtEnum.IVT_STATUS.code("有子卷"), "", "", "");
if (CollectionUtils.isEmpty(zxqPackageinfoivtList)) {
return;
}
//装箱位上的木箱号
String boxNo = zxwPackageinfoivtList.get(0).getContainer_name();
//获取木箱信息,未包装的木箱
BstIvtBoxinfo bstIvtBoxinfo = bstIvtBoxinfoMapper.selectOne(new LambdaQueryWrapper<BstIvtBoxinfo>().eq(BstIvtBoxinfo::getBox_no, boxNo).ne(BstIvtBoxinfo::getIs_packing, "1"));
if (bstIvtBoxinfo == null) {
throw new BadRequestException("请检查木箱号:" + boxNo + "是否存在或者状态为已装箱!");
}
//检查木箱信息
checkBoxParams(boxNo, bstIvtBoxinfo);
//3.查询子卷对应的包装关系表,判断装箱位的木箱号是否为子卷对应的木箱号,是,创建搬运任务到装箱对接位位桁架任务
List<PdmBiSubpackagerelation> relationList = subpackageRelationService
.list(new LambdaUpdateWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getPackage_box_sn, boxNo).eq(PdmBiSubpackagerelation::getStatus, "0"));
if (CollectionUtils.isEmpty(relationList)) {
throw new BadRequestException("装箱位的木箱号" + boxNo + "对应的子卷包装关系异常,请检查子卷包装关系状态是否为0!");
}
//获取与该木箱号匹配的子卷号
String containerName = relationList.get(0).getContainer_name();
List<BstIvtPackageinfoivt> zxqPoint = zxqPackageinfoivtList.stream().filter(r -> r.getContainer_name().equals(containerName)).collect(Collectors.toList());
//装箱区点位上有与该木箱号匹配的子卷
if (CollectionUtils.isNotEmpty(zxqPoint)) {
List<PdmBiSlittingproductionplan> productionPlanList = pdmBiSlittingproductionplanMapper.selectList(new LambdaQueryWrapper<PdmBiSlittingproductionplan>().eq(PdmBiSlittingproductionplan::getContainer_name, containerName));
if (productionPlanList.isEmpty()) {
throw new BadRequestException("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!");
}
//校验是否存在相同子卷号任务
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, containerName).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位")).eq(SchBaseTask::getIs_delete, IOSEnum.IS_NOTANDYES.code("")));
if (CollectionUtils.isEmpty(taskList)) {
//创建搬运任务到装箱位
JSONObject jo = new JSONObject();
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位"));
jo.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
jo.put("point_code1", zxqPoint.get(0).getPoint_code());
jo.put("point_code2", zxwPackageinfoivtList.get(0).getPoint_code());
jo.put("vehicle_code", containerName);
jo.put("vehicle_code2", boxNo);
jo.put("is_send", IOSEnum.IS_NOTANDYES.code(""));
//扩展参数
JSONObject param = new JSONObject();
//查询是否为最后一个子卷暂时默认1
param.put("lastOne", IOSEnum.IS_NOTANDYES.code(""));
//获取木箱高度等级
param.put("heightLevel", getHeightLevel(bstIvtBoxinfo));
//获取子卷长度
param.put("len", getMaxNum(productionPlanList.get(0), null));
//木箱最大数量
param.put("maxNo", bstIvtBoxinfo.getNum());
//托盘类型 1小托盘 2大托盘
param.put("containerType", bstIvtBoxinfo.getVehicle_type());
//木箱需放入子卷数量
//param.put("boxNo", relationList.get(0).getQuanlity_in_box());
param.put("boxNo", 1);
//子卷号
param.put("barcode", containerName);
jo.put("request_param", param.toString());
zxDjwTask.createTask(jo);
try {
//传输子卷包装关系至MES
transferBoxPackageToMes(relationList, bstIvtBoxinfo);
} catch (Exception ex) {
log.error("装箱区->装箱对接位sendZxToDjw,传输子卷包装关系至MES接口捕获异常信息" + ex);
}
}
}
}
/**
* 传输子卷包装关系至MES
*/
public void transferBoxPackageToMes(List<PdmBiSubpackagerelation> packagerelationList, BstIvtBoxinfo bstIvtBoxinfo) {
if (StringUtils.isBlank(packagerelationList.get(0).getPackage_box_sn()) || packagerelationList.get(0).getBox_weight() == null) {
throw new BadRequestException("子卷未确定木箱规格信息!");
}
JSONObject param = new JSONObject();
Set<String> containerNameList = packagerelationList.stream()
.map(PdmBiSubpackagerelation::getContainer_name)
.collect(Collectors.toSet());
List<PdmBiSlittingproductionplan> planList = iPdmBiSlittingproductionplanService.list(new LambdaQueryWrapper<PdmBiSlittingproductionplan>().in(PdmBiSlittingproductionplan::getContainer_name, containerNameList));
if (CollectionUtils.isEmpty(planList)) {
throw new BadRequestException("该箱号不存在分切计划");
}
BigDecimal totalWeight;
totalWeight = planList.stream()
.map(PdmBiSlittingproductionplan::getWeight)
.filter(Objects::nonNull)
.filter(r -> !r.isEmpty())
.map(BigDecimal::new)
.reduce(BigDecimal.ZERO, BigDecimal::add);
if (totalWeight.compareTo(new BigDecimal(0)) == 0) {
throw new BadRequestException("分切计划的子卷重量不能为0");
}
BigDecimal boxWeight = new BigDecimal(bstIvtBoxinfo.getBox_weight());
if (boxWeight.compareTo(new BigDecimal(0)) == 0) {
throw new BadRequestException("木箱的重量不能0");
}
totalWeight = totalWeight.add(boxWeight);
if (totalWeight.compareTo(new BigDecimal(0)) == 0) {
throw new BadRequestException("理论毛重不能为0");
}
//更新子卷包装关系的重量
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("box_weight", totalWeight);
updateWrapper.set("status", "0");
updateWrapper.eq("container_name", packagerelationList.get(0).getContainer_name());
pdmBiSubpackagerelationMapper.update(null, updateWrapper);
//推送MES
JSONArray containerJsonArray = packagerelationList.stream().map(PdmBiSubpackagerelation::getContainer_name).collect(Collectors.toCollection(JSONArray::new));
param.put("rows", containerJsonArray);
param.put("num", packagerelationList.size());
param.put("box_no", packagerelationList.get(0).getPackage_box_sn());
param.put("box_weight", totalWeight);
lmsToMesServiceImpl.momBoxPackageSubmit(param);
}
void sendZxToDjw8() {
//todo 正式环境代码,需恢复
//装箱位有木箱
List<BstIvtPackageinfoivt> zxwPackageinfoivtList = packageinfoivtService.checkEndPointTask(PackageInfoIvtEnum.POINT_STATUS.code("装箱位"), PackageInfoIvtEnum.IVT_STATUS.code("空载具"), "", PackageInfoIvtEnum.SORT_TYPE.code("升序"), PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位"));
if (CollectionUtils.isEmpty(zxwPackageinfoivtList)) {
return;
}
//装箱区有子卷且没有正在进行的装箱任务
List<BstIvtPackageinfoivt> zxqPackageinfoivtList = packageinfoivtService.checkEndPointTask(PackageInfoIvtEnum.POINT_STATUS.code("装箱区"), PackageInfoIvtEnum.IVT_STATUS.code("有子卷"), "", "", "");
if (CollectionUtils.isEmpty(zxqPackageinfoivtList)) {
return;
}
@@ -115,7 +259,7 @@ public class AutoSendZxToDjw {
//获取木箱高度等级
param.put("heightLevel", getHeightLevel(bstIvtBoxinfo));
//获取子卷长度
param.put("len", getMaxNum(productionPlanList.get(0),null));
param.put("len", getMaxNum(productionPlanList.get(0), null));
//木箱最大数量
param.put("maxNo", bstIvtBoxinfo.getNum());
//托盘类型 1小托盘 2大托盘
@@ -127,7 +271,6 @@ public class AutoSendZxToDjw {
jo.put("request_param", param.toString());
zxDjwTask.createTask(jo);
}
}
private static void checkBoxParams(String boxNo, BstIvtBoxinfo bstIvtBoxinfo) {
@@ -144,8 +287,10 @@ public class AutoSendZxToDjw {
private String getHeightLevel(BstIvtBoxinfo bstIvtBoxinfo) {
String height;
String heightLevel1 = iSysParamService.findByCode("height_level_1").getValue();
String heightLevel2 = iSysParamService.findByCode("height_level_2").getValue();
//String heightLevel1 = iSysParamService.findByCode("height_level_1").getValue();
//String heightLevel2 = iSysParamService.findByCode("height_level_2").getValue();
String heightLevel1 = "650";
String heightLevel2 = "800";
String box_high = bstIvtBoxinfo.getBox_high();
if (Integer.parseInt(box_high) <= Integer.parseInt(heightLevel1)) {
height = "1";

View File

@@ -1,7 +1,10 @@
package org.nl.b_lms.sch.tasks.first_floor_area.auto;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
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.task.dao.SchBaseTask;
import org.nl.b_lms.sch.task.service.IschBaseTaskService;
import org.nl.b_lms.sch.tasks.first_floor_area.ZxqTask;
@@ -20,6 +23,9 @@ public class TaskQueue {
@Resource
private IschBaseTaskService taskService;
@Resource
private PdmBiSubpackagerelationMapper pdmBiSubpackagerelationMapper;
@Resource
private ZxqTask zxqTask;
@@ -58,7 +64,10 @@ public class TaskQueue {
task.setPoint_code2(pointCode);
task.setTask_status(TaskStatusEnum.START_AND_POINT.getCode());
taskService.updateById(task);
zxqTask.immediateNotifyAcs(null);
//删除子卷包装关系
LambdaQueryWrapper<PdmBiSubpackagerelation> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PdmBiSubpackagerelation::getContainer_name, task.getVehicle_code());
pdmBiSubpackagerelationMapper.delete(queryWrapper);
}
}