| | |
| | | <div class="bui-page">
|
| | | <header class="bui-bar">
|
| | | <div class="bui-bar-left">
|
| | | <div class="bui-btn btn-back"><i class="icon-back"></i></div>
|
| | | </div>
|
| | | <div class="bui-bar-main">模板页</div>
|
| | | <div class="bui-bar-right"></div>
|
| | | </header>
|
| | | <main>
|
| | | <button @click="update">测试数据</button>
|
| | | {{msg}}
|
| | | </main>
|
| | | <footer>
|
| | | |
| | | </footer>
|
| | | <div class="bui-page"> |
| | | <header class="bui-bar"> |
| | | <div class="bui-bar-left"> |
| | | <div class="bui-btn btn-back"><i class="icon-back"></i></div> |
| | | </div> |
| | | <div class="bui-bar-main">模板页</div> |
| | | <div class="bui-bar-right"></div> |
| | | </header> |
| | | <main> |
| | | <button @click="update">测试数据</button> |
| | | <br/> |
| | | {{msg}} |
| | | </main> |
| | | <footer> |
| | | |
| | | </footer> |
| | | </div> |
| | |
| | | /**
|
| | | * 模板模块
|
| | | * 默认模块名: test
|
| | | * @return {[object]} [ 返回一个对象 ]
|
| | | */
|
| | | loader.define({
|
| | | data: {
|
| | | vm: ''
|
| | | },
|
| | | loaded: function loaded(require, exports, module) {
|
| | | // 引入vue
|
| | | this.vm = new Vue({
|
| | | el: getPageRoot(module),
|
| | | data: {
|
| | | msg: ''
|
| | | },
|
| | | methods: {
|
| | | update: function() {
|
| | | if(typeof(BattinfService) != "undefined") {
|
| | | var data = {
|
| | | BattGroupId: 1,
|
| | | BattGroupName: '电池组1',
|
| | | BattGroupName1: "电池组",
|
| | | BattFloatCurrent: 10,
|
| | | MonCount: 4,
|
| | | MonCapStd: 150,
|
| | | MonVolStd: 40,
|
| | | MonResStd: 30,
|
| | | MonSerStd: 1000,
|
| | | MonTmpStd: 30,
|
| | | BattProducer: '理士',
|
| | | BattInUseDate: '2019-11-14 00:00:00',
|
| | | station_install: 1
|
| | | |
| | | };
|
| | | BattinfService.update(JSON.stringify(data));
|
| | | }else {
|
| | | bui.alert("请使用手机端登陆")
|
| | | }
|
| | | }
|
| | | },
|
| | | mounted: function() {
|
| | | var self = this;
|
| | | window["updatecalljs"] = function(res) {
|
| | | self.msg = res;
|
| | | }
|
| | | },
|
| | | destroyed: function() {}
|
| | | });
|
| | | },
|
| | | destroyed: function() {
|
| | | this.vm.$destroy();
|
| | | }
|
| | | /** |
| | | * 模板模块 |
| | | * 默认模块名: test |
| | | * @return {[object]} [ 返回一个对象 ] |
| | | */ |
| | | loader.define({ |
| | | data: { |
| | | vm: '' |
| | | }, |
| | | loaded: function loaded(require, exports, module) { |
| | | // 引入vue |
| | | this.vm = new Vue({ |
| | | el: getPageRoot(module), |
| | | data: { |
| | | msg: '' |
| | | }, |
| | | methods: { |
| | | update: function() { |
| | | if(typeof(BattinfService) != "undefined") { |
| | | var data = { |
| | | BattGroupId:1, |
| | | BattGroupName: '电池组1', |
| | | BattGroupName1: "电池组", |
| | | BattFloatCurrent: 10, |
| | | MonCount: 4, |
| | | MonCapStd: 150, |
| | | MonVolStd: 12, |
| | | MonResStd: 30, |
| | | MonSerStd: 1000, |
| | | MonTmpStd: 30, |
| | | BattProducer: '南都', |
| | | BattInUseDate: '2019-11-14', |
| | | station_install: 1 |
| | | |
| | | }; |
| | | //tb_battinf |
| | | { |
| | | //BattinfService.update(JSON.stringify(data)); |
| | | BattinfService.searchAll(); |
| | | //BattinfService.add(JSON.stringify(data)); |
| | | } |
| | | |
| | | }else { |
| | | bui.alert("请使用手机端登陆") |
| | | } |
| | | } |
| | | }, |
| | | mounted: function() { |
| | | var self = this; |
| | | window["updatecalljs"] = function(res) { |
| | | self.msg = res; |
| | | } |
| | | window["searchAllcalljs"] = function(res) { |
| | | if(res.code==1){ |
| | | var data=res.data; |
| | | self.msg = data; |
| | | }else{ |
| | | self.msg=res; |
| | | } |
| | | |
| | | } |
| | | window["addcalljs"] = function(res) { |
| | | self.msg = res; |
| | | } |
| | | }, |
| | | destroyed: function() {} |
| | | }); |
| | | }, |
| | | destroyed: function() { |
| | | this.vm.$destroy(); |
| | | } |
| | | }); |
| | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.GsonBuilder; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | public class ActionUtil { |
| | | |
| | | public static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | public static SimpleDateFormat sdfwithOut=new SimpleDateFormat("yyyy-MM-dd"); |
| | | |
| | | public static Date getSimpDate(Date time){ |
| | | //System.out.println(time); |
| | | return new java.sql.Date(time.getTime()); |
| | | } |
| | | /** |
| | | * 返回数据给前台js |
| | | * @param funName |
| | | * @param model |
| | | */ |
| | | public static void SendCallDataToJS(String funName, ServiceModel model,WebView webView){ |
| | | String call = "javascript:"+funName+"calljs(" + getGson("yyyy-MM-dd HH:mm:ss").toJson(model) + ")"; |
| | | public static void SendCallDataToJS(String funName, ServiceModel model,WebView webView,Gson gson){ |
| | | String call = "javascript:"+funName+"calljs(" + gson.toJson(model) + ")"; |
| | | new Handler(Looper.getMainLooper()).post(() -> webView.loadUrl(call)); |
| | | } |
| | | /** |
New file |
| | |
| | | package com.fgkj.dao; |
| | | import android.content.ContentValues; |
| | | import android.content.Context; |
| | | import android.database.Cursor; |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.database.sqlite.SQLiteDatabase.CursorFactory; |
| | | import android.database.sqlite.SQLiteOpenHelper; |
| | | import android.util.Log; |
| | | |
| | | public class DBHelper extends SQLiteOpenHelper { |
| | | private final static int VERSION = 1; |
| | | private final static String DB_NAME = "fbs9600.db"; |
| | | private SQLiteDatabase db; |
| | | |
| | | //SQLiteOpenHelper子类必须要的一个构造函数 |
| | | public DBHelper(Context context, String name, CursorFactory factory,int version) { |
| | | //必须通过super 调用父类的构造函数 |
| | | super(context, name, factory, version); |
| | | } |
| | | |
| | | //数据库的构造函数,传递三个参数的 |
| | | public DBHelper(Context context, String name, int version){ |
| | | this(context, name, null, version); |
| | | } |
| | | |
| | | //数据库的构造函数,传递一个参数的, 数据库名字和版本号都写死了 |
| | | public DBHelper(Context context){ |
| | | this(context, DB_NAME, null, VERSION); |
| | | } |
| | | |
| | | // 回调函数,第一次创建时才会调用此函数,创建一个数据库 |
| | | @Override |
| | | public void onCreate(SQLiteDatabase db) { |
| | | this.db = db; |
| | | //System.out.println("Create Database"); |
| | | //创建tb_battinf |
| | | Create_battinf(db); |
| | | |
| | | //创建tb_batttestdata_inf |
| | | Create_batttestdata_inf(db); |
| | | |
| | | //db.close(); |
| | | |
| | | } |
| | | |
| | | //回调函数,当你构造DBHelper的传递的Version与之前的Version调用此函数 |
| | | @Override |
| | | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { |
| | | System.out.println("update Database"); |
| | | |
| | | } |
| | | |
| | | //关闭数据库 |
| | | public void close(){ |
| | | if(db != null){ |
| | | db.close(); |
| | | } |
| | | } |
| | | //创建tb_battinf |
| | | public static void Create_battinf(SQLiteDatabase db){ |
| | | String Create_battinf_sql=" CREATE TABLE if not exists tb_battinf ( "+ |
| | | "num integer PRIMARY KEY AUTOINCREMENT NOT NULL," + |
| | | "BattGroupId int(11) NOT NULL DEFAULT '0'," + |
| | | "BattGroupName varchar(100) NOT NULL DEFAULT ' '," + |
| | | "BattGroupName1 varchar(100) NOT NULL DEFAULT ' '," + |
| | | "BattFloatCurrent float NOT NULL DEFAULT '0'," + |
| | | "MonCount int(11) NOT NULL DEFAULT '0'," + |
| | | "MonCapStd float NOT NULL DEFAULT '0'," + |
| | | "MonVolStd float NOT NULL DEFAULT '0'," + |
| | | "MonResStd float NOT NULL DEFAULT '0'," + |
| | | "MonSerStd float NOT NULL DEFAULT '0'," + |
| | | "MonTmpStd float NOT NULL DEFAULT '0'," + |
| | | "BattProducer varchar(45) NOT NULL DEFAULT '0'," + |
| | | "BattInUseDate date NOT NULL DEFAULT '2006-07-06'," + |
| | | "station_install tinyint(1) NOT NULL DEFAULT '0'" + |
| | | ")"; |
| | | db.execSQL(Create_battinf_sql); |
| | | String battinf_index_sql=" CREATE UNIQUE INDEX index_BattGroupId_unique ON tb_battinf (BattGroupId ASC) "; |
| | | db.execSQL(battinf_index_sql); |
| | | } |
| | | //创建tb_batttestdata_inf |
| | | public static void Create_batttestdata_inf(SQLiteDatabase db){ |
| | | String Create_batttestdata_inf_sql="CREATE TABLE if not exists tb_batttestdata_inf ("+ |
| | | " num integer NOT NULL PRIMARY KEY AUTOINCREMENT," + |
| | | " BattGroupId int(11) NOT NULL DEFAULT '0'," + |
| | | " test_record_count int(11) NOT NULL DEFAULT '0'," + |
| | | " test_record_count_ex int(11) NOT NULL DEFAULT '0'," + |
| | | " test_type int(11) NOT NULL DEFAULT '0'," + |
| | | " record_time_interval int(11) NOT NULL DEFAULT '0'," + |
| | | " data_new tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " data_available tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " record_num int(11) NOT NULL DEFAULT '0'," + |
| | | " test_starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " test_starttime_ex datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " test_starttype int(11) NOT NULL DEFAULT '0'," + |
| | | " record_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " test_timelong int(11) NOT NULL DEFAULT '0'," + |
| | | " test_stoptype int(11) NOT NULL DEFAULT '0'," + |
| | | " group_vol float NOT NULL DEFAULT '0'," + |
| | | " test_curr float NOT NULL DEFAULT '0'," + |
| | | " test_cap float NOT NULL DEFAULT '0'," + |
| | | " max_monnum int(11) NOT NULL DEFAULT '0'," + |
| | | " max_monvol float NOT NULL DEFAULT '0'," + |
| | | " min_monnum int(11) NOT NULL DEFAULT '0'," + |
| | | " min_monvol float NOT NULL DEFAULT '0'," + |
| | | " mon_num int(11) NOT NULL DEFAULT '0'," + |
| | | " mon_vol float NOT NULL DEFAULT '0'," + |
| | | " upload_usr_id int(11) NOT NULL DEFAULT '0'," + |
| | | " upload_data_ext int(11) NOT NULL DEFAULT '0'," + |
| | | " upload_client_type int(11) NOT NULL DEFAULT '0'" + |
| | | ")"; |
| | | db.execSQL(Create_batttestdata_inf_sql); |
| | | String index_battgroup_idsql="CREATE INDEX index_battgroup_id ON tb_batttestdata_inf (BattGroupId ASC)"; |
| | | db.execSQL(index_battgroup_idsql); |
| | | String index_test_record_countsql= "CREATE INDEX index_test_record_count ON tb_batttestdata_inf (test_record_count ASC)"; |
| | | db.execSQL(index_test_record_countsql); |
| | | String index_test_starttimesql="CREATE INDEX index_test_starttime ON tb_batttestdata_inf (test_starttime ASC)"; |
| | | db.execSQL(index_test_starttimesql); |
| | | } |
| | | //创建tb_batttestdata |
| | | public static void Create_batttestdata(SQLiteDatabase db,int battgroupid){ |
| | | String Create_batttestdata_sql="CREATE TABLE if not exists tb_batttestdata_" +battgroupid+ |
| | | " num integer NOT NULL PRIMARY KEY AUTOINCREMENT," + |
| | | " BattGroupId int(11) NOT NULL DEFAULT '0'," + |
| | | " test_record_count int(11) NOT NULL DEFAULT '0'," + |
| | | " test_type int(11) NOT NULL DEFAULT '0'," + |
| | | " data_new tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " data_available tinyint(1) NOT NULL DEFAULT '0'," + |
| | | " record_num int(11) NOT NULL DEFAULT '0'," + |
| | | " test_starttime datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " record_time datetime NOT NULL DEFAULT '1982-01-01 00:00:00'," + |
| | | " test_timelong int(11) NOT NULL DEFAULT '0'," + |
| | | " online_vol float NOT NULL DEFAULT '0'," + |
| | | " group_vol float NOT NULL DEFAULT '0'," + |
| | | " test_curr float NOT NULL DEFAULT '0'," + |
| | | " test_cap float NOT NULL DEFAULT '0'," + |
| | | " mon_num int(11) NOT NULL DEFAULT '0'," + |
| | | " mon_vol float NOT NULL DEFAULT '0'," + |
| | | " mon_tmp float NOT NULL DEFAULT '0'" + |
| | | ")"; |
| | | db.execSQL(Create_batttestdata_sql); |
| | | String index_test_record_countsql= "CREATE INDEX index_test_record_count_"+battgroupid+" ON tb_batttestdata_"+battgroupid+" (test_record_count ASC);"; |
| | | db.execSQL(index_test_record_countsql); |
| | | |
| | | } |
| | | } |
| | |
| | | package com.fgkj.impl; |
| | | |
| | | import android.database.Cursor; |
| | | import android.database.SQLException; |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.util.Log; |
| | | |
| | | import com.fgkj.dao.ActionUtil; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dto.Battinf; |
| | | import com.sqlite_DaoHelper.CallBack; |
| | |
| | | @Override |
| | | public boolean add(SQLiteDatabase db,Object obj) { |
| | | Battinf binf=(Battinf) obj; |
| | | boolean bl=true; |
| | | String sql=" insert into tb_battinf(BattGroupId,BattGroupName,BattGroupName1,BattFloatCurrent,MonCount,MonCapStd,MonVolStd,MonResStd,MonSerStd,MonTmpStd,BattProducer,BattInUseDate,station_install) " + |
| | | " values(?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| | | boolean bl= DAOHelper.executeUpdate(DBUtil.getConn(),sql,new Object[]{binf.getBattGroupId(),binf.getBattGroupName(),binf.getBattGroupName1(),binf.getBattFloatCurrent(),binf.getMonCount(),binf.getMonCapStd(),binf.getMonVolStd() |
| | | ,binf.getMonResStd(),binf.getMonSerStd(),binf.getMonTmpStd(),binf.getBattProducer(),binf.getBattInUseDate(),binf.getStation_install()}); |
| | | return bl; |
| | | db.execSQL(sql,new Object[]{binf.getBattGroupId(),binf.getBattGroupName(),binf.getBattGroupName1(),binf.getBattFloatCurrent(),binf.getMonCount(),binf.getMonCapStd(),binf.getMonVolStd() |
| | | ,binf.getMonResStd(),binf.getMonSerStd(),binf.getMonTmpStd(),binf.getBattProducer(),ActionUtil.getSimpDate(binf.getBattInUseDate()),binf.getStation_install()}); |
| | | try { |
| | | return bl; |
| | | } catch (Exception e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | return bl; |
| | | } |
| | | //根据battgroupid修改表的数据 |
| | | @Override |
| | | public boolean update(SQLiteDatabase db,Object obj) { |
| | | Battinf binf=(Battinf) obj; |
| | | String sql=" update tb_battinf set BattGroupName=?,BattGroupName1=?,BattFloatCurrent=?,MonCount=?,MonCapStd=?,MonVolStd=?,MonResStd=?,MonSerStd=?,MonTmpStd=?,BattProducer=?,BattInUseDate=?,station_install=? where BattGroupId=? ) "; |
| | | boolean bl= DAOHelper.executeUpdate(DBUtil.getConn(),sql,new Object[]{binf.getBattGroupName(),binf.getBattGroupName1(),binf.getBattFloatCurrent(),binf.getMonCount(),binf.getMonCapStd(),binf.getMonVolStd() |
| | | ,binf.getMonResStd(),binf.getMonSerStd(),binf.getMonTmpStd(),binf.getBattProducer(),binf.getBattInUseDate(),binf.getStation_install(),binf.getBattGroupId()}); |
| | | boolean bl=true; |
| | | String sql=" update tb_battinf set BattGroupName=?,BattGroupName1=?,BattFloatCurrent=?,MonCount=?,MonCapStd=?,MonVolStd=?,MonResStd=?,MonSerStd=?,MonTmpStd=?,BattProducer=?,BattInUseDate=?,station_install=? where BattGroupId=? "; |
| | | try { |
| | | db.execSQL(sql,new Object[]{binf.getBattGroupName(),binf.getBattGroupName1(),binf.getBattFloatCurrent(),binf.getMonCount(),binf.getMonCapStd(),binf.getMonVolStd() |
| | | ,binf.getMonResStd(),binf.getMonSerStd(),binf.getMonTmpStd(),binf.getBattProducer(),ActionUtil.getSimpDate(binf.getBattInUseDate()),binf.getStation_install(),binf.getBattGroupId()}); |
| | | } catch (SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | return bl; |
| | | } |
| | | |
| | | //根据id删除 |
| | | @Override |
| | | public boolean del(SQLiteDatabase db,Object obj) { |
| | | return false; |
| | | Battinf binf=(Battinf)obj; |
| | | boolean bl=true; |
| | | String sql=" delete from tb_battinf where BattGroupId=? "; |
| | | try { |
| | | db.execSQL(sql,new Object[]{binf.getBattGroupId()}); |
| | | } catch (SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return bl; |
| | | } |
| | | //查询库中存在的所有电池组信息 |
| | | @Override |
| | | public List searchAll(SQLiteDatabase db) { |
| | | //Log.d("dddddddd:",db.toString()); |
| | | String sql=" select * from tb_battinf where station_install=1 order by battgroupid asc "; |
| | | List list=new ArrayList(); |
| | | Cursor rs = db.rawQuery(sql,new String[]{}); |
| | |
| | | binf.setMonSerStd(rs.getDouble(rs.getColumnIndex("MonSerStd"))); |
| | | binf.setMonTmpStd(rs.getDouble(rs.getColumnIndex("MonTmpStd"))); |
| | | binf.setBattProducer(rs.getString(rs.getColumnIndex("BattProducer"))); |
| | | String battInuseDate=rs.getString(rs.getColumnIndex("BattInUseDate")); |
| | | Log.d("*****",battInuseDate); |
| | | //binf.setBattInUseDate(rs.get); |
| | | try { |
| | | Date date= ActionUtil.sdfwithOut.parse( rs.getString(rs.getColumnIndex("BattInUseDate"))); |
| | | binf.setBattInUseDate(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | binf.setStation_install(rs.getInt(rs.getColumnIndex("station_install"))); |
| | | Log.d("@@@@@@",binf.toString()); |
| | | list.add(binf); |
| | | } |
| | | rs.close(); |
| | | return list; |
| | | } |
| | | |
| | | //根据电池组id查询电池组信息 |
| | | @Override |
| | | public List serchByCondition(SQLiteDatabase db,Object obj) { |
| | | return null; |
| | | Battinf b=(Battinf)obj; |
| | | String sql=" select * from tb_battinf where BattGroupId=? order by battgroupid asc "; |
| | | List list=new ArrayList(); |
| | | Cursor rs = db.rawQuery(sql,new String[]{String.valueOf(b.getBattGroupId())}); |
| | | while(rs.moveToNext()){ |
| | | Battinf binf=new Battinf(); |
| | | binf.setNum(rs.getInt(rs.getColumnIndex("num"))); |
| | | binf.setBattGroupId(rs.getInt(rs.getColumnIndex("BattGroupId"))); |
| | | binf.setBattGroupName(rs.getString(rs.getColumnIndex("BattGroupName"))); |
| | | binf.setBattGroupName1(rs.getString(rs.getColumnIndex("BattGroupName1"))); |
| | | binf.setBattFloatCurrent(rs.getDouble(rs.getColumnIndex("BattFloatCurrent"))); |
| | | binf.setMonCapStd(rs.getDouble(rs.getColumnIndex("MonCapStd"))); |
| | | binf.setMonVolStd(rs.getDouble(rs.getColumnIndex("MonVolStd"))); |
| | | binf.setMonCount(rs.getInt(rs.getColumnIndex("MonCount"))); |
| | | binf.setMonResStd(rs.getDouble(rs.getColumnIndex("MonResStd"))); |
| | | binf.setMonSerStd(rs.getDouble(rs.getColumnIndex("MonSerStd"))); |
| | | binf.setMonTmpStd(rs.getDouble(rs.getColumnIndex("MonTmpStd"))); |
| | | binf.setBattProducer(rs.getString(rs.getColumnIndex("BattProducer"))); |
| | | try { |
| | | Date date= ActionUtil.sdfwithOut.parse( rs.getString(rs.getColumnIndex("BattInUseDate"))); |
| | | binf.setBattInUseDate(date); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | binf.setStation_install(rs.getInt(rs.getColumnIndex("station_install"))); |
| | | list.add(binf); |
| | | } |
| | | rs.close(); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | |
| | | binf.setMonSerStd(0.002); |
| | | binf.setMonTmpStd(50.2); |
| | | binf.setBattProducer("理士"); |
| | | binf.setBattInUseDate(DAOHelper.getSimpDate(date1)); |
| | | binf.setBattInUseDate(ActionUtil.getSimpDate(date1)); |
| | | //System.out.println(DAOHelper.getSimpDate(date1)); |
| | | // System.out.println(binf.getBattInUseDate()); |
| | | binf.setStation_install(1); |
| | |
| | | package com.fgkj.impl; |
| | | |
| | | import android.database.Cursor; |
| | | import android.database.SQLException; |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Connection; |
| | | import java.sql.ResultSet; |
| | | import java.sql.SQLException; |
| | | import java.text.ParseException; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | import com.fgkj.dao.ActionUtil; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.BattTestData; |
| | | import com.fgkj.dto.Batttestdata; |
| | |
| | | import com.sqlite_DaoHelper.DBUtil; |
| | | |
| | | public class BatttestdataDAOImpl implements BaseDAO{ |
| | | |
| | | //批量插入放电记录 |
| | | public boolean add(SQLiteDatabase db,Object obj) { |
| | | List<Batttestdata> list=(List<Batttestdata>) obj; |
| | | ArrayList<String> sql_str=new ArrayList(); |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Batttestdata b=list.get(i); |
| | | String sql="insert into db_batt_testdata.tb_batttestdata_"+b.getBattGroupId()+"(BattGroupId,test_record_count,test_type,data_new,data_available,record_num,test_starttime,record_time,test_timelong,online_vol,group_vol,test_curr,test_cap,mon_num,mon_vol,mon_tmp) " + |
| | | " values("+b.getBattGroupId()+","+b.getTest_record_count()+","+b.getTest_type()+","+b.getData_new()+","+b.getData_available()+","+b.getRecord_num()+",'"+DAOHelper.sdf.format(b.getTest_starttime())+"','"+DAOHelper.sdf.format(b.getRecord_time())+"',"+b.getTest_timelong()+","+b.getOnline_vol()+","+b.getGroup_vol()+","+b.getTest_curr()+","+b.getTest_cap()+","+b.getMon_num()+","+b.getMon_vol()+","+b.getMon_tmp()+")"; |
| | | sql_str.add(sql); |
| | | boolean bl=true; |
| | | try { |
| | | db.beginTransaction(); |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Batttestdata b=list.get(i); |
| | | String sql="insert into db_batt_testdata.tb_batttestdata_"+b.getBattGroupId()+"(BattGroupId,test_record_count,test_type,data_new,data_available,record_num,test_starttime,record_time,test_timelong,online_vol,group_vol,test_curr,test_cap,mon_num,mon_vol,mon_tmp) " + |
| | | " values("+b.getBattGroupId()+","+b.getTest_record_count()+","+b.getTest_type()+","+b.getData_new()+","+b.getData_available()+","+b.getRecord_num()+",'"+ ActionUtil.sdf.format(b.getTest_starttime())+"','"+ActionUtil.sdf.format(b.getRecord_time())+"',"+b.getTest_timelong()+","+b.getOnline_vol()+","+b.getGroup_vol()+","+b.getTest_curr()+","+b.getTest_cap()+","+b.getMon_num()+","+b.getMon_vol()+","+b.getMon_tmp()+")"; |
| | | db.execSQL(sql); |
| | | } |
| | | } |
| | | db.setTransactionSuccessful(); |
| | | db.endTransaction(); |
| | | } catch (SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | boolean bl= DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); |
| | | return bl; |
| | | } |
| | | |
| | |
| | | return bl; |
| | | } |
| | | |
| | | |
| | | //批量修改数据 |
| | | public boolean updatePro(SQLiteDatabase db,Object obj) { |
| | | List<Batttestdata> list= (List<Batttestdata>) obj; |
| | | ArrayList<String> sql_str=new ArrayList(); |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Batttestdata b=list.get(i); |
| | | float mon_tmp=(float) (Math.random()+20); |
| | | BigDecimal bd = new BigDecimal((double)mon_tmp); |
| | | bd = bd.setScale(1,4); |
| | | mon_tmp = bd.floatValue(); |
| | | String sql="update db_batt_testdata.tb_batttestdata_"+b.getBattGroupId()+" set mon_tmp="+mon_tmp+" where num="+b.getNum(); |
| | | sql_str.add(sql); |
| | | System.out.println(mon_tmp+" "+i); |
| | | boolean bl=true; |
| | | try { |
| | | db.beginTransaction(); |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Batttestdata b=list.get(i); |
| | | float mon_tmp=(float) (Math.random()+20); |
| | | BigDecimal bd = new BigDecimal((double)mon_tmp); |
| | | bd = bd.setScale(1,4); |
| | | mon_tmp = bd.floatValue(); |
| | | String sql="update db_batt_testdata.tb_batttestdata_"+b.getBattGroupId()+" set mon_tmp="+mon_tmp+" where num="+b.getNum(); |
| | | db.execSQL(sql); |
| | | } |
| | | } |
| | | db.setTransactionSuccessful(); |
| | | db.endTransaction(); |
| | | } catch (SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str); |
| | | return bl; |
| | | } |
| | | //6.1电池充放电管理删除操作 |
| | | //删除放电记录(battgroupid,test_record_count) |
| | | public boolean del(SQLiteDatabase db,Object obj) { |
| | | Batttestdata test = (Batttestdata) obj; |
| | | String sql = "delete from db_batt_testdata.tb_batttestdata_" + test.getBattGroupId() |
| | | + " where battgroupid=? and test_record_count=? "; |
| | | Boolean bl = DAOHelper.executeUpdate( |
| | | DBUtil.getConn(), sql, |
| | | new Object[] { test.getBattGroupId(),test.getTest_record_count() }); |
| | | Batttestdata bdata = (Batttestdata) obj; |
| | | boolean bl=true; |
| | | try { |
| | | String sql = "delete from db_batt_testdata.tb_batttestdata_" + bdata.getBattGroupId() |
| | | + " where battgroupid=? and test_record_count=? "; |
| | | db.execSQL(sql,new Object[]{bdata.getBattGroupId(),bdata.getTest_record_count()}); |
| | | } catch (SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | return bl; |
| | | } |
| | | |
| | | //电池充/放电数据管理删除 |
| | | public String delPro(SQLiteDatabase db,Object obj) { |
| | | Batttestdata bd=(Batttestdata) obj; |
| | | String sql="delete from db_batt_testdata.tb_batttestdata_"+bd.getBattGroupId()+" where test_record_count="+bd.getTest_record_count(); |
| | | return sql; |
| | | //批量删除数据 |
| | | public boolean delPro(SQLiteDatabase db,Object obj) { |
| | | List<Batttestdata> list= (List<Batttestdata>) obj; |
| | | boolean bl=true; |
| | | try { |
| | | db.beginTransaction(); |
| | | if(list!=null&&list.size()>0){ |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Batttestdata b=list.get(i); |
| | | String sql = "delete from db_batt_testdata.tb_batttestdata_" + b.getBattGroupId() |
| | | + " where battgroupid="+b.getBattGroupId()+" and test_record_count="+b.getTest_record_count(); |
| | | db.execSQL(sql); |
| | | } |
| | | } |
| | | db.setTransactionSuccessful(); |
| | | db.endTransaction(); |
| | | } catch (SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | return bl; |
| | | } |
| | | |
| | | |
| | | public List searchAll(SQLiteDatabase db) { |
| | | return null; |
| | | } |
| | | //历史监测 |
| | | //历史监测根据battgroupid查询 |
| | | public List serchByCondition(SQLiteDatabase db,Object obj) { |
| | | Batttestdata btd=(Batttestdata)obj; |
| | | int number=btd.getRecord_num();//总数 |
| | |
| | | " from db_batt_testdata.tb_batttestdata_"+btd.getBattGroupId()+"" + |
| | | " where test_record_count=? and (record_num%"+roteN+"=0 or test_timelong>=? or test_timelong<= ? or record_num>=("+number+"-100)) " + |
| | | " and db_batt_testdata.tb_batttestdata_"+btd.getBattGroupId()+".data_available=1 "; |
| | | //System.out.println(sql); |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{btd.getTest_record_count(),btd.getNum(),btd.getTest_type()}, new CallBack() { |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | Batttestdata b=new Batttestdata(); |
| | | b.setNum(rs.getInt("num")); |
| | | b.setBattGroupId(rs.getInt("BattGroupId")); |
| | | b.setTest_record_count(rs.getInt("test_record_count")); |
| | | b.setTest_type(rs.getInt("test_type")); |
| | | b.setData_new(rs.getInt("data_new")); |
| | | b.setData_available(rs.getInt("data_available")); |
| | | b.setRecord_num(rs.getInt("record_num")); |
| | | b.setTest_starttime(rs.getTimestamp("test_starttime")); |
| | | b.setRecord_time(rs.getTimestamp("record_time")); |
| | | b.setTest_timelong(rs.getInt("test_timelong")); |
| | | b.setOnline_vol(rs.getFloat("online_vol")); |
| | | b.setGroup_vol(rs.getFloat("group_vol")); |
| | | b.setTest_curr(rs.getFloat("test_curr")); |
| | | b.setTest_cap(rs.getFloat("test_cap")); |
| | | b.setMon_num(rs.getInt("mon_num")); |
| | | b.setMon_vol(rs.getFloat("mon_vol")); |
| | | b.setMon_tmp(rs.getFloat("mon_tmp")); |
| | | list.add(b); |
| | | } |
| | | }catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | |
| | | List list=new ArrayList(); |
| | | Cursor rs=db.rawQuery(sql,new String[]{String.valueOf(btd.getTest_record_count()),String.valueOf(btd.getNum()),String.valueOf(btd.getTest_type())}); |
| | | try { |
| | | while (rs.moveToNext()){ |
| | | Batttestdata b=new Batttestdata(); |
| | | b.setNum(rs.getInt(rs.getColumnIndex("num"))); |
| | | b.setBattGroupId(rs.getInt(rs.getColumnIndex("BattGroupId"))); |
| | | b.setTest_record_count(rs.getInt(rs.getColumnIndex("test_record_count"))); |
| | | b.setTest_type(rs.getInt(rs.getColumnIndex("test_type"))); |
| | | b.setData_new(rs.getInt(rs.getColumnIndex("data_new"))); |
| | | b.setData_available(rs.getInt(rs.getColumnIndex("data_available"))); |
| | | b.setRecord_num(rs.getInt(rs.getColumnIndex("record_num"))); |
| | | b.setTest_starttime(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("test_starttime")))); |
| | | b.setRecord_time(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("record_time")))); |
| | | b.setTest_timelong(rs.getInt(rs.getColumnIndex("test_timelong"))); |
| | | b.setOnline_vol(rs.getFloat(rs.getColumnIndex("online_vol"))); |
| | | b.setGroup_vol(rs.getFloat(rs.getColumnIndex("group_vol"))); |
| | | b.setTest_curr(rs.getFloat(rs.getColumnIndex("test_curr"))); |
| | | b.setTest_cap(rs.getFloat(rs.getColumnIndex("test_cap"))); |
| | | b.setMon_num(rs.getInt(rs.getColumnIndex("mon_num"))); |
| | | b.setMon_vol(rs.getFloat(rs.getColumnIndex("mon_vol"))); |
| | | b.setMon_tmp(rs.getFloat(rs.getColumnIndex("mon_tmp"))); |
| | | list.add(b); |
| | | } |
| | | }); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rs.close(); |
| | | return list; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //查询某一次测试中的最大一次的测试时长和最短时长<历史监测> |
| | | public List serchMaxAndMintime(Object obj){ |
| | | public List serchMaxAndMintime(SQLiteDatabase db,Object obj){ |
| | | Batttestdata btb=(Batttestdata) obj; |
| | | String sql=" SELECT MAX(record_num) number,MAX(test_timelong) as maxtime,MIN(test_timelong) as mintime FROM db_batt_testdata.tb_batttestdata_"+btb.getBattGroupId()+ |
| | | " WHERE test_record_count=? and db_batt_testdata.tb_batttestdata_"+btb.getBattGroupId()+".data_available=1 LIMIT 1"; |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{btb.getTest_record_count()}, new CallBack() { |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | Batttestdata btb=new Batttestdata(); |
| | | btb.setNum(rs.getInt("maxtime")); |
| | | btb.setTest_type(rs.getInt("mintime")); |
| | | btb.setRecord_num(rs.getInt("number")); |
| | | list.add(btb); |
| | | } |
| | | } catch (SQLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | List list=new ArrayList(); |
| | | Cursor rs=db.rawQuery(sql,new String[]{String.valueOf(btb.getTest_record_count())}); |
| | | while(rs.moveToNext()){ |
| | | Batttestdata b=new Batttestdata(); |
| | | b.setNum(rs.getInt(rs.getColumnIndex("maxtime"))); |
| | | b.setTest_type(rs.getInt(rs.getColumnIndex("mintime"))); |
| | | b.setRecord_num(rs.getInt(rs.getColumnIndex("number"))); |
| | | list.add(b); |
| | | } |
| | | rs.close(); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | BatttestdataDAOImpl bimpl=new BatttestdataDAOImpl(); |
| | | Batttestdata_inf btd=new Batttestdata_inf(); |
| | | btd.setBattGroupId(1002410); |
| | | btd.setNote("1,2,8,10,11,13,14,15,16,17,18,20,22,24,25,26,27,30,31,33,44,45,48,50,51,52,53,54,55"); |
| | | btd.setTest_record_count(47); |
| | | List list=new ArrayList(); |
| | | list.add(btd); |
| | | /*List list_all=bimpl.serchByInfo(list); |
| | | for (int i = 0; i < list_all.size(); i++) { |
| | | List<Batttestdata> list1=(List<Batttestdata>) list_all.get(i); |
| | | for (Batttestdata b : list1) { |
| | | System.out.println(b); |
| | | } |
| | | } |
| | | System.out.println(list_all.size());*/ |
| | | |
| | | } |
| | | } |
| | |
| | | package com.fgkj.impl; |
| | | |
| | | import android.database.Cursor; |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | |
| | | import java.sql.Connection; |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import com.fgkj.dao.ActionUtil; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.BattTestData; |
| | | import com.fgkj.dto.Batttestdata_inf; |
| | |
| | | |
| | | |
| | | public class Batttestdata_infDAOImpl implements BaseDAO, CallBack { |
| | | private SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | //向batttestdata_inf表中添加数据 |
| | | public boolean add(SQLiteDatabase db,Object obj) { |
| | | Batttestdata_inf b=(Batttestdata_inf)obj; |
| | | String sql="insert into tb_batttestdata_inf(BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; |
| | | return DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{ |
| | | b.getBattGroupId(), |
| | | b.getTest_record_count(), |
| | | b.getTest_record_count_ex(), |
| | | b.getTest_type(), |
| | | b.getRecord_time_interval(), |
| | | b.getData_new(), |
| | | b.getData_available(), |
| | | b.getRecord_num(), |
| | | b.getTest_starttime(), |
| | | b.getTest_starttime_ex(), |
| | | b.getTest_starttype(), |
| | | b.getRecord_time(), |
| | | b.getTest_timelong(), |
| | | b.getTest_stoptype(), |
| | | b.getGroup_vol(), |
| | | b.getTest_curr(), |
| | | b.getTest_cap(), |
| | | b.getMax_monnum(), |
| | | b.getMax_monvol(), |
| | | b.getMin_monnum(), |
| | | b.getMin_monvol(), |
| | | b.getMon_num(), |
| | | b.getMon_vol(), |
| | | b.getUpload_usr_id() |
| | | }); |
| | | |
| | | boolean bl=true; |
| | | try { |
| | | db.execSQL(sql,new Object[]{ |
| | | b.getBattGroupId(), |
| | | b.getTest_record_count(), |
| | | b.getTest_record_count_ex(), |
| | | b.getTest_type(), |
| | | b.getRecord_time_interval(), |
| | | b.getData_new(), |
| | | b.getData_available(), |
| | | b.getRecord_num(), |
| | | b.getTest_starttime(), |
| | | b.getTest_starttime_ex(), |
| | | b.getTest_starttype(), |
| | | b.getRecord_time(), |
| | | b.getTest_timelong(), |
| | | b.getTest_stoptype(), |
| | | b.getGroup_vol(), |
| | | b.getTest_curr(), |
| | | b.getTest_cap(), |
| | | b.getMax_monnum(), |
| | | b.getMax_monvol(), |
| | | b.getMin_monnum(), |
| | | b.getMin_monvol(), |
| | | b.getMon_num(), |
| | | b.getMon_vol(), |
| | | b.getUpload_usr_id() |
| | | }); |
| | | } catch (android.database.SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | return bl; |
| | | } |
| | | |
| | | public boolean update(SQLiteDatabase db,Object obj) { |
| | |
| | | return false; |
| | | } |
| | | |
| | | //6.1电池充放电删除操作 |
| | | //电池充放电删除记录 |
| | | public boolean del(SQLiteDatabase db,Object obj) { |
| | | Batttestdata_inf tdata=(Batttestdata_inf)obj; |
| | | boolean bl=true; |
| | | String sql="delete from tb_batttestdata_inf where num=?"; |
| | | return DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{tdata.getNum()}); |
| | | } |
| | | //电池充/放电数据管理删除 |
| | | public String delPro(SQLiteDatabase db,Object obj) { |
| | | Batttestdata_inf tdata=(Batttestdata_inf)obj; |
| | | String sql="delete from tb_batttestdata_inf where num="+tdata.getNum(); |
| | | return sql; |
| | | try { |
| | | db.execSQL(sql, new Object[]{tdata.getNum()}); |
| | | } catch (android.database.SQLException e) { |
| | | bl=false; |
| | | e.printStackTrace(); |
| | | } |
| | | return bl; |
| | | } |
| | | //查询所有的充放电信息 |
| | | public List searchAll(SQLiteDatabase db) { |
| | | String sql="select num,BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id " + |
| | | " from tb_batttestdata_inf " + |
| | | " where tb_batttestdata_inf.data_available=1 "; |
| | | return DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { |
| | | Cursor rs=db.rawQuery(sql,new String[]{}); |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.moveToNext()){ |
| | | Batttestdata_inf b=new Batttestdata_inf(); |
| | | b.setNum(rs.getInt(rs.getColumnIndex("num"))); |
| | | b.setBattGroupId(rs.getInt(rs.getColumnIndex("BattGroupId"))); |
| | | b.setTest_record_count(rs.getInt(rs.getColumnIndex("test_record_count"))); |
| | | b.setTest_record_count_ex(rs.getInt(rs.getColumnIndex("test_record_count_ex"))); |
| | | b.setTest_type(rs.getInt(rs.getColumnIndex("test_type"))); |
| | | b.setRecord_time_interval(rs.getInt(rs.getColumnIndex("record_time_interval"))); |
| | | b.setData_new(rs.getInt(rs.getColumnIndex("data_new"))); |
| | | b.setData_available(rs.getInt(rs.getColumnIndex("data_available"))); |
| | | b.setRecord_num(rs.getInt(rs.getColumnIndex("record_num"))); |
| | | |
| | | b.setTest_starttime(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("test_starttime")))); |
| | | b.setTest_starttime_ex(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("test_starttime_ex")))); |
| | | b.setTest_starttype(rs.getInt(rs.getColumnIndex("test_starttype"))); |
| | | b.setRecord_time(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("record_time")))); |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | Batttestdata_inf b=new Batttestdata_inf(); |
| | | b.setNum(rs.getInt("num")); |
| | | b.setBattGroupId(rs.getInt("BattGroupId")); |
| | | b.setTest_record_count(rs.getInt("test_record_count")); |
| | | b.setTest_record_count_ex(rs.getInt("test_record_count_ex")); |
| | | b.setTest_type(rs.getInt("test_type")); |
| | | b.setRecord_time_interval(rs.getInt("record_time_interval")); |
| | | b.setData_new(rs.getInt("data_new")); |
| | | b.setData_available(rs.getInt("data_available")); |
| | | b.setRecord_num(rs.getInt("record_num")); |
| | | b.setTest_starttime(rs.getTimestamp("test_starttime")); |
| | | b.setTest_starttime_ex(rs.getTimestamp("test_starttime_ex")); |
| | | b.setTest_starttype(rs.getInt("test_starttype")); |
| | | b.setRecord_time(rs.getTimestamp("record_time")); |
| | | b.setTest_timelong(rs.getInt("test_timelong")); |
| | | b.setTest_stoptype(rs.getInt("test_stoptype")); |
| | | b.setGroup_vol(rs.getFloat("group_vol")); |
| | | b.setTest_curr(rs.getFloat("test_curr")); |
| | | b.setTest_cap(rs.getFloat("test_cap")); |
| | | b.setMax_monnum(rs.getInt("max_monnum")); |
| | | b.setMax_monvol(rs.getFloat("max_monvol")); |
| | | b.setMin_monnum(rs.getInt("min_monnum")); |
| | | b.setMin_monvol(rs.getFloat("min_monvol")); |
| | | b.setMon_num(rs.getInt("mon_num")); |
| | | b.setMon_vol(rs.getFloat("mon_vol")); |
| | | b.setUpload_usr_id(rs.getInt("upload_usr_id")); |
| | | list.add(b); |
| | | //System.out.println(b); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | b.setTest_timelong(rs.getInt(rs.getColumnIndex("test_timelong"))); |
| | | b.setTest_stoptype(rs.getInt(rs.getColumnIndex("test_stoptype"))); |
| | | b.setGroup_vol(rs.getFloat(rs.getColumnIndex("group_vol"))); |
| | | b.setTest_curr(rs.getFloat(rs.getColumnIndex("test_curr"))); |
| | | b.setTest_cap(rs.getFloat(rs.getColumnIndex("test_cap"))); |
| | | b.setMax_monnum(rs.getInt(rs.getColumnIndex("max_monnum"))); |
| | | b.setMax_monvol(rs.getFloat(rs.getColumnIndex("max_monvol"))); |
| | | b.setMin_monnum(rs.getInt(rs.getColumnIndex("min_monnum"))); |
| | | b.setMin_monvol(rs.getFloat(rs.getColumnIndex("min_monvol"))); |
| | | b.setMon_num(rs.getInt(rs.getColumnIndex("mon_num"))); |
| | | b.setMon_vol(rs.getFloat(rs.getColumnIndex("mon_vol"))); |
| | | b.setUpload_usr_id(rs.getInt(rs.getColumnIndex("upload_usr_id"))); |
| | | list.add(b); |
| | | } |
| | | }); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rs.close(); |
| | | return list; |
| | | } |
| | | |
| | | //历史数据查询 |
| | | //根据battfroupid查询历史数据查询 |
| | | public List serchByCondition(SQLiteDatabase db,Object obj) { |
| | | final Batttestdata_inf bti=(Batttestdata_inf)obj; |
| | | String sql="select tb_batttestdata_inf.num,tb_batttestdata_inf.BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id" |
| | | Batttestdata_inf bti=(Batttestdata_inf)obj; |
| | | String sql="select num,BattGroupId,test_record_count,test_record_count_ex,test_type,record_time_interval,data_new,data_available,record_num,test_starttime,test_starttime_ex,test_starttype,record_time,test_timelong,test_stoptype,group_vol,test_curr,test_cap,max_monnum,max_monvol,min_monnum,min_monvol,mon_num,mon_vol,upload_usr_id" |
| | | +" from tb_batttestdata_inf where " |
| | | +" tb_batttestdata_inf.data_available=1 " + |
| | | +" data_available=1 and BattGroupId=? " + |
| | | " order by test_type asc,test_starttime desc "; |
| | | return DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{bti.getBattGroupId()}, new CallBack() { |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | Batttestdata_inf b=new Batttestdata_inf(); |
| | | b.setNum(rs.getInt("num")); |
| | | b.setBattGroupId(rs.getInt("BattGroupId")); |
| | | b.setTest_record_count(rs.getInt("test_record_count")); |
| | | b.setTest_record_count_ex(rs.getInt("test_record_count_ex")); |
| | | b.setTest_type(rs.getInt("test_type")); |
| | | b.setRecord_time_interval(rs.getInt("record_time_interval")); |
| | | b.setData_new(rs.getInt("data_new")); |
| | | b.setData_available(rs.getInt("data_available")); |
| | | b.setRecord_num(rs.getInt("record_num")); |
| | | b.setTest_starttime(rs.getTimestamp("test_starttime")); |
| | | b.setTest_starttime_ex(rs.getTimestamp("test_starttime_ex")); |
| | | b.setTest_starttype(rs.getInt("test_starttype")); |
| | | b.setRecord_time(rs.getTimestamp("record_time")); |
| | | b.setTest_timelong(rs.getInt("test_timelong")); |
| | | b.setTest_stoptype(rs.getInt("test_stoptype")); |
| | | //放电终止原因 |
| | | |
| | | if(bti.getNum()/100000==6185){ |
| | | b.setTest_stoptype_reason(BattTestData.getStopType_6185(b.getTest_stoptype())); |
| | | }else if(bti.getNum()/100000==4016){ |
| | | b.setTest_stoptype_reason(BattTestData.getStopType_4016(b.getTest_stoptype())); |
| | | }else{ |
| | | b.setTest_stoptype_reason(BattTestData.getStopType(b.getTest_starttype(), b.getTest_stoptype())); |
| | | } |
| | | b.setGroup_vol(rs.getFloat("group_vol")); |
| | | b.setTest_curr(rs.getFloat("test_curr")); |
| | | b.setTest_cap(rs.getFloat("test_cap")); |
| | | b.setMax_monnum(rs.getInt("max_monnum")); |
| | | b.setMax_monvol(rs.getFloat("max_monvol")); |
| | | b.setMin_monnum(rs.getInt("min_monnum")); |
| | | b.setMin_monvol(rs.getFloat("min_monvol")); |
| | | b.setMon_num(rs.getInt("mon_num")); |
| | | b.setMon_vol(rs.getFloat("mon_vol")); |
| | | b.setUpload_usr_id(rs.getInt("upload_usr_id")); |
| | | b.setMoncapstd(rs.getFloat("MonCapStd")); |
| | | b.setMonvolstd(rs.getFloat("monvolstd")); |
| | | list.add(b); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | List list=new ArrayList(); |
| | | Cursor rs=db.rawQuery(sql,new String[]{String.valueOf(bti.getBattGroupId())}); |
| | | try { |
| | | while(rs.moveToNext()){ |
| | | Batttestdata_inf b=new Batttestdata_inf(); |
| | | b.setNum(rs.getInt(rs.getColumnIndex("num"))); |
| | | b.setBattGroupId(rs.getInt(rs.getColumnIndex("BattGroupId"))); |
| | | b.setTest_record_count(rs.getInt(rs.getColumnIndex("test_record_count"))); |
| | | b.setTest_record_count_ex(rs.getInt(rs.getColumnIndex("test_record_count_ex"))); |
| | | b.setTest_type(rs.getInt(rs.getColumnIndex("test_type"))); |
| | | b.setRecord_time_interval(rs.getInt(rs.getColumnIndex("record_time_interval"))); |
| | | b.setData_new(rs.getInt(rs.getColumnIndex("data_new"))); |
| | | b.setData_available(rs.getInt(rs.getColumnIndex("data_available"))); |
| | | b.setRecord_num(rs.getInt(rs.getColumnIndex("record_num"))); |
| | | |
| | | b.setTest_starttime(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("test_starttime")))); |
| | | b.setTest_starttime_ex(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("test_starttime_ex")))); |
| | | b.setTest_starttype(rs.getInt(rs.getColumnIndex("test_starttype"))); |
| | | b.setRecord_time(ActionUtil.sdf.parse(rs.getString(rs.getColumnIndex("record_time")))); |
| | | |
| | | b.setTest_timelong(rs.getInt(rs.getColumnIndex("test_timelong"))); |
| | | b.setTest_stoptype(rs.getInt(rs.getColumnIndex("test_stoptype"))); |
| | | b.setGroup_vol(rs.getFloat(rs.getColumnIndex("group_vol"))); |
| | | b.setTest_curr(rs.getFloat(rs.getColumnIndex("test_curr"))); |
| | | b.setTest_cap(rs.getFloat(rs.getColumnIndex("test_cap"))); |
| | | b.setMax_monnum(rs.getInt(rs.getColumnIndex("max_monnum"))); |
| | | b.setMax_monvol(rs.getFloat(rs.getColumnIndex("max_monvol"))); |
| | | b.setMin_monnum(rs.getInt(rs.getColumnIndex("min_monnum"))); |
| | | b.setMin_monvol(rs.getFloat(rs.getColumnIndex("min_monvol"))); |
| | | b.setMon_num(rs.getInt(rs.getColumnIndex("mon_num"))); |
| | | b.setMon_vol(rs.getFloat(rs.getColumnIndex("mon_vol"))); |
| | | b.setUpload_usr_id(rs.getInt(rs.getColumnIndex("upload_usr_id"))); |
| | | list.add(b); |
| | | } |
| | | }); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | rs.close(); |
| | | return list; |
| | | } |
| | | |
| | | public List serchByInfo(SQLiteDatabase db,Object obj) { |
| | |
| | | |
| | | public static void main(String[] args) { |
| | | Batttestdata_infDAOImpl bimpl=new Batttestdata_infDAOImpl(); |
| | | /*List<Batttestdata_inf> list=bimpl.searchAll(); |
| | | for (Batttestdata_inf b:list) { |
| | | System.out.println(b); |
| | | }*/ |
| | | } |
| | | } |
| | |
| | | import com.fgkj.dao.ActionUtil; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.BaseDAOFactory; |
| | | import com.fgkj.dao.DBHelper; |
| | | import com.fgkj.dto.Battinf; |
| | | import com.google.gson.Gson; |
| | | import com.sqlite_DaoHelper.DAOHelper; |
| | |
| | | private BaseDAO dao; |
| | | private ServiceModel model; |
| | | private WebView webView; |
| | | private Gson gson = new Gson(); |
| | | public static final String BATTINFSERVICE_NAME = "BattinfService";//JS调用类名 |
| | | private SQLiteDatabase sqldb; |
| | | private DBHelper dbHelper; |
| | | |
| | | public BattinfService( WebView webView,SQLiteDatabase db) { |
| | | public BattinfService( WebView webView,DBHelper dbHelper) { |
| | | this.dao = BaseDAOFactory.getBaseDAO(BaseDAO.BATTINF); |
| | | this.model = new ServiceModel(); |
| | | this.webView = webView; |
| | | this.sqldb=db; |
| | | this.dbHelper=dbHelper; |
| | | } |
| | | //查询库中存在的所有电池组信息 |
| | | //查询库中存在的所有电池组信息 |
| | | @JavascriptInterface |
| | | public void searchAll() { |
| | | List list=dao.searchAll(sqldb); |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | List list=dao.searchAll(db); |
| | | if(list!=null&&list.size()>0){ |
| | | model.code=1; |
| | | model.data=list; |
| | |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | ActionUtil.SendCallDataToJS("searchAll",model,webView); |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("searchAll",model,webView,ActionUtil.getGson("yyyy-MM-dd")); |
| | | } |
| | | //查询库中插入电池组信息 |
| | | //根据电池组id查询电池组信息 |
| | | @JavascriptInterface |
| | | public void update(Object obj) { |
| | | Battinf binf=ActionUtil.getGson().fromJson((String)obj,Battinf.class); |
| | | boolean bl=dao.update(sqldb,binf); |
| | | public void serchByCondition(String obj) { |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | Battinf binf=ActionUtil.getGson("yyyy-MM-dd").fromJson(obj,Battinf.class); |
| | | List list=dao.serchByCondition(db,binf); |
| | | if(list!=null&&list.size()>0){ |
| | | model.code=1; |
| | | model.data=list; |
| | | model.msg="查询成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("serchByCondition",model,webView,ActionUtil.getGson("yyyy-MM-dd")); |
| | | } |
| | | //根据battgroupid修改电池组信息 |
| | | @JavascriptInterface |
| | | public void update(String obj) { |
| | | // 获取数据库对象 |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | Battinf binf=ActionUtil.getGson("yyyy-MM-dd").fromJson(obj,Battinf.class); |
| | | //List<App_Param> params = getGson().fromJson(json, new TypeToken<List<App_Param>>(){}.getType()); |
| | | boolean bl=dao.update(db,binf); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="修改成功"; |
| | |
| | | model.code=0; |
| | | model.msg="修改失败"; |
| | | } |
| | | ActionUtil.SendCallDataToJS("update",model,webView); |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("update",model,webView,ActionUtil.getGson("yyyy-MM-dd")); |
| | | } |
| | | /* *//** |
| | | * 返回数据给前台js |
| | | * @param funName |
| | | * @param model |
| | | *//* |
| | | public void SendCallDataToJS(String funName,ServiceModel model){ |
| | | String call = "javascript:"+funName+"calljs(" + gson.toJson(model) + ")"; |
| | | new Handler(Looper.getMainLooper()).post(() -> webView.loadUrl(call)); |
| | | }*/ |
| | | //插入数据 |
| | | @JavascriptInterface |
| | | public void add(String obj) { |
| | | // 获取数据库对象 |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | Battinf binf=ActionUtil.getGson("yyyy-MM-dd").fromJson(obj,Battinf.class); |
| | | boolean bl=dao.add(db,binf); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="插入成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="插入失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("add",model,webView,ActionUtil.getGson("yyyy-MM-dd")); |
| | | } |
| | | //根据battgroupid删除信息 |
| | | @JavascriptInterface |
| | | public void del(String obj) { |
| | | // 获取数据库对象 |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | Battinf binf=ActionUtil.getGson("yyyy-MM-dd").fromJson(obj,Battinf.class); |
| | | |
| | | boolean bl=dao.del(db,binf); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="修改成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="修改失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("del",model,webView,ActionUtil.getGson("yyyy-MM-dd")); |
| | | } |
| | | } |
New file |
| | |
| | | package com.fgkj.service; |
| | | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.webkit.JavascriptInterface; |
| | | import android.webkit.WebView; |
| | | |
| | | import com.fgkj.action.ServiceModel; |
| | | import com.fgkj.dao.ActionUtil; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.BaseDAOFactory; |
| | | import com.fgkj.dao.DBHelper; |
| | | import com.fgkj.dto.Battinf; |
| | | import com.fgkj.dto.Batttestdata; |
| | | import com.fgkj.impl.BatttestdataDAOImpl; |
| | | import com.google.gson.reflect.TypeToken; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class BatttestdataService { |
| | | private BaseDAO dao; |
| | | private ServiceModel model; |
| | | private WebView webView; |
| | | public static final String BATTTESTDATASERVICE_NAME = "BatttestdataService";//JS调用类名 |
| | | private DBHelper dbHelper; |
| | | |
| | | public BatttestdataService(WebView webView,DBHelper dbHelper) { |
| | | this.dao = BaseDAOFactory.getBaseDAO(BaseDAO.BATTTESTDATA); |
| | | this.model =new ServiceModel(); |
| | | this.webView = webView; |
| | | this.dbHelper=dbHelper; |
| | | } |
| | | //批量插入修改 |
| | | @JavascriptInterface |
| | | public void updatePro(String obj) { |
| | | // 获取数据库对象 |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | List<Batttestdata> list= ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj, new TypeToken<List<Batttestdata>>(){}.getType()); |
| | | boolean bl=((BatttestdataDAOImpl)dao).updatePro(db,list); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="修改成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="修改失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("updatePro",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | //批量插入放电记录 |
| | | @JavascriptInterface |
| | | public void add(String obj) { |
| | | // 获取数据库对象 |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | List<Batttestdata> list= ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj, new TypeToken<List<Batttestdata>>(){}.getType()); |
| | | boolean bl=dao.add(db,list); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="添加成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="添加失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("add",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | //删除放电记录(battgroupid,test_record_count) |
| | | @JavascriptInterface |
| | | public void delPro(String obj) { |
| | | // 获取数据库对象 |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | List<Batttestdata> list= ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj, new TypeToken<List<Batttestdata>>(){}.getType()); |
| | | boolean bl=((BatttestdataDAOImpl)dao).delPro(db,list); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="删除成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="删除失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("delPro",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | //历史监测根据battgroupid查询 |
| | | @JavascriptInterface |
| | | public void serchByCondition(String obj) { |
| | | SQLiteDatabase db = dbHelper.getWritableDatabase(); |
| | | Batttestdata bdata=ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj,Batttestdata.class); |
| | | List list=((BatttestdataDAOImpl)dao).serchMaxAndMintime(db,bdata); |
| | | if(list!=null&&list.size()>0){ |
| | | Batttestdata b=(Batttestdata)list.get(list.size()-1); |
| | | b.setBattGroupId(bdata.getBattGroupId()); |
| | | b.setTest_record_count(bdata.getTest_record_count()); |
| | | List listT=dao.serchByCondition(db,b); |
| | | if(listT!=null&&listT.size()>0){ |
| | | model.code=1; |
| | | model.data=listT; |
| | | model.msg="查询成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("serchByCondition",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | } |
New file |
| | |
| | | package com.fgkj.service; |
| | | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.webkit.JavascriptInterface; |
| | | import android.webkit.WebView; |
| | | |
| | | import com.fgkj.action.ServiceModel; |
| | | import com.fgkj.dao.ActionUtil; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.BaseDAOFactory; |
| | | import com.fgkj.dao.DBHelper; |
| | | import com.fgkj.dto.Batttestdata_inf; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class Batttestdata_infService { |
| | | private ServiceModel model; |
| | | private BaseDAO dao; |
| | | private WebView webView; |
| | | public static final String BATTTESTDATA_INFSERVICE_NAME = "Batttestdata_infService";//JS调用类名 |
| | | private DBHelper dbHelper; |
| | | |
| | | public Batttestdata_infService(WebView webView,DBHelper dbHelper) { |
| | | this.webView = webView; |
| | | this.dbHelper=dbHelper; |
| | | this.model=new ServiceModel(); |
| | | this.dao= BaseDAOFactory.getBaseDAO(BaseDAO.BATTTESTDATA_INF); |
| | | } |
| | | |
| | | //向batttestdata_inf表中添加数据 |
| | | @JavascriptInterface |
| | | public void add(String obj) { |
| | | SQLiteDatabase db=dbHelper.getWritableDatabase(); |
| | | Batttestdata_inf binf= ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj,Batttestdata_inf.class); |
| | | boolean bl=dao.add(db,binf); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="添加成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="添加失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("add",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | //电池充放电删除记录 |
| | | @JavascriptInterface |
| | | public void del(String obj) { |
| | | SQLiteDatabase db=dbHelper.getWritableDatabase(); |
| | | Batttestdata_inf bti= ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj,Batttestdata_inf.class); |
| | | boolean bl=dao.del(db,bti); |
| | | if(bl){ |
| | | model.code=1; |
| | | model.msg="删除成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="删除失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("del",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | |
| | | //查询所有的充放电信息 |
| | | @JavascriptInterface |
| | | public void searchAll() { |
| | | SQLiteDatabase db=dbHelper.getWritableDatabase(); |
| | | List list=dao.searchAll(db); |
| | | if(list!=null&&list.size()>0){ |
| | | model.code=1; |
| | | model.data=list; |
| | | model.msg="查询成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("searchAll",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | //根据battfroupid查询历史数据查询 |
| | | @JavascriptInterface |
| | | public void serchByCondition(String obj) { |
| | | SQLiteDatabase db=dbHelper.getWritableDatabase(); |
| | | Batttestdata_inf bti= ActionUtil.getGson("yyyy-MM-dd HH:mm:ss").fromJson(obj,Batttestdata_inf.class); |
| | | List list=dao.serchByCondition(db,bti); |
| | | if(list!=null&&list.size()>0){ |
| | | model.code=1; |
| | | model.data=list; |
| | | model.msg="查询成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | db.close(); |
| | | ActionUtil.SendCallDataToJS("serchByCondition",model,webView,ActionUtil.getGson("yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | } |
| | |
| | | */ |
| | | |
| | | public class DAOHelper { |
| | | public static SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | public static SimpleDateFormat sdfwithOut=new SimpleDateFormat("yyyy-MM-dd"); |
| | | public static Date getSimpDate(Date time){ |
| | | //System.out.println(time); |
| | | return new java.sql.Date(time.getTime()); |
| | | } |
| | | |
| | | /** |
| | | * 封装所有更新的操作(添加,删除,修改) |
| | | * @param conn |
| | |
| | | |
| | | import android.database.sqlite.SQLiteDatabase; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.webkit.WebView; |
| | | |
| | | import com.fgkj.action.JsInterface; |
| | | import com.fgkj.dao.DBHelper; |
| | | import com.fgkj.dao.SQLdm; |
| | | import com.fgkj.dto.Batttestdata_inf; |
| | | import com.fgkj.service.BattinfService; |
| | | import com.fgkj.service.BatttestdataService; |
| | | import com.fgkj.service.Batttestdata_infService; |
| | | |
| | | import org.apache.cordova.*; |
| | | |
| | |
| | | |
| | | // Set by <content src="index.html" /> in config.xml |
| | | loadUrl(launchUrl); |
| | | |
| | | SQLdm s = new SQLdm(); |
| | | SQLiteDatabase db = s.openDatabase(getApplicationContext()); |
| | | |
| | | |
| | | |
| | | DBHelper dbHelper=new DBHelper(this,"fbs9600.db", null, 1); |
| | | |
| | | webview = findViewById(appView.getView().getId()); |
| | | // 添加事件 |
| | | webview.addJavascriptInterface(new JsInterface(this, webview,MainActivity.this), JsInterface.JS_INTERFACE_NAME); |
| | | |
| | | webview.addJavascriptInterface(new BattinfService(webview, db),BattinfService.BATTINFSERVICE_NAME); |
| | | |
| | | |
| | | //tb_battinf表的操作 |
| | | webview.addJavascriptInterface(new BattinfService(webview, dbHelper),BattinfService.BATTINFSERVICE_NAME); |
| | | //tb_batttestdata表的操作 |
| | | webview.addJavascriptInterface(new BatttestdataService(webview, dbHelper),BatttestdataService.BATTTESTDATASERVICE_NAME); |
| | | //tb_batttestdata_inf表的操作 |
| | | webview.addJavascriptInterface(new Batttestdata_infService(webview, dbHelper),Batttestdata_infService.BATTTESTDATA_INFSERVICE_NAME); |
| | | } |
| | | |
| | | } |