fast()预警报警
parent
ad1accf68e
commit
32e2ff6ee6
|
@ -1,5 +1,8 @@
|
||||||
package com.business.common.Select;
|
package com.business.common.Select;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -7,20 +10,18 @@ import lombok.NoArgsConstructor;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
public class BreakdownSel{
|
||||||
@NoArgsConstructor
|
|
||||||
public class BreakdownSel {
|
|
||||||
/**
|
|
||||||
* 故障类型
|
|
||||||
*/
|
|
||||||
private String faultCode;
|
|
||||||
/**
|
/**
|
||||||
* 多
|
* 多
|
||||||
*/
|
*/
|
||||||
|
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
// @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
|
@JsonProperty("faultStartTime")
|
||||||
private Date faultStartTime;
|
private Date faultStartTime;
|
||||||
/**
|
/**
|
||||||
* 少
|
* 少
|
||||||
*/
|
*/
|
||||||
|
@JsonProperty("faultEndTime")
|
||||||
private Date faultEndTime;
|
private Date faultEndTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package com.business.common.domain;
|
package com.business.common.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -8,36 +11,36 @@ import lombok.NoArgsConstructor;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Builder
|
public class Breakdown extends BaseEntity
|
||||||
@AllArgsConstructor
|
{
|
||||||
@NoArgsConstructor
|
private static final long serialVersionUID = 1L;
|
||||||
public class Breakdown {
|
|
||||||
/**
|
/** $column.columnComment */
|
||||||
* 主键
|
|
||||||
*/
|
|
||||||
private Long id;
|
private Long id;
|
||||||
/**
|
|
||||||
* 故障码
|
/** 故障码 */
|
||||||
*/
|
@Excel(name = "故障码")
|
||||||
private String faultCode;
|
private String faultCode;
|
||||||
/**
|
|
||||||
* 车辆标识
|
/** 车辆标识 */
|
||||||
*/
|
@Excel(name = "车辆标识")
|
||||||
private String vin;
|
private String vin;
|
||||||
/**
|
|
||||||
* 故障状态
|
/** 故障状态 */
|
||||||
*/
|
@Excel(name = "故障状态")
|
||||||
private Integer faultState;
|
private Integer faultState;
|
||||||
/**
|
|
||||||
* 故障产生时间
|
/** 故障产生时间 */
|
||||||
*/
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "故障产生时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date faultStartTime;
|
private Date faultStartTime;
|
||||||
/**
|
|
||||||
* 故障解决时间
|
/** 故障解决时间 */
|
||||||
*/
|
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||||
|
@Excel(name = "故障解决时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||||
private Date faultEndTime;
|
private Date faultEndTime;
|
||||||
/**
|
|
||||||
* 故障级别
|
/** 故障级别 */
|
||||||
*/
|
@Excel(name = "故障级别")
|
||||||
private Integer faultLevel;
|
private Integer faultLevel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,13 @@ import com.business.common.psvm.FaultInfo;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
|
import com.muyu.goods.incident.mq.Producer;
|
||||||
import com.muyu.goods.service.IBreakdownService;
|
import com.muyu.goods.service.IBreakdownService;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@ -22,37 +24,48 @@ import java.util.Map;
|
||||||
public class BreakdownController extends BaseController {
|
public class BreakdownController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IBreakdownService service;
|
private IBreakdownService service;
|
||||||
|
@Autowired
|
||||||
|
private Producer producer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页
|
* 分页
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* 查询故障列表
|
||||||
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<Breakdown>> list(BreakdownSel breakdownSel)
|
public Result<TableDataInfo<Breakdown>> list( )
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<Breakdown> list = service.selectBreakdownList(breakdownSel);
|
List<Breakdown> list = service.selectBreakdownList();
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/lists")
|
||||||
|
public Result<List<Breakdown>> lists() {
|
||||||
|
List<Breakdown> list = service.lists();
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加新的故障记录
|
* 添加新的故障记录
|
||||||
* @param faultInfo
|
* @param breakdown
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("indexBreakDown")
|
@PostMapping("indexBreakDown")
|
||||||
public Result indexBreakDown(@RequestBody FaultInfo faultInfo) {
|
public Result indexBreakDown(@RequestBody Breakdown breakdown) {
|
||||||
return success(service.indexBreakDown(faultInfo));
|
return success(service.indexBreakDown(breakdown));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障解决记录
|
* 故障解决记录
|
||||||
* @param faultInfo
|
* @param breakdown
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("updateBreakDown")
|
@PostMapping("updateBreakDown")
|
||||||
public Result updateBreakDown(@RequestBody FaultInfo faultInfo) {
|
public Result updateBreakDown(@RequestBody Breakdown breakdown) {
|
||||||
return success(service.updateBreakDown(faultInfo));
|
return success(service.updateBreakDown(breakdown));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,8 +77,8 @@ public class BreakdownController extends BaseController {
|
||||||
return success(service.listFaultCode());
|
return success(service.listFaultCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("selectVinEnterprise")
|
@PostMapping("selectVinEnterprise/{vin}")
|
||||||
public Result<Sources> selectVinEnterprise(@RequestParam String vin) {
|
public Result<Sources> selectVinEnterprise(@PathVariable String vin) {
|
||||||
return success(service.selectVinEnterprise(vin));
|
return success(service.selectVinEnterprise(vin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +87,31 @@ public class BreakdownController extends BaseController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("pies")
|
@PostMapping("pies")
|
||||||
public Result<List<Map<String,Object>>> pies() {
|
public Result<List<Map<String,Object>>> pies(@RequestBody BreakdownSel breakdownSel) {
|
||||||
return success(service.pies());
|
System.out.println(breakdownSel);
|
||||||
|
return success(service.pies(breakdownSel));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 测试队列
|
||||||
|
*/
|
||||||
|
@PostMapping("start")
|
||||||
|
public void start() {
|
||||||
|
FaultInfo faultInfo = FaultInfo.builder()
|
||||||
|
.faultCode("456")
|
||||||
|
.vin("123")
|
||||||
|
.time(new Date())
|
||||||
|
.build();
|
||||||
|
producer.start_time(faultInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("end")
|
||||||
|
public void end() {
|
||||||
|
FaultInfo faultInfo = FaultInfo.builder()
|
||||||
|
.faultCode("456")
|
||||||
|
.vin("123")
|
||||||
|
.time(new Date())
|
||||||
|
.build();
|
||||||
|
producer.end_time(faultInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package com.muyu.goods.incident.mq;
|
package com.muyu.goods.incident.mq;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.business.common.psvm.FaultInfo;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -13,4 +15,14 @@ public class Producer {
|
||||||
public void electronic(Integer id) {
|
public void electronic(Integer id) {
|
||||||
rabbitTemplate.convertAndSend("vehicle.event","",id);
|
rabbitTemplate.convertAndSend("vehicle.event","",id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void start_time(FaultInfo faultInfo) {
|
||||||
|
String jsonString = JSONObject.toJSONString(faultInfo);
|
||||||
|
rabbitTemplate.convertAndSend("fault.message","start",jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void end_time(FaultInfo faultInfo) {
|
||||||
|
String jsonString = JSONObject.toJSONString(faultInfo);
|
||||||
|
rabbitTemplate.convertAndSend("fault.message","end",jsonString);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,15 +11,18 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface BreakdownMapper {
|
public interface BreakdownMapper {
|
||||||
Integer indexBreakDown(FaultInfo faultInfo);
|
Integer indexBreakDown(Breakdown breakdown);
|
||||||
|
|
||||||
Integer updateBreakDown(FaultInfo faultInfo);
|
Integer updateBreakDown(Breakdown breakdown);
|
||||||
|
|
||||||
List<FaultCode> listFaultCode();
|
List<FaultCode> listFaultCode();
|
||||||
|
|
||||||
Car selectVinCar(@Param("vin") String vin);
|
Car selectVinCar(@Param("vin") String vin);
|
||||||
|
|
||||||
List<Breakdown> selectBreakdownList(BreakdownSel breakdownSel);
|
List<Breakdown> selectBreakdownList();
|
||||||
|
|
||||||
List<Map<String, Object>> pies();
|
List<Map<String, Object>> pies(BreakdownSel breakdownSel);
|
||||||
|
|
||||||
|
|
||||||
|
List<Breakdown> lists();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,76 @@
|
||||||
package com.muyu.goods.monitor.mq;
|
package com.muyu.goods.monitor.mq;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.business.common.domain.Breakdown;
|
||||||
|
import com.business.common.domain.VehicleInfo;
|
||||||
import com.business.common.psvm.FaultInfo;
|
import com.business.common.psvm.FaultInfo;
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
|
||||||
import com.muyu.goods.controller.BreakdownController;
|
import com.muyu.goods.controller.BreakdownController;
|
||||||
|
import com.muyu.goods.service.impl.ExecuteService;
|
||||||
|
import lombok.Data;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.amqp.core.AmqpAdmin;
|
import org.springframework.amqp.core.AmqpAdmin;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.core.ExchangeTypes;
|
import org.springframework.amqp.core.ExchangeTypes;
|
||||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Log4j2
|
@Log4j2
|
||||||
public class breakdownMqConsumer {
|
public class breakdownMqConsumer {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AmqpAdmin amqpAdmin;
|
private AmqpAdmin amqpAdmin;
|
||||||
@Autowired
|
@Autowired
|
||||||
|
private ExecuteService executeService;
|
||||||
|
@Autowired
|
||||||
private BreakdownController breakdownController;
|
private BreakdownController breakdownController;
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理发生的故障
|
* 处理发生的故障
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
//监听交换机 Queue(队列名) @Exchange(value = "交换机名称", type = ExchangeTypes.FANOUT)
|
// @RabbitListener(queuesToDeclare = {@Queue("fault_start_message")})
|
||||||
@RabbitListener(bindings = {@QueueBinding(value = @Queue("fault_start_message"),
|
// 监听交换机 Queue(队列名) @Exchange(value = "交换机名称", type = ExchangeTypes.FANOUT)
|
||||||
exchange = @Exchange(value = "fault.message", type = ExchangeTypes.FANOUT))})
|
|
||||||
public void failureOccurrence(String message) {
|
@RabbitListener(bindings = {@QueueBinding(value = @Queue(name = "fault_start_message"),
|
||||||
FaultInfo faultInfo = JSONObject.parseObject(message, FaultInfo.class);
|
exchange = @Exchange(name = "fault.message", type = ExchangeTypes.DIRECT),
|
||||||
|
key = { "start" })})
|
||||||
|
// @RabbitListener(bindings = {@QueueBinding(value = @Queue("fault_start_message"),
|
||||||
|
// exchange = @Exchange(value = "fault.message", type = ExchangeTypes.FANOUT))})
|
||||||
|
public void failureOccurrence(String message, Channel channel, Message messageProperties) {
|
||||||
|
String parse = JSON.parse(message).toString();
|
||||||
|
FaultInfo faultInfo = JSON.parseObject(parse, FaultInfo.class);
|
||||||
log.info("获取存在:{}",faultInfo);
|
log.info("获取存在:{}",faultInfo);
|
||||||
log.info("获取存在:{}",message);
|
Breakdown breakdown = new Breakdown();
|
||||||
// breakdownController.indexBreakDown(faultInfo);
|
breakdown.setFaultLevel(1);
|
||||||
amqpAdmin.deleteQueue("fault_start_message");
|
breakdown.setFaultStartTime(faultInfo.getTime());
|
||||||
|
breakdown.setFaultCode(faultInfo.getFaultCode());
|
||||||
|
breakdown.setVin(faultInfo.getVin());
|
||||||
|
breakdown.setFaultState(0);
|
||||||
|
System.out.println("取");
|
||||||
|
executeService.indexBreakdown(breakdown);
|
||||||
|
redisTemplate.opsForValue().set("vin",faultInfo.getVin(),10,TimeUnit.MINUTES);
|
||||||
|
executeService.selectVinEnterprise();
|
||||||
|
// 消费成功 手动确认
|
||||||
|
try {
|
||||||
|
channel.basicAck(messageProperties.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
// 在这里处理接收到的消息
|
// 在这里处理接收到的消息
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +78,30 @@ public class breakdownMqConsumer {
|
||||||
* 处理解决的故障
|
* 处理解决的故障
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
@RabbitListener(bindings = {@QueueBinding(value = @Queue("fault_end_message"),
|
// @RabbitListener(queuesToDeclare = {@Queue("fault_end_message")})
|
||||||
exchange = @Exchange(value = "fault.message", type = ExchangeTypes.FANOUT))})
|
|
||||||
public void failureShooting(String message) {
|
@RabbitListener(bindings = {@QueueBinding(value = @Queue(name = "fault_end_message"),
|
||||||
FaultInfo faultInfo = JSONObject.parseObject(message, FaultInfo.class);
|
exchange = @Exchange(name = "fault.message", type = ExchangeTypes.DIRECT),
|
||||||
|
key = { "end" })})
|
||||||
|
// @RabbitListener(bindings = {@QueueBinding(value = @Queue("fault_end_message"),
|
||||||
|
// exchange = @Exchange(value = "fault.message", type = ExchangeTypes.FANOUT))})
|
||||||
|
public void failureShooting(String message, Channel channel, Message messageProperties) {
|
||||||
|
String parse = JSON.parse(message).toString();
|
||||||
|
FaultInfo faultInfo = JSON.parseObject(parse, FaultInfo.class);
|
||||||
log.info("解决:{}",message);
|
log.info("解决:{}",message);
|
||||||
log.info("解决:{}",faultInfo);
|
Breakdown breakdown = new Breakdown();
|
||||||
// breakdownController.updateBreakDown(faultInfo);
|
breakdown.setFaultEndTime(faultInfo.getTime());
|
||||||
amqpAdmin.deleteQueue("fault_end_message");
|
breakdown.setFaultCode(faultInfo.getFaultCode());
|
||||||
|
breakdown.setVin(faultInfo.getVin());
|
||||||
|
breakdown.setFaultState(1);
|
||||||
|
System.out.println("改");
|
||||||
|
breakdownController.updateBreakDown(breakdown);
|
||||||
|
// 消费成功 手动确认
|
||||||
|
try {
|
||||||
|
channel.basicAck(messageProperties.getMessageProperties().getDeliveryTag(),false);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
// 在这里处理接收到的消息
|
// 在这里处理接收到的消息
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,20 +14,23 @@ public interface IBreakdownService {
|
||||||
* 故障记录
|
* 故障记录
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Breakdown> selectBreakdownList(BreakdownSel breakdownSel);
|
List<Breakdown> selectBreakdownList();
|
||||||
|
|
||||||
|
List<Breakdown> lists();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录故障发生
|
* 记录故障发生
|
||||||
* @param faultInfo
|
* @param breakdown
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer indexBreakDown(FaultInfo faultInfo);
|
Integer indexBreakDown(Breakdown breakdown);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录故障解决
|
* 记录故障解决
|
||||||
* @param faultInfo
|
* @param breakdown
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Integer updateBreakDown(FaultInfo faultInfo);
|
Integer updateBreakDown(Breakdown breakdown);
|
||||||
|
|
||||||
List<FaultCode> listFaultCode();
|
List<FaultCode> listFaultCode();
|
||||||
|
|
||||||
|
@ -37,5 +40,7 @@ public interface IBreakdownService {
|
||||||
* 图形化
|
* 图形化
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Map<String,Object>> pies();
|
List<Map<String,Object>> pies(BreakdownSel breakdownSel);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,22 +30,27 @@ public class BreakdownService implements IBreakdownService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 故障记录
|
* 故障记录
|
||||||
* @param breakdownSel
|
* @param breakdown
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<Breakdown> selectBreakdownList(BreakdownSel breakdownSel) {
|
public List<Breakdown> selectBreakdownList() {
|
||||||
return mapper.selectBreakdownList(breakdownSel);
|
return mapper.selectBreakdownList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer indexBreakDown(FaultInfo faultInfo) {
|
public List<Breakdown> lists() {
|
||||||
return mapper.indexBreakDown(faultInfo);
|
return mapper.lists();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer updateBreakDown(FaultInfo faultInfo) {
|
public Integer indexBreakDown(Breakdown breakdown) {
|
||||||
return mapper.updateBreakDown(faultInfo);
|
return mapper.indexBreakDown(breakdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer updateBreakDown(Breakdown breakdown) {
|
||||||
|
return mapper.updateBreakDown(breakdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,14 +62,28 @@ public class BreakdownService implements IBreakdownService {
|
||||||
public Sources selectVinEnterprise(String vin) {
|
public Sources selectVinEnterprise(String vin) {
|
||||||
// 查询车辆
|
// 查询车辆
|
||||||
Car car = mapper.selectVinCar(vin);
|
Car car = mapper.selectVinCar(vin);
|
||||||
|
if (car == null) {
|
||||||
|
System.out.println("查询不到车辆");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
//根据车辆管理人查询员工
|
//根据车辆管理人查询员工
|
||||||
List<SysUser> userList = remoteUserService.lists().getData();
|
List<SysUser> userList = remoteUserService.lists().getData();
|
||||||
SysUser sysUser = userList.stream().filter(firm -> firm.getFirm() == car.getOwnerId()).collect(Collectors.toList()).get(0);
|
List<SysUser> sysUserList = userList.stream().filter(firm -> firm.getFirm() == car.getOwnerId()).collect(Collectors.toList());
|
||||||
|
if (sysUserList == null ){
|
||||||
|
System.out.println("该车负责人未找到");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
SysUser sysUser = sysUserList.get(0);
|
||||||
//根据员工查询到企业
|
//根据员工查询到企业
|
||||||
List<Enterprise> enterpriseList = remoteSourcesService.lists().getData();
|
List<Enterprise> enterpriseList = remoteSourcesService.lists().getData();
|
||||||
Enterprise enterprise1 = enterpriseList.stream().filter(enterprise -> enterprise.getId() == sysUser.getFirm()).collect(Collectors.toList()).get(0);
|
List<Enterprise> enterprises = enterpriseList.stream().filter(enterprise -> enterprise.getId() == sysUser.getFirm()).collect(Collectors.toList());
|
||||||
|
if (enterprises == null) {
|
||||||
|
System.out.println("未成功定义企业");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Enterprise enterprise = enterprises.get(0);
|
||||||
//根据企业查询到企业数据源
|
//根据企业查询到企业数据源
|
||||||
com.muyu.common.goods.domain.Sources sources = remoteSourcesService.listSources().getData().stream().filter(sour -> sour.getEnterpriseId() == enterprise1.getId()).collect(Collectors.toList()).get(0);
|
com.muyu.common.goods.domain.Sources sources = remoteSourcesService.listSources().getData().stream().filter(sour -> sour.getEnterpriseId() == enterprise.getId()).collect(Collectors.toList()).get(0);
|
||||||
Sources sources1 = Sources.builder()
|
Sources sources1 = Sources.builder()
|
||||||
.id(sources.getId())
|
.id(sources.getId())
|
||||||
.enterpriseId(sources.getEnterpriseId())
|
.enterpriseId(sources.getEnterpriseId())
|
||||||
|
@ -74,11 +93,12 @@ public class BreakdownService implements IBreakdownService {
|
||||||
.username(sources.getUsername())
|
.username(sources.getUsername())
|
||||||
.password(sources.getPassword())
|
.password(sources.getPassword())
|
||||||
.build();
|
.build();
|
||||||
|
System.out.println(sources1);
|
||||||
return sources1;
|
return sources1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> pies() {
|
public List<Map<String, Object>> pies(BreakdownSel breakdownSel) {
|
||||||
return mapper.pies();
|
return mapper.pies(breakdownSel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
package com.muyu.goods.service.impl;
|
package com.muyu.goods.service.impl;
|
||||||
|
|
||||||
|
import com.business.common.domain.Breakdown;
|
||||||
import com.business.common.middle.GroupFenceDev;
|
import com.business.common.middle.GroupFenceDev;
|
||||||
import com.business.common.domain.Car;
|
import com.business.common.domain.Car;
|
||||||
|
import com.business.common.psvm.FaultInfo;
|
||||||
import com.muyu.goods.mapper.MapMapper;
|
import com.muyu.goods.mapper.MapMapper;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.scheduling.annotation.Async;
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@ -16,6 +19,10 @@ import java.util.stream.Collectors;
|
||||||
public class ExecuteService {
|
public class ExecuteService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MapMapper mapMapper;
|
private MapMapper mapMapper;
|
||||||
|
@Autowired
|
||||||
|
private BreakdownService breakdownService;
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public void indexGroupFence(Car car) {
|
public void indexGroupFence(Car car) {
|
||||||
|
@ -35,4 +42,15 @@ public class ExecuteService {
|
||||||
mapMapper.deleteCarFence(carId);
|
mapMapper.deleteCarFence(carId);
|
||||||
log.info("delete完成");
|
log.info("delete完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void indexBreakdown(Breakdown breakdown) {
|
||||||
|
breakdownService.indexBreakDown(breakdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Async
|
||||||
|
public void selectVinEnterprise() {
|
||||||
|
String vin = redisTemplate.opsForValue().get("vin");
|
||||||
|
breakdownService.selectVinEnterprise(vin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,26 +32,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
<if test="faultCode != null">fault_code,</if>
|
<if test="faultCode != null">fault_code,</if>
|
||||||
<if test="vin != null">vin,</if>
|
<if test="vin != null">vin,</if>
|
||||||
fault_state,
|
<if test="faultState!=null">fault_state,</if>
|
||||||
<if test="faultStartTime != null">fault_start_time,</if>
|
<if test="faultStartTime != null">fault_start_time,</if>
|
||||||
fault_level,
|
<if test="faultLevel!=null">fault_level,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="faultCode != null">#{faultCode},</if>
|
<if test="faultCode != null">#{faultCode},</if>
|
||||||
<if test="vin != null">#{vin},</if>
|
<if test="vin != null">#{vin},</if>
|
||||||
<if test="faultState != null">0,</if>
|
<if test="faultState != null">0,</if>
|
||||||
<if test="faultStartTime != null">#{time},</if>
|
<if test="faultStartTime != null">#{faultStartTime},</if>
|
||||||
<if test="faultLevel != null">1,</if>
|
<if test="faultLevel != null">1,</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateBreakDown">
|
<update id="updateBreakDown">
|
||||||
update breakdown
|
update breakdown
|
||||||
set fault_end_time = #{time},
|
set fault_end_time = #{faultEndTime},
|
||||||
fault_state = 1
|
fault_state = 1
|
||||||
where
|
where
|
||||||
fault_code = #{faultCode} and
|
fault_code = #{faultCode} and
|
||||||
vin = #{vin} and
|
vin = #{vin} and
|
||||||
fault_end_time = null
|
fault_end_time is null
|
||||||
</update>
|
</update>
|
||||||
<select id="listFaultCode" resultType="com.business.common.domain.FaultCode">
|
<select id="listFaultCode" resultType="com.business.common.domain.FaultCode">
|
||||||
<include refid="selectFaultCodeVo"></include>
|
<include refid="selectFaultCodeVo"></include>
|
||||||
|
@ -62,13 +62,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
<select id="selectBreakdownList" resultType="com.business.common.domain.Breakdown">
|
<select id="selectBreakdownList" resultType="com.business.common.domain.Breakdown">
|
||||||
<include refid="selectBreakdownVo"></include>
|
<include refid="selectBreakdownVo"></include>
|
||||||
<where>
|
|
||||||
<if test="faultCode != null and faultCode!=''">and fault_code like concat('%',#{faultCode},'%')</if>
|
|
||||||
<if test="faultStartTime != null and faultStartTime != ''">and fault_start_time >= #{faultStartTime} </if>
|
|
||||||
<if test="faultEndTime != null and faultEndTime != ''">and fault_start_time < = #{faultEndTime} </if>
|
|
||||||
</where>
|
|
||||||
</select>
|
</select>
|
||||||
<select id="pies" resultType="java.util.Map">
|
<select id="pies" resultType="java.util.Map">
|
||||||
select fault_code name, count(fault_code) value from breakdown group by fault_code
|
select fault_code name, count(fault_code) value from breakdown
|
||||||
|
<where>
|
||||||
|
<if test="faultStartTime != null">and fault_start_time >= #{faultStartTime} </if>
|
||||||
|
<if test="faultEndTime != null ">and fault_start_time <= #{faultEndTime} </if>
|
||||||
|
</where>
|
||||||
|
group by fault_code
|
||||||
</select>
|
</select>
|
||||||
|
<select id="lists" resultType="com.business.common.domain.Breakdown"></select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -22,8 +22,6 @@ public class EnterpriseConfigRunner implements ApplicationRunner {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RemoteSourcesService remoteSourcesService;
|
private RemoteSourcesService remoteSourcesService;
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args){
|
||||||
Result<List<Sources>> listResult = remoteSourcesService.listSources();
|
|
||||||
System.out.println(listResult);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.muyu.goods.config;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.goods.controller.EnterpriseController;
|
||||||
|
import com.muyu.goods.domain.Enterprise;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.ApplicationArguments;
|
||||||
|
import org.springframework.boot.ApplicationRunner;
|
||||||
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Log4j2
|
||||||
|
@Configuration
|
||||||
|
@ComponentScan
|
||||||
|
public class EnterpiseConfig implements ApplicationRunner {
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String,String> redisTemplate;
|
||||||
|
@Autowired
|
||||||
|
private EnterpriseController enterpriseController;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
List<Enterprise> enterprises = enterpriseController.lists().getData();
|
||||||
|
List<String> range = redisTemplate.opsForList().range("enterprises", 0, -1);
|
||||||
|
if (range.size() == 0){
|
||||||
|
for (Enterprise enterpris : enterprises) {
|
||||||
|
redisTemplate.opsForList().leftPushAll("enterprises",JSONObject.toJSONString(enterpris));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -139,9 +139,7 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
Sources sources = Sources.index(enterprise1.getId(),"enterprise" + enterprise1.getId(), String.valueOf((int) (enterprise.getId() + 3306)));
|
Sources sources = Sources.index(enterprise1.getId(),"enterprise" + enterprise1.getId(), String.valueOf((int) (enterprise.getId() + 3306)));
|
||||||
System.out.println(sources);
|
|
||||||
enterpriseMapper.indexSources(sources);
|
enterpriseMapper.indexSources(sources);
|
||||||
System.out.println(sources.getIp());
|
|
||||||
producer.datasource(sources.getIp());
|
producer.datasource(sources.getIp());
|
||||||
}
|
}
|
||||||
return i;
|
return i;
|
||||||
|
@ -197,9 +195,6 @@ public class EnterpriseServiceImpl implements IEnterpriseService
|
||||||
@Override
|
@Override
|
||||||
public List<Enterprise> lists() {
|
public List<Enterprise> lists() {
|
||||||
List<Enterprise> enterprises = selectEnterpriseList(null);
|
List<Enterprise> enterprises = selectEnterpriseList(null);
|
||||||
for (Enterprise enterpris : enterprises) {
|
|
||||||
redisTemplate.opsForList().leftPush("enterprises",JSONObject.toJSONString(enterpris));
|
|
||||||
}
|
|
||||||
List<String> range = redisTemplate.opsForList().range("enterprises", 0, -1);
|
List<String> range = redisTemplate.opsForList().range("enterprises", 0, -1);
|
||||||
System.out.println(range);
|
System.out.println(range);
|
||||||
return enterprises;
|
return enterprises;
|
||||||
|
|
|
@ -21,4 +21,6 @@ public class CloudManyDataSourceApplication {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(CloudManyDataSourceApplication.class,args);
|
SpringApplication.run(CloudManyDataSourceApplication.class,args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue