提交 | 用户 | 时间
|
4eb113
|
1 |
package com.iailab.module.model.mcs.pre.service.impl; |
潘 |
2 |
|
|
3 |
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
4 |
import com.iailab.module.model.mcs.pre.dao.MmItemStatusDao; |
|
5 |
import com.iailab.module.model.mcs.pre.entity.MmItemStatusEntity; |
|
6 |
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum; |
|
7 |
import com.iailab.module.model.mcs.pre.service.MmItemStatusService; |
|
8 |
import org.springframework.stereotype.Service; |
|
9 |
|
|
10 |
import javax.annotation.Resource; |
|
11 |
import java.util.Date; |
|
12 |
import java.util.UUID; |
|
13 |
|
|
14 |
/** |
|
15 |
* @author PanZhibao |
|
16 |
* @Description |
|
17 |
* @createTime 2024年11月11日 |
|
18 |
*/ |
|
19 |
@Service |
|
20 |
public class MmItemStatusServiceImpl implements MmItemStatusService { |
|
21 |
|
|
22 |
|
|
23 |
@Resource |
|
24 |
public MmItemStatusDao mmItemStatusDao; |
|
25 |
|
|
26 |
public void recordStatus(String itemId, ItemRunStatusEnum status, Long duration) { |
|
27 |
QueryWrapper<MmItemStatusEntity> queryWrapper = new QueryWrapper<>(); |
|
28 |
queryWrapper.eq("item_id", itemId); |
|
29 |
MmItemStatusEntity entity = mmItemStatusDao.selectOne(queryWrapper); |
|
30 |
if (entity == null) { |
|
31 |
entity = new MmItemStatusEntity(); |
|
32 |
entity.setId(UUID.randomUUID().toString()); |
|
33 |
entity.setLastTime(new Date()); |
|
34 |
entity.setStatus(status.getCode()); |
|
35 |
entity.setDuration(duration); |
|
36 |
mmItemStatusDao.insert(entity); |
|
37 |
} else { |
|
38 |
entity.setLastTime(new Date()); |
|
39 |
entity.setStatus(status.getCode()); |
|
40 |
entity.setDuration(duration); |
|
41 |
mmItemStatusDao.updateById(entity); |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
|
|
46 |
} |
|
47 |
} |