10 changed files with 213 additions and 157 deletions
@ -0,0 +1,21 @@ |
|||
package com.ccsens.wisdomcar.persist.dao; |
|||
|
|||
import com.ccsens.wisdomcar.persist.mapper.StepMapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
/** |
|||
* @author 逗 |
|||
*/ |
|||
@Repository |
|||
public interface StepDao extends StepMapper { |
|||
|
|||
/** |
|||
* 通过rfid查找流程 |
|||
* @param value rfid |
|||
* @return 返回流程的code |
|||
*/ |
|||
String getCodeByRfId(@Param("rfid") String value); |
|||
|
|||
String getCodeByStepOne(); |
|||
} |
@ -1,57 +1,55 @@ |
|||
//package com.ccsens.wisdomcar.rabbitMQ;
|
|||
//
|
|||
//import cn.hutool.core.collection.CollectionUtil;
|
|||
//import cn.hutool.core.util.ObjectUtil;
|
|||
//import com.alibaba.fastjson.JSONObject;
|
|||
//import com.ccsens.util.bean.message.common.OutMessage;
|
|||
//import com.ccsens.util.bean.message.common.OutMessageSet;
|
|||
//import com.ccsens.util.config.RabbitMQConfig;
|
|||
//import com.ccsens.wisdomcar.bean.dto.Message.CarRecordMessageDto;
|
|||
//import com.ccsens.wisdomcar.service.IRecordService;
|
|||
//import com.ccsens.wisdomcar.service.RecordService;
|
|||
//import lombok.extern.slf4j.Slf4j;
|
|||
//import org.slf4j.Logger;
|
|||
//import org.slf4j.LoggerFactory;
|
|||
//import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
|||
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|||
//import org.springframework.stereotype.Component;
|
|||
//
|
|||
//import javax.annotation.Resource;
|
|||
//import java.util.List;
|
|||
//import java.util.Set;
|
|||
//
|
|||
//@Slf4j
|
|||
//@Component
|
|||
//@RabbitListener(queues = RabbitMQConfig.WISDOM_CAR)
|
|||
//public class RabbitController {
|
|||
// @Resource
|
|||
// private IRecordService recordService;
|
|||
//
|
|||
// private Logger logger = LoggerFactory.getLogger(RabbitController.class);
|
|||
//
|
|||
// @RabbitHandler
|
|||
// public void process(String messageJson) {
|
|||
// logger.info("平车上传消息数据: {}",messageJson);
|
|||
// OutMessageSet outMessageSet = JSONObject.parseObject(messageJson,OutMessageSet.class);
|
|||
// if(ObjectUtil.isNull(outMessageSet)){
|
|||
// return;
|
|||
// }
|
|||
// Set<OutMessage> messageSet = outMessageSet.getMessageSet();
|
|||
// if (CollectionUtil.isEmpty(messageSet)) {
|
|||
// return;
|
|||
// }
|
|||
// messageSet.forEach(outMessage -> {
|
|||
// CarRecordMessageDto carRecordMessageDto = JSONObject.parseObject(outMessage.getData(),CarRecordMessageDto.class);
|
|||
// if(ObjectUtil.isNull(carRecordMessageDto)){
|
|||
// return;
|
|||
// }
|
|||
// try {
|
|||
// recordService.disposeMessage(carRecordMessageDto);
|
|||
// } catch (Exception e) {
|
|||
// log.error("处理平车信息异常",e);
|
|||
// e.printStackTrace();
|
|||
// }
|
|||
// });
|
|||
// }
|
|||
//
|
|||
//}
|
|||
package com.ccsens.wisdomcar.rabbitMQ; |
|||
|
|||
import cn.hutool.core.collection.CollectionUtil; |
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.ccsens.util.bean.message.common.OutMessage; |
|||
import com.ccsens.util.bean.message.common.OutMessageSet; |
|||
import com.ccsens.util.config.RabbitMQConfig; |
|||
import com.ccsens.wisdomcar.bean.dto.Message.CarRecordMessageDto; |
|||
import com.ccsens.wisdomcar.service.IRecordService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitHandler; |
|||
import org.springframework.amqp.rabbit.annotation.RabbitListener; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.Set; |
|||
|
|||
@Slf4j |
|||
@Component |
|||
@RabbitListener(queues = RabbitMQConfig.WISDOM_CAR) |
|||
public class RabbitController { |
|||
@Resource |
|||
private IRecordService recordService; |
|||
|
|||
private Logger logger = LoggerFactory.getLogger(RabbitController.class); |
|||
|
|||
@RabbitHandler |
|||
public void process(String messageJson) { |
|||
logger.info("平车上传消息数据: {}",messageJson); |
|||
OutMessageSet outMessageSet = JSONObject.parseObject(messageJson,OutMessageSet.class); |
|||
if(ObjectUtil.isNull(outMessageSet)){ |
|||
return; |
|||
} |
|||
Set<OutMessage> messageSet = outMessageSet.getMessageSet(); |
|||
if (CollectionUtil.isEmpty(messageSet)) { |
|||
return; |
|||
} |
|||
messageSet.forEach(outMessage -> { |
|||
CarRecordMessageDto carRecordMessageDto = JSONObject.parseObject(outMessage.getData(),CarRecordMessageDto.class); |
|||
if(ObjectUtil.isNull(carRecordMessageDto)){ |
|||
return; |
|||
} |
|||
try { |
|||
recordService.disposeMessage(carRecordMessageDto); |
|||
} catch (Exception e) { |
|||
log.error("处理平车信息异常",e); |
|||
e.printStackTrace(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
} |
|||
|
@ -0,0 +1,25 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.ccsens.wisdomcar.persist.dao.StepDao"> |
|||
|
|||
|
|||
<select id="getCodeByRfId" resultType="java.lang.String"> |
|||
SELECT |
|||
s. |
|||
FROM |
|||
`t_step` s, |
|||
t_rfid r |
|||
WHERE |
|||
s.id = r.step_id |
|||
and r.rfid = #{rfid} |
|||
limit 1 |
|||
</select> |
|||
<select id="getCodeByStepOne" resultType="java.lang.String"> |
|||
SELECT |
|||
s.code |
|||
FROM |
|||
`t_step` s |
|||
ORDER BY id |
|||
limit 1 |
|||
</select> |
|||
</mapper> |
Loading…
Reference in new issue