初始化
parent
3d8b02a00e
commit
97b20e395a
|
@ -3,6 +3,7 @@ package com.muyu.cloud.faultmanage.controller;
|
|||
import com.muyu.cloud.faultmanage.domain.CarFaultRule;
|
||||
import com.muyu.cloud.faultmanage.domain.FaultCondition;
|
||||
import com.muyu.cloud.faultmanage.domain.FaultRule;
|
||||
import com.muyu.cloud.faultmanage.domain.Vehicle;
|
||||
import com.muyu.cloud.faultmanage.domain.req.FaultConditionListReq;
|
||||
import com.muyu.cloud.faultmanage.service.FaultRuleService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
@ -14,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.faultmanage.controller
|
||||
|
@ -33,18 +36,6 @@ public class FaultRuleController {
|
|||
private FaultRuleService faultRuleService;
|
||||
|
||||
|
||||
// /**
|
||||
// * 车辆故障检测
|
||||
// * @return
|
||||
// */
|
||||
// @PostMapping("/check-faults")
|
||||
// @Operation(summary = "检查故障",description = "进行故障检查")
|
||||
// public Result checkfaults(@Validated FaultRule faultRule){
|
||||
// String checkfaults = faultRuleService.checkfaults(faultRule);
|
||||
// return Result.success(checkfaults);
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 故障参数匹配检查
|
||||
* @param carFaultRule
|
||||
|
@ -53,7 +44,7 @@ public class FaultRuleController {
|
|||
@PostMapping("/cheakfaults")
|
||||
@Operation(summary = "故障参数匹配检查",description = "获取报文数据与故障参数进行比较")
|
||||
public Result cheakfaults(@Validated @RequestBody CarFaultRule carFaultRule){
|
||||
faultRuleService.checkfault(carFaultRule);
|
||||
return null;
|
||||
List<Vehicle> checkfault = faultRuleService.checkfault(carFaultRule);
|
||||
return Result.success(checkfault);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.muyu.cloud.faultmanage.domain.CarFaultRule;
|
|||
import com.muyu.cloud.faultmanage.domain.FaultRule;
|
||||
import com.muyu.cloud.faultmanage.domain.Vehicle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.faultmanage.service.impl
|
||||
|
@ -14,17 +16,11 @@ import com.muyu.cloud.faultmanage.domain.Vehicle;
|
|||
*/
|
||||
public interface FaultRuleService extends IService<CarFaultRule> {
|
||||
|
||||
// /**
|
||||
// * 车辆故障检测
|
||||
// * @return
|
||||
// */
|
||||
// String checkfaults(FaultRule faultRule);
|
||||
|
||||
|
||||
/**
|
||||
* 故障参数匹配检查
|
||||
* @param carFaultRule
|
||||
* @return
|
||||
*/
|
||||
Vehicle checkfault(CarFaultRule carFaultRule);
|
||||
List<Vehicle> checkfault(CarFaultRule carFaultRule);
|
||||
}
|
||||
|
|
|
@ -1,22 +1,14 @@
|
|||
package com.muyu.cloud.faultmanage.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.faultmanage.domain.*;
|
||||
import com.muyu.cloud.faultmanage.domain.req.FaultConditionListReq;
|
||||
import com.muyu.cloud.faultmanage.domain.resp.FaultCodeListResp;
|
||||
import com.muyu.cloud.faultmanage.domain.resp.FaultCodeTotalListResp;
|
||||
import com.muyu.cloud.faultmanage.domain.resp.FaultConditionTotalListResp;
|
||||
import com.muyu.cloud.faultmanage.domain.vo.FaultCodeVO;
|
||||
import com.muyu.cloud.faultmanage.mapper.FaultRuleMapper;
|
||||
import com.muyu.cloud.faultmanage.service.FaultRuleService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -33,50 +25,15 @@ public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultR
|
|||
@Autowired
|
||||
private FaultRuleMapper faultRuleMapper;
|
||||
|
||||
// /**
|
||||
// * 车辆故障检测
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public String checkfaults(FaultRule faultRule) {
|
||||
// //获取触发条件
|
||||
// LambdaQueryWrapper<FaultRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// if (Long.valueOf(faultRule.getFaultcodeId())!=null && faultRule.getFaultcodeId()!=0){
|
||||
// queryWrapper.eq(FaultRule::getFaultcodeId, faultRule.getFaultcodeId());
|
||||
// }
|
||||
// List<FaultRule> faultRuleList = this.list(queryWrapper);
|
||||
// for (FaultRule rule : faultRuleList) {
|
||||
// //单个值比较
|
||||
// if (faultRule.getSingleThreshold()!=null && faultRule.getMaxThreshold()==null && faultRule.getMinThreshold()==null){
|
||||
// //大于阈值
|
||||
// if (faultRule.getConditionContent().contains(">") || faultRule.getConditionContent().contains("大于")){
|
||||
// if (faultRule.getThreshold().compareTo(rule.getSingleThreshold())>0){
|
||||
// return "数据超过阈值,出现异常";
|
||||
// }
|
||||
// }
|
||||
// //小于阈值
|
||||
// if (faultRule.getConditionContent().contains("<") || faultRule.getConditionContent().contains("小于")){
|
||||
// if (faultRule.getThreshold().compareTo(rule.getSingleThreshold())<0){
|
||||
// return "数据过低,出现异常";
|
||||
// }
|
||||
// }
|
||||
// }else { //区间值比较
|
||||
// if (faultRule.getThreshold().compareTo(rule.getMinThreshold())<0 || faultRule.getThreshold().compareTo(rule.getMaxThreshold())>0){
|
||||
// return "数据不在可控范围内,出现异常";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return "判断出现异常";
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 故障参数匹配检查
|
||||
* @param carFaultRule
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Vehicle checkfault(CarFaultRule carFaultRule) {
|
||||
public List<Vehicle> checkfault(CarFaultRule carFaultRule) {
|
||||
List<Vehicle> vehicles = new ArrayList<>();
|
||||
|
||||
//根据车辆VIN判断它属于什么类型的车辆
|
||||
CarInformation carInformation = faultRuleMapper.selectTypeByVIN(carFaultRule.getVin());
|
||||
Integer carInformationType = carInformation.getCarInformationType();
|
||||
|
@ -94,8 +51,32 @@ public class FaultRuleServiceImpl extends ServiceImpl<FaultRuleMapper, CarFaultR
|
|||
if (value != null && (!declaredField.getType().isPrimitive() && declaredField.get(carFaultRule)!=null)) {
|
||||
// 遍历faultConditionList,查找匹配的FaultCondition
|
||||
for (FaultCondition faultCondition : faultConditionList) {
|
||||
|
||||
|
||||
if (faultCondition.getMessageTypeCode().equals(declaredField)){
|
||||
String faultconditionIdentification = faultCondition.getFaultconditionIdentification();
|
||||
BigDecimal faultconditionParameter = faultCondition.getFaultconditionParameter();
|
||||
//判断条件选择
|
||||
if (faultconditionIdentification.equals(">") || faultconditionIdentification.equals(">") ){
|
||||
if (BigDecimal.valueOf((Long) value).compareTo(faultconditionParameter)>0){
|
||||
vehicles.add(new Vehicle(carFaultRule.getVin(),declaredField+"超出规定范围"));
|
||||
}
|
||||
}else if(faultconditionIdentification.equals("<") || faultconditionIdentification.equals("<")){
|
||||
if (BigDecimal.valueOf((Long) value).compareTo(faultconditionParameter)<0){
|
||||
vehicles.add(new Vehicle(carFaultRule.getVin(),declaredField+"过低"));
|
||||
}
|
||||
}else if(faultconditionIdentification.equals(">=") || faultconditionIdentification.equals(">=")){
|
||||
if (BigDecimal.valueOf((Long) value).compareTo(faultconditionParameter)>0){
|
||||
vehicles.add(new Vehicle(carFaultRule.getVin(),declaredField+"超出规定范围")) ;
|
||||
}
|
||||
}else if(faultconditionIdentification.equals("<=") || faultconditionIdentification.equals("<=")){
|
||||
if (BigDecimal.valueOf((Long) value).compareTo(faultconditionParameter)<0){
|
||||
vehicles.add(new Vehicle(carFaultRule.getVin(),declaredField+"过低"));
|
||||
}
|
||||
}else {
|
||||
if (BigDecimal.valueOf((Long) value).compareTo(faultconditionParameter)==0){
|
||||
vehicles.add(new Vehicle(carFaultRule.getVin(),declaredField+"已达到故障点"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue