feax:()添加企业表的同时将数据同步进去 企业列表展示

dev.entOperation
crj 2024-10-05 20:41:45 +08:00
parent 46689d02e1
commit 3fb0158cfa
5 changed files with 139 additions and 14 deletions

View File

@ -29,18 +29,40 @@ public class FaultrRule extends BaseEntity {
@Schema(defaultValue = "故障规则ID",type = "Long",description = "故障规则ID")
private Long faultRuleId;
/**
*
* ID
*/
@Schema(defaultValue = "故障规则名称",type = "String",description = "故障规则名称")
private String faultRuleName;
@Schema(defaultValue = "车辆类型ID",type = "Integer",description = "车辆类型ID")
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 = "故障规则参数")
private String faultRuleParameter;
private String ruleParameters;
/**
*
*
*/
@Schema(defaultValue = "故障规则描述",type = "String",description = "故障规则描述")
private String faultRuleDescription;
@Schema(defaultValue = "车辆类型名称",type = "String",description = "车辆类型名称")
private String carTypeName;
/**
*
*/
@Schema(defaultValue = "故障名称",type = "String",description = "故障名称")
private String faultName;
/**
* VIN
*/
@Schema(defaultValue = "车辆VIN",type = "String",description = "车辆VIN")
private String carVin;
}

View File

@ -4,8 +4,10 @@ package com.muyu.enterprise.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.enterprise.domain.FaultrRule;
import com.muyu.enterprise.service.FaultrRuleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
@ -73,5 +75,17 @@ public class FaultrRuleController {
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);
}
}

View File

@ -14,4 +14,6 @@ public interface FaultrRuleService extends IService<FaultrRule> {
List<FaultrRule> faultRuleList(FaultrRule faultrRule);
FaultrRule byidRuleId(Long faultRuleId);
List<FaultrRule> checkfault(FaultrRule faultrRule);
}

View File

@ -3,12 +3,15 @@ package com.muyu.enterprise.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils;
import com.muyu.enterprise.domain.CarType;
import com.muyu.enterprise.domain.FaultrRule;
import com.muyu.enterprise.mapper.FaultrRuleMapper;
import com.muyu.enterprise.service.FaultrRuleService;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
*
@ -22,11 +25,8 @@ public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultrR
@Override
public List<FaultrRule> faultRuleList(FaultrRule faultrRule) {
LambdaQueryWrapper<FaultrRule> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleName())) {
queryWrapper.eq(FaultrRule::getFaultRuleName,faultrRule.getFaultRuleName());
}
if (StringUtils.isNotEmpty(faultrRule.getFaultRuleParameter())) {
queryWrapper.eq(FaultrRule::getFaultRuleParameter,faultrRule.getFaultRuleParameter());
if (StringUtils.isNotEmpty(faultrRule.getRuleParameters())) {
queryWrapper.eq(FaultrRule::getRuleParameters,faultrRule.getRuleParameters());
}
return this.list(queryWrapper);
}
@ -38,4 +38,93 @@ public class FaultrRuleServiceImpl extends ServiceImpl<FaultrRuleMapper, FaultrR
queryWrapper.eq(FaultrRule::getFaultRuleId, faultRuleId);
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("&gt;") ){
// if (bigDecimalValue.compareTo(faultconditionParameter)>0){
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"超出规定范围"));
// }
// }else if(faultconditionIdentification.equals("<") || faultconditionIdentification.equals("&lt;")){
// if (bigDecimalValue.compareTo(faultconditionParameter)<0){
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"过低"));
// }
// }else if(faultconditionIdentification.equals(">=") || faultconditionIdentification.equals("&gt;=")){
// if (bigDecimalValue.compareTo(faultconditionParameter)>=0){
// FaultrRules.add(new FaultrRule(FaultrRule.getVin(),declaredField.getName()+"超出规定范围")) ;
// }
// }else if(faultconditionIdentification.equals("<=") || faultconditionIdentification.equals("&lt;=")){
// 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;
}
}

View File

@ -1,2 +0,0 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}