feat():下发钢卷设定值请求到模型程序

This commit is contained in:
Allenxy
2025-01-11 16:32:30 +08:00
parent 8c49e04783
commit 627fcb1482

View File

@@ -70,27 +70,26 @@ public class ModSetupResultServiceImpl extends ServiceImpl<ModSetupResultMapper,
public String calcSetup(CalcPdiPlanForm form) {
//发送MQ
// MessageProperties props = MessagePropertiesBuilder.newInstance()
// .setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
// .setMessageId("CALL_SETUP")
// .build();
// rabbitTemplate.send(CommonConstants.RabbitMQ.SEND_MODEL,new Message(JSONUtil.toJsonStr(form).getBytes(StandardCharsets.UTF_8),props));
MessageProperties props = MessagePropertiesBuilder.newInstance()
.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
.setMessageId("CALL_SETUP")
.build();
rabbitTemplate.send(CommonConstants.RabbitMQ.SEND_MODEL,new Message(JSONUtil.toJsonStr(form).getBytes(StandardCharsets.UTF_8),props));
// 获取当前时间的毫秒级时间戳
long timestampMillis = LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli();
// 生成字符串:由 coilid 和当前时间戳拼接而成
String resultString = form.getCoilid() + timestampMillis;
// 先返回构建的字符串
// 这里是返回值先返回,后面调用副作用的逻辑
// 然后调用mockCalcResult方法它是异步的不会影响返回值
// mockCalcResult将会在返回之后执行不影响calcSetup的返回
new Thread(() -> mockCalcResult(form.getCoilid(), resultString)).start();
// new Thread(() -> mockCalcResult(form.getCoilid(), resultString)).start();
// 返回值会先返回给调用者
return resultString;
return form.getCoilid() + timestampMillis;
}
private void mockCalcResult(String coilid, String string) {