From 90a1495b9d765c9e1d48f689dbcf977cbdb2768e Mon Sep 17 00:00:00 2001 From: dengzedong <dengzedong@email> Date: 星期二, 31 十二月 2024 17:23:13 +0800 Subject: [PATCH] 模型结果修改为存在唯一索引则修改,不存在插入。避免死锁问题 --- iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemStatusServiceImpl.java | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemStatusServiceImpl.java b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemStatusServiceImpl.java index f5f5b04..9ab41e0 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemStatusServiceImpl.java +++ b/iailab-module-model/iailab-module-model-biz/src/main/java/com/iailab/module/model/mcs/pre/service/impl/MmItemStatusServiceImpl.java @@ -23,19 +23,20 @@ @Resource public MmItemStatusDao mmItemStatusDao; - public void recordStatus(String itemId, ItemRunStatusEnum status, Long duration) { + public void recordStatus(String itemId, ItemRunStatusEnum status, Long duration, Date runTime) { QueryWrapper<MmItemStatusEntity> queryWrapper = new QueryWrapper<>(); queryWrapper.eq("item_id", itemId); MmItemStatusEntity entity = mmItemStatusDao.selectOne(queryWrapper); if (entity == null) { entity = new MmItemStatusEntity(); entity.setId(UUID.randomUUID().toString()); - entity.setLastTime(new Date()); + entity.setItemId(itemId); + entity.setLastTime(runTime); entity.setStatus(status.getCode()); entity.setDuration(duration); mmItemStatusDao.insert(entity); } else { - entity.setLastTime(new Date()); + entity.setLastTime(runTime); entity.setStatus(status.getCode()); entity.setDuration(duration); mmItemStatusDao.updateById(entity); -- Gitblit v1.9.3