| | |
| | | package com.ruoyi.alarmpoints.well.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | 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.domain.*; |
| | | import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper; |
| | | import com.ruoyi.alarmpoints.well.mapper.ArdWellGuideCameraMapper; |
| | | import com.ruoyi.alarmpoints.well.service.IArdAlarmpointsWellService; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.core.domain.entity.SysConfig; |
| | |
| | | private static final Logger log = LoggerFactory.getLogger(ArdAlarmpointsWellServiceImpl.class); |
| | | @Resource |
| | | private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; |
| | | @Resource |
| | | private ArdWellGuideCameraMapper ardWellGuideCameraMapper; |
| | | |
| | | @Autowired |
| | | protected Validator validator; |
| | | |
| | |
| | | ardAlarmpointsWell.setUpdateTime(DateUtils.getNowDate()); |
| | | return ardAlarmpointsWellMapper.updateArdAlarmpointsWell(ardAlarmpointsWell); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public int updateArdAlarmpointsWellByWellId(ArdAlarmpointsWell ardAlarmpointsWell) { |
| | |
| | | ardAlarmpointsWell.setUpdateTime(DateUtils.getNowDate()); |
| | | return ardAlarmpointsWellMapper.updateArdAlarmpointsWellByWellId(ardAlarmpointsWell); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除井管理 |
| | | * |
| | |
| | | Integer pageNum = ardAlarmpointsWellParam.getPageNum(); |
| | | Integer pageSize = ardAlarmpointsWellParam.getPageSize(); |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("dept_id", ardAlarmpointsWellParam.getDeptList()) |
| | | .like(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellId()), "well_id", ardAlarmpointsWellParam.getWellId()); |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellNumber()),"well_number",ardAlarmpointsWellParam.getWellNumber()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getOilProduction()),"oil_production",ardAlarmpointsWellParam.getOilProduction()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellBlock()),"well_block",ardAlarmpointsWellParam.getWellBlock()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getDisplacementMode()),"displacement_mode",ardAlarmpointsWellParam.getDisplacementMode()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getSurroundingEnvironment()),"surrounding_environment",ardAlarmpointsWellParam.getSurroundingEnvironment()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellType()),"well_type",ardAlarmpointsWellParam.getWellType()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getInstalledLoad()),"installed_load",ardAlarmpointsWellParam.getInstalledLoad()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getMeteringStation()),"metering_station",ardAlarmpointsWellParam.getMeteringStation()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getTransferStation()),"transfer_station",ardAlarmpointsWellParam.getTransferStation()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getDehydrationStation()),"dehydration_station",ardAlarmpointsWellParam.getDehydrationStation()) |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getRunStatus()),"run_status",ardAlarmpointsWellParam.getRunStatus()); |
| | | List<ArdAlarmpointsWell> list = ardAlarmpointsWellMapper.selectList(queryWrapper); |
| | | // QueryWrapper<ArdAlarmpointsWell> queryWrapper = new QueryWrapper<>(); |
| | | // queryWrapper.select("id","altitude","metering_station","displacement_mode","latitude","dehydration_station", |
| | | // "well_type","production_date","well_id","transfer_station","oil_production","run_status","longitude", |
| | | // "installed_load","dept_id","user_id","surrounding_environment","well_number","well_block") |
| | | // .eq(!StringUtils.isBlank(ardAlarmpointsWellParam.getWellId()), "well_id", ardAlarmpointsWellParam.getWellId()) |
| | | // .in("dept_id", ardAlarmpointsWellParam.getDeptList()); |
| | | // List<ArdAlarmpointsWell> list = ardAlarmpointsWellMapper.selectList(queryWrapper); |
| | | List<ArdAlarmpointsWell> list = ardAlarmpointsWellMapper.conditionList(ardAlarmpointsWellParam); |
| | | return new PageInfo<>(list); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<ArdAlarmpointsWell> getNearbyWellList(Double longitudeCenter,Double latitudeCenter, Long deptId, Integer range) { |
| | | public List<ArdAlarmpointsWell> getNearbyWellList(Double longitudeCenter, Double latitudeCenter, Long deptId, Integer range) { |
| | | List<ArdAlarmpointsWell> nearbyWellList = new ArrayList<>(); |
| | | try { |
| | | if (longitudeCenter != null && latitudeCenter != null) { |
| | | ArdAlarmpointsWell ardAlarmpointsWell=new ArdAlarmpointsWell(); |
| | | ArdAlarmpointsWell ardAlarmpointsWell = new ArdAlarmpointsWell(); |
| | | ardAlarmpointsWell.setDeptId(deptId); |
| | | List<ArdAlarmpointsWell> ardAlarmpointsWells = ardAlarmpointsWellMapper.selectArdAlarmpointsWellList(ardAlarmpointsWell); |
| | | if (ardAlarmpointsWells.size() > 0) { |
| | |
| | | @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",""); |
| | | 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.getUserId() != null) { |
| | | result.put("userId", ardAlarmpointsWell.getUserId()); |
| | | } else { |
| | | result.put("userId", ""); |
| | | } |
| | | if(ardAlarmpointsWell.getDeptId() != null){ |
| | | result.put("deptId",ardAlarmpointsWell.getDeptId()); |
| | | 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",""); |
| | | if (sysDept != null) { |
| | | result.put("deptName", sysDept.getDeptName()); |
| | | } else { |
| | | result.put("deptName", ""); |
| | | } |
| | | }else{ |
| | | result.put("deptId",""); |
| | | 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.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.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.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.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){ |
| | | if (config.size() != 0) { |
| | | String oracle = config.get(0).getConfigValue(); |
| | | String[] oracleArr = oracle.split(";"); |
| | | if(oracleArr.length == 3){ |
| | | 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 + "\'"); |
| | | 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{ |
| | | } else { |
| | | result.put("wellRunningState", "n");//油井运行状态 |
| | | result.put("totalPowerConsumption", "n");//总耗电量 |
| | | result.put("communicationMachine", "n");//设备通讯 |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else if(oracleArr.length == 4){ |
| | | } 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 + "\'"); |
| | | 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{ |
| | | } else { |
| | | result.put("wellRunningState", "n");//油井运行状态 |
| | | result.put("totalPowerConsumption", "n");//总耗电量 |
| | | result.put("communicationMachine", "n");//设备通讯 |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | }else{ |
| | | } else { |
| | | result.put("wellRunningState", "n");//油井运行状态 |
| | | result.put("totalPowerConsumption", "n");//总耗电量 |
| | | result.put("communicationMachine", "n");//设备通讯 |
| | |
| | | return result; |
| | | } |
| | | |
| | | public int checkTable(String url,String username,String password,String tableName) throws ClassNotFoundException, SQLException { |
| | | @Override |
| | | public Map<String, Object> getWellDataByPatrolplanIdAndPosition(Map<String, Object> para, List<SysConfig> config) { |
| | | String patrolplanId = (String) para.get("patrolplanId"); |
| | | Double longitude = null; |
| | | Double latitude = null; |
| | | try{ |
| | | longitude = (Double) para.get("longitude"); |
| | | latitude = (Double) para.get("latitude"); |
| | | } catch (Exception e){ |
| | | longitude = ((BigDecimal) para.get("longitude")).doubleValue(); |
| | | latitude = ((BigDecimal) para.get("latitude")).doubleValue(); |
| | | } |
| | | ArdAlarmpointsWell ardAlarmpointsWell = ardAlarmpointsWellMapper.getWellDataByPatrolplanIdAndPosition(patrolplanId,longitude,latitude); |
| | | if(ardAlarmpointsWell != null){ |
| | | 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 (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", "\'" + ardAlarmpointsWell.getWellId() + "\'"); |
| | | 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", "\'" + ardAlarmpointsWell.getWellId() + "\'"); |
| | | 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; |
| | | }else{ |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public ArdAlarmpointsWell getWellById(String id) { |
| | | ArdAlarmpointsWell result = ardAlarmpointsWellMapper.getWellById(id); |
| | | return result; |
| | | } |
| | | |
| | | public int checkTable(String url, String username, String password, String tableName) throws ClassNotFoundException, SQLException { |
| | | Connection connection = null; |
| | | |
| | | Statement updateStatement = null; |
| | |
| | | |
| | | try { |
| | | Class.forName("oracle.jdbc.OracleDriver"); |
| | | connection = DriverManager.getConnection(url,username,password); |
| | | connection = DriverManager.getConnection(url, username, password); |
| | | //Statement 对象 发送sql |
| | | updateStatement = connection.createStatement(); |
| | | //查询 |
| | |
| | | ResultSet resultSet = queryStatement.executeQuery("select count(*) from user_tables where table_name = upper(" + tableName + ")"); |
| | | |
| | | int result = 0; |
| | | while(resultSet.next()){ |
| | | while (resultSet.next()) { |
| | | int column = resultSet.getInt(1); |
| | | result = column; |
| | | } |
| | |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } finally { |
| | | if (updateStatement != null){ |
| | | if (updateStatement != null) { |
| | | updateStatement.close(); |
| | | } |
| | | if (queryStatement != null){ |
| | | if (queryStatement != null) { |
| | | queryStatement.close(); |
| | | } |
| | | if (connection != null){ |
| | | if (connection != null) { |
| | | connection.close(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public Map<String,Object> getRtuDataYjByJH(String url,String username,String password,String tableName,String JH) throws ClassNotFoundException, SQLException{ |
| | | public Map<String, Object> getRtuDataYjByJH(String url, String username, String password, String tableName, String JH) throws ClassNotFoundException, SQLException { |
| | | Connection connection = null; |
| | | |
| | | Statement updateStatement = null; |
| | |
| | | |
| | | try { |
| | | Class.forName("oracle.jdbc.OracleDriver"); |
| | | connection = DriverManager.getConnection(url,username,password); |
| | | connection = DriverManager.getConnection(url, username, password); |
| | | //Statement 对象 发送sql |
| | | updateStatement = connection.createStatement(); |
| | | //查询 |
| | |
| | | "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()){ |
| | | Map<String, Object> result = new HashMap(); |
| | | while (resultSet.next()) { |
| | | result.put("wellRunningState", "n"); |
| | | result.put("totalPowerConsumption", "n");//总耗电量 |
| | | result.put("communicationMachine", "n");//设备通讯 |
| | |
| | | result.put("meteringPlantWaterPressure", "n");//计量间掺水压力// |
| | | result.put("torque", "n");//扭矩 |
| | | |
| | | if(resultSet.getString("MAT") != null){//回油温度 |
| | | if (resultSet.getString("MAT") != null) {//回油温度 |
| | | result.put("MAT", resultSet.getString("MAT")); |
| | | }else{ |
| | | } else { |
| | | result.put("MAT", "n"); |
| | | } |
| | | if(resultSet.getString("TGP") != null){//井口油压 |
| | | if (resultSet.getString("TGP") != null) {//井口油压 |
| | | result.put("TGP", resultSet.getString("TGP")); |
| | | }else{ |
| | | } else { |
| | | result.put("TGP", "n"); |
| | | } |
| | | if(resultSet.getString("CPV") != null){//井口套压 |
| | | if (resultSet.getString("CPV") != null) {//井口套压 |
| | | result.put("CPV", resultSet.getString("CPV")); |
| | | }else{ |
| | | } else { |
| | | result.put("CPV", "n"); |
| | | } |
| | | if(resultSet.getString("ADL") != null){//A相电流 |
| | | if (resultSet.getString("ADL") != null) {//A相电流 |
| | | result.put("ADL", resultSet.getString("ADL")); |
| | | }else{ |
| | | } else { |
| | | result.put("ADL", "n"); |
| | | } |
| | | if(resultSet.getString("ADY") != null){//A相电压 |
| | | if (resultSet.getString("ADY") != null) {//A相电压 |
| | | result.put("ADY", resultSet.getString("ADY")); |
| | | }else{ |
| | | } else { |
| | | result.put("ADY", "n"); |
| | | } |
| | | if(resultSet.getString("BDL") != null){//B相电流 |
| | | if (resultSet.getString("BDL") != null) {//B相电流 |
| | | result.put("BDL", resultSet.getString("BDL")); |
| | | }else{ |
| | | } else { |
| | | result.put("BDL", "n"); |
| | | } |
| | | if(resultSet.getString("BDY") != null){//B相电压 |
| | | if (resultSet.getString("BDY") != null) {//B相电压 |
| | | result.put("BDY", resultSet.getString("BDY")); |
| | | }else{ |
| | | } else { |
| | | result.put("BDY", "n"); |
| | | } |
| | | if(resultSet.getString("CDL") != null){//C相电流 |
| | | if (resultSet.getString("CDL") != null) {//C相电流 |
| | | result.put("CDL", resultSet.getString("CDL")); |
| | | }else{ |
| | | } else { |
| | | result.put("CDL", "n"); |
| | | } |
| | | if(resultSet.getString("CDY") != null){//C相电压 |
| | | if (resultSet.getString("CDY") != null) {//C相电压 |
| | | result.put("CDY", resultSet.getString("CDY")); |
| | | }else{ |
| | | } else { |
| | | result.put("CDY", "n"); |
| | | } |
| | | if(resultSet.getString("UCV") != null){//上行电流 |
| | | if (resultSet.getString("UCV") != null) {//上行电流 |
| | | result.put("UCV", resultSet.getString("UCV")); |
| | | }else{ |
| | | } else { |
| | | result.put("UCV", "n"); |
| | | } |
| | | if(resultSet.getString("DCV") != null){//下行电流 |
| | | if (resultSet.getString("DCV") != null) {//下行电流 |
| | | result.put("DCV", resultSet.getString("DCV")); |
| | | }else{ |
| | | } else { |
| | | result.put("DCV", "n"); |
| | | } |
| | | if(resultSet.getString("SLV") != null){//冲程 |
| | | if (resultSet.getString("SLV") != null) {//冲程 |
| | | result.put("SLV", resultSet.getString("SLV")); |
| | | }else{ |
| | | } else { |
| | | result.put("SLV", "n"); |
| | | } |
| | | if(resultSet.getString("CHC") != null){//冲次 |
| | | if (resultSet.getString("CHC") != null) {//冲次 |
| | | result.put("CHC", resultSet.getString("CHC")); |
| | | }else{ |
| | | } else { |
| | | result.put("CHC", "n"); |
| | | } |
| | | if(resultSet.getString("BPV") != null){//井口回压 |
| | | if (resultSet.getString("BPV") != null) {//井口回压 |
| | | result.put("BPV", resultSet.getString("BPV")); |
| | | }else{ |
| | | } else { |
| | | result.put("BPV", "n"); |
| | | } |
| | | if(resultSet.getString("ZWG") != null){//总无功功率 |
| | | if (resultSet.getString("ZWG") != null) {//总无功功率 |
| | | result.put("ZWG", resultSet.getString("ZWG")); |
| | | }else{ |
| | | } else { |
| | | result.put("ZWG", "n"); |
| | | } |
| | | if(resultSet.getString("ZYG") != null){//总有功功率 |
| | | if (resultSet.getString("ZYG") != null) {//总有功功率 |
| | | result.put("ZYG", resultSet.getString("ZYG")); |
| | | }else{ |
| | | } else { |
| | | result.put("ZYG", "n"); |
| | | } |
| | | if(resultSet.getString("GYS") != null){//功率因数 |
| | | if (resultSet.getString("GYS") != null) {//功率因数 |
| | | result.put("GYS", resultSet.getString("GYS")); |
| | | }else{ |
| | | } else { |
| | | result.put("GYS", "n"); |
| | | } |
| | | if(resultSet.getString("UWL") != null){//最大载荷 |
| | | if (resultSet.getString("UWL") != null) {//最大载荷 |
| | | result.put("UWL", resultSet.getString("UWL")); |
| | | }else{ |
| | | } else { |
| | | result.put("UWL", "n"); |
| | | } |
| | | if(resultSet.getString("DWL") != null){//最小载荷 |
| | | if (resultSet.getString("DWL") != null) {//最小载荷 |
| | | result.put("DWL", resultSet.getString("DWL")); |
| | | }else{ |
| | | } else { |
| | | result.put("DWL", "n"); |
| | | } |
| | | if(resultSet.getString("ZHS") != null){//转速 |
| | | if (resultSet.getString("ZHS") != null) {//转速 |
| | | result.put("ZHS", resultSet.getString("ZHS")); |
| | | }else{ |
| | | } else { |
| | | result.put("ZHS", "n"); |
| | | } |
| | | } |
| | | if(result.size() == 0){ |
| | | if (result.size() == 0) { |
| | | result.put("wellRunningState", "n");//油井运行状态 |
| | | result.put("totalPowerConsumption", "n");//总耗电量 |
| | | result.put("communicationMachine", "n");//设备通讯 |
| | |
| | | } |
| | | return result; |
| | | } finally { |
| | | if (updateStatement != null){ |
| | | if (updateStatement != null) { |
| | | updateStatement.close(); |
| | | } |
| | | if (queryStatement != null){ |
| | | if (queryStatement != null) { |
| | | queryStatement.close(); |
| | | } |
| | | if (connection != null){ |
| | | if (connection != null) { |
| | | connection.close(); |
| | | } |
| | | } |