| | |
| | | |
| | | import java.util.*; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.ruoyi.common.core.domain.entity.SysConfig; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | |
| | | import com.ruoyi.sy.mapper.*; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.utils.forest.SYClient; |
| | | import com.ruoyi.utils.websocket.util.WebSocketUtils; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import com.ruoyi.sy.service.IArdTankLockService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.ruoyi.utils.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; |
| | | |
| | | /** |
| | | * 电磁锁Service业务层处理 |
| | |
| | | |
| | | @Override |
| | | public void sendLockState(String userId, String syUserId, String syPassword) { |
| | | /*List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | List<SysConfig> syURLResult = sysConfigMapper.selectByType("syCarPT"); |
| | | String syURL = ""; |
| | | if(syURLResult.size() != 0){ |
| | | syURL = syURLResult.get(0).getConfigValue(); |
| | |
| | | String passwordMd5 = DigestUtils.md5Hex(syPassword); |
| | | Map<String, Object> LogInResult = sYClient.logIn(syURL, passwordMd5, syUserId); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | Map<String,Object> syResult = sYClient.getCarNearPositionByCarId(syURL, carId, syUserId, sessionId); |
| | | |
| | | List<SysConfig> lockBatteryVoltageResult = sysConfigMapper.selectByType("lockBatteryVoltage"); |
| | | Integer lockBatteryVoltage = 9; |
| | | if(!lockBatteryVoltageResult.isEmpty()){ |
| | | lockBatteryVoltage = Integer.parseInt(lockBatteryVoltageResult.get(0).getConfigValue()); |
| | | } |
| | | |
| | | List<SysConfig> lockPowerVoltageResult = sysConfigMapper.selectByType("lockPowerVoltage"); |
| | | Integer lockPowerVoltage = 5; |
| | | if(!lockPowerVoltageResult.isEmpty()){ |
| | | lockPowerVoltage = Integer.parseInt(lockPowerVoltageResult.get(0).getConfigValue()); |
| | | } |
| | | |
| | | List<Map<String,Object>> result = new ArrayList(); |
| | | List<ArdSyCar> ardSyCarResult = ardSyCarMapper.selectArdSyCarAndTankLockByUserId(userId); |
| | | List<ArdSyCar> ardSyCarResult = ardSyCarMapper.selectArdSyCarAndTankLockByUserId(userId.split("_")[0]); |
| | | for(ArdSyCar ardSyCar : ardSyCarResult){ |
| | | Map<String,Object> map = new HashMap(); |
| | | map.put("id",ardSyCar.getId()); |
| | |
| | | map.put("carType",ardSyCar.getCarType()); |
| | | map.put("carBrand",ardSyCar.getCarBrand()); |
| | | map.put("deptId",ardSyCar.getDeptId()); |
| | | |
| | | |
| | | |
| | | |
| | | map.put("carPicture",ardSyCar.getCarPicture()); |
| | | Map<String,Object> syResult = sYClient.getCarNearPositionByCarId(syURL, ardSyCar.getCarId(), syUserId, 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")); |
| | | } |
| | | List<Map<String,Object>> lockList = new ArrayList(); |
| | | List<ArdTankLock> ardTankLockList = ardSyCar.getArdTankLockList(); |
| | | for(ArdTankLock ardTankLock : ardTankLockList){ |
| | | Map<String,Object> lockMap = new HashMap(); |
| | | lockMap.put("id",ardTankLock.getId()); |
| | | lockMap.put("lockNum",ardTankLock.getLockNum()); |
| | | lockMap.put("lockName",ardTankLock.getLockName()); |
| | | lockMap.put("imgPositionTop",ardTankLock.getImgPositionTop()); |
| | | lockMap.put("imgPositionLeft",ardTankLock.getImgPositionLeft()); |
| | | lockMap.put("carId",ardTankLock.getCarId()); |
| | | lockMap.put("enable",ardTankLock.getEnable()); |
| | | if(ardTankLock.getRestartState() == null){ |
| | | lockMap.put("restartState",""); |
| | | }else{ |
| | | lockMap.put("restartState",ardTankLock.getRestartState()); |
| | | } |
| | | if(ardTankLock.getOnlineTime() == null){ |
| | | lockMap.put("onlineTime",""); |
| | | }else{ |
| | | lockMap.put("onlineTime",ardTankLock.getOnlineTime()); |
| | | } |
| | | Map<String,Object> ardTankLockState = new HashMap(); |
| | | ArdTankLockState ardTankLockStateResult = ardTankLockStateMapper.selectArdTankLockStateByLockIdLimitOne(ardTankLock.getId()); |
| | | if(ardTankLockStateResult == null){ |
| | | ardTankLockState.put("id",""); |
| | | ardTankLockState.put("lockId",""); |
| | | ardTankLockState.put("lockNum",""); |
| | | ardTankLockState.put("lockState",""); |
| | | ardTankLockState.put("lockPositionState",""); |
| | | ardTankLockState.put("lockShellState",""); |
| | | ardTankLockState.put("restartState",""); |
| | | ardTankLockState.put("batterVoltage",""); |
| | | ardTankLockState.put("batterVoltageAlarm",false); |
| | | ardTankLockState.put("powerVoltage",""); |
| | | ardTankLockState.put("powerVoltageAlarm",false); |
| | | ardTankLockState.put("uploadTime",""); |
| | | ardTankLockState.put("uniqueMark",""); |
| | | ardTankLockState.put("lockStateMark",false); |
| | | lockMap.put("ardTankLockState",ardTankLockState); |
| | | }else{ |
| | | ardTankLockState.put("id",ardTankLockStateResult.getId()); |
| | | ardTankLockState.put("lockId",ardTankLockStateResult.getLockId()); |
| | | ardTankLockState.put("lockNum",ardTankLockStateResult.getLockNum()); |
| | | ardTankLockState.put("lockState",ardTankLockStateResult.getLockState()); |
| | | ardTankLockState.put("lockPositionState",ardTankLockStateResult.getLockPositionState()); |
| | | ardTankLockState.put("lockShellState",ardTankLockStateResult.getLockShellState()); |
| | | ardTankLockState.put("restartState",ardTankLockStateResult.getRestartState()); |
| | | ardTankLockState.put("batterVoltage",ardTankLockStateResult.getBatterVoltage()); |
| | | if(Double.parseDouble(ardTankLockStateResult.getBatterVoltage()) <= lockBatteryVoltage){ |
| | | ardTankLockState.put("batterVoltageAlarm",true); |
| | | }else{ |
| | | ardTankLockState.put("batterVoltageAlarm",false); |
| | | } |
| | | ardTankLockState.put("powerVoltage",ardTankLockStateResult.getPowerVoltage()); |
| | | if(Double.parseDouble(ardTankLockStateResult.getPowerVoltage()) <= lockPowerVoltage){ |
| | | ardTankLockState.put("powerVoltageAlarm",true); |
| | | }else{ |
| | | ardTankLockState.put("powerVoltageAlarm",false); |
| | | } |
| | | ardTankLockState.put("uploadTime",ardTankLockStateResult.getUploadTime()); |
| | | ardTankLockState.put("uniqueMark",ardTankLockStateResult.getUniqueMark()); |
| | | ardTankLockState.put("lockStateMark",ardTankLockStateResult.getLockStateMark()); |
| | | lockMap.put("ardTankLockState",ardTankLockState); |
| | | } |
| | | lockList.add(lockMap); |
| | | } |
| | | }*/ |
| | | map.put("lockList",lockList); |
| | | result.add(map); |
| | | Map<String,Object> data = new HashMap(); |
| | | data.put("40002",result); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(userId), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | } |