feat: 异常处理逻辑

This commit is contained in:
2025-09-04 17:31:53 +08:00
parent 7dc6402b25
commit dde6888074
10 changed files with 321 additions and 45 deletions

View File

@@ -54,6 +54,15 @@ public interface IBstIvtCutpointivtService extends IService<BstIvtCutpointivt> {
* @return /
*/
List<BstIvtCutpointivt> getAreaNotTaskPointByStatus(String type, String pointStatus, String area, String sort);
/**
*
* @param type 点位类型1套轴对接位2分切缓存位3分切对接位4套轴异常位
* @param area 区域0上1下
* @return
*/
List<String> getCanUseMinPointByShelf(String type, String area);
List<String> getCanUseMinPointByShelfSpecial(String type, String area);
/**
* 获取类型状态,没任务的点位,不校验取货完成的任务
* @param type 点位类型1套轴对接位2分切缓存位3分切对接位4套轴异常位

View File

@@ -32,4 +32,7 @@ public interface BstIvtCutpointivtMapper extends BaseMapper<BstIvtCutpointivt> {
List<BstIvtCutpointivt> getNBJCanUsePoint(String type, String pointStatus, String area, String sort);
List<BstIvtCutpointivt> getNBJAreaNotTaskPointByStatus(String type, String pointStatus, String area, String sort);
List<String> getCanUseMinPointByShelf(String type, String area);
List<String> getCanUseMinPointByShelfSpecial(String type, String area);
}

View File

@@ -241,4 +241,76 @@
AND t.is_delete = '0'
AND (t.point_code1 = bic.truss_point_code2 oR t.point_code2 = bic.truss_point_code2));
</select>
<select id="getCanUseMinPointByShelf" resultType="java.lang.String">
SELECT bic.truss_point_code1
FROM bst_ivt_cutpointivt bic
WHERE bic.point_type = #{type}
AND bic.is_used = '1'
AND bic.point_location = #{area}
AND IFNULL(bic.qzz_no1, '') = ''
AND 0 = (SELECT COUNT(*)
FROM sch_base_task t
WHERE t.task_status <![CDATA[ <= ]]> '071'
AND t.task_status <![CDATA[ <> ]]> '07'
AND t.is_delete = '0'
AND (t.point_code1 = bic.point_code OR t.point_code2 = bic.point_code
OR t.point_code1 = bic.truss_point_code1 OR t.point_code2 = bic.truss_point_code1))
UNION
SELECT bic.truss_point_code2
FROM bst_ivt_cutpointivt bic
WHERE bic.point_type = #{type}
AND bic.is_used = '1'
AND bic.point_location = #{area}
AND IFNULL(bic.qzz_no2, '') = ''
AND 0 = (SELECT COUNT(*)
FROM sch_base_task t
WHERE t.task_status <![CDATA[ <= ]]> '071'
AND t.task_status <![CDATA[ <> ]]> '07'
AND t.is_delete = '0'
AND (t.point_code1 = bic.point_code OR t.point_code2 = bic.point_code
OR t.point_code1 = bic.truss_point_code2 OR t.point_code2 = bic.truss_point_code2))
</select>
<select id="getCanUseMinPointByShelfSpecial" resultType="java.lang.String">
SELECT truss_point_code
FROM (SELECT bic.truss_point_code1 AS truss_point_code,
bic.point_status
FROM bst_ivt_cutpointivt bic
WHERE bic.point_type = #{type}
AND bic.is_used = '1'
AND bic.point_location = #{area}
AND bic.point_status IN ('4', '1')
AND IFNULL(bic.qzz_no1, '') = ''
AND 0 = (SELECT COUNT(*)
FROM sch_base_task t
WHERE t.task_status <![CDATA[ <= ]]> '071'
AND t.task_status <![CDATA[ <> ]]> '07'
AND t.is_delete = '0'
AND (
t.point_code1 = bic.point_code
OR t.point_code2 = bic.point_code
OR t.point_code1 = bic.truss_point_code1
OR t.point_code2 = bic.truss_point_code1
))
UNION ALL
SELECT bic.truss_point_code2 AS truss_point_code,
bic.point_status
FROM bst_ivt_cutpointivt bic
WHERE bic.point_type = #{type}
AND bic.is_used = '1'
AND bic.point_location = #{area}
AND bic.point_status IN ('4', '1')
AND IFNULL(bic.qzz_no2, '') = ''
AND 0 = (SELECT COUNT(*)
FROM sch_base_task t
WHERE t.task_status <![CDATA[ <= ]]> '071'
AND t.task_status <![CDATA[ <> ]]> '07'
AND t.is_delete = '0'
AND (
t.point_code1 = bic.point_code
OR t.point_code2 = bic.point_code
OR t.point_code1 = bic.truss_point_code2
OR t.point_code2 = bic.truss_point_code2
))) AS combined
ORDER BY point_status DESC, truss_point_code;
</select>
</mapper>

View File

@@ -96,6 +96,15 @@ public class BstIvtCutpointivtServiceImpl extends ServiceImpl<BstIvtCutpointivtM
return bstIvtCutpointivtMapper.getAreaNotTaskPointByStatus(type, pointStatus, area, sort);
}
@Override
public List<String> getCanUseMinPointByShelf(String type, String area) {
return bstIvtCutpointivtMapper.getCanUseMinPointByShelf(type, area);
}
@Override
public List<String> getCanUseMinPointByShelfSpecial(String type, String area) {
return bstIvtCutpointivtMapper.getCanUseMinPointByShelfSpecial(type, area);
}
@Override
public List<BstIvtCutpointivt> getAreaNotTaskPointByStatusNotCheckPickUpCompleted(String type, String pointStatus, String area, String sort) {
return bstIvtCutpointivtMapper.getAreaNotTaskPointByStatusNotCheckPickUpCompleted(type, pointStatus, area, sort);

View File

@@ -87,20 +87,37 @@ public class SendNBJExceptionPointTask extends AbstractAcsTask {
// update: 在acs请求取货完成就已经清空点位信息
String endPoint = task.getPoint_code2();
BstIvtCutpointivt endPointObj = bcutpointivtService.getPointByTrussOrAgvCode(endPoint, false);
TaskUtils.pointMaintenanceInventory(task, endPointObj, "2");
// 设置有异常
TaskUtils.pointMaintenanceInventory(task, endPointObj, "4");
// (桁架任务的时候)起点要清空
if (task.getPoint_code2().equals(endPointObj.getTruss_point_code1())
|| task.getPoint_code2().equals(endPointObj.getTruss_point_code2())) {
BstIvtShafttubeivt shafttubeivt = shaftivtService.getByPointCode(task.getPoint_code1(), false);
shafttubeivt.setQzz_size("");
shafttubeivt.setHave_qzz("0");
shafttubeivt.setTube_code1("");
shafttubeivt.setTube_code2("");
shafttubeivt.setTube_name1("");
shafttubeivt.setTube_name2("");
shafttubeivt.setContainer_name1("");
shafttubeivt.setContainer_name2("");
shaftivtService.updateById(shafttubeivt);
if (ObjectUtil.isNotEmpty(shafttubeivt)) {
shafttubeivt.setQzz_size("");
shafttubeivt.setHave_qzz("0");
shafttubeivt.setTube_code1("");
shafttubeivt.setTube_code2("");
shafttubeivt.setTube_name1("");
shafttubeivt.setTube_name2("");
shafttubeivt.setContainer_name1("");
shafttubeivt.setContainer_name2("");
shafttubeivt.setUpdate_time(DateUtil.now());
shaftivtService.updateById(shafttubeivt);
} else {
BstIvtCutpointivt trussCode = bcutpointivtService.getPintByTrussCode(task.getPoint_code1(), false);
if (trussCode.getTruss_point_code1().equals(task.getPoint_code1())) {
trussCode.setQzz_no1("");
} else {
trussCode.setQzz_no2("");
}
if (ObjectUtil.isEmpty(trussCode.getQzz_no1()) && ObjectUtil.isEmpty(trussCode.getQzz_no2())) {
trussCode.setPoint_status("1");
trussCode.setRemark("");
}
trussCode.setUpdate_time(DateUtil.now());
bcutpointivtService.updateById(trussCode);
}
}
bcutpointivtService.updateById(endPointObj);
}

View File

@@ -0,0 +1,84 @@
package org.nl.b_lms.sch.tasks.slitter.auto;
import com.alibaba.fastjson.JSONObject;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.nl.b_lms.bst.ivt.cutpointivt.service.IBstIvtCutpointivtService;
import org.nl.b_lms.bst.ivt.cutpointivt.service.dao.BstIvtCutpointivt;
import org.nl.b_lms.pdm.bi.slittingproductionplan.service.IPdmBiSlittingproductionplanService;
import org.nl.b_lms.sch.point.service.IstIvtCutpointivtService;
import org.nl.b_lms.sch.tasks.slitter.SendNBJExceptionPointTask;
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterConstant;
import org.nl.b_lms.sch.tasks.slitter.constant.SlitterEnum;
import org.nl.b_lms.sch.tasks.slitter.mapper.SlitterMapper;
import org.nl.modules.common.exception.BadRequestException;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
* 自动创建异常任务
*
* @Author: lyd
* @Date: 2025/9/4
*/
@Slf4j
@Component
public class AutoExceptionTrussTask {
@Autowired
private IBstIvtCutpointivtService bcutpointivtService;
@Autowired
private IstIvtCutpointivtService cutpointivtService;
@Autowired
private IPdmBiSlittingproductionplanService slittingproductionplanService;
@Autowired
private SlitterMapper slitterMapper;
@Autowired
private SendNBJExceptionPointTask sendNBJExceptionPointTask;
@Autowired
private RedissonClient redissonClient;
@SneakyThrows
public void run() {
log.info("正在执行异常轴补偿机制...");
RLock lock = redissonClient.getLock("doAcsFinishLoadShaft");
boolean tryLock = lock.tryLock(10, TimeUnit.SECONDS);
try {
if (tryLock) {
// 获取能够拉走的点位
List<String> needMoves = slitterMapper.getMoveTzdjwExceptionPoint();
for (String needMove : needMoves) {
List<String> exceptionPointCodes = bcutpointivtService.getCanUseMinPointByShelf("4", "0");
if (exceptionPointCodes.size() == 0) {
log.info("没有可用的异常处理位...");
return;
}
BstIvtCutpointivt cutpointivt = bcutpointivtService.getPintByTrussCode(needMove, false);
// 创建任务
JSONObject exParam = new JSONObject();
exParam.put("point_code1", needMove);
exParam.put("point_code2", exceptionPointCodes.get(0));
if (needMove.endsWith("A")) {
exParam.put("vehicle_code1", cutpointivt.getQzz_no1());
} else {
exParam.put("vehicle_code2", cutpointivt.getQzz_no2());
}
exParam.put("task_type", SlitterEnum.TASK_TYPE.code("套轴异常处理桁架任务"));
exParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
exParam.put("acs_task_type", "6");
sendNBJExceptionPointTask.createTask(exParam);
}
} else {
log.info("系统繁忙,稍后在试...");
}
} finally {
if (tryLock) {
lock.unlock();
}
}
}
}

View File

@@ -79,28 +79,34 @@ public class AutoSendAirShaftAgvTask {
.eq(PdmBiSlittingproductionplan::getIs_delete, SlitterConstant.SLITTER_NO));
if (plans.size() == 0) {
log.info("找不到状态01的分切计划送到异常处理位置");
// hint: 搬运到异常处理位不在使用AGV用新的定时器执行此处只是改点位状态
// 不能抛异常需要通过通知的形式并且创建agv搬到异常处理位4
// 判断套轴暂存位异常点位是否含有任务
List<BstIvtCutpointivt> exceptionPoints = bcutpointivtService.getAreaNotTaskPointByStatus("4", "1", "0", "0");
if (exceptionPoints.size() > 0) {
BstIvtCutpointivt exceptionPoint = exceptionPoints.get(0);
// 需要枷锁
JSONObject exParam = new JSONObject();
exParam.put("point_code1", cutPoint.getPoint_code());
exParam.put("point_code2", exceptionPoint.getPoint_code());
exParam.put("vehicle_code1", cutPoint.getQzz_no1());
exParam.put("vehicle_code2", cutPoint.getQzz_no2());
exParam.put("task_type", SlitterEnum.TASK_TYPE.code("套轴异常处理AGV任务"));
exParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
sendNBJExceptionPointTask.createTask(exParam);
} else {
log.info("异常处理位无空位!");
// 点位禁用
cutPoint.setRemark("计划状态已被改变!");
cutPoint.setIs_used("0");
cutPoint.setUpdate_time(DateUtil.now());
bcutpointivtService.updateById(cutPoint);
}
// List<BstIvtCutpointivt> exceptionPoints = bcutpointivtService.getAreaNotTaskPointByStatus("4", "1", "0", "0");
// if (exceptionPoints.size() > 0) {
// BstIvtCutpointivt exceptionPoint = exceptionPoints.get(0);
// // 需要枷锁
// JSONObject exParam = new JSONObject();
// exParam.put("point_code1", cutPoint.getPoint_code());
// exParam.put("point_code2", exceptionPoint.getPoint_code());
// exParam.put("vehicle_code1", cutPoint.getQzz_no1());
// exParam.put("vehicle_code2", cutPoint.getQzz_no2());
// exParam.put("task_type", SlitterEnum.TASK_TYPE.code("套轴异常处理AGV任务"));
// exParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
// sendNBJExceptionPointTask.createTask(exParam);
// } else {
// log.info("异常处理位无空位!");
// // 点位禁用
// cutPoint.setRemark("计划状态已被改变!");
// cutPoint.setIs_used("0");
// cutPoint.setUpdate_time(DateUtil.now());
// bcutpointivtService.updateById(cutPoint);
// }
// 点位禁用
cutPoint.setRemark("计划状态已被改变, 等待搬运到异常处理位...");
cutPoint.setPoint_status("4");
cutPoint.setUpdate_time(DateUtil.now());
bcutpointivtService.updateById(cutPoint);
continue;
}
// 获取任意一条

View File

@@ -66,4 +66,10 @@ public interface SlitterMapper {
List<CallPlanViewVO> showManualViewNoXn();
List<CallPlanViewVO> showManualCall(Integer days);
/**
* 套轴对接位异常位搬运到异常处理架子
* @return
*/
List<String> getMoveTzdjwExceptionPoint();
}

View File

@@ -282,4 +282,52 @@
manufacture_sort desc,
start_time
</select>
<select id="getMoveTzdjwExceptionPoint" resultType="java.lang.String">
SELECT truss_point_code
FROM (SELECT bic.truss_point_code1 AS truss_point_code,
bic.point_status,
IF
(LENGTH(bic.qzz_no1) = 0 || LENGTH(bic.qzz_no2) = 0, 0, 1) AS p
FROM bst_ivt_cutpointivt bic
WHERE bic.point_type = '1'
AND bic.is_used = '1'
AND bic.point_location = '0'
AND bic.point_status = '4'
AND IFNULL(bic.qzz_no1, '') <![CDATA[ <> ]]> ''
AND 0 = (SELECT COUNT(*)
FROM sch_base_task t
WHERE t.task_status <![CDATA[ <= ]]> '071'
AND t.task_status <![CDATA[ <> ]]> '07'
AND t.is_delete = '0'
AND (
t.point_code1 = bic.point_code
OR t.point_code2 = bic.point_code
OR t.point_code1 = bic.truss_point_code1
OR t.point_code2 = bic.truss_point_code1
))
UNION ALL
SELECT bic.truss_point_code2 AS truss_point_code,
bic.point_status,
IF
(LENGTH(bic.qzz_no1) = 0 || LENGTH(bic.qzz_no2) = 0, 0, 1) AS p
FROM bst_ivt_cutpointivt bic
WHERE bic.point_type = '1'
AND bic.is_used = '1'
AND bic.point_location = '0'
AND bic.point_status = '4'
AND IFNULL(bic.qzz_no2, '') <![CDATA[ <> ]]> ''
AND 0 = (SELECT COUNT(*)
FROM sch_base_task t
WHERE t.task_status <![CDATA[ <= ]]> '071'
AND t.task_status <![CDATA[ <> ]]> '07'
AND t.is_delete = '0'
AND (
t.point_code1 = bic.point_code
OR t.point_code2 = bic.point_code
OR t.point_code1 = bic.truss_point_code2
OR t.point_code2 = bic.truss_point_code2
))) AS combined
ORDER BY p,
truss_point_code;
</select>
</mapper>

View File

@@ -349,14 +349,14 @@ public class SlitterServiceImpl implements SlitterService {
if (plans.size() == 0) {
log.error("找不到[{}]对应的分切计划,分切计划可能被删除或者拼接!", collect);
// 移动到异常处理位随机一个点位在送到B2对面的位置
List<BstIvtCutpointivt> exceptionPoints = bcutpointivtService.getAreaNotTaskPointByStatus("1", "1", "0", "0");
if (exceptionPoints.size() > 0) {
BstIvtCutpointivt exceptionPoint = exceptionPoints.get(0);
// List<BstIvtCutpointivt> exceptionPoints = bcutpointivtService.getAreaNotTaskPointByStatus("4", "1", "0", "0");
List<String> exceptionPointCodes = bcutpointivtService.getCanUseMinPointByShelf("4", "0");
if (exceptionPointCodes.size() > 0) {
String exceptionPoint = exceptionPointCodes.get(0);
JSONObject exParam = new JSONObject();
exParam.put("point_code1", startPoint.getPoint_code());
exParam.put("point_code2", ObjectUtil.isEmpty(exceptionPoint.getQzz_no1())
? exceptionPoint.getTruss_point_code1() : exceptionPoint.getTruss_point_code2());
if (ObjectUtil.isEmpty(exceptionPoint.getQzz_no1())) {
exParam.put("point_code2", exceptionPoint);
if (exceptionPoint.endsWith("A")) {
exParam.put("vehicle_code1", collect);
} else {
exParam.put("vehicle_code2", collect);
@@ -369,24 +369,46 @@ public class SlitterServiceImpl implements SlitterService {
res.put("status", HttpStatus.HTTP_OK);
res.put("message", "创建送至异常处理位!");
return res;
} else {
stepTipLogs.add("套轴完成->[" + collect + "]对应的分切计划状态已更改,无暂存位置,创建任务失败!");
redisUtils.set("ERROR" + deviceCode, stepTipLogs);
}
// 找套轴对接位(任取一个空点)
exceptionPointCodes = bcutpointivtService.getCanUseMinPointByShelfSpecial("1", "0");
if (exceptionPointCodes.size() > 0) {
String exceptionPoint = exceptionPointCodes.get(0);
JSONObject exParam = new JSONObject();
exParam.put("point_code1", startPoint.getPoint_code());
exParam.put("point_code2", "-");
exParam.put("vehicle_code1", collect);
exParam.put("point_code2", exceptionPoint);
if (exceptionPoint.endsWith("A")) {
exParam.put("vehicle_code1", collect);
} else {
exParam.put("vehicle_code2", collect);
}
exParam.put("task_type", SlitterEnum.TASK_TYPE.code("套轴异常处理桁架任务"));
exParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
exParam.put("task_status", TaskStatusEnum.SURE_START.getCode());
exParam.put("acs_task_type", "6");
exParam.put("containers", collect);
sendNBJExceptionPointTask.createTask(exParam);
res.put("status", HttpStatus.HTTP_OK);
res.put("message", "请求成功");
res.put("msg", msg);
res.put("message", "创建送至对接位等待异常处理位!");
return res;
}
// 半条任务等待补齐
stepTipLogs.add("套轴完成->[" + collect + "]对应的分切计划状态已更改,无暂存位置,创建任务失败!");
redisUtils.set("ERROR" + deviceCode, stepTipLogs);
JSONObject exParam = new JSONObject();
exParam.put("point_code1", startPoint.getPoint_code());
exParam.put("point_code2", "-");
exParam.put("vehicle_code1", collect);
exParam.put("task_type", SlitterEnum.TASK_TYPE.code("套轴异常处理桁架任务"));
exParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
exParam.put("task_status", TaskStatusEnum.SURE_START.getCode());
exParam.put("acs_task_type", "6");
exParam.put("containers", collect);
sendNBJExceptionPointTask.createTask(exParam);
res.put("status", HttpStatus.HTTP_OK);
res.put("message", "请求成功");
res.put("msg", msg);
return res;
}
// 分切计划设置纸卷重量
for (PdmBiSlittingproductionplan plan : plans) {
@@ -1265,7 +1287,7 @@ public class SlitterServiceImpl implements SlitterService {
taskParam.put("product_area", SlitterConstant.SLITTER_TASK_AREA);
slitterDownAgvTask.createTask(taskParam);
} else {
throw new BadRequestException("系统繁忙,稍后在试!!");
throw new BadRequestException("内包间正在分配点位,请重试!");
}
} finally {
if (lock.isLocked() && lock.isHeldByCurrentThread()) {