Quellcode durchsuchen

陆运 添加设备状态和当前温度

qukaidi vor 6 Tagen
Ursprung
Commit
15c62d786f

+ 74 - 43
src/components/trackPlayback.vue

@@ -1,22 +1,23 @@
 <template>
   <el-dialog
-      title="车辆轨迹"
-      append-to-body
-      custom-class="dialog_two"
-      :visible.sync="dialogVisible"
-      lock-scroll
-      :before-close="handleClose"
-      width="80%">
+    title="车辆轨迹"
+    append-to-body
+    custom-class="dialog_two"
+    :visible.sync="dialogVisible"
+    lock-scroll
+    :before-close="handleClose"
+    width="80%"
+  >
     <div id="container" v-if="dialogVisible"></div>
-    <div class="input-card" style="right: 10.3%;bottom: 10.3%" v-if="this.lineArr.length>0">
+    <div class="input-card" style="right: 10.3%;bottom: 10.3%" v-if="this.lineArr.length > 0">
       <h4>轨迹回放控制</h4>
       <div class="input-item">
-        <input type="button" class="btn" value="开始动画" id="start" @click="startAnimation()"/>
-        <input type="button" class="btn" value="暂停动画" id="pause" @click="pauseAnimation()"/>
+        <input type="button" class="btn" value="开始动画" id="start" @click="startAnimation()" />
+        <input type="button" class="btn" value="暂停动画" id="pause" @click="pauseAnimation()" />
       </div>
       <div class="input-item">
-        <input type="button" class="btn" value="继续动画" id="resume" @click="resumeAnimation()"/>
-        <input type="button" class="btn" value="停止动画" id="stop" @click="stopAnimation()"/>
+        <input type="button" class="btn" value="继续动画" id="resume" @click="resumeAnimation()" />
+        <input type="button" class="btn" value="停止动画" id="stop" @click="stopAnimation()" />
       </div>
     </div>
     <div class="input-card" style="right: 10.3%;bottom: 10.3%" v-else>
@@ -26,6 +27,7 @@
 </template>
 
 <script>
