Compare commits
2 Commits
94475aab0e
...
4cbc8e470e
Author | SHA1 | Date |
---|---|---|
|
4cbc8e470e | |
|
b8f3a4443f |
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.many.domain.req;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 统计
|
||||
*
|
||||
* @ClassName DefectInfoAndFaultInfoList
|
||||
* @Author AnNan.Wang
|
||||
* @Date 2024/6/21 20:32
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DefectInfoAndFaultInfoList {
|
||||
private String defectCode;
|
||||
private Integer numCode;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.many.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 统计条件
|
||||
*
|
||||
* @ClassName FaultInfoVo
|
||||
* @Author AnNan.Wang
|
||||
* @Date 2024/6/21 20:05
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FaultInfoVo {
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
private Date startTime;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private Date endTime;
|
||||
}
|
|
@ -6,10 +6,13 @@ import javax.servlet.http.HttpServletResponse;
|
|||
import com.muyu.authentication.service.FaultInfoService;
|
||||
import com.muyu.clw.common.many.datasource.holder.DynamicDataSourceHolder;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.many.domain.DefectInfo;
|
||||
import com.muyu.many.domain.FaultInfo;
|
||||
import com.muyu.many.domain.req.DefectInfoAndFaultInfoList;
|
||||
import com.muyu.many.domain.req.FaultInfoEditReq;
|
||||
import com.muyu.many.domain.req.FaultInfoQueryReq;
|
||||
import com.muyu.many.domain.req.FaultInfoSaveReq;
|
||||
import com.muyu.many.domain.vo.FaultInfoVo;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -113,4 +116,12 @@ public class FaultInfoController extends BaseController {
|
|||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||
return toAjax(b);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/statistics")
|
||||
public Result<List<DefectInfoAndFaultInfoList>> getDefectInfoAndFaultInfoList(@RequestBody FaultInfoVo faultInfoVo){
|
||||
return Result.success(
|
||||
faultInfoService.getDefectInfoAndFaultInfoList(faultInfoVo)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package com.muyu.authentication.rabbitmq.vo;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.muyu.authentication.mapper.FaultInfoMapper;
|
||||
import com.muyu.clw.common.many.datasource.holder.DynamicDataSourceHolder;
|
||||
import com.muyu.many.domain.Enterprise;
|
||||
import com.muyu.many.domain.FaultInfo;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接收故障信息
|
||||
*
|
||||
|
@ -20,25 +28,56 @@ import org.springframework.stereotype.Component;
|
|||
public class BreakdownAbnormalMq {
|
||||
|
||||
|
||||
@Autowired
|
||||
private FaultInfoMapper faultInfoMapper;
|
||||
@Autowired
|
||||
private StringRedisTemplate redisTemplate;
|
||||
|
||||
@RabbitListener(queues = "discover_time")
|
||||
public void discoverTime(String message){
|
||||
log.info("开始消费");
|
||||
//转换
|
||||
FaultInfo faultInfo = JSON.parseObject(message, FaultInfo.class);
|
||||
|
||||
// redis
|
||||
// VIN
|
||||
// ent_????
|
||||
|
||||
log.info("faultInfo:{}", faultInfo);
|
||||
String key=faultInfo.getVin()+"123";
|
||||
String ent = redisTemplate.opsForValue().get(key);
|
||||
DynamicDataSourceHolder.setDynamicDataSourceKey(ent);
|
||||
faultInfoMapper.insert(faultInfo);
|
||||
log.info("消费结束");
|
||||
DynamicDataSourceHolder.removeDynamicDataSourceKey();
|
||||
}
|
||||
|
||||
|
||||
@RabbitListener(queues = "resolve_time")
|
||||
public void resolveTime(String message){
|
||||
log.info("开始消费");
|
||||
FaultInfo parse = JSON.parseObject(message, FaultInfo.class);
|
||||
FaultInfo faultInfo = JSON.parseObject(message, FaultInfo.class);
|
||||
log.info("faultInfo:{}", faultInfo);
|
||||
String key=faultInfo.getVin()+"123";
|
||||
String ent = redisTemplate.opsForValue().get(key);
|
||||
DynamicDataSourceHolder.setDynamicDataSourceKey(ent);
|
||||
|
||||
//获取最新一天数据
|
||||
List<FaultInfo> faultInfos = faultInfoMapper.selectList(
|
||||
new QueryWrapper<FaultInfo>().orderByDesc("id").last("limit 1")
|
||||
);
|
||||
//判断非空
|
||||
if (!faultInfos.isEmpty()) {
|
||||
//获取第一条数据
|
||||
FaultInfo latestFaultInfo = faultInfos.get(0);
|
||||
// 这里可以对 latestFaultInfo 进行进一步操作或者返回
|
||||
log.info("Latest FaultInfo: {}", latestFaultInfo);
|
||||
|
||||
//修改数据
|
||||
faultInfoMapper.updateById(
|
||||
FaultInfo.builder()
|
||||
.id(latestFaultInfo.getId())
|
||||
.endTime(faultInfo.getEndTime())
|
||||
.build()
|
||||
);
|
||||
log.info("消费结束");
|
||||
}
|
||||
log.info("消费结束");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package com.muyu.authentication.service;
|
|||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.many.domain.FaultInfo;
|
||||
import com.muyu.many.domain.req.DefectInfoAndFaultInfoList;
|
||||
import com.muyu.many.domain.vo.FaultInfoVo;
|
||||
|
||||
/**
|
||||
* 故障记录Service接口
|
||||
|
@ -19,4 +21,5 @@ public interface FaultInfoService extends IService<FaultInfo> {
|
|||
*/
|
||||
public List<FaultInfo> list(FaultInfo faultInfo);
|
||||
|
||||
List<DefectInfoAndFaultInfoList> getDefectInfoAndFaultInfoList(FaultInfoVo faultInfoVo);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.authentication.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -7,6 +8,8 @@ import com.muyu.authentication.mapper.FaultInfoMapper;
|
|||
import com.muyu.authentication.service.FaultInfoService;
|
||||
import com.muyu.common.core.utils.ObjUtils;
|
||||
import com.muyu.many.domain.FaultInfo;
|
||||
import com.muyu.many.domain.req.DefectInfoAndFaultInfoList;
|
||||
import com.muyu.many.domain.vo.FaultInfoVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
@ -52,11 +55,26 @@ public class FaultInfoServiceImpl extends ServiceImpl<FaultInfoMapper, FaultInfo
|
|||
if (ObjUtils.notNull(faultInfo.getEndTime())){
|
||||
queryWrapper.eq(FaultInfo::getEndTime, faultInfo.getEndTime());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DefectInfoAndFaultInfoList> getDefectInfoAndFaultInfoList(FaultInfoVo faultInfoVo) {
|
||||
//条件
|
||||
LambdaQueryWrapper<FaultInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (ObjUtils.notNull(faultInfoVo.getEndTime())){
|
||||
queryWrapper.le(FaultInfo::getEndTime,faultInfoVo.getEndTime());
|
||||
}
|
||||
|
||||
if (ObjUtils.notNull(faultInfoVo.getStartTime())){
|
||||
queryWrapper.ge(FaultInfo::getStartTime,faultInfoVo.getStartTime());
|
||||
}
|
||||
List<FaultInfo> list = list(queryWrapper);
|
||||
List<DefectInfoAndFaultInfoList> arrayList = new ArrayList<>();
|
||||
for (FaultInfo faultInfo : list) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
com.muyu.authentication.rabbitmq.MessageConsumer
|
||||
com.muyu.authentication.rabbitmq.vo.BreakdownAbnormalMq
|
||||
|
|
Loading…
Reference in New Issue