package com.fgkj.services;
|
|
import com.fgkj.dto.*;
|
import com.fgkj.mapper.AlarmDaoFactory;
|
import com.fgkj.mapper.TestDaoFactory;
|
import com.fgkj.mapper.impl.*;
|
import com.fgkj.util.ActionUtil;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
@Service
|
public class BattTest_ResService {
|
|
ServiceModel model = new ServiceModel();
|
|
|
@Resource
|
private BattInfServices bservice;
|
@Resource
|
private Batt_maintenance_infService mservice;
|
@Resource
|
private Batttestdata_infService tservice;
|
@Resource
|
private BatttestdatastopService sservice;
|
@Resource
|
private Battresdata_infService rservice;
|
@Resource
|
private BattresdataService dservice;
|
@Resource
|
private User_infService uservice;
|
|
|
@Resource
|
private BattTest_ResMapper mapper;
|
@Resource
|
private BattInfMapper binf;
|
@Resource
|
private Alarm_paramMapper alarmParamMapper;
|
@Resource
|
private Batttestdata_infMapper battTestDataInfMapper;
|
@Resource
|
private BattresdataMapper battResDataMapper;
|
@Resource
|
private Battresdata_infMapper battResDataInfMapper;
|
@Resource
|
private BatttestdataMapper battTestDataMapper;
|
|
/*@Resource
|
private BaseDAO daoAgin;*/
|
|
private Batt_Maint_Dealarm bd;
|
|
|
//6.1电池充放电数据管理
|
public List serchByCondition(Object obj){
|
Batt_Maint_Dealarm bmd=(Batt_Maint_Dealarm) obj;
|
Batttestdata_inf tdata = bmd.getTdata();
|
Batttestdatastop sdata = new Batttestdatastop();
|
Battresdata_inf rinf=new Battresdata_inf();
|
Battresdata rdata=new Battresdata();
|
List<Batt_Maint_Dealarm> list=mapper.serchByCondition(bmd);
|
//System.out.println(list.size()+"$$$$$$$$");
|
List<AllModel> listall=new ArrayList<AllModel>();
|
float param=0;//容量告警参数
|
int Caplevel=0;
|
Alarm_param aparam=new Alarm_param();
|
aparam.setAlm_id(AlarmDaoFactory.Alarm_CapAlarm);
|
List<Alarm_param> listA=alarmParamMapper.serchByCondition(aparam,new AlarmDaoFactory());
|
if(listA!=null&&listA.size()>0){
|
param=listA.get(listA.size()-1).getAlm_low_coe();
|
}
|
float Cparam=0;//容量更换告警参数
|
aparam.setAlm_id(AlarmDaoFactory.Alarm_CapChange);
|
List<Alarm_param> listC=alarmParamMapper.serchByCondition(aparam,new AlarmDaoFactory());
|
if(listC!=null&&listA.size()>0){
|
Cparam=listC.get(listC.size()-1).getAlm_low_coe();
|
}
|
//System.out.println(listC.size());
|
for(int i=0;i<list.size();i++){
|
AllModel allmodel=new AllModel();
|
if(list.get(i).getTdata()!=null){
|
tdata.setBattGroupId(list.get(i).getBinf().getBattGroupId());
|
sdata.setBattGroupId(list.get(i).getBinf().getBattGroupId());
|
//求得具体放电测试类型
|
int start_type=0;
|
int test_type=0;
|
if(list.get(i).getTdata().getTest_starttype()!=null){
|
start_type=list.get(i).getTdata().getTest_starttype();
|
test_type=list.get(i).getTdata().getTest_type();
|
}
|
//获取放电/充电时测试仪表类型
|
String test_starttypeHex=TestDaoFactory.getTest_starttypeHex(start_type, test_type);
|
list.get(i).getTdata().setTest_starttypeHex(test_starttypeHex);
|
|
sdata.setBattGroupId(list.get(i).getBinf().getBattGroupId());
|
sdata.setTest_cap(list.get(i).getBinf().getMonVolStd());//电压类型
|
sdata.setTest_curr(list.get(i).getBinf().getMonCapStd());//标称电容
|
sdata.setTest_record_count(list.get(i).getTdata().getTest_record_count());
|
sdata.setMon_max(list.get(i).getTdata().getMax_monvol());//最大电压
|
sdata.setLowC(param);//容量告警
|
sdata.setLowV(Cparam);//容量更换告警
|
ServiceModel smodel=new ServiceModel();
|
if(tservice.judge(tdata).getCode()==1){
|
smodel=sservice.serchByLow(sdata);
|
allmodel.setSmodel(smodel);
|
}
|
}else if(list.get(i).getRinf()!=null){
|
rinf.setBattGroupId(list.get(i).getBinf().getBattGroupId());
|
rdata.setBattGroupId(list.get(i).getBinf().getBattGroupId());
|
//求得具体放电测试类型
|
int dev_type=list.get(i).getRinf().getTest_devtype();
|
//获取电导/内阻时测试仪表类型
|
String dev_typeHex=TestDaoFactory.getRes_starttypeHex(dev_type);
|
list.get(i).getRinf().setTest_starttypeHex(dev_typeHex);
|
rdata.setBattGroupId(list.get(i).getBinf().getBattGroupId());
|
rdata.setTest_record_count(list.get(i).getRinf().getTest_record_count());
|
ServiceModel rmodel=new ServiceModel();
|
if(rservice.judge(rinf).getCode()==1){
|
Float MonCapStd=list.get(i).getBinf().getMonCapStd();//标存容量
|
//求截至平均电压和最低电压单体编号和电压值
|
rmodel=dservice.serchByLow(rdata);
|
allmodel.setRmodel(rmodel);
|
}
|
}
|
listall.add(allmodel);
|
listall.get(i).setData(list.get(i));
|
//System.out.println(list.get(i).getTdata().getMin_monnum()+" "+list.get(i).getTdata().getMin_monvol());
|
}
|
//System.out.println(listall.size());
|
return listall;
|
}
|
/**
|
* 6.1电池充放电删除操作
|
* 暂时不做,后续对接前端再沟通实现
|
*/
|
public ServiceModel delete(Object obj){
|
/*List<BattInf> list=(List<BattInf>) obj;
|
ArrayList<String> sql_str = new ArrayList<String>();//存放所有的sql语句
|
List<User_log> listU=new ArrayList();//存放user_log
|
if(list!=null&&list.size()>0){
|
for(int i=0;i<list.size();i++){
|
BattInf binf=list.get(i);
|
if(binf.getStationId().equals("1")){
|
Batttestdata_inf tdata=new Batttestdata_inf();
|
tdata.setNum(binf.getNum());
|
Batttestdata test=new Batttestdata();
|
test.setBattGroupId(binf.getBattGroupId());
|
test.setTest_record_count(binf.getFbsDeviceId());
|
|
String str=battTestDataInfMapper.delPro(tdata);
|
sql_str.add(str);
|
{
|
String msg="删除"+binf.getBattGroupId()+"电池组在充放电记录中第"+binf.getFbsDeviceId()+"笔充放电记录";
|
User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
|
listU.add(ulog);
|
}
|
String str_id=battTestDataMapper.delPro(test);
|
sql_str.add(str_id);
|
{
|
String msg="删除"+binf.getBattGroupId()+"电池组在单体充放电记录中第"+binf.getFbsDeviceId()+"笔充放电记录";
|
User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
|
listU.add(ulog);
|
}
|
|
}else if(binf.getStationId().equals("2")){
|
Battresdata_inf rinf=new Battresdata_inf();
|
rinf.setNum(binf.getNum());
|
|
Battresdata rdata=new Battresdata();
|
rdata.setBattGroupId(binf.getBattGroupId());
|
rdata.setTest_record_count(binf.getFbsDeviceId());
|
|
String str=battResDataInfMapper.delPro(rinf);
|
sql_str.add(str);
|
{
|
String msg="删除"+binf.getBattGroupId()+"电池组在内阻测试记录中第"+binf.getFbsDeviceId()+"笔内阻测试记录";
|
User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
|
listU.add(ulog);
|
}
|
String str_id=battResDataMapper.delPro(rdata);
|
sql_str.add(str_id);
|
{
|
String msg="删除"+binf.getBattGroupId()+"电池组在内阻测试单体记录中第"+binf.getFbsDeviceId()+"笔内阻测试记录";
|
User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Delete, msg);
|
listU.add(ulog);
|
}
|
}
|
}
|
}
|
// Boolean bl=DateUtil.makeManualCommit(DBUtil.getConn(), sql_str);
|
Boolean bl=true;
|
|
new User_logService().addPro(listU);//将用户的操作记录下来
|
|
if(bl){
|
model.setCode(1);
|
model.setMsg("删除成功!");
|
}else{
|
model.setCode(0);
|
model.setMsg("删除失败!");
|
}
|
return model;*/
|
return null;
|
}
|
|
public static void main(String[] args) throws ParseException {
|
BattTest_ResService bservice=new BattTest_ResService();
|
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.setBattGroupId(0);
|
binf.setBattGroupName1("");
|
binf.setBattProducer("");
|
binf.setMonCapStd(0f);
|
binf.setMonVolStd(0f);
|
binf.setBattProductDate(ActionUtil.getSimpDate(date1));
|
binf.setBattProductDate1(ActionUtil.getSimpDate(date2));
|
binf.setBattInUseDate(ActionUtil.getSimpDate(date1));
|
binf.setBattInUseDate1(ActionUtil.getSimpDate(date2));
|
|
Batt_maint_inf mainf=new Batt_maint_inf();
|
mainf.setRemark("100");
|
mainf.setMaint_done_time(ActionUtil.getSimpDate(date1));
|
mainf.setMaint_done_time1(ActionUtil.getSimpDate(date2));
|
|
Batttestdata_inf tdata=new Batttestdata_inf();
|
tdata.setTest_type(0);
|
tdata.setTest_starttype(0);
|
tdata.setRecord_time(ActionUtil.getSimpDate(date1));
|
tdata.setRecord_time1(ActionUtil.getSimpDate(date2));
|
|
User_inf uinf=new User_inf();
|
uinf.setuId(0);
|
|
PageBean p = new PageBean();
|
p.setPageCurr(1);
|
p.setPageSize(200);
|
|
Batt_Maint_Dealarm bmd = new Batt_Maint_Dealarm();
|
bmd.setPageBean(p);
|
bmd.setBinf(binf);
|
bmd.setTdata(tdata);
|
bmd.setMainf(mainf);
|
bmd.setUinf(uinf);
|
bservice.serchByCondition(bmd);
|
|
}
|
}
|