| | |
| | | <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
|
| | | <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
|
| | | <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/build/generated/res/resValues/debug" />
|
| | | <option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="" />
|
| | | <option name="TEST_RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" /> |
| | | <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
|
| | | </configuration>
|
| | | </facet>
|
| | |
| | | </content>
|
| | | <orderEntry type="jdk" jdkName="Android API 28 Platform" jdkType="Android SDK" />
|
| | | <orderEntry type="sourceFolder" forTests="false" />
|
| | | <orderEntry type="library" name="Gradle: __local_aars__:D.\GitWorkSpace\FBS9600App\platforms\android\app\src\main\java\com\sqlite_DaoHelper\lib\sqlite-jdbc-3.7.2.jar:unspecified@jar" level="project" /> |
| | | <orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.8.5@jar" level="project" />
|
| | | <orderEntry type="module" module-name="CordovaLib" />
|
| | | </component>
|
| | |
| | | |
| | | |
| | | dependencies { |
| | | implementation fileTree(dir: 'libs', include: '*.jar') |
| | | implementation fileTree(include: '*.jar', dir: 'libs') |
| | | // SUB-PROJECT DEPENDENCIES START |
| | | implementation(project(path: ":CordovaLib")) |
| | | implementation project(path: ':CordovaLib') |
| | | // SUB-PROJECT DEPENDENCIES END |
| | | |
| | | implementation 'com.google.code.gson:gson:2.8.5' |
| | | implementation files('src/main/java/com/sqlite_DaoHelper/lib/sqlite-jdbc-3.7.2.jar') |
| | | } |
| | | |
| | | def promptForReleaseKeyPassword() { |
| | |
| | | public interface BaseDAO { |
| | | |
| | | public static final int BATTTESTDATA_INF = 1; |
| | | public static final int BATTINF=2; |
| | | public static final int BATTTESTDATA=3; |
| | | |
| | | |
| | | public boolean add(Object obj); // 添加 |
| | |
| | | package com.fgkj.dao; |
| | | |
| | | |
| | | import com.fgkj.impl.BattinfImpl; |
| | | import com.fgkj.impl.BatttestdataDAOImpl; |
| | | import com.fgkj.impl.Batttestdata_infDAOImpl; |
| | | |
| | | public class BaseDAOFactory { |
| | |
| | | public static BaseDAO getBaseDAO(int DAOcode){ |
| | | switch(DAOcode){ |
| | | case 1:return new Batttestdata_infDAOImpl(); |
| | | case 2:return new BattinfImpl(); |
| | | case 3:return new BatttestdataDAOImpl(); |
| | | default :return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.fgkj.dto; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | public class Battinf implements Serializable { |
| | | private int num; |
| | | private int BattGroupId; |
| | | private String BattGroupName; |
| | | private String BattGroupName1; |
| | | private double BattFloatCurrent; |
| | | private int MonCount; |
| | | private double MonCapStd; |
| | | private double MonVolStd; |
| | | private double MonResStd; |
| | | private double MonSerStd; |
| | | private double MonTmpStd; |
| | | private String BattProducer; |
| | | private Date BattInUseDate; |
| | | private int station_install; |
| | | |
| | | public int getNum() { |
| | | return num; |
| | | } |
| | | |
| | | public void setNum(int num) { |
| | | this.num = num; |
| | | } |
| | | |
| | | public int getBattGroupId() { |
| | | return BattGroupId; |
| | | } |
| | | |
| | | public void setBattGroupId(int battGroupId) { |
| | | BattGroupId = battGroupId; |
| | | } |
| | | |
| | | public String getBattGroupName() { |
| | | return BattGroupName; |
| | | } |
| | | |
| | | public void setBattGroupName(String battGroupName) { |
| | | BattGroupName = battGroupName; |
| | | } |
| | | |
| | | public String getBattGroupName1() { |
| | | return BattGroupName1; |
| | | } |
| | | |
| | | public void setBattGroupName1(String battGroupName1) { |
| | | BattGroupName1 = battGroupName1; |
| | | } |
| | | |
| | | public double getBattFloatCurrent() { |
| | | return BattFloatCurrent; |
| | | } |
| | | |
| | | public void setBattFloatCurrent(double battFloatCurrent) { |
| | | BattFloatCurrent = battFloatCurrent; |
| | | } |
| | | |
| | | public int getMonCount() { |
| | | return MonCount; |
| | | } |
| | | |
| | | public void setMonCount(int monCount) { |
| | | MonCount = monCount; |
| | | } |
| | | |
| | | public double getMonCapStd() { |
| | | return MonCapStd; |
| | | } |
| | | |
| | | public void setMonCapStd(double monCapStd) { |
| | | MonCapStd = monCapStd; |
| | | } |
| | | |
| | | public double getMonVolStd() { |
| | | return MonVolStd; |
| | | } |
| | | |
| | | public void setMonVolStd(double monVolStd) { |
| | | MonVolStd = monVolStd; |
| | | } |
| | | |
| | | public double getMonResStd() { |
| | | return MonResStd; |
| | | } |
| | | |
| | | public void setMonResStd(double monResStd) { |
| | | MonResStd = monResStd; |
| | | } |
| | | |
| | | public double getMonSerStd() { |
| | | return MonSerStd; |
| | | } |
| | | |
| | | public void setMonSerStd(double monSerStd) { |
| | | MonSerStd = monSerStd; |
| | | } |
| | | |
| | | public double getMonTmpStd() { |
| | | return MonTmpStd; |
| | | } |
| | | |
| | | public void setMonTmpStd(double monTmpStd) { |
| | | MonTmpStd = monTmpStd; |
| | | } |
| | | |
| | | public String getBattProducer() { |
| | | return BattProducer; |
| | | } |
| | | |
| | | public void setBattProducer(String battProducer) { |
| | | BattProducer = battProducer; |
| | | } |
| | | |
| | | public Date getBattInUseDate() { |
| | | return BattInUseDate; |
| | | } |
| | | |
| | | public void setBattInUseDate(Date battInUseDate) { |
| | | BattInUseDate = battInUseDate; |
| | | } |
| | | |
| | | public int getStation_install() { |
| | | return station_install; |
| | | } |
| | | |
| | | public void setStation_install(int station_install) { |
| | | this.station_install = station_install; |
| | | } |
| | | |
| | | @Override |
| | | public String toString() { |
| | | return "Battinf{" + |
| | | "num=" + num + |
| | | ", BattGroupId=" + BattGroupId + |
| | | ", BattGroupName='" + BattGroupName + '\'' + |
| | | ", BattGroupName1='" + BattGroupName1 + '\'' + |
| | | ", BattFloatCurrent=" + BattFloatCurrent + |
| | | ", MonCount=" + MonCount + |
| | | ", MonCapStd=" + MonCapStd + |
| | | ", MonVolStd=" + MonVolStd + |
| | | ", MonResStd=" + MonResStd + |
| | | ", MonSerStd=" + MonSerStd + |
| | | ", MonTmpStd=" + MonTmpStd + |
| | | ", BattProducer='" + BattProducer + '\'' + |
| | | ", BattInUseDate=" + BattInUseDate + |
| | | ", station_install=" + station_install + |
| | | '}'; |
| | | } |
| | | } |
New file |
| | |
| | | package com.fgkj.impl; |
| | | |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dto.Battinf; |
| | | import com.sqlite_DaoHelper.CallBack; |
| | | import com.sqlite_DaoHelper.DAOHelper; |
| | | import com.sqlite_DaoHelper.DBUtil; |
| | | |
| | | 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; |
| | | |
| | | |
| | | public class BattinfImpl implements BaseDAO, CallBack { |
| | | //插入电池组信息 |
| | | @Override |
| | | public boolean add(Object obj) { |
| | | Battinf binf=(Battinf) obj; |
| | | 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; |
| | | } |
| | | //根据battgroupid修改表的数据 |
| | | @Override |
| | | public boolean update(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()}); |
| | | return bl; |
| | | } |
| | | |
| | | @Override |
| | | public boolean del(Object obj) { |
| | | return false; |
| | | } |
| | | //查询库中存在的所有电池组信息 |
| | | @Override |
| | | public List searchAll() { |
| | | String sql=" select * from tb_battinf where station_install=1 order by battgroupid asc "; |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while (rs.next()){ |
| | | Battinf binf=new Battinf(); |
| | | binf.setNum(rs.getInt("num")); |
| | | binf.setBattGroupId(rs.getInt("battgroupid")); |
| | | binf.setBattGroupName(rs.getString("battgroupname")); |
| | | binf.setBattGroupName1(rs.getString("battgroupname1")); |
| | | binf.setBattFloatCurrent(rs.getDouble("BattFloatCurrent")); |
| | | binf.setMonCapStd(rs.getDouble("MonCapStd")); |
| | | binf.setMonVolStd(rs.getDouble("MonVolStd")); |
| | | binf.setMonCount(rs.getInt("MonCount")); |
| | | binf.setMonResStd(rs.getDouble("MonResStd")); |
| | | binf.setMonSerStd(rs.getDouble("MonSerStd")); |
| | | binf.setMonTmpStd(rs.getDouble("MonTmpStd")); |
| | | binf.setBattProducer(rs.getString("BattProducer")); |
| | | binf.setBattInUseDate(rs.getDate("BattInUseDate")); |
| | | binf.setStation_install(rs.getInt("Station_install")); |
| | | list.add(binf); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public List serchByCondition(Object obj) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List serchByInfo(Object obj) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List getResults(ResultSet rs) { |
| | | return null; |
| | | } |
| | | |
| | | public static void main (String[] args) throws ParseException { |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date date1 = sdf.parse("2000-01-01"); |
| | | |
| | | Battinf binf=new Battinf(); |
| | | binf.setBattGroupId(1000002); |
| | | binf.setBattGroupName("电池组2"); |
| | | binf.setBattGroupName1("电池组"); |
| | | binf.setBattFloatCurrent(51.5); |
| | | binf.setMonCapStd(150); |
| | | binf.setMonVolStd(12); |
| | | binf.setMonCount(4); |
| | | binf.setMonResStd(5000); |
| | | binf.setMonSerStd(0.002); |
| | | binf.setMonTmpStd(50.2); |
| | | binf.setBattProducer("理士"); |
| | | binf.setBattInUseDate(DAOHelper.getSimpDate(date1)); |
| | | //System.out.println(DAOHelper.getSimpDate(date1)); |
| | | // System.out.println(binf.getBattInUseDate()); |
| | | binf.setStation_install(1); |
| | | BattinfImpl bimpl=new BattinfImpl(); |
| | | /*boolean bl=bimpl.add(binf); |
| | | System.out.println(bl);*/ |
| | | List<Battinf> list=bimpl.searchAll(); |
| | | for (Battinf b:list |
| | | ) { |
| | | System.out.println(b); |
| | | } |
| | | } |
| | | } |
| | |
| | | return bl; |
| | | } |
| | | |
| | | public boolean updatenew(Object obj) { |
| | | Batttestdata b=(Batttestdata) obj; |
| | | 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=? where num=?"; |
| | | boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{mon_tmp,b.getNum()}); |
| | | return bl; |
| | | } |
| | | |
| | | |
| | | public boolean updatePro(Object obj) { |
| | | List<Batttestdata> list= (List<Batttestdata>) obj; |
| | |
| | | roteN=number/endN+1; |
| | | } |
| | | } |
| | | //System.out.println(number+" "+roteN); |
| | | String sql="select num,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 " + |
| | | " 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)) " + |
| | |
| | | }); |
| | | return list; |
| | | } |
| | | //历史监测<-------跨域-----------> |
| | | public List serchByCondition_ky(Object obj) { |
| | | Batttestdata btd=(Batttestdata)obj; |
| | | int number=btd.getRecord_num();//总数 |
| | | int roteN=0; |
| | | int endN=BattTestData.RC_NUM_PARAM;//总笔数 |
| | | if(number<=endN){ |
| | | roteN=1; |
| | | }else{ |
| | | if(number%endN==0){ |
| | | roteN=number/endN; |
| | | }else{ |
| | | roteN=number/endN+1; |
| | | |
| | | @Override |
| | | public List serchByInfo(Object obj) { |
| | | return null; |
| | | } |
| | | } |
| | | String sql="select num,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 " + |
| | | " from db_batt_testdata.tb_batttestdata_"+btd.getBattGroupId()+"" + |
| | | " where test_record_count=? and (record_num%"+roteN+"=0 or test_timelong>=? or test_timelong<= ?) " + |
| | | " and db_batt_testdata.tb_batttestdata_"+btd.getBattGroupId()+".data_available=1 "; |
| | | 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; |
| | | } |
| | | }); |
| | | return list; |
| | | } |
| | | |
| | | //查询某一次测试中的最大一次的测试时长和最短时长<历史监测> |
| | | public List serchMaxAndMintime(Object obj){ |
| | | Batttestdata btb=(Batttestdata) obj; |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | //查询电池组监测放电中最后三比数据中是否存在二次下电 |
| | | public List serchByInfo(Object obj) { |
| | | List<Batttestdata_inf> list_inf=(List<Batttestdata_inf>) obj; |
| | | List list_all=new ArrayList(); |
| | | for (Batttestdata_inf batt : list_inf) { |
| | | String sql=" select DISTINCT db_batt_testdata.tb_batttestdata_"+batt.getBattGroupId()+".BattGroupId,test_record_count,test_type,test_starttime " |
| | | + " ,stationname,stationname1,stationname2,stationname3,stationname5,GroupIndexInFBSDevice,BattGroupName,StationId,FBSDeviceId " |
| | | + " from db_batt_testdata.tb_batttestdata_"+batt.getBattGroupId()+",db_battinf.tb_battinf " |
| | | + " where db_batt_testdata.tb_batttestdata_"+batt.getBattGroupId()+".BattGroupId=db_battinf.tb_battinf.BattGroupId" |
| | | + " and test_record_count in("+batt.getNote()+")" |
| | | + " and online_vol<40 " |
| | | + " order by test_starttime desc"; |
| | | //System.out.println(sql); |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(), null, new CallBack() { |
| | | |
| | | @Override |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | Batttestdata data=new Batttestdata(); |
| | | data.setBattGroupId(rs.getInt("battGroupId")); |
| | | data.setTest_record_count(rs.getInt("test_record_count")); |
| | | data.setTest_type(rs.getInt("test_type")); |
| | | data.setTest_starttime(rs.getTimestamp("test_starttime")); |
| | | list.add(data); |
| | | } |
| | | } catch (SQLException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | if(list!=null&&list.size()>0){ |
| | | list_all.add(list); |
| | | } |
| | | |
| | | } |
| | | |
| | | return list_all; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | BatttestdataDAOImpl bimpl=new BatttestdataDAOImpl(); |
| | |
| | | public List serchByCondition(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" |
| | | +" from db_batt_testdata.tb_batttestdata_inf where " |
| | | +" db_batt_testdata.tb_batttestdata_inf.data_available=1 " + |
| | | +" from tb_batttestdata_inf where " |
| | | +" tb_batttestdata_inf.data_available=1 " + |
| | | " order by test_type asc,test_starttime desc "; |
| | | return DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{bti.getBattGroupId()}, new CallBack() { |
| | | |
| | |
| | | }); |
| | | } |
| | | |
| | | //6.2根据battgroupi和test_starttime查test_record_count |
| | | public List serchTest_record_count(Object obj) { |
| | | Batttestdata_inf tdata=(Batttestdata_inf)obj; |
| | | String sql="select test_record_count " + |
| | | "from tb_batttestdata_inf where BattGroupId=? and (test_starttime)=(?) " + |
| | | "and tb_batttestdata_inf.data_available=1 "; |
| | | return DAOHelper.executeQuery(sql, DBUtil.getConn(), new Object[]{tdata.getBattGroupId(),tdata.getTest_starttime()}, new CallBack() { |
| | | |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while(rs.next()){ |
| | | Batttestdata_inf tdata=new Batttestdata_inf(); |
| | | |
| | | tdata.setTest_record_count(rs.getInt("test_record_count")); |
| | | list.add(tdata); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |
| | | } |
| | | }); |
| | | } |
| | | //0.7电测放电测试比例 |
| | | public List serchByInfo(Object obj) { |
| | | return null; |
| | | } |
New file |
| | |
| | | package com.fgkj.service; |
| | | |
| | | import android.os.Handler; |
| | | import android.os.Looper; |
| | | import android.webkit.JavascriptInterface; |
| | | import android.webkit.WebView; |
| | | |
| | | import com.fgkj.action.ServiceModel; |
| | | import com.fgkj.dao.BaseDAO; |
| | | import com.fgkj.dao.BaseDAOFactory; |
| | | import com.google.gson.Gson; |
| | | |
| | | import java.util.List; |
| | | |
| | | public class BattinfService { |
| | | private BaseDAO dao; |
| | | private ServiceModel model; |
| | | private WebView webView; |
| | | private Gson gson = new Gson(); |
| | | public static final String BATTINFSERVICE_NAME = "BattinfService";//JS调用类名 |
| | | |
| | | public BattinfService( WebView webView) { |
| | | this.dao = BaseDAOFactory.getBaseDAO(BaseDAO.BATTINF); |
| | | this.model = new ServiceModel(); |
| | | this.webView = webView; |
| | | } |
| | | //查询库中存在的所有电池组信息 |
| | | @JavascriptInterface |
| | | public void searchAll() { |
| | | List list=dao.searchAll(); |
| | | if(list!=null&&list.size()>0){ |
| | | model.code=1; |
| | | model.data=list; |
| | | model.msg="查询成功"; |
| | | }else{ |
| | | model.code=0; |
| | | model.msg="查询失败"; |
| | | } |
| | | SendCallDataToJS("searchAll",model); |
| | | } |
| | | /** |
| | | * 返回数据给前台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)); |
| | | } |
| | | } |
| | |
| | | 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 |
| | |
| | | ps = conn.prepareStatement(sql); |
| | | if(values != null){ |
| | | for (int i = 0; i < values.length; i++) { |
| | | //System.out.println(values[i]); |
| | | ps.setObject(i+1, values[i]); |
| | | } |
| | | } |
| | |
| | | public static List executeQuery(String sql,Connection conn,Object[] values,CallBack call){ |
| | | //System.out.println("释放之前************"); |
| | | //DBUtil.getConnections(); |
| | | System.out.println("connection:"+conn); |
| | | //System.out.println("connection:"+conn); |
| | | PreparedStatement ps = null; |
| | | ResultSet rs = null; |
| | | try { |
| | |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String sql="SELECT * from main.tb_battinf where StationId=? "; |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{"4208555"}, new CallBack() { |
| | | String sql="SELECT * from main.tb_battinf where num=?"; |
| | | List list=DAOHelper.executeQuery(sql, DBUtil.getConn(),new Object[]{6}, new CallBack() { |
| | | @Override |
| | | public List getResults(ResultSet rs) { |
| | | List list=new ArrayList(); |
| | | try { |
| | | while (rs.next()){ |
| | | list.add(rs.getString("StationId")); |
| | | list.add(rs.getInt("FBSDeviceId")); |
| | | list.add(rs.getInt("BattGroupId")); |
| | | list.add(rs.getFloat("MonSerStd")); |
| | | list.add(rs.getDate("BattInUseDate")); |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | |
| | | dbFilePath = path+"/app/src/main/java/com/sqlite_DaoHelper/fbs9600.db"; |
| | | //System.out.println(dbFilePath); |
| | | connection = SqliteHelper.getConnection(dbFilePath); |
| | | // System.out.println(connection); |
| | | } |
| | | /** |
| | | * 获取数据库连接 |
| | |
| | | |
| | | public static void main(String[] args) throws ClassNotFoundException, SQLException{ |
| | | //SqliteHelper.getSqliteHelper(); |
| | | String sql="SELECT * from \"main\".\" tb_battinf \""; |
| | | String sql="SELECT * from tb_battinf "; |
| | | getSqliteHelper(); |
| | | List list=SqliteHelper.executeQuery(sql, connection, null, new CallBack() { |
| | | @Override |
| | |
| | | import android.webkit.WebView; |
| | | |
| | | import com.fgkj.action.JsInterface; |
| | | import com.fgkj.service.BattinfService; |
| | | |
| | | import org.apache.cordova.*; |
| | | |
| | |
| | | webview = findViewById(appView.getView().getId()); |
| | | // 添加事件 |
| | | webview.addJavascriptInterface(new JsInterface(this, webview,MainActivity.this), JsInterface.JS_INTERFACE_NAME); |
| | | |
| | | webview.addJavascriptInterface(new BattinfService(webview), BattinfService.BATTINFSERVICE_NAME); |
| | | |
| | | |
| | | } |
| | | } |