fix:暂时取消MES子卷毛重推送
This commit is contained in:
@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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.wms.ext.mes.service.impl.LmsToMesServiceImpl;
|
||||
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.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -52,6 +55,7 @@ import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -65,6 +69,9 @@ import java.util.stream.Collectors;
|
||||
@Log4j
|
||||
public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpackagerelationMapper, PdmBiSubpackagerelation> implements IpdmBiSubpackagerelationService {
|
||||
|
||||
|
||||
@Resource
|
||||
private RedissonClient redissonClient;
|
||||
@Resource
|
||||
private IschBaseTaskService taskService;
|
||||
@Resource
|
||||
@@ -353,11 +360,11 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
boxInfo.put("device_code", deviceCode);
|
||||
boxInfo.put("material_code", boxType);
|
||||
boxInfo.put("num", workIdList.size());
|
||||
String boxSn = outBoxManageService.outBox(boxInfo);
|
||||
//String boxSn = outBoxManageService.outBox(boxInfo);
|
||||
stopWatch.stop();
|
||||
System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||
log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||
//String boxSn = "MX230118000013";
|
||||
String boxSn = "MX230118000013";
|
||||
StopWatch stopWatch1 = new StopWatch();
|
||||
stopWatch1.start();
|
||||
//更新及子卷包装状态已分配规格及木箱规格组
|
||||
@@ -760,11 +767,16 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
sub.setCustomer_description("临时包装关系");
|
||||
sub.setProduct_description(plan.getDescription());
|
||||
sub.setWidth(String.valueOf(plan.getSplit_breadth()));
|
||||
if (StringUtils.isBlank(plan.getWeight()) || StringUtils.isBlank(plan.getPaper_weight())) {
|
||||
throw new BadRequestException("该子卷分切计划中的子卷重量参数为空!");
|
||||
BigDecimal paperWeight = BigDecimal.ZERO;
|
||||
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());
|
||||
sub.setNet_weight(net_weight + "");
|
||||
if (StringUtils.isNotBlank(plan.getWeight())) {
|
||||
weight = new BigDecimal(plan.getWeight());
|
||||
}
|
||||
BigDecimal netWeightDecimal = weight.subtract(paperWeight);
|
||||
sub.setNet_weight(netWeightDecimal.toString());
|
||||
sub.setLength("1000");
|
||||
sub.setIs_un_plan_production("0");
|
||||
sub.setCreate_id(1L);
|
||||
@@ -819,7 +831,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
.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)
|
||||
@@ -835,9 +846,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -854,11 +862,11 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
boxInfo.put("device_code", deviceCode);
|
||||
boxInfo.put("material_code", boxType);
|
||||
boxInfo.put("num", workIdList.size());
|
||||
//String boxSn = outBoxManageService.outBox(boxInfo);
|
||||
String boxSn = outBoxManageService.outBox(boxInfo);
|
||||
stopWatch.stop();
|
||||
System.out.println("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||
log.info("木箱出库代码执行花费时间------------------------------------------------------------------------------------------*************************************************************************************************= totalTime = " + stopWatch.getTotalTimeMillis());
|
||||
String boxSn = "MX240703000118";
|
||||
//String boxSn = "MX240703000118";
|
||||
StopWatch stopWatch1 = new StopWatch();
|
||||
stopWatch1.start();
|
||||
//更新及子卷包装状态已分配规格及木箱规格组
|
||||
@@ -883,6 +891,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
}
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
protected void agvTransfer(Set<String> containerNameList, String deviceCode, String boxSn) {
|
||||
//待检区点位
|
||||
List<BstIvtPackageinfoivt> djqPointList = packageinfoivtService
|
||||
@@ -897,34 +906,47 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
|
||||
.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("否")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED));
|
||||
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);
|
||||
RLock lock = redissonClient.getLock(groupId);
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
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("否")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED));
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
log.info("待检区->装箱区任务队列正在创建被锁住。");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(schBaseTaskList)) {
|
||||
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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.UpdateWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
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.wms.ext.mes.service.impl.LmsToMesServiceImpl;
|
||||
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||
import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -35,6 +38,7 @@ import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.nl.wms.util.TaskUtil.getMaxNum;
|
||||
@@ -45,6 +49,7 @@ import static org.nl.wms.util.TaskUtil.getMaxNum;
|
||||
@RequiredArgsConstructor
|
||||
public class AutoSendZxToDjw {
|
||||
|
||||
private final RedissonClient redissonClient;
|
||||
@Resource
|
||||
private IschBaseTaskService taskService;
|
||||
@Resource
|
||||
@@ -76,7 +81,8 @@ public class AutoSendZxToDjw {
|
||||
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("装箱区->装箱对接位"));
|
||||
if (CollectionUtils.isEmpty(zxwPackageinfoivtList)) {
|
||||
@@ -106,51 +112,63 @@ public class AutoSendZxToDjw {
|
||||
}
|
||||
//获取与该木箱号匹配的子卷号
|
||||
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()) {
|
||||
log.info("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!");
|
||||
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("否")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode()));
|
||||
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);
|
||||
RLock lock = redissonClient.getLock(containerName);
|
||||
boolean tryLock = lock.tryLock(0, TimeUnit.SECONDS);
|
||||
try {
|
||||
if (tryLock) {
|
||||
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()) {
|
||||
log.info("装箱区的子卷号为" + containerName + "无对应的分切计划信息,请检查!");
|
||||
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("否")).lt(SchBaseTask::getTask_status, TaskStatusEnum.FINISHED.getCode()));
|
||||
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 {
|
||||
//todo 传输子卷包装关系至MES,暂时不计算,MES会推过来
|
||||
//transferBoxPackageToMes(relationList, bstIvtBoxinfo);
|
||||
// } catch (Exception ex) {
|
||||
// log.error("装箱区->装箱对接位sendZxToDjw,传输子卷包装关系至MES接口捕获异常信息:" + ex);
|
||||
// }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info("装箱区->装箱对接位agv自动搬运任务正在创建被锁住。");
|
||||
}
|
||||
} finally {
|
||||
if (tryLock) {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user