package com.hxzkoa.services;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
import javax.persistence.EntityManager;
|
import javax.persistence.PersistenceContext;
|
import javax.persistence.Query;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.hxzkoa.json.tb_collector;
|
import com.hxzkoa.json.tb_gas;
|
import com.hxzkoa.json.tb_gas_history;
|
import com.hxzkoa.json.tb_tag;
|
import com.hxzkoa.util.Config;
|
import com.hxzkoa.util.ModifyConfig;
|
|
@Service
|
public class GasService {
|
@PersistenceContext
|
private EntityManager em;
|
@Autowired
|
private CaozuoService cs;
|
|
public List<tb_gas> getSensorManagement() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,wei_zhi,gas_type,nong_du,status,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime FROM tb_gas";
|
query = this.em.createNativeQuery(sql);
|
List resultList = query.getResultList();
|
List<tb_gas> tb_gasList = new ArrayList<tb_gas>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas gas = new tb_gas();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas.setId((int) obj[0]);
|
gas.setWei_zhi(obj[1] == null ? "" : obj[1].toString());
|
gas.setGas_type(obj[2] == null ? "" : obj[2].toString());
|
gas.setNong_du(obj[3] == null ? "" : obj[3].toString());
|
gas.setStatus(obj[4] == null ? "" : obj[4].toString());
|
gas.setCollect_ip(obj[5] == null ? "" : obj[5].toString());
|
gas.setTong_dao(obj[6] == null ? "" : obj[6].toString());
|
gas.setWaring_zhi(obj[7] == null ? "" : obj[7].toString());
|
gas.setIp(obj[8] == null ? "" : obj[8].toString());
|
gas.setX(obj[9] == null ? "" : obj[9].toString());
|
gas.setY(obj[10] == null ? "" : obj[10].toString());
|
gas.setAddtime(obj[11] == null ? "" : obj[11].toString());
|
tb_gasList.add(gas);
|
}
|
}
|
return tb_gasList;
|
}
|
|
public List<tb_gas> getSensorManagement(int page) {
|
int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
|
int start = (page - 1) * perPage;
|
int end = perPage;
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,wei_zhi,gas_type,nong_du,status,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime FROM tb_gas LIMIT :start,:end";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("start", start);
|
query.setParameter("end", end);
|
List resultList = query.getResultList();
|
List<tb_gas> tb_gasList = new ArrayList<tb_gas>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas gas = new tb_gas();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas.setId((int) obj[0]);
|
gas.setWei_zhi(obj[1] == null ? "" : obj[1].toString());
|
gas.setGas_type(obj[2] == null ? "" : obj[2].toString());
|
gas.setNong_du(obj[3] == null ? "" : obj[3].toString());
|
gas.setStatus(obj[4] == null ? "" : obj[4].toString());
|
gas.setCollect_ip(obj[5] == null ? "" : obj[5].toString());
|
gas.setTong_dao(obj[6] == null ? "" : obj[6].toString());
|
gas.setWaring_zhi(obj[7] == null ? "" : obj[7].toString());
|
gas.setIp(obj[8] == null ? "" : obj[8].toString());
|
gas.setX(obj[9] == null ? "" : obj[9].toString());
|
gas.setY(obj[10] == null ? "" : obj[10].toString());
|
gas.setAddtime(obj[11] == null ? "" : obj[11].toString());
|
tb_gasList.add(gas);
|
}
|
}
|
return tb_gasList;
|
}
|
|
public int getSensorManagementCount() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT count(1) FROM tb_gas";
|
query = this.em.createNativeQuery(sql);
|
return Integer.parseInt(query.getSingleResult().toString());
|
}
|
|
public List<tb_gas> searchSensorManagement(String input) {
|
int id = Integer.parseInt(input);
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,wei_zhi,gas_type,nong_du,status,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime FROM tb_gas WHERE id = :id";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
List resultList = query.getResultList();
|
List<tb_gas> tb_gasList = new ArrayList<tb_gas>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas gas = new tb_gas();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas.setId((int) obj[0]);
|
gas.setWei_zhi(obj[1] == null ? "" : obj[1].toString());
|
gas.setGas_type(obj[2] == null ? "" : obj[2].toString());
|
gas.setNong_du(obj[3] == null ? "" : obj[3].toString());
|
gas.setStatus(obj[4] == null ? "" : obj[4].toString());
|
gas.setCollect_ip(obj[5] == null ? "" : obj[5].toString());
|
gas.setTong_dao(obj[6] == null ? "" : obj[6].toString());
|
gas.setWaring_zhi(obj[7] == null ? "" : obj[7].toString());
|
gas.setIp(obj[8] == null ? "" : obj[8].toString());
|
gas.setX(obj[9] == null ? "" : obj[9].toString());
|
gas.setY(obj[10] == null ? "" : obj[10].toString());
|
gas.setAddtime(obj[11] == null ? "" : obj[11].toString());
|
tb_gasList.add(gas);
|
}
|
}
|
return tb_gasList;
|
}
|
|
@Transactional
|
public void sensorManagement_delete(String[] checkVal) {
|
String sql = null;
|
Query query = null;
|
for (int i = 0; i < checkVal.length; i++) {
|
int id = Integer.parseInt(checkVal[i]);
|
sql = "DELETE FROM tb_gas WHERE id = :id";
|
cs.tb_caozuo("tb_gas", 2);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
query.executeUpdate();
|
}
|
}
|
|
@Transactional
|
public void sensorManagement_deleteAll() {
|
String sql = null;
|
Query query = null;
|
sql = "DELETE FROM tb_gas";
|
cs.tb_caozuo("tb_gas", 2);
|
query = this.em.createNativeQuery(sql);
|
query.executeUpdate();
|
}
|
|
public List<tb_collector> getcollectorList() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT macid,ip,macname FROM tb_collector";
|
query = this.em.createNativeQuery(sql);
|
List resultList = query.getResultList();
|
List<tb_collector> tb_collectorList = new ArrayList<tb_collector>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_collector collector = new tb_collector();
|
Object[] obj = (Object[]) resultList.get(i);
|
collector.setMacid((int) obj[0]);
|
collector.setIp(obj[1] == null ? "" : obj[1].toString());
|
collector.setMacname(obj[2] == null ? "" : obj[2].toString());
|
tb_collectorList.add(collector);
|
}
|
}
|
return tb_collectorList;
|
}
|
|
public List<tb_collector> getmacName(String gasMacid) {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macname FROM tb_collector WHERE macid = :id ";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", gasMacid);
|
List resultList = query.getResultList();
|
List<tb_collector> tb_collectorList = new ArrayList<tb_collector>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_collector gas = new tb_collector();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas.setMacname(obj[1] == null ? "" : obj[1].toString());
|
tb_collectorList.add(gas);
|
}
|
}
|
return tb_collectorList;
|
}
|
|
@Transactional
|
public int sensorManagement_add(tb_gas gas) {
|
String sql = null;
|
Query query = null;
|
sql = "INSERT INTO tb_gas(id,gas_type,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime,wei_zhi,nong_du,status) VALUES(:id,:gas_type,:collect_ip,:tong_dao,:waring_zhi,:ip,:x,:y,now(),:wei_zhi,:nong_du,:status)";
|
cs.tb_caozuo("tb_gas", 1);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", gas.getId());
|
query.setParameter("gas_type", gas.getGas_type());
|
query.setParameter("collect_ip", gas.getCollect_ip());
|
query.setParameter("tong_dao", gas.getTong_dao());
|
query.setParameter("waring_zhi", gas.getWaring_zhi());
|
query.setParameter("ip", gas.getIp());
|
query.setParameter("x", gas.getX());
|
query.setParameter("y", gas.getY());
|
query.setParameter("nong_du", "0");
|
query.setParameter("status", "正常");
|
query.setParameter("wei_zhi", gas.getWei_zhi());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
@Transactional
|
public int sensor_exist(String id) {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT count(1) FROM tb_gas WHERE id= :id";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
return Integer.parseInt(query.getSingleResult().toString());
|
}
|
|
@Transactional
|
public int sensorManagement_modify(tb_gas gas) {
|
String sql = null;
|
Query query = null;
|
sql = "UPDATE tb_gas SET gas_type = :gas_type,collect_ip = :collect_ip,tong_dao = :tong_dao,waring_zhi = :waring_zhi,ip = :ip,x = :x,y = :y,wei_zhi = :wei_zhi,addtime = now() WHERE id= :id";
|
cs.tb_caozuo("tb_gas", 3);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", gas.getId());
|
query.setParameter("gas_type", gas.getGas_type());
|
query.setParameter("collect_ip", gas.getCollect_ip());
|
query.setParameter("tong_dao", gas.getTong_dao());
|
query.setParameter("waring_zhi", gas.getWaring_zhi());
|
query.setParameter("ip", gas.getIp());
|
query.setParameter("x", gas.getX());
|
query.setParameter("y", gas.getY());
|
query.setParameter("wei_zhi", gas.getWei_zhi());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
public List<tb_gas_history> getHistoricalDetection() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macid,name,type,x,y,deep,waring,addtime FROM tb_gas_history";
|
query = this.em.createNativeQuery(sql);
|
List resultList = query.getResultList();
|
List<tb_gas_history> tb_gas_historyList = new ArrayList<tb_gas_history>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas_history gas_history = new tb_gas_history();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas_history.setId((int) obj[0]);
|
gas_history.setMacid(obj[1] == null ? "" : obj[1].toString());
|
gas_history.setName(obj[2] == null ? "" : obj[2].toString());
|
gas_history.setType(obj[3] == null ? "" : obj[3].toString());
|
gas_history.setX((int) obj[4]);
|
gas_history.setY((int) obj[5]);
|
gas_history.setDeep(obj[6] == null ? "" : obj[6].toString());
|
gas_history.setWaring(obj[7] == null ? "" : obj[7].toString());
|
gas_history.setAddtime(obj[8] == null ? "" : obj[8].toString());
|
tb_gas_historyList.add(gas_history);
|
}
|
}
|
return tb_gas_historyList;
|
}
|
|
public List<tb_gas_history> getHistoricalDetection(int page) {
|
int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
|
int start = (page - 1) * perPage;
|
int end = perPage;
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macid,name,type,x,y,deep,waring,addtime FROM tb_gas_history LIMIT :start,:end";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("start", start);
|
query.setParameter("end", end);
|
List resultList = query.getResultList();
|
List<tb_gas_history> tb_gas_historyList = new ArrayList<tb_gas_history>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas_history gas_history = new tb_gas_history();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas_history.setId((int) obj[0]);
|
gas_history.setMacid(obj[1] == null ? "" : obj[1].toString());
|
gas_history.setName(obj[2] == null ? "" : obj[2].toString());
|
gas_history.setType(obj[3] == null ? "" : obj[3].toString());
|
gas_history.setX(obj[4] == null ? (int)-1 :(int) obj[4]);
|
gas_history.setY(obj[5] == null ? (int)-1 :(int) obj[5]);
|
gas_history.setDeep(obj[6] == null ? "" : obj[6].toString());
|
gas_history.setWaring(obj[7] == null ? "" : obj[7].toString());
|
gas_history.setAddtime(obj[8] == null ? "" : obj[8].toString());
|
tb_gas_historyList.add(gas_history);
|
}
|
}
|
return tb_gas_historyList;
|
}
|
|
public List<tb_gas_history> searchHistoricalDetection(String input) {
|
int id = Integer.parseInt(input);
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macid,name,type,x,y,deep,waring,addtime FROM tb_gas_history WHERE id = :id";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
List resultList = query.getResultList();
|
List<tb_gas_history> tb_gas_historyList = new ArrayList<tb_gas_history>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas_history gas_history = new tb_gas_history();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas_history.setId((int) obj[0]);
|
gas_history.setMacid(obj[1] == null ? "" : obj[1].toString());
|
gas_history.setName(obj[2] == null ? "" : obj[2].toString());
|
gas_history.setType(obj[3] == null ? "" : obj[3].toString());
|
gas_history.setX((int) obj[4]);
|
gas_history.setY((int) obj[5]);
|
gas_history.setDeep(obj[6] == null ? "" : obj[6].toString());
|
gas_history.setWaring(obj[7] == null ? "" : obj[7].toString());
|
gas_history.setAddtime(obj[8] == null ? "" : obj[8].toString());
|
tb_gas_historyList.add(gas_history);
|
}
|
}
|
return tb_gas_historyList;
|
}
|
|
public int getHistoricalDetectionCount() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT count(1) FROM tb_gas_history";
|
query = this.em.createNativeQuery(sql);
|
return Integer.parseInt(query.getSingleResult().toString());
|
}
|
|
@Transactional
|
public void historicalDetection_delete(String[] checkVal) {
|
String sql = null;
|
Query query = null;
|
for (int i = 0; i < checkVal.length; i++) {
|
int id = Integer.parseInt(checkVal[i]);
|
sql = "DELETE FROM tb_gas_history WHERE id = :id";
|
cs.tb_caozuo("tb_gas_history", 2);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
query.executeUpdate();
|
}
|
}
|
|
@Transactional
|
public void historicalDetection_deleteAll() {
|
String sql = null;
|
Query query = null;
|
sql = "DELETE FROM tb_gas_history";
|
cs.tb_caozuo("tb_gas_history", 2);
|
query = this.em.createNativeQuery(sql);
|
query.executeUpdate();
|
}
|
|
public List<tb_collector> getCollectorManagement() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macid,startip,datlenth,ip,macname,posx,posy,addtime FROM tb_collector";
|
query = this.em.createNativeQuery(sql);
|
List resultList = query.getResultList();
|
List<tb_collector> tb_collectorList = new ArrayList<tb_collector>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_collector collector = new tb_collector();
|
Object[] obj = (Object[]) resultList.get(i);
|
collector.setId((int) obj[0]);
|
collector.setMacid((int) obj[1]);
|
collector.setStartip((int) obj[2]);
|
collector.setDatlenth((int) obj[3]);
|
collector.setIp(obj[4] == null ? "" : obj[4].toString());
|
collector.setMacname(obj[5] == null ? "" : obj[5].toString());
|
collector.setPosx((int) obj[6]);
|
collector.setPosy((int) obj[7]);
|
collector.setAddtime((Date) obj[8]);
|
tb_collectorList.add(collector);
|
}
|
}
|
return tb_collectorList;
|
}
|
|
public List<tb_collector> getCollectorManagement(int page) {
|
int perPage = Integer.parseInt(ModifyConfig.readData(Config.getPageConfig(), "perPage"));
|
int start = (page - 1) * perPage;
|
int end = perPage;
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macid,startip,datlenth,ip,macname,posx,posy,addtime FROM tb_collector LIMIT :start,:end";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("start", start);
|
query.setParameter("end", end);
|
List resultList = query.getResultList();
|
List<tb_collector> tb_collectorList = new ArrayList<tb_collector>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_collector collector = new tb_collector();
|
Object[] obj = (Object[]) resultList.get(i);
|
collector.setId((int) obj[0]);
|
collector.setMacid((int) obj[1]);
|
collector.setStartip((int) obj[2]);
|
collector.setDatlenth((int) obj[3]);
|
collector.setIp(obj[4] == null ? "" : obj[4].toString());
|
collector.setMacname(obj[5] == null ? "" : obj[5].toString());
|
collector.setPosx((int) obj[6]);
|
collector.setPosy((int) obj[7]);
|
collector.setAddtime((Date) obj[8]);
|
tb_collectorList.add(collector);
|
}
|
}
|
return tb_collectorList;
|
}
|
|
public List<tb_collector> searchCollectorManagement(String input) {
|
|
int id = Integer.parseInt(input);
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,macid,startip,datlenth,ip,macname,posx,posy,addtime FROM tb_collector WHERE id = :id";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
List resultList = query.getResultList();
|
List<tb_collector> tb_collectorList = new ArrayList<tb_collector>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_collector collector = new tb_collector();
|
Object[] obj = (Object[]) resultList.get(i);
|
collector.setId((int) obj[0]);
|
collector.setMacid((int) obj[1]);
|
collector.setStartip((int) obj[2]);
|
collector.setDatlenth((int) obj[3]);
|
collector.setIp(obj[4] == null ? "" : obj[4].toString());
|
collector.setMacname(obj[5] == null ? "" : obj[5].toString());
|
collector.setPosx((int) obj[6]);
|
collector.setPosy((int) obj[7]);
|
collector.setAddtime((Date) obj[8]);
|
tb_collectorList.add(collector);
|
}
|
}
|
return tb_collectorList;
|
}
|
|
public int getCollectorManagementCount() {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT count(1) FROM tb_collector";
|
query = this.em.createNativeQuery(sql);
|
return Integer.parseInt(query.getSingleResult().toString());
|
}
|
|
@Transactional
|
public void collectorManagement_delete(String[] checkVal) {
|
String sql = null;
|
Query query = null;
|
for (int i = 0; i < checkVal.length; i++) {
|
int id = Integer.parseInt(checkVal[i]);
|
sql = "DELETE FROM tb_collector WHERE id = :id";
|
cs.tb_caozuo("tb_collector", 2);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", id);
|
query.executeUpdate();
|
}
|
}
|
|
@Transactional
|
public void collectorManagement_deleteAll() {
|
String sql = null;
|
Query query = null;
|
sql = "DELETE FROM tb_collector";
|
cs.tb_caozuo("tb_collector", 2);
|
query = this.em.createNativeQuery(sql);
|
query.executeUpdate();
|
}
|
|
@Transactional
|
public int collectorManagement_add(tb_collector collector) {
|
String sql = null;
|
Query query = null;
|
sql = "INSERT INTO tb_collector(macid,startip,datlenth,ip,macname,posx,posy,addtime) VALUES(:macid,:startip,:datlenth,:ip,:macname,:posx,:posy,now())";
|
cs.tb_caozuo("tb_collector", 1);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("macid", collector.getMacid());
|
query.setParameter("startip", collector.getStartip());
|
query.setParameter("datlenth", collector.getDatlenth());
|
query.setParameter("ip", collector.getIp());
|
query.setParameter("macname", collector.getMacname());
|
query.setParameter("posx", collector.getPosx());
|
query.setParameter("posy", collector.getPosy());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
|
@Transactional
|
public int collectorManagement_modify(tb_collector collector) {
|
String sql = null;
|
Query query = null;
|
sql = "UPDATE tb_collector SET macid = :macid,startip = :startip,datlenth = :datlenth,ip = :ip,macname = :macname,posx = :posx,posy = :posy,addtime = now() WHERE id= :id";
|
cs.tb_caozuo("tb_collector", 3);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", collector.getId());
|
query.setParameter("macid", collector.getMacid());
|
query.setParameter("startip", collector.getStartip());
|
query.setParameter("datlenth", collector.getDatlenth());
|
query.setParameter("ip", collector.getIp());
|
query.setParameter("macname", collector.getMacname());
|
query.setParameter("posx", collector.getPosx());
|
query.setParameter("posy", collector.getPosy());
|
int executeUpdate = query.executeUpdate();
|
return executeUpdate;
|
}
|
|
/**获取某个采集仪所占用的通道数意思就是安装了几个气体传感器*/
|
@Transactional
|
public int getGasNumber(String ip) {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT count(1) FROM tb_gas WHERE ip = :ip";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("ip", ip);
|
return Integer.parseInt(query.getSingleResult().toString());
|
}
|
|
public List<tb_gas> getGas(String tong_dao ,String ip ) {
|
String sql = null;
|
Query query = null;
|
sql = "SELECT id,wei_zhi,gas_type,nong_du,status,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime FROM tb_gas WHERE ip=:ip AND tong_dao=:tong_dao ";
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("ip", ip);
|
query.setParameter("tong_dao", tong_dao);
|
List resultList = query.getResultList();
|
List<tb_gas> tb_gasList = new ArrayList<tb_gas>();
|
if (resultList.size() > 0) {
|
for (int i = 0; i < resultList.size(); i++) {
|
tb_gas gas = new tb_gas();
|
Object[] obj = (Object[]) resultList.get(i);
|
gas.setId((int) obj[0]);
|
gas.setWei_zhi(obj[1] == null ? "" : obj[1].toString());
|
gas.setGas_type(obj[2] == null ? "" : obj[2].toString());
|
gas.setNong_du(obj[3] == null ? "" : obj[3].toString());
|
gas.setStatus(obj[4] == null ? "" : obj[4].toString());
|
gas.setCollect_ip(obj[5] == null ? "" : obj[5].toString());
|
gas.setTong_dao(obj[6] == null ? "" : obj[6].toString());
|
gas.setWaring_zhi(obj[7] == null ? "" : obj[7].toString());
|
gas.setIp(obj[8] == null ? "" : obj[8].toString());
|
gas.setX(obj[9] == null ? "" : obj[9].toString());
|
gas.setY(obj[10] == null ? "" : obj[10].toString());
|
gas.setAddtime(obj[11] == null ? "" : obj[11].toString());
|
tb_gasList.add(gas);
|
}
|
}
|
return tb_gasList;
|
}
|
|
@Transactional
|
public void modifyWarning(tb_gas gas) {
|
String sql = null;
|
Query query = null;
|
sql = "UPDATE tb_gas SET status = :status,nong_du=:nong_du,addtime=now() WHERE id= :id";
|
cs.tb_caozuo("tb_gas", 3);
|
query = this.em.createNativeQuery(sql);
|
query.setParameter("id", gas.getId());
|
query.setParameter("status", gas.getStatus());
|
query.setParameter("nong_du", gas.getNong_du());
|
query.executeUpdate();
|
}
|
|
|
}
|