Commit 5a943828 authored by 张森's avatar 张森

Merge remote-tracking branch 'origin/develop_dl' into develop_dl_bugfix

parents b9454fc3 256e3bfb
......@@ -79,4 +79,7 @@ public class EquipTypeImgAmountVO {
@ApiModelProperty(value = "日常运维")
private String equip;
@ApiModelProperty(value = "系统IDs")
private String systemId;
}
package com.yeejoin.equipmanage.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -1008,11 +1009,31 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
}
IPage<EquipTypeImgAmountVO> list = fireFightingSystemMapper
.getColaCategoryAmountEquList(equipTypeAmountPage.getPage(), hierarchy, codeHead, equipTypeAmountPage);
ArrayList<String> systemIds = new ArrayList<>();
list.getRecords().forEach(x -> {
if (!x.getEqtype().startsWith("4") && StringUtil.isNotEmpty(x.getAmount())) {
x.setAmount(x.getAmount().split("\\.")[0]);
}
if (StringUtil.isNotEmpty(x.getSystemId())) {
List<String> systemId = Arrays.asList(x.getSystemId().split(","));
systemIds.addAll(systemId);
}
});
if (CollUtil.isNotEmpty(systemIds)) {
LambdaQueryWrapper<FireFightingSystemEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.in(FireFightingSystemEntity::getId, systemIds);
List<FireFightingSystemEntity> fireSystemList = fireFightingSystemMapper.selectList(wrapper);
Map<String, String> systemNameMap = fireSystemList.stream().collect(Collectors.toMap(t -> t.getId().toString(), FireFightingSystemEntity::getName));
list.getRecords().parallelStream().forEach(item -> {
if (StringUtil.isNotEmpty(item.getSystemId())) {
ArrayList<String> systemNames = new ArrayList<>();
List<String> systemIdList = Arrays.asList(item.getSystemId().split(","));
systemIdList.parallelStream().forEach(id -> systemNames.add(systemNameMap.getOrDefault(id, "")));
String join = String.join(",", systemNames);
item.setSystemName(join);
}
});
}
return list;
}
......
......@@ -2071,7 +2071,7 @@
<select id="getColaCategoryAmountEquList" resultMap="CategoryAmountList">
select * from (
SELECT
wles.id,
wles.qr_code,
......@@ -2083,8 +2083,7 @@
concat_ws('-',wlws.full_name,wled.area) as full_name,
wlws.name as belongBuildName,
wlun.NAME unitName,
(SELECT GROUP_CONCAT(fem.name) FROM `f_fire_fighting_system` fem WHERE find_in_set(fem.id,wles.system_id))
as systemName,
wles.system_id as systemId,
wlsd.amount,
wlsd.id as stockDetailId,
'equipment' as type,
......@@ -2165,13 +2164,12 @@
<if test="equipTypeAmountPage.iotCode!=null and equipTypeAmountPage.iotCode!=''">
AND wles.iot_code LIKE CONCAT('%',#{equipTypeAmountPage.iotCode},'%')
</if>
)s1 WHERE 1=1
<if test="equipTypeAmountPage.warehouseStructureName!=null and equipTypeAmountPage.warehouseStructureName!=''">
AND s1.full_name LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%')
AND concat_ws('-',wlws.full_name,wled.area) LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%')
</if>
<if test="equipTypeAmountPage.bizOrgCode!=null and equipTypeAmountPage.bizOrgCode!=''">
AND s1.bizOrgCode LIKE CONCAT(#{equipTypeAmountPage.bizOrgCode},'%')
AND wles.biz_org_code LIKE CONCAT(#{equipTypeAmountPage.bizOrgCode},'%')
</if>
order by createDate DESC
</select>
......
......@@ -40,33 +40,33 @@ public class KafkaConsumerService {
@Value("classpath:/json/commonMessage.json")
private Resource commonMessage;
/**
* 批量消费kafka消息
* Kafka消息转emq
*
* @param consumerRecords messages
* @param ack ack
*/
@KafkaListener(id = "consumerSingle", groupId = "zhTestGroup", topics = "#{'${kafka.topics}'.split(',')}")
public void listen1(List<ConsumerRecord<String, String>> consumerRecords, Acknowledgment ack) {
try {
for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
if (kafkaMessage.isPresent()) {
JSONObject messageObj = JSONObject.fromObject(kafkaMessage.get());
if (messageObj.has(TOPIC)) {
emqKeeper.getMqttClient().publish(messageObj.optString(TOPIC), messageObj.getJSONObject(DATA).toString()
.getBytes(StandardCharsets.UTF_8), 0, false);
}
log.info("kafka消费zhTestGroup消息{}", messageObj);
}
}
} catch (Exception e) {
log.error("kafka失败,当前失败的批次: data:{}, {}", consumerRecords, e);
} finally {
ack.acknowledge();
}
}
// /**
// * 批量消费kafka消息
// * Kafka消息转emq
// *
// * @param consumerRecords messages
// * @param ack ack
// */
// @KafkaListener(id = "consumerSingle", groupId = "zhTestGroup", topics = "#{'${kafka.topics}'.split(',')}")
// public void listen1(List<ConsumerRecord<String, String>> consumerRecords, Acknowledgment ack) {
// try {
// for (ConsumerRecord<String, String> consumerRecord : consumerRecords) {
// Optional<?> kafkaMessage = Optional.ofNullable(consumerRecord.value());
// if (kafkaMessage.isPresent()) {
// JSONObject messageObj = JSONObject.fromObject(kafkaMessage.get());
// if (messageObj.has(TOPIC)) {
// emqKeeper.getMqttClient().publish(messageObj.optString(TOPIC), messageObj.getJSONObject(DATA).toString()
// .getBytes(StandardCharsets.UTF_8), 0, false);
// }
// log.info("kafka消费zhTestGroup消息{}", messageObj);
// }
// }
// } catch (Exception e) {
// log.error("kafka失败,当前失败的批次: data:{}, {}", consumerRecords, e);
// } finally {
// ack.acknowledge();
// }
// }
/**
* 批量消费kafka消息
......@@ -244,29 +244,29 @@ public class KafkaConsumerService {
// }
///**
// * 消费单条消息,topics 可以监听多个topic,如:topics = {"topic1", "topic2"}
// *
// * @param message 消息
// */
//@KafkaListener(id = "consumerSingle", groupId = "zhTestGroup", topics = "#{'${kafka.topics}'.split(',')}", concurrency = "2")
//public void consumerSingle(String message, Acknowledgment ack) {
// JSONObject messageObj = JSONObject.fromObject(message);
// try {
// String topic = null;
// JSONObject data = null;
// if (messageObj.has("topic")) {
// topic = messageObj.getString("topic");
// data = messageObj.getJSONObject("data");
// emqKeeper.getMqttClient().publish(topic, data.toString().getBytes(StandardCharsets.UTF_8), 0, false);
// ack.acknowledge();
// log.info("消息转发成功" + messageObj);
// }
// } catch (Exception e) {
// log.error("消息转发失败" + e.getMessage(), e);
// }
//}
//
/**
* 消费单条消息,topics 可以监听多个topic,如:topics = {"topic1", "topic2"}
*
* @param message 消息
*/
@KafkaListener(id = "consumerSingle", topics = "#{'${kafka.topics}'.split(',')}", concurrency = "2")
public void consumerSingle(String message, Acknowledgment ack) {
JSONObject messageObj = JSONObject.fromObject(message);
try {
String topic = null;
JSONObject data = null;
if (messageObj.has("topic")) {
topic = messageObj.getString("topic");
data = messageObj.getJSONObject("data");
emqKeeper.getMqttClient().publish(topic, data.toString().getBytes(StandardCharsets.UTF_8), 0, false);
ack.acknowledge();
log.info("消息转发成功" + messageObj);
}
} catch (Exception e) {
log.error("消息转发失败" + e.getMessage(), e);
}
}
///**
// * 省级消息转发
......
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