应急处置ncc
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m22s
All checks were successful
local-test分支构建docker并发布运行 / Docker-Build (push) Successful in 1m22s
This commit is contained in:
parent
5790fd2cfb
commit
a051e6d8a1
@ -3,6 +3,8 @@ package club.joylink.xiannccda.constants.common;
|
|||||||
public enum FaultQueryType {
|
public enum FaultQueryType {
|
||||||
// FAULT_EMERGENCY_GUIDE 开头是应急故障,FAULT_EXIT_SERVICE 开头是故障退出服务
|
// FAULT_EMERGENCY_GUIDE 开头是应急故障,FAULT_EXIT_SERVICE 开头是故障退出服务
|
||||||
// T 代表车辆,T后面代表车辆型号
|
// T 代表车辆,T后面代表车辆型号
|
||||||
|
|
||||||
|
FAULT_EMERGENCY_NCC,
|
||||||
FAULT_EMERGENCY_GUIDE,
|
FAULT_EMERGENCY_GUIDE,
|
||||||
FAULT_EXIT_SERVICE,
|
FAULT_EXIT_SERVICE,
|
||||||
FAULT_EMERGENCY_GUIDE_T_DK37,
|
FAULT_EMERGENCY_GUIDE_T_DK37,
|
||||||
|
@ -7,6 +7,7 @@ import club.joylink.xiannccda.constants.common.FaultQueryType;
|
|||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipInfoDto;
|
||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipQueryDTO;
|
||||||
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
import club.joylink.xiannccda.dto.alertTip.AlertTipSaveDTO;
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultQueryNcc;
|
||||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||||
import club.joylink.xiannccda.dto.fq.FaultType;
|
import club.joylink.xiannccda.dto.fq.FaultType;
|
||||||
import club.joylink.xiannccda.dto.fq.FaultType.FaultTypeDetail;
|
import club.joylink.xiannccda.dto.fq.FaultType.FaultTypeDetail;
|
||||||
@ -58,14 +59,22 @@ public class FaultQueryController {
|
|||||||
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
// @CommonLogAnno(name = "决策信息-查看", logType = CommonLogTypeEnum.OPERATE, subLogType = SubEventType.QUERY)
|
||||||
public List<FaultType> faultType() {
|
public List<FaultType> faultType() {
|
||||||
return List.of(new FaultType(3,
|
return List.of(new FaultType(3,
|
||||||
List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE, "车辆故障应急处置指导关键点"), new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE, "车辆故障退出服务地点")))
|
List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE, "车辆故障应急处置指导关键点"), new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE, "车辆故障退出服务地点")
|
||||||
|
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_NCC, "NCC应急查询")))
|
||||||
, new FaultType(4, List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_DK37, "车辆故障应急处置指导关键点-DK37车型"),
|
, new FaultType(4, List.of(new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_DK37, "车辆故障应急处置指导关键点-DK37车型"),
|
||||||
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_DK37, "车辆故障退出服务地点-DK37车型")
|
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_DK37, "车辆故障退出服务地点-DK37车型")
|
||||||
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_CCD_5037, "车辆故障应急处置指导关键点CCD-5037车型"),
|
, new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_GUIDE_T_CCD_5037, "车辆故障应急处置指导关键点CCD-5037车型"),
|
||||||
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_CCD_5037, "车辆故障退出服务地点CCD-5037车型")))
|
new FaultTypeDetail(FaultQueryType.FAULT_EXIT_SERVICE_T_CCD_5037, "车辆故障退出服务地点CCD-5037车型"), new FaultTypeDetail(FaultQueryType.FAULT_EMERGENCY_NCC, "NCC应急查询")))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SecurityRequirement(name = "jwt")
|
||||||
|
@Operation(summary = "保存故障查询")
|
||||||
|
@PostMapping("/ncc")
|
||||||
|
public List<FaultQueryNcc> queryFQForNcc() {
|
||||||
|
return this.faultQueryRepository.fqNcc();
|
||||||
|
}
|
||||||
|
|
||||||
@SecurityRequirement(name = "jwt")
|
@SecurityRequirement(name = "jwt")
|
||||||
@Operation(summary = "保存故障查询")
|
@Operation(summary = "保存故障查询")
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
package club.joylink.xiannccda.dto.fq;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.entity.FaultQuery;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.security.PublicKey;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FaultQueryNcc {
|
||||||
|
|
||||||
|
public FaultQueryNcc() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public FaultQueryNcc(String typeName, List<FaultQuery> fqList) {
|
||||||
|
this.nccTypeName = typeName;
|
||||||
|
Map<String, List<String>> dataMapList = fqList.stream().collect(Collectors.groupingBy(FaultQuery::getFaultDriverShower, Collectors.mapping(FaultQuery::getResultMsg, Collectors.toList())));
|
||||||
|
List<NccData> tl = Lists.newArrayList();
|
||||||
|
dataMapList.forEach((k, v) -> {
|
||||||
|
tl.add(new NccData(k, v));
|
||||||
|
});
|
||||||
|
this.nccData = tl;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String nccTypeName;
|
||||||
|
private List<NccData> nccData;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class NccData {
|
||||||
|
|
||||||
|
public NccData() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public NccData(String action, List<String> datas) {
|
||||||
|
|
||||||
|
this.action = action;
|
||||||
|
this.datas = datas;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String action;
|
||||||
|
private List<String> datas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
|||||||
package club.joylink.xiannccda.repository;
|
package club.joylink.xiannccda.repository;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultQueryNcc;
|
||||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||||
import club.joylink.xiannccda.entity.FaultQuery;
|
import club.joylink.xiannccda.entity.FaultQuery;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@ -17,5 +19,7 @@ public interface IFaultQueryRepository extends IService<FaultQuery> {
|
|||||||
|
|
||||||
void newSaveOrUpdate(FaultQuery fq);
|
void newSaveOrUpdate(FaultQuery fq);
|
||||||
|
|
||||||
|
List<FaultQueryNcc> fqNcc();
|
||||||
|
|
||||||
IPage<FaultQuery> page(FaultQueryReqDTO reqDTO);
|
IPage<FaultQuery> page(FaultQueryReqDTO reqDTO);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package club.joylink.xiannccda.repository.impl;
|
package club.joylink.xiannccda.repository.impl;
|
||||||
|
|
||||||
|
import club.joylink.xiannccda.constants.common.FaultQueryType;
|
||||||
import club.joylink.xiannccda.dto.CommonPageRequest;
|
import club.joylink.xiannccda.dto.CommonPageRequest;
|
||||||
|
import club.joylink.xiannccda.dto.fq.FaultQueryNcc;
|
||||||
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
import club.joylink.xiannccda.dto.fq.FaultQueryReqDTO;
|
||||||
import club.joylink.xiannccda.entity.FaultQuery;
|
import club.joylink.xiannccda.entity.FaultQuery;
|
||||||
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum;
|
||||||
@ -10,9 +12,21 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -27,6 +41,9 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class FaultQueryRepository extends ServiceImpl<FaultQueryMapper, FaultQuery> implements IFaultQueryRepository {
|
public class FaultQueryRepository extends ServiceImpl<FaultQueryMapper, FaultQuery> implements IFaultQueryRepository {
|
||||||
|
|
||||||
|
|
||||||
|
private final static Cache<String, List<FaultQueryNcc>> FQ_NCC_CACHE = CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).build();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void newSaveOrUpdate(FaultQuery fq) {
|
public void newSaveOrUpdate(FaultQuery fq) {
|
||||||
if (fq.getId() == null) {
|
if (fq.getId() == null) {
|
||||||
@ -40,13 +57,50 @@ public class FaultQueryRepository extends ServiceImpl<FaultQueryMapper, FaultQue
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<FaultQuery> page(FaultQueryReqDTO reqDTO) {
|
public List<FaultQueryNcc> fqNcc() {
|
||||||
|
try {
|
||||||
|
return FQ_NCC_CACHE.get(FaultQueryType.FAULT_EMERGENCY_NCC.name(), () -> {
|
||||||
|
List<FaultQueryNcc> nccList = queryNccData();
|
||||||
|
return nccList;
|
||||||
|
});
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<FaultQueryNcc> queryNccData() {
|
||||||
|
FaultQueryReqDTO dto = new FaultQueryReqDTO();
|
||||||
|
dto.setFaultType(FaultQueryType.FAULT_EMERGENCY_NCC.name());
|
||||||
|
Page p = new Page();
|
||||||
|
p.setCurrent(1);
|
||||||
|
p.setSize(999);
|
||||||
|
QueryWrapper<FaultQuery> qw = createQueryWrapper(dto);
|
||||||
|
IPage<FaultQuery> page = this.page(p, qw);
|
||||||
|
// Map<String, List<FaultQuery>> typeMapList = page.getRecords().stream().collect(Collectors.groupingBy(FaultQuery::getFaultNameShower, TreeMap::new, Collectors.toList())).descendingMap();
|
||||||
|
Map<String, List<FaultQuery>> typeMapList = page.getRecords().stream().collect(Collectors.groupingBy(FaultQuery::getFaultNameShower, Collectors.collectingAndThen(Collectors.toList(), list -> {
|
||||||
|
list.sort(Comparator.comparingLong(FaultQuery::getId));
|
||||||
|
return list;
|
||||||
|
})));
|
||||||
|
List<FaultQueryNcc> nccList = Lists.newArrayList();
|
||||||
|
typeMapList.forEach((k, v) -> {
|
||||||
|
nccList.add(new FaultQueryNcc(k, v));
|
||||||
|
});
|
||||||
|
return nccList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private QueryWrapper<FaultQuery> createQueryWrapper(FaultQueryReqDTO reqDTO) {
|
||||||
QueryWrapper<FaultQuery> qw = new QueryWrapper<>();
|
QueryWrapper<FaultQuery> qw = new QueryWrapper<>();
|
||||||
LambdaQueryWrapper<FaultQuery> lam = qw.lambda().eq(Objects.nonNull(reqDTO.getLineId()), FaultQuery::getLineId, reqDTO.getLineId())
|
LambdaQueryWrapper<FaultQuery> lam = qw.lambda().eq(Objects.nonNull(reqDTO.getLineId()), FaultQuery::getLineId, reqDTO.getLineId())
|
||||||
.like(StringUtils.isNotEmpty(reqDTO.getFaultName()), FaultQuery::getFaultNameShower, reqDTO.getFaultName());
|
.like(StringUtils.isNotEmpty(reqDTO.getFaultName()), FaultQuery::getFaultNameShower, reqDTO.getFaultName());
|
||||||
if (StringUtils.isNotEmpty(reqDTO.getFaultType())) {
|
if (StringUtils.isNotEmpty(reqDTO.getFaultType())) {
|
||||||
lam.in(FaultQuery::getFaultType, Splitter.on(StringPool.COMMA).trimResults().splitToList(reqDTO.getFaultType()));
|
lam.in(FaultQuery::getFaultType, Splitter.on(StringPool.COMMA).trimResults().splitToList(reqDTO.getFaultType()));
|
||||||
}
|
}
|
||||||
|
return qw;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IPage<FaultQuery> page(FaultQueryReqDTO reqDTO) {
|
||||||
|
QueryWrapper<FaultQuery> qw = createQueryWrapper(reqDTO);
|
||||||
return this.page(CommonPageRequest.defaultPage(), qw);
|
return this.page(CommonPageRequest.defaultPage(), qw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user