From 13fd6f11ae17f6f9de4a041e6e4561a3d617d25f Mon Sep 17 00:00:00 2001 From: cdf <857448963@qq.com> Date: Tue, 12 Aug 2025 09:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=97=E4=BA=AC=E6=9A=82=E9=99=8D=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../event/devcie/mapper/PqLineMapper.java | 7 +- .../devcie/mapper/PqsStationMapMapper.java | 22 +++ .../devcie/mapper/mapping/PqLineMapper.xml | 26 ++++ .../devcie/pojo/dto/LedgerBaseInfoDTO.java | 5 + .../event/devcie/pojo/po/PqsStationMap.java | 58 ++++++++ .../event/devcie/service/PqLineService.java | 4 +- .../service/impl/PqLineServiceImpl.java | 24 ++- .../transientes/filter/JwtRequestFilter.java | 5 +- .../pojo/vo/SubStationCountVO.java | 4 +- .../transientes/security/AuthController.java | 9 +- .../security/MyUserDetailsService.java | 4 +- .../transientes/security/SecurityConfig.java | 8 +- .../service/impl/EventRightServiceImpl.java | 8 +- .../impl/LargeScreenCountServiceImpl.java | 139 ++++++++++++------ .../event/transientes/utils/JwtUtil.java | 4 +- .../src/main/resources/application-dev.yml | 2 +- .../src/main/resources/application-prod.yml | 2 +- .../src/main/resources/application.yml | 2 +- 18 files changed, 262 insertions(+), 71 deletions(-) create mode 100644 event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqsStationMapMapper.java create mode 100644 event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/po/PqsStationMap.java diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqLineMapper.java b/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqLineMapper.java index 9cf3e9d6..72c937f9 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqLineMapper.java +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqLineMapper.java @@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Param; import java.util.List; /** - * + * * Description: * Date: 2025/06/19 下午 1:43【需求编号】 * @@ -19,4 +19,7 @@ public interface PqLineMapper extends BaseMapper { List getBaseLineInfo(@Param("ids")List ids); -} \ No newline at end of file + + List getBaseLedger(@Param("ids")List ids); + +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqsStationMapMapper.java b/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqsStationMapMapper.java new file mode 100644 index 00000000..969cce23 --- /dev/null +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/PqsStationMapMapper.java @@ -0,0 +1,22 @@ +package com.njcn.gather.event.devcie.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO; +import com.njcn.gather.event.devcie.pojo.po.PqLine; +import com.njcn.gather.event.devcie.pojo.po.PqsStationMap; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * + * Description: + * Date: 2025/06/19 下午 1:43【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +public interface PqsStationMapMapper extends BaseMapper { + + +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/mapping/PqLineMapper.xml b/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/mapping/PqLineMapper.xml index 70218b95..102ede38 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/mapping/PqLineMapper.xml +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/mapper/mapping/PqLineMapper.xml @@ -62,4 +62,30 @@ where 1=1 + + + diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/dto/LedgerBaseInfoDTO.java b/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/dto/LedgerBaseInfoDTO.java index 703fb53b..3c83a84e 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/dto/LedgerBaseInfoDTO.java +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/dto/LedgerBaseInfoDTO.java @@ -2,6 +2,8 @@ package com.njcn.gather.event.devcie.pojo.dto; import lombok.Data; +import java.math.BigDecimal; + /** * @Author: cdf * @CreateTime: 2025-06-25 @@ -32,5 +34,8 @@ public class LedgerBaseInfoDTO { //通讯状态 private Integer runFlag=0; + private Integer eventCount; + + } diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/po/PqsStationMap.java b/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/po/PqsStationMap.java new file mode 100644 index 00000000..d1305506 --- /dev/null +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/pojo/po/PqsStationMap.java @@ -0,0 +1,58 @@ +package com.njcn.gather.event.devcie.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * CN_Gather + * + * @author cdf + * @date 2025/8/11 + */ +@TableName(value="PQS_MAP") +@Data +public class PqsStationMap { + + + @TableId + @TableField(value = "MAP_INDEX") + private String mapIndex; + + + @TableField(value = "SUB_INDEX") + private Long subIndex; + + + @TableField(value = "GD_INDEX") + private Long gdIndex; + + //经度 + + @TableField(value = "LONGITUDE") + private Float longItude; + + //纬度 + + @TableField(value = "LATITUDE") + private Float latItude; + + //数据状态 + + @TableField(value = "STATE") + private Long state; + + //用户ID + + @TableField(value = "USER_INDEX") + private String userIndex; + + //更新时间 + + @TableField(value = "UPDATETIME") + private Date updateTime; + +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/service/PqLineService.java b/event_smart/src/main/java/com/njcn/gather/event/devcie/service/PqLineService.java index 20eb92fd..13e2520a 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/devcie/service/PqLineService.java +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/service/PqLineService.java @@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; /** - * + * * Description: * Date: 2025/06/19 下午 1:43【需求编号】 * @@ -19,4 +19,6 @@ public interface PqLineService extends IService{ List getBaseLineInfo(List ids); + + List getBaseLedger(List ids); } diff --git a/event_smart/src/main/java/com/njcn/gather/event/devcie/service/impl/PqLineServiceImpl.java b/event_smart/src/main/java/com/njcn/gather/event/devcie/service/impl/PqLineServiceImpl.java index 76f76462..f4bd8758 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/devcie/service/impl/PqLineServiceImpl.java +++ b/event_smart/src/main/java/com/njcn/gather/event/devcie/service/impl/PqLineServiceImpl.java @@ -15,7 +15,7 @@ import com.njcn.gather.event.devcie.service.PqLineService; import org.springframework.util.CollectionUtils; /** - * + * * Description: * Date: 2025/06/19 下午 1:43【需求编号】 * @@ -44,6 +44,28 @@ public class PqLineServiceImpl extends ServiceImpl impleme ledgerBaseInfoDTOS.addAll(temp); } return ledgerBaseInfoDTOS; + } + + @Override + public List getBaseLedger(List ids) { + List ledgerBaseInfoDTOS = new ArrayList<>(); + + if(CollectionUtils.isEmpty(ids)){ + return ledgerBaseInfoDTOS; + } + if(ids.size()>1000){ + List> listIds = CollUtil.split(ids,1000); + for(List itemIds : listIds){ + List temp =this.baseMapper.getBaseLedger(itemIds); + ledgerBaseInfoDTOS.addAll(temp); + } + }else { + List temp =this.baseMapper.getBaseLedger(ids); + ledgerBaseInfoDTOS.addAll(temp); + } + return ledgerBaseInfoDTOS; }; + + } diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/filter/JwtRequestFilter.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/filter/JwtRequestFilter.java index 34b9733b..eae599a2 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/filter/JwtRequestFilter.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/filter/JwtRequestFilter.java @@ -36,8 +36,7 @@ public class JwtRequestFilter extends OncePerRequestFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException { - - /* final String authorizationHeader = request.getHeader("Authorization"); + /* final String authorizationHeader = request.getHeader("Authorization"); String username = null; String jwt = null; if (authorizationHeader != null && authorizationHeader.startsWith("Bearer ")) { @@ -79,4 +78,4 @@ public class JwtRequestFilter extends OncePerRequestFilter { response.getWriter().write(new JSONObject(httpResult, false).toString()); } -} \ No newline at end of file +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/pojo/vo/SubStationCountVO.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/pojo/vo/SubStationCountVO.java index 20ba6b60..74a8347e 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/pojo/vo/SubStationCountVO.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/pojo/vo/SubStationCountVO.java @@ -1,5 +1,6 @@ package com.njcn.gather.event.transientes.pojo.vo; +import com.njcn.gather.event.devcie.pojo.dto.LedgerBaseInfoDTO; import com.njcn.gather.event.transientes.pojo.po.PqsEventdetail; import lombok.AllArgsConstructor; import lombok.Data; @@ -26,7 +27,7 @@ public class SubStationCountVO { private Integer lineCount; private Integer eventCount; - private List lineEventDetails; + private List lineEventDetails; @Data @@ -55,6 +56,7 @@ public class SubStationCountVO { private String stationName; //通讯状态 private Integer runFlag=0; + private Integer eventCount; private List pqsEventdetails; diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/security/AuthController.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/security/AuthController.java index df54fbdf..ecd02fe2 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/security/AuthController.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/security/AuthController.java @@ -21,10 +21,13 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; +import javax.validation.constraints.NotBlank; + @RestController @Slf4j @RequiredArgsConstructor @@ -46,7 +49,7 @@ public class AuthController extends BaseController { @PostMapping("/cn_authenticate") @ApiOperation("登录认证") - public HttpResult createAuthenticationToken(@RequestBody AuthRequest authRequest) { + public HttpResult createAuthenticationToken(@RequestBody @Validated AuthRequest authRequest) { String methodDescribe = getMethodDescribe("createAuthenticationToken"); //log.info("Authentication request - username: {}, password: {}",authRequest.getUsername(),authRequest.getPassword()); try { @@ -84,6 +87,8 @@ public class AuthController extends BaseController { // 认证请求类 class AuthRequest { + + @NotBlank(message = "用户名不可为空") private String username; private String password; @@ -102,4 +107,4 @@ class AuthRequest { public void setPassword(String password) { this.password = password; } -} \ No newline at end of file +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/security/MyUserDetailsService.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/security/MyUserDetailsService.java index fadb29ba..1e3ee432 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/security/MyUserDetailsService.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/security/MyUserDetailsService.java @@ -36,7 +36,7 @@ public class MyUserDetailsService implements UserDetailsService { public MyUserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - if(username.equals("system_event")){ + if("system_event".equals(username)){ return new MyUserDetails("12345678910","system_event", "@#001njcnpqs","10001", new ArrayList<>()); } @@ -67,4 +67,4 @@ public class MyUserDetailsService implements UserDetailsService { throw new UsernameNotFoundException("User not found with username: " + username); } } -} \ No newline at end of file +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/security/SecurityConfig.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/security/SecurityConfig.java index ee5d52fb..53f44113 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/security/SecurityConfig.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/security/SecurityConfig.java @@ -34,16 +34,14 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { protected void configure(HttpSecurity http) throws Exception { http.csrf().disable() .authorizeRequests() - //.antMatchers("/cn_authenticate","/ws/**","/accept/testEvent").permitAll() // 允许访问认证接口 - .antMatchers("/**").permitAll() // 允许访问认证接口 .antMatchers("/cn_authenticate","/ws/**","/accept/testEvent").permitAll() // 允许访问认证接口 -// .antMatchers("/**").permitAll() // 允许访问认证接口 + .antMatchers("/**").permitAll() // 允许访问认证接口 .anyRequest().authenticated() .and() .sessionManagement() .sessionCreationPolicy(SessionCreationPolicy.STATELESS); // 使用无状态会话 -// http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class); + //http.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class); } @Bean @@ -56,4 +54,4 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { public PasswordEncoder passwordEncoder() { return new BCryptPasswordEncoder(); } -} \ No newline at end of file +} diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/EventRightServiceImpl.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/EventRightServiceImpl.java index 61186268..7fd1feb2 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/EventRightServiceImpl.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/EventRightServiceImpl.java @@ -177,7 +177,11 @@ public class EventRightServiceImpl implements EventRightService { } else { eventQuery.in(PqsEventdetail::getLineid, lineIds); } - return pqsEventdetailService.list(eventQuery); + List eventdetailList = pqsEventdetailService.list(eventQuery); + if(CollUtil.isNotEmpty(eventdetailList)){ + eventdetailList.forEach(it->it.setPersisttime(BigDecimal.valueOf(it.getPersisttime() / 1000).setScale(3,RoundingMode.HALF_UP).doubleValue())); + } + return eventdetailList; } private List getUserLedgers(List assUserIds,LargeScreenCountParam param,boolean queryFlag){ @@ -382,7 +386,7 @@ public class EventRightServiceImpl implements EventRightService { eventDetailVO.setPointname(dto.getLineName()); eventDetailVO.setEventdetail_index(pqsEventdetail.getEventdetailIndex()); eventDetailVO.setDevName(dto.getDevName()); - + eventDetailVO.setPersisttime(BigDecimal.valueOf(pqsEventdetail.getPersisttime() / 1000).setScale(3,RoundingMode.HALF_UP).toString()); resultList.add(eventDetailVO); } result.setTotal(page.getTotal()); diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/LargeScreenCountServiceImpl.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/LargeScreenCountServiceImpl.java index e86e8751..c8e48fd5 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/LargeScreenCountServiceImpl.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/service/impl/LargeScreenCountServiceImpl.java @@ -17,19 +17,17 @@ import com.njcn.common.pojo.exception.BusinessException; import com.njcn.gather.event.devcie.config.PqlineCache; import com.njcn.gather.event.devcie.mapper.PqLineMapper; import com.njcn.gather.event.devcie.mapper.PqLinedetailMapper; +import com.njcn.gather.event.devcie.mapper.PqsStationMapMapper; import com.njcn.gather.event.devcie.pojo.dto.DeviceDTO; 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.SubstationDTO; -import com.njcn.gather.event.devcie.pojo.po.PqLinedetail; +import com.njcn.gather.event.devcie.pojo.po.*; import com.njcn.gather.event.transientes.mapper.PqUserLedgerMapper; import com.njcn.gather.event.transientes.mapper.PqUserLineAssMapper; import com.njcn.gather.event.transientes.mapper.PqsIntegrityMapper; import com.njcn.gather.event.transientes.mapper.PqsOnlinerateMapper; 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.PqLine; -import com.njcn.gather.event.devcie.pojo.po.PqsDeptsline; import com.njcn.gather.event.transientes.pojo.param.MessageEventFeedbackParam; import com.njcn.gather.event.transientes.pojo.po.PqsDepts; import com.njcn.gather.event.transientes.pojo.po.MessageEventFeedback; @@ -99,6 +97,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService { private final PqUserLineAssMapper pqUserLineAssMapper; + private final PqsStationMapMapper pqsStationMapMapper; + @Value("${SYS_TYPE_ZT}") private String sysTypeZt; private final static String NAME_KEY = "LineCache:"; @@ -977,23 +977,47 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService { return result; } + private List getUserLineAssociations(List lineIds){ + LambdaQueryWrapper assQuery = new LambdaQueryWrapper<>(); + assQuery.in(PqUserLineAssPO::getLineIndex, lineIds); + if(lineIds.size()>1000){ + List> lineList = CollUtil.split(lineIds, 1000); + assQuery.and(w -> { + for (List ids : lineList) { + w.or(wIn -> wIn.in(PqUserLineAssPO::getLineIndex, ids)); + } + }); + }else { + assQuery.in(PqUserLineAssPO::getLineIndex, lineIds); + } + + return pqUserLineAssMapper.selectList(assQuery); + } + + private List getUserLedgers(List assUserIds){ + LambdaQueryWrapper userWrapper = new LambdaQueryWrapper<>(); + if(assUserIds.size()>1000){ + List> assUserIdsList = CollUtil.split(assUserIds, 1000); + userWrapper.and(w -> { + for (List ids : assUserIdsList) { + w.or(wIn -> wIn.in(PqUserLedgerPO::getId, ids)); + } + }); + }else { + userWrapper.in(PqUserLedgerPO::getId, assUserIds); + } + return pqUserLedgerMapper.selectList(userWrapper); + } @Override public List substationCount(LargeScreenCountParam largeScreenCountParam) { LocalDateTime startTime = largeScreenCountParam.getStartTime().atStartOfDay(); LocalDateTime endTime = LocalDateTimeUtil.endOfDay(largeScreenCountParam.getEndTime().atStartOfDay()); - List subStationCountVOS = new ArrayList<>(); - List pqLineList = (List) redisUtil.getObjectByKey( NAME_KEY+ StrUtil.DASHED+"pqLineList"); - List deptslineIds = (List) redisUtil.getObjectByKey( NAME_KEY+ StrUtil.DASHED+largeScreenCountParam.getDeptId()); - List ledgerBaseInfoDTOS = pqLineService.getBaseLineInfo(deptslineIds); - Map ledgerBaseInfoDTOMap = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity())); - - pqLineList = pqLineList.stream().filter(temp->deptslineIds.contains(temp.getLineIndex())).collect(Collectors.toList()); - List subIndexs = pqLineList.stream().map(PqLine::getSubIndex).collect(Collectors.toList()); - List substationDTOS = pqSubstationService.queryListByIds(subIndexs); - Map substationDTOMap= substationDTOS.stream().collect(Collectors.toMap(SubstationDTO::getStationId, Function.identity())); - + List deptslineIds = commGeneralService.getLineIdsByRedis(largeScreenCountParam.getDeptId()); + if(CollUtil.isEmpty(deptslineIds)){ + return new ArrayList<>(); + } //查询暂态事件 List eventdetails = new ArrayList<>(); if(deptslineIds.size()>1000){ @@ -1002,9 +1026,8 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService { List temp = pqsEventdetailService.lambdaQuery() .between(PqsEventdetail::getTimeid,startTime, endTime) .in(PqsEventdetail::getWavetype,msgEventConfigService.getEventType()) - .in(PqsEventdetail::getLineid,listIds) - .orderByDesc(PqsEventdetail::getTimeid).list() - ; + .in(PqsEventdetail::getLineid,itemIds) + .orderByDesc(PqsEventdetail::getTimeid).list(); eventdetails.addAll(temp); } }else { @@ -1015,42 +1038,64 @@ public class LargeScreenCountServiceImpl implements LargeScreenCountService { .orderByDesc(PqsEventdetail::getTimeid).list(); eventdetails.addAll(temp); } - Map> map = pqLineList.stream().collect(Collectors.groupingBy(PqLine::getSubIndex)); - map.forEach((k,v)->{ - if(substationDTOMap.containsKey(k)){ + + if(CollUtil.isEmpty(eventdetails)){ + return new ArrayList<>(); + } + + List lineIds = eventdetails.stream().map(PqsEventdetail::getLineid).distinct().collect(Collectors.toList()); + //List pqLineList = (List) redisUtil.getObjectByKey( NAME_KEY+ StrUtil.DASHED+"pqLineList"); + //pqLineList = pqLineList.stream().filter(temp->lineIds.contains(temp.getLineIndex())).collect(Collectors.toList()); + + List assPOList = getUserLineAssociations(lineIds); + List userIds = assPOList.stream().map(PqUserLineAssPO::getUserIndex).distinct().collect(Collectors.toList()); + + Map> lineAssMap = assPOList.stream().collect(Collectors.groupingBy(PqUserLineAssPO::getLineIndex,Collectors.mapping(PqUserLineAssPO::getUserIndex,Collectors.toList()))); + + List pqUserLedgerPOList = getUserLedgers(userIds); + + List subStationCountVOS = new ArrayList<>(); + List ledgerBaseInfoDTOS = pqLineService.getBaseLedger(lineIds); + //Map ledgerBaseInfoDTOMap = ledgerBaseInfoDTOS.stream().collect(Collectors.toMap(LedgerBaseInfoDTO::getLineId, Function.identity())); + + List subIndexs = ledgerBaseInfoDTOS.stream().map(LedgerBaseInfoDTO::getStationId).collect(Collectors.toList()); + List pqsStationMapList = pqsStationMapMapper.selectList(new LambdaQueryWrapper().in(PqsStationMap::getSubIndex,subIndexs).eq(PqsStationMap::getState,1)); + Map stationMapMap = pqsStationMapList.stream().collect(Collectors.toMap(PqsStationMap::getSubIndex,dept->dept)); + + Map> substationDTOMap= ledgerBaseInfoDTOS.stream().collect(Collectors.groupingBy(LedgerBaseInfoDTO::getStationId)); + + Map> collect = eventdetails.stream().collect(Collectors.groupingBy(PqsEventdetail::getLineid)); + + substationDTOMap.forEach((k,v)->{ + LedgerBaseInfoDTO ledgerBaseInfoDTO = v.get(0); SubStationCountVO subStationCountVO = new SubStationCountVO(); - SubstationDTO substationDTO = substationDTOMap.get(k); - subStationCountVO.setStationId(substationDTO.getStationId()); - subStationCountVO.setStationName(substationDTO.getStationName()); - subStationCountVO.setGdName(substationDTO.getGdName()); - subStationCountVO.setLongitude(substationDTO.getLongitude()); - subStationCountVO.setLatitude(substationDTO.getLatitude()); - List tempLineIds = v.stream().map(PqLine::getLineIndex).collect(Collectors.toList()); + subStationCountVO.setStationId(k); + subStationCountVO.setStationName(ledgerBaseInfoDTO.getStationName()); + subStationCountVO.setGdName(ledgerBaseInfoDTO.getGdName()); + PqsStationMap pqsStationMap = stationMapMap.get(k.longValue()); + subStationCountVO.setLongitude(pqsStationMap.getLongItude()); + subStationCountVO.setLatitude(pqsStationMap.getLatItude()); + + List tempLineIds = v.stream().map(LedgerBaseInfoDTO::getLineId).collect(Collectors.toList()); + + + subStationCountVO.setLineCount(tempLineIds.size()); List tempEventList = eventdetails.stream().filter(temp -> tempLineIds.contains(temp.getLineid())).collect(Collectors.toList()); - if(CollectionUtils.isEmpty(tempEventList)){ - subStationCountVO.setEventCount(0); - return; - - } subStationCountVO.setEventCount(tempEventList.size()); - Map> collect = tempEventList.stream().collect(Collectors.groupingBy(PqsEventdetail::getLineid)); - List lineEventDetails = new ArrayList<>(); - collect.forEach((k1,v1)->{ - SubStationCountVO.LineEventDetail lineEventDetail = new SubStationCountVO.LineEventDetail(); - LedgerBaseInfoDTO ledgerBaseInfoDTO = ledgerBaseInfoDTOMap.get(k1); - BeanUtils.copyProperties(ledgerBaseInfoDTO,lineEventDetail); - lineEventDetail.setEventCount(v1.size()); -// lineEventDetail.setPqsEventdetails(v1); - lineEventDetails.add(lineEventDetail); + + v.forEach(item->{ + String obj = ""; + if(lineAssMap.containsKey(item.getLineId())){ + List userIndex = lineAssMap.get(item.getLineId()); + obj = pqUserLedgerPOList.stream().filter(it->userIndex.contains(it.getId())).map(PqUserLedgerPO::getCustomerName).collect(Collectors.joining(";")); + } + item.setObjName(StrUtil.isNotBlank(obj)? obj:"/"); + item.setEventCount(collect.get(item.getLineId()).size()); }); - subStationCountVO.setLineEventDetails(lineEventDetails); + subStationCountVO.setLineEventDetails(v); subStationCountVOS.add(subStationCountVO); - } - }); - - return subStationCountVOS; } diff --git a/event_smart/src/main/java/com/njcn/gather/event/transientes/utils/JwtUtil.java b/event_smart/src/main/java/com/njcn/gather/event/transientes/utils/JwtUtil.java index 2cf6e945..70805f73 100644 --- a/event_smart/src/main/java/com/njcn/gather/event/transientes/utils/JwtUtil.java +++ b/event_smart/src/main/java/com/njcn/gather/event/transientes/utils/JwtUtil.java @@ -23,7 +23,7 @@ public class JwtUtil { private static final Key SECRET_KEY = Keys.secretKeyFor(SignatureAlgorithm.HS256); - private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 100000L; // 10小时 + private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 1000000000L; // 100000小时 // 生成JWT令牌 public String generateToken(MyUserDetails userDetails) { @@ -82,4 +82,4 @@ public class JwtUtil { private Boolean isTokenExpired(String token) { return extractExpiration(token).before(new Date()); } -} \ No newline at end of file +} diff --git a/event_smart/src/main/resources/application-dev.yml b/event_smart/src/main/resources/application-dev.yml index d8076e3a..2c95ddb2 100644 --- a/event_smart/src/main/resources/application-dev.yml +++ b/event_smart/src/main/resources/application-dev.yml @@ -46,7 +46,7 @@ spring: lettuce: pool: max-active: 8 - max-wait: -1 + max-wait: 8000 max-idle: 8 min-idle: 0 diff --git a/event_smart/src/main/resources/application-prod.yml b/event_smart/src/main/resources/application-prod.yml index 8847f395..334d60d2 100644 --- a/event_smart/src/main/resources/application-prod.yml +++ b/event_smart/src/main/resources/application-prod.yml @@ -48,7 +48,7 @@ spring: lettuce: pool: max-active: 20 - max-wait: 5000 + max-wait: 8000 max-idle: 8 min-idle: 0 diff --git a/event_smart/src/main/resources/application.yml b/event_smart/src/main/resources/application.yml index ac63024e..da1c319f 100644 --- a/event_smart/src/main/resources/application.yml +++ b/event_smart/src/main/resources/application.yml @@ -8,7 +8,7 @@ spring: application: name: event_smart profiles: - active: dev + active: prod #mybatis配置信息