| | |
| | | import java.util.function.Predicate; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | 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.system.service.ISysConfigService; |
| | | 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.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.sy.mapper.ArdSyCarMapper; |
| | | import com.ruoyi.sy.domain.ArdSyCar; |
| | |
| | | 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; |
| | | |
| | | |
| | | /** |
| | | * 查询三一车辆 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getArdSyCarAll(String userId) { |
| | | SysConfig config = new SysConfig(); |
| | | config.setConfigKey("syCarPT"); |
| | | List<SysConfig> sysConfigResult = sysConfigMapper.selectConfigList(config); |
| | | String syURL = ""; |
| | | Map<String,Object> result = new HashMap(); |
| | | if(sysConfigResult.size() == 0){ |
| | | result.put("data","三一车辆url没有录入"); |
| | | result.put("code","500"); |
| | | return result; |
| | | }else{ |
| | | syURL = sysConfigResult.get(0).getConfigValue(); |
| | | ArdSyUser ardSyUserPara = new ArdSyUser(); |
| | | ardSyUserPara.setSysUserId(userId); |
| | | List<ArdSyUser> ardSyUserList = ardSyUserMapper.selectArdSyUserList(ardSyUserPara); |
| | | if(ardSyUserList.size() == 0){ |
| | | result.put("data","用户未挂接三一车辆"); |
| | | result.put("code","500"); |
| | | return result; |
| | | }else{ |
| | | ArdSyUser ardSyUser = ardSyUserList.get(0); |
| | | Map<String,Object> LogInResult = SYCarClient.logIn(syURL,ardSyUser.getUserId(), ardSyUser.getPassword()); |
| | | String sessionId = (String) LogInResult.get("sessionId"); |
| | | Map<String,Object> carListMap = SYCarClient.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; |
| | | }else{ |
| | | result.put("data","三一车辆平台出错"); |
| | | result.put("code","500"); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String,String>> getAllCarModel() { |
| | | boolean exsit = MinioUtils.exitsBucket("sycar"); |
| | | if (exsit) { |
| | |
| | | return ""; |
| | | } |
| | | } |
| | | |
| | | // @Override |
| | | // public List<ArdSyCar> getArdSyCarWithRightByCarIdList(List<String> carIdList) { |
| | | // List<ArdSyCar> result = ardSyCarMapper.getArdSyCarWithRightByCarIdList(carIdList); |
| | | // return result; |
| | | // } |
| | | |
| | | |
| | | @Override |
| | | 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)); |
| | | } |
| | | } |
| | | } |