Parcourir la source

新增数据发送模块接口

oldwine il y a 4 mois
Parent
commit
0d20902e90
1 fichiers modifiés avec 104 ajouts et 16 suppressions
  1. 104 16
      models/data_sender.py

+ 104 - 16
models/data_sender.py

@@ -9,12 +9,20 @@ class Sender:
         self.topic = {
             'billet_add': 'trace/performance/billet/add',
             'heat_add': 'trace/performance/converter/add',
-            'billet_union': 'trace/billet/billetAssemblyNumber/add'
+            'billet_union': 'trace/billet/billetAssemblyNumber/add',
+            'host_send': 'syn/billetHotsendBase/save',
+            'car_add': 'syn/storageBill/add',
+            'car_save': 'syn/billetHotsendBase/shipp/save',
+            'car_go': 'syn/billetHotsendBase/shipp/save/depart'
         }
 
         self.url = {
             'billet_add': 'http://192.168.0.119:8181/jeecg-boot/actualControl/billetActual/reportRealTimeBilletBasicInfo',
-            'heat_add': 'http://192.168.0.119:8181/jeecg-boot/actualControl/heatsActuals/reportRealTimeHeatsActuals'
+            'heat_add': 'http://192.168.0.119:8181/jeecg-boot/actualControl/heatsActuals/reportRealTimeHeatsActuals',
+            'host_send': '/billetHotsendBase/billetHotsendBase/add',
+            'car_add': '/storageBill/add',
+            'car_save': '/billetHotsendBase/billetHotsendBase/add',
+            'car_go': '/billetHotsendBase/billetHotsendBase/rodLineDepart'
         }
 
         self.heat_tangible_temp = {
@@ -68,6 +76,37 @@ class Sender:
             "billetWeight": 0       # 钢坯坯重  double高精度数值类型
         }
 
+        self.host_send_temp = {
+            "ccmNo": "",
+            "billetNos": "",
+            "billetHotsendTypeConfigId": "",
+            "vehicleNumber": "",
+            "liftingTime": "",
+            "location": ""
+        }
+
+        self.car_add_temp = {
+            "ccmNo": "",
+            "licensePlate": "",
+            "billetHotsendTypeConfigId": "",
+            "positionNum": ""
+        }
+
+        self.car_save_temp = {
+            "ccmNo": "",
+            "billetNos": "",
+            "billetHotsendTypeConfigId": "",
+            "licensePlate": "",
+            "vehicleNumber": "",
+            "liftingTime": "",
+            "location": ""
+        }
+
+        self.car_go_temp = {
+            "ccmNo": "",
+            "licensePlate": ""
+        }
+
         self.mqtt_cli = None
         self.http_flag = True
         self._cache = {}
@@ -231,25 +270,74 @@ class Sender:
         #此处应存储进数据库
         self.send('billet_union', tmp)
 
+    def host_send(self, ccmNo, billetNos, dst_str, craneNo = ""):
+        tmp = self.host_send_temp.copy()
+        
+        tmp['ccmNo'] = ccmNo
+        tmp['billetNos'] = ','.join(billetNos) if isinstance(billetNos, list) else billetNos
+        tmp['billetHotsendTypeConfigId'] = "1" if dst_str == "棒一" else "15"
+        tmp['liftingTime'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
+        tmp['vehicleNumber'] = craneNo
+        tmp['location'] = "6#热送辊道" if dst_str == "高线" else ""
+
+        #此处应存储进数据库
+        self.send('host_send', tmp)
+
+    def car_add(self, ccmNo, carNo, plate: str):
+        tmp = self.car_add_temp.copy()
+        
+        tmp['ccmNo'] = ccmNo
+        tmp['billetHotsendTypeConfigId'] = "16" if plate.startswith("陕E") else ""
+        tmp['licensePlate'] = plate
+        tmp['positionNum'] = carNo
+
+        #此处应存储进数据库
+        self.send('car_add', tmp)
+
+    def car_save(self, ccmNo, billetNos, plate, craneNo, Ltime):
+        tmp = self.car_save_temp.copy()
+        
+        tmp['ccmNo'] = ccmNo
+        tmp['billetNos'] = ','.join(billetNos) if isinstance(billetNos, list) else billetNos
+        tmp['billetHotsendTypeConfigId'] = "16" if plate.startswith("陕E") else ""
+        tmp['licensePlate'] = plate
+        tmp['vehicleNumber'] = craneNo
+        tmp['liftingTime'] = Ltime
+        tmp['location'] = '装车'
+
+        #此处应存储进数据库
+        self.send('car_save', tmp)
+
+    def car_go(self, ccmNo, plate):
+        tmp = self.car_go_temp.copy()
+        
+        tmp['ccmNo'] = ccmNo
+        tmp['licensePlate'] = plate
+
+        #此处应存储进数据库
+        self.send('car_go', tmp)
+
+
 if __name__ == '__main__':
+    import logging
+
+    logger = logging.getLogger(__name__)
+    logger.setLevel(level = logging.DEBUG)
+    formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+
+    console = logging.StreamHandler()
+    console.setLevel(logging.DEBUG)
+    logger.addHandler(console)
+
     mqttcli = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, 'python-mqtt-992-sender_test')
     mqttcli.username_pw_set('admin', '123456')
     mqttcli.connect('192.168.0.119', 1883)
     mqttcli.loop_start()
-    test = Sender()
+    test = Sender(logger)
     test.set_mqtt_client(mqttcli)
+    test.http_flag = False
 
-    testheat = {"netWeight":140.06,"ladleNo":"13","heatNo":"24617099","grade":"微氮铌钢","castState":1,"spec":"上若泰基","ccmNo":"6","sendTime":"2024-11-28 12:57:09"}
-    test.begin_pour(testheat, 210.0)
-    time.sleep(1)
-    test.heat_first(testheat)
-
-    time.sleep(1)
-    test.begin_cut(testheat, "246170996301", 5, 11000, 2.85)
-    time.sleep(1)
-    test.end_cut(testheat, 5)
+    testheat = {"netWeight":140.06,"ladleNo":"13","heatNo":"25501045","grade":"微氮铌钢","castState":1,"spec":"上若泰基","ccmNo":"5","sendTime":"2025-01-20 09:44:17"}
+    test.host_send("5", "255010455107", "棒一")
 
-    time.sleep(1)
-    test.end_pour({"netWeight":0.0,"ladleNo":"","heatNo":"24617099","grade":"微氮铌钢","castState":0,"spec":"上若泰基","ccmNo":"6","sendTime":"2024-11-28 13:21:20"})
-    time.sleep(1)
-    test.heat_last(testheat)
+    test.host_send("6", ["256009976601","256009976701","256009976801","256009976602"], "高线", "A2")