修复支付等相关问题
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.gxwebsoft.apps.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.apps.mapper.EquipmentMapper;
|
||||
@@ -10,6 +12,7 @@ import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.common.system.service.UserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -27,6 +30,7 @@ import java.util.stream.Collectors;
|
||||
* @author 科技小王子
|
||||
* @since 2022-11-30 02:11:16
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements EquipmentService {
|
||||
@Resource
|
||||
@@ -42,8 +46,15 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||
List<Equipment> list = baseMapper.selectPageRel(page, param);
|
||||
|
||||
Set<Integer> touziUserIds = list.stream().map(Equipment::getTouziUserId).collect(Collectors.toSet());
|
||||
List<User> touziUserList = userService.lambdaQuery().in(User::getUserId, touziUserIds).list();
|
||||
Map<Integer, List<User>> touziUserCollect = touziUserList.stream().collect(Collectors.groupingBy(User::getUserId));
|
||||
// List<User> touziUserList = userService.lambdaQuery().in(User::getUserId, touziUserIds).list();
|
||||
Map<Integer, User> touziUserCollect = null;
|
||||
if(CollectionUtil.isNotEmpty(touziUserIds)){
|
||||
List<User> touziUserList = userService.listByIds(touziUserIds);
|
||||
if(CollectionUtil.isNotEmpty(touziUserList)){
|
||||
touziUserCollect = touziUserList.stream().collect(Collectors.toMap(User::getUserId, e->e));
|
||||
}
|
||||
}
|
||||
|
||||
// 查询绑定电池的用户
|
||||
for (Equipment equipment : list) {
|
||||
// 查询状态
|
||||
@@ -52,31 +63,36 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||
JSONObject body = entity.getBody();
|
||||
Integer code = body.getInteger("code");
|
||||
JSONObject data = body.getJSONObject("data");
|
||||
equipment.setBms(data.getString("bms_zt"));
|
||||
equipment.setBatteryPower(data.getString("sydl"));
|
||||
equipment.setTotalVoltage(data.getString("sbdy"));
|
||||
equipment.setGps(data.getString("gps_xh"));
|
||||
equipment.setGsm(data.getString("gsm_xh"));
|
||||
equipment.setWorkingStatus(data.getString("sbzt"));
|
||||
System.out.println(body);
|
||||
if(null != data){
|
||||
equipment.setBms(data.getString("bms_zt"));
|
||||
equipment.setBatteryPower(data.getString("sydl"));
|
||||
equipment.setTotalVoltage(data.getString("sbdy"));
|
||||
equipment.setGps(data.getString("gps_xh"));
|
||||
equipment.setGsm(data.getString("gsm_xh"));
|
||||
equipment.setWorkingStatus(data.getString("sbzt"));
|
||||
}
|
||||
else {
|
||||
log.warn("获取电池信息返回失败!{}", JSON.toJSONString(body));
|
||||
}
|
||||
|
||||
// System.out.println(body);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
if (!equipment.getUserId().equals(0)) {
|
||||
equipment.setUser(userService.getById(equipment.getUserId()));
|
||||
}
|
||||
|
||||
|
||||
if ( equipment.getTouziUserId()!= null && !equipment.getTouziUserId().equals(0)) {
|
||||
List<User> users = touziUserCollect.get(equipment.getTouziUserId());
|
||||
if(!CollectionUtils.isEmpty(users)) {
|
||||
equipment.setTouziUser(users.get(0));
|
||||
|
||||
if(CollectionUtil.isNotEmpty(touziUserCollect) &&
|
||||
equipment.getTouziUserId()!= null && !equipment.getTouziUserId().equals(0)) {
|
||||
User tUser = touziUserCollect.get(equipment.getTouziUserId());
|
||||
if(null != tUser){
|
||||
equipment.setTouziUser(tUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
@@ -100,18 +116,20 @@ public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment
|
||||
JSONObject body = entity.getBody();
|
||||
Integer code = body.getInteger("code");
|
||||
JSONObject data = body.getJSONObject("data");
|
||||
equipment.setBms(data.getString("bms_zt"));
|
||||
equipment.setBatteryPower(data.getString("sydl"));
|
||||
equipment.setTotalVoltage(data.getString("sbdy"));
|
||||
equipment.setGps(data.getString("gps_xh"));
|
||||
equipment.setGsm(data.getString("gsm_xh"));
|
||||
equipment.setWorkingStatus(data.getString("sbzt"));
|
||||
System.out.println(body);
|
||||
if(null != data){
|
||||
equipment.setBms(data.getString("bms_zt"));
|
||||
equipment.setBatteryPower(data.getString("sydl"));
|
||||
equipment.setTotalVoltage(data.getString("sbdy"));
|
||||
equipment.setGps(data.getString("gps_xh"));
|
||||
equipment.setGsm(data.getString("gsm_xh"));
|
||||
equipment.setWorkingStatus(data.getString("sbzt"));
|
||||
}
|
||||
else {
|
||||
log.warn("获取电池信息返回失败!{}", JSON.toJSONString(body));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
||||
return equipment;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user