修复bug:45420,操作的NC处理,2个人同时操作,产生2笔move数据。

uat-temp-nht-2503100000-45420
jason 2 months ago
parent 64380a5f5a
commit a5df54bc98

@ -28,13 +28,16 @@ import cn.estsh.i3plus.pojo.mes.model.GenSerialNoModel;
import cn.estsh.i3plus.pojo.mes.repository.*;
import cn.estsh.i3plus.pojo.mes.util.MesExtEnumUtil;
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
import cn.estsh.impp.framework.boot.util.ImppRedis;
import cn.estsh.impp.framework.boot.util.ResultBean;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -127,6 +130,9 @@ public class MesNcProcessingService implements IMesNcProcessingService {
@Autowired
private IMesMoveRuleRepository mesMoveRuleRepository;
@Resource(name = "redisMesPcn")
private ImppRedis redisMesPcn;
@Override
public ListPager<MesPartInspection> queryPartInspectionByPager(MesPartInspection partInspection, Pager pager) {
@ -204,8 +210,22 @@ public class MesNcProcessingService implements IMesNcProcessingService {
Integer type = model.getType();
MesDefectType person = StringUtil.isEmpty(model.getPerson())?new MesDefectType():model.getPerson();
//保存数据
saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder);
final String redisKey = MesPcnExtConstWords.SAP_TRANS_JOB_LOCK_TAG + model.getSn();
RLock rLock = (RLock) redisMesPcn.getLock(redisKey);
try {
//使用tryLock拿不到锁直接返回
//rlock的leaseTime为-1会每隔WatchdogTimeout秒去续约
if (!rLock.tryLock()){
throw new ImppBusiException(String.format("【%s】此条码正在处理中不能并发执行", model.getSn()));
}
//保存数据
saveDate(model, model.getPart(), type, person, org,model.getInventoryLocationCode(),isOrder);
} finally {
if (rLock.isHeldByCurrentThread()) {
rLock.unlock();
}
}
} else {
Integer type = model.getType();

@ -806,4 +806,5 @@ public class MesPcnExtConstWords {
//螺钉包保存生产版本标记
public static final String SAVE_PRODUCT_VERSION_FLAG = "ZFBT";
public static final String SAP_TRANS_JOB_LOCK_TAG = "MES:JOB:MES_NC_PROCESSING_LOCK_TAG:";
}

Loading…
Cancel
Save