find()故障规则创建时查询列表添加新的缓存

dev.yang
Yueng 2024-10-08 19:05:07 +08:00
parent 50b462ae60
commit 36c1f661b6
7 changed files with 57 additions and 8 deletions

View File

@ -43,4 +43,9 @@ public class FaultCodeCache {
*/
private List<FaultCode> faultCode;
/**
*
*/
private FaultLabel faultLabels;
}

View File

@ -59,7 +59,10 @@ public class FaultConditionController {
if (faultConditionList.size()>0){
return Result.error("此车辆类型已存在所对应的故障规则,无需重新制定,可在原规则上进行修改");
}
faultConditionService.saveFaultCondition(FaultCondition.faultConditionadd(faultConditionAddReq));
boolean save = faultConditionService.save(FaultCondition.faultConditionadd(faultConditionAddReq));
if (save){
faultConditionService.RunCarCondition();
}
return Result.success(null,"规则制定成功");
}

View File

@ -33,11 +33,14 @@ public interface FaultConditionService extends IService<FaultCondition> {
*/
List<FaultCondition> selectBytypeAndlabel(FaultConditionAddReq faultConditionAddReq);
void saveFaultCondition(FaultCondition faultCondition);
/**
*
* @return
*/
List<FaultCondition> saveFaultConditionList();
/**
*
*/
void RunCarCondition();
}

View File

@ -43,4 +43,9 @@ public interface FaultLabelService extends IService<FaultLabel> {
*/
Integer delfaultlabel(Integer messageTypeId);
/**
*
* @param messageTypeId
*/
FaultLabel faultLabelList(long messageTypeId);
}

View File

@ -13,6 +13,8 @@ import com.muyu.domain.resp.FaultLogListResp;
import com.muyu.server.mapper.FaultConditionMapper;
import com.muyu.server.service.FaultConditionService;
import com.muyu.server.util.ObtainRootLogin;
import com.muyu.server.util.RunCarCondition;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -29,12 +31,14 @@ import java.util.List;
*/
@Service
@AllArgsConstructor
public class FaultConditionServiceImpl
extends ServiceImpl<FaultConditionMapper, FaultCondition>
implements FaultConditionService {
@Autowired
private FaultConditionMapper faultConditionMapper;
private final RunCarCondition runCarCondition;
@ -85,16 +89,19 @@ public class FaultConditionServiceImpl
return list;
}
@Override
public void saveFaultCondition(FaultCondition faultCondition) {
}
@Override
public List<FaultCondition> saveFaultConditionList() {
return this.list().stream().map(FaultCondition::faultConditionBuilder).toList();
}
/**
*
*/
@Override
public void RunCarCondition() {
runCarCondition.text();
}
// private void faultCache(long messageTypeId, Long faulttypeId,String faultcodeNumber) {
// FaultCodeCache faultCodeCache = new FaultCodeCache();
//

View File

@ -78,4 +78,24 @@ public class FaultLabelServiceImpl extends ServiceImpl<FaultLabelMapper, FaultLa
return faultLabelMapper.delete(queryWrapper);
}
/**
*
* @param messageTypeId
*/
@Override
public FaultLabel faultLabelList(long messageTypeId) {
List<FaultLabel> list = this.list(new LambdaQueryWrapper<FaultLabel>().eq(StringUtils.isNotNull(messageTypeId),
FaultLabel::getMessageTypeId, messageTypeId)).stream().toList();
FaultLabel faultLabel1 = new FaultLabel();
if (!list.isEmpty()){
list.forEach(faultLabel -> {
faultLabel1.setMessageTypeId(faultLabel.getMessageTypeId());
faultLabel1.setMessageTypeName(faultLabel.getMessageTypeName());
faultLabel1.setMessageTypeCode(faultLabel.getMessageTypeCode());
faultLabel1.setMessageTypeBelongs(faultLabel.getMessageTypeBelongs());
});
}
return faultLabel1;
}
}

View File

@ -30,9 +30,14 @@ public class RunCarCondition implements ApplicationRunner {
private final CarFenceService carFenceService;
private final WarnStrategyService warnStrategyService;
private final FaultCodeService faultCodeService;
private final FaultLabelService faultLabelService;
@Override
public void run(ApplicationArguments args) throws Exception {
text();
}
public void text() {
List<FaultCondition> list = faultConditionService.saveFaultConditionList();
list.forEach(faultCondition -> {
List<CarInformation> carInformationList = carInformationService.selectCarInformation(faultCondition.getCarTypeId());
@ -47,6 +52,7 @@ public class RunCarCondition implements ApplicationRunner {
}
if (StringUtils.isNotNull(faultCondition.getMessageTypeId())) {
faultCodeCache.setFaultCode(faultCodeService.faultCodeList(faultCondition.getMessageTypeId()));
faultCodeCache.setFaultLabels(faultLabelService.faultLabelList(faultCondition.getMessageTypeId()));
}
ArrayList<CarInformation> carInformations = new ArrayList<>();
carInformations.add(carInformation);