北京暂降平台调整
This commit is contained in:
@@ -56,7 +56,8 @@ public class PqlineCache {
|
|||||||
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+pqsDepts.getDeptsIndex(),deptslineIds);
|
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+pqsDepts.getDeptsIndex(),deptslineIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<PqsDepts> deptsList = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState,1).list();
|
||||||
|
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+"AllDept",deptsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreDestroy
|
@PreDestroy
|
||||||
|
|||||||
@@ -53,5 +53,9 @@ public class LineCacheJob {
|
|||||||
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
List<Integer> deptslineIds = deptslines.stream().map(PqsDeptsline::getLineIndex).collect(Collectors.toList());
|
||||||
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+pqsDepts.getDeptsIndex(),deptslineIds);
|
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+pqsDepts.getDeptsIndex(),deptslineIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<PqsDepts> deptsList = pqsDeptsService.lambdaQuery().eq(PqsDepts::getState,1).list();
|
||||||
|
redisUtil.saveByKey(NAME_KEY + StrUtil.DASHED+"AllDept",deptsList);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.njcn.gather.event.transientes.pojo.po.*;
|
|||||||
import com.njcn.gather.event.transientes.service.*;
|
import com.njcn.gather.event.transientes.service.*;
|
||||||
import com.njcn.gather.event.transientes.service.impl.MsgEventInfoServiceImpl;
|
import com.njcn.gather.event.transientes.service.impl.MsgEventInfoServiceImpl;
|
||||||
import com.njcn.gather.event.transientes.websocket.WebSocketServer;
|
import com.njcn.gather.event.transientes.websocket.WebSocketServer;
|
||||||
|
import com.njcn.redis.utils.RedisUtil;
|
||||||
import com.njcn.web.controller.BaseController;
|
import com.njcn.web.controller.BaseController;
|
||||||
import com.njcn.web.utils.HttpResultUtil;
|
import com.njcn.web.utils.HttpResultUtil;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -46,6 +47,8 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import static com.njcn.gather.event.transientes.pojo.constant.RedisConstant.REDIS_DEPT_INDEX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author: cdf
|
* @Author: cdf
|
||||||
* @CreateTime: 2025-06-23
|
* @CreateTime: 2025-06-23
|
||||||
@@ -83,6 +86,8 @@ public class EventGateController extends BaseController {
|
|||||||
|
|
||||||
private final MsgEventInfoService msgEventInfoService;
|
private final MsgEventInfoService msgEventInfoService;
|
||||||
|
|
||||||
|
private final RedisUtil redisUtil;
|
||||||
|
|
||||||
|
|
||||||
@OperateInfo
|
@OperateInfo
|
||||||
@GetMapping("/eventMsg")
|
@GetMapping("/eventMsg")
|
||||||
@@ -90,7 +95,7 @@ public class EventGateController extends BaseController {
|
|||||||
@ApiImplicitParam(name = "eventMsg", value = "暂态事件json字符", required = true)
|
@ApiImplicitParam(name = "eventMsg", value = "暂态事件json字符", required = true)
|
||||||
public HttpResult<Object> eventMsg(@RequestParam("msg") String msg) {
|
public HttpResult<Object> eventMsg(@RequestParam("msg") String msg) {
|
||||||
String methodDescribe = getMethodDescribe("eventMsg");
|
String methodDescribe = getMethodDescribe("eventMsg");
|
||||||
System.out.println(msg);
|
log.info("收到前置推送暂降事件:"+msg);
|
||||||
|
|
||||||
JSONObject jsonObject;
|
JSONObject jsonObject;
|
||||||
try {
|
try {
|
||||||
@@ -107,28 +112,52 @@ public class EventGateController extends BaseController {
|
|||||||
String str ="/";
|
String str ="/";
|
||||||
if(CollUtil.isNotEmpty(assList)){
|
if(CollUtil.isNotEmpty(assList)){
|
||||||
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||||
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId,PqUserLedgerPO::getCustomerName).in(PqUserLedgerPO::getId,userIds));
|
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().select(PqUserLedgerPO::getId,PqUserLedgerPO::getProjectName).in(PqUserLedgerPO::getId,userIds));
|
||||||
str = poList.stream().map(PqUserLedgerPO::getCustomerName).collect(Collectors.joining(StrUtil.COMMA));
|
str = poList.stream().map(PqUserLedgerPO::getProjectName).collect(Collectors.joining(StrUtil.COMMA));
|
||||||
}
|
}
|
||||||
jsonObject.put("objName",str);
|
|
||||||
|
List<PqsDepts> deptsList = (List<PqsDepts>)redisUtil.getObjectByKey(REDIS_DEPT_INDEX+ StrUtil.DASHED+"AllDept");
|
||||||
|
Map<String,PqsDepts> deptsMap = deptsList.stream().collect(Collectors.toMap(PqsDepts::getDeptsIndex,dept->dept));
|
||||||
|
|
||||||
|
List<PqsDeptsline> deptslineList = pqsDeptslineService.lambdaQuery().eq(PqsDeptsline::getLineIndex,lineId).list();
|
||||||
|
List<String> deptIds = deptslineList.stream().map(PqsDeptsline::getDeptsIndex).collect(Collectors.toList());
|
||||||
|
Set<String> set =getAllParentIdsWithChildrenBatch(deptIds,deptsMap);
|
||||||
|
jsonObject.putOpt("objName",str);
|
||||||
|
jsonObject.putOpt("dept", String.join(StrUtil.COMMA, set));
|
||||||
|
|
||||||
webSocketServer.sendMessageToAll(jsonObject.toString());
|
webSocketServer.sendMessageToAll(jsonObject.toString());
|
||||||
|
|
||||||
//开始发送短信
|
|
||||||
/* try {
|
|
||||||
sendMessage(jsonObject);
|
|
||||||
}catch (Exception e){
|
|
||||||
log.error("短信组装发送失败!失败原因{}",e.getMessage());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
log.error("暂降json格式异常!{}", e.getMessage());
|
log.error("暂降json格式异常!{}", e.getMessage());
|
||||||
}
|
}
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getAllParentIdsRecursive(String deptId, Map<String, PqsDepts> deptMap, Set<String> result) {
|
||||||
|
if (deptId == null || result.contains(deptId)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
result.add(deptId); // 添加当前ID
|
||||||
|
PqsDepts dept = deptMap.get(deptId);
|
||||||
|
if (dept != null && dept.getParentnodeid() != null) {
|
||||||
|
getAllParentIdsRecursive(dept.getParentnodeid(), deptMap, result); // 递归处理父节点
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量处理入口方法
|
||||||
|
public Set<String> getAllParentIdsWithChildrenBatch(Collection<String> deptIds, Map<String, PqsDepts> deptMap) {
|
||||||
|
Set<String> result = new HashSet<>();
|
||||||
|
for (String deptId : deptIds) {
|
||||||
|
getAllParentIdsRecursive(deptId, deptMap, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@OperateInfo
|
@OperateInfo
|
||||||
@GetMapping("/testEvent")
|
@GetMapping("/testEvent")
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ public class PqUserLedgerPO implements Serializable {
|
|||||||
@TableField(value = "CUSTOMER_NAME")
|
@TableField(value = "CUSTOMER_NAME")
|
||||||
private String customerName;
|
private String customerName;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(value = "PROJECT_NAME")
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
@TableField(value = "ELECTRICITY_ADDRESS")
|
@TableField(value = "ELECTRICITY_ADDRESS")
|
||||||
private String electricityAddress;
|
private String electricityAddress;
|
||||||
|
|
||||||
|
|||||||
@@ -72,14 +72,64 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
private final PqDeviceMapper pqDeviceMapper;
|
private final PqDeviceMapper pqDeviceMapper;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserLedgerStatisticVO userLedgerStatistic(LargeScreenCountParam param) {
|
public UserLedgerStatisticVO userLedgerStatistic(LargeScreenCountParam param) {
|
||||||
UserLedgerStatisticVO result = new UserLedgerStatisticVO();
|
UserLedgerStatisticVO result = new UserLedgerStatisticVO();
|
||||||
|
|
||||||
//获取字典树
|
// 1. 获取字典树数据
|
||||||
List<PqsDicTreePO> dicTreeList = pqsDicTreeMapper.selectList(new LambdaQueryWrapper<>());
|
List<PqsDicTreePO> dicTreeList = getAllDicTrees();
|
||||||
|
Map<String, PqsDicTreePO> treeMap = getDicTreeMap(dicTreeList);
|
||||||
|
setResultIds(result, treeMap);
|
||||||
|
|
||||||
|
// 2. 获取线路ID列表
|
||||||
|
List<Integer> lineIds = commGeneralService.getLineIdsByDept(param);
|
||||||
|
if (CollUtil.isEmpty(lineIds)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 获取用户线路关联数据
|
||||||
|
List<PqUserLineAssPO> assList = getUserLineAssociations(lineIds);
|
||||||
|
if (CollUtil.isEmpty(assList)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 获取用户台账信息
|
||||||
|
Set<String> assUserIds = assList.stream()
|
||||||
|
.map(PqUserLineAssPO::getUserIndex)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
List<PqUserLedgerPO> userLedgers = getUserLedgers(new ArrayList<>(assUserIds),null,false);
|
||||||
|
if (CollUtil.isEmpty(userLedgers)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 获取事件和线路数据
|
||||||
|
List<PqsEventdetail> events = getEventsInTimeRange(param, lineIds);
|
||||||
|
List<PqLine> lines = getLines(lineIds);
|
||||||
|
|
||||||
|
// 6. 按用户类型分组处理
|
||||||
|
Map<String, List<PqUserLedgerPO>> userMap = userLedgers.stream()
|
||||||
|
.collect(Collectors.groupingBy(PqUserLedgerPO::getBigObjType));
|
||||||
|
|
||||||
|
// 7. 构建结果
|
||||||
|
buildResult(result, treeMap, userMap, assList, events, lines);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<PqsDicTreePO> getAllDicTrees(){
|
||||||
|
return pqsDicTreeMapper.selectList(new LambdaQueryWrapper<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, PqsDicTreePO> getDicTreeMap(List<PqsDicTreePO> dicTreeList) {
|
||||||
List<PqsDicTreePO> touList = dicTreeList.stream().filter(it -> Objects.equals(it.getCode(), DicTreeEnum.BJ_USER.getCode())||Objects.equals(it.getCode(), DicTreeEnum.OI_USER.getCode())||Objects.equals(it.getCode(), DicTreeEnum.OT_USER.getCode())).collect(Collectors.toList());
|
List<PqsDicTreePO> touList = dicTreeList.stream().filter(it -> Objects.equals(it.getCode(), DicTreeEnum.BJ_USER.getCode())||Objects.equals(it.getCode(), DicTreeEnum.OI_USER.getCode())||Objects.equals(it.getCode(), DicTreeEnum.OT_USER.getCode())).collect(Collectors.toList());
|
||||||
Map<String, PqsDicTreePO> treeMap = touList.stream().collect(Collectors.toMap(PqsDicTreePO::getCode, Function.identity()));
|
Map<String, PqsDicTreePO> treeMap = touList.stream().collect(Collectors.toMap(PqsDicTreePO::getCode, Function.identity()));
|
||||||
|
return treeMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setResultIds (UserLedgerStatisticVO result,Map<String, PqsDicTreePO> treeMap){
|
||||||
treeMap.forEach((tree, obj) -> {
|
treeMap.forEach((tree, obj) -> {
|
||||||
if (tree.equals(DicTreeEnum.BJ_USER.getCode())) {
|
if (tree.equals(DicTreeEnum.BJ_USER.getCode())) {
|
||||||
result.setImportId(obj.getId());
|
result.setImportId(obj.getId());
|
||||||
@@ -89,28 +139,32 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
result.setOtherId(obj.getId());
|
result.setOtherId(obj.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
List<Integer> lineIds = commGeneralService.getLineIdsByDept(param);
|
|
||||||
//获取当前用户权限能获取到的用户台账信息
|
private List<PqUserLineAssPO> getUserLineAssociations(List<Integer> lineIds){
|
||||||
LambdaQueryWrapper<PqUserLineAssPO> assQuery = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PqUserLineAssPO> assQuery = new LambdaQueryWrapper<>();
|
||||||
assQuery.in(PqUserLineAssPO::getLineIndex, lineIds);
|
assQuery.in(PqUserLineAssPO::getLineIndex, lineIds);
|
||||||
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(assQuery);
|
|
||||||
if(CollUtil.isEmpty(assList)){
|
if(lineIds.size()>1000){
|
||||||
return result;
|
List<List<Integer>> lineList = CollUtil.split(lineIds, 1000);
|
||||||
|
assQuery.and(w -> {
|
||||||
|
for (List<Integer> ids : lineList) {
|
||||||
|
w.or(wIn -> wIn.in(PqUserLineAssPO::getLineIndex, ids));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
assQuery.in(PqUserLineAssPO::getLineIndex, lineIds);
|
||||||
}
|
}
|
||||||
List<String> assUserIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Map<String, PqsDicTreePO> dicTreeMap = dicTreeList.stream().collect(Collectors.toMap(PqsDicTreePO::getId, Function.identity()));
|
|
||||||
|
|
||||||
|
return pqUserLineAssMapper.selectList(assQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PqsEventdetail> getEventsInTimeRange(LargeScreenCountParam param,List<Integer> lineIds){
|
||||||
//查询时间段的暂降事件
|
//查询时间段的暂降事件
|
||||||
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
|
||||||
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
|
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
|
||||||
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType());
|
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType());
|
||||||
|
|
||||||
LambdaQueryWrapper<PqLine> lineQuery = new LambdaQueryWrapper<>();
|
|
||||||
if (lineIds.size() > 1000) {
|
if (lineIds.size() > 1000) {
|
||||||
List<List<Integer>> listLineIds = CollUtil.split(lineIds, 1000);
|
List<List<Integer>> listLineIds = CollUtil.split(lineIds, 1000);
|
||||||
eventQuery.and(w -> {
|
eventQuery.and(w -> {
|
||||||
@@ -118,24 +172,54 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
w.or(wIn -> wIn.in(PqsEventdetail::getLineid, ids));
|
w.or(wIn -> wIn.in(PqsEventdetail::getLineid, ids));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
eventQuery.in(PqsEventdetail::getLineid, lineIds);
|
||||||
|
}
|
||||||
|
return pqsEventdetailService.list(eventQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<PqUserLedgerPO> getUserLedgers(List<String> assUserIds,LargeScreenCountParam param,boolean queryFlag){
|
||||||
|
LambdaQueryWrapper<PqUserLedgerPO> userWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if(assUserIds.size()>1000){
|
||||||
|
List<List<String>> assUserIdsList = CollUtil.split(assUserIds, 1000);
|
||||||
|
userWrapper.and(w -> {
|
||||||
|
for (List<String> ids : assUserIdsList) {
|
||||||
|
w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
userWrapper.in(PqUserLedgerPO::getId, assUserIds);
|
||||||
|
}
|
||||||
|
if(queryFlag){
|
||||||
|
if(StrUtil.isNotBlank(param.getBigObjType())){
|
||||||
|
//对象大类不为空
|
||||||
|
userWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType());
|
||||||
|
}
|
||||||
|
if(StrUtil.isNotBlank(param.getSmallObjType())){
|
||||||
|
//对象大类不为空
|
||||||
|
userWrapper.eq(PqUserLedgerPO::getSmallObjType,param.getSmallObjType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pqUserLedgerMapper.selectList(userWrapper);
|
||||||
|
}
|
||||||
|
private List<PqLine> getLines(List<Integer> lineIds){
|
||||||
|
LambdaQueryWrapper<PqLine> lineQuery = new LambdaQueryWrapper<>();
|
||||||
|
if (lineIds.size() > 1000) {
|
||||||
|
List<List<Integer>> listLineIds = CollUtil.split(lineIds, 1000);
|
||||||
|
|
||||||
lineQuery.and(w -> {
|
lineQuery.and(w -> {
|
||||||
for (List<Integer> ids : listLineIds) {
|
for (List<Integer> ids : listLineIds) {
|
||||||
w.or(wIn -> wIn.in(PqLine::getLineIndex, ids));
|
w.or(wIn -> wIn.in(PqLine::getLineIndex, ids));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
eventQuery.in(PqsEventdetail::getLineid, lineIds);
|
|
||||||
lineQuery.in(PqLine::getLineIndex, lineIds);
|
lineQuery.in(PqLine::getLineIndex, lineIds);
|
||||||
}
|
}
|
||||||
List<PqsEventdetail> eventdetailList = pqsEventdetailService.list(eventQuery);
|
return pqLineService.list(lineQuery);
|
||||||
List<PqLine> lineList = pqLineService.list(lineQuery);
|
|
||||||
|
|
||||||
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId, assUserIds));
|
|
||||||
if(CollUtil.isEmpty(pqUserLedgerPOList)){
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
Map<String, List<PqUserLedgerPO>> userMap = pqUserLedgerPOList.stream().collect(Collectors.groupingBy(PqUserLedgerPO::getBigObjType));
|
|
||||||
|
|
||||||
|
|
||||||
|
private void buildResult(UserLedgerStatisticVO result,Map<String, PqsDicTreePO> treeMap,Map<String, List<PqUserLedgerPO>> userMap,List<PqUserLineAssPO> assList,List<PqsEventdetail> eventdetailList, List<PqLine> lineList){
|
||||||
List<UserLedgerStatisticVO.Inner> innerList = new ArrayList<>();
|
List<UserLedgerStatisticVO.Inner> innerList = new ArrayList<>();
|
||||||
treeMap.forEach((tree, obj) -> {
|
treeMap.forEach((tree, obj) -> {
|
||||||
//获取对象大类的用户
|
//获取对象大类的用户
|
||||||
@@ -169,7 +253,7 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
item.setCount(count[0]);
|
item.setCount(count[0]);
|
||||||
item.setTreeId(key);
|
item.setTreeId(key);
|
||||||
item.setParentId(obj.getId());
|
item.setParentId(obj.getId());
|
||||||
item.setName(dicTreeMap.containsKey(key) ? dicTreeMap.get(key).getName() : "/");
|
item.setName(treeMap.containsKey(key) ? treeMap.get(key).getName() : "/");
|
||||||
childrenList.add(item);
|
childrenList.add(item);
|
||||||
});
|
});
|
||||||
inner.setChildren(childrenList);
|
inner.setChildren(childrenList);
|
||||||
@@ -178,9 +262,51 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
result.setInnerList(innerList);
|
result.setInnerList(innerList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* @Override
|
||||||
|
public Page<EventDetailVO> rightEventOpen(LargeScreenCountParam param) {
|
||||||
|
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param));
|
||||||
|
|
||||||
|
// 1. 获取线路ID
|
||||||
|
List<Integer> lineIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
|
||||||
|
if (CollUtil.isEmpty(lineIds)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 获取用户线路关联
|
||||||
|
List<PqUserLineAssPO> assList = getUserLineAssociations(lineIds);
|
||||||
|
if (CollUtil.isEmpty(assList)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 获取用户台账
|
||||||
|
List<PqUserLedgerPO> userLedgers = getFilteredUserLedgers(assList, param);
|
||||||
|
if (CollUtil.isEmpty(userLedgers)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 获取事件数据
|
||||||
|
List<Integer> lineUseList = assList.stream()
|
||||||
|
.map(PqUserLineAssPO::getLineIndex)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
Page<PqsEventdetail> eventPage = getEventsPage(param, lineUseList);
|
||||||
|
if (CollUtil.isEmpty(eventPage.getRecords())) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 构建结果
|
||||||
|
buildEventDetailResult(result, eventPage, assList, userLedgers);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<EventDetailVO> rightEventOpen(LargeScreenCountParam param) {
|
public Page<EventDetailVO> rightEventOpen(LargeScreenCountParam param) {
|
||||||
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
|
Page<EventDetailVO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
|
||||||
@@ -189,24 +315,14 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
//获取用户监测点关系符合部门监测点的
|
//获取用户监测点关系符合部门监测点的
|
||||||
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,deptLineIds));
|
List<PqUserLineAssPO> assList = getUserLineAssociations(deptLineIds);
|
||||||
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||||
if(CollUtil.isEmpty(userIds)){
|
if(CollUtil.isEmpty(userIds)){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
LambdaQueryWrapper<PqUserLedgerPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
||||||
lambdaQueryWrapper.in(PqUserLedgerPO::getId,userIds);
|
|
||||||
if(StrUtil.isNotBlank(param.getBigObjType())){
|
|
||||||
//对象大类不为空
|
|
||||||
lambdaQueryWrapper.eq(PqUserLedgerPO::getBigObjType,param.getBigObjType());
|
|
||||||
}
|
|
||||||
if(StrUtil.isNotBlank(param.getSmallObjType())){
|
|
||||||
//对象大类不为空
|
|
||||||
lambdaQueryWrapper.eq(PqUserLedgerPO::getSmallObjType,param.getSmallObjType());
|
|
||||||
}
|
|
||||||
//获取符合条件的用户
|
//获取符合条件的用户
|
||||||
List<PqUserLedgerPO> pqUserLedgerPOList = pqUserLedgerMapper.selectList(lambdaQueryWrapper);
|
List<PqUserLedgerPO> pqUserLedgerPOList =getUserLedgers(userIds,param,true);
|
||||||
|
|
||||||
if(CollUtil.isEmpty(pqUserLedgerPOList)){
|
if(CollUtil.isEmpty(pqUserLedgerPOList)){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -218,7 +334,7 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
//查询时间段的暂降事件
|
//查询时间段的暂降事件
|
||||||
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PqsEventdetail> eventQuery = new LambdaQueryWrapper<>();
|
||||||
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
|
eventQuery.between(PqsEventdetail::getTimeid, DateUtil.parse(param.getSearchBeginTime()), DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())))
|
||||||
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType());
|
.in(PqsEventdetail::getWavetype, msgEventConfigService.getEventType()).orderByDesc(PqsEventdetail::getTimeid);
|
||||||
|
|
||||||
if (lineUseList.size() > 1000) {
|
if (lineUseList.size() > 1000) {
|
||||||
List<List<Integer>> listLineIds = CollUtil.split(lineUseList, 1000);
|
List<List<Integer>> listLineIds = CollUtil.split(lineUseList, 1000);
|
||||||
@@ -246,7 +362,7 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
EventDetailVO eventDetailVO = new EventDetailVO();
|
EventDetailVO eventDetailVO = new EventDetailVO();
|
||||||
BeanUtil.copyProperties(pqsEventdetail,eventDetailVO);
|
BeanUtil.copyProperties(pqsEventdetail,eventDetailVO);
|
||||||
List<String> userTemIds = temMap.get(pqsEventdetail.getLineid());
|
List<String> userTemIds = temMap.get(pqsEventdetail.getLineid());
|
||||||
String objName = userTemIds.stream().map(it->pqMap.get(it).getCustomerName()).collect(Collectors.joining(StrUtil.COMMA));
|
String objName = userTemIds.stream().map(it->pqMap.get(it).getProjectName()).collect(Collectors.joining("; "));
|
||||||
eventDetailVO.setObjName(objName);
|
eventDetailVO.setObjName(objName);
|
||||||
LedgerBaseInfoDTO dto = lineMap.get(pqsEventdetail.getLineid());
|
LedgerBaseInfoDTO dto = lineMap.get(pqsEventdetail.getLineid());
|
||||||
eventDetailVO.setBdname(dto.getStationName());
|
eventDetailVO.setBdname(dto.getStationName());
|
||||||
@@ -270,9 +386,7 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
Page<DeviceDTO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
|
Page<DeviceDTO> result = new Page<>(PageFactory.getPageNum(param),PageFactory.getPageSize(param));
|
||||||
List<Integer> lineIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
|
List<Integer> lineIds = commGeneralService.getLineIdsByRedis(param.getDeptId());
|
||||||
|
|
||||||
LambdaQueryWrapper<PqUserLineAssPO> assQuery = new LambdaQueryWrapper<>();
|
List<PqUserLineAssPO> assPOList =getUserLineAssociations(lineIds);
|
||||||
assQuery.in(PqUserLineAssPO::getLineIndex,lineIds);
|
|
||||||
List<PqUserLineAssPO> assPOList = pqUserLineAssMapper.selectList(assQuery);
|
|
||||||
if(CollUtil.isEmpty(assPOList)){
|
if(CollUtil.isEmpty(assPOList)){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -343,25 +457,36 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
if(CollUtil.isEmpty(deptLineIds)){
|
if(CollUtil.isEmpty(deptLineIds)){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
List<PqUserLineAssPO> list = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,deptLineIds));
|
|
||||||
if(CollUtil.isEmpty(list)){
|
List<PqUserLineAssPO> assPOList = getUserLineAssociations(deptLineIds);
|
||||||
|
if(CollUtil.isEmpty(assPOList)){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
List<String> userIds = list.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
List<String> userIds = assPOList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId,userIds).eq(PqUserLedgerPO::getIsShow,1));
|
LambdaQueryWrapper<PqUserLedgerPO> userQuery = new LambdaQueryWrapper<>();
|
||||||
|
if(userIds.size() > 1000){
|
||||||
|
List<List<String>> userIdList = CollUtil.split(userIds,1000);
|
||||||
|
userQuery.and(ad->{
|
||||||
|
for(List<String> ids : userIdList){
|
||||||
|
ad.or(o->o.in(PqUserLedgerPO::getId,ids));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else {
|
||||||
|
userQuery.in(PqUserLedgerPO::getId,userIds);
|
||||||
|
}
|
||||||
|
userQuery.eq(PqUserLedgerPO::getIsShow,1);
|
||||||
|
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(userQuery);
|
||||||
if(CollUtil.isEmpty(poList)){
|
if(CollUtil.isEmpty(poList)){
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> ids = poList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
|
List<String> ids = poList.stream().map(PqUserLedgerPO::getId).collect(Collectors.toList());
|
||||||
List<PqUserLineAssPO> assTemList = list.stream().filter(it->ids.contains(it.getUserIndex())).collect(Collectors.toList());
|
List<PqUserLineAssPO> assTemList = assPOList.stream().filter(it->ids.contains(it.getUserIndex())).collect(Collectors.toList());
|
||||||
|
|
||||||
//获取监测id,用于查询暂降表
|
//获取监测id,用于查询暂降表
|
||||||
List<Integer> lineIds = assTemList.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
|
List<Integer> lineIds = assTemList.stream().map(PqUserLineAssPO::getLineIndex).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
List<PqsEventdetail> eventList = pqsEventdetailService.lambdaQuery().
|
List<PqsEventdetail> eventList = pqsEventdetailService.lambdaQuery().
|
||||||
in(PqsEventdetail::getLineid,lineIds)
|
in(PqsEventdetail::getLineid,lineIds)
|
||||||
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
|
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
|
||||||
@@ -370,7 +495,7 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
poList.forEach(item->{
|
poList.forEach(item->{
|
||||||
UserLedgerStatisticVO.Inner inner = new UserLedgerStatisticVO.Inner();
|
UserLedgerStatisticVO.Inner inner = new UserLedgerStatisticVO.Inner();
|
||||||
inner.setCustomId(item.getId());
|
inner.setCustomId(item.getId());
|
||||||
inner.setName(item.getCustomerName());
|
inner.setName(item.getProjectName());
|
||||||
inner.setCount(0);
|
inner.setCount(0);
|
||||||
result.add(inner);
|
result.add(inner);
|
||||||
});
|
});
|
||||||
@@ -381,7 +506,7 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
poList.forEach(item->{
|
poList.forEach(item->{
|
||||||
UserLedgerStatisticVO.Inner inner = new UserLedgerStatisticVO.Inner();
|
UserLedgerStatisticVO.Inner inner = new UserLedgerStatisticVO.Inner();
|
||||||
inner.setCustomId(item.getId());
|
inner.setCustomId(item.getId());
|
||||||
inner.setName(item.getCustomerName());
|
inner.setName(item.getProjectName());
|
||||||
List<Integer> LIds = assMap.get(item.getId());
|
List<Integer> LIds = assMap.get(item.getId());
|
||||||
List<String> eventIds = eventList.stream().filter(it -> LIds.contains(it.getLineid())).map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
|
List<String> eventIds = eventList.stream().filter(it -> LIds.contains(it.getLineid())).map(PqsEventdetail::getEventdetailIndex).collect(Collectors.toList());
|
||||||
inner.setEventList(eventIds);
|
inner.setEventList(eventIds);
|
||||||
@@ -409,4 +534,21 @@ public class EventRightServiceImpl implements EventRightService {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <T, ID> List<T> batchQuery(List<ID> ids, Function<List<ID>, List<T>> queryFunc, int batchSize) {
|
||||||
|
if (CollectionUtils.isEmpty(ids)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ids.size() <= batchSize) {
|
||||||
|
return queryFunc.apply(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<T> result = new ArrayList<>();
|
||||||
|
List<List<ID>> batches = CollUtil.split(ids, batchSize);
|
||||||
|
for (List<ID> batch : batches) {
|
||||||
|
result.addAll(queryFunc.apply(batch));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO;
|
|||||||
import com.njcn.gather.event.devcie.pojo.dto.PqsDeptDTO;
|
import com.njcn.gather.event.devcie.pojo.dto.PqsDeptDTO;
|
||||||
import com.njcn.gather.event.devcie.pojo.dto.SubstationDTO;
|
import com.njcn.gather.event.devcie.pojo.dto.SubstationDTO;
|
||||||
import com.njcn.gather.event.devcie.pojo.po.PqLinedetail;
|
import com.njcn.gather.event.devcie.pojo.po.PqLinedetail;
|
||||||
|
import com.njcn.gather.event.transientes.mapper.PqUserLedgerMapper;
|
||||||
|
import com.njcn.gather.event.transientes.mapper.PqUserLineAssMapper;
|
||||||
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
|
import com.njcn.gather.event.transientes.pojo.param.LargeScreenCountParam;
|
||||||
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
|
import com.njcn.gather.event.devcie.pojo.po.PqDevice;
|
||||||
import com.njcn.gather.event.devcie.pojo.po.PqLine;
|
import com.njcn.gather.event.devcie.pojo.po.PqLine;
|
||||||
@@ -88,6 +90,11 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
|||||||
private final PqLinedetailMapper pqLinedetailMapper;
|
private final PqLinedetailMapper pqLinedetailMapper;
|
||||||
private final RedisUtil redisUtil;
|
private final RedisUtil redisUtil;
|
||||||
private final PqsOnlinerateService pqsOnlinerateService;
|
private final PqsOnlinerateService pqsOnlinerateService;
|
||||||
|
|
||||||
|
private final PqUserLedgerMapper pqUserLedgerMapper;
|
||||||
|
|
||||||
|
private final PqUserLineAssMapper pqUserLineAssMapper;
|
||||||
|
|
||||||
@Value("${SYS_TYPE_ZT}")
|
@Value("${SYS_TYPE_ZT}")
|
||||||
private String sysTypeZt;
|
private String sysTypeZt;
|
||||||
private final static String NAME_KEY = "LineCache:";
|
private final static String NAME_KEY = "LineCache:";
|
||||||
@@ -460,14 +467,14 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
|||||||
throw new BusinessException("统计类型有误类型");
|
throw new BusinessException("统计类型有误类型");
|
||||||
}
|
}
|
||||||
//根据用户获取当前部门及子部门id
|
//根据用户获取当前部门及子部门id
|
||||||
// List<Integer> deptslineIds = commGeneralService.getLineIdsByDept(largeScreenCountParam);
|
List<Integer> deptslineIds = commGeneralService.getLineIdsByRedis(largeScreenCountParam.getDeptId());
|
||||||
if (CollUtil.isEmpty(lineIds)) {
|
if (CollUtil.isEmpty(deptslineIds)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
List<PqsEventdetail> allList = new ArrayList<>();
|
List<PqsEventdetail> allList = new ArrayList<>();
|
||||||
LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<PqsEventdetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
if(lineIds.size()>1000){
|
if(deptslineIds.size()>1000){
|
||||||
List<List<Integer>> idList = CollUtil.split(lineIds,1000);
|
List<List<Integer>> idList = CollUtil.split(deptslineIds,1000);
|
||||||
for(List<Integer> ids:idList){
|
for(List<Integer> ids:idList){
|
||||||
lambdaQueryWrapper.clear();
|
lambdaQueryWrapper.clear();
|
||||||
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
|
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||||
@@ -487,7 +494,7 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
|||||||
}else {
|
}else {
|
||||||
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
|
lambdaQueryWrapper.between(PqsEventdetail::getTimeid, startTime, endTime)
|
||||||
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
|
.in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType())
|
||||||
.in(PqsEventdetail::getLineid, lineIds)
|
.in(PqsEventdetail::getLineid, deptslineIds)
|
||||||
.and(wrapper -> wrapper.eq(PqsEventdetail::getLookFlag, 0).or().isNull(PqsEventdetail::getLookFlag));
|
.and(wrapper -> wrapper.eq(PqsEventdetail::getLookFlag, 0).or().isNull(PqsEventdetail::getLookFlag));
|
||||||
if (Objects.nonNull(largeScreenCountParam.getEventDeep())) {
|
if (Objects.nonNull(largeScreenCountParam.getEventDeep())) {
|
||||||
if (largeScreenCountParam.getEventDeep() == 0) {
|
if (largeScreenCountParam.getEventDeep() == 0) {
|
||||||
@@ -505,6 +512,14 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
|||||||
List<Integer> ids = allList.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
|
List<Integer> ids = allList.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList());
|
||||||
List<LedgerBaseInfoDTO> pqLineList = pqLineService.getBaseLineInfo(ids);
|
List<LedgerBaseInfoDTO> pqLineList = pqLineService.getBaseLineInfo(ids);
|
||||||
Map<Integer, LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pqLineList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
|
Map<Integer, LedgerBaseInfoDTO> ledgerBaseInfoDTOMap = pqLineList.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity()));
|
||||||
|
|
||||||
|
List<PqUserLineAssPO> assList = pqUserLineAssMapper.selectList(new LambdaQueryWrapper<PqUserLineAssPO>().in(PqUserLineAssPO::getLineIndex,ids));
|
||||||
|
List<String> userIds = assList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList());
|
||||||
|
List<PqUserLedgerPO> poList = pqUserLedgerMapper.selectList(new LambdaQueryWrapper<PqUserLedgerPO>().in(PqUserLedgerPO::getId,userIds));
|
||||||
|
Map<String,PqUserLedgerPO> userMap = poList.stream().collect(Collectors.toMap(PqUserLedgerPO::getId,Function.identity()));
|
||||||
|
|
||||||
|
Map<Integer,List<PqUserLineAssPO>> assMap = assList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex));
|
||||||
|
|
||||||
for(PqsEventdetail it : allList){
|
for(PqsEventdetail it : allList){
|
||||||
EventDetailVO eventDetailVO = new EventDetailVO();
|
EventDetailVO eventDetailVO = new EventDetailVO();
|
||||||
eventDetailVO.setEventdetail_index(it.getEventdetailIndex());
|
eventDetailVO.setEventdetail_index(it.getEventdetailIndex());
|
||||||
@@ -521,6 +536,11 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService {
|
|||||||
eventDetailVO.setGdName(ledgerBaseInfoDTO.getGdName());
|
eventDetailVO.setGdName(ledgerBaseInfoDTO.getGdName());
|
||||||
eventDetailVO.setBusName(ledgerBaseInfoDTO.getBusBarName());
|
eventDetailVO.setBusName(ledgerBaseInfoDTO.getBusBarName());
|
||||||
}
|
}
|
||||||
|
if(assMap.containsKey(eventDetailVO.getLineid())) {
|
||||||
|
List<String> temList = assMap.get(eventDetailVO.getLineid()).stream().map(PqUserLineAssPO::getUserIndex).collect(Collectors.toList());
|
||||||
|
String str = temList.stream().map(its -> userMap.containsKey(its)?userMap.get(its).getProjectName() + "; ":"/").collect(Collectors.joining());
|
||||||
|
eventDetailVO.setObjName(str);
|
||||||
|
}
|
||||||
result.add(eventDetailVO);
|
result.add(eventDetailVO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user