From 8db9059c5f83018550a70c3676de0817294ac9ff Mon Sep 17 00:00:00 2001 From: liyongde <1419499670@qq.com> Date: Sat, 19 Apr 2025 16:38:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A5=97=E8=BD=B4=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E9=80=8F=E6=98=8E=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../slitter/auto/AutoCallAirShaftTask.java | 61 ++++++++++++++++++- .../slitter/controller/SlitterController.java | 52 +++------------- 2 files changed, 69 insertions(+), 44 deletions(-) diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/auto/AutoCallAirShaftTask.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/auto/AutoCallAirShaftTask.java index 35bdef81a..ae83d4072 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/auto/AutoCallAirShaftTask.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/auto/AutoCallAirShaftTask.java @@ -31,6 +31,7 @@ import org.nl.b_lms.sch.tasks.slitter.util.SlitterTaskUtil; import org.nl.common.enums.NoticeTypeEnum; import org.nl.common.utils.TaskUtils; import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.common.utils.RedisUtils; import org.nl.system.service.notice.ISysNoticeService; import org.nl.system.service.param.ISysParamService; import org.nl.system.service.param.dao.Param; @@ -86,10 +87,13 @@ public class AutoCallAirShaftTask { private IschBaseTaskService taskService; @Autowired private ISysParamService paramService; + @Autowired + private RedisUtils redisUtils; public final static String PARAM_CODE_PLAN_AREA = "PARAM_CODE_PLAN_AREA"; public final static String IS_ONLY_PULLING = "IS_ONLY_PULLING"; public final static String TZ_DAY = "TZ_DAY"; + public String stepStr = ""; private static final DateTimeFormatter TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @@ -112,7 +116,12 @@ public class AutoCallAirShaftTask { // 1、获取空的插拔轴位(无任务) List emptyPoints = bstIvtShafttubeivtService.getAllShaftPointsByConditions("2", "0", "0"); - emptyPoints.forEach(empty -> doCallShaft(empty, isOnlyPulling, tzDay, paramObj)); +// emptyPoints.forEach(empty -> doCallShaft(empty, isOnlyPulling, tzDay, paramObj)); + for (BstIvtShafttubeivt empty : emptyPoints) { + stepStr = ""; + doCallShaft(empty, isOnlyPulling, tzDay, paramObj); + redisUtils.set(empty.getPoint_code(), stepStr); + } } @Transactional(rollbackFor = Exception.class) @@ -120,11 +129,13 @@ public class AutoCallAirShaftTask { // 标箔:1,锂电:2 改:大小:4代5代 String specification = empty.getQzz_generation(); String location = empty.getPoint_location(); + stepStr += "1"; if (ObjectUtil.isNotEmpty(isOnlyPulling) && SlitterConstant.SLITTER_YES.equals(isOnlyPulling.getValue())) { // 只做拔轴 makePullShaft(empty, specification); return; } + stepStr += ",2"; Integer integer = Integer.valueOf(ObjectUtil.isEmpty(tzDay.getValue()) ? "0" : tzDay.getValue()); // 2、获取分切计划数据 校验代数 todo: 顺序可能需要考虑 // List planAll = slittingproductionplanService.getAllCutPlan(integer); @@ -153,11 +164,13 @@ public class AutoCallAirShaftTask { // todo: 这里需要注意不要去校验071的任务,不然提前释放货位没意义。 List emptyShaftPoint = bcutpointivtService.getAreaNotTaskPointByStatus("1", "1", location, "0"); + stepStr += ",6"; // 如果满了就只做拔轴 预留一个货位?,防止套轴直接站满 if (emptyShaftPoint.size() <= 1) { log.info("暂存位没有空位!正在检测是否存在半个点位!"); // 校验是否存在半个位置,且有分切计划 // 获取只有一个位置的点位 + stepStr += ",7"; List halfPlacePoint = bcutpointivtService.getAllHalfPlacePoints("1", "1", location); List qzzs = halfPlacePoint.stream() @@ -169,9 +182,11 @@ public class AutoCallAirShaftTask { makePullShaft(empty, specification); return; } + stepStr += ",12"; // 从寻查找分切计划,并放在plans, 没有考虑区域问题, 里面会考虑代数 List tzOKPlans = slittingproductionplanService.getByQzzNos(qzzs, "01"); if (ObjectUtil.isEmpty(tzOKPlans)) { + stepStr += ",13"; log.info("计划找不到"); return; } @@ -190,6 +205,7 @@ public class AutoCallAirShaftTask { } log.info("找到对应的另一半的计划 - {}", plans); } + stepStr += ",14"; // 获取一个分切计划的Dto。如果是6寸,可以直接使用、如果是3寸,需要判断当前位置是否满足 // todo: 需要校验分切设备是在对应的区域中 SlitterPlanDistinctDto planDto = plans.stream() @@ -229,9 +245,11 @@ public class AutoCallAirShaftTask { // 从套轴对接位获取相同气涨轴大小 // update: 不需要(同标箔或者锂电分开) // todo: 需要校验区域0/1 + stepStr += ",15"; List qzzPoint = bcutpointivtService.getPointByTypeAndShaftSize("1", qzzSize, specification); log.info("查找到满足到对应尺寸的点位-{}", qzzPoint); if (qzzPoint.size() == 0) { + stepStr += ",16"; //若套轴暂存位没有相同规格的气胀轴,直接去气胀轴库找即可 // 要先判断AGV任务,才能去呼叫出轴 if (!toCallAgvMovePaperTube(needPlans, location, empty)) { @@ -245,6 +263,7 @@ public class AutoCallAirShaftTask { } // 保存所需要的分切计划数据到点位上(套轴对接位)更新分切计划 saveCutPlanMessage(empty, needPlans, qzzSize); + stepStr += ",97"; return; } // 查找一条没任务的点位 @@ -252,16 +271,20 @@ public class AutoCallAirShaftTask { // 当前纸管的规格信息 String oldQzzNo = ObjectUtil.isNotEmpty(startPoint.getQzz_no1()) ? startPoint.getQzz_no1() : startPoint.getQzz_no2(); + stepStr += ",33"; if (oldQzzNo == null) { log.error("当前气胀轴的编码为空!"); + stepStr += ",96"; return; } String startPointCode = ObjectUtil.isNotEmpty(startPoint.getQzz_no1()) ? startPoint.getTruss_point_code1() : startPoint.getTruss_point_code2(); if (startPointCode == null) { log.error("当前点位的编码为空!"); + stepStr += ",96"; return; } + stepStr += ",34"; // 如果A6寸 B3寸,则需要过滤到精确点位 if (ObjectUtil.isNotEmpty(startPoint.getQzz_no1()) && ObjectUtil.isNotEmpty(startPoint.getQzz_no2())) { // 获取需要的数据 @@ -284,6 +307,7 @@ public class AutoCallAirShaftTask { } } } + stepStr += ",35"; // 创建任务 JSONObject param = new JSONObject(); param.put("point_code1", startPointCode); @@ -306,6 +330,7 @@ public class AutoCallAirShaftTask { // 最多两条 List oldPlans = slittingproductionplanService.getByQzzNo(oldQzzNo); if (oldPlans.size() == 0) { + stepStr += ",96"; log.warn("当前气胀轴编码{},找不到对应的计划", oldQzzNo); return; } @@ -319,13 +344,16 @@ public class AutoCallAirShaftTask { log.error("呼叫AGV失败-穿拔轴{}不进行套轴,跳过!", empty.getPoint_code()); return; } + stepStr += ",36"; trussCallAirShaftTask.createTask(param); + stepStr += ",37"; // 将分切计划is_paper_ok 1(纸管已经准备好) -> 2(已经套轴) needPlans.forEach(p -> { p.setIs_paper_ok("2"); TaskUtils.updateOptMessageBySlitterPlan(p); }); slittingproductionplanService.updateBatchById(needPlans); + stepStr += ",97"; } /** @@ -356,6 +384,7 @@ public class AutoCallAirShaftTask { * @param location 位置 */ public Boolean toCallAgvMovePaperTube(List needPlans, String location, BstIvtShafttubeivt empty) { + stepStr += ",17"; // 最多两根 List tubes = needPlans.stream().map(plan -> { if (SlitterConstant.SLITTER_TYPE_PAPER.equals(plan.getPaper_tube_or_FRP())) { @@ -371,6 +400,7 @@ public class AutoCallAirShaftTask { .eq(BstIvtShafttubeivt::getPoint_type, empty.getPoint_type()) .eq(BstIvtShafttubeivt::getIs_used, "1")); log.info("同位置的另一台穿拔轴机构:{}", one); + stepStr += ",18"; // 另一台所需要的数量 int otherDeviceTubeSize = 0; // 缺省的数量 @@ -388,6 +418,7 @@ public class AutoCallAirShaftTask { } // 说明三个位置中有包含此纸管的数据。 if (sum >= tubes.size() + otherDeviceTubeSize) { + stepStr += ",19"; return true; } // 如果不够,就计算还缺多少个 @@ -395,6 +426,7 @@ public class AutoCallAirShaftTask { // 兜底 needQuantity = needTemp > 0 ? needTemp : 1; } + stepStr += ",20"; // 查找type=0的位置(待命的托盘)中是否存在(需要判断的是单独一个托盘) 校验了不在搬运中 List stockingivtList = stockingivtService.getNeedPaperTubePoint("0", tubes.get(0), location); // 找一个点位: 目的需要的点位 @@ -407,6 +439,7 @@ public class AutoCallAirShaftTask { } } if (needPoint == null) { + stepStr += ",21"; // 不存在则站内通知 noticeService.createNotice("备货区找不到[" + tubes.get(0) + "]的纸管信息", "点位[" + empty.getPoint_name() + "]无法从备货区找到纸管信息", @@ -418,6 +451,7 @@ public class AutoCallAirShaftTask { List needMovePointList = stockingivtService.getCanMovePointList(location, "1"); // 空位就直接创建搬过来的任务 BhTubeMovePointDto needMovePoint = needMovePointList.size() > 0 ? needMovePointList.get(0) : null; + stepStr += ",22"; if (ObjectUtil.isEmpty(needMovePoint) || "0".equals(needMovePoint.getIvt_status())) { // 直接搬过来即可 JSONObject param = new JSONObject(); @@ -431,11 +465,14 @@ public class AutoCallAirShaftTask { .eq(MdPbPapervehicle::getVehicle_code, needPoint.getVehicle_code())); doSavePaperInfos(paperList, param); stockAreaCallTubeTask.createTask(param); + stepStr += ",23"; return true; } + stepStr += ",24"; // 查找一个没有任务的空位 List list = stockingivtService.getEmptyPointNotTask(location, "0"); if (list.size() == 0) { + stepStr += ",25"; noticeService.createNotice("备货区找不到空位置搬运", "点位[" + empty.getPoint_name() + "]无法从备货区找到空位", NoticeTypeEnum.EXCEPTION.getCode()); @@ -452,6 +489,7 @@ public class AutoCallAirShaftTask { param.put("task_type", SlitterEnum.TASK_TYPE.code("备货区送载具")); param.put("product_area", SlitterConstant.SLITTER_TASK_AREA); stockAreaSendVehicleTask.createTask(param); + stepStr += ",26"; return true; } @@ -464,14 +502,18 @@ public class AutoCallAirShaftTask { * @param empty 套拔轴点位 */ private Boolean toAcsOutShaft(String qzzSize, String location, BstIvtShafttubeivt empty) { + stepStr += ",27"; // 需要区分上下 List shafttubeivts = bstIvtShafttubeivtService.getByQzzSize(qzzSize ,empty.getPoint_code(), location); + stepStr += ",28"; if (shafttubeivts.size() == 0) { log.error("气胀轴库找不到[" + qzzSize + "]规格的气涨轴位"); + stepStr += ",98"; return false; } // 气涨轴库 BstIvtShafttubeivt shafttubeivt = shafttubeivts.get(0); + stepStr += ",29"; // 判断气胀轴是否有轴 JSONArray device_rows = new JSONArray(); JSONObject device_obj = new JSONObject(); @@ -481,6 +523,7 @@ public class AutoCallAirShaftTask { device_obj.put("product_area", "B1"); JSONObject pointStatus = wmsToAcsService.getPointStatus(device_rows); if (ObjectUtil.isEmpty(pointStatus) || ObjectUtil.isEmpty(pointStatus.getJSONArray("data"))) { + stepStr += ",98"; log.error("获取气胀轴库信息失败"); return false; } @@ -498,8 +541,10 @@ public class AutoCallAirShaftTask { log.warn("未找到气胀轴密集库气涨轴规格「" + qzzSize + "」的暂存位"); judgment2 = false; } + stepStr += ",30"; if (!judgment1 && !judgment2) { log.warn("没有气胀轴,不给ACS写出轴信息"); + stepStr += ",98"; return false; } // 判断气胀轴密集库是否有数据 @@ -511,6 +556,7 @@ public class AutoCallAirShaftTask { acsQzz.put("value", "1"); acsQzz.put("product_area", SlitterConstant.SLITTER_TASK_AREA); acsParam.add(acsQzz); + stepStr += ",31"; log.info("开始给ACS写信号出气胀轴 - {}", acsQzz); JSONObject action = wmsToAcsService.action(acsParam); log.info("下发给ACS写信号出气涨轴返回参数:{}", action); @@ -549,6 +595,7 @@ public class AutoCallAirShaftTask { * @param qzzSize 气涨轴尺寸 */ private void saveCutPlanMessage(BstIvtShafttubeivt empty, List needPlans, String qzzSize) { + stepStr += ",32"; log.info("正在保存套轴信息 - {} , 尺寸 - {} 到点位 - {}", needPlans, qzzSize, empty); empty.setHave_qzz(SlitterConstant.SLITTER_YES); empty.setQzz_size(qzzSize); @@ -595,12 +642,16 @@ public class AutoCallAirShaftTask { * @param specification 代数(4、5) */ private void makePullShaft(BstIvtShafttubeivt empty, String specification) { + stepStr += ",3"; + stepStr += ",8"; log.info("不需要套轴,只做拔轴!"); //查询套轴缓存位哦:point_type=1 List notTaskPoints = bcutpointivtService.getAreaNotTaskPointByLocationAreaAndStatus(empty.getPoint_location()); if (notTaskPoints.size() == 0) { + stepStr += ",99"; return; } + stepStr += ",9"; // 筛选一个满足的位置:3寸:看代数4/5;6寸直接 //判断气胀轴代 BstIvtCutpointivt cutpointivt = notTaskPoints.stream() @@ -609,8 +660,10 @@ public class AutoCallAirShaftTask { .findFirst() .orElse(null); if (cutpointivt == null) { + stepStr += ",99"; return; } + stepStr += ",10"; String pointCode1 = ObjectUtil.isNotEmpty(cutpointivt.getQzz_no1()) ? cutpointivt.getTruss_point_code1() : cutpointivt.getTruss_point_code2(); String qzzNo = ObjectUtil.isNotEmpty(cutpointivt.getQzz_no1()) ? cutpointivt.getQzz_no1() : cutpointivt.getQzz_no2(); // 获取对应的分切计划 @@ -618,6 +671,7 @@ public class AutoCallAirShaftTask { .eq(PdmBiSlittingproductionplan::getQzzno, qzzNo) .eq(PdmBiSlittingproductionplan::getIs_delete, "0")); if (list.size() == 0) { + stepStr += ",99"; log.warn("气涨轴[{}]对应的分切计划不存在!", qzzNo); throw new BadRequestException("气涨轴[" + qzzNo + "]对应的分切计划不存在!"); } @@ -642,6 +696,7 @@ public class AutoCallAirShaftTask { param.put("is_bushing", SlitterConstant.SLITTER_NO); param.put("is_pulling", SlitterConstant.SLITTER_YES); trussCallAirShaftTask.createTask(param); + stepStr += ",11"; } /** @@ -657,6 +712,7 @@ public class AutoCallAirShaftTask { return true; } log.info("存在任务,不允许套轴{}", dto); + stepStr += ",5"; return false; } @@ -684,11 +740,13 @@ public class AutoCallAirShaftTask { if ("1".equals(byContainerName.getOrder_type())) { // 判断母卷 if (byContainerName.getParent_container_name().equals(dto.getParent_container_name())) { + stepStr += ",4"; return false; } } else { // 判断改切 if (byContainerName.getRestruct_container_name().equals(dto.getParent_container_name())) { + stepStr += ",4"; return false; } } @@ -701,6 +759,7 @@ public class AutoCallAirShaftTask { } } log.info("检查有同母卷不允许套轴:{}", dto); + stepStr += ",4"; // 有就返回true return false; } diff --git a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/controller/SlitterController.java b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/controller/SlitterController.java index 79388ff40..635b7f2b1 100644 --- a/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/controller/SlitterController.java +++ b/lms/nladmin-system/src/main/java/org/nl/b_lms/sch/tasks/slitter/controller/SlitterController.java @@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j; import org.nl.b_lms.pdm.bi.slittingproductionplan.service.dao.PdmBiSlittingproductionplan; import org.nl.b_lms.sch.tasks.slitter.service.SlitterService; import org.nl.common.utils.TaskUtils; +import org.nl.modules.common.utils.RedisUtils; import org.nl.modules.logging.annotation.Log; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; @@ -32,53 +33,18 @@ import java.util.stream.Stream; public class SlitterController { @Autowired private SlitterService slitterService; - - @PostMapping("/test1") - @Log("1111") - public ResponseEntity create(@RequestBody JSONObject entity){ - if ("1".equals(entity.getString("type"))) { - return new ResponseEntity<>(slitterService.acsRequestShaftLoadTube(entity), HttpStatus.OK); - } else if ("2".equals(entity.getString("type"))) { - return new ResponseEntity<>(slitterService.acsFinishLoadShaft(entity), HttpStatus.OK); - } else if ("3".equals(entity.getString("type"))) { - return new ResponseEntity<>(slitterService.acsFinishShaftPluckTube(entity), HttpStatus.OK); - } else if ("5".equals(entity.getString("type"))) { - return new ResponseEntity<>(slitterService.acsSendShaftToCache(entity), HttpStatus.OK); - } - return new ResponseEntity<>(slitterService.acsRequestShaftLoadTube(entity), HttpStatus.OK); - } - @PostMapping("/test2") - @Log("1111") - public ResponseEntity create2(@RequestBody JSONObject entity){ - return new ResponseEntity<>(slitterService.acsFinishLoadShaft(entity), HttpStatus.OK); - } - @PostMapping("/test3") - @Log("1111") - public ResponseEntity create3(@RequestBody JSONObject entity){ - List collect = Stream.of("B1182312040201A1").collect(Collectors.toList()); - entity.put("container", collect); - return new ResponseEntity<>(slitterService.mesSlittingMachineSendMaterial(entity), HttpStatus.CREATED); - } - @PostMapping("/test4") - @Log("1111") - public ResponseEntity create4(@RequestBody JSONObject entity){ - return new ResponseEntity<>(slitterService.acsFinishShaftPluckTube(entity), HttpStatus.CREATED); - } - @PostMapping("/test5") - @Log("1111") - @SaIgnore - public ResponseEntity create5(@RequestBody JSONObject entity){ - return new ResponseEntity<>(slitterService.mesGetWeighingOfWasteFoil(entity), HttpStatus.CREATED); - } - @PostMapping("/test6") - @Log("1111") - public ResponseEntity create6(@RequestBody JSONObject entity){ - return new ResponseEntity<>(slitterService.mesGetFinishWeighingOfWasteFoil(entity), HttpStatus.CREATED); - } + @Autowired + private RedisUtils redisUtils; @PostMapping("/calPaperNum") @Log("扣除纸管库存") @SaIgnore public ResponseEntity calPaperNum(@RequestBody JSONObject entity){ return new ResponseEntity<>(slitterService.acsToReduceTube(entity), HttpStatus.CREATED); } + @PostMapping("/tzInfo") + @Log("套轴BCP透明链路") + @SaIgnore + public ResponseEntity tzInfo(@RequestBody JSONObject entity){ + return new ResponseEntity<>(redisUtils.get(entity.getString("device_code")), HttpStatus.CREATED); + } }