feax:()添加企业表的同时将数据同步进去 企业列表展示
parent
46689d02e1
commit
3fb0158cfa
|
@ -29,18 +29,40 @@ public class FaultrRule extends BaseEntity {
|
||||||
@Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID")
|
@Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID")
|
||||||
private Long faultRuleId;
|
private Long faultRuleId;
|
||||||
/**
|
/**
|
||||||
* 故障规则名称
|
* 车辆类型ID
|
||||||
*/
|
*/
|
||||||
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称")
|
@Schema(defaultValue = "车辆类型ID",type = "Integer",description = "车辆类型ID")
|
||||||
private String faultRuleName;
|
private Integer carTypeId;
|
||||||
|
/**
|
||||||
|
* 故障名称ID
|
||||||
|
*/
|
||||||
|
@Schema(defaultValue = "故障名称ID",type = "Integer",description = "故障名称ID")
|
||||||
|
private Integer faultId;
|
||||||
|
/**
|
||||||
|
* 故障条件
|
||||||
|
*/
|
||||||
|
@Schema(defaultValue = "故障条件",type = "String",description = "故障条件")
|
||||||
|
private String faultConditions;
|
||||||
/**
|
/**
|
||||||
* 故障规则参数
|
* 故障规则参数
|
||||||
*/
|
*/
|
||||||
@Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数")
|
@Schema(defaultValue = "故障规则参数",type = "String",description = "故障规则参数")
|
||||||
private String faultRuleParameter;
|
private String ruleParameters;
|
||||||
/**
|
/**
|
||||||
* 故障规则描述
|
* 车辆类型名称
|
||||||
*/
|
*/
|
||||||
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述")
|
@Schema(defaultValue = "车辆类型名称",type = "String",description = "车辆类型名称")
|
||||||
private String faultRuleDescription;
|
private String carTypeName;
|
||||||
|
/**
|
||||||
|
* 故障名称
|
||||||
|
*/
|
||||||
|
@Schema(defaultValue = "故障名称",type = "String",description = "故障名称")
|
||||||
|
private String faultName;
|
||||||
|
/**
|
||||||
|
* 车辆VIN
|
||||||
|
*/
|
||||||
|
@Schema(defaultValue = "车辆VIN",type = "String",description = "车辆VIN")
|
||||||
|
private String carVin;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,10 @@ package com.muyu.enterprise.controller;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.enterprise.domain.FaultrRule;
|
import com.muyu.enterprise.domain.FaultrRule;
|
||||||
import com.muyu.enterprise.service.FaultrRuleService;
|
import com.muyu.enterprise.service.FaultrRuleService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -73,5 +75,17 @@ public class FaultrRuleController {
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障参数匹配检查
|
||||||
|
* @param faultrRule
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/cheakfaults")
|
||||||
|
@Operation(summary = "故障参数匹配检查",description = "获取报文数据与故障参数进行比较")
|
||||||
|
public Result cheakfaults(@Validated @RequestBody FaultrRule faultrRule){
|
||||||
|
List<FaultrRule> checkfault = faultrRuleService.checkfault(faultrRule);
|
||||||
|
return Result.success(checkfault);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,6 @@ public interface FaultrRuleService extends IService<FaultrRule> {
|
||||||
List<FaultrRule> faultRuleList(FaultrRule faultrRule);
|
List<FaultrRule> faultRuleList(FaultrRule faultrRule);
|
||||||
|
|
||||||
FaultrRule byidRuleId(Long faultRuleId);
|
FaultrRule byidRuleId(Long faultRuleId);
|
||||||
|
|
||||||
|
List<FaultrRule> checkfault(FaultrRule faultrRule);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,15 @@ package com.muyu.enterprise.service.impl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.enterprise.domain.CarType;
|
||||||
import com.muyu.enterprise.domain.FaultrRule;
|
import com.muyu.enterprise.domain.FaultrRule;
|
||||||
import com.muyu.enterprise.mapper.FaultrRuleMapper;
|
import com.muyu.enterprise.mapper.FaultrRuleMapper;
|
||||||
import com.muyu.enterprise.service.FaultrRuleService;
|
import com.muyu.enterprise.service.FaultrRuleService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
/**
|
/**
|
||||||
* 故障规则业务实现层
|
* 故障规则业务实现层
|
||||||
|
@ -22,11 +25,8 @@ public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultrR
|
||||||
@Override
|
@Override
|
||||||
public List<FaultrRule> faultRuleList(FaultrRule faultrRule) {
|
public List<FaultrRule> faultRuleList(FaultrRule faultrRule) {
|
||||||
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleName())) {
|
if (StringUtils.isNotEmpty(faultrRule.getRuleParameters())) {
|
||||||
queryWrapper.eq(FaultrRule::getFaultRuleName,faultrRule.getFaultRuleName());
|
queryWrapper.eq(FaultrRule::getRuleParameters,faultrRule.getRuleParameters());
|
||||||
}
|
|
||||||
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleParameter())) {
|
|
||||||
queryWrapper.eq(FaultrRule::getFaultRuleParameter,faultrRule.getFaultRuleParameter());
|
|
||||||
}
|
}
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
@ -38,4 +38,93 @@ public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultrR
|
||||||
queryWrapper.eq(FaultrRule::getFaultRuleId, faultRuleId);
|
queryWrapper.eq(FaultrRule::getFaultRuleId, faultRuleId);
|
||||||
return this.getOne(queryWrapper);
|
return this.getOne(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障参数匹配检查
|
||||||
|
* @param faultrRule
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<FaultrRule> checkfault(FaultrRule faultrRule) {
|
||||||
|
// List<FaultrRule> FaultrRules = new ArrayList<>();
|
||||||
|
// //根据车辆VIN判断它属于什么类型的车辆
|
||||||
|
// List<CarInformation> carInformationList = carInformationMapper.selectList(
|
||||||
|
// new LambdaQueryWrapper<CarInformation>()
|
||||||
|
// .eq(CarInformation::getCarInformationVIN, faultrRule.getVin()));
|
||||||
|
// //根据车辆类型,查询表获取对应的类型的故障规则
|
||||||
|
// Integer carInformationType = null;
|
||||||
|
// for (CarInformation carInformation : carInformationList) {
|
||||||
|
// carInformationType= carInformation.getCarInformationType();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// List<FaultConditionResp> faultConditionResps = faultConditionMapper.selectJoinList(FaultConditionResp.class, new MPJLambdaWrapper<FaultCondition>()
|
||||||
|
// .selectAll(FaultCondition.class)
|
||||||
|
// .select(CarType::getCarTypeName)
|
||||||
|
// .select(FaultLabel::getMessageTypeName)
|
||||||
|
// .select(FaultLabel::getMessageTypeCode)
|
||||||
|
// .leftJoin(CarType.class, CarType::getCarTypeId, FaultCondition::getCarTypeId)
|
||||||
|
// .leftJoin(FaultLabel.class, FaultLabel::getMessageTypeId, FaultCondition::getMessageTypeId)
|
||||||
|
// .eq(FaultCondition::getCarTypeId,carInformationType));
|
||||||
|
// //获取当前类的所有字段,不包括继承的
|
||||||
|
// Class<? extends FaultrRule> FaultrRuleClass = FaultrRule.getClass();
|
||||||
|
// Field[] declaredFields = FaultrRuleClass.getDeclaredFields();
|
||||||
|
// for (Field declaredField : declaredFields) {
|
||||||
|
// //确保可以访问私有字段
|
||||||
|
// declaredField.setAccessible(true);
|
||||||
|
// try {
|
||||||
|
// //获取字段的值
|
||||||
|
// Object value = declaredField.get(FaultrRule);
|
||||||
|
// if (value != null && declaredField.get(FaultrRule)!=null) {
|
||||||
|
// // 遍历faultConditionList,查找匹配的FaultCondition
|
||||||
|
// for (FaultConditionResp faultCondition : faultConditionResps) {
|
||||||
|
// if (faultCondition.getMessageTypeCode().equals(declaredField.getName())){
|
||||||
|
// String faultconditionIdentification = faultCondition.getFaultconditionIdentification();
|
||||||
|
// BigDecimal faultconditionParameter = faultCondition.getFaultconditionParameter();
|
||||||
|
// // 尝试将值转换为BigDecimal
|
||||||
|
// BigDecimal bigDecimalValue = null;
|
||||||
|
// if (value instanceof Number) {
|
||||||
|
// Number numberValue = (Number) value;
|
||||||
|
// if (numberValue instanceof Long || numberValue instanceof Integer) {
|
||||||
|
// bigDecimalValue = BigDecimal.valueOf(numberValue.longValue());
|
||||||
|
// } else if (numberValue instanceof Double || numberValue instanceof Float) {
|
||||||
|
// // 注意:Double转BigDecimal可能会引入精度问题,因为Double本身可能不精确
|
||||||
|
// // 如果需要精确控制,可以考虑从源头使用BigDecimal
|
||||||
|
// bigDecimalValue = BigDecimal.valueOf(numberValue.doubleValue());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //判断条件选择
|
||||||
|
// if (faultconditionIdentification.equals(">") || faultconditionIdentification.equals(">") ){
|
||||||
|
// if (bigDecimalValue.compareTo(faultconditionParameter)>0){
|
||||||
|
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"超出规定范围"));
|
||||||
|
// }
|
||||||
|
// }else if(faultconditionIdentification.equals("<") || faultconditionIdentification.equals("<")){
|
||||||
|
// if (bigDecimalValue.compareTo(faultconditionParameter)<0){
|
||||||
|
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"过低"));
|
||||||
|
// }
|
||||||
|
// }else if(faultconditionIdentification.equals(">=") || faultconditionIdentification.equals(">=")){
|
||||||
|
// if (bigDecimalValue.compareTo(faultconditionParameter)>=0){
|
||||||
|
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"超出规定范围")) ;
|
||||||
|
// }
|
||||||
|
// }else if(faultconditionIdentification.equals("<=") || faultconditionIdentification.equals("<=")){
|
||||||
|
// if (bigDecimalValue.compareTo(faultconditionParameter)<=0){
|
||||||
|
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"过低"));
|
||||||
|
// }
|
||||||
|
// }else {
|
||||||
|
// if (bigDecimalValue.compareTo(faultconditionParameter)==0){
|
||||||
|
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"已达到故障点"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// } catch (IllegalAccessException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
Spring Boot Version: ${spring-boot.version}
|
|
||||||
Spring Application Name: ${spring.application.name}
|
|
Loading…
Reference in New Issue