| | |
| | | import java.util.function.Predicate; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.common.websocket.util.WebSocketUtils; |
| | | import com.ruoyi.device.hiksdk.config.MinioClientSingleton; |
| | | import com.ruoyi.device.hiksdk.util.minio.MinioUtils; |
| | | import com.ruoyi.sy.domain.ArdSyUser; |
| | | import com.ruoyi.sy.gps31.PositionContainer; |
| | | import com.ruoyi.sy.mapper.ArdSyUserMapper; |
| | | import com.ruoyi.system.domain.SysConfig; |
| | | import com.ruoyi.system.mapper.SysConfigMapper; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.utils.forest.SYClient; |
| | | import com.ruoyi.utils.httpclient.SYCarClient; |
| | | import com.ruoyi.utils.result.Constants; |
| | | import com.ruoyi.utils.result.Results; |
| | | import io.minio.GetPresignedObjectUrlArgs; |
| | | import io.minio.ListObjectsArgs; |
| | | import io.minio.PutObjectArgs; |
| | | import io.minio.Result; |
| | | import io.minio.http.Method; |
| | | import io.minio.messages.Contents; |
| | | import io.minio.messages.Item; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.sy.mapper.ArdSyCarMapper; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import static com.ruoyi.common.websocket.util.WebSocketUtils.ONLINE_USER_SESSIONS; |
| | | |
| | | /** |
| | | * 三一车辆Service业务层处理 |
| | |
| | | @Resource |
| | | private ArdSyUserMapper ardSyUserMapper; |
| | | |
| | | @Resource |
| | | private SysUserMapper userMapper; |
| | | |
| | | @Resource |
| | | private SYClient sYClient; |
| | | |
| | | /** |
| | | * 查询三一车辆 |
| | |
| | | return result; |
| | | }else{ |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | //Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String,Object> LogInResult = sYClient.logIn(syURL,passwordMd5,ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId); |
| | | //Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId); |
| | | Map<String,Object> carListMap = sYClient.getCarList(syURL,sessionId); |
| | | if(((String)carListMap.get("rspCode")).equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String,Object>>) carListMap.get("list"); |
| | | ArdSyCar ardSyCar = new ArdSyCar(); |
| | |
| | | return result; |
| | | }else{ |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | //Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | String passwordMd5 = DigestUtils.md5Hex(ardSyUser.getPassword()); |
| | | Map<String,Object> LogInResult = sYClient.logIn(syURL,passwordMd5,ardSyUser.getUserId()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId); |
| | | //Map<String,Object> carListMap = SYCarClient.getCarList(syURL,sessionId); |
| | | Map<String,Object> carListMap = sYClient.getCarList(syURL,sessionId); |
| | | if(((String)carListMap.get("rspCode")).equals("1")){ |
| | | List<Map<String,Object>> list = (List<Map<String,Object>>) carListMap.get("list"); |
| | | /*ArdSyCar ardSyCar = new ArdSyCar(); |
| | | List<ArdSyCar> ardSyCarList = ardSyCarMapper.selectArdSyCarList(ardSyCar); |
| | | List<String> carIdList = new ArrayList(); |
| | | for(ArdSyCar innerArdSyCar : ardSyCarList){ |
| | | carIdList.add(innerArdSyCar.getCarId()); |
| | | } |
| | | |
| | | List<Map<String,Object>> carList = list.stream().filter(new Predicate<Map<String,Object>>(){ |
| | | @Override |
| | | public boolean test(Map<String,Object> map) { |
| | | return !carIdList.contains((String)map.get("carId")); |
| | | } |
| | | }).collect(Collectors.toList()); |
| | | result.put("data",carList);*/ |
| | | result.put("data",list); |
| | | result.put("code","200"); |
| | | return result; |
| | |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // public List<ArdSyCar> getArdSyCarWithRightByCarIdList(List<String> carIdList) { |
| | | // List<ArdSyCar> result = ardSyCarMapper.getArdSyCarWithRightByCarIdList(carIdList); |
| | | // return result; |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | public List<ArdSyCar> carListById(String carId) { |
| | | return ardSyCarMapper.carListById(carId); |
| | | public Results carListById(String id) { |
| | | try { |
| | | List<ArdSyCar> list = ardSyCarMapper.carListById(id); |
| | | if(list.size()>0){ |
| | | ArdSyCar ardSyCar = list.get(0); |
| | | return Results.succeed(ardSyCar); |
| | | }else { |
| | | return Results.succeed(); |
| | | } |
| | | } catch (Exception e) { |
| | | return Results.error(e.toString()); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getArdSyCarAndDeptByCarId(String carId) { |
| | | Map<String, Object> result = ardSyCarMapper.getArdSyCarAndDeptByCarId(carId); |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public void sendArdSyCarPosition() { |
| | | for(String key : ONLINE_USER_SESSIONS.keySet()){ |
| | | SysUser sysUser = userMapper.selectUserById(key); |
| | | String deptId = String.valueOf(sysUser.getDeptId()); |
| | | Map<String,Map<String,Object>> map = PositionContainer.getDeptPositionMap().get(deptId); |
| | | System.out.println("/////////////"); |
| | | System.out.println(PositionContainer.getDeptPositionMap()); |
| | | Map<Integer,Object> data = new HashMap(); |
| | | data.put(30000, map.values()); |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(key), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void sendArdSyCarAlarmByCarId(String carId, Map<Integer,Object> data) { |
| | | List<SysUser> result = userMapper.getSysUserByCarId(carId); |
| | | for(SysUser sysUser : result){ |
| | | WebSocketUtils.sendMessage(ONLINE_USER_SESSIONS.get(sysUser.getUserId()), JSON.toJSONString(data)); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据dept集合查询出所有对应的carId |
| | | * @param deptList |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<ArdSyCar> carIdByDeptList(List<Long> deptList){ |
| | | QueryWrapper<ArdSyCar> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.in("dept_id",deptList); |
| | | return ardSyCarMapper.selectList(queryWrapper); |
| | | } |
| | | } |