| | |
| | |
|
| | | import com.fgkj.dao.impl.BattInfImpl;
|
| | | import com.fgkj.dao.impl.Batt_rtstateDAOImpl;
|
| | | import com.fgkj.dao.impl.Battinf_applyImpl;
|
| | | import com.fgkj.dao.impl.Database_backupImpl;
|
| | | import com.fgkj.dto.BattInf;
|
| | | import com.fgkj.dto.Database_backup;
|
| | |
|
| | | public class BattinfGroupFactory {
|
| | | //将同一stationame中的2v,6v,12v数据整合
|
| | |
| | | }
|
| | | //查询当前最大的电池组id
|
| | | public static int searchMaxBattgroupId(){
|
| | | int BattgroupId_max=(new Batt_rtstateDAOImpl()).searchMaxBattgroupId();//当前内存中最大的电池组id
|
| | | int BattgroupId_next=BattgroupId_max+1;
|
| | | return BattgroupId_next;
|
| | | int battgroupid=0;
|
| | | int BattgroupId_rtstate=(new Batt_rtstateDAOImpl()).searchMaxBattgroupId();//当前内存中最大的电池组id
|
| | | int BattgroupId_apply=(new Battinf_applyImpl()).searchMaxBattgroupId_apply();//当前内存中最大的电池组id
|
| | | int BattgroupId_inf=(new BattInfImpl()).searchMaxBattgroupId();//当前内存中最大的电池组id
|
| | | if(BattgroupId_inf>=BattgroupId_apply){
|
| | | battgroupid=BattgroupId_inf;
|
| | | if(battgroupid>=BattgroupId_rtstate) {
|
| | | battgroupid=battgroupid;
|
| | | }else {
|
| | | battgroupid=BattgroupId_rtstate;
|
| | | }
|
| | | }else{
|
| | | battgroupid=BattgroupId_apply;
|
| | | if(battgroupid>=BattgroupId_rtstate) {
|
| | | battgroupid=battgroupid;
|
| | | }else {
|
| | | battgroupid=BattgroupId_rtstate;
|
| | | }
|
| | | }
|
| | | return battgroupid+1;
|
| | | }
|
| | | //查询当前最大的stationid
|
| | | public static int searchStationId(){
|
| | | int station_max=(new BattInfImpl()).searchMaxId();//当前最大的stationid
|
| | | int station_next=station_max+1;
|
| | | return station_next;
|
| | | int stationid=0;
|
| | | int stationid_inf=(new BattInfImpl()).searchMaxId();//当前最大的stationid
|
| | | int stationid_apply=(new Battinf_applyImpl()).searchMaxId_apply();//当前最大的stationid
|
| | | if(stationid_inf>=stationid_apply){
|
| | | stationid=stationid_inf+1;
|
| | | }else{
|
| | | stationid=stationid_apply+1;
|
| | | }
|
| | | return stationid;
|
| | | }
|
| | | //查询当前最大的dev_id
|
| | | public static int searchmaxdev_id(){
|
| | | int dev_id=0;
|
| | | int devid_inf=(new BattInfImpl()).searchMaxdevId_binf();
|
| | | int devid_apply=(new Battinf_applyImpl()).searchMaxdevId_apply();
|
| | | if(devid_inf>=devid_apply){
|
| | | dev_id=devid_inf+1;
|
| | | }else{
|
| | | dev_id=devid_apply+1;
|
| | | }
|
| | | return dev_id;
|
| | | }
|
| | | //当对battinf表中数据进行增删改的操作时,先备份db_battinf.tb_battinf
|
| | | public static boolean backup_battinf(){
|
| | | boolean en=false;
|
| | | { |
| | | Database_backup baseup=new Database_backup();
|
| | | baseup.setBackup_en(1);
|
| | | baseup.setDatabase_name("db_battinf");
|
| | | baseup.setTable_name("tb_battinf");
|
| | | (new Database_backupImpl()).update(baseup);
|
| | | for (int i = 0; i < 20; i++) {
|
| | | boolean b=(new Database_backupImpl()).serchTable_en(baseup);
|
| | | if(b){
|
| | | en=true;
|
| | | }else{
|
| | | try {
|
| | | Thread.sleep(250);
|
| | | } catch (InterruptedException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | };//出现删除操作时,先备份数据库表
|
| | | return en;
|
| | | }
|
| | |
|
| | | }
|