ard-work/src/main/java/com/ruoyi/sy/controller/ArdTankLockController.java
@@ -354,7 +354,7 @@ return dataTable; } @ApiOperation("查询电磁锁密码") @ApiOperation("根据锁主键查询电磁锁密码") @PreAuthorize("@ss.hasPermi('sy:lock:getLockPasswordByLockId')") @PostMapping("/getLockPasswordByLockId") public TableDataInfo getLockPasswordByLockId(@RequestBody Map<String,Object> para) { @@ -367,4 +367,19 @@ dataTable.setMsg("查询成功"); return dataTable; } @ApiOperation("根据三一主键查询电磁锁密码") @PreAuthorize("@ss.hasPermi('sy:lock:getLockPasswordByCarId')") @PostMapping("/getLockPasswordByCarId") public TableDataInfo getLockPasswordByCarId(@RequestBody Map<String,Object> para) { String userId = SecurityUtils.getUserId(); Map<String,Object> result = ardTankLockPasswordService.getLockPasswordByCarId(userId,para); TableDataInfo dataTable = new TableDataInfo(); dataTable.setRows((List<Map<String,Object>>) result.get("list")); dataTable.setTotal((Long) result.get("total")); dataTable.setCode(200); dataTable.setMsg("查询成功"); return dataTable; } } ard-work/src/main/java/com/ruoyi/sy/mapper/ArdTankLockPasswordMapper.java
@@ -1,6 +1,8 @@ package com.ruoyi.sy.mapper; import java.util.List; import java.util.Map; import com.ruoyi.sy.domain.ArdTankLockPassword; import org.apache.ibatis.annotations.Param; @@ -67,4 +69,8 @@ public List<ArdTankLockPassword> getLockPasswordByLockId(String lockId); public Long selectLockPasswordTotalBylockId(String lockId); public List<Map<String,Object>> getLockPasswordByCarId(String carId); public Long selectLockPasswordTotalByCarId(String carId); } ard-work/src/main/java/com/ruoyi/sy/service/IArdTankLockPasswordService.java
@@ -64,4 +64,6 @@ public int updateArdTankLockPasswordByLockNum(String lockNum, String password, String useTime); public Map<String,Object> getLockPasswordByLockId(Map<String,Object> para); public Map<String,Object> getLockPasswordByCarId(String userId,Map<String,Object> para); } 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; } } ard-work/src/main/resources/mapper/sy/ArdTankLockPasswordMapper.xml
@@ -99,4 +99,20 @@ <select id="selectLockPasswordTotalBylockId" parameterType="java.lang.String" resultType="java.lang.Long"> select count(*) from ard_tank_lock_password atlp where lock_id = #{lockId} </select> <select id="getLockPasswordByCarId" parameterType="java.lang.String" resultType="java.util.Map"> select "asc".car_id as "carId",atlp.id,atlp.lock_id as "lockId",atlp."password", atlp."no",atlp.create_time as "createTime",coalesce(atlp.use_time,'') as "useTime", atl.lock_name as "lockName" from ard_sy_car "asc" inner join ard_tank_lock atl on "asc".car_id = atl.car_id inner join ard_tank_lock_password atlp on atl.id = atlp.lock_id where "asc".car_id = #{carId} order by "asc".car_id asc,use_time asc,no asc </select> <select id="selectLockPasswordTotalByCarId" parameterType="java.lang.String" resultType="java.lang.Long"> select count(*) from ard_sy_car "asc" inner join ard_tank_lock atl on "asc".car_id = atl.car_id inner join ard_tank_lock_password atlp on atl.id = atlp.lock_id where "asc".car_id = #{carId} </select> </mapper>