opt:6.15上线装箱区代码修改

This commit is contained in:
2024-06-17 21:26:41 +08:00
parent 019022a5a8
commit fd7f0e488b
5 changed files with 80 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
package org.nl.b_lms.pdm.subpackagerelation.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -26,6 +27,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.nl.common.domain.query.PageQuery;
@@ -34,6 +37,8 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.stream.Collectors;
@@ -55,7 +60,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
private ISysParamService iSysParamService;
@Resource
private DjqTask djqTask;
@Resource
@@ -84,6 +88,9 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
private TaskQueueManager taskQueueManager;
@Resource
private TaskQueue taskQueue;
@Resource
@Qualifier("threadPoolExecutor")
private ThreadPoolExecutor pool;
/**
* 查询数据分页
@@ -101,11 +108,10 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
@Override
public IPage<PdmBiSubpackagerelation> queryContainerization(Map whereJson, PageQuery pageable) {
Page<PdmBiSubpackagerelation> pageObject = new Page<>(pageable.getPage(), pageable.getSize());
return pdmBiSubpackagerelationMapper.selectGroupedSubPackageRelation(pageObject,(String)whereJson.get("sale_order_name"),(String)whereJson.get("customer_name"),(String)whereJson.get("customer_description"),(String)whereJson.get("status"));
return pdmBiSubpackagerelationMapper.selectGroupedSubPackageRelation(pageObject, (String) whereJson.get("sale_order_name"), (String) whereJson.get("customer_name"), (String) whereJson.get("customer_description"), (String) whereJson.get("status"));
}
/**
* 查询订单装箱信息
*
@@ -140,10 +146,6 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
}
/**
* 根据订单号查询子卷信息
*
@@ -405,15 +407,12 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
if (isOutBox.size() > 0) {
throw new BadRequestException("标记为黄色的子卷号已分配木箱,请重新选择未分配木箱的子卷");
}
List<String> entityList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
.map(PdmBiSubpackagerelation::getWorkorder_id)
.map(String::valueOf)
.collect(Collectors.toList());
if (entityList.isEmpty()) {
return;
JSONArray jsonArray = whereJson.getJSONArray("tableMater");
if (jsonArray == null || jsonArray.size() == 0) {
throw new BadRequestException("无选中子卷信息");
}
List<PdmBiSubpackagerelation> pdmBiSubpackagerelationList = pdmBiSubpackagerelationMapper
.selectList(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getSale_order_name, whereJson.getString("sale_order_name")));
.selectList(new LambdaQueryWrapper<PdmBiSubpackagerelation>().eq(PdmBiSubpackagerelation::getSale_order_name, jsonArray.getJSONObject(0).getString("sale_order_name")));
Integer maxBoxGroup = pdmBiSubpackagerelationList.stream()
.map(PdmBiSubpackagerelation::getBox_group)
.filter(Objects::nonNull)
@@ -421,6 +420,13 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
.max(Integer::compareTo)
.orElse(0) + 1;
try {
List<String> entityList = JSONObject.parseArray(whereJson.getJSONArray("tableMater").toJSONString(), PdmBiSubpackagerelation.class).stream()
.map(PdmBiSubpackagerelation::getWorkorder_id)
.map(String::valueOf)
.collect(Collectors.toList());
if (entityList.isEmpty()) {
return;
}
// code终点,material_code木箱规格,num: 子卷数
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper = new UpdateWrapper<>();
String boxType = whereJson.getString("checked");
@@ -440,8 +446,38 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
* 空木箱出库
*/
private void outBox(List<String> entityList, List<PdmBiSubpackagerelation> packagerelationList, String boxType) {
//均衡获取装箱对接位
//String deviceCode= getPointCode();
String deviceCode = "ZXQ_1_1";
JSONObject boxInfo = new JSONObject();
String deviceCode;
//确定装箱区终点
boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", boxType);
boxInfo.put("num", entityList.size());
String boxSn = outBoxManageService.outBox(boxInfo);
if (StringUtils.isBlank(boxSn)) {
throw new BadRequestException("库位 -> 装箱对接位,木箱码不能为空!");
}
//更新子卷包装关系更新木箱号
CompletableFuture.runAsync(() -> {
try {
updateBoxInfo(entityList, boxSn);
} catch (Exception e) {
log.error("异常信息:" + e);
}
}, pool);
//待检区->装箱区agv任务
String finalDeviceCode = deviceCode;
CompletableFuture.runAsync(() -> {
try {
agvTransfer(packagerelationList, finalDeviceCode, boxSn);
} catch (Exception e) {
log.error("异常信息:" + e);
}
}, pool);
}
private String getPointCode() {
//均衡获取木箱出库终点
List<BstIvtPackageinfoivt> bstIvtPackageinfoivtList = bstIvtPackageinfoivtMapper.selectList(new LambdaQueryWrapper<BstIvtPackageinfoivt>().eq(BstIvtPackageinfoivt::getPoint_status, "5").eq(BstIvtPackageinfoivt::getIs_used, "1").orderByAsc(BstIvtPackageinfoivt::getPoint_code));
if (CollectionUtils.isEmpty(bstIvtPackageinfoivtList)) {
@@ -476,23 +512,15 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
Optional<String> minPointCode = result.stream()
.min(Comparator.comparingInt(map -> map.entrySet().iterator().next().getValue()))
.map(map -> map.keySet().iterator().next());
deviceCode = minPointCode.orElseGet(() -> bstIvtPackageinfoivtList.get(0).getPoint_code());
//确定装箱区终点
boxInfo.put("device_code", deviceCode);
boxInfo.put("material_code", boxType);
boxInfo.put("num", entityList.size());
String boxSn = outBoxManageService.outBox(boxInfo);
//String boxSn = "MX61401";
if (StringUtils.isBlank(boxSn)) {
throw new BadRequestException("库位 -> 装箱对接位,木箱码不能为空!");
}
//更新子卷包装关系更新木箱号
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper1 = new UpdateWrapper<>();
updateWrapper1.set("package_box_sn", boxSn);
updateWrapper1.in("workorder_id", entityList);
pdmBiSubpackagerelationMapper.update(null, updateWrapper1);
//待检区->装箱区agv任务
agvTransfer(packagerelationList, deviceCode, boxSn);
return minPointCode.orElseGet(() -> bstIvtPackageinfoivtList.get(0).getPoint_code());
}
protected void updateBoxInfo(List<String> entityList, String boxSn) {
UpdateWrapper<PdmBiSubpackagerelation> updateWrapper = new UpdateWrapper<>();
updateWrapper.set("package_box_sn", boxSn);
updateWrapper.in("workorder_id", entityList);
pdmBiSubpackagerelationMapper.update(null, updateWrapper);
}
@@ -539,7 +567,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
}
private void agvTransfer(List<PdmBiSubpackagerelation> packagerelationList, String deviceCode, String boxSn) {
protected void agvTransfer(List<PdmBiSubpackagerelation> packagerelationList, String deviceCode, String boxSn) {
//待检区点位
List<BstIvtPackageinfoivt> djqPointList = packageinfoivtService
.list(new LambdaUpdateWrapper<BstIvtPackageinfoivt>()
@@ -571,7 +599,7 @@ public class PdmBiSubpackagerelationServiceImpl extends ServiceImpl<PdmBiSubpack
schBaseTaskList.add(task);
});
//taskQueueManager.addTasksToQueue(groupId, schBaseTaskList);
taskQueue.addTasksToQueue(groupId, schBaseTaskList);
// taskQueue.addTasksToQueue(groupId, schBaseTaskList);
}

