| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.dtflys.forest.annotation.Var; |
| | | import com.ruoyi.common.core.domain.entity.SysConfig; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | |
| | | import com.ruoyi.sy.mapper.ArdTankWallLockTemporaryMapper; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.utils.forest.SYClient; |
| | | import com.ruoyi.utils.result.Results; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.sy.mapper.ArdTankLockMapper; |
| | | import com.ruoyi.sy.domain.ArdTankLock; |
| | | import com.ruoyi.sy.service.IArdTankLockService; |
| | |
| | | /** |
| | | * 新增电磁锁 |
| | | * |
| | | * @param ardTankLock 电磁锁 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | |
| | | //public Results List<Map<String,Object>> getAll(String usersId) { |
| | | public List<Map<String,Object>> getAll(String usersId) { |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | /*if(ardSyUser == null){ |
| | | return Results.error("没有挂接三一车辆用户"); |
| | | }*/ |
| | | if(ardSyUser == null){ |
| | | return new ArrayList(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | }/*else{ |
| | | return Results.error("三一车辆地址未录入"); |
| | | }*/ |
| | | }else{ |
| | | return new ArrayList(); |
| | | } |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | |
| | | @Override |
| | | public Map<String, Object> getLockByCarId(String carId, String usersId) { |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | /*if(ardSyUser == null){ |
| | | return Results.error("没有挂接三一车辆用户"); |
| | | }*/ |
| | | 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 Results.error("三一车辆地址未录入"); |
| | | }*/ |
| | | }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"); |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, String>> getLockByCarPlate(String usersId, String carPlate) { |
| | | ArdSyUser ardSyUser = ardSyUserMapper.userById(usersId); |
| | | if(ardSyUser == null){ |
| | | return new ArrayList(); |
| | | } |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | | }else{ |
| | | return new ArrayList(); |
| | | } |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | List<ArdTankLock> ardTankLockList = ardTankLockMapper.getAll(); |
| | | List<Map<String,String>> result = new ArrayList(); |
| | | if(!carPlate.equals("")){ |
| | | Map<String,Object> carMap = sYClient.getCarListByPlate(syURL,carPlate,ardSyUser.getUserId(),sessionId);//车牌号模糊搜索车辆 |
| | | List<Map<String,Object>> carList = new ArrayList(); |
| | | if(((String)carMap.get("rspCode")).equals("1")){ |
| | | carList = (List<Map<String, Object>>) carMap.get("list"); |
| | | }else{ |
| | | return new ArrayList(); |
| | | } |
| | | List<String> carIdList = new ArrayList();//记录三一车辆主键 |
| | | for(Map<String,Object> map : carList){ |
| | | carIdList.add((String) map.get("carId")); |
| | | } |
| | | for(ArdTankLock ardTankLock : ardTankLockList){ |
| | | if(carIdList.contains(ardTankLock.getCarId())){//返回的车辆包含数据库录入的车辆 |
| | | Map<String,String> map = new HashMap(); |
| | | map.put("id",ardTankLock.getId()); |
| | | map.put("lockNum",ardTankLock.getLockNum()); |
| | | map.put("lockName",ardTankLock.getLockName()); |
| | | map.put("imgPositionTop",ardTankLock.getImgPositionTop()); |
| | | map.put("imgPositionLeft",ardTankLock.getImgPositionLeft()); |
| | | map.put("carId",ardTankLock.getCarId()); |
| | | map.put("enable",ardTankLock.getEnable()); |
| | | if(ardTankLock.getRestartState() == null){ |
| | | map.put("restartState",""); |
| | | }else{ |
| | | map.put("restartState",ardTankLock.getRestartState()); |
| | | } |
| | | if(ardTankLock.getOnlineTime() == null){ |
| | | map.put("onlineTime",""); |
| | | }else{ |
| | | map.put("onlineTime",ardTankLock.getOnlineTime()); |
| | | } |
| | | Map<String,Object> car = carList.stream().filter(mapCar -> ((String)mapCar.get("carId")).equals(ardTankLock.getCarId())).collect(Collectors.toList()).get(0); |
| | | map.put("carPlate", (String) car.get("carPlate")); |
| | | result.add(map); |
| | | }else{ |
| | | continue; |
| | | } |
| | | } |
| | | }else{ |
| | | for(ArdTankLock ardTankLock : ardTankLockList){ |
| | | Map<String,String> map = new HashMap(); |
| | | map.put("id",ardTankLock.getId()); |
| | | map.put("lockNum",ardTankLock.getLockNum()); |
| | | map.put("lockName",ardTankLock.getLockName()); |
| | | map.put("imgPositionTop",ardTankLock.getImgPositionTop()); |
| | | map.put("imgPositionLeft",ardTankLock.getImgPositionLeft()); |
| | | map.put("carId",ardTankLock.getCarId()); |
| | | map.put("enable",ardTankLock.getEnable()); |
| | | if(ardTankLock.getRestartState() == null){ |
| | | map.put("restartState",""); |
| | | }else{ |
| | | map.put("restartState",ardTankLock.getRestartState()); |
| | | } |
| | | if(ardTankLock.getOnlineTime() == null){ |
| | | map.put("onlineTime",""); |
| | | }else{ |
| | | map.put("onlineTime",ardTankLock.getOnlineTime()); |
| | | } |
| | | Map<String,Object> syResult = sYClient.getCarNearPositionByCarId(syURL, ardTankLock.getCarId(), ardSyUser.getUserId(), sessionId); |
| | | if(((String)syResult.get("rspCode")).equals("1")){ |
| | | Map<String,Object> carMap = ((List<Map<String,Object>>)syResult.get("list")).get(0); |
| | | map.put("carPlate", (String) carMap.get("carPlate")); |
| | | } |
| | | result.add(map); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |