From 57dc08a1404b2fdf60e1ac2446eba9c7d8eca72f Mon Sep 17 00:00:00 2001 From: zhangnaisong <2434969829@qq.com> Date: 星期三, 10 一月 2024 14:07:26 +0800 Subject: [PATCH] 兴趣点动静态数据查询加入所属部门提交 --- ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java | 493 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 493 insertions(+), 0 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java index 70182f0..6970cce 100644 --- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java +++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java @@ -1,7 +1,10 @@ package com.ruoyi.alarmpoints.well.service.impl; +import java.sql.*; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; @@ -9,9 +12,12 @@ import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo; import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellParam; +import com.ruoyi.alarmpoints.well.domain.RTU_DATA_YJ_8; import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper; import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService; import com.ruoyi.common.annotation.DataScope; +import com.ruoyi.common.core.domain.entity.SysConfig; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.DateUtils; @@ -20,6 +26,8 @@ import com.ruoyi.common.utils.bean.BeanValidators; import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.uuid.IdUtils; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.utils.data.Query; import com.ruoyi.utils.gis.GisUtil; import lombok.ToString; import org.slf4j.Logger; @@ -44,6 +52,9 @@ private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; @Autowired protected Validator validator; + + @Resource + protected SysDeptMapper sysDeptMapper; /** * 鏌ヨ浜曠鐞� @@ -326,4 +337,486 @@ } return nearbyWellList; } + + @Override + public Map<String, Object> getWellDataByWellId(String wellId, List<SysConfig> config) { + ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.selectArdAlarmpointsWellByWellId(wellId); + Map<String,Object> result = new HashMap(); + if(ardAlarmpointsWell.getWellId() != null){ + result.put("wellId",ardAlarmpointsWell.getWellId()); + }else{ + result.put("wellId",""); + } + if(ardAlarmpointsWell.getWellNumber() != null){ + result.put("wellNumber",ardAlarmpointsWell.getWellNumber()); + }else{ + result.put("wellNumber",""); + } + if(ardAlarmpointsWell.getOilProduction() != null){ + result.put("oilProduction",ardAlarmpointsWell.getOilProduction()); + }else{ + result.put("oilProduction",""); + } + if(ardAlarmpointsWell.getWellBlock() != null){ + result.put("wellBlock",ardAlarmpointsWell.getWellBlock()); + }else{ + result.put("wellBlock",""); + } + if(ardAlarmpointsWell.getProductionDate() != null){ + result.put("productionDate",ardAlarmpointsWell.getProductionDate()); + }else{ + result.put("productionDate",""); + } + if(ardAlarmpointsWell.getDisplacementMode() != null){ + result.put("displacementMode",ardAlarmpointsWell.getDisplacementMode()); + }else{ + result.put("displacementMode",""); + } + if(ardAlarmpointsWell.getSurroundingEnvironment() != null){ + result.put("surroundingEnvironment",ardAlarmpointsWell.getSurroundingEnvironment()); + }else{ + result.put("surroundingEnvironment",""); + } + if(ardAlarmpointsWell.getWellType() != null){ + result.put("wellType",ardAlarmpointsWell.getWellType()); + }else{ + result.put("wellType",""); + } + if(ardAlarmpointsWell.getInstalledLoad() != null){ + result.put("installedLoad",ardAlarmpointsWell.getInstalledLoad()); + }else{ + result.put("installedLoad",""); + } + if(ardAlarmpointsWell.getMeteringStation() != null){ + result.put("meteringStation",ardAlarmpointsWell.getMeteringStation()); + }else{ + result.put("meteringStation",""); + } + if(ardAlarmpointsWell.getTransferStation() != null){ + result.put("transferStation",ardAlarmpointsWell.getTransferStation()); + }else{ + result.put("transferStation",""); + } + if(ardAlarmpointsWell.getDehydrationStation() != null){ + result.put("dehydrationStation",ardAlarmpointsWell.getDehydrationStation()); + }else{ + result.put("dehydrationStation",""); + } + if(ardAlarmpointsWell.getRunStatus() != null){ + result.put("runStatus",ardAlarmpointsWell.getRunStatus()); + }else{ + result.put("runStatus",""); + } + if(ardAlarmpointsWell.getLongitude() != null){ + result.put("longitude",ardAlarmpointsWell.getLongitude()); + }else{ + result.put("longitude",""); + } + if(ardAlarmpointsWell.getLatitude() != null){ + result.put("latitude",ardAlarmpointsWell.getLatitude()); + }else{ + result.put("latitude",""); + } + if(ardAlarmpointsWell.getAltitude() != null){ + result.put("altitude",ardAlarmpointsWell.getAltitude()); + }else{ + result.put("altitude",""); + } + if(ardAlarmpointsWell.getUserId() != null){ + result.put("userId",ardAlarmpointsWell.getUserId()); + }else{ + result.put("userId",""); + } + if(ardAlarmpointsWell.getDeptId() != null){ + result.put("deptId",ardAlarmpointsWell.getDeptId()); + SysDept sysDept = sysDeptMapper.selectDeptById(ardAlarmpointsWell.getDeptId());//鏌ヨ鍏磋叮鐐规墍鍦ㄩ儴闂� + if(sysDept != null){ + result.put("deptName",sysDept.getDeptName()); + }else{ + result.put("deptName",""); + } + }else{ + result.put("deptId",""); + result.put("deptName",""); + } + if(ardAlarmpointsWell.getCreateBy() != null){ + result.put("createBy",ardAlarmpointsWell.getCreateBy()); + }else{ + result.put("createBy",""); + } + if(ardAlarmpointsWell.getCreateTime() != null){ + result.put("createTime",ardAlarmpointsWell.getCreateTime()); + }else{ + result.put("createTime",""); + } + if(ardAlarmpointsWell.getUpdateBy() != null){ + result.put("updateBy",ardAlarmpointsWell.getUpdateBy()); + }else{ + result.put("updateBy",""); + } + if(ardAlarmpointsWell.getUpdateTime() != null){ + result.put("updateTime",ardAlarmpointsWell.getUpdateTime()); + }else{ + result.put("updateTime",""); + } + if(ardAlarmpointsWell.getGuideP1() != null){ + result.put("guideP1",ardAlarmpointsWell.getGuideP1()); + }else{ + result.put("guideP1",""); + } + if(ardAlarmpointsWell.getGuideP2() != null){ + result.put("guideP2",ardAlarmpointsWell.getGuideP2()); + }else{ + result.put("guideP2",""); + } + if(ardAlarmpointsWell.getGuideT1() != null){ + result.put("guideT1",ardAlarmpointsWell.getGuideT1()); + }else{ + result.put("guideT1",""); + } + if(ardAlarmpointsWell.getGuideT2() != null){ + result.put("guideT2",ardAlarmpointsWell.getGuideT2()); + }else{ + result.put("guideT2",""); + } + if(ardAlarmpointsWell.getGuideZ1() != null){ + result.put("guideZ1",ardAlarmpointsWell.getGuideZ1()); + }else{ + result.put("guideZ1",""); + } + if(ardAlarmpointsWell.getGuideZ2() != null){ + result.put("guideZ2",ardAlarmpointsWell.getGuideZ2()); + }else{ + result.put("guideZ2",""); + } + if(config.size() != 0){ + String oracle = config.get(0).getConfigValue(); + String[] oracleArr = oracle.split(";"); + if(oracleArr.length == 3){ + String url = oracle.split(";")[0]; + String username = oracle.split(";")[1]; + String password = oracle.split(";")[2]; + try { + int checkMark = checkTable(url,username,password,"\'RTU_DATA_YJ_8\'");//涓夊巶琛ㄥ瓨鍦� + if(checkMark == 1){ + Map<String,Object> resultRTU = getRtuDataYjByJH(url,username,password,"RTU_DATA_YJ_8","\'" + wellId + "\'"); + result.putAll(resultRTU); + }else{ + result.put("wellRunningState", "n");//娌逛簳杩愯鐘舵�� + result.put("totalPowerConsumption", "n");//鎬昏�楃數閲� + result.put("communicationMachine", "n");//璁惧閫氳 + result.put("remark", "n");//澶囨敞 + result.put("singleWellWaterTemperature", "n");//鍗曚簳鎺烘按娓╁害// + result.put("meteringPlantWaterPressure", "n");//璁¢噺闂存幒姘村帇鍔�// + result.put("torque", "n");//鎵煩 + result.put("MAT", "n");//鍥炴补娓╁害 + result.put("TGP", "n");//浜曞彛娌瑰帇 + result.put("CPV", "n");//浜曞彛濂楀帇 + result.put("ADL", "n");//A鐩哥數娴� + result.put("ADY", "n");//A鐩哥數鍘� + result.put("BDL", "n");//B鐩哥數娴� + result.put("BDY", "n");//B鐩哥數鍘� + result.put("CDL", "n");//C鐩哥數娴� + result.put("CDY", "n");//C鐩哥數鍘� + result.put("UCV", "n");//涓婅鐢垫祦 + result.put("DCV", "n");//涓嬭鐢垫祦 + result.put("SLV", "n");//鍐茬▼ + result.put("CHC", "n");//鍐叉 + result.put("BPV", "n");//浜曞彛鍥炲帇 + result.put("ZWG", "n");//鎬绘棤鍔熷姛鐜� + result.put("ZYG", "n");//鎬绘湁鍔熷姛鐜� + result.put("GYS", "n");//鍔熺巼鍥犳暟 + result.put("UWL", "n");//鏈�澶ц浇鑽� + result.put("DWL", "n");//鏈�灏忚浇鑽� + result.put("ZHS", "n");//杞�� + } + } catch (Exception e) { + e.printStackTrace(); + } + }else if(oracleArr.length == 4){ + String url = oracle.split(";")[0]; + String username = oracle.split(";")[1]; + String password = oracle.split(";")[2]; + String prod = oracle.split(";")[3]; + try { + //int checkMark = checkTable(url,username,password,"\'RTU_DATA_YJ_8\'");//涓夊巶琛ㄥ瓨鍦� + int checkMark = checkTable(url,username,password,"\'" + prod + ".RTU_DATA_YJ_8\'");//涓夊巶琛ㄥ瓨鍦� + if(checkMark == 1){ + Map<String,Object> resultRTU = getRtuDataYjByJH(url,username,password,prod + ".RTU_DATA_YJ_8","\'" + wellId + "\'"); + result.putAll(resultRTU); + }else{ + result.put("wellRunningState", "n");//娌逛簳杩愯鐘舵�� + result.put("totalPowerConsumption", "n");//鎬昏�楃數閲� + result.put("communicationMachine", "n");//璁惧閫氳 + result.put("remark", "n");//澶囨敞 + result.put("singleWellWaterTemperature", "n");//鍗曚簳鎺烘按娓╁害// + result.put("meteringPlantWaterPressure", "n");//璁¢噺闂存幒姘村帇鍔�// + result.put("torque", "n");//鎵煩 + result.put("MAT", "n");//鍥炴补娓╁害 + result.put("TGP", "n");//浜曞彛娌瑰帇 + result.put("CPV", "n");//浜曞彛濂楀帇 + result.put("ADL", "n");//A鐩哥數娴� + result.put("ADY", "n");//A鐩哥數鍘� + result.put("BDL", "n");//B鐩哥數娴� + result.put("BDY", "n");//B鐩哥數鍘� + result.put("CDL", "n");//C鐩哥數娴� + result.put("CDY", "n");//C鐩哥數鍘� + result.put("UCV", "n");//涓婅鐢垫祦 + result.put("DCV", "n");//涓嬭鐢垫祦 + result.put("SLV", "n");//鍐茬▼ + result.put("CHC", "n");//鍐叉 + result.put("BPV", "n");//浜曞彛鍥炲帇 + result.put("ZWG", "n");//鎬绘棤鍔熷姛鐜� + result.put("ZYG", "n");//鎬绘湁鍔熷姛鐜� + result.put("GYS", "n");//鍔熺巼鍥犳暟 + result.put("UWL", "n");//鏈�澶ц浇鑽� + result.put("DWL", "n");//鏈�灏忚浇鑽� + result.put("ZHS", "n");//杞�� + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }else{ + result.put("wellRunningState", "n");//娌逛簳杩愯鐘舵�� + result.put("totalPowerConsumption", "n");//鎬昏�楃數閲� + result.put("communicationMachine", "n");//璁惧閫氳 + result.put("remark", "n");//澶囨敞 + result.put("singleWellWaterTemperature", "n");//鍗曚簳鎺烘按娓╁害// + result.put("meteringPlantWaterPressure", "n");//璁¢噺闂存幒姘村帇鍔�// + result.put("torque", "n");//鎵煩 + result.put("MAT", "n");//鍥炴补娓╁害 + result.put("TGP", "n");//浜曞彛娌瑰帇 + result.put("CPV", "n");//浜曞彛濂楀帇 + result.put("ADL", "n");//A鐩哥數娴� + result.put("ADY", "n");//A鐩哥數鍘� + result.put("BDL", "n");//B鐩哥數娴� + result.put("BDY", "n");//B鐩哥數鍘� + result.put("CDL", "n");//C鐩哥數娴� + result.put("CDY", "n");//C鐩哥數鍘� + result.put("UCV", "n");//涓婅鐢垫祦 + result.put("DCV", "n");//涓嬭鐢垫祦 + result.put("SLV", "n");//鍐茬▼ + result.put("CHC", "n");//鍐叉 + result.put("BPV", "n");//浜曞彛鍥炲帇 + result.put("ZWG", "n");//鎬绘棤鍔熷姛鐜� + result.put("ZYG", "n");//鎬绘湁鍔熷姛鐜� + result.put("GYS", "n");//鍔熺巼鍥犳暟 + result.put("UWL", "n");//鏈�澶ц浇鑽� + result.put("DWL", "n");//鏈�灏忚浇鑽� + result.put("ZHS", "n");//杞�� + } + return result; + } + + public int checkTable(String url,String username,String password,String tableName) throws ClassNotFoundException, SQLException { + Connection connection = null; + + Statement updateStatement = null; + + Statement queryStatement = null; + + try { + Class.forName("oracle.jdbc.OracleDriver"); + connection = DriverManager.getConnection(url,username,password); + //Statement 瀵硅薄 鍙戦�乻ql + updateStatement = connection.createStatement(); + //鏌ヨ + queryStatement = connection.createStatement(); + ResultSet resultSet = queryStatement.executeQuery("select count(*) from user_tables where table_name = upper(" + tableName + ")"); + + int result = 0; + while(resultSet.next()){ + int column = resultSet.getInt(1); + result = column; + } + return result; + } catch (SQLException e) { + e.printStackTrace(); + return 0; + } finally { + if (updateStatement != null){ + updateStatement.close(); + } + if (queryStatement != null){ + queryStatement.close(); + } + if (connection != null){ + connection.close(); + } + } + } + + public Map<String,Object> getRtuDataYjByJH(String url,String username,String password,String tableName,String JH) throws ClassNotFoundException, SQLException{ + Connection connection = null; + + Statement updateStatement = null; + + Statement queryStatement = null; + + try { + Class.forName("oracle.jdbc.OracleDriver"); + connection = DriverManager.getConnection(url,username,password); + //Statement 瀵硅薄 鍙戦�乻ql + updateStatement = connection.createStatement(); + //鏌ヨ + queryStatement = connection.createStatement(); + ResultSet resultSet = queryStatement.executeQuery("select rdy0.* from " + tableName + " rdy0 inner join (" + + "select rdy.JH,max(rdy.RQ) as RQ from RTU_DATA_YJ_8 rdy group by rdy.JH" + + ")t on rdy0.JH = t.JH and rdy0.RQ = t.RQ where rdy0.JH = " + JH); + + Map<String,Object> result = new HashMap(); + while(resultSet.next()){ + result.put("wellRunningState", "n"); + result.put("totalPowerConsumption", "n");//鎬昏�楃數閲� + result.put("communicationMachine", "n");//璁惧閫氳 + result.put("remark", "n");//澶囨敞 + result.put("singleWellWaterTemperature", "n");//鍗曚簳鎺烘按娓╁害// + result.put("meteringPlantWaterPressure", "n");//璁¢噺闂存幒姘村帇鍔�// + result.put("torque", "n");//鎵煩 + + if(resultSet.getString("MAT") != null){//鍥炴补娓╁害 + result.put("MAT", resultSet.getString("MAT")); + }else{ + result.put("MAT", "n"); + } + if(resultSet.getString("TGP") != null){//浜曞彛娌瑰帇 + result.put("TGP", resultSet.getString("TGP")); + }else{ + result.put("TGP", "n"); + } + if(resultSet.getString("CPV") != null){//浜曞彛濂楀帇 + result.put("CPV", resultSet.getString("CPV")); + }else{ + result.put("CPV", "n"); + } + if(resultSet.getString("ADL") != null){//A鐩哥數娴� + result.put("ADL", resultSet.getString("ADL")); + }else{ + result.put("ADL", "n"); + } + if(resultSet.getString("ADY") != null){//A鐩哥數鍘� + result.put("ADY", resultSet.getString("ADY")); + }else{ + result.put("ADY", "n"); + } + if(resultSet.getString("BDL") != null){//B鐩哥數娴� + result.put("BDL", resultSet.getString("BDL")); + }else{ + result.put("BDL", "n"); + } + if(resultSet.getString("BDY") != null){//B鐩哥數鍘� + result.put("BDY", resultSet.getString("BDY")); + }else{ + result.put("BDY", "n"); + } + if(resultSet.getString("CDL") != null){//C鐩哥數娴� + result.put("CDL", resultSet.getString("CDL")); + }else{ + result.put("CDL", "n"); + } + if(resultSet.getString("CDY") != null){//C鐩哥數鍘� + result.put("CDY", resultSet.getString("CDY")); + }else{ + result.put("CDY", "n"); + } + if(resultSet.getString("UCV") != null){//涓婅鐢垫祦 + result.put("UCV", resultSet.getString("UCV")); + }else{ + result.put("UCV", "n"); + } + if(resultSet.getString("DCV") != null){//涓嬭鐢垫祦 + result.put("DCV", resultSet.getString("DCV")); + }else{ + result.put("DCV", "n"); + } + if(resultSet.getString("SLV") != null){//鍐茬▼ + result.put("SLV", resultSet.getString("SLV")); + }else{ + result.put("SLV", "n"); + } + if(resultSet.getString("CHC") != null){//鍐叉 + result.put("CHC", resultSet.getString("CHC")); + }else{ + result.put("CHC", "n"); + } + if(resultSet.getString("BPV") != null){//浜曞彛鍥炲帇 + result.put("BPV", resultSet.getString("BPV")); + }else{ + result.put("BPV", "n"); + } + if(resultSet.getString("ZWG") != null){//鎬绘棤鍔熷姛鐜� + result.put("ZWG", resultSet.getString("ZWG")); + }else{ + result.put("ZWG", "n"); + } + if(resultSet.getString("ZYG") != null){//鎬绘湁鍔熷姛鐜� + result.put("ZYG", resultSet.getString("ZYG")); + }else{ + result.put("ZYG", "n"); + } + if(resultSet.getString("GYS") != null){//鍔熺巼鍥犳暟 + result.put("GYS", resultSet.getString("GYS")); + }else{ + result.put("GYS", "n"); + } + if(resultSet.getString("UWL") != null){//鏈�澶ц浇鑽� + result.put("UWL", resultSet.getString("UWL")); + }else{ + result.put("UWL", "n"); + } + if(resultSet.getString("DWL") != null){//鏈�灏忚浇鑽� + result.put("DWL", resultSet.getString("DWL")); + }else{ + result.put("DWL", "n"); + } + if(resultSet.getString("ZHS") != null){//杞�� + result.put("ZHS", resultSet.getString("ZHS")); + }else{ + result.put("ZHS", "n"); + } + } + if(result.size() == 0){ + result.put("wellRunningState", "n");//娌逛簳杩愯鐘舵�� + result.put("totalPowerConsumption", "n");//鎬昏�楃數閲� + result.put("communicationMachine", "n");//璁惧閫氳 + result.put("remark", "n");//澶囨敞 + result.put("singleWellWaterTemperature", "n");//鍗曚簳鎺烘按娓╁害// + result.put("meteringPlantWaterPressure", "n");//璁¢噺闂存幒姘村帇鍔�// + result.put("torque", "n");//鎵煩 + result.put("MAT", "n");//鍥炴补娓╁害 + result.put("TGP", "n");//浜曞彛娌瑰帇 + result.put("CPV", "n");//浜曞彛濂楀帇 + result.put("ADL", "n");//A鐩哥數娴� + result.put("ADY", "n");//A鐩哥數鍘� + result.put("BDL", "n");//B鐩哥數娴� + result.put("BDY", "n");//B鐩哥數鍘� + result.put("CDL", "n");//C鐩哥數娴� + result.put("CDY", "n");//C鐩哥數鍘� + result.put("UCV", "n");//涓婅鐢垫祦 + result.put("DCV", "n");//涓嬭鐢垫祦 + result.put("SLV", "n");//鍐茬▼ + result.put("CHC", "n");//鍐叉 + result.put("BPV", "n");//浜曞彛鍥炲帇 + result.put("ZWG", "n");//鎬绘棤鍔熷姛鐜� + result.put("ZYG", "n");//鎬绘湁鍔熷姛鐜� + result.put("GYS", "n");//鍔熺巼鍥犳暟 + result.put("UWL", "n");//鏈�澶ц浇鑽� + result.put("DWL", "n");//鏈�灏忚浇鑽� + result.put("ZHS", "n");//杞�� + } + return result; + } finally { + if (updateStatement != null){ + updateStatement.close(); + } + if (queryStatement != null){ + queryStatement.close(); + } + if (connection != null){ + connection.close(); + } + } + } + } -- Gitblit v1.9.3