View File

@@ -130,7 +130,7 @@ public class MzhcwTask extends AbstractAcsTask {
.eq(BstIvtPackageinfoivt::getIs_used, PackageInfoIvtEnum.IS_USED.code("启用"))
.eq(BstIvtPackageinfoivt::getPoint_status, PackageInfoIvtEnum.POINT_STATUS.code("空载具缓存位"))
.eq(BstIvtPackageinfoivt::getIvt_status, PackageInfoIvtEnum.IVT_STATUS.code("空载具"))
.orderByAsc(BstIvtPackageinfoivt::getSort_seq));
.orderByDesc(BstIvtPackageinfoivt::getSort_seq));
JSONObject toSsxTask = new JSONObject();
toSsxTask.put("acs_task_type", PackageInfoIvtEnum.ACS_TASK_TYPE.code("桁架任务"));
toSsxTask.put("task_type", PackageInfoIvtEnum.TASK_TYPE.code("放空(空载具缓存位->输送线)"));

View File

@@ -37,4 +37,6 @@ public class AsyncTaskProperties {
private int keepAliveSeconds;
private int queueCapacity;
private int awaitTerminationSeconds;
}

View File

@@ -44,6 +44,8 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
String search = MapUtil.getStr(whereJson, "search");
//只查询木箱
String box = MapUtil.getStr(whereJson, "box");
//物料限制的时候使用,初始化页面
String class_idStr = MapUtil.getStr(whereJson, "class_idStr");
String material_type_id = MapUtil.getStr(whereJson, "material_type_id");
@@ -61,6 +63,13 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
}
map.put("search", "%" + search + "%");
}
if (!StrUtil.isEmpty(box)) {
//处理转义字符
if (box.contains("\\")) {
box = box.replace("\\", "\\\\\\");
}
map.put("box", "%" + box + "%");
}
//处理物料当前节点的所有子节点
if (!StrUtil.isEmpty(material_type_id)) {

View File

@@ -15,6 +15,7 @@
#################################################
输入.flag TYPEAS s_string
输入.search TYPEAS s_string
输入.box TYPEAS s_string
输入.class_code TYPEAS s_string
输入.idssql TYPEAS f_string
输入.classIds TYPEAS f_string
@@ -59,6 +60,11 @@
mb.material_name like 输入.search
)
ENDOPTION
OPTION 输入.box <> ""
(
mb.material_name like 输入.box
)
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF