Merge remote-tracking branch 'origin/master'
# Conflicts:
# ard-work/src/main/java/com/ruoyi/alarmpoints/well/mapper/ArdAlarmpointsWellMapper.java
# ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
| | |
| | | <artifactId>orai18n</artifactId>
|
| | | <version>12.1.0.2.0</version>
|
| | | </dependency>
|
| | | <!-- <dependency>-->
|
| | | <!-- WebSocket客æ·ç«¯ -->
|
| | | <dependency>
|
| | | <groupId>org.java-websocket</groupId>
|
| | | <artifactId>Java-WebSocket</artifactId>
|
| | | <version>1.3.8</version>
|
| | | </dependency>
|
| | |
|
| | | <!-- <dependency>-->
|
| | | <!-- <groupId>com.alibaba</groupId>-->
|
| | | <!-- <artifactId>druid</artifactId>-->
|
| | | <!-- <version>1.2.15</version>-->
|
| | |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @GetMapping("/getWellDataByPatrolplanIdAndPosition") |
| | | @ApiOperation("æ¥è¯¢æè¿å·¡æ£è®¾å¤å¨éæå±æ§") |
| | | public AjaxResult getWellDataByPatrolplanIdAndPosition(@RequestBody Map<String,Object> para){ |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey("3coracle"); |
| | | List<SysConfig> sysConfigResult = sysConfigService.selectConfigList(config); |
| | | Map<String,Object> result = ardAlarmpointsWellService.getWellDataByPatrolplanIdAndPosition(para,sysConfigResult); |
| | | return AjaxResult.success(result); |
| | | } |
| | | |
| | | @GetMapping("/getWellById") |
| | | @ApiOperation("æ ¹æ®æ¥è¯¢å
´è¶£ç¹åºæ¬å±æ§") |
| | | public AjaxResult getWellById(@RequestBody Map<String,String> para){ |
| | | ArdAlarmpointsWell result = ardAlarmpointsWellService.getWellById(para.get("id")); |
| | | return AjaxResult.success(result); |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo; |
| | | import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellParam; |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | List<ArdAlarmpointsWellDeptVo> wellListDept(List<Long> deptList); |
| | | |
| | | ArdAlarmpointsWell getWellDataByPatrolplanIdAndPosition(@Param("patrolplanId") String patrolplanId,@Param("longitude") Double longitude,@Param("latitude") Double latitude); |
| | | |
| | | ArdAlarmpointsWell getWellById(String id); |
| | | List<ArdAlarmpointsWell> conditionList(ArdAlarmpointsWellParam ardAlarmpointsWellParam); |
| | | |
| | | } |
| | |
| | | * æ¥è¯¢æ²¹äºå¨éææ°æ® |
| | | */ |
| | | Map<String,Object> getWellDataByWellId(String wellId, List<SysConfig> config); |
| | | |
| | | Map<String,Object> getWellDataByPatrolplanIdAndPosition(Map<String,Object> para,List<SysConfig> sysConfigResult); |
| | | |
| | | ArdAlarmpointsWell getWellById(String id); |
| | | } |
| | |
| | | package com.ruoyi.alarmpoints.well.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | return result; |
| | | } |
| | | |
| | | @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; |
| | | |
| | |
| | | package com.ruoyi.app.application.controller; |
| | | |
| | | import java.awt.geom.QuadCurve2D; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/getSoilderAndCarPositionByCommanderIdNear") |
| | | @ApiOperation("PCç«¯ææ¥ç«¯æ¥çåå
µç«¯å车è¾ä½ç½®") |
| | | public AjaxResult getSoilderAndCarPositionByCommanderIdNear(@RequestBody Map<String, Double> para) { |
| | | String commanderId = SecurityUtils.getUserId(); |
| | | try{ |
| | | Map<String,Map<String,List<Map<String,Object>>>> result = ardAppApplicationService.getSoilderAndCarPositionByCommanderId(commanderId,para); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | } |
| | | } |
| | |
| | | public int approvalCheckPositionOwn(String soilderId,Map<String,String> para); |
| | | |
| | | public List<Map<String,Object>> getCheckPositionNo(String commanderId);/// |
| | | |
| | | public Map<String,Map<String,List<Map<String,Object>>>> getSoilderAndCarPositionByCommanderId(String commanderId,Map<String, Double> para); |
| | | } |
| | |
| | | package com.ruoyi.app.application.service.impl; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.app.position.appcontainer.AppContainer; |
| | | import com.ruoyi.app.position.domain.ArdAppPosition; |
| | | import com.ruoyi.app.position.mapper.ArdAppPositionMapper; |
| | | import com.ruoyi.common.core.domain.entity.SysConfig; |
| | | import com.ruoyi.common.core.domain.entity.SysRole; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | | import com.ruoyi.sy.mapper.ArdSyCarMapper; |
| | | import com.ruoyi.sy.mapper.ArdSyUserMapper; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.utils.forest.SYClient; |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | |
| | | |
| | | @Resource |
| | | private SysRoleMapper sysRoleMapper; |
| | | |
| | | @Resource |
| | | private SysUserMapper userMapper; |
| | | |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @Resource |
| | | private ArdAppPositionMapper ardAppPositionMapper; |
| | | |
| | | @Resource |
| | | private ArdSyUserMapper ardSyUserMapper; |
| | | |
| | | @Resource |
| | | private SysConfigMapper sysConfigMapper; |
| | | |
| | | @Resource |
| | | private ArdSyCarMapper ardSyCarMapper; |
| | | |
| | | @Resource |
| | | private SYClient sYClient; |
| | | |
| | | @Value("${minio.endpoint}") |
| | | private String minioEndpoint; |
| | | |
| | | private Map<String,Thread> threadMap = new HashMap(); |
| | | |
| | |
| | | } |
| | | return ardAppApplicationList; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String,Map<String,List<Map<String,Object>>>> getSoilderAndCarPositionByCommanderId(String commanderId,Map<String, Double> para) { |
| | | Map<String,Map<String,List<Map<String,Object>>>> mapResault = new HashMap(); |
| | | SysUser sysUser = userMapper.selectUserById(commanderId);//è·åç³»ç»ç¨æ· |
| | | List<Long> deptIdList = new ArrayList(); |
| | | deptIdList.add(sysUser.getDeptId()); |
| | | deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//é彿¥è¯¢ä¸å±é¨é¨ä¸»é® |
| | | List<SysUser> sysUsersResult = userMapper.getOwnAndChildrenSoilderListAll(deptIdList); |
| | | List<SysUser> sysUsersResultOnline = sysUsersResult.stream().filter(sysUserTest -> sysUserTest.getAppOnlineState().equals("1")).collect(Collectors.toList());//å¨çº¿ç¨æ· |
| | | List<SysUser> sysUsersResultOffline = sysUsersResult.stream().filter(sysUserTest -> !sysUserTest.getAppOnlineState().equals("1")).collect(Collectors.toList());//ç¦»çº¿ç¨æ· |
| | | List<Map<String,Object>> sysUsersOnlineList = new ArrayList(); |
| | | List<Map<String,Object>> sysUsersOfflineList = new ArrayList(); |
| | | for(SysUser sysUserIn : sysUsersResultOnline){ |
| | | Map<String,Object> map = new HashMap(); |
| | | map.put("userId",sysUserIn.getUserId()); |
| | | map.put("deptId",sysUserIn.getDeptId()); |
| | | map.put("userName",sysUserIn.getUserName()); |
| | | map.put("nickName",sysUserIn.getNickName()); |
| | | try{ |
| | | map.put("longitude", AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getLongitude()); |
| | | map.put("latitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getLatitude()); |
| | | map.put("altitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getAltitude()); |
| | | }catch(Exception e){ |
| | | ArdAppPosition ardAppPosition = ardAppPositionMapper.getLastAPPPositionByUserId(sysUserIn.getUserId()); |
| | | map.put("longitude",ardAppPosition.getLongitude()); |
| | | map.put("latitude",ardAppPosition.getLatitude()); |
| | | map.put("altitude",ardAppPosition.getAltitude()); |
| | | } |
| | | sysUsersOnlineList.add(map); |
| | | } |
| | | List<Map<String,Object>> sysUsersOnlineNearList = new ArrayList();//å¨200ç±³å
|
| | | for(Map<String,Object> mapOn : sysUsersOnlineList){ |
| | | Double longitude = (Double) mapOn.get("longitude"); |
| | | Double latitude = (Double) mapOn.get("latitude"); |
| | | double distance = GisUtil.getDistance(para.get("longitude"),para.get("latitude"),longitude,latitude); |
| | | if(distance <= 200){ |
| | | sysUsersOnlineNearList.add(mapOn); |
| | | } |
| | | } |
| | | Map<String,List<Map<String,Object>>> appMap = new HashMap(); |
| | | appMap.put("onlineApp",sysUsersOnlineNearList); |
| | | for(SysUser sysUserIn : sysUsersResultOffline){ |
| | | Map<String,Object> map = new HashMap(); |
| | | map.put("userId",sysUserIn.getUserId()); |
| | | map.put("deptId",sysUserIn.getDeptId()); |
| | | map.put("userName",sysUserIn.getUserName()); |
| | | map.put("nickName",sysUserIn.getNickName()); |
| | | sysUsersOfflineList.add(map); |
| | | } |
| | | appMap.put("offlineApp",sysUsersOfflineList); |
| | | mapResault.put("app",appMap); |
| | | |
| | | ArdSyUser ardSyUserPara = new ArdSyUser(); |
| | | ardSyUserPara.setSysUserId(commanderId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara);//æ¥è¯¢ææ¥çä¸ä¸è´¦å· |
| | | |
| | | String syURL = ""; |
| | | List<SysConfig> sysConfigResult = sysConfigMapper.selectByType("syCarPT"); |
| | | if(sysConfigResult.size() > 0){ |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | } |
| | | |
| | | if(ardSyUserList.size() == 0 || syURL.equals("")){ |
| | | List<Map<String,Object>> onlineCar = new ArrayList(); |
| | | List<Map<String,Object>> offlineCar = new ArrayList(); |
| | | Map<String,List<Map<String,Object>>> carMap = new HashMap(); |
| | | carMap.put("onlineCar",onlineCar); |
| | | carMap.put("offlineCar",offlineCar); |
| | | mapResault.put("car",carMap); |
| | | return mapResault; |
| | | } |
| | | |
| | | List<String> carIdList = ardSyCarMapper.selectArdSyCarByDeptIds(deptIdList); |
| | | String carIds = ""; |
| | | for(String carId : carIdList){ |
| | | carIds = carIds + carId + ","; |
| | | } |
| | | carIds = carIds.substring(0,carIds.length() - 1); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUserList.get(0).getPassword()); |
| | | Map<String,Object> syLoginResult = sYClient.logIn(syURL, passwordMd5, ardSyUserList.get(0).getUserId()); |
| | | String sessionId = (String) syLoginResult.get("sessionId"); |
| | | Map<String,Object> carNearPositionResult = sYClient.getCarNearPositionByCarId(syURL, carIds, ardSyUserList.get(0).getUserId(),sessionId); |
| | | if(((String)carNearPositionResult.get("rspCode")).equals("1")){ |
| | | List<Map<String,Object>> SYCarPositionList = (List<Map<String, Object>>) carNearPositionResult.get("list"); |
| | | //çéå¨çº¿ |
| | | List<Map<String,Object>> onlineSYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("å¨çº¿")).collect(Collectors.toList()); |
| | | //çé200ç±³èå´å
|
| | | List<Map<String,Object>> onlineSYCarPositionNearList = new ArrayList();//å¨200ç±³å
|
| | | for(Map<String,Object> mapOn : onlineSYCarPositionList){ |
| | | Double longitude = new BigDecimal((String) mapOn.get("lng")).doubleValue(); |
| | | Double latitude = new BigDecimal((String) mapOn.get("lat")).doubleValue(); |
| | | double distance = GisUtil.getDistance(para.get("longitude"),para.get("latitude"),longitude,latitude); |
| | | if(distance <= 200){ |
| | | mapOn.put("longitude",longitude); |
| | | mapOn.put("latitude",latitude); |
| | | onlineSYCarPositionNearList.add(mapOn); |
| | | } |
| | | } |
| | | |
| | | //for(Map<String,Object> sycar : onlineSYCarPositionList){ |
| | | for(Map<String,Object> sycar : onlineSYCarPositionNearList){ |
| | | Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId")); |
| | | String carModel = this.minioEndpoint + "/" + (String) map.get("carModel"); |
| | | map.put("carModel",carModel); |
| | | sycar.putAll(map); |
| | | } |
| | | //çé离线 |
| | | List<Map<String,Object>> offlineSYCarPositionList = SYCarPositionList.stream().filter(map -> ((String)map.get("stateCn")).startsWith("离线")).collect(Collectors.toList()); |
| | | for(Map<String,Object> sycar : offlineSYCarPositionList){ |
| | | Map<String,Object> map = ardSyCarMapper.getArdSyCarAndDeptByCarId((String)sycar.get("carId")); |
| | | String carModel = this.minioEndpoint + "/" + (String) map.get("carModel"); |
| | | map.put("carModel",carModel); |
| | | sycar.putAll(map); |
| | | } |
| | | Map<String,List<Map<String,Object>>> carMap = new HashMap(); |
| | | //carMap.put("onlineCar",onlineSYCarPositionList); |
| | | carMap.put("onlineCar",onlineSYCarPositionNearList); |
| | | carMap.put("offlineCar",offlineSYCarPositionList); |
| | | mapResault.put("car",carMap); |
| | | }else{ |
| | | List<Map<String,Object>> onlineCar = new ArrayList(); |
| | | List<Map<String,Object>> offlineCar = new ArrayList(); |
| | | Map<String,List<Map<String,Object>>> carMap = new HashMap(); |
| | | carMap.put("onlineCar",onlineCar); |
| | | carMap.put("offlineCar",offlineCar); |
| | | mapResault.put("car",carMap); |
| | | return mapResault; |
| | | } |
| | | |
| | | return mapResault; |
| | | } |
| | | |
| | | public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){ |
| | | deptIdListr.addAll(deptIdList); |
| | | List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList); |
| | | if(result.size() != 0){ |
| | | deptIdListr.addAll(result); |
| | | result = getOwnAndChildrenDeptIdList(result,deptIdListr); |
| | | } |
| | | deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList()); |
| | | return deptIdListr; |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.app.position.appcontainer; |
| | | |
| | | import com.ruoyi.app.position.domain.ArdAppPosition; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | public class AppContainer { |
| | | |
| | | private static Map<String, ArdAppPosition> ardAppPositionMap = new HashMap(); |
| | | |
| | | public static Map<String, ArdAppPosition> getArdAppPositionMap() { |
| | | return ardAppPositionMap; |
| | | } |
| | | |
| | | public static void setArdAppPositionMap(Map<String, ArdAppPosition> ardAppPositionMap) { |
| | | ardAppPositionMap = ardAppPositionMap; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | /*@PostMapping("/sendCheckCommandersPosition") |
| | | @ApiOperation("åèµ·æ¥çææ¥ç«¯ä½ç½®") |
| | | public AjaxResult sendCheckCommandersPosition(@RequestBody Map<String,Object> para) { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | @GetMapping("/getAPPPositionByUserIdAndTime") |
| | | @ApiOperation("æ¥çAPPåå²ä½ç½®") |
| | | public AjaxResult getAPPPositionByUserIdAndTime(@RequestBody Map<String,String> para) { |
| | | try{ |
| | | ardAppPositionService.sendCheckCommandersPosition(usersId,para); |
| | | return AjaxResult.success(); |
| | | }catch(Exception e){ |
| | | return AjaxResult.error(); |
| | | } |
| | | }*/ |
| | | |
| | | /*@PostMapping("/sendCheckSYCarsPosition") |
| | | @ApiOperation("åèµ·æ¥ç车è¾ä½ç½®") |
| | | public AjaxResult sendCheckSYCarsPosition(@RequestBody Map<String,Object> para) { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | ardAppPositionService.sendCheckSYCarsPosition(usersId,para); |
| | | return AjaxResult.success(); |
| | | }catch(Exception e){ |
| | | return AjaxResult.error(); |
| | | } |
| | | }*/ |
| | | |
| | | /*@GetMapping("/getCheckCommandersPosition") |
| | | @ApiOperation("ææ¥ç«¯æ¥çææ¥ç«¯ä½ç½®ç³è¯·") |
| | | public AjaxResult getCheckCommandersPosition() {//å¼ç¨ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | List<Map<String,Object>> result = ardAppPositionService.getCheckCommandersPosition(usersId); |
| | | List<ArdAppPosition> result = ardAppPositionService.getAPPPositionByUserIdAndTime(para); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | }*/ |
| | | } |
| | | |
| | | /*@GetMapping("/getCheckSYCarsPosition") |
| | | @ApiOperation("ææ¥ç«¯æ¥ç车è¾ä½ç½®ç³è¯·") |
| | | public AjaxResult getCheckSYCarsPosition() {//å¼ç¨ |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | List<Map<String,Object>> result = ardAppPositionService.getCheckSYCarsPosition(usersId); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | }*/ |
| | | |
| | | /*@GetMapping("/getCheckPosition") |
| | | @ApiOperation("ææ¥ç«¯æ¥çä½ç½®ç³è¯·") |
| | | public AjaxResult getCheckPosition() { |
| | | String usersId = SecurityUtils.getUserId(); |
| | | try{ |
| | | Map<String,List<Map<String,Object>>> result = ardAppPositionService.getCheckPosition(usersId); |
| | | return AjaxResult.success(result); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | return AjaxResult.error(); |
| | | } |
| | | }*/ |
| | | @GetMapping("/getOnlineAPPSoilderByCommanderId") |
| | | public AjaxResult getOnlineAPPSoilderByCommanderId() { |
| | | String userId = SecurityUtils.getUserId(); |
| | | return success(ardAppPositionService.getOnlineAPPSoilderByCommanderId(userId)); |
| | | } |
| | | |
| | | } |
| | |
| | | import java.util.Map; |
| | | |
| | | import com.ruoyi.app.position.domain.ArdAppPosition; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | |
| | | /** |
| | |
| | | public int deleteArdAppPositionByIds(String[] ids); |
| | | |
| | | public List<Map<String,Object>> getOnlineCommanderPosition(String soilderId); |
| | | |
| | | public List<ArdAppPosition> getAPPPositionByUserIdAndTime(@Param("userId") String userId,@Param("beginTime") String beginTime,@Param("endTime") String endTime); |
| | | |
| | | public ArdAppPosition getLastAPPPositionByUserId(String userId); |
| | | } |
| | |
| | | |
| | | public List<Map<String,Object>> getOnlineCommanderPosition(String soilderId); |
| | | |
| | | //public void sendCheckCommandersPosition(String usersId,Map<String,Object> para); |
| | | public List<ArdAppPosition> getAPPPositionByUserIdAndTime(Map<String,String> para); |
| | | |
| | | //public void sendCheckSYCarsPosition(String usersId,Map<String,Object> para); |
| | | public List<Map<String,Object>> getOnlineAPPSoilderByCommanderId(String userId); |
| | | |
| | | //public List<Map<String,Object>> getCheckCommandersPosition(String usersId); |
| | | |
| | | //public List<Map<String,Object>> getCheckSYCarsPosition(String usersId); |
| | | |
| | | //public Map<String,List<Map<String,Object>>> getCheckPosition(String usersId); |
| | | } |
| | |
| | | package com.ruoyi.app.position.service.impl; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.ruoyi.alarm.wall.domain.ArdAlarmWall; |
| | | import com.ruoyi.alarm.wall.mapper.ArdAlarmWallMapper; |
| | | import com.ruoyi.alarm.wall.service.IArdAlarmWallService; |
| | | import com.ruoyi.alarmpoints.wall.domain.ArdWall; |
| | | import com.ruoyi.alarmpoints.wall.mapper.ArdWallMapper; |
| | | import com.ruoyi.app.position.appcontainer.AppContainer; |
| | | import com.ruoyi.app.position.domain.ArdAppPosition; |
| | | import com.ruoyi.app.position.mapper.ArdAppPositionMapper; |
| | | import com.ruoyi.app.position.service.IArdAppPositionService; |
| | |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.scheduling.domian.SchedulingParam; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | import com.ruoyi.utils.gis.GisUtil; |
| | | import com.ruoyi.utils.gis.Point; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.boot.autoconfigure.data.redis.RedisProperties; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | IArdAlarmWallService ardAlarmWallService; |
| | | @Resource |
| | | private SysUserMapper sysUserMapper; |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | Map<String, String> firstAlarmMap = new HashMap<>();//馿¬¡æ¥è¦ç¼åkey:ç¨æ·id_å´æ id value: æ¥è¦id |
| | | /** |
| | |
| | | ardAppPosition.setId(IdUtils.simpleUUID()); |
| | | ardAppPosition.setCreateTime(DateUtils.getNowDate()); |
| | | ardAppPositionMapper.insertArdAppPosition(ardAppPosition); |
| | | return DetectionWallAlarm(ardAppPosition); |
| | | try{ |
| | | return DetectionWallAlarm(ardAppPosition); |
| | | }finally { |
| | | AppContainer.getArdAppPositionMap().put(ardAppPosition.getUserId(),ardAppPosition);//宿¶ä½ç½®åå
¥å®¹å¨ |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | return result; |
| | | } |
| | | |
| | | /*@Override |
| | | public void sendCheckCommandersPosition(String usersId,Map<String, Object> para) { |
| | | String reason = (String) para.get("reason"); |
| | | List<String> usersIdList = (List<String>) para.get("usersIdList"); |
| | | for(String commanderId : usersIdList){ |
| | | //设置key为checkCommanderPosition_ææ¥ç«¯ä¸»é®_åå
µç«¯ä¸»é® |
| | | String key = "checkCommanderPosition_" + commanderId + "_" + usersId; |
| | | Map<String,Object> value = new HashMap(); |
| | | value.put("reason",reason); |
| | | value.put("state","0"); |
| | | value.put("begin",""); |
| | | value.put("commanderId",commanderId); |
| | | value.put("soilderId",usersId); |
| | | redisCache.setCacheObject(key, JSON.toJSONString(value)); |
| | | } |
| | | }*/ |
| | | |
| | | /*@Override |
| | | public void sendCheckSYCarsPosition(String usersId, Map<String, Object> para) { |
| | | String reason = (String) para.get("reason"); |
| | | List<String> usersIdList = (List<String>) para.get("usersIdList"); |
| | | for(String commanderId : usersIdList){ |
| | | //设置key为checkSYCarsPosition_ææ¥ç«¯ä¸»é®/PC端主é®_åå
µç«¯ä¸»é® |
| | | String key = "checkSYCarsPosition_" + commanderId + "_" + usersId; |
| | | Map<String,Object> value = new HashMap(); |
| | | value.put("reason",reason); |
| | | value.put("state","0"); |
| | | value.put("begin",""); |
| | | value.put("commanderId",commanderId); |
| | | value.put("soilderId",usersId); |
| | | redisCache.setCacheObject(key, JSON.toJSONString(value)); |
| | | } |
| | | }*/ |
| | | |
| | | /*@Override |
| | | public List<Map<String, Object>> getCheckCommandersPosition(String usersId) { |
| | | String key = "checkCommanderPosition_" + usersId + "_"; |
| | | List<Object> keyValueList = redisCache.getListKey(key); |
| | | List<Map<String, Object>> result = new ArrayList(); |
| | | for(Object o : keyValueList){ |
| | | Map<String,Object> map = JSON.parseObject((String) o); |
| | | if(((String)map.get("state")).equals("0")){//state为0å°±æ¯æªå®¡æ¹ |
| | | SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId")); |
| | | map.put("userName",sysUser.getUserName()); |
| | | result.add(map); |
| | | } |
| | | } |
| | | @Override |
| | | public List<ArdAppPosition> getAPPPositionByUserIdAndTime(Map<String, String> para) { |
| | | String userId = para.get("userId"); |
| | | String beginTime = para.get("beginTime"); |
| | | String endTime = para.get("endTime"); |
| | | List<ArdAppPosition> result = ardAppPositionMapper.getAPPPositionByUserIdAndTime(userId,beginTime,endTime); |
| | | return result; |
| | | }*/ |
| | | } |
| | | |
| | | /*@Override |
| | | public List<Map<String, Object>> getCheckSYCarsPosition(String usersId) { |
| | | String key = "checkSYCarsPosition_" + usersId + "_"; |
| | | List<Object> keyValueList = redisCache.getListKey(key); |
| | | List<Map<String, Object>> result = new ArrayList(); |
| | | for(Object o : keyValueList){ |
| | | Map<String,Object> map = JSON.parseObject((String) o); |
| | | if(((String)map.get("state")).equals("0")){//state为0å°±æ¯æªå®¡æ¹ |
| | | SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId")); |
| | | map.put("userName",sysUser.getUserName()); |
| | | result.add(map); |
| | | @Override |
| | | public List<Map<String,Object>> getOnlineAPPSoilderByCommanderId(String userId) { |
| | | SysUser sysUser = sysUserMapper.selectUserById(userId);//è·åç³»ç»ç¨æ· |
| | | List<Long> deptIdList = new ArrayList(); |
| | | deptIdList.add(sysUser.getDeptId()); |
| | | deptIdList = getOwnAndChildrenDeptIdList(deptIdList,new ArrayList());//é彿¥è¯¢ä¸å±é¨é¨ä¸»é® |
| | | List<SysUser> result = sysUserMapper.getOwnAndChildrenOnlineSoilderList(deptIdList); |
| | | List<Map<String,Object>> resultList = new ArrayList(); |
| | | for(SysUser sysUserIn : result){ |
| | | Map<String,Object> map = new HashMap(); |
| | | map.put("userId",sysUserIn.getUserId()); |
| | | map.put("deptId",sysUserIn.getDeptId()); |
| | | map.put("userName",sysUserIn.getUserName()); |
| | | map.put("nickName",sysUserIn.getNickName()); |
| | | try{ |
| | | map.put("longitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getLongitude()); |
| | | map.put("latitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getLatitude()); |
| | | map.put("altitude",AppContainer.getArdAppPositionMap().get(sysUserIn.getUserId()).getAltitude()); |
| | | }catch(Exception e){ |
| | | ArdAppPosition ardAppPosition = ardAppPositionMapper.getLastAPPPositionByUserId(sysUserIn.getUserId()); |
| | | map.put("longitude",ardAppPosition.getLongitude()); |
| | | map.put("latitude",ardAppPosition.getLatitude()); |
| | | map.put("altitude",ardAppPosition.getAltitude()); |
| | | } |
| | | resultList.add(map); |
| | | } |
| | | return result; |
| | | }*/ |
| | | return resultList; |
| | | } |
| | | |
| | | /*@Override |
| | | public Map<String, List<Map<String, Object>>> getCheckPosition(String usersId) { |
| | | Map<String, List<Map<String, Object>>> result = new HashMap(); |
| | | //æ¥çææ¥ç«¯ä½ç½®ç³è¯· |
| | | String keyCommanderPosition = "checkCommanderPosition_" + usersId + "_"; |
| | | List<Object> keyValueCommanderPositionList = redisCache.getListKey(keyCommanderPosition); |
| | | List<Map<String, Object>> resultCommanderPosition = new ArrayList(); |
| | | for(Object o : keyValueCommanderPositionList){ |
| | | Map<String,Object> map = JSON.parseObject((String) o); |
| | | if(((String)map.get("state")).equals("0")){//state为0å°±æ¯æªå®¡æ¹ |
| | | SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId")); |
| | | map.put("userName",sysUser.getUserName()); |
| | | if(sysUser.getNickName() != null){ |
| | | map.put("nickName",sysUser.getNickName()); |
| | | }else{ |
| | | map.put("nickName",sysUser.getNickName()); |
| | | } |
| | | resultCommanderPosition.add(map); |
| | | } |
| | | public List<Long> getOwnAndChildrenDeptIdList(List<Long> deptIdList,List<Long> deptIdListr){ |
| | | deptIdListr.addAll(deptIdList); |
| | | List<Long> result = sysDeptMapper.getChildrenDeptIdList(deptIdList); |
| | | if(result.size() != 0){ |
| | | deptIdListr.addAll(result); |
| | | result = getOwnAndChildrenDeptIdList(result,deptIdListr); |
| | | } |
| | | //æ¥ç车è¾ä½ç½®ç³è¯· |
| | | String keySYCarsPosition = "checkSYCarsPosition_" + usersId + "_"; |
| | | List<Object> keyValueSYCarsPositionList = redisCache.getListKey(keySYCarsPosition); |
| | | List<Map<String, Object>> resultSYCarsPosition = new ArrayList(); |
| | | for(Object o : keyValueSYCarsPositionList){ |
| | | Map<String,Object> map = JSON.parseObject((String) o); |
| | | if(((String)map.get("state")).equals("0")){//state为0å°±æ¯æªå®¡æ¹ |
| | | SysUser sysUser = sysUserMapper.selectUserById((String) map.get("soilderId")); |
| | | map.put("userName",sysUser.getUserName()); |
| | | if(sysUser.getNickName() != null){ |
| | | map.put("nickName",sysUser.getNickName()); |
| | | }else{ |
| | | map.put("nickName",sysUser.getNickName()); |
| | | } |
| | | resultSYCarsPosition.add(map); |
| | | } |
| | | } |
| | | result.put("commander",resultCommanderPosition); |
| | | result.put("SYCars",resultSYCarsPosition); |
| | | return result; |
| | | }*/ |
| | | deptIdListr = deptIdListr.stream().distinct().collect(Collectors.toList()); |
| | | return deptIdListr; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.ruoyi.device.uav.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.dtflys.forest.exceptions.ForestNetworkException; |
| | | import com.dtflys.forest.exceptions.ForestRuntimeException; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.ConfigUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.device.uav.websocketclient.UAVWebsocketClient; |
| | | import com.ruoyi.sy.controller.ArdSyCarController; |
| | | import com.ruoyi.utils.forest.UavClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.apache.commons.collections4.map.HashedMap; |
| | | import org.java_websocket.WebSocket; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpMethod; |
| | |
| | | import java.io.IOException; |
| | | import java.lang.reflect.InvocationTargetException; |
| | | import java.lang.reflect.Method; |
| | | import java.util.Map; |
| | | import java.net.URI; |
| | | import java.net.URISyntaxException; |
| | | import java.util.*; |
| | | |
| | | @Service |
| | | @Slf4j(topic = "uav") |
| | |
| | | |
| | | private Map uavUser;//ç»å½çç¨æ·ä¿¡æ¯ |
| | | private ObjectMapper om = new ObjectMapper(); |
| | | |
| | | private Map<String, UAVWebsocketClient> UAVWebsocketClientMap = new HashedMap(); |
| | | |
| | | private String token; |
| | | |
| | | @Autowired |
| | | private UavClient uavClient; |
| | | @Autowired |
| | |
| | | |
| | | getUavConfig(); |
| | | this.login(); |
| | | //å建æ 人æºWebsocket客æ·ç«¯ |
| | | createWebsocketCients(); |
| | | } |
| | | |
| | | private void getUavConfig() { |
| | |
| | | String token = this.getToken(); |
| | | res = (String) requestMethod.invoke(this.uavClient, this.host + url, token, data); |
| | | } catch (IllegalAccessException e) { |
| | | System.out.println("doUavRequest 访é®å¤±è´¥"); |
| | | System.out.println(url); |
| | | log.error("doUavRequest 访é®å¤±è´¥" + e.getMessage()); |
| | | } catch (InvocationTargetException e) { |
| | | System.out.println("doUavRequest æ§è¡å¤±è´¥"); |
| | | System.out.println(url); |
| | | log.error("doUavRequest æ§è¡å¤±è´¥" + e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | String res = uavClient.GET(this.host+"manage/api/v1/devices", token, "{}"); |
| | | res+=""; |
| | | //System.out.println(res); |
| | | |
| | | //tokenèµå¼ |
| | | this.token = token; |
| | | } catch (ForestNetworkException fe) { |
| | | if (fe.getStatusCode() == 401) {//token失æ,éæ°ç»å½ |
| | | this.login(); |
| | | //忬¡è·åtoken |
| | | uavUser = redisCache.getCacheMap("uav:uavUser"); |
| | | token = (String) uavUser.get("access_token"); |
| | | //tokenèµå¼ |
| | | this.token = token; |
| | | return token; |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public void createWebsocketCients(){ |
| | | /*String ip = this.host.replace("http://", ""); |
| | | if(this.UAVWebsocketClientMap.get("status") != null && this.UAVWebsocketClientMap.get("control") != null){ |
| | | //æ 人æºç¶æçæ´» |
| | | UAVWebsocketClient uavStatusWebsocketClient = this.UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient.getHeartBeatTimer().cancel(); |
| | | uavStatusWebsocketClient.close(); |
| | | //æ äººæºæ§å¶çæ´» |
| | | UAVWebsocketClient uavControlWebsocketClient = this.UAVWebsocketClientMap.get("control"); |
| | | uavControlWebsocketClient.getHeartBeatTimer().cancel(); |
| | | uavControlWebsocketClient.close(); |
| | | |
| | | this.UAVWebsocketClientMap.remove("status"); |
| | | this.UAVWebsocketClientMap.remove("control"); |
| | | } |
| | | |
| | | String uavStatusWsURL = "ws://" + ip + "api/v1/ws?x-auth-token=" + token; |
| | | System.out.println(uavStatusWsURL); |
| | | UAVWebsocketClient uavStatusWebsocketClient; |
| | | try { |
| | | uavStatusWebsocketClient = new UAVWebsocketClient(new URI(uavStatusWsURL)); |
| | | uavStatusWebsocketClient.connect(); |
| | | System.out.println("è¿æ¥ä¸ããã"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(!uavStatusWebsocketClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){ |
| | | uavStatusWebsocketClient.close(); |
| | | return; |
| | | } |
| | | Date date = new Date(); |
| | | Timer heartBeatTimer = new Timer(); |
| | | TimerTask heartBeatTask = new TimerTask(){ |
| | | public void run(){ |
| | | Map<String,Object> para = new HashMap(); |
| | | para.put("biz_code", "user_cmd"); |
| | | para.put("version", "1.0"); |
| | | Date date = new Date(); |
| | | para.put("time_stamp", String.valueOf(date.getTime())); |
| | | Map<String,String> payload = new HashMap(); |
| | | payload.put("timeStamp", String.valueOf(date.getTime())); |
| | | Map<String,Object> data = new HashMap(); |
| | | data.put("dataHead", "0x7479"); |
| | | data.put("cmdCode", "0x02"); |
| | | data.put("payload", payload); |
| | | para.put("data", data); |
| | | try{ |
| | | uavStatusWebsocketClient.send(JSON.toJSONString(para)); |
| | | System.out.println("æ 人æºç¶æå¿è·³åé"); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println(uavStatusWebsocketClient.getServerUri()); |
| | | } |
| | | } |
| | | }; |
| | | uavStatusWebsocketClient.setHeartBeatTimer(heartBeatTimer); |
| | | heartBeatTimer.scheduleAtFixedRate(heartBeatTask,date,10*1000); |
| | | this.UAVWebsocketClientMap.put("status", uavStatusWebsocketClient); |
| | | } catch (NumberFormatException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (URISyntaxException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String uavControlWsURL = "ws://" + ip + "api/v1/ws/cmd?x-auth-token=" + token; |
| | | System.out.println(uavControlWsURL); |
| | | UAVWebsocketClient uavControlWebsocketClient; |
| | | try { |
| | | uavControlWebsocketClient = new UAVWebsocketClient(new URI(uavControlWsURL)); |
| | | uavControlWebsocketClient.connect(); |
| | | System.out.println("è¿æ¥ä¸ããã"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(!uavControlWebsocketClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){ |
| | | //æ 人æºç¶æçæ´» |
| | | UAVWebsocketClient uavStatusWebsocketClient0 = this.UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient0.getHeartBeatTimer().cancel(); |
| | | uavStatusWebsocketClient0.close(); |
| | | |
| | | uavControlWebsocketClient.close(); |
| | | return; |
| | | } |
| | | Date date = new Date(); |
| | | Timer heartBeatTimer = new Timer(); |
| | | TimerTask heartBeatTask = new TimerTask(){ |
| | | public void run(){ |
| | | Map<String,Object> para = new HashMap(); |
| | | para.put("biz_code", "user_cmd"); |
| | | para.put("version", "1.0"); |
| | | Date date = new Date(); |
| | | para.put("time_stamp", String.valueOf(date.getTime())); |
| | | Map<String,String> payload = new HashMap(); |
| | | payload.put("timeStamp", String.valueOf(date.getTime())); |
| | | Map<String,Object> data = new HashMap(); |
| | | data.put("dataHead", "0x7479"); |
| | | data.put("cmdCode", "0x02"); |
| | | data.put("payload", payload); |
| | | para.put("data", data); |
| | | try{ |
| | | uavControlWebsocketClient.send(JSON.toJSONString(para)); |
| | | System.out.println("æ äººæºæ§å¶å¿è·³åé"); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println(uavControlWebsocketClient.getServerUri()); |
| | | } |
| | | } |
| | | }; |
| | | uavControlWebsocketClient.setHeartBeatTimer(heartBeatTimer); |
| | | heartBeatTimer.scheduleAtFixedRate(heartBeatTask,date,10*1000); |
| | | this.UAVWebsocketClientMap.put("control", uavControlWebsocketClient); |
| | | } catch (NumberFormatException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (URISyntaxException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | }*/ |
| | | String ip = this.host.replace("http://", ""); |
| | | Date date = new Date(); |
| | | Timer heartBeatTimer = new Timer(); |
| | | TimerTask heartBeatTask = new TimerTask(){ |
| | | public void run(){ |
| | | if(token != null){//夿æ¯å¦ä¸ºnull |
| | | if(UAVWebsocketClientMap.get("status") != null && UAVWebsocketClientMap.get("control") != null){ |
| | | String oldURL = UAVWebsocketClientMap.get("status").getServerUri().toString(); |
| | | String oldToken = oldURL.split("x-auth-token=")[1]; |
| | | if(!oldToken.equals(token)){//tokenæ´æ°ä»æ°å建客æ·ç«¯ |
| | | //å客æ·ç«¯çæ´» |
| | | UAVWebsocketClientMap.get("status").close();//æ 人æºç¶æçæ´» |
| | | UAVWebsocketClientMap.get("control").close();//æ äººæºæ§å¶çæ´» |
| | | UAVWebsocketClientMap.remove("status"); |
| | | UAVWebsocketClientMap.remove("control"); |
| | | |
| | | String uavStatusWsURL = "ws://" + ip + "api/v1/ws?x-auth-token=" + token; |
| | | UAVWebsocketClient uavStatusWebsocketClient = null; |
| | | try { |
| | | uavStatusWebsocketClient = new UAVWebsocketClient(new URI(uavStatusWsURL)); |
| | | uavStatusWebsocketClient.connect(); |
| | | System.out.println("è¿æ¥ä¸ããã"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(!uavStatusWebsocketClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){ |
| | | uavStatusWebsocketClient.close(); |
| | | uavStatusWebsocketClient = null; |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (URISyntaxException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String uavControlWsURL = "ws://" + ip + "api/v1/ws/cmd?x-auth-token=" + token; |
| | | UAVWebsocketClient uavControlWebsocketClient = null; |
| | | try { |
| | | uavControlWebsocketClient = new UAVWebsocketClient(new URI(uavControlWsURL)); |
| | | uavControlWebsocketClient.connect(); |
| | | System.out.println("è¿æ¥ä¸ããã"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(!uavControlWebsocketClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){ |
| | | //æ 人æºç¶æçæ´» |
| | | UAVWebsocketClient uavStatusWebsocketClient0 = UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient0.close(); |
| | | |
| | | uavControlWebsocketClient.close(); |
| | | uavStatusWebsocketClient0 = null; |
| | | uavControlWebsocketClient = null; |
| | | //return; |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (URISyntaxException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(uavStatusWebsocketClient != null || uavControlWebsocketClient != null){ |
| | | UAVWebsocketClientMap.put("status", uavStatusWebsocketClient); |
| | | UAVWebsocketClientMap.put("control", uavControlWebsocketClient); |
| | | |
| | | Map<String,Object> para = new HashMap(); |
| | | para.put("biz_code", "user_cmd"); |
| | | para.put("version", "1.0"); |
| | | Date date = new Date(); |
| | | para.put("time_stamp", String.valueOf(date.getTime())); |
| | | Map<String,String> payload = new HashMap(); |
| | | payload.put("timeStamp", String.valueOf(date.getTime())); |
| | | Map<String,Object> data = new HashMap(); |
| | | data.put("dataHead", "0x7479"); |
| | | data.put("cmdCode", "0x02"); |
| | | data.put("payload", payload); |
| | | para.put("data", data); |
| | | try{ |
| | | uavStatusWebsocketClient.send(JSON.toJSONString(para)); |
| | | uavControlWebsocketClient.send(JSON.toJSONString(para)); |
| | | //System.out.println("æ 人æºå¿è·³åé"); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println(uavStatusWebsocketClient.getServerUri()); |
| | | System.out.println(uavControlWebsocketClient.getServerUri()); |
| | | //æ 人æºç¶æçæ´» |
| | | uavStatusWebsocketClient = UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient.close(); |
| | | //æ äººæºæ§å¶çæ´» |
| | | uavControlWebsocketClient = UAVWebsocketClientMap.get("control"); |
| | | uavControlWebsocketClient.close(); |
| | | |
| | | UAVWebsocketClientMap.remove("status"); |
| | | UAVWebsocketClientMap.remove("control"); |
| | | } |
| | | } |
| | | }else{ |
| | | Map<String,Object> para = new HashMap(); |
| | | para.put("biz_code", "user_cmd"); |
| | | para.put("version", "1.0"); |
| | | Date date = new Date(); |
| | | para.put("time_stamp", String.valueOf(date.getTime())); |
| | | Map<String,String> payload = new HashMap(); |
| | | payload.put("timeStamp", String.valueOf(date.getTime())); |
| | | Map<String,Object> data = new HashMap(); |
| | | data.put("dataHead", "0x7479"); |
| | | data.put("cmdCode", "0x02"); |
| | | data.put("payload", payload); |
| | | para.put("data", data); |
| | | UAVWebsocketClient uavStatusWebsocketClient = UAVWebsocketClientMap.get("status"); |
| | | UAVWebsocketClient uavControlWebsocketClient = UAVWebsocketClientMap.get("control"); |
| | | try{ |
| | | uavStatusWebsocketClient.send(JSON.toJSONString(para)); |
| | | uavControlWebsocketClient.send(JSON.toJSONString(para)); |
| | | //System.out.println("æ 人æºå¿è·³åé"); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println(uavStatusWebsocketClient.getServerUri()); |
| | | System.out.println(uavControlWebsocketClient.getServerUri()); |
| | | //æ 人æºç¶æçæ´» |
| | | uavStatusWebsocketClient = UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient.close(); |
| | | //æ äººæºæ§å¶çæ´» |
| | | uavControlWebsocketClient = UAVWebsocketClientMap.get("control"); |
| | | uavControlWebsocketClient.close(); |
| | | |
| | | UAVWebsocketClientMap.remove("status"); |
| | | UAVWebsocketClientMap.remove("control"); |
| | | } |
| | | } |
| | | }else{ |
| | | String uavStatusWsURL = "ws://" + ip + "api/v1/ws?x-auth-token=" + token; |
| | | System.out.println(uavStatusWsURL); |
| | | UAVWebsocketClient uavStatusWebsocketClient = null; |
| | | try { |
| | | uavStatusWebsocketClient = new UAVWebsocketClient(new URI(uavStatusWsURL)); |
| | | uavStatusWebsocketClient.connect(); |
| | | System.out.println("è¿æ¥ä¸ããã"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(!uavStatusWebsocketClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){ |
| | | uavStatusWebsocketClient.close(); |
| | | uavStatusWebsocketClient = null; |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (URISyntaxException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String uavControlWsURL = "ws://" + ip + "api/v1/ws/cmd?x-auth-token=" + token; |
| | | System.out.println(uavControlWsURL); |
| | | UAVWebsocketClient uavControlWebsocketClient = null; |
| | | try { |
| | | uavControlWebsocketClient = new UAVWebsocketClient(new URI(uavControlWsURL)); |
| | | uavControlWebsocketClient.connect(); |
| | | System.out.println("è¿æ¥ä¸ããã"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(!uavControlWebsocketClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){ |
| | | //æ 人æºç¶æçæ´» |
| | | UAVWebsocketClient uavStatusWebsocketClient0 = UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient0.close(); |
| | | |
| | | uavControlWebsocketClient.close(); |
| | | uavStatusWebsocketClient0 = null; |
| | | uavControlWebsocketClient = null; |
| | | } |
| | | } catch (NumberFormatException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } catch (URISyntaxException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | if(uavStatusWebsocketClient != null || uavControlWebsocketClient != null){ |
| | | UAVWebsocketClientMap.put("status", uavStatusWebsocketClient); |
| | | UAVWebsocketClientMap.put("control", uavControlWebsocketClient); |
| | | |
| | | Map<String,Object> para = new HashMap(); |
| | | para.put("biz_code", "user_cmd"); |
| | | para.put("version", "1.0"); |
| | | Date date = new Date(); |
| | | para.put("time_stamp", String.valueOf(date.getTime())); |
| | | Map<String,String> payload = new HashMap(); |
| | | payload.put("timeStamp", String.valueOf(date.getTime())); |
| | | Map<String,Object> data = new HashMap(); |
| | | data.put("dataHead", "0x7479"); |
| | | data.put("cmdCode", "0x02"); |
| | | data.put("payload", payload); |
| | | para.put("data", data); |
| | | try{ |
| | | uavStatusWebsocketClient.send(JSON.toJSONString(para)); |
| | | uavControlWebsocketClient.send(JSON.toJSONString(para)); |
| | | //System.out.println("æ 人æºå¿è·³åé"); |
| | | }catch(Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println(uavStatusWebsocketClient.getServerUri()); |
| | | System.out.println(uavControlWebsocketClient.getServerUri()); |
| | | //æ 人æºç¶æçæ´» |
| | | uavStatusWebsocketClient = UAVWebsocketClientMap.get("status"); |
| | | uavStatusWebsocketClient.close(); |
| | | //æ äººæºæ§å¶çæ´» |
| | | uavControlWebsocketClient = UAVWebsocketClientMap.get("control"); |
| | | uavControlWebsocketClient.close(); |
| | | |
| | | UAVWebsocketClientMap.remove("status"); |
| | | UAVWebsocketClientMap.remove("control"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }; |
| | | heartBeatTimer.scheduleAtFixedRate(heartBeatTask,date,10*1000); |
| | | } |
| | | |
| | | |
| | | public String Encrypt(String sSrc, String sKey) { |
| | | if (sKey == null) { |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.device.uav.websocketclient; |
| | | |
| | | import org.java_websocket.client.WebSocketClient; |
| | | import org.java_websocket.handshake.ServerHandshake; |
| | | |
| | | import java.net.URI; |
| | | import java.util.Timer; |
| | | |
| | | public class UAVWebsocketClient extends WebSocketClient { |
| | | |
| | | private URI serverUri; |
| | | |
| | | public UAVWebsocketClient(URI serverUri) { |
| | | super(serverUri); |
| | | this.serverUri = serverUri; |
| | | } |
| | | |
| | | public URI getServerUri() { |
| | | return serverUri; |
| | | } |
| | | |
| | | public void setServerUri(URI serverUri) { |
| | | this.serverUri = serverUri; |
| | | } |
| | | |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onMessage(String s) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Exception e) { |
| | | |
| | | } |
| | | } |
| | |
| | | |
| | | @Override |
| | | public Results chaseCarByCarId(String usersId, String carId, String cycle) { |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | }else{ |
| | | return Results.error("æ²¡æææ¥ä¸ä¸è½¦è¾ç¨æ·"); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("ä¸ä¸è½¦è¾å°åæªå½å
¥"); |
| | | } |
| | | |
| | | String sessionId = ""; |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | if(key.startsWith(usersId + "_")){ |
| | |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//åæ¢è¿½è¸ªï¼æ¹ä¸ºå®æ¶30sæ¨é |
| | | System.out.println("åæ¢è¿½è¸ª"); |
| | | } |
| | | return Results.succeed("åæ¢è¿½è¸ª"); |
| | |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time"); |
| | | String time = ""; |
| | | if(distanceSYResult.size() != 0){ |
| | | time = distanceSYResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("ä¸ä¸è½¦è¾å®æ¶æªå½å
¥"); |
| | | } |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//å¼å§è¿½è¸ªï¼æ¹ä¸ºå®æ¶æ¨é |
| | | |
| | | Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//æ¥è¯¢å½å车è¾ä½ç½® |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = ardSyUser.getPassword(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | } |
| | | if(!userId.equals("") && !password.equals("") && !syURL.equals("")){ |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//åæ¢è¿½è¸ªï¼æ¹ä¸ºå®æ¶30s |
| | | } |
| | | System.out.println("ç¨æ·ç¦»çº¿ï¼åæ¢è¿½è¸ª"); |
| | | } |
| | | } |
| | |
| | | Map<String, Map<String, Object>> map = new HashMap(); |
| | | map.put(carId, new HashMap()); |
| | | PositionContainer.getUserPositionMap().put(usersId, map); |
| | | |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | List<SysConfig> distanceSYResult = sysConfigMapper.selectByType("31time"); |
| | | String time = ""; |
| | | if(distanceSYResult.size() != 0){ |
| | | time = distanceSYResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return Results.error("ä¸ä¸è½¦è¾å®æ¶æªå½å
¥"); |
| | | } |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%22"+time+"%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//å¼å§è¿½è¸ªï¼æ¹ä¸ºå®æ¶æ¨é |
| | | |
| | | Map<String, Object> position = PositionContainer.getCarPositionMap().get(carId);//æ¥è¯¢å½å车è¾ä½ç½® |
| | | if (position != null) { |
| | | if (position.size() != 0) { |
| | |
| | | userCarTimerMap.get(usersId).cancel(); |
| | | userCarTimerMap.remove(usersId); |
| | | PositionContainer.getUserPositionMap().remove(usersId); |
| | | |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | String userId =""; |
| | | String password = ""; |
| | | if(ardSyUser != null){ |
| | | userId = ardSyUser.getUserId(); |
| | | password = ardSyUser.getPassword(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | } |
| | | if(!userId.equals("") && !password.equals("") && !syURL.equals("")){ |
| | | Map<String,Object> loginResult = sYClient.logIn(syURL, password, userId); |
| | | String sySessionId = (String) loginResult.get("sessionId"); |
| | | String params = "%7B%220020%22:%220%22,%220029%22:%2230%22%7d"; |
| | | sYClient.changePositionSendMode(syURL, carId,104,"CmdSetParam",params,sySessionId);//åæ¢è¿½è¸ªï¼æ¹ä¸ºå®æ¶30s |
| | | } |
| | | System.out.println("ç¨æ·ç¦»çº¿ï¼åæ¢è¿½è¸ª"); |
| | | } |
| | | } |
| | |
| | | |
| | | @Get(url = "${syURL}/gps-web/api/get_alarm_h_pfm_detail.jsp?carId=${carId}&startTime=${startTime}&endTime=${endTime}&typeIds=&speed=&duration=&alarmSrcs=&alarmLevels=1&sessionId=${sessionId}") |
| | | Map<String,Object> getAlarmHPfmCountDetail(@Var("syURL") String syURL, @Var("carId") String carId,@Var("sessionId") String sessionId,@Var("startTime") String startTime,@Var("endTime") String endTime); |
| | | |
| | | @Get(url = "${syURL}/gps-web/api/send_cmd.jsp?params=${paramsStr}&userId=admin&loginType=user&carId=${carId}&cmdId=${cmdId}&cmd=${cmd}&sessionId=${sessionId}") |
| | | Map<String,Object> changePositionSendMode(@Var("syURL") String syURL, @Var("carId") String carId,@Var("cmdId") Integer cmdId,@Var("cmd") String cmd,@Var("paramsStr") String paramsStr,@Var("sessionId") String sessionId); |
| | | } |
| | |
| | | left join sys_user u on u.user_id = c.user_id |
| | | </sql> |
| | | |
| | | <resultMap type="ArdAlarmpointsWell" id="ArdAlarmpointsWellOnlyResult"> |
| | | <result property="id" column="id"/> |
| | | <result property="wellId" column="well_id"/> |
| | | <result property="wellNumber" column="well_number"/> |
| | | <result property="oilProduction" column="oil_production"/> |
| | | <result property="wellBlock" column="well_block"/> |
| | | <result property="productionDate" column="production_date"/> |
| | | <result property="displacementMode" column="displacement_mode"/> |
| | | <result property="surroundingEnvironment" column="surrounding_environment"/> |
| | | <result property="wellType" column="well_type"/> |
| | | <result property="installedLoad" column="installed_load"/> |
| | | <result property="meteringStation" column="metering_station"/> |
| | | <result property="transferStation" column="transfer_station"/> |
| | | <result property="dehydrationStation" column="dehydration_station"/> |
| | | <result property="runStatus" column="run_status"/> |
| | | <result property="longitude" column="longitude"/> |
| | | <result property="latitude" column="latitude"/> |
| | | <result property="altitude" column="altitude"/> |
| | | <result property="deptId" column="dept_id"/> |
| | | <result property="userId" column="user_id"/> |
| | | <result property="createBy" column="create_by"/> |
| | | <result property="createTime" column="create_time"/> |
| | | <result property="updateBy" column="update_by"/> |
| | | <result property="updateTime" column="update_time"/> |
| | | </resultMap> |
| | | |
| | | <select id="selectArdAlarmpointsWellList" parameterType="ArdAlarmpointsWell" resultMap="ArdAlarmpointsWellResult"> |
| | | <include refid="selectArdAlarmpointsWellVo"/> |
| | | <where> |
| | |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="getWellDataByPatrolplanIdAndPosition" resultMap="ArdAlarmpointsWellOnlyResult"> |
| | | select aaw.* from ard_app_patrolplan aap |
| | | inner join ard_app_patrolpoint aap0 on aap.id = aap0.patrolplan_id |
| | | inner join ard_alarmpoints_well aaw on aap0.alarmpoints_id = aaw.id |
| | | where del is null and aap.id = #{patrolplanId} |
| | | and f_compute_distance(cast(#{longitude} as decimal),cast(#{latitude} as decimal),aaw.longitude,aaw.latitude) |
| | | <= (select cast(sc.config_value as decimal) from sys_config sc where sc.config_key = 'appAlarmPointsDistance') |
| | | order by f_compute_distance(cast(#{longitude} as decimal),cast(#{latitude} as decimal),aaw.longitude,aaw.latitude) desc limit 1 offset 0 |
| | | </select> |
| | | |
| | | <select id="getWellById" resultMap="ArdAlarmpointsWellOnlyResult"> |
| | | select aaw.* from ard_alarmpoints_well aaw where aaw.id = #{id} |
| | | </select> |
| | | |
| | | |
| | | <select id="conditionList" parameterType="List" |
| | | resultType="com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellDeptVo"> |
| | |
| | | and aaa.state = '1' and su.app_online_state = '1' |
| | | order by aap.create_time desc limit 1 offset 0 |
| | | </select> |
| | | |
| | | <select id="getAPPPositionByUserIdAndTime" parameterType="java.lang.String" resultMap="ArdAppPositionResult"> |
| | | select * from ard_app_position aap |
| | | where aap.user_id = #{userId} and aap.create_time >= #{beginTime} |
| | | and aap.create_time <= #{endTime} order by aap.create_time asc |
| | | </select> |
| | | |
| | | <select id="getLastAPPPositionByUserId" parameterType="java.lang.String" resultMap="ArdAppPositionResult"> |
| | | select * from ard_app_position aap |
| | | where aap.user_id = #{userId} |
| | | order by aap.create_time desc limit 1 offset 0 |
| | | </select> |
| | | </mapper> |
| | |
| | | return Results.succeed("ä¿®æ¹å¯ç æåï¼"); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | server: |
| | | # æå¡å¨çHTTP端å£ï¼é»è®¤ä¸º8080 |
| | | port: 8080 |
| | | ssl: |
| | | # å¼å¯HTTPSï¼å¹¶é
ç½®èªç¾åè¯ä¹¦ |
| | | enabled: true |
| | | #ç§é¥åºæä»¶åç§°ï¼å³ä¸é¢çæçèªç¾åè¯ä¹¦ |
| | | key-store: classpath:keystore |
| | | # çæç§é¥åºæä»¶çå¯ç |
| | | key-store-password: 123456 |
| | | # ç§é¥åºç±»åï¼JKS为jdkçkeytoolå·¥å
·é»è®¤çæçç§é¥åºç±»åï¼ |
| | | key-store-type: JKS |
| | | # ç§é¥å«å |
| | | key-alias: tomcat |
| | | servlet: |
| | | # åºç¨ç访é®è·¯å¾ |
| | | context-path: / |
| | |
| | | # æ¥å¿é
ç½® |
| | | logging: |
| | | level: |
| | | com.ruoyi.common.filter.MyI18nInterceptor: debug |
| | | com.ruoyi.common.filter.MyI18nInterceptor: info |
| | | authorize: info |
| | | minio: info |
| | | hikSdk: debug |
| | | dhSdk: debug |
| | | sdk: debug |
| | | vtdu: debug |
| | | hikSdk: info |
| | | dhSdk: info |
| | | sdk: info |
| | | vtdu: info |
| | | stealAlarm: info |
| | | websocket: info |
| | | patrolInspectionTask: info |
| | | mqtt: info |
| | | patrolInspectionTask: debug |
| | | mqtt: debug |
| | | guideQueue: debug |
| | | rongCloud: info |
| | | cmd: info |
| | | cmd: debug |
| | | alarm: debug |
| | | uav: info |
| | | sy: debug |
| | | mqttCar: debug |
| | | sy: info |
| | | mqttCar: info |
| | | ## knife4jé
ç½® |
| | | knife4j: |
| | | # knife4jå¢å¼ºåè½,å¼å¯åä¸é¢åæ°æçæ |
| | |
| | | #å
¨é¨ä¸»é¢ï¼minioEvent,radar,stealelec,tube,camera,external,accessControl,apponekey,digitization3 |
| | | mqtt: |
| | | host: tcp://192.168.2.15:1883 |
| | | clientId: Server-227 |
| | | clientId: Server |
| | | username: admin |
| | | password: admin |
| | | topic: minioEvent,radar,stealelec,tube,camera,external,accessControl,apponekey,digitization3,radarForceGuide |
| | |
| | | enabled: true |
| | | #ä¸ä¸è½¦è¾å¼å
³ |
| | | syCar: |
| | | enabled: true |
| | | enabled: true |
| | |
| | | server: |
| | | # æå¡å¨çHTTP端å£ï¼é»è®¤ä¸º8080 |
| | | port: 8080 |
| | | ssl: |
| | | # å¼å¯HTTPSï¼å¹¶é
ç½®èªç¾åè¯ä¹¦ |
| | | enabled: true |
| | | #ç§é¥åºæä»¶åç§°ï¼å³ä¸é¢çæçèªç¾åè¯ä¹¦ |
| | | key-store: classpath:keystore |
| | | # çæç§é¥åºæä»¶çå¯ç |
| | | key-store-password: 123456 |
| | | # ç§é¥åºç±»åï¼JKS为jdkçkeytoolå·¥å
·é»è®¤çæçç§é¥åºç±»åï¼ |
| | | key-store-type: JKS |
| | | # ç§é¥å«å |
| | | key-alias: tomcat |
| | | servlet: |
| | | # åºç¨ç访é®è·¯å¾ |
| | | context-path: / |
| | |
| | | List<SysUser> getOnlineCommander(String usersId); |
| | | |
| | | List<SysUser> getOnlinePC(@Param("usersId") String usersId,@Param("onLinePCIdList")List<String> onLinePCIdList); |
| | | |
| | | List<SysUser> getOwnAndChildrenOnlineSoilderList(@Param("deptIdList")List<Long> deptIdList); |
| | | |
| | | List<SysUser> getOwnAndChildrenSoilderListAll(@Param("deptIdList")List<Long> deptIdList); |
| | | } |
| | |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.DictUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.system.mapper.*; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.ruoyi.system.domain.SysPost; |
| | | import com.ruoyi.system.domain.SysUserPost; |
| | | import com.ruoyi.system.domain.SysUserRole; |
| | | import com.ruoyi.system.mapper.SysPostMapper; |
| | | import com.ruoyi.system.mapper.SysRoleMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.mapper.SysUserPostMapper; |
| | | import com.ruoyi.system.mapper.SysUserRoleMapper; |
| | | import com.ruoyi.system.service.ISysConfigService; |
| | | import com.ruoyi.system.service.ISysUserService; |
| | | |
| | |
| | | private RedisCache redisCache; |
| | | @Resource |
| | | private ArdAlarmTypeConfigMapper ardAlarmTypeConfigMapper; |
| | | |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | /** |
| | | * 项ç®å¯å¨æ¶ï¼åå§ååæ°å°ç¼å |
| | |
| | | queryWrapper.eq("dept_id",deptId).eq("del_flag","0").eq("app_user_type","1"); |
| | | return userMapper.selectList(queryWrapper); |
| | | } |
| | | |
| | | } |
| | |
| | | #{userId} |
| | | </foreach> |
| | | </select> |
| | | |
| | | <select id="getOwnAndChildrenOnlineSoilderList" resultMap="SysUserOnlyResult"> |
| | | select distinct su.user_id,su.dept_id,su.user_name, |
| | | concat(su.nick_name,'(',sd.dept_name,')') as nick_name from sys_user su |
| | | inner join sys_user_role sur on su.user_id = sur.user_id |
| | | inner join sys_role sr on sur.role_id = sr.role_id |
| | | inner join sys_dept sd on su.dept_id = sd.dept_id |
| | | where sr.role_key = 'appUser' and su.dept_id in |
| | | <foreach collection="deptIdList" item="deptId" open="(" close=")" separator=","> |
| | | #{deptId} |
| | | </foreach> |
| | | and su.app_online_state = '1' and su.status = '0' and su.del_flag = '0' |
| | | order by su.dept_id asc |
| | | </select> |
| | | |
| | | <select id="getOwnAndChildrenSoilderListAll" resultMap="SysUserOnlyResult"> |
| | | select distinct su.user_id,su.dept_id,su.user_name, |
| | | concat(su.nick_name,'(',sd.dept_name,')') as nick_name, |
| | | su.app_online_state from sys_user su |
| | | inner join sys_user_role sur on su.user_id = sur.user_id |
| | | inner join sys_role sr on sur.role_id = sr.role_id |
| | | inner join sys_dept sd on su.dept_id = sd.dept_id |
| | | where sr.role_key = 'appUser' and su.dept_id in |
| | | <foreach collection="deptIdList" item="deptId" open="(" close=")" separator=","> |
| | | #{deptId} |
| | | </foreach> |
| | | and su.status = '0' and su.del_flag = '0' |
| | | order by su.dept_id asc |
| | | </select> |
| | | </mapper> |