opt: 备货区检测管芯使用,防止所需要的托盘被搬走
This commit is contained in:
@@ -58,6 +58,16 @@ public interface IBstIvtStockingivtService extends IService<BstIvtStockingivt> {
|
||||
*/
|
||||
List<BstIvtStockingivt> getPaperTubePoint(String pointType, String tube, String location, int qty);
|
||||
|
||||
|
||||
/**
|
||||
* 获取备货区中指定条件的货位
|
||||
* @param pointType 类型:0暂存位置,1靠近分切机
|
||||
* @param location 位置:0上区域,1下区域
|
||||
* @param qty 数量
|
||||
* @return /
|
||||
*/
|
||||
List<MdPbPapervehicle> getPaperTubesPoint(String pointType, String location, int qty);
|
||||
|
||||
/**
|
||||
* 获取备货区空位,没有任务的位置
|
||||
* @param location 位置:0上区域,1下区域
|
||||
@@ -92,6 +102,14 @@ public interface IBstIvtStockingivtService extends IService<BstIvtStockingivt> {
|
||||
* @return
|
||||
*/
|
||||
List<BhTubePointDto> getNeedPaperTubePoint(String pointType, String tube, String location);
|
||||
/**
|
||||
* 分组聚合获取需要管芯数组的托盘位置
|
||||
* @param pointType
|
||||
* @param tubes
|
||||
* @param location
|
||||
* @return
|
||||
*/
|
||||
List<BhTubePointDto> getNeedPaperTubesPoint(String pointType, List<String> tubes, String location);
|
||||
|
||||
/**
|
||||
* 获取3个托盘的数据
|
||||
|
||||
@@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @description 添加'@Builder'注解最好不好添加'@NoArgsConstructor'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.b_lms.bst.ivt.stockingivt.service.dao.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.b_lms.bst.ivt.papervehicle.service.dao.MdPbPapervehicle;
|
||||
import org.nl.b_lms.bst.ivt.stockingivt.service.dao.BstIvtStockingivt;
|
||||
import org.nl.b_lms.sch.tasks.slitter.mapper.dto.BhTubeMovePointDto;
|
||||
import org.nl.b_lms.sch.tasks.slitter.mapper.dto.BhTubePointDto;
|
||||
@@ -22,6 +23,9 @@ public interface BstIvtStockingivtMapper extends BaseMapper<BstIvtStockingivt> {
|
||||
* @return /
|
||||
*/
|
||||
List<BstIvtStockingivt> getPaperTubePoint(String pointType, String tube, String location, int qty);
|
||||
|
||||
|
||||
List<MdPbPapervehicle> getPaperTubesPoint(String pointType, String location, int qty);
|
||||
/**
|
||||
* 获取备货区空位,没有任务的位置
|
||||
* @param location 位置:0上区域,1下区域
|
||||
@@ -40,8 +44,17 @@ public interface BstIvtStockingivtMapper extends BaseMapper<BstIvtStockingivt> {
|
||||
* @return /
|
||||
*/
|
||||
List<BhTubePointDto> getNeedPaperTubePoint(String pointType, String tube, String location);
|
||||
/**
|
||||
* 分组聚合获取备货区中数量够用的的货位
|
||||
* @param pointType 类型:0暂存位置,1靠近分切机
|
||||
* @param tubes 纸管号 两个不一定一样的
|
||||
* @param location 位置:0上区域,1下区域
|
||||
* @return /
|
||||
*/
|
||||
List<BhTubePointDto> getNeedPaperTubesPoint(String pointType, List<String> tubes, String location);
|
||||
|
||||
List<BhTubeMovePointDto> getCanMovePointList(String location, String pointType);
|
||||
|
||||
List<BstIvtStockingivt> getMoveTaskPoints();
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,23 @@
|
||||
t.point_code3 = bs.point_code)
|
||||
AND t.task_status <![CDATA[ < ]]> '07')
|
||||
</select>
|
||||
<select id="getPaperTubesPoint"
|
||||
resultType="org.nl.b_lms.bst.ivt.papervehicle.service.dao.MdPbPapervehicle">
|
||||
SELECT mp.*
|
||||
FROM `bst_ivt_stockingivt` bs
|
||||
LEFT JOIN md_pb_papervehicle mp ON mp.vehicle_code = bs.vehicle_code
|
||||
WHERE bs.point_location = #{location}
|
||||
AND bs.point_type = #{pointType}
|
||||
AND bs.ivt_status = '1'
|
||||
AND bs.is_used = '1'
|
||||
AND mp.qty <![CDATA[ > ]]> #{qty}
|
||||
AND 0 = (SELECT COUNT(*)
|
||||
FROM sch_base_task t
|
||||
WHERE (t.point_code1 = bs.point_code OR t.point_code2 = bs.point_code OR
|
||||
t.point_code3 = bs.point_code)
|
||||
AND t.task_status <![CDATA[ < ]]> '07')
|
||||
</select>
|
||||
|
||||
<select id="getEmptyPointNotTask"
|
||||
resultType="org.nl.b_lms.bst.ivt.stockingivt.service.dao.BstIvtStockingivt">
|
||||
SELECT bs.*
|
||||
@@ -68,6 +85,29 @@
|
||||
AND t.task_status <![CDATA[ < ]]> '07')
|
||||
GROUP BY bs.point_code;
|
||||
</select>
|
||||
<select id="getNeedPaperTubesPoint" resultType="org.nl.b_lms.sch.tasks.slitter.mapper.dto.BhTubePointDto">
|
||||
SELECT bs.point_code,
|
||||
MAX(bs.vehicle_code) AS vehicle_code,
|
||||
SUM(mp.qty) AS qty
|
||||
FROM `bst_ivt_stockingivt` bs
|
||||
LEFT JOIN
|
||||
md_pb_papervehicle mp
|
||||
ON mp.vehicle_code = bs.vehicle_code
|
||||
WHERE bs.point_location = #{location}
|
||||
AND bs.point_type = #{pointType}
|
||||
AND bs.ivt_status = '1'
|
||||
AND bs.is_used = '1'
|
||||
AND mp.material_code IN
|
||||
<foreach item="code" collection="tubes" open="(" separator="," close=")">
|
||||
#{code}
|
||||
</foreach>
|
||||
AND 0 = (SELECT COUNT(*)
|
||||
FROM sch_base_task t
|
||||
WHERE (t.point_code1 = bs.point_code OR t.point_code2 = bs.point_code OR
|
||||
t.point_code3 = bs.point_code)
|
||||
AND t.task_status <![CDATA[ < ]]> '07')
|
||||
GROUP BY bs.point_code;
|
||||
</select>
|
||||
<select id="getCanMovePointList" resultType="org.nl.b_lms.sch.tasks.slitter.mapper.dto.BhTubeMovePointDto">
|
||||
SELECT bs.point_code,
|
||||
MAX(bs.vehicle_code) AS vehicle_code,
|
||||
|
||||
@@ -109,6 +109,11 @@ public class BstIvtStockingivtServiceImpl extends ServiceImpl<BstIvtStockingivtM
|
||||
return bstIvtStockingivtMapper.getPaperTubePoint(pointType, tube, location, qty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MdPbPapervehicle> getPaperTubesPoint(String pointType, String location, int qty) {
|
||||
return bstIvtStockingivtMapper.getPaperTubesPoint(pointType, location, qty);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BstIvtStockingivt> getEmptyPointNotTask(String location, String pointType) {
|
||||
return bstIvtStockingivtMapper.getEmptyPointNotTask(location, pointType);
|
||||
@@ -311,6 +316,10 @@ public class BstIvtStockingivtServiceImpl extends ServiceImpl<BstIvtStockingivtM
|
||||
public List<BhTubePointDto> getNeedPaperTubePoint(String pointType, String tube, String location) {
|
||||
return bstIvtStockingivtMapper.getNeedPaperTubePoint(pointType, tube, location);
|
||||
}
|
||||
@Override
|
||||
public List<BhTubePointDto> getNeedPaperTubesPoint(String pointType, List<String> tubes, String location) {
|
||||
return bstIvtStockingivtMapper.getNeedPaperTubesPoint(pointType, tubes, location);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BhTubeMovePointDto> getCanMovePointList(String location, String pointType) {
|
||||
|
||||
@@ -151,7 +151,6 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void doCallShaft(BstIvtShafttubeivt empty, Param isOnlyPulling, Param tzDay, Param paramObj, Param useXn) {
|
||||
log.info(empty.getPoint_code() + "执行中...");
|
||||
@@ -525,12 +524,13 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
}
|
||||
|
||||
/**
|
||||
* 呼叫AGV更换纸管
|
||||
*
|
||||
* <h2>呼叫AGV更换纸管</h2>
|
||||
* <p>默认双管芯尺寸一致
|
||||
* @param needPlans 所需要套轴的分切计划
|
||||
* @param location 位置
|
||||
*/
|
||||
public Boolean toCallAgvMovePaperTube(List<PdmBiSlittingproductionplan> needPlans, String location, BstIvtShafttubeivt empty) {
|
||||
// 1 前置参数获取
|
||||
// 最多两根
|
||||
List<String> tubes = needPlans.stream().map(plan -> {
|
||||
if (SlitterConstant.SLITTER_TYPE_PAPER.equals(plan.getPaper_tube_or_FRP())) {
|
||||
@@ -539,6 +539,7 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
return plan.getFRP_material();
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
// 获取需要的管芯个数的映射值
|
||||
// 判断另一台穿拔轴机的管芯
|
||||
BstIvtShafttubeivt one = bstIvtShafttubeivtService.getOne(new LambdaQueryWrapper<BstIvtShafttubeivt>()
|
||||
.ne(BstIvtShafttubeivt::getPoint_code, empty.getPoint_code())
|
||||
@@ -555,8 +556,9 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
}
|
||||
// 缺省的数量
|
||||
int needQuantity = 0;
|
||||
// 判断当前区域location对应的备货区是否含有相同的纸管 校验了不在搬运中
|
||||
// todo: 要考虑防止所需要的托盘被搬走!双管芯的尺寸不一致
|
||||
// 2 判断搬运托盘AGV任务
|
||||
// 2.1 判断当前区域location对应的备货区是否含有相同的纸管 校验了不在搬运中
|
||||
// 要考虑防止所需要的托盘被搬走! todo: 双管芯的尺寸不一致
|
||||
// type=1(桁架底下的托盘), 关联对象material_code=纸管, qty > 0
|
||||
List<BstIvtStockingivt> useList = stockingivtService.getPaperTubePoint("1", tubes.get(0), location, 0);
|
||||
if (useList.size() > 0) {
|
||||
@@ -571,7 +573,7 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
// 兜底
|
||||
needQuantity = needTemp > 0 ? needTemp : 1;
|
||||
}
|
||||
// 查询是否存在任务正在搬运过来。(路上的是另一台机构的轴)
|
||||
// 2.2 查询是否存在任务正在搬运过来。(路上的是另一台机构的轴)
|
||||
List<MdPbPapervehicle> havePapers = papervehicleService.getInfoByTask();
|
||||
if (CollectionUtil.isNotEmpty(havePapers)) {
|
||||
Map<String, BigDecimal> sumByMaterialCode = havePapers.stream()
|
||||
@@ -596,7 +598,7 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
// 兜底
|
||||
needQuantity = needTemp > 0 ? needTemp : tubes.size();
|
||||
}
|
||||
// 查找type=0的位置(待命的托盘)中是否存在(需要判断的是单独一个托盘) 校验了不在搬运中
|
||||
// 2.3 查找type=0的位置(待命的托盘)中是否存在(需要判断的是单独一个托盘) 校验了不在搬运中
|
||||
List<BhTubePointDto> stockingivtList = stockingivtService.getNeedPaperTubePoint("0", tubes.get(0), location);
|
||||
// 找一个点位: 目的需要的点位
|
||||
// 筛选单独托盘有超过所需数
|
||||
@@ -615,10 +617,26 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
stepErrorInfo.add("备货区找不到[" + tubes.get(0) + "]的纸管信息");
|
||||
return false;
|
||||
}
|
||||
// 找到就创建AGV搬运任务
|
||||
// 3 找到就创建AGV搬运任务
|
||||
// 筛选3个位置中数量最少的搬走, 如果是空位,直接搬运过来
|
||||
List<BhTubeMovePointDto> needMovePointList = stockingivtService.getCanMovePointList(location, "1");
|
||||
// 空位就直接创建搬过来的任务
|
||||
List<BhTubeMovePointDto> needMovePointListAll = stockingivtService.getCanMovePointList(location, "1");
|
||||
// 过滤掉另一台穿拔轴需要的轴的数据
|
||||
List<BhTubeMovePointDto> needMovePointList = new ArrayList<>();
|
||||
if (ObjectUtil.isEmpty(one)) {
|
||||
needMovePointList = needMovePointListAll;
|
||||
} else {
|
||||
List<String> otherTubes = Stream.of(one.getTube_code1(), one.getTube_code2()).filter(ObjectUtil::isNotEmpty).collect(Collectors.toList());
|
||||
needMovePointList = needMovePointListAll.stream().filter(bh -> {
|
||||
String vehicleCode = bh.getVehicle_code();
|
||||
if (otherTubes.size() == 0 || "0".equals(bh.getIvt_status()) || ObjectUtil.isEmpty(vehicleCode)) {
|
||||
return true;
|
||||
}
|
||||
List<MdPbPapervehicle> list = papervehicleService.list(new LambdaQueryWrapper<MdPbPapervehicle>()
|
||||
.eq(MdPbPapervehicle::getVehicle_code, vehicleCode).eq(MdPbPapervehicle::getMaterial_code, otherTubes.get(0)));
|
||||
return list.size() == 0;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
// 3.1 空位就直接创建搬过来的任务
|
||||
BhTubeMovePointDto needMovePoint = needMovePointList.size() > 0 ? needMovePointList.get(0) : null;
|
||||
if (ObjectUtil.isEmpty(needMovePoint) || "0".equals(needMovePoint.getIvt_status())) {
|
||||
// 直接搬过来即可
|
||||
@@ -636,7 +654,7 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
stepErrorInfo.add("备货区正在搬运管芯过来,托盘号:[" + needPoint.getVehicle_code() + "]。");
|
||||
return true;
|
||||
}
|
||||
// 判断是否有单独拉出去的任务,有的话直接拉过来。
|
||||
// 3.2 判断是否有单独拉出去的任务,有的话直接拉过来。
|
||||
List<BstIvtStockingivt> stockingivts = stockingivtService.getMoveTaskPoints();
|
||||
if (CollectionUtil.isNotEmpty(stockingivts)) {
|
||||
BstIvtStockingivt bstIvtStockingivt = stockingivts.get(0);
|
||||
@@ -655,7 +673,7 @@ public class AutoCallAirShaftTask extends Prun {
|
||||
stepErrorInfo.add("备货区正在搬运管芯过来,托盘号:[" + needPoint.getVehicle_code() + "]。");
|
||||
return true;
|
||||
}
|
||||
// 查找一个没有任务的空位
|
||||
// 3.3 查找一个没有任务的空位(创建交换任务)
|
||||
List<BstIvtStockingivt> list = stockingivtService.getEmptyPointNotTask(location, "0");
|
||||
if (list.size() == 0) {
|
||||
noticeService.createNotice("备货区找不到空位置搬运",
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -554,4 +555,22 @@ public class SlitterTaskUtil {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组成映射Map
|
||||
* @param tubes
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Integer> countTubes(List<String> tubes) {
|
||||
if (tubes == null) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
return tubes.stream()
|
||||
.filter(tube -> tube != null)
|
||||
.collect(Collectors.toMap(
|
||||
Function.identity(),
|
||||
value -> 1,
|
||||
Integer::sum
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user