package com.fgkj.services;
|
|
import java.util.List;
|
|
import com.fgkj.dao.BaseDAO;
|
import com.fgkj.dao.BaseDAOFactory;
|
import com.fgkj.dao.impl.Batt_attentionImpl;
|
import com.fgkj.dao.impl.BatttestdatastopDAOImpl;
|
import com.fgkj.dto.BattInf;
|
import com.fgkj.dto.Batt_Maint_Dealarm;
|
import com.fgkj.dto.Page;
|
import com.fgkj.dto.ServiceModel;
|
|
public class Batt_attentionService {
|
private BaseDAO dao;
|
private ServiceModel model;
|
|
public Batt_attentionService() {
|
super();
|
model=new ServiceModel();
|
dao=BaseDAOFactory.getBaseDAO(BaseDAO.BATT_ATTENTION);
|
}
|
//添加关注
|
public ServiceModel add(Object obj) {
|
Boolean bl = dao.add(obj);
|
if (bl) {
|
model.setCode(1);
|
model.setMsg("添加成功!");
|
} else {
|
model.setMsg("添加失败!");
|
}
|
return model;
|
|
}
|
|
public ServiceModel update(Object obj) {
|
Boolean bl = dao.update(obj);
|
if (bl) {
|
model.setCode(1);
|
model.setMsg("修改成功!");
|
} else {
|
model.setMsg("修改失败!");
|
}
|
return model;
|
}
|
//取消关注
|
public ServiceModel delete(Object obj) {
|
Boolean bl = dao.del(obj);
|
if (bl) {
|
model.setCode(1);
|
model.setMsg("删除成功!");
|
} else {
|
model.setMsg("删除失败!");
|
}
|
return model;
|
}
|
//根据电池组的筛选条件,查询单体的实际电压
|
public ServiceModel serchByCondition(Object obj) {
|
List<BattInf> list = dao.serchByCondition(obj);
|
if(list!=null&&list.size()>0){
|
for (int i=0;i<list.size();i++) {
|
BattInf binf=list.get(i);
|
//最近一笔的实际容量
|
double realcap=(new BatttestdatastopDAOImpl()).serchRealCapByMon_num(binf);
|
binf.setMonSerStd((float) realcap);//实际容量
|
}
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
//System.out.println(list);
|
return model;
|
}
|
//关注之前识别是否关注过
|
public ServiceModel judgeInOrNot(Object obj) {
|
int flag = ((Batt_attentionImpl)dao).judgeInOrNot(obj);
|
if (flag==1) {
|
model.setCode(1);
|
model.setMsg("该信息已经被关注!");
|
}else{
|
model.setCode(0);
|
model.setMsg("该信息未被关注!");
|
}
|
return model;
|
}
|
|
public static void main(String[] args) {
|
Batt_attentionService bservice=new Batt_attentionService();
|
BattInf binf=new BattInf();
|
binf.setStationName("");
|
binf.setStationName1("");
|
binf.setBattGroupId(0);
|
binf.setMonNum(0);
|
binf.setNum(1002);
|
Page page=new Page();
|
page.setPageCurr(1);
|
page.setPageSize(10);
|
|
Batt_Maint_Dealarm bmd=new Batt_Maint_Dealarm();
|
bmd.setBinf(binf);
|
bmd.setPage(page);
|
bservice.serchByCondition(bmd);
|
}
|
}
|