Explorar el Código

新增换炉接口以及向mqtt推送消息

lingpeng.li hace 3 semanas
padre
commit
6e048f21f7

+ 11 - 1
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/controller/BilletHotsendBaseController.java

@@ -9,7 +9,10 @@ import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.modules.billetActual.entity.BilletHotsend;
 import org.jeecg.modules.billetActual.service.IBilletHotsendBaseService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 /**
 * @Description: 钢坯热送基础信息
 * @Author: jeecg-boot
@@ -46,4 +49,11 @@ public class BilletHotsendBaseController extends JeecgController<BilletHotsend,
       return Result.OK("自动化轧钢外运直接发车成功!");
    }
 
+   @ApiOperation(value="换炉推送消息", notes="换炉推送消息")
+   @PostMapping(value = "/furnaceChange")
+   public Result<?> furnaceChange(@RequestBody JSONObject jsonObject){
+      billetHotsendBaseService.furnaceChange(jsonObject);
+      return Result.OK("换炉推送消息成功!");
+   }
+
 }

+ 2 - 3
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/service/IBilletHotsendBaseService.java

@@ -3,9 +3,6 @@ package org.jeecg.modules.billetActual.service;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.billetActual.entity.BilletHotsend;
-import org.jeecg.modules.billetActual.entity.BilletHotsendDetailsVo;
-
-import java.util.List;
 
 /**
  * @Description: 钢坯热送基础信息
@@ -20,4 +17,6 @@ public interface IBilletHotsendBaseService extends IService<BilletHotsend> {
     void autoAddRodLineCommon(JSONObject jsonObject);
 
     void autoDepartTrucking(JSONObject jsonObject);
+
+    void furnaceChange(JSONObject jsonObject);
 }

+ 33 - 5
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/billetActual/service/impl/BilletHotsendBaseServiceImpl.java

@@ -7,8 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang.StringUtils;
-import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.billetActual.entity.*;
@@ -24,8 +22,11 @@ import org.jeecg.modules.billetHotsendConfig.entity.BilletHotsendTypeConfig;
 import org.jeecg.modules.billetHotsendConfig.service.IBilletHotsendTypeConfigService;
 import org.jeecg.modules.billetLiftingBill.entity.BilletLiftingBill;
 import org.jeecg.modules.billetLiftingBill.service.IBilletLiftingBillService;
+import org.jeecg.modules.connConfig.configMqtt.mapper.ConfigMqttMapper;
 import org.jeecg.modules.operateLog.entity.OperateLog;
 import org.jeecg.modules.operateLog.service.IOperateLogService;
+import org.jeecg.modules.push.utils.MqttClientUtil;
+import org.jeecg.modules.push.utils.TopicType;
 import org.jeecg.modules.rollClubOne.entity.RollClubOne;
 import org.jeecg.modules.rollClubOne.entity.RollClubOneDetails;
 import org.jeecg.modules.rollClubOne.service.IRollClubOneDetailsService;
@@ -46,12 +47,9 @@ import org.jeecg.modules.rollOutShipp.entity.RollOutShipp;
 import org.jeecg.modules.rollOutShipp.entity.RollOutShippDetails;
 import org.jeecg.modules.rollOutShipp.service.IRollOutShippDetailsService;
 import org.jeecg.modules.rollOutShipp.service.IRollOutShippService;
-import org.jeecg.modules.storageBill.entity.ShiftEnum;
-import org.jeecg.modules.storageBill.entity.ShiftGroupEnum;
 import org.jeecg.modules.storageBill.entity.StorageBill;
 import org.jeecg.modules.storageBill.service.IStorageBillService;
 import org.jeecg.modules.storageCarLog.entity.StorageCarLog;
-import org.jeecg.modules.storageCarLog.mapper.StorageCarLogMapper;
 import org.jeecg.modules.storageCarLog.service.IStorageCarLogService;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -116,6 +114,8 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 	private IBilletLiftingBillService billetLiftingBillService;
 	@Autowired
 	private IOperateLogService operateLogService;
+	@Autowired
+	private ConfigMqttMapper configMqttMapper;
 
 	/**
 	 * 自动化新增 5号机 直轧棒1   6号机 高线
@@ -550,6 +550,34 @@ public class BilletHotsendBaseServiceImpl extends ServiceImpl<BilletHotsendBaseM
 	}
 
 
+	@Override
+	public void furnaceChange(JSONObject jsonObject) {
+		String ccmNo = jsonObject.getString("ccmNo");// 铸机号
+		String heatNo = jsonObject.getString("heatNo");// 炉号
+		if (oConvertUtils.isEmpty(ccmNo) || oConvertUtils.isEmpty(heatNo)){
+			log.info("{}{}", "换炉的铸机号跟炉号不能为空", jsonObject);
+			return;
+		}
+		// 发送mqtt消息
+		sendFurnaceChangeToMqtt(ccmNo, heatNo);
+	}
+
+	public void sendFurnaceChangeToMqtt(String ccmNo, String heatNo) {
+		try {
+			Map<String, Object> mapSendInfo = new HashMap<>();
+			mapSendInfo.put("ccmNo", ccmNo);
+			mapSendInfo.put("heatNo", heatNo);
+
+			// 执行MQTT推送,设置合理的超时时间
+			MqttClientUtil mqttClientUtilBe = new MqttClientUtil();
+			mqttClientUtilBe.pushCData(configMqttMapper, mapSendInfo, TopicType.SYN_PUSHBILLETHOTSEND_NEXTSEND.getTopicValue());
+			log.info("B端传递换炉参数,发送MQTT成功: {}", mapSendInfo);
+		} catch (Exception e) {
+			log.error("B端传递换炉参数,发送MQTT异常!", e);
+		}
+	}
+
+
 	/**
 	 * 6号机高线,吊运单保存
 	 * @param billetLiftingBill

+ 1 - 1
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/push/utils/MqttClientUtil.java

@@ -237,7 +237,7 @@ public class MqttClientUtil implements ApplicationRunner {
         MqttTopic topic = mqttClient.getTopic(topicInfo);
         MqttMessage message = new MqttMessage();
         message.setPayload(JSON.toJSON(map).toString().getBytes());
-        message.setQos(0);
+        message.setQos(2);
         message.setRetained(true);
         if (null == topic) {
             log.error("topic is not exist");

+ 5 - 1
zgzt-sys-java/jeecg-module-conn/src/main/java/org/jeecg/modules/push/utils/TopicType.java

@@ -74,7 +74,11 @@ public enum TopicType {
     /**
      * 回传堆垛被占位置总数
      */
-    SYN_PLACEHOLDER_PASSBACK("syn/placeholderSum/passback");
+    SYN_PLACEHOLDER_PASSBACK("syn/placeholderSum/passback"),
+    /**
+     * 换炉传递参数
+     */
+    SYN_PUSHBILLETHOTSEND_NEXTSEND("syn/pushbillethotsend/nexthosend");
 
     private String topicValue;