package com.fgkj.services;
|
|
import ch.qos.logback.core.db.dialect.DBUtil;
|
import com.fgkj.db.DBUtil1;
|
import com.fgkj.dto.*;
|
import com.fgkj.mapper.*;
|
import com.fgkj.mapper.impl.BattInfMapper;
|
import com.fgkj.mapper.impl.Database_backupMapper;
|
import com.fgkj.mapper.impl.Process_surveyMapper;
|
import com.fgkj.mapper.impl.ram.Fbs9100_setparamMapper;
|
import com.fgkj.services.ram.Fbs9100_setparamService;
|
import com.fgkj.util.ActionUtil;
|
import com.fgkj.util.DateUtil;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import org.apache.ibatis.annotations.Param;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.TransactionDefinition;
|
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
import javax.annotation.Priority;
|
import javax.annotation.Resource;
|
import java.lang.annotation.Target;
|
import java.sql.Connection;
|
import java.sql.PreparedStatement;
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
import java.util.Map;
|
@Service
|
public class BattInfServices {
|
|
ServiceModel model = new ServiceModel();
|
|
@Resource
|
private Fbs9100_setparamService fbs9100_setparamService;
|
@Resource
|
private BattInfMapper mapper;
|
|
@Resource
|
private Fbs9100_setparamMapper fbs9100SetParamMapper;
|
@Resource
|
private Process_surveyMapper surveyMapper;
|
@Resource
|
private User_logService uservice;
|
@Autowired
|
DataSourceTransactionManager dataSourceTransactionManager;
|
@Autowired
|
TransactionDefinition transactionDefinition;
|
|
|
//添加新的电池组
|
public ServiceModel add(List<BattInf> list) {
|
//更新数据库备份标志表的标志
|
boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
|
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
ServiceModel model = new ServiceModel();
|
boolean flag=true;
|
if (list != null && list.size() > 0) {
|
int battgroupid = BattinfGroupFactory.searchMaxBattgroupId();
|
int stationid = BattinfGroupFactory.searchStationId();
|
// int dev_id=BattinfGroupFactory.searchmaxdev_id();
|
// int dev_id=BattinfGroupFactory.searchmaxdev_id(list.get(0).getFbsDeviceId()); //TODO 方法名不一致
|
for (int i = 0; i < list.size(); i++) {
|
BattInf binf = list.get(i);
|
if(!mapper.add(binf)){
|
flag=false;
|
}
|
mapper.add(binf);
|
{
|
String msg = "添加" + binf.getStationName() + "机房" + binf.getBattGroupId() + "电池组的信息";
|
User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Increase, msg);
|
uservice.add(ulog);//将用户的操作记录下来
|
}
|
|
}
|
|
}else{
|
flag=false;
|
}
|
if (flag) {
|
dataSourceTransactionManager.commit(transactionStatus);
|
/*//将主程序的服务设为重启
|
Process_survey process=new Process_survey();
|
process.setProcessName(ProcessServerDao.BMS_FBSDEV);
|
Boolean b=(new Process_surveyImpl()).update(process);*/
|
/*App_Sys as=new App_Sys();
|
as.setAppServer_Reinit_BattGroupData_EN(BattTestData.AppServer_Reinit_BattGroupData_EN);
|
Boolean b=(new App_SysImpl()).update(as);*/
|
BattTestData.run_cmd();
|
model.setCode(1);
|
model.setMsg("添加成功!");
|
} else {
|
dataSourceTransactionManager.rollback(transactionStatus);
|
model.setCode(0);
|
model.setMsg("添加失败!");
|
}
|
return model;
|
|
}
|
|
//修改电池组信息
|
public ServiceModel update( List<BattInf> list) {
|
//更新数据库备份标志表的标志
|
boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
|
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
ServiceModel model = new ServiceModel();
|
boolean flag = true;
|
if (list != null && list.size() > 0) {
|
for (int i = 0; i < list.size(); i++) {
|
BattInf binf = list.get(i);
|
// System.out.println("binf = " + binf);
|
if (!(mapper.update(binf)>0)) {
|
flag = false;
|
}
|
{
|
String msg = "修改" + binf.getStationName() + "机房" + binf.getBattGroupId() + "电池组的信息";
|
User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg);
|
uservice.add(ulog);//将用户的操作记录下来
|
}
|
}
|
}else{
|
flag = false;
|
}
|
if (flag) {
|
dataSourceTransactionManager.commit(transactionStatus);
|
BattTestData.run_cmd();//缺少文件
|
model.setCode(1);
|
model.setMsg("修改成功!");
|
} else {
|
dataSourceTransactionManager.rollback(transactionStatus);
|
model.setCode(0);
|
model.setMsg("修改失败!");
|
}
|
return model;
|
}
|
|
|
@Resource
|
private Database_backupMapper backupmapper;
|
//修改电池信息配置(ip地址,掩码和网关)
|
public ServiceModel updateIp(BattInf binf) {
|
ServiceModel model = new ServiceModel();
|
//更新数据库备份标志表的标志
|
boolean flag = backupmapper.updateBackupEn("tb_battinf") > 0;
|
boolean b=mapper.updateIp(binf)>0;
|
if(b){
|
boolean bl = fbs9100_setparamService.sendCmdToFBS9100Dev(binf.getNum(), 0, binf.getFbsDeviceId());
|
if(bl){
|
//将6185的服务设为重启
|
Process_survey process=new Process_survey();
|
process.setProcessName(ProcessServerDao.BMS_FBS61850_BATT);
|
Boolean bt=surveyMapper.update(process);
|
model.setCode(1);
|
model.setMsg("修改成功!");
|
}else{
|
System.out.println(bl);
|
binf.setFbsDeviceIp(binf.getFbsDeviceIp_old());
|
binf.setFbsDeviceIp_WG(binf.getFbsDeviceIp_WG_old());
|
binf.setFbsDeviceIp_YM(binf.getFbsDeviceIp_YM_old());
|
mapper.updateIp(binf);
|
model.setCode(0);
|
model.setMsg("修改61850设备IP信息失败,请检查网络!");
|
}
|
}else{
|
model.setCode(0);
|
model.setMsg("修改失败!");
|
}
|
//System.out.println(model);
|
return model;
|
}
|
|
//删除电池组
|
public ServiceModel delete(List<BattInf> list) {
|
//更新数据库备份标志表的标志
|
boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
|
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
|
ServiceModel model = new ServiceModel();
|
boolean flag = true;
|
if(list!=null&&list.size()>0){
|
for (int i = 0; i < list.size(); i++) {
|
BattInf binf=list.get(i);
|
try {
|
flag =mapper.del(binf)>0;
|
} catch (Exception e) {
|
e.printStackTrace();
|
dataSourceTransactionManager.rollback(transactionStatus);
|
model.setCode(0);
|
model.setMsg("删除失败!");
|
return model;
|
}
|
{
|
String msg="删除"+binf.getStationName()+"机房"+binf.getBattGroupId()+"电池组的信息";
|
User_log ulog = UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg);
|
uservice.add(ulog);//将用户的操作记录下来
|
}
|
}
|
}
|
|
if(flag){
|
dataSourceTransactionManager.commit(transactionStatus);
|
/*//将主程序的服务设为重启
|
Process_survey process=new Process_survey();
|
process.setProcessName(ProcessServerDao.BMS_FBSDEV);
|
Boolean b=(new Process_surveyImpl()).update(process);*/
|
/*App_Sys as=new App_Sys();
|
as.setAppServer_Reinit_BattGroupData_EN(BattTestData.AppServer_Reinit_BattGroupData_EN);
|
Boolean b=(new App_SysImpl()).update(as);*/
|
BattTestData.run_cmd();
|
model.setCode(1);
|
model.setMsg("删除成功!");
|
}
|
else{
|
dataSourceTransactionManager.rollback(transactionStatus);
|
model.setCode(0);
|
model.setMsg("删除失败!");
|
}
|
return model;
|
}
|
//根据维护区和机房名称查询电池组信息
|
public ServiceModel searchInform(Batt_Maint_Dealarm obj) {
|
//更新数据库备份标志表的标志
|
boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
|
ServiceModel model = new ServiceModel();
|
PageBean pageBean = obj.getPageBean();
|
PageHelper.startPage(pageBean.getPageNum(),pageBean.getPageSize(),true);
|
List<BattInf> list=mapper.searchInform(obj);
|
if (list != null && list.size() > 0) {
|
PageInfo<BattInf> pageInfo = new PageInfo<>(list);
|
model.setCode(1);
|
model.setData(pageInfo);
|
model.setMsg("查询成功!");
|
}
|
else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
public ServiceModel searchAll() {
|
//更新数据库备份标志表的标志
|
boolean flag1 = backupmapper.updateBackupEn("tb_battinf") > 0;
|
ServiceModel model = new ServiceModel();
|
List<Integer> list = mapper.searchAll();
|
/*for (int i = 0; i < 100; i++) {
|
System.out.println(list.get(i));
|
}
|
System.out.println("查询结束。。。");*/
|
if (list != null && list.size() > 0) {
|
ArrayList<Integer> last = new ArrayList<>();
|
for (int i = 0; i < list.size(); i++) {
|
Integer num = list.get(i);
|
if (num.equals(0)) {
|
continue;
|
} else {
|
last.add(list.get(i));
|
}
|
}
|
model.setCode(1);
|
model.setData(last);
|
}
|
return model;
|
}
|
public ServiceModelOnce serchByCondition(BattInf bif) {
|
List<BattInf> list=mapper.serchByCondition(bif);
|
ServiceModelOnce model=new ServiceModelOnce();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
//查询出当前存在内存中最大的设备的id(很重要**********)
|
public ServiceModel searchMaxdevId_binf(){
|
ServiceModel model = new ServiceModel();
|
int id=mapper.searchMaxdevId_binf();
|
if(id!=0){
|
model.setCode(1);
|
model.setData(id);
|
}else{
|
model.setCode(0);
|
model.setData(910000001);
|
}
|
return model;
|
}
|
|
//查询电池组左侧导航菜单(实时监测,历史数据查询)
|
public ServiceModel findMenu() {
|
List<List> list = mapper.findMenu();
|
model.setCode(1);
|
model.setData(list);
|
return model;
|
}
|
public ServiceModel findByBattGroupId(BattInf obj) {
|
ServiceModel model = new ServiceModel();
|
List list=mapper.serchByBattgroupId(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
}
|
return model;
|
}
|
//----------根据StationName1(维护区) 查不重复BattGroupName(蓄电池组)
|
public ServiceModelOnce serchByStationName1(BattInf bif) {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list = null;
|
if (bif==null || bif.getStationName1() == null) {
|
list = mapper.serchByStationName1(bif);
|
}else{
|
list = mapper.serchByStationName1plus(bif);
|
}
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
//System.out.println(model);
|
return model;
|
}
|
|
// ----------根据StationName1(维护区) 查不重复的StationName(站点)
|
public ServiceModelOnce serchByStationName(BattInf obj) {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list=mapper.serchByStationName(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
|
// ----------根据StationName1(维护区) 查不重复的StationName(站点)不包含91000000一期设备
|
public ServiceModelOnce serchByStationNameNot91(BattInf obj) {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list=mapper.serchByStationNameNot91(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
//-----------查询所有的省份
|
public ServiceModel serchAllStationName1(User_inf obj) {
|
ServiceModel model = new ServiceModel();
|
List list=mapper.serchAllStationName1(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
// ----------查询所有的市
|
public ServiceModel serchAllStationName2(BattInf obj) {
|
ServiceModel model = new ServiceModel();
|
List list=mapper.serchAllStationName2(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
// ----------查询所有的区县
|
public ServiceModel serchAllStationName5(BattInf obj) {
|
ServiceModel model = new ServiceModel();
|
List list=mapper.serchAllStationName5(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//-----------查询所有的机房
|
public ServiceModel serchAllStationName(BattInf obj) {
|
ServiceModel model = new ServiceModel();
|
List list=mapper.serchAllStationName(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
//--------查询电池组信息
|
public ServiceModel serchAllBattinf(BattInf obj) {
|
ServiceModel model = new ServiceModel();
|
List list=mapper.serchAllBattinf(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
//判断新增的电池组是否存在
|
public ServiceModel judgeBatt(BattInf obj){
|
ServiceModel model = new ServiceModel();
|
List list=mapper.judgeBattStationName(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setMsg("该机房存在!");
|
}else{
|
model.setCode(0);
|
model.setMsg("该机房不存在!");
|
}
|
return model;
|
}
|
|
|
//查电池品牌
|
public ServiceModelOnce serchByBattProducer() {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list=mapper.serchByBattProducer();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
//查单体电压
|
public ServiceModelOnce serchByMonVolStd() {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list = mapper.serchByMonVolStd();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
//查电池容量
|
public ServiceModelOnce serchByMonCapStd() {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list=mapper.serchByMonCapStd();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
//System.out.println(model);
|
return model;
|
}
|
//5.3添加选取电池组或者机房或者维护区(未被应用)
|
public ServiceModel serchBatt(Object obj) {
|
Boolean bl=false;
|
List<BattInf> list=mapper.serchBatt(obj);
|
if(list!=null && list.size()>0){
|
model.setCode(1);
|
model.setData(list);
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
// ----------查不重复的StationName1(维护区)
|
public ServiceModelOnce serchByStation() {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list=mapper.serchByStation();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
// ----------查不重复的StationName1(维护区)不包含91000000一期设备
|
public ServiceModelOnce serchByStationNot91() {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List list=mapper.serchByStationNot91();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
}
|
return model;
|
}
|
//查单体编号
|
public ServiceModelOnce serchByMonNum(BattInf obj) {
|
ServiceModelOnce model = new ServiceModelOnce();
|
List<BattInf> list = mapper.serchByMonNum(obj);
|
if (list != null && list.size() > 0) {
|
for (int i = 0; i <list.size(); i++) {
|
String s = list.get(i).getSignalName().split("#")[0];
|
list.get(i).setMonNum(Integer.parseInt(s));
|
}
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
} else {
|
model.setCode(0);
|
model.setSum(0);
|
}
|
return model;
|
}
|
//根据电池id查询电池的基本信息
|
public ServiceModel searchBattBybattgroupid(BattInf obj){
|
ServiceModel model=new ServiceModel();
|
List list=mapper.searchBattBybattgroupid(obj);
|
//System.out.println(list);
|
if(list!=null && list.size()>0){
|
model.setCode(1);
|
model.setData(list);
|
}
|
return model;
|
}
|
public ServiceModelOnce serchByBattGroupName(BattInf obj) {
|
ServiceModelOnce model=new ServiceModelOnce();
|
List list=mapper.serchByBattGroupName(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setSum(list.size());
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//6.4.7按地域和标称电压分组统计蓄电池组服役超期的数量
|
/*
|
* 区域层次放在stationid中
|
* battgroupnum 中存放统计方式:年度统计为0 季度统计为1
|
* moncount中存放统计季度:一季度为1 以此类推
|
* monnum 中存放年份*/
|
public ServiceModel serchBeyondTime(Object obj){
|
System.out.println(1111111111);
|
BattInf binf=(BattInf) obj;
|
int year=binf.getMonNum();//获取年份
|
int firstMonth=0;//获取起始月份
|
int lastMonth=0;//获取结束月份
|
String dateFirst=""; //起始时间
|
String dateLast=""; //结束时间
|
//做时间判断
|
if(binf.getBattGroupNum()==0){
|
firstMonth=0;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}else if(binf.getBattGroupNum()==1){
|
if(binf.getMonCount()==1){
|
firstMonth=0;//获取起始月份
|
lastMonth=2;//获取结束月份
|
}else if(binf.getMonCount()==2){
|
firstMonth=3;//获取起始月份
|
lastMonth=5;//获取结束月份
|
}else if(binf.getMonCount()==3){
|
firstMonth=6;//获取起始月份
|
lastMonth=8;//获取结束月份
|
}else if(binf.getMonCount()==4){
|
firstMonth=9;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}
|
}
|
try {
|
dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
|
binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst));
|
//System.out.println(dateFirst.substring(0,10));
|
dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
|
binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
|
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
//求总数
|
List<BattInf> list=mapper.serchByMonVolStdGroup(binf);
|
List<BattInf> listB=BattinfGroupFactory.finishMonvol(list);
|
List<BattInf> listL=BattinfGroupFactory.delMonvol(listB);
|
//求超期服役的数量
|
try {
|
year=(new Date()).getYear()+1900-3;//当前时间减去年限
|
//System.out.println(year);
|
dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
|
binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst));
|
//System.out.println(binf.getBattInUseDate());
|
} catch (ParseException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
List<BattInf> listY=mapper.serchBeyondTime(binf);//超期服役的电池组数
|
List<BattInf> listBY=BattinfGroupFactory.finishMonvol(listY);
|
List<BattInf> listLY=BattinfGroupFactory.delMonvol(listBY);
|
/*for (BattInf b : listBY) {
|
System.out.println("0 "+b.getBattGroupNum()+" "+
|
"2v: "+b.getBattGroupId()+" "+
|
"6v: "+b.getMonCount()+" "+
|
"12v: "+b.getMonNum());
|
}*/
|
int level = Integer.parseInt(binf.getStationId());
|
List<BattInf> listFalse=mapper.serchBylevel(level);
|
/* for (BattInf b : listL) {
|
System.out.println("1 "+b.getBattGroupNum()+" "+
|
"2v: "+b.getBattGroupId()+" "+
|
"6v: "+b.getMonCount()+" "+
|
"12v: "+b.getMonNum());
|
}*/
|
List<BattInf> listEnd=BattinfGroupFactory.countAll(listL, listLY);
|
for (BattInf b : listEnd) {
|
System.out.println("2 "+b.getBattGroupNum()+" "+
|
"2v: "+b.getBattGroupId()+" 超过2v: "+b.getMonCapStd()+" "+
|
"6v: "+b.getMonCount()+" 超过6v: "+b.getMonResStd()+" "+
|
"12v: "+b.getMonNum()+" 超过12v: "+b.getMonSerStd());
|
}
|
if(listL!=null&&listL.size()>0){
|
model.setCode(1);
|
model.setData(listEnd);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(listFalse);
|
System.out.println(listFalse.size());
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//6.4.8按地域和标称电压分组统计蓄电池组的数量(蓄电池组数量统计)
|
/*
|
* 区域层次放在stationid中
|
* battgroupnum 中存放统计方式:年度统计为0 季度统计为1
|
* moncount中存放统计季度:一季度为1 以此类推
|
* monnum 中存放年份*/
|
public ServiceModel serchByMonVolStdGroup(Object obj){
|
BattInf binf=(BattInf) obj;
|
int year=binf.getMonNum();//获取年份
|
int firstMonth=0;//获取起始月份
|
int lastMonth=0;//获取结束月份
|
String dateFirst=""; //起始时间
|
String dateLast=""; //结束时间
|
//做时间判断
|
if(binf.getBattGroupNum()==0){
|
firstMonth=0;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}else if(binf.getBattGroupNum()==1){
|
if(binf.getMonCount()==1){
|
firstMonth=0;//获取起始月份
|
lastMonth=2;//获取结束月份
|
}else if(binf.getMonCount()==2){
|
firstMonth=3;//获取起始月份
|
lastMonth=5;//获取结束月份
|
}else if(binf.getMonCount()==3){
|
firstMonth=6;//获取起始月份
|
lastMonth=8;//获取结束月份
|
}else if(binf.getMonCount()==4){
|
firstMonth=9;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}
|
}
|
try {
|
dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
|
binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst));
|
//System.out.println(dateFirst.substring(0,10));
|
dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
|
binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
|
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
|
List<BattInf> list=mapper.serchByMonVolStdGroup(binf);
|
List<BattInf> listB=BattinfGroupFactory.finishMonvol(list);
|
List<BattInf> listL=BattinfGroupFactory.delMonvol(listB);
|
//没有数据时传分组情况
|
int level = Integer.parseInt(binf.getStationId());
|
List<BattInf> listFalse=mapper.serchBylevel(level);
|
// for (BattInf b : listL) {
|
// System.out.println(b.getBattGroupNum()+" "+
|
// "2v: "+b.getBattGroupId()+" "+
|
// "6v: "+b.getMonCount()+" "+
|
// "12v: "+b.getMonNum());
|
// }
|
if(listL!=null&&listL.size()>0){
|
model.setCode(1);
|
model.setData(listL);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(listFalse);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//6.4.9按地域和标称电压分组统计蓄电池组品牌的数量(蓄电池供应商信息统计)
|
/*
|
* 区域层次放在stationid中
|
* battgroupnum 中存放统计方式:年度统计为0 季度统计为1
|
* moncount中存放统计季度:一季度为1 以此类推
|
* monnum 中存放年份*/
|
public ServiceModel serchByBattProducerGroup(Object obj){
|
BattInf binf=(BattInf) obj;
|
int year=binf.getMonNum();//获取年份
|
int firstMonth=0;//获取起始月份
|
int lastMonth=0;//获取结束月份
|
String dateFirst=""; //起始时间
|
String dateLast=""; //结束时间
|
//做时间判断
|
if(binf.getBattGroupNum()==0){
|
firstMonth=0;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}else if(binf.getBattGroupNum()==1){
|
if(binf.getMonCount()==1){
|
firstMonth=0;//获取起始月份
|
lastMonth=2;//获取结束月份
|
}else if(binf.getMonCount()==2){
|
firstMonth=3;//获取起始月份
|
lastMonth=5;//获取结束月份
|
}else if(binf.getMonCount()==3){
|
firstMonth=6;//获取起始月份
|
lastMonth=8;//获取结束月份
|
}else if(binf.getMonCount()==4){
|
firstMonth=9;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}
|
}
|
try {
|
dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
|
binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst));
|
//System.out.println(dateFirst.substring(0,10));
|
dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
|
binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
|
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
|
List<BattInf> list=mapper.serchByBattProducerGroup(binf);
|
//没有数据时传分组情况
|
int level = Integer.parseInt(binf.getStationId());
|
List<BattInf> listFalse=mapper.serchBylevel(level);
|
|
// for (BattInf b : list) {
|
// System.out.println(b.getNum()+" "+
|
// b.getStationName1()+" "+
|
// b.getStationName2()+" "+
|
// b.getStationName3()+" "+
|
// b.getStationName4()+" "+
|
// b.getBattProducer()+" "+
|
// b.getBattGroupNum());
|
// }
|
if(list!=null&&list.size()>0){
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
System.out.println(listFalse);
|
model.setData(listFalse);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//6.4.10按地域和标称电压分组统计蓄电池组使用时间(蓄电池投产年限统计)
|
/*
|
* 区域层次放在stationid中
|
* battgroupnum 中存放统计方式:年度统计为0 季度统计为1
|
* moncount中存放统计季度:一季度为1 以此类推
|
* monnum 中存放年份*/
|
public ServiceModel serchByBattInUseDateGroup(Object obj){
|
BattInf binf=(BattInf) obj;
|
int year=binf.getMonNum();//获取年份
|
int firstMonth=0;//获取起始月份
|
int lastMonth=0;//获取结束月份
|
String dateFirst=""; //起始时间
|
String dateLast=""; //结束时间
|
//做时间判断
|
if(binf.getBattGroupNum()==0){
|
firstMonth=0;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}else if(binf.getBattGroupNum()==1){
|
if(binf.getMonCount()==1){
|
firstMonth=0;//获取起始月份
|
lastMonth=2;//获取结束月份
|
}else if(binf.getMonCount()==2){
|
firstMonth=3;//获取起始月份
|
lastMonth=5;//获取结束月份
|
}else if(binf.getMonCount()==3){
|
firstMonth=6;//获取起始月份
|
lastMonth=8;//获取结束月份
|
}else if(binf.getMonCount()==4){
|
firstMonth=9;//获取起始月份
|
lastMonth=11;//获取结束月份
|
}
|
}
|
try {
|
dateFirst=ActionUtil.getFirstDayOfMonth(year,firstMonth);//起始时间
|
binf.setBattInUseDate(DateUtil.sdf.parse(dateFirst));
|
//System.out.println(dateFirst.substring(0,10));
|
dateLast=ActionUtil.getLastDayOfMonth(year,lastMonth);//结束时间
|
binf.setBattInUseDate1(DateUtil.sdf.parse(dateLast));
|
} catch (Exception e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
|
|
List<BattInf> list=mapper.serchByBattInUseDateGroup(binf);
|
//System.out.println(list.size());
|
//没有数据时传分组情况
|
int level = Integer.parseInt(binf.getStationId());
|
List<BattInf> listFalse=mapper.serchBylevel(level);
|
|
// for (BattInf b : list) {
|
// System.out.println(b.getNum()+" "+
|
// b.getStationName1()+" "+
|
// b.getStationName2()+" "+
|
// b.getStationName3()+" "+
|
// b.getStationName4()+" "+
|
// b.getBattInUseDate()+" "+
|
// b.getBattGroupNum());
|
// }
|
if(list!=null&&list.size()>0){
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(listFalse);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
//1 根据机房id查询电池组id排序最小值
|
public ServiceModel serchByIdLow(Object obj){
|
List list=mapper.serchByIdLow(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(list);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
/**
|
* 根据机房id查询机房中的电池组信息
|
* @param obj
|
* @return
|
*/
|
public ServiceModel searchBattByStationId(Object obj){
|
ServiceModel model = new ServiceModel();
|
List list = mapper.searchBattByStationId(obj);
|
if(list != null && list.size()>0){
|
model.setCode(1);
|
model.setData(list);
|
|
}else{
|
model.setCode(0);
|
}
|
return model;
|
}
|
//查询所有的机房
|
public ServiceModel serchAllStation(Object obj){
|
List list=mapper.serchAllStation(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(list);
|
model.setMsg("查询失败!");
|
}
|
//System.out.println(model);
|
return model;
|
}
|
//搜索机房或电池组
|
public ServiceModel serchStationOrBattgroup(Object obj){
|
List list=mapper.serchStationOrBattgroup(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(list);
|
model.setMsg("查询失败!");
|
}
|
//System.out.println(list.size());
|
return model;
|
}
|
//根据机房id查询机房下的电池组信息
|
public ServiceModel serchBattByStation(Object obj){
|
List list=mapper.serchBattByStation(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setData(list);
|
model.setMsg("查询失败!");
|
}
|
//System.out.println(model);
|
return model;
|
}
|
//查询所有的电池组数
|
public ServiceModel serchAllBatt(Object obj){
|
int nums=mapper.serchAllBatt(obj);
|
model.setCode(1);
|
//TODO perry
|
// model.setSum(nums);
|
model.setMsg("查询成功!");
|
//System.out.println(model);
|
return model;
|
}
|
@Resource
|
private BattInfMapper battInfMapper;
|
//添加站点时返回最大的机房id,设备id,电池组id
|
public ServiceModel searchmaxId() {
|
ServiceModel model = new ServiceModel();
|
List list=new ArrayList();
|
|
// int battgroupid=BattinfGroupFactory.searchMaxBattgroupId();
|
int battgroupid=0;
|
int BattgroupId_inf=battInfMapper.searchMaxBattgroupId_zj();//当前内存中最大的电池组id
|
if (BattgroupId_inf==0){
|
BattgroupId_inf=1010000;
|
}
|
battgroupid=BattgroupId_inf+1;
|
list.add(battgroupid);
|
|
// int stationid=BattinfGroupFactory.searchStationId();
|
int stationid=0;
|
int stationid_inf=battInfMapper.searchMaxId_zj();//当前最大的stationid
|
if (stationid_inf==0){
|
stationid_inf=42010000;
|
}
|
stationid=stationid_inf+1;
|
list.add(stationid);
|
|
// int dev_id=BattinfGroupFactory.searchmaxdev_id();
|
int dev_id=0;
|
int devid_inf=battInfMapper.searchMaxdevId_binf();
|
dev_id=devid_inf+1;
|
if(dev_id == 1){
|
dev_id = 618500001;
|
}
|
list.add(dev_id);
|
model.setData(list);
|
model.setCode(1);
|
model.setMsg("查询成功");
|
return model;
|
}
|
//根据维护区和机房名称查询电池组信息(电池组信息配置)<-------跨域----------->
|
public ServiceModel searchInform_ky() {
|
List<BattInf> list=mapper.searchInform_ky();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}
|
else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
//查站点下的所有设备名称
|
public ServiceModel searchDevByStationName3(Object obj) {
|
List<BattInf> list=mapper.searchDevByStationName3(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}
|
else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
//首页上根据stationid查询电池组的机历卡
|
public ServiceModel serchBattAllInfoByStationId(Object obj){
|
List list=mapper.serchBattAllInfoByStationId(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
//--------查询电池组信息<大屏显示>
|
public ServiceModel serchBatt_DP(Object obj) {
|
List list=mapper.serchBatt_DP(obj);
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
|
//紫晶山西——---机房列表
|
public ServiceModel searchStationList() {
|
List list=mapper.searchStationList();
|
if (list != null && list.size() > 0) {
|
model.setCode(1);
|
model.setData(list);
|
model.setMsg("查询成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("查询失败!");
|
}
|
return model;
|
}
|
public static void main(String[] args) {
|
//new BattInfServices().findMenu();
|
BattInf b=new BattInf();
|
//b.setBattGroupId(1000005);
|
b.setNum(58);
|
b.setFbsDeviceId(91000001);
|
b.setFbsDeviceIp("192.168.0.56");
|
b.setFbsDeviceIp_YM("255.255.255.0");
|
b.setFbsDeviceIp_WG("127.0.0.1");
|
b.setFbsDeviceIp_old("192.168.0.56");
|
b.setFbsDeviceIp_YM_old("255.255.255.0");
|
b.setFbsDeviceIp_WG_old("192.168.0.1");
|
b.setStationName("");
|
b.setStationName1("");
|
b.setStationName9("");
|
b.setBattGroupName("");
|
b.setStationId("42070463");
|
//b.setBattGroupName1("开关电源系统");
|
//b.setBattProducer("光宇");
|
b.setMonCapStd(100f);
|
b.setMonVolStd(12f);
|
BattInfServices bs=new BattInfServices();
|
//bs.serchByStation();
|
//bs.serchByStationName(b);
|
//bs.serchByStationName1(b);
|
//bs.serchByCondition(b);
|
|
//bs.searchBattBybattgroupid(b);
|
//bs.serchByBattGroupName(b);
|
//bs.findMenu();
|
//bs.serchAllStation();
|
//bs.serchStationOrBattgroup(b);
|
//bs.serchBattByStation(b);
|
|
PageBean pageBean =new PageBean();
|
pageBean.setPageCurr(1);
|
pageBean.setPageSize(10);
|
Batt_Maint_Dealarm bmd=new Batt_Maint_Dealarm();
|
bmd.setBinf(b);
|
bmd.setPageBean(pageBean);
|
//bs.searchInform(bmd);
|
//bs.serchByBattGroupName(b);
|
bs.updateIp(b);
|
}
|
|
/**查询所有省市区站点机房*/
|
public ServiceModel searchAllStation(Integer uId) {
|
Map map =mapper.searchAllStation(uId);
|
if(map!=null && !map.isEmpty()){
|
model.setCode(1);
|
model.setData(map);
|
}
|
return model;
|
}
|
}
|