Commit 68a7706e authored by zhangsen's avatar zhangsen

场站红黄码规则部分代码提交

parent 04c57b16
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 场站基础信息表 Mapper 接口
......@@ -57,4 +58,10 @@ public interface StationBasicMapper extends BaseMapper<StationBasic> {
*/
List<TreeDto> getStationListByRegionCode(@Param("regionCode")String regionCode);
/**
* 根据ProjectOrgCode更新红黄绿码
* @param analysisResult 更新数据信息
*/
int updateYardByProjectOrgCode(@Param("list") List<Map<String,String>> analysisResult);
}
......@@ -168,4 +168,15 @@
</if>
</where>
</select>
<update id="updateYardByProjectOrgCode">
<foreach collection="list" item="item" separator=";">
update
`station_basic`
set
`qrcode_color` = #{item.qrcodeColor}
where
project_org_code = #{item.code}
</foreach>
</update>
</mapper>
......@@ -41,6 +41,12 @@
<artifactId>spring-boot-starter-activemq</artifactId>
<version>2.5.4</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
</dependencies>
<build>
......
package com.yeejoin.amos.boot.module.jxiop.biz.emqx;
import com.alibaba.fastjson.JSONArray;
import com.yeejoin.amos.boot.module.jxiop.api.mapper.StationBasicMapper;
import lombok.extern.slf4j.Slf4j;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.emq.EmqxListener;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@Component
@EnableScheduling
@Slf4j
public class StationYardMessage extends EmqxListener {
@Autowired
private AmosRequestContext amosAuth;
@Autowired
protected EmqKeeper emqKeeper;
@Autowired
private StationBasicMapper stationBasicMapper;
// 江西电建接收红黄绿码主题
private static final String JXIOP_STATION_YARD = "jxIop/station/yard";
private static final BlockingQueue<List<Map<String, String>>> blockingQueue = new LinkedBlockingQueue<List<Map<String, String>>>();
@PostConstruct
void init() throws Exception {
new Thread(taskRunnable).start();
emqKeeper.subscript(JXIOP_STATION_YARD, 2, this);
}
@Override
public void processMessage(String topic, MqttMessage message) throws Exception {
JSONArray ja = JSONArray.parseArray(new String(message.getPayload()));
List<Map<String, String>> liMap = JSONArray.toJavaObject(ja, List.class);
blockingQueue.add(liMap);
}
Runnable taskRunnable = new Runnable() {
@Override
public void run() {
boolean isRun = true;
int k = 0;
while (isRun) {
k++;
isRun = k < Integer.MAX_VALUE;
try {
List<Map<String, String>> analysisResult = blockingQueue.take();
RequestContext.setAppKey(amosAuth.getAppKey());
RequestContext.setProduct(amosAuth.getProduct());
RequestContext.setToken(amosAuth.getToken());
jxIopUpdate(analysisResult);
} catch (Exception e) {
e.printStackTrace();
}
}
}
};
public void jxIopUpdate(List<Map<String, String>> analysisResult) {
log.info("场站红黄绿码数据:{}", analysisResult);
stationBasicMapper.updateYardByProjectOrgCode(analysisResult);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment