| | |
| | | package com.fgkj.dao.impl.ram;
|
| | |
|
| | | import java.sql.Connection;
|
| | | import java.sql.PreparedStatement;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | | import java.util.ArrayList;
|
| | |
| | | import com.fgkj.dao.BaseDAO;
|
| | | import com.fgkj.dao.CallBack;
|
| | | import com.fgkj.dao.DAOHelper;
|
| | | import com.fgkj.dao.FBS9100_ComBase;
|
| | | import com.fgkj.dao.UinfDaoFactory;
|
| | | import com.fgkj.db.DBUtil;
|
| | | import com.fgkj.dto.User_log;
|
| | | import com.fgkj.dto.ram.Fbs9100_battparam;
|
| | | import com.fgkj.dto.ram.Fbs9100_sysparam;
|
| | | import com.fgkj.services.User_logService;
|
| | | import com.mysql.fabric.xmlrpc.base.Array;
|
| | |
|
| | | public class Fbs9100_battparamImpl implements BaseDAO,CallBack{
|
| | |
| | | // TODO Auto-generated method stub
|
| | | return false;
|
| | | }
|
| | |
|
| | | //修改参数
|
| | | public boolean update(Object obj) {
|
| | | // TODO Auto-generated method stub
|
| | | return false;
|
| | | Fbs9100_battparam bparam=(Fbs9100_battparam) obj;
|
| | | /*String sql=" update db_ram_db.tb_fbs9100_battparam set STD_CAP=?,STD_RES=?,BattGroupCount=?,EachGroupBattCount=?,MonomerVol=?,GroupVol=?,BattTemp=?,FloatChargeVol=?,FloatChargeCurr=?,OnlineVolLow=?,GroupConnType=? " +
|
| | | " where dev_id=? ";*/
|
| | | String sql=" replace into db_ram_db.tb_fbs9100_battparam(dev_id,dev_ip,STD_CAP,STD_RES,BattGroupCount,EachGroupBattCount,MonomerVol,GroupVol,BattTemp,FloatChargeVol,FloatChargeCurr,OnlineVolLow,GroupConnType) values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
| | | boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{bparam.getDev_id(),bparam.getDev_ip(),bparam.getSTD_CAP(),bparam.getSTD_RES(),bparam.getBattGroupCount(),bparam.getEachGroupBattCount(),bparam.getMonomerVol(),bparam.getGroupVol()
|
| | | ,bparam.getBattTemp(),bparam.getFloatChargeVol(),bparam.getFloatChargeCurr(),bparam.getOnlineVolLow(),bparam.getGroupConnType()});
|
| | | return bl;
|
| | | }
|
| | |
|
| | | //批量设置参数前往表中加入数据
|
| | | public boolean updatePL(Object obj) {
|
| | | Fbs9100_battparam bparam=(Fbs9100_battparam) obj;
|
| | | /*String sql=" update db_ram_db.tb_fbs9100_battparam set STD_CAP=?,STD_RES=?,BattGroupCount=?,EachGroupBattCount=?,MonomerVol=?,GroupVol=?,BattTemp=?,FloatChargeVol=?,FloatChargeCurr=?,OnlineVolLow=?,GroupConnType=? " +
|
| | | " where dev_id=? ";*/
|
| | | String sql=" replace into db_ram_db.tb_fbs9100_battparam(dev_id,op_cmd,dev_ip,STD_CAP,STD_RES,BattGroupCount,EachGroupBattCount,MonomerVol,GroupVol,BattTemp,FloatChargeVol,FloatChargeCurr,OnlineVolLow,GroupConnType) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
| | | boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{bparam.getDev_id(),bparam.getOp_cmd(),bparam.getDev_ip(),bparam.getSTD_CAP(),bparam.getSTD_RES(),bparam.getBattGroupCount(),bparam.getEachGroupBattCount(),bparam.getMonomerVol(),bparam.getGroupVol()
|
| | | ,bparam.getBattTemp(),bparam.getFloatChargeVol(),bparam.getFloatChargeCurr(),bparam.getOnlineVolLow(),bparam.getGroupConnType()});
|
| | | return bl;
|
| | | }
|
| | | //批量修改电池参数
|
| | | public boolean updatePro(Object obj) {
|
| | | List<Fbs9100_battparam> list=(List<Fbs9100_battparam>) obj;
|
| | | ArrayList sql_str=new ArrayList();
|
| | | List<User_log> listU=new ArrayList<User_log>();//存放user_log
|
| | | if(list!=null&&list.size()>0){
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | Fbs9100_battparam fs=list.get(i);
|
| | | String sql="replace into db_ram_db.tb_fbs9100_battparam(dev_id,op_cmd,dev_ip,STD_CAP,STD_RES,BattGroupCount,EachGroupBattCount"
|
| | | + ",MonomerVol,GroupVol,BattTemp,FloatChargeVol,FloatChargeCurr,OnlineVolLow,GroupConnType) "
|
| | | + " values("+fs.getDev_id()+","+fs.getOp_cmd()+",'"+fs.getDev_ip()+"',"+fs.getSTD_CAP()+","+fs.getSTD_RES()+","+fs.getBattGroupCount()+","+fs.getEachGroupBattCount()
|
| | | +","+fs.getMonomerVol()+","+fs.getGroupVol()+","+fs.getBattTemp()+","+fs.getFloatChargeVol()+","+fs.getFloatChargeCurr()+","+fs.getOnlineVolLow()+","+fs.getGroupConnType()+")";
|
| | | sql_str.add(sql);
|
| | | {
|
| | | String msg="修改"+fs.getDev_id()+"电池参数";
|
| | | User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg);
|
| | | listU.add(ulog);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | Boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str);
|
| | | (new User_logService()).addPro(listU);//将用户的操作记录下来
|
| | | return bl;
|
| | | }
|
| | | //批量读取电池参数
|
| | | public boolean readPL(Object obj) {
|
| | | List<Fbs9100_battparam> list=(List<Fbs9100_battparam>) obj;
|
| | | ArrayList sql_str=new ArrayList();
|
| | | List<User_log> listU=new ArrayList<User_log>();//存放user_log
|
| | | if(list!=null&&list.size()>0){
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | Fbs9100_battparam fs=list.get(i);
|
| | | String sql="replace into db_ram_db.tb_fbs9100_battparam(dev_id,op_cmd) "
|
| | | + " values("+fs.getDev_id()+","+fs.getOp_cmd()+")";
|
| | | sql_str.add(sql);
|
| | | {
|
| | | String msg="获取"+fs.getDev_id()+"电池参数";
|
| | | User_log ulog=UinfDaoFactory.CreateULog(UinfDaoFactory.Alter, msg);
|
| | | listU.add(ulog);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | Boolean bl=DAOHelper.makeManualCommit(DBUtil.getConn(), sql_str);
|
| | | (new User_logService()).addPro(listU);//将用户的操作记录下来
|
| | | return bl;
|
| | | }
|
| | | public boolean del(Object obj) {
|
| | | // TODO Auto-generated method stub
|
| | | return false;
|
| | |
| | | //根据设备id查询电池参数信息
|
| | | public List serchByCondition(Object obj) {
|
| | | Fbs9100_battparam bparam=(Fbs9100_battparam) obj;
|
| | | String sql=" select distinct num,dev_ip,dev_id,op_cmd,STD_CAP,STD_RES,BattGroupCount,EachGroupBattCount,MonomerVol,GroupVol,BattTemp,FloatChargeVol,FloatChargeCurr,OnlineVolLow,GroupConnType " +
|
| | | String sql=" select distinct dev_id, dev_ip,op_cmd,STD_CAP,STD_RES,BattGroupCount,EachGroupBattCount,MonomerVol,GroupVol,BattTemp,FloatChargeVol,FloatChargeCurr,OnlineVolLow,GroupConnType " +
|
| | | " ,db_battinf.tb_battinf.DeviceName,StationName,StationName1,StationName2,StationName3,StationName5,StationId " +
|
| | | " from db_ram_db.tb_fbs9100_battparam,db_battinf.tb_battinf " +
|
| | | " where dev_id=? and db_ram_db.tb_fbs9100_battparam.dev_id=db_battinf.tb_battinf.fbsdeviceid" +
|
| | |
| | | try {
|
| | | while(rs.next()){
|
| | | Fbs9100_battparam b=new Fbs9100_battparam();
|
| | | b.setNum(rs.getInt("num"));
|
| | | b.setDev_ip(rs.getString("dev_ip"));
|
| | | b.setDev_id(rs.getInt("dev_id"));
|
| | | b.setOp_cmd(rs.getInt("op_cmd"));
|
| | |
| | | b.setEachGroupBattCount(rs.getInt("eachGroupBattCount"));
|
| | | b.setMonomerVol(rs.getFloat("monomerVol"));
|
| | | b.setGroupVol(rs.getFloat("groupVol"));
|
| | | b.setBattTemp(rs.getFloat("battTemp"));
|
| | | b.setFloatChargeVol(rs.getFloat("floatChargeVol"));
|
| | | b.setFloatChargeCurr(rs.getFloat("floatChargeCurr"));
|
| | | b.setOnlineVolLow(rs.getFloat("onlineVolLow"));
|
| | | b.setGroupConnType(rs.getInt("groupConnType"));
|
| | | b.setDeviceName(rs.getString("deviceName"));
|
| | | b.setStationName(rs.getString("stationName"));
|
| | | b.setStationName1(rs.getString("stationName1"));
|
| | | b.setStationName2(rs.getString("stationName2"));
|
| | | b.setStationName3(rs.getString("stationName3"));
|
| | | b.setStationName5(rs.getString("stationName5"));
|
| | | b.setStationId(rs.getString("stationId"));
|
| | | list.add(b);
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | return null;
|
| | | return list;
|
| | | }
|
| | | });
|
| | | return null;
|
| | | return list;
|
| | | }
|
| | |
|
| | | //电池参数命令操作设备时的cmd和ack校验 |
| | | public boolean sendCmdToBattparam(int cmd,int dev_id)
|
| | | { |
| | | int m_cmd = cmd;
|
| | | int m_cmd_ack = cmd;
|
| | | switch(m_cmd) {
|
| | | case FBS9100_ComBase.CMD_GetBattParam: m_cmd_ack = FBS9100_ComBase.CMD_GetBattParamACK; break;
|
| | | case FBS9100_ComBase.CMD_SetBattParam: m_cmd_ack = FBS9100_ComBase.CMD_SetBattParamACK; break;
|
| | | default: return false;
|
| | | }
|
| | | String sql_end = "";
|
| | | boolean res_exe = false;
|
| | | String sql = "UPDATE db_ram_db.tb_fbs9100_battparam SET "
|
| | | + " op_cmd=? " + sql_end
|
| | | + " WHERE dev_id=? ";
|
| | | Boolean bl=DAOHelper.executeUpdate(DBUtil.getConn(), sql, new Object[]{m_cmd,dev_id});
|
| | | if(true == bl)
|
| | | {
|
| | | sql = "SELECT op_cmd FROM db_ram_db.tb_fbs9100_battparam "+
|
| | | " WHERE dev_id="+dev_id;
|
| | | Connection conn=DBUtil.getConn();
|
| | | PreparedStatement ps = null;
|
| | | ResultSet rs = null;
|
| | | for(int n=0; n<20; n++)
|
| | | {
|
| | | try {
|
| | | ps = conn.prepareStatement(sql);
|
| | | rs=ps.executeQuery();
|
| | | if(rs.next())
|
| | | {
|
| | | if(rs.getInt("op_cmd") == m_cmd_ack)
|
| | | {
|
| | | res_exe = true;
|
| | | break;
|
| | | }
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | try {
|
| | | Thread.sleep(250);
|
| | | } catch (InterruptedException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | DBUtil.close(rs, ps, conn);
|
| | | }
|
| | | return res_exe;
|
| | | }
|
| | | |
| | | //批量设置电池参数成功后读取命令的ACK
|
| | | public boolean getCmdAck(int cmd,int dev_id) {
|
| | | int m_cmd = cmd;
|
| | | int m_cmd_ack = cmd;
|
| | | switch(m_cmd) {
|
| | | case FBS9100_ComBase.CMD_GetBattParam: m_cmd_ack = FBS9100_ComBase.CMD_GetBattParamACK; break;
|
| | | case FBS9100_ComBase.CMD_SetBattParam: m_cmd_ack = FBS9100_ComBase.CMD_SetBattParamACK; break;
|
| | | default: return false;
|
| | | }
|
| | | String sql = "SELECT op_cmd FROM db_ram_db.tb_fbs9100_battparam "+
|
| | | " WHERE dev_id="+dev_id;
|
| | | Connection conn=DBUtil.getConn();
|
| | | PreparedStatement ps = null;
|
| | | ResultSet rs = null;
|
| | | boolean res_exe=false;
|
| | | try {
|
| | | ps = conn.prepareStatement(sql);
|
| | | rs=ps.executeQuery();
|
| | | if(rs.next())
|
| | | {
|
| | | if(rs.getInt("op_cmd") == m_cmd_ack)
|
| | | {
|
| | | res_exe = true;
|
| | | }
|
| | | }
|
| | | } catch (SQLException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | | DBUtil.close(rs, ps, conn);
|
| | | return res_exe;
|
| | | }
|
| | | public List serchByInfo(Object obj) {
|
| | | // TODO Auto-generated method stub
|
| | | return null;
|