fix:暂时取消MES子卷毛重推送

This commit is contained in:
2024-07-04 00:05:08 +08:00
parent 63316e1f19
commit d9f374983d
2 changed files with 122 additions and 82 deletions

View File

@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j; import lombok.extern.log4j.Log4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -42,6 +43,8 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.ISysParamService;
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl; import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
import org.nl.wms.sch.manage.TaskStatusEnum; import org.nl.wms.sch.manage.TaskStatusEnum;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -52,6 +55,7 @@ import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -65,6 +69,9 @@ import java.util.stream.Collectors;
@Log4j @Log4j
public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpackagerelationMapper, PdmBiSubpackagerelation> implements IpdmBiSubpackagerelationService { public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpackagerelationMapper, PdmBiSubpackagerelation> implements IpdmBiSubpackagerelationService {
@Resource
private RedissonClient redissonClient;
@Resource @Resource
private IschBaseTaskService taskService; private IschBaseTaskService taskService;
@Resource @Resource
@@ -353,11 +360,11 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
boxInfo.put("device_code", deviceCode); boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", boxType); boxInfo.put("material_code", boxType);
boxInfo.put("num", workIdList.size()); boxInfo.put("num", workIdList.size());
String boxSn = outBoxManageService.outBox(boxInfo); //String boxSn = outBoxManageService.outBox(boxInfo);
stopWatch.stop(); stopWatch.stop();
System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis()); System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis()); log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
//String boxSn = "MX230118000013"; String boxSn = "MX230118000013";
StopWatch stopWatch1 = new StopWatch(); StopWatch stopWatch1 = new StopWatch();
stopWatch1.start(); stopWatch1.start();
//更新及子卷包装状态已分配规格及木箱规格组 //更新及子卷包装状态已分配规格及木箱规格组
@@ -760,11 +767,16 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
sub.setCustomer_description("临时包装关系"); sub.setCustomer_description("临时包装关系");
sub.setProduct_description(plan.getDescription()); sub.setProduct_description(plan.getDescription());
sub.setWidth(String.valueOf(plan.getSplit_breadth())); sub.setWidth(String.valueOf(plan.getSplit_breadth()));
if (StringUtils.isBlank(plan.getWeight()) || StringUtils.isBlank(plan.getPaper_weight())) { BigDecimal paperWeight = BigDecimal.ZERO;
throw new BadRequestException("该子卷分切计划中的子卷重量参数为空!"); BigDecimal weight = BigDecimal.ZERO;
if (StringUtils.isNotBlank(plan.getPaper_weight())) {
paperWeight = new BigDecimal(plan.getPaper_weight());
} }
int net_weight = Integer.parseInt(plan.getWeight()) - Integer.parseInt(plan.getPaper_weight()); if (StringUtils.isNotBlank(plan.getWeight())) {
sub.setNet_weight(net_weight + ""); weight = new BigDecimal(plan.getWeight());
}
BigDecimal netWeightDecimal = weight.subtract(paperWeight);
sub.setNet_weight(netWeightDecimal.toString());
sub.setLength("1000"); sub.setLength("1000");
sub.setIs_un_plan_production("0"); sub.setIs_un_plan_production("0");
sub.setCreate_id(1L); sub.setCreate_id(1L);
@@ -819,7 +831,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
.map(Integer::parseInt) .map(Integer::parseInt)
.max(Integer::compareTo) .max(Integer::compareTo)
.orElse(0) + 1; .orElse(0) + 1;
try {
List<String> workIdList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream() List<String> workIdList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
.map(PdmBiSubpackagerelation::getWorkorder_id) .map(PdmBiSubpackagerelation::getWorkorder_id)
.map(String::valueOf) .map(String::valueOf)
@@ -835,9 +846,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
System.out.println("子卷装箱代码1装箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis()); System.out.println("子卷装箱代码1装箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("子卷装箱代码1箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis()); log.info("子卷装箱代码1箱信息查询执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson.getString("checked")); outBox(workIdList, containerNameList, deviceCode, maxBoxGroup, whereJson.getString("checked"));
} catch (Exception e) {
log.error("子卷装箱updateEntityList接口捕获异常信息" + e);
}
} }
@@ -854,11 +862,11 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
boxInfo.put("device_code", deviceCode); boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", boxType); boxInfo.put("material_code", boxType);
boxInfo.put("num", workIdList.size()); boxInfo.put("num", workIdList.size());
//String boxSn = outBoxManageService.outBox(boxInfo); String boxSn = outBoxManageService.outBox(boxInfo);
stopWatch.stop(); stopWatch.stop();
System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis()); System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis()); log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
String boxSn = "MX240703000118"; //String boxSn = "MX240703000118";
StopWatch stopWatch1 = new StopWatch(); StopWatch stopWatch1 = new StopWatch();
stopWatch1.start(); stopWatch1.start();
//更新及子卷包装状态已分配规格及木箱规格组 //更新及子卷包装状态已分配规格及木箱规格组
@@ -883,6 +891,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
} }
@SneakyThrows
protected void agvTransfer(Set<String> containerNameList, String deviceCode, String boxSn) { protected void agvTransfer(Set<String> containerNameList, String deviceCode, String boxSn) {
//待检区点位 //待检区点位
List<BstIvtPackageinfoivt> djqPointList = packageinfoivtService List<BstIvtPackageinfoivt> djqPointList = packageinfoivtService
@@ -897,34 +906,47 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
.collect(Collectors.toList()); .collect(Collectors.toList());
//任务组id //任务组id
String groupId = deviceCode.substring(deviceCode.lastIndexOf("_") + 1); String groupId = deviceCode.substring(deviceCode.lastIndexOf("_") + 1);
List<SchBaseTask> schBaseTaskList = new ArrayList<>(); RLock lock = redissonClient.getLock(groupId);
//确定起点,安装装箱组标识加入任务队列 boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
djqPoints.forEach(r -> { try {
//校验重复任务 if (tryLock) {
List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, r.getContainer_name()).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区")) List<SchBaseTask> schBaseTaskList = new ArrayList<>();
.eq(SchBaseTask::getIs_delete, IOSEnum.IS_NOTANDYES.code("")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED)); //确定起点,安装装箱组标识加入任务队列
if (CollectionUtils.isEmpty(taskList)) { djqPoints.forEach(r -> {
JSONObject jo = new JSONObject(); //校验重复任务
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区")); List<SchBaseTask> taskList = taskService.list(new LambdaQueryWrapper<SchBaseTask>().eq(SchBaseTask::getVehicle_code, r.getContainer_name()).eq(SchBaseTask::getTask_type, PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"))
jo.put("vehicle_code", r.getContainer_name()); .eq(SchBaseTask::getIs_delete, IOSEnum.IS_NOTANDYES.code("")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED));
jo.put("point_code1", r.getPoint_code()); if (CollectionUtils.isEmpty(taskList)) {
jo.put("task_status", TaskStatusEnum.SURE_START.getCode()); JSONObject jo = new JSONObject();
//木箱号 jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("待检区->装箱区"));
jo.put("vehicle_code2", groupId); jo.put("vehicle_code", r.getContainer_name());
//任务组id jo.put("point_code1", r.getPoint_code());
SchBaseTask task = new SchBaseTask(); jo.put("task_status", TaskStatusEnum.SURE_START.getCode());
//保存任务子卷 //木箱
SchBaseTask taskDto = zxqTask.createTaskReturnTask(jo); jo.put("vehicle_code2", groupId);
task.setTask_id(taskDto.getTask_id()); //任务组id
task.setVehicle_code(taskDto.getVehicle_code()); SchBaseTask task = new SchBaseTask();
//增加任务到队列 //保存任务子卷号
schBaseTaskList.add(task); 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);
}
} else {
log.info("待检区->装箱区任务队列正在创建被锁住。");
}
} finally {
if (tryLock) {
lock.unlock();
} }
});
if (CollectionUtils.isNotEmpty(schBaseTaskList)) {
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
} }
} }
} }

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -28,6 +29,8 @@ import org.nl.modules.common.exception.BadRequestException;
import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.ISysParamService;
import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl; import org.nl.wms.ext.mes.service.impl.LmsToMesServiceImpl;
import org.nl.wms.sch.manage.TaskStatusEnum; import org.nl.wms.sch.manage.TaskStatusEnum;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@@ -35,6 +38,7 @@ import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.nl.wms.util.TaskUtil.getMaxNum; import static org.nl.wms.util.TaskUtil.getMaxNum;
@@ -45,6 +49,7 @@ import static org.nl.wms.util.TaskUtil.getMaxNum;
@RequiredArgsConstructor @RequiredArgsConstructor
public class AutoSendZxToDjw { public class AutoSendZxToDjw {
private final RedissonClient redissonClient;
@Resource @Resource
private IschBaseTaskService taskService; private IschBaseTaskService taskService;
@Resource @Resource
@@ -76,7 +81,8 @@ public class AutoSendZxToDjw {
this.sendZxToDjw(); this.sendZxToDjw();
} }
void sendZxToDjw() { @SneakyThrows
public void sendZxToDjw() {
//装箱位有木箱 //装箱位有木箱
List<BstIvtPackageinfoivt> zxwPackageinfoivtList = packageinfoivtService.checkEndPointTask(PackageInfoIvtEnum.POINT_STATUS.code("装箱位"), PackageInfoIvtEnum.IVT_STATUS.code("空载具"), "", PackageInfoIvtEnum.SORT_TYPE.code("升序"), PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位")); 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)) { if (CollectionUtils.isEmpty(zxwPackageinfoivtList)) {
@@ -106,51 +112,63 @@ public class AutoSendZxToDjw {
} }
//获取与该木箱号匹配的子卷号 //获取与该木箱号匹配的子卷号
String containerName = relationList.get(0).getContainer_name(); String containerName = relationList.get(0).getContainer_name();
List<BstIvtPackageinfoivt> zxqPoint = zxqPackageinfoivtList.stream().filter(r -> r.getContainer_name().equals(containerName)).collect(Collectors.toList()); RLock lock = redissonClient.getLock(containerName);
//装箱区点位上有与该木箱号匹配的子卷 boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
if (CollectionUtils.isNotEmpty(zxqPoint)) { try {
List<PdmBiSlittingproductionplan> productionPlanList = pdmBiSlittingproductionplanMapper.selectList(new LambdaQueryWrapper<PdmBiSlittingproductionplan>().eq(PdmBiSlittingproductionplan::getContainer_name, containerName)); if (tryLock) {
if (productionPlanList.isEmpty()) { List<BstIvtPackageinfoivt> zxqPoint = zxqPackageinfoivtList.stream().filter(r -> r.getContainer_name().equals(containerName)).collect(Collectors.toList());
log.info("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!"); //装箱区点位上有与该木箱号匹配的子卷
throw new BadRequestException("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!"); if (CollectionUtils.isNotEmpty(zxqPoint)) {
} List<PdmBiSlittingproductionplan> productionPlanList = pdmBiSlittingproductionplanMapper.selectList(new LambdaQueryWrapper<PdmBiSlittingproductionplan>().eq(PdmBiSlittingproductionplan::getContainer_name, containerName));
//校验是否存在相同子卷号任务 if (productionPlanList.isEmpty()) {
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("")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode())); log.info("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!");
if (CollectionUtils.isEmpty(taskList)) { throw new BadRequestException("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!");
//创建搬运任务到装箱位 }
JSONObject jo = new JSONObject(); //校验是否存在相同子卷号任务
jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位")); 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("")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode()));
jo.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务")); if (CollectionUtils.isEmpty(taskList)) {
jo.put("point_code1", zxqPoint.get(0).getPoint_code()); //创建搬运任务到装箱位
jo.put("point_code2", zxwPackageinfoivtList.get(0).getPoint_code()); JSONObject jo = new JSONObject();
jo.put("vehicle_code", containerName); jo.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("装箱区->装箱对接位"));
jo.put("vehicle_code2", boxNo); jo.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
jo.put("is_send", IOSEnum.IS_NOTANDYES.code("")); jo.put("point_code1", zxqPoint.get(0).getPoint_code());
//扩展参数 jo.put("point_code2", zxwPackageinfoivtList.get(0).getPoint_code());
JSONObject param = new JSONObject(); jo.put("vehicle_code", containerName);
//查询是否为最后一个子卷暂时默认1 jo.put("vehicle_code2", boxNo);
param.put("lastOne", IOSEnum.IS_NOTANDYES.code("")); jo.put("is_send", IOSEnum.IS_NOTANDYES.code(""));
//获取木箱高度等级 //扩展参数
param.put("heightLevel", getHeightLevel(bstIvtBoxinfo)); JSONObject param = new JSONObject();
//获取子卷长度 //查询是否为最后一个子卷暂时默认1
param.put("len", getMaxNum(productionPlanList.get(0), null)); param.put("lastOne", IOSEnum.IS_NOTANDYES.code(""));
//木箱最大数量 //获取木箱高度等级
param.put("maxNo", bstIvtBoxinfo.getNum()); param.put("heightLevel", getHeightLevel(bstIvtBoxinfo));
//托盘类型 1小托盘 2大托盘 //获取子卷长度
param.put("containerType", bstIvtBoxinfo.getVehicle_type()); param.put("len", getMaxNum(productionPlanList.get(0), null));
//木箱需放入子卷数量 //木箱最大数量
//param.put("boxNo", relationList.get(0).getQuanlity_in_box()); param.put("maxNo", bstIvtBoxinfo.getNum());
param.put("boxNo", 1); //托盘类型 1小托盘 2大托盘
//子卷号 param.put("containerType", bstIvtBoxinfo.getVehicle_type());
param.put("barcode", containerName); //木箱需放入子卷数量
jo.put("request_param", param.toString()); //param.put("boxNo", relationList.get(0).getQuanlity_in_box());
zxDjwTask.createTask(jo); param.put("boxNo", 1);
try { //子卷号
//传输子卷包装关系至MES param.put("barcode", containerName);
transferBoxPackageToMes(relationList, bstIvtBoxinfo); jo.put("request_param", param.toString());
} catch (Exception ex) { zxDjwTask.createTask(jo);
log.error("装箱区->装箱对接位sendZxToDjw,传输子卷包装关系至MES接口捕获异常信息" + ex); // try {
//todo 传输子卷包装关系至MES,暂时不计算,MES会推过来
//transferBoxPackageToMes(relationList, bstIvtBoxinfo);
// } catch (Exception ex) {
// log.error("装箱区->装箱对接位sendZxToDjw,传输子卷包装关系至MES接口捕获异常信息" + ex);
// }
}
} }
} else {
log.info("装箱区->装箱对接位agv自动搬运任务正在创建被锁住。");
}
} finally {
if (tryLock) {
lock.unlock();
} }
} }
} }