package com.fgkj.services;
|
|
import com.fgkj.dto.*;
|
import com.fgkj.mapper.impl.Batt_attentionMapper;
|
import com.fgkj.mapper.impl.BatttestdatastopMapper;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.List;
|
@Service
|
public class Batt_attentionService {
|
|
@Resource
|
private Batt_attentionMapper mapper;
|
|
@Resource
|
private BatttestdatastopMapper battTestDataStopmapper;
|
|
//添加关注
|
public ServiceModel add(Batt_attention attention) {
|
ServiceModel model = new ServiceModel();
|
Boolean bl = null;
|
try {
|
bl = mapper.add(attention)>0;
|
} catch (Exception e) {
|
e.printStackTrace();
|
model.setMsg("添加失败!");
|
return model;
|
}
|
if (bl) {
|
model.setCode(1);
|
model.setMsg("添加成功!");
|
} else {
|
model.setMsg("添加失败!");
|
}
|
return model;
|
|
}
|
|
/*public ServiceModel update(Object obj) {
|
Boolean bl = mapper.update(obj);
|
if (bl) {
|
model.setCode(1);
|
model.setMsg("修改成功!");
|
} else {
|
model.setMsg("修改失败!");
|
}
|
return model;
|
}*/
|
//取消关注
|
public ServiceModel delete(Batt_attention attention) {
|
ServiceModel model = new ServiceModel();
|
Boolean bl = mapper.del(attention)>0;
|
if (bl) {
|
model.setCode(1);
|
}
|
return model;
|
}
|
//根据电池组的筛选条件,查询单体的实际电压
|
public ServiceModel serchByCondition(Batt_Maint_Dealarm bmd) {
|
ServiceModel model = new ServiceModel();
|
PageHelper.startPage(bmd.getPageBean().getPageNum(),bmd.getPageBean().getPageSize(),true);
|
List<BattInf> list = mapper.serchByCondition(bmd);
|
PageInfo<BattInf> pageInfo = new PageInfo<>(list);
|
if(list!=null&&list.size()>0){
|
for (int i=0;i<list.size();i++) {
|
BattInf binf=list.get(i);
|
//最近一笔的实际容量
|
double realcap=battTestDataStopmapper.serchRealCapByMon_num(binf);
|
binf.setMonSerStd((float) realcap);//实际容量
|
}
|
model.setData(pageInfo);
|
}
|
model.setCode(1);
|
return model;
|
}
|
//关注之前识别是否关注过
|
public ServiceModel judgeInOrNot(Batt_attention attention) {
|
ServiceModel model = new ServiceModel();
|
int flag = mapper.judgeInOrNot(attention);
|
if (flag==1) {
|
|
model.setMsg("该信息已经被关注!");
|
}else{
|
model.setMsg("该信息未被关注!");
|
}
|
model.setCode(1);
|
return model;
|
}
|
|
}
|