package com.iailab.module.model.mcs.pre.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.module.model.mcs.pre.dao.MmItemStatusDao;
|
import com.iailab.module.model.mcs.pre.entity.MmItemStatusEntity;
|
import com.iailab.module.model.mcs.pre.enums.ItemRunStatusEnum;
|
import com.iailab.module.model.mcs.pre.service.MmItemStatusService;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.UUID;
|
|
/**
|
* @author PanZhibao
|
* @Description
|
* @createTime 2024年11月11日
|
*/
|
@Service
|
public class MmItemStatusServiceImpl implements MmItemStatusService {
|
|
|
@Resource
|
public MmItemStatusDao mmItemStatusDao;
|
|
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.setItemId(itemId);
|
entity.setLastTime(runTime);
|
entity.setStatus(status.getCode());
|
entity.setDuration(duration);
|
mmItemStatusDao.insert(entity);
|
} else {
|
entity.setLastTime(runTime);
|
entity.setStatus(status.getCode());
|
entity.setDuration(duration);
|
mmItemStatusDao.updateById(entity);
|
|
}
|
|
|
}
|
}
|