package com.iailab.module.mcs.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.iailab.framework.common.page.PageData;
|
import com.iailab.framework.common.service.impl.CrudServiceImpl;
|
import com.iailab.common.utils.Constant;
|
import com.iailab.framework.common.util.object.ConvertUtils;
|
import com.iailab.common.utils.DateUtils;
|
import com.iailab.module.mcs.dao.StModelRunlogDao;
|
import com.iailab.module.mcs.dto.StModelRunlogDTO;
|
import com.iailab.module.mcs.entity.StModelRunlogEntity;
|
import com.iailab.module.mcs.service.StModelRunlogService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.util.CollectionUtils;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
|
/**
|
* 运行日志表
|
*
|
* @author lirm ${email}
|
* @since 1.0.0 2023-06-21
|
*/
|
@Service
|
public class StModelRunlogServiceImpl extends CrudServiceImpl<StModelRunlogDao, StModelRunlogEntity, StModelRunlogDTO> implements StModelRunlogService {
|
|
@Resource
|
private StModelRunlogDao runlogDao;
|
|
@Override
|
public QueryWrapper<StModelRunlogEntity> getWrapper(Map<String, Object> params){
|
String modelCode = (String)params.get("modelCode");
|
String modelName = (String)params.get("modelName");
|
|
QueryWrapper<StModelRunlogEntity> wrapper = new QueryWrapper<>();
|
wrapper.like(StringUtils.isNotBlank(modelCode), "model_code", modelCode);
|
wrapper.like(StringUtils.isNotBlank(modelName), "model_name", modelName);
|
|
return wrapper;
|
}
|
|
@Override
|
public List<StModelRunlogDTO> getLastFxLog(Integer limit) {
|
Map<String, Object> params = new HashMap<>(1);
|
params.put("runType", "separation_control");
|
params.put("limit", limit == null ? 5 : limit);
|
return runlogDao.getLastLog(params);
|
}
|
|
@Override
|
public List<StModelRunlogDTO> getLastJyLog(Integer limit) {
|
Map<String, Object> params = new HashMap<>(1);
|
params.put("runType", "dosing_control");
|
params.put("limit", limit == null ? 5 : limit);
|
return runlogDao.getLastLog(params);
|
}
|
|
@Override
|
public void cleanRunlogTask(Map<String, Date> tMap) {
|
runlogDao.cleanRunlogTask(tMap);
|
}
|
|
@Override
|
public PageData<StModelRunlogDTO> queryPage(Map<String, Object> params) {
|
long curPage = 1;
|
long limit = 10;
|
|
if(params.get(Constant.PAGE) != null){
|
curPage = Long.parseLong((String)params.get(Constant.PAGE));
|
}
|
if(params.get(Constant.LIMIT) != null){
|
limit = Long.parseLong((String)params.get(Constant.LIMIT));
|
}
|
|
IPage<StModelRunlogEntity> page = baseDao.queryList(new Page<>(curPage, limit), params);
|
return getPageData(page, StModelRunlogDTO.class);
|
}
|
|
@Override
|
public List<StModelRunlogDTO> listAll(Map<String, Object> params) {
|
return runlogDao.listAll(params);
|
}
|
|
@Override
|
public void add(StModelRunlogDTO dto) {
|
StModelRunlogEntity entity = ConvertUtils.sourceToTarget(dto, StModelRunlogEntity.class);
|
baseDao.insert(entity);
|
}
|
|
@Override
|
public void migrationModelRunlog(Map<String, Date> tMap) {
|
List<StModelRunlogEntity> list = runlogDao.selectList(getDateWrapper(tMap));
|
if (CollectionUtils.isEmpty(list)){
|
return;
|
}
|
runlogDao.migrationModelRunlog(list);
|
runlogDao.delete(getDateWrapper(tMap));
|
}
|
|
public QueryWrapper<StModelRunlogEntity> getDateWrapper(Map<String, Date> params) {
|
String startDate = DateUtils.format(params.get("startdate"),DateUtils.DATE_TIME_PATTERN);
|
String endDate = DateUtils.format(params.get("enddate"),DateUtils.DATE_TIME_PATTERN);
|
|
QueryWrapper<StModelRunlogEntity> wrapper = new QueryWrapper<>();
|
wrapper.ge(StringUtils.isNotBlank(startDate), "run_time", startDate);
|
wrapper.le(StringUtils.isNotBlank(endDate), "run_time", endDate);
|
return wrapper;
|
}
|
|
}
|