zhangnaisong
2024-07-29 79d24d16b133a07a1a7cd887348683be6d8c8ef3
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdTankLockPasswordServiceImpl.java
@@ -1,16 +1,19 @@
package com.ruoyi.sy.service.impl;
import java.util.HashMap;
import java.util.List;
import java.util.*;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.domain.entity.SysConfig;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.sy.domain.ArdSyUser;
import com.ruoyi.sy.mapper.ArdSyUserMapper;
import com.ruoyi.system.mapper.SysConfigMapper;
import com.ruoyi.utils.forest.SYClient;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Map;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SecurityUtils;
@@ -30,6 +33,15 @@
public class ArdTankLockPasswordServiceImpl implements IArdTankLockPasswordService {
    @Resource
    private ArdTankLockPasswordMapper ardTankLockPasswordMapper;
    @Resource
    private ArdSyUserMapper ardSyUserMapper;
    @Resource
    private SysConfigMapper sysConfigMapper;
    @Resource
    private SYClient sYClient;
    /**
     * 查询罐车锁密码
@@ -121,4 +133,46 @@
        resultMap.put("total",total);
        return resultMap;
    }
    @Override
    public Map<String, Object> getLockPasswordByCarId(String userId, Map<String, Object> para) {
        ArdSyUser ardSyUser = ardSyUserMapper.userById(userId);
        if(ardSyUser == null){
            return new HashMap();
        }
        List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT");
        String syURL = "";
        if(syURLResult.size() != 0){
            syURL = syURLResult.get(0).getConfigValue();
        }else{
            return new HashMap();
        }
        String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword());
        Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId());
        String sessionId = (String) LogInResult.get("sessionId");
        String carId = (String) para.get("carId");
        String carPlate = "";
        Map<String,Object> syResult = sYClient.getCarNearPositionByCarId(syURL, carId, ardSyUser.getUserId(), sessionId);
        if(((String)syResult.get("rspCode")).equals("1")){
            Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0);
            carPlate = (String) carMap.get("carPlate");
        }
        //分页属性
        Integer pageNum = (Integer) para.get("pageNum");
        Integer pageSize = (Integer) para.get("pageSize");
        PageHelper.startPage(pageNum, pageSize);//分页
        Map<String,Object> resultMap = new HashMap();
        List<Map<String,Object>> resultList = ardTankLockPasswordMapper.getLockPasswordByCarId(carId);
        for(Map<String,Object> map : resultList){
            map.put("carPlate",carPlate);
        }
        Long total =  ardTankLockPasswordMapper.selectLockPasswordTotalByCarId(carId);
        resultMap.put("list",resultList);
        resultMap.put("total",total);
        return resultMap;
    }
}