From e0244835040d0d0e6248f758c0911c633c2f8c1f Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 11 Mar 2025 20:26:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug=EF=BC=9A45420=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=89=B9=E9=87=8F=E5=B9=B6=E5=8F=91=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E5=8D=A1=E6=8E=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../serviceimpl/busi/MesNcProcessingService.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java index 97ffb2f..06afe66 100644 --- a/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java +++ b/modules/i3plus-ext-mes-pcn-apiservice/src/main/java/cn/estsh/i3plus/ext/mes/pcn/apiservice/serviceimpl/busi/MesNcProcessingService.java @@ -206,13 +206,14 @@ public class MesNcProcessingService implements IMesNcProcessingService { if(!Objects.isNull(model.getPart())){ model.setPart(mesPartService.getMesPartSapByPartNo(model.getPart().getPartNo(), org)); } - if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { - Integer type = model.getType(); - MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getSn(); - RLock rLock = (RLock) redisMesPcn.getLock(redisKey); - try { + final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getPartInspection().getId(); + RLock rLock = (RLock) redisMesPcn.getLock(redisKey); + try { + if (model.getPartInspection().getSourceType() == MesExtEnumUtil.PART_INSPECTION_SOURCE_TYPE.SINGLE.getValue()) { + Integer type = model.getType(); + MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); + //使用tryLock拿不到锁直接返回 //rlock的leaseTime为-1,会每隔WatchdogTimeout秒去续约 if (!rLock.tryLock()){ @@ -221,17 +222,16 @@ public class MesNcProcessingService implements IMesNcProcessingService { //保存数据 saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder); - } finally { - if (rLock.isHeldByCurrentThread()) { - rLock.unlock(); - } + } else { + Integer type = model.getType(); + MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); + //保存数据 + saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder); + } + } finally { + if (rLock.isHeldByCurrentThread()) { + rLock.unlock(); } - } else { - - Integer type = model.getType(); - MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson(); - //保存数据 - saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(), isOrder); } }