package com.fgkj.services;
|
|
import com.fgkj.dto.BattInf;
|
import com.fgkj.dto.Batt_Devdischarge;
|
import com.fgkj.dto.Batt_Devdischarge_all;
|
import com.fgkj.dto.ServiceModel;
|
import com.fgkj.mapper.impl.Batt_DevdischargeMapper;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
import javax.annotation.Resource;
|
@Service
|
public class Batt_DevdischargeService {
|
|
|
@Resource
|
private Batt_DevdischargeMapper mapper;;
|
|
public ServiceModel add(Batt_Devdischarge bd){
|
ServiceModel model = new ServiceModel();
|
Boolean bl= null;
|
try {
|
bl = mapper.add(bd)>0;
|
} catch (Exception e) {
|
e.printStackTrace();
|
model.setCode(0);
|
model.setMsg("添加失败!");
|
return model;
|
}
|
if(bl){
|
model.setCode(1);
|
model.setMsg("添加成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("添加失败!");
|
}
|
return model;
|
}
|
public ServiceModel update(Batt_Devdischarge obj){
|
ServiceModel model = new ServiceModel();
|
Boolean bl=mapper.update(obj)>0;
|
if(bl){
|
model.setCode(1);
|
model.setMsg("修改成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("修改失败!");
|
}
|
return model;
|
}
|
public ServiceModel del(Batt_Devdischarge obj){
|
ServiceModel model = new ServiceModel();
|
Boolean bl=mapper.del(obj)>0;
|
if(bl){
|
model.setCode(1);
|
model.setMsg("删除成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("删除失败!");
|
}
|
return model;
|
}
|
public ServiceModel searchAll(){
|
ServiceModel model = new ServiceModel();
|
List list=mapper.searchAll();
|
if(list!=null&&list.size()>0){
|
model.setCode(1);
|
model.setMsg("查询成功!");
|
model.setData(list);
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//10.1根据设备id连battinf和batt_devdischarge表
|
/*
|
* 记录时间放在battinf的battproducer
|
* MonCount:当前页
|
* MonNum :页面的大小
|
*/
|
public ServiceModel serchByCondition(BattInf binf) {
|
ServiceModel model = new ServiceModel();
|
binf.setNum(0);
|
binf.setMonCount(0);
|
binf.setMonNum(0);
|
List<Batt_Devdischarge> listN = mapper.serchMaxAndMinNum(binf);
|
boolean searchFlag=true;
|
if (listN != null && listN.size() > 0) {
|
System.out.println("listN = " + listN);
|
Float dev_curr = listN.get(listN.size() - 1).getDev_curr();
|
float number = -1;
|
if (dev_curr != null) {
|
number = dev_curr;
|
}else{
|
searchFlag=false;
|
}
|
Float dev_power = listN.get(listN.size() - 1).getDev_power();
|
float maxnum = -1;
|
if (dev_power != null) {
|
maxnum = dev_power;
|
}else{
|
searchFlag=false;
|
}
|
Float dev_vol = listN.get(listN.size() - 1).getDev_vol();
|
float minnum = -1;
|
if (dev_vol != null) {
|
minnum = dev_vol;
|
}else{
|
searchFlag=false;
|
}
|
binf.setNum((int) number);
|
binf.setMonCount((int) maxnum);
|
binf.setMonNum((int) minnum);
|
}
|
List<Batt_Devdischarge_all> list = null;
|
if (searchFlag){
|
list = mapper.serchByCondition(binf);
|
}
|
//System.out.println(list.size());
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setMsg("查询成功!");
|
model.setData(list);
|
} else {
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
//System.out.println(model);
|
return model;
|
}
|
|
/*public static void main(String[] args) throws ParseException {
|
Batt_DevdischargeService bservice=new Batt_DevdischargeService();
|
Batt_DevdischargeImpl bimpl=new Batt_DevdischargeImpl();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
Date date1 = sdf.parse("2000-01-01");
|
Date date2 = sdf.parse("2020-01-01");
|
BattInf binf=new BattInf();
|
binf.setStationName("");
|
binf.setStationName1("");
|
binf.setStationId("42070450");
|
binf.setMonCount(1);
|
binf.setMonNum(100);
|
binf.setBattProductDate(ActionUtil.getSimpDate(date1));
|
binf.setBattProductDate1(ActionUtil.getSimpDate(date2));
|
bservice.serchByCondition(binf);
|
}*/
|
}
|