+import {dateFormat} from "@/util/date";
 export default {
   name: "trackPlayback",
   props: {
@@ -35,33 +37,34 @@ export default {
     parkingPoint: {
       type: Boolean
     },
-    lineArr:Object,
+    lineArr: Object
   },
-  data(){
-    return{
+  data() {
+    return {
       map: null,
       marker: null,
       infoWindow: null
-    }
+    };
   },
   beforeDestroy() {
     this.map && this.map.destroy();
   },
-  methods:{
+  methods: {
     handleClose(done) {
-      this.dialogVisible = false
-      this.$emit('closeDialog')
+      this.dialogVisible = false;
+      this.$emit("closeDialog");
     },
-    initMap() {
+    initMap(carData) {
+      let isCar = carData ? true : false;
       this.map = new AMap.Map("container", {
         resizeEnable: true,
-        center: this.lineArr.length >0 ?this.lineArr[this.lineArr.length - 1]:[120.382891,36.066460],
+        center: this.lineArr.length > 0 ? this.lineArr[this.lineArr.length - 1] : [120.382891, 36.06646],
         zoom: 17
       });
       let icon = new AMap.Icon({
         size: new AMap.Size(52, 26), // 图标尺寸
-        image: 'http://trade.tubaosoft.com/file/bladex/000000/1123598821738675201/che.png',
-        imageSize: new AMap.Size(52, 26), // 根据所设置的大小拉伸或压缩图片
+        image: "http://trade.tubaosoft.com/file/bladex/000000/1123598821738675201/che.png",
+        imageSize: new AMap.Size(52, 26) // 根据所设置的大小拉伸或压缩图片
       });
       // 绘制轨迹
       let polyline = new AMap.Polyline({
@@ -81,7 +84,7 @@ export default {
         strokeWeight: 6 //线宽
         // strokeStyle: "solid"  //线样式
       });
-      if (this.parkingPoint.length>0){
+      if (this.parkingPoint.length > 0) {
         this.infoWindow = new AMap.InfoWindow({
           offset: new AMap.Pixel(0, -30)
         });
@@ -90,19 +93,47 @@ export default {
             position: this.parkingPoint[i].location,
             map: this.map
           });
-          let fun = this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete)==='获取失败'?'':this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete)
-          this.marker.content = '<div style="width: 300px;">'
-              + '<p style="font-size: 22px;font-weight: bold;background-color: #2d8cf0;color: #fff;">' + fun + '</p>'
-              + '<p style="padding: 5px 0"><span style="color: #a0a0a0">停车时间:</span>' + (new Date(Number(this.parkingPoint[i].bte) + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ').substr(0, 19)).slice(5,19)+'至'+ (new Date(Number(this.parkingPoint[i].ete) + 8 * 60 * 60 * 1000).toJSON().split('T').join(' ').substr(0, 19)).slice(5,19)+ '</p>'
-              + '<p><span style="color: #a0a0a0">当前位置:</span>' +this.parkingPoint[i].address + '</p>'
-              + '</div>'
-          this.marker.on('click', this.markerClick);
-          this.marker.emit('click', {target: this.marker});
+          let fun =
+            this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete) === "获取失败"
+              ? ""
+              : this.fun(this.parkingPoint[i].bte, this.parkingPoint[i].ete);
+          this.marker.content =
+            '<div style="width: 300px;">' +
+            '<p style="font-size: 22px;font-weight: bold;background-color: #2d8cf0;color: #fff;">' +
+            fun +
+            "</p>" +
+            '<p style="padding: 5px 0"><span style="color: #a0a0a0">停车时间:</span>' +
+            new Date(Number(this.parkingPoint[i].bte) + 8 * 60 * 60 * 1000)
+              .toJSON()
+              .split("T")
+              .join(" ")
+              .substr(0, 19)
+              .slice(5, 19) +
+            "至" +
+            new Date(Number(this.parkingPoint[i].ete) + 8 * 60 * 60 * 1000)
+              .toJSON()
+              .split("T")
+              .join(" ")
+              .substr(0, 19)
+              .slice(5, 19) +
+            "</p>" +
+            '<p><span style="color: #a0a0a0">当前位置:</span>' +
+            this.parkingPoint[i].address +
+            "</p>" +
+            '<p><span style="color: #a0a0a0">设备状态:</span>' +
+            (isCar ? (carData.is_online ? '<span style="color: #67C23A">在线</span>' : '<span style="color: #F56C6C">离线</span>') : "暂无设备") +
+            "</p>" +
+            '<span style="color: #a0a0a0">当前温度:</span><span style="color: #F56C6C">' +
+            (isCar ? carData.wd?carData.wd + "℃ " +dateFormat(new Date(carData.ts*1000)):'暂无温度': "暂无设备") + 
+            "</span>" +
+            "</div>";
+          this.marker.on("click", this.markerClick);
+          this.marker.emit("click", { target: this.marker });
         }
       }
       this.marker = new AMap.Marker({
         map: this.map,
-        position: this.lineArr.length >0 ?this.lineArr[this.lineArr.length - 1]:[120.382891,36.066460],
+        position: this.lineArr.length > 0 ? this.lineArr[this.lineArr.length - 1] : [120.382891, 36.06646],
         // icon: "https://webapi.amap.com/images/car.png",
         icon: icon,
         markerMeta: new AMap.Size(28, 28),
@@ -112,17 +143,17 @@ export default {
       });
       this.map.setFitView();
     },
-    fun(startTime,endTime) {
+    fun(startTime, endTime) {
       let usedTime = endTime - startTime; // 相差的毫秒数
       let days = Math.floor(usedTime / (24 * 3600 * 1000)); // 计算出天数
       let leavel = usedTime % (24 * 3600 * 1000); // 计算天数后剩余的时间
       let hours = Math.floor(leavel / (3600 * 1000)); // 计算剩余的小时数
       let leavel2 = leavel % (3600 * 1000); // 计算剩余小时后剩余的毫秒数
       let minutes = Math.floor(leavel2 / (60 * 1000)); // 计算剩余的分钟数
-      if (startTime && endTime){
-        return  days + '天' + hours + '时' + minutes + '分'
-      }else {
-        return '获取失败'
+      if (startTime && endTime) {
+        return days + "天" + hours + "时" + minutes + "分";
+      } else {
+        return "获取失败";
       }
     },
     markerClick(e) {
@@ -140,9 +171,9 @@ export default {
     },
     stopAnimation() {
       this.marker.stopMove();
-    },
+    }
   }
-}
+};
 </script>
 
 <style scoped src="../styles/demo-center.css"></style>
@@ -195,11 +226,11 @@ export default {
   padding: 0 20px 10px 20px !important;
 }
 
-::v-deep .amap-info-close{
-  right: 10px!important;
+::v-deep .amap-info-close {
+  right: 10px !important;
   top: 12px !important;
 }
-::v-deep .amap-info-content{
+::v-deep .amap-info-content {
   padding: 5px 5px 5px 5px !important;
 }
 </style>

+ 12 - 9
src/views/iosBasicData/PaymentApplication/finstlbillsDetails.vue

@@ -962,6 +962,7 @@ export default {
         this.form.businessType = "FFSQ"; // 结算单
         this.form.businessTypes = this.form.businessTypes ? this.form.businessTypes.join(",") : ""; // 业务类型
         this.form.feeCnName = this.form.feeCnName ? this.form.feeCnName.join(",") : "";
+        console.log(this.form);
         this.saveLoading = true; // 打开按钮动画
         if (this.form.id) {
           if (type == "选定行") {
@@ -1005,16 +1006,16 @@ export default {
         // 判断是直接保存还是提交申请
         if (type == "申请") {
           if (this.auditing == 1) {
-              for (let [index, row] of this.tableData.entries()) {
-                if (row.feeCnName == "增值税") {
-                  if (!row.taxInvoiceNumber || !row.taxInvoiceDate || !row.deductionTime) {
-                    this.pageLoading = false;
-                    this.saveLoading = false;
-                    return this.$message.error("第" + Number(index + 1) + "行费用为增值税,请完善税票号、税票日期、扣款时间");
-                  }
+            for (let [index, row] of this.tableData.entries()) {
+              if (row.feeCnName == "增值税") {
+                if (!row.taxInvoiceNumber || !row.taxInvoiceDate || !row.deductionTime) {
+                  this.pageLoading = false;
+                  this.saveLoading = false;
+                  return this.$message.error("第" + Number(index + 1) + "行费用为增值税,请完善税票号、税票日期、扣款时间");
                 }
               }
             }
+          }
           finstlbillsSubmit(this.form)
             .then(res => {
               this.form = res.data.data;
@@ -1307,7 +1308,7 @@ export default {
     },
     // 结算确认
     settlementApprovefun() {
-      this.form.businessTypes = this.form.businessTypes ? this.form.businessTypes.join(",") : ""; // 业务类型
+      this.form.auditDateTo = this.form.auditDateTo ? this.form.auditDateTo.slice(0, 10) + " 00:00:00" : null;
       this.form.businessDateStart = this.form.businessDateStart ? this.form.businessDateStart.slice(0, 10) + " 00:00:00" : null; // 财务开始日期
       this.form.businessDateEnd = this.form.businessDateEnd ? this.form.businessDateEnd.slice(0, 10) + " 00:00:00" : null; // 财务开始日期
       this.form.estimatedTime = this.form.estimatedTime ? this.form.estimatedTime.slice(0, 10) + " 00:00:00" : null;
@@ -1315,6 +1316,7 @@ export default {
       (this.form.url = "/iosBasicData/PaymentApplication/index"), (this.form.pageStatus = "this.$store.getters.paidapplication");
       this.form.pageLabel = "付费申请(F)";
 
+      this.form.businessTypes = this.form.businessTypes ? this.form.businessTypes.join(",") : ""; // 业务类型
       this.pageLoading = true;
       settlementApprove(this.form)
         .then(res => {
@@ -1334,12 +1336,13 @@ export default {
         cancelButtonText: "取消",
         type: "warning"
       }).then(() => {
-        this.form.businessTypes = this.form.businessTypes ? this.form.businessTypes.join(",") : ""; // 业务类型
+        this.form.auditDateTo = this.form.auditDateTo ? this.form.auditDateTo.slice(0, 10) + " 00:00:00" : null;
         this.form.feeCnName = this.form.feeCnName ? this.form.feeCnName.join(",") : "";
         this.form.businessDateStart = this.form.businessDateStart ? this.form.businessDateStart.slice(0, 10) + " 00:00:00" : null; // 财务开始日期
         this.form.businessDateEnd = this.form.businessDateEnd ? this.form.businessDateEnd.slice(0, 10) + " 00:00:00" : null; // 财务开始日期
         this.form.estimatedTime = this.form.estimatedTime ? this.form.estimatedTime.slice(0, 10) + " 00:00:00" : null;
         this.form.billDate = this.form.billDate ? this.form.billDate.slice(0, 10) + " 00:00:00" : null;
+        this.form.businessTypes = this.form.businessTypes ? this.form.businessTypes.join(",") : ""; // 业务类型
         revokeSettlementApprove(this.form)
           .then(res => {
             this.$message.success("操作成功");

+ 90 - 5
src/views/landTransportation/bulkCargo/detailPage.vue

@@ -1042,6 +1042,14 @@ import { getDictionary } from "@/api/system/dictbiz";
 import { allCropList, customerList } from "@/api/basicData/customerInformation";
 import { contrastList, contrastObj } from "@/util/contrastData";
 import { isProcurement } from "@/api/basicData/configuration";
+import { getCarList } from "@/api/landTransportation/car";
+import { dateFormat } from "@/util/date";
+import axios from "axios";
+const gizwitsHttp = axios.create({
+  timeout: 30000,
+  withCredentials: false,
+  headers: { "Content-Type": "application/json" }
+});
 // goodsOptionFormTwo
 export default {
   comments: {
@@ -1132,10 +1140,11 @@ export default {
   },
   data() {
     return {
+      token: null,
       returnButton: Boolean,
       dialogVisible: false,
       dialogVisible2: false,
-      
+
       map: null,
       infoWindow: null,
       marker: null,
@@ -2434,10 +2443,11 @@ export default {
           }
         ]
       },
-      isMap:false,
+      isMap: false
     };
   },
   async created() {
+    this.getToken();
     if (this.roleName2 == "平台,调度派单") {
       this.findObject(this.goodsOptionForm.column, "unitPrice").display = false;
       this.findObject(this.goodsOptionForm.column, "freightCollect").display = false;
@@ -2717,6 +2727,19 @@ export default {
     // this.$refs.other.show = false
   },
   methods: {
+    getToken() {
+      gizwitsHttp({
+        url: "/enterprise-gizwits/v1/products/69740dade7f14816a1bc77b3e0cc4595/access_token",
+        method: "POST",
+        data: {
+          enterprise_id: "53e44ae3bfdd4e92990128c8a6e0dd0e",
+          enterprise_secret: "0b9697a953e74aed88938b6373b92865",
+          product_secret: "187e384cce504202ac4e79d1fda85d34"
+        }
+      }).then(res => {
+        this.token = res.data.token;
+      });
+    },
     //单车运费计算
     calculateFreight(data) {
       if (this.goodsForm.pricingUnit && this.goodsForm.loadingUnloading && this.goodsForm.unitPrice) {
@@ -2786,20 +2809,75 @@ export default {
     },
 
     openTrack2(row) {
+      this.getDeviceDetail(row);
+    },
+    getDeviceDetail(row) {
+      getCarList({ plateNo: row.plateNo }).then(res => {
+        if (res.data.data.records.length) {
+          if (res.data.data.records[0].gpsId) {
+            gizwitsHttp({
+              url: "/enterprise-gizwits/v1/products/69740dade7f14816a1bc77b3e0cc4595/device_detail",
+              method: "GET",
+              headers: {
+                Authorization: `token ${this.token}`
+              },
+              params: {
+                mac: res.data.data.records[0].gpsId
+              }
+            }).then(res => {
+              this.getDeviceData(row, { ...res.data });
+            });
+          } else {
+            this.openMap(row);
+          }
+        }
+      });
+    },
+    getDeviceData(row, data) {
+      let now = new Date();
+      now.setMinutes(now.getMinutes() - 2);
+      // console.log(now.getTime(),1777533068)
+      gizwitsHttp({
+        url: `/enterprise-gizwits/v1/products/69740dade7f14816a1bc77b3e0cc4595/devices/${data.did}/data`,
+        method: "GET",
+        headers: {
+          Authorization: `token ${this.token}`
+        },
+        params: {
+          end_ts: Math.floor(now.getTime() / 1000)
+        }
+      }).then(res => {
+        let list = [];
+        for (let item of res.data.objects) {
+          if (item.attrs.rtn_temp_iot) {
+            list.push({
+              wd: item.attrs.rtn_temp_iot,
+              ts: item.ts
+            });
+          }
+        }
+        if (list.length) {
+          this.openMap(row, { ...data, ...list[0] });
+        } else {
+          this.openMap(row, data);
+        }
+      });
+    },
+    openMap(row, carData) {
       location({ plateNo: row.plateNo, tenantId: "234557", color: "2" }).then(res => {
         this.dialogVisible2 = true;
         let this_ = this;
         setTimeout(function() {
-          this_.initMap(res.data.data, row.plateNo);
+          this_.initMap(res.data.data, row.plateNo, carData);
         }, 1000);
       });
     },
-    
     markerClick(e) {
       this.infoWindow.setContent(e.target.content);
       this.infoWindow.open(this.map, e.target.getPosition());
     },
-    initMap(data, plateNo) {
+    initMap(data, plateNo, carData) {
+      let isCar = carData ? true : false;
       this.map = null;
       this.map = new AMap.Map("container", { resizeEnable: true });
       this.infoWindow = new AMap.InfoWindow({
@@ -2848,6 +2926,13 @@ export default {
         '<p style="padding: 5px 0"><span style="color: #a0a0a0">经纬度:</span>' +
         data.location.join(",") +
         "</p>" +
+        
+        '<p><span style="color: #a0a0a0">设备状态:</span>' +
+        (isCar ? (carData.is_online ? '<span style="color: #67C23A">在线</span>' : '<span style="color: #F56C6C">离线</span>') : "暂无设备") +
+        "</p>" +
+        '<span style="color: #a0a0a0">当前温度:</span><span style="color: #F56C6C">' +
+        (isCar ? (carData.wd ? carData.wd + "℃ " + dateFormat(new Date(carData.ts * 1000)) : "暂无温度") : "暂无设备") +
+        "</span>" +
         "</div>";
       this.infoWindow.open(this.map, this.map.getCenter());
       this.marker.on("click", this.markerClick);

+ 89 - 4
src/views/landTransportation/bulkCargo/index.vue

@@ -371,6 +371,14 @@ import { gaude, location } from "@/api/gaude";
 import { customerList, fleetList } from "@/api/basicData/customerInformation";
 import { defaultDate } from "@/util/date";
 import { isProcurement } from "@/api/basicData/configuration";
+import { getCarList } from "@/api/landTransportation/car";
+import {dateFormat} from "@/util/date";
+import axios from "axios";
+const gizwitsHttp = axios.create({
+  timeout: 30000,
+  withCredentials: false,
+  headers: { "Content-Type": "application/json" }
+});
 export default {
   name: "index",
   components: {
@@ -392,6 +400,7 @@ export default {
   },
   data() {
     return {
+      token:null,
       id: "",
       map: null,
       infoWindow: null,
@@ -1278,7 +1287,7 @@ export default {
       home: false,
       entrustTimer: null,
       roleName: localStorage.getItem("roleName").split(","),
-      isMap:false,
+      isMap: false
     };
   },
 
@@ -1296,6 +1305,7 @@ export default {
     // this.option = this.optionListOne
     // this.option = this.optionListTwo
     // this.option = this.optionListThree
+    this.getToken();
     this.query = {
       arrivalTime: [defaultDate(4)[0] + " 00:00:00", defaultDate(4)[1] + " 23:59:59"]
     };
@@ -1312,7 +1322,7 @@ export default {
       this.activeName = "3";
       this.optionList = this.optionListFour;
     }
-    
+
     isProcurement({ param: "is.map" }).then(res => {
       if (res.data.data == 1) {
         this.isMap = true;
@@ -1362,12 +1372,80 @@ export default {
     clearInterval(this.entrustTimer); //关闭
   },
   methods: {
+    getToken() {
+      gizwitsHttp({
+        url: "/enterprise-gizwits/v1/products/69740dade7f14816a1bc77b3e0cc4595/access_token",
+        method: "POST",
+        data: {
+          enterprise_id: "53e44ae3bfdd4e92990128c8a6e0dd0e",
+          enterprise_secret: "0b9697a953e74aed88938b6373b92865",
+          product_secret: "187e384cce504202ac4e79d1fda85d34"
+        }
+      }).then(res => {
+        this.token = res.data.token;
+      });
+    },
     openTrack(row) {
+      this.getDeviceDetail(row);
+    },
+    getDeviceDetail(row) {
+      getCarList({ plateNo: row.plateNo }).then(res => {
+        if (res.data.data.records.length) {
+          if (res.data.data.records[0].gpsId) {
+            gizwitsHttp({
+              url: "/enterprise-gizwits/v1/products/69740dade7f14816a1bc77b3e0cc4595/device_detail",
+              method: "GET",
+              headers: {
+                Authorization: `token ${this.token}`
+              },
+              params: {
+                mac: res.data.data.records[0].gpsId
+              }
+            }).then(res => {
+              this.getDeviceData(row, { ...res.data });
+            });
+          } else {
+            this.openMap(row);
+          }
+        }
+      });
+    },
+    getDeviceData(row, data) {
+      let now = new Date();
+      now.setMinutes(now.getMinutes() - 2);
+      // console.log(now.getTime(),1777533068)
+      gizwitsHttp({
+        url: `/enterprise-gizwits/v1/products/69740dade7f14816a1bc77b3e0cc4595/devices/${data.did}/data`,
+        method: "GET",
+        headers: {
+          Authorization: `token ${this.token}`
+        },
+        params: {
+          end_ts: Math.floor(now.getTime() / 1000)
+        }
+      }).then(res => {
+        let list = [];
+        for (let item of res.data.objects) {
+          if (item.attrs.rtn_temp_iot) {
+            list.push({
+              wd: item.attrs.rtn_temp_iot,
+              ts: item.ts
+            });
+          }
+        }
+        if (list.length) {
+          this.openMap(row, { ...data, ...list[0] });
+        } else {
+          this.openMap(row, data);
+        }
+      });
+    },
+    openMap(row, carData) {
       location({ itemId: row.itemId, plateNo: row.plateNo, tenantId: "234557", color: "2" }).then(res => {
         this.dialogVisible = true;
         let this_ = this;
         setTimeout(function() {
-          this_.initMap(res.data.data, row.plateNo);
+          this_.initMap(res.data.data, row.plateNo, carData);
         }, 1000);
       });
     },
@@ -1375,7 +1453,8 @@ export default {
       this.infoWindow.setContent(e.target.content);
       this.infoWindow.open(this.map, e.target.getPosition());
     },
-    initMap(data, plateNo) {
+    initMap(data, plateNo, carData) {
+      let isCar = carData ? true : false;
       this.map = null;
       this.map = new AMap.Map("container", { resizeEnable: true });
       this.infoWindow = new AMap.InfoWindow({
@@ -1424,6 +1503,12 @@ export default {
         '<p style="padding: 5px 0"><span style="color: #a0a0a0">经纬度:</span>' +
         data.location.join(",") +
         "</p>" +
+        '<p><span style="color: #a0a0a0">设备状态:</span>' +
+        (isCar ? (carData.is_online ? '<span style="color: #67C23A">在线</span>' : '<span style="color: #F56C6C">离线</span>') : "暂无设备") +
+        "</p>" +
+        '<span style="color: #a0a0a0">当前温度:</span><span style="color: #F56C6C">' +
+        (isCar ? (carData.wd ? carData.wd + "℃ " + dateFormat(new Date(carData.ts * 1000)) : "暂无温度") : "暂无设备") +
+        "</span>" +
         "</div>";
       this.infoWindow.open(this.map, this.map.getCenter());
       this.marker.on("click", this.markerClick);

Datei-Diff unterdrückt, da er zu groß ist
+ 606 - 539
src/views/landTransportation/bulkReportAnalysis/index.vue


Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden.