艾金辉
2023-07-21 3c075575f95f2e10a66d38e1b28c284e938f2e52
根据用户名获取三一列表
已修改10个文件
131 ■■■■■ 文件已修改
ard-work/pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/client/ARDCarGPSLogInClient.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/client/ARDCarSYGPSClient.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java 78 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyUserMapper.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/mapper/SysParaMapper.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/IArdSyUserService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyUserServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/src/main/resources/mapper/sy/ArdSyUserMapper.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-druid.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ard-work/pom.xml
@@ -117,6 +117,13 @@
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.alibaba.fastjson2/fastjson2 -->
        <dependency>
            <groupId>com.alibaba.fastjson2</groupId>
            <artifactId>fastjson2</artifactId>
            <version>2.0.36</version>
        </dependency>
    </dependencies>
    <build>
ard-work/src/main/java/com/ruoyi/client/ARDCarGPSLogInClient.java
@@ -1,10 +1,10 @@
package com.ruoyi.client;
import com.alibaba.fastjson.JSON;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import com.alibaba.fastjson2.JSON;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.apache.commons.codec.digest.DigestUtils;
import java.io.IOException;
import java.util.HashMap;
ard-work/src/main/java/com/ruoyi/client/ARDCarSYGPSClient.java
@@ -1,10 +1,10 @@
package com.ruoyi.client;
import com.alibaba.fastjson.JSON;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.ResponseBody;
import com.alibaba.fastjson2.JSON;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import java.io.IOException;
import java.util.HashMap;
ard-work/src/main/java/com/ruoyi/sy/controller/ArdSyCarController.java
@@ -11,6 +11,7 @@
import com.ruoyi.client.ARDCarSYGPSClient;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyUser;
import com.ruoyi.sy.service.IArdSyUserService;
import com.ruoyi.sy.service.SysParaService;
import com.ruoyi.system.domain.SysConfig;
@@ -226,48 +227,49 @@
    @ApiOperation("根据用户获取三一列表")
    public Map<String,Object> allListByUser(){
        String usersId = SecurityUtils.getUserId();
        Map<String, String> result = logInMap.get(Integer.parseInt(usersId));
        String syURL = sysParaService.getSYURL();
        if(result == null){
            Map<String,Object> m = iArdSyUserService.selectArdSyUserByUsersId(Integer.parseInt(usersId));
            if(m == null){
                Map<String,Object> map0 = new HashMap();
                map0.put("rspDesc", "当前登录用户未挂接车辆权限");
                map0.put("rspCode", "0");
                return map0;
            }
            Map<String, Object> result0 = ARDCarGPSLogInClient.loginIn(syURL,(String) m.get("userId"), (String) m.get("password"));
            result = new HashMap();
            result.put("userId", (String) m.get("userId"));
            result.put("sessionId", (String) result0.get("sessionId"));
        }
        ArdSyUser ardSyUser = iArdSyUserService.userById(usersId);
        Map<String,Object> result0 = new HashMap();
        try {
            result0 = ARDCarSYGPSClient.getCarGPSTeamList(syURL,result.get("userId"),result.get("sessionId"));//
        } catch (Exception e) {
            Map<String,Object> map = new HashMap();
            map.put("rspCode", 0);
            map.put("list", new ArrayList());
            return map;
        }
        int online = 0;
        for(Map<String,Object> map : (List<Map<String,Object>>) result0.get("list")){
            Map<String,Object> resultMap = (Map<String, Object>) ARDCarSYGPSClient.getCarListByTeamId(syURL,(String)map.get("teamId"),result.get("sessionId"));
            List<Map<String,Object>> carList = (List<Map<String, Object>>) resultMap.get("carList");
            for(Map<String,Object> m : carList){
                if(((String) m.get("stateCn")).contains("在线")){
                    online = online + 1;
                }else{
                    continue;
                }
        //判断关联表是否有数据
        if(ardSyUser!=null){
            //31用户名密码
            String username31 = ardSyUser.getUserId();
            String password31 = ardSyUser.getPassword();
            //查询地址
            Map<String, String> result = logInMap.get(Integer.parseInt(usersId));
            String syURL = sysParaService.getSYURL();
            Map<String, Object> result1 = ARDCarGPSLogInClient.loginIn(syURL,username31, password31);
            result = new HashMap();
            result.put("userId", username31);
            result.put("sessionId", (String) result1.get("sessionId"));
            try {
                result0 = ARDCarSYGPSClient.getCarGPSTeamList(syURL,result.get("userId"),result.get("sessionId"));//
            } catch (Exception e) {
                Map<String,Object> map = new HashMap();
                map.put("rspCode", 0);
                map.put("list", new ArrayList());
                return map;
            }
            for(Map<String,Object> m : (List<Map<String,Object>>) result0.get("list")){
                if(((String) m.get("teamId")).equals(((String) map.get("teamId")))){
                    map.put("count", Integer.parseInt((String) m.get("carNum")));
            int online = 0;
            for(Map<String,Object> map : (List<Map<String,Object>>) result0.get("list")){
                Map<String,Object> resultMap = (Map<String, Object>) ARDCarSYGPSClient.getCarListByTeamId(syURL,(String)map.get("teamId"),result.get("sessionId"));
                List<Map<String,Object>> carList = (List<Map<String, Object>>) resultMap.get("carList");
                for(Map<String,Object> m : carList){
                    if(((String) m.get("stateCn")).contains("在线")){
                        online = online + 1;
                    }else{
                        continue;
                    }
                }
                for(Map<String,Object> m : (List<Map<String,Object>>) result0.get("list")){
                    if(((String) m.get("teamId")).equals(((String) map.get("teamId")))){
                        map.put("count", Integer.parseInt((String) m.get("carNum")));
                    }
                }
                map.put("online", online);
                online = 0;
            }
            map.put("online", online);
            online = 0;
        }else {
            result0.put("列表为空!","无关联账号!");
        }
        return result0;
    }
ard-work/src/main/java/com/ruoyi/sy/mapper/ArdSyUserMapper.java
@@ -5,6 +5,7 @@
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.sy.domain.ArdSyUser;
import org.apache.ibatis.annotations.MapKey;
/**
 * 三一车辆用户Mapper接口
@@ -76,5 +77,8 @@
     */
    public List<SysUser> getSysUserNoSY();
    public Map<String,Object> selectArdSyUserByUsersId(Integer usersId);
    @MapKey("id")
    Map<String,Object> selectArdSyUserByUsersId(Integer usersId);
    ArdSyUser userById(String id);
}
ard-work/src/main/java/com/ruoyi/sy/mapper/SysParaMapper.java
@@ -1,6 +1,8 @@
package com.ruoyi.sy.mapper;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.sy.domain.SysPara;
import com.ruoyi.sy.domain.SysParaExample;
import java.util.List;
@@ -8,7 +10,7 @@
/**
 * @author 11441
 */
@DS("slave")
@DataSource(value = DataSourceType.SLAVE)
public interface SysParaMapper {
    List<SysPara> selectByExample(String sysType);
ard-work/src/main/java/com/ruoyi/sy/service/IArdSyUserService.java
@@ -75,4 +75,6 @@
    public List<SysUser> getSysUserNoSY();
    Map<String,Object> selectArdSyUserByUsersId(Integer usersId);
    ArdSyUser userById(String id);
}
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyUserServiceImpl.java
@@ -121,4 +121,9 @@
        Map<String,Object> result = ardSyUserMapper.selectArdSyUserByUsersId(usersId);
        return result;
    }
    @Override
    public ArdSyUser userById(String id) {
        return ardSyUserMapper.userById(id);
    }
}
ard-work/src/main/resources/mapper/sy/ArdSyUserMapper.xml
@@ -132,4 +132,9 @@
        inner join ard_users au on aus.users_id = au.id
        where aus.users_id = #{usersId}
  </select>
    <select id="userById" parameterType="String" resultMap="ArdSyUserResult">
        <include refid="selectArdSyUserVo"/>
        where sys_user_id = #{id}
    </select>
</mapper>
ruoyi-admin/src/main/resources/application-druid.yml
@@ -15,7 +15,7 @@
            # 从库数据源
            slave:
                # 从数据源开关/默认关闭
#                enabled: true
                enabled: true
                url: jdbc:postgresql://112.98.126.2:35432/ard732
                username: postgres
                password: Yykj.2017
@@ -38,7 +38,7 @@
            testWhileIdle: true
            testOnBorrow: false
            testOnReturn: false
            webStatFilter:
            webStatFilter:
                enabled: true
            statViewServlet:
                enabled: true