ソースを参照

Merge remote-tracking branch 'origin/master'

wangchao 4 年 前
コミット
ef9e1ad29b

+ 1 - 0
ebc-middle-platform/src/conf/services.js

@ -194,6 +194,7 @@ export default {
194 194
    GET_WORK_EMPLOYEE: '/workEmployee/queryWorkEmployee', // 查询人员信息
195 195
    GET_ALL_ORGANIZE: '/workEmployee/queryAllOrganize', // 查询部门信息
196 196
    ADD_WORK_EMPLOYEE: '/workEmployee/createWorkEmployee', // 新增人员信息
197
    DEL_WORK_EMPLOYEE: '/workEmployee/deleteWorkEmployee', // 删除人员信息
197 198
    UPD_WORK_EMPLOYEE: '/workEmployee/modifyWorkEmployee' // 修改人员信息
198 199
  }
199 200
}

+ 43 - 19
ebc-middle-platform/src/modules/system-management/equipment-management.vue

@ -75,14 +75,11 @@
75 75
            <t-option v-for="(item,index) in typeList" :value="item.resourceToolType" :key="index+'type'">{{ item.name }}</t-option>
76 76
          </t-select>
77 77
        </t-form-item>
78
        <t-form-item label="设备名称" prop="name">
79
          <t-input v-model="formValidate.name" placeholder="请输入设备名称"></t-input>
80
        </t-form-item>
81 78
        <t-form-item label="设备编号" prop="number">
82 79
          <t-input v-model="formValidate.number" placeholder="请输入字母、数字、中划线、下划线、#"></t-input>
83 80
        </t-form-item>
84
        <t-form-item label="半径" prop="radius">
85
          <t-input v-model="formValidate.radius" placeholder="请输入设备名称"></t-input>
81
        <t-form-item label="设备名称" prop="name">
82
          <t-input v-model="formValidate.name" placeholder="请输入设备名称"></t-input>
86 83
        </t-form-item>
87 84
        <div v-if="formValidate.type!=='001'">
88 85
          <t-form-item label="经度" prop="lng">
@ -94,6 +91,9 @@
94 91
            <t-format-input v-model="formValidate.lat" :numeral-decimal-scale="8" numeral placeholder="请输入数字"></t-format-input>
95 92
          </t-form-item>
96 93
        </div>
94
        <t-form-item label="半径" prop="radius">
95
          <t-input v-model="formValidate.radius" placeholder="请输入半径"></t-input>
96
        </t-form-item>
97 97
      </t-form>
98 98
      <div slot="footer">
99 99
        <t-button @click="cancel">取消</t-button>
@ -111,9 +111,6 @@
111 111
        <t-form-item label="设备名称" prop="resourceToolName">
112 112
          <t-input v-model="updateRow.resourceToolName" placeholder="请输入设备名称"></t-input>
113 113
        </t-form-item>
114
        <t-form-item label="半径" prop="radius">
115
          <t-input v-model="updateRow.radius" numeral placeholder="请输入设备半径"></t-input>
116
        </t-form-item>
117 114
        <div v-if="updateRow.resourceToolType!=='001'">
118 115
          <t-form-item label="经度" prop="longitude">
119 116
            <t-format-input v-model="updateRow.longitude" :numeral-decimal-scale="8" numeral placeholder="请输入数字"></t-format-input>
@ -124,6 +121,9 @@
124 121
            <t-format-input v-model="updateRow.latitude" :numeral-decimal-scale="8" numeral placeholder="请输入数字"></t-format-input>
125 122
          </t-form-item>
126 123
        </div>
124
        <t-form-item label="半径" prop="radius">
125
          <t-input v-model="updateRow.radius" numeral placeholder="请输入半径"></t-input>
126
        </t-form-item>
127 127
      </t-form>
128 128
      <div slot="footer">
129 129
        <t-button @click="cancel">取消</t-button>
@ -237,6 +237,11 @@ export default {
237 237
        ],
238 238
        radius: [
239 239
          {
240
            required: true,
241
            message: '半径不能为空',
242
            trigger: 'blur'
243
          },
244
          {
240 245
            message: '请输入数字',
241 246
            trigger: 'blur',
242 247
            validator: function(rule, value, callback) {
@ -322,6 +327,11 @@ export default {
322 327
        ],
323 328
        radius: [
324 329
          {
330
            required: true,
331
            message: '半径不能为空',
332
            trigger: 'blur'
333
          },
334
          {
325 335
            message: '请输入数字',
326 336
            trigger: 'blur',
327 337
            validator: function(rule, value, callback) {
@ -379,11 +389,11 @@ export default {
379 389
  },
380 390
  methods: {
381 391
    async getType() {
382
      this.fullLoading = true
392
      // this.fullLoading = true
383 393
      await this.$test.post(services.equipment.EQUIPMENT_TYPE, {}
384 394
      ).then(res => {
385 395
        // 请求成功处理...
386
        this.fullLoading = false
396
        // this.fullLoading = false
387 397
        this.typeList = res.data
388 398
      }).catch(res => {
389 399
        // 请求失败处理...
@ -445,7 +455,7 @@ export default {
445 455
    },
446 456
    checkReptition(data) {
447 457
      return new Promise((resolve) => {
448
        this.fullLoading = true
458
        // this.fullLoading = true
449 459
        this.$test.post(services.equipment.GET_EQUIPMENT, {
450 460
          pageNumber: 1,
451 461
          pageSize: 10,
@ -453,7 +463,7 @@ export default {
453 463
        }
454 464
        ).then(res => {
455 465
        // 请求成功处理...
456
          this.fullLoading = false
466
        //   this.fullLoading = false
457 467
          console.log(res)
458 468
          if (res.data.totalPage > 0 && res.data.data[0].resourceToolId === this.updateRow.resourceToolId) {
459 469
            resolve(false)
@ -476,6 +486,8 @@ export default {
476 486
      this.getList()
477 487
    },
478 488
    cancel() {
489
      this.$refs['formValidate'].resetFields()
490
      this.$refs['updateRow'].resetFields()
479 491
      this.modal = false
480 492
      this.updateModal = false
481 493
      this.formValidate = {
@ -552,15 +564,27 @@ export default {
552 564
    },
553 565
    handleClick(row) {
554 566
      this.updateModal = true
555
      console.log(row)
556
      var name
557
      this.typeList.forEach(element => {
558
        if (element.resourceToolType === row.resourceToolType) {
559
          name = element.name
567
      this.$test.post(services.equipment.GET_EQUIPMENT, {
568
        pageNumber: 1,
569
        pageSize: 1,
570
        data: {
571
          resourceToolType: '',
572
          resourceToolNameAsLike: '',
573
          resourceToolCode: row.resourceToolCode
560 574
        }
575
      }).then(res => {
576
        // 请求成功处理...
577
        this.updateRow = res.data.data[0]
578
        var name
579
        this.typeList.forEach(element => {
580
          if (element.resourceToolType === this.updateRow.resourceToolType) {
581
            name = element.name
582
          }
583
        })
584
        this.updateRow.name = name
585
      }).catch(res => {
586
        // 请求失败处理...
561 587
      })
562
      row.name = name
563
      this.updateRow = row
564 588
    },
565 589
    remove(row) {
566 590
      this.delete([row.resourceToolId])

+ 5 - 29
ebc-middle-platform/src/modules/system-management/map-mark.vue

@ -150,22 +150,6 @@
150 150
        <div class="left">
151 151
          <div class="header">
152 152
            <div>坐标列表</div>
153
            <div class="import-down">
154
              <a href="javascript:void(0)" size="sm" @click="handleFile1()"
155
              >导入</a
156
              >
157
              <input
158
                id="file"
159
                type="file"
160
                accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
161
                style="display: none"
162
                @change="handleFile($event)"
163
              />
164
              <span class="mod-line">|</span>
165
              <a href="javascript:void(0)" size="sm" @click="downloadTemplate()"
166
              >下载模板</a
167
              >
168
            </div>
169 153
          </div>
170 154
          <div>
171 155
            <t-table :data="modalData" size="sm" height="500">
@ -194,10 +178,9 @@
194 178
            <div>
195 179
              2、可编辑坐标列表中的经纬度值调整对应点坐标,对应点在地图中处于选中态
196 180
            </div>
197
            <div>3、导入将清空已绘制信息</div>
198 181
          </div>
199 182
        </div>
200
        <div id="modalMap" class="right"></div>
183
        <div id="modalMap" class="right" style = "margin:0 auto;width: 100%;height:500px" ></div>
201 184
      </div>
202 185
    </t-modal>
203 186
    <t-loading v-model="fullLoading" fullscreen tip="加载中...."></t-loading>
@ -266,12 +249,12 @@ export default {
266 249
  },
267 250
  methods: {
268 251
    getDepartmentsList() {
269
      this.fullLoading = true
252
      // this.fullLoading = true
270 253
      this.$test
271 254
        .post(services.workEmployee.GET_ALL_ORGANIZE, {})
272 255
        .then((res) => {
273 256
          // 请求成功处理...
274
          this.fullLoading = false
257
          // this.fullLoading = false
275 258
          this.departments = res.data
276 259
          // this.onReset()
277 260
        })
@ -281,12 +264,12 @@ export default {
281 264
        })
282 265
    },
283 266
    getTagType() {
284
      this.fullLoading = true
267
      // this.fullLoading = true
285 268
      this.$test
286 269
        .post(services.mapTag.MAP_TAG_TYPE, {})
287 270
        .then((res) => {
288 271
          // 请求成功处理...
289
          this.fullLoading = false
272
          // this.fullLoading = false
290 273
          console.log(res)
291 274
          this.markTypes = res.data
292 275
        })
@ -315,7 +298,6 @@ export default {
315 298
      this.polygonDrawer = Ai.DrawPolygon(this.map, options) // 初始化多边形绘制工具
316 299
      this.polygonDrawer.enable() // 激活多边形绘制工具
317 300
      this.map.on(AiDrawEvent.CREATED, (e) => {
318
        // debugger
319 301
        console.log(e)
320 302
        this.layer = this.polygonDrawer.polygon(e) // 获取多边形信息
321 303
        var color
@ -401,7 +383,6 @@ export default {
401 383
        .post(services.excel.EXPROT_MAP_TAG, params)
402 384
        .then((res) => {
403 385
          // 请求成功处理...
404
          // debugger
405 386
          console.log(res)
406 387
          this.downloadDoc(res.data)
407 388
        })
@ -410,7 +391,6 @@ export default {
410 391
        })
411 392
    },
412 393
    downloadDoc(response) {
413
      // debugger
414 394
      var blob = new Blob([response], {
415 395
        type: 'application/vnd.ms-excel;charset=utf-8'
416 396
      })
@ -467,7 +447,6 @@ export default {
467 447
        })
468 448
        return false
469 449
      }
470
      // debugger
471 450
      if (this.markName === '') {
472 451
        this.$Confirm.warning({
473 452
          title: '提示',
@ -649,9 +628,7 @@ export default {
649 628
      var files = e.target.files
650 629
      var f = files[0]
651 630
      var reader = new FileReader()
652
      // debugger
653 631
      reader.onload = function (e) {
654
        // debugger
655 632
        var data = new Uint8Array(e.target.result)
656 633
        var workbook = XLSX.read(data, { type: 'array' })
657 634
        /* DO SOMETHING WITH workbook HERE */
@ -674,7 +651,6 @@ export default {
674 651
          5
675 652
        ) // 地图定位
676 653
        // that.map.center =  []
677
        // debugger
678 654
        coverWktStr_blue = coverWktStr_blue.substring(
679 655
          0,
680 656
          coverWktStr_blue.length - 1

+ 34 - 59
ebc-middle-platform/src/modules/system-management/terminal-management.vue

@ -317,8 +317,8 @@ export default {
317 317
      }).then(res => {
318 318
        // 请求成功处理...
319 319
        this.tableLoading = false
320
        this.table.data = res.data.dataList
321
        this.table.pager.total = res.data.dataNum
320
        this.table.data = res.data.data
321
        this.table.pager.total = res.data.total
322 322
      }).catch(res => {
323 323
        // 请求失败处理...
324 324
        this.tableLoading = false
@ -329,7 +329,7 @@ export default {
329 329
      ).then(res => {
330 330
        // 请求成功处理...
331 331
        this.currentLoading = false
332
        this.itemList[0].goList = res.data.result
332
        this.itemList[0].goList = res.data
333 333
      }).catch(res => {
334 334
        // 请求失败处理...
335 335
      })
@ -337,7 +337,7 @@ export default {
337 337
      ).then(res => {
338 338
        // 请求成功处理...
339 339
        this.currentLoading = false
340
        var arr = res.data.result
340
        var arr = res.data
341 341
        for (let i = 0; i < arr.length; i++) {
342 342
          arr[i].name = arr[i].resourceToolName
343 343
          arr[i].code = arr[i].resourceToolCode
@ -352,7 +352,7 @@ export default {
352 352
      this.$test.post(services.device.GET_DEVICETYPES, {}
353 353
      ).then(res => {
354 354
        // 请求成功处理...
355
        this.deviceTypes = res.data.dataList
355
        this.deviceTypes = res.data
356 356
      }).catch(res => {
357 357
        // 请求失败处理...
358 358
      })
@ -387,12 +387,10 @@ export default {
387 387
          ).then(res => {
388 388
            // 请求成功处理...
389 389
            this.fullLoading = false
390
            if (res.data.result) {
391
              this.relevance = false
392
              this.loading = false
393
              this.$Message.success('提交成功!')
394
              this.getList()
395
            }
390
            this.relevance = false
391
            this.loading = false
392
            this.$Message.success('提交成功!')
393
            this.getList()
396 394
          }).catch(res => {
397 395
            // 请求失败处理...
398 396
            this.loading = false
@ -465,15 +463,12 @@ export default {
465 463
          }).then(res => {
466 464
            // 请求成功处理...
467 465
            that.fullLoading = false
468
            if (res.data.result) {
469
              that.$Message.success('提交成功!')
470
              that.cancel()
471
              that.getList()
472
            } else {
473
              that.$Message.danger(res.data.errMsg)
474
            }
466
            that.$Message.success('提交成功!')
467
            that.cancel()
468
            that.getList()
475 469
          }).catch(res => {
476 470
            // 请求失败处理...
471
            that.fullLoading = false
477 472
          })
478 473
        } else {
479 474
          this.$Message.danger('表单验证失败!')
@ -490,13 +485,9 @@ export default {
490 485
      }).then(res => {
491 486
        // 请求成功处理...
492 487
        this.fullLoading = false
493
        if (res.data.result) {
494
          this.$Message.success('提交成功!')
495
          this.cancel()
496
          this.getList()
497
        } else {
498
          this.$Message.danger(res.data.errMsg)
499
        }
488
        this.$Message.success('提交成功!')
489
        this.cancel()
490
        this.getList()
500 491
      }).catch(res => {
501 492
        // 请求失败处理...
502 493
        this.fullLoading = false
@ -518,12 +509,8 @@ export default {
518 509
            ).then(res => {
519 510
              // 请求成功处理...
520 511
              this.fullLoading = false
521
              if (res.data.result) {
522
                this.$Message.success('解绑成功!')
523
                this.getList()
524
              } else {
525
                this.$Message.danger('解绑失败!')
526
              }
512
              this.$Message.success('解绑成功!')
513
              this.getList()
527 514
            }).catch(res => {
528 515
              // 请求失败处理...
529 516
              this.fullLoading = false
@ -556,12 +543,8 @@ export default {
556 543
            ).then(res => {
557 544
              // 请求成功处理...
558 545
              this.fullLoading = false
559
              if (res.data.result) {
560
                this.$Message.success('解绑成功!')
561
                this.getList()
562
              } else {
563
                this.$Message.danger('解绑失败!')
564
              }
546
              this.$Message.success('解绑成功!')
547
              this.getList()
565 548
            }).catch(res => {
566 549
              // 请求失败处理...
567 550
              this.fullLoading = false
@ -578,14 +561,14 @@ export default {
578 561
      ).then(res => {
579 562
        // 请求成功处理...
580 563
        this.updateModal = true
581
        this.updateFormValidate.number = res.data.resultData.deviceNo
582
        this.updateFormValidate.type = res.data.resultData.deviceTypeName
583
        this.updateFormValidate.typeId = res.data.resultData.deviceTypeId
584
        this.updateFormValidate.id = res.data.resultData.deviceId
585
        if (res.data.resultData.remarks === '无') {
564
        this.updateFormValidate.number = res.data.deviceNo
565
        this.updateFormValidate.type = res.data.deviceTypeName
566
        this.updateFormValidate.typeId = res.data.deviceTypeId
567
        this.updateFormValidate.id = res.data.deviceId
568
        if (res.data.remarks === '无') {
586 569
          this.updateFormValidate.desc = ''
587 570
        } else {
588
          this.updateFormValidate.desc = res.data.resultData.remarks
571
          this.updateFormValidate.desc = res.data.remarks
589 572
        }
590 573
      }).catch(res => {
591 574
        // 请求失败处理...
@ -603,16 +586,16 @@ export default {
603 586
      this.$test.post(services.device.GET_BIND_DEVICE, {deviceId: row.deviceId}
604 587
      ).then(res => {
605 588
        // 请求成功处理...
606
        if (res.data.resultData == null) {
589
        if (res.data == null) {
607 590
          this.relevanceValidate.msgisShow = false
608 591
          this.relevanceValidate.msg = ''
609 592
        } else {
610 593
          this.relevanceValidate.msgisShow = true
611 594
          var name = ''
612
          if (res.data.resultData.bindType === '1') {
613
            name = res.data.resultData.name
595
          if (res.data.bindType === '1') {
596
            name = res.data.name
614 597
          } else {
615
            name = res.data.resultData.resourceToolName
598
            name = res.data.resourceToolName
616 599
          }
617 600
          this.relevanceValidate.msg = '当前终端已关联 ' + name + ' ,点击保存更改关联关系'
618 601
        }
@ -630,12 +613,8 @@ export default {
630 613
          ).then(res => {
631 614
            // 请求成功处理...
632 615
            this.fullLoading = false
633
            if (res.data.result) {
634
              this.$Message.success('操作成功')
635
              this.getList()
636
            } else {
637
              this.$Message.danger(res.data.errMsg)
638
            }
616
            this.$Message.success('操作成功')
617
            this.getList()
639 618
          }).catch(res => {
640 619
            // 请求失败处理...
641 620
            this.fullLoading = false
@ -665,12 +644,8 @@ export default {
665 644
            ).then(res => {
666 645
              // 请求成功处理...
667 646
              this.fullLoading = false
668
              if (res.data.result) {
669
                this.$Message.success('操作成功')
670
                this.getList()
671
              } else {
672
                this.$Message.danger(res.data.errMsg)
673
              }
647
              this.$Message.success('操作成功')
648
              this.getList()
674 649
            }).catch(res => {
675 650
              // 请求失败处理...
676 651
              this.fullLoading = false

+ 259 - 65
ebc-middle-platform/src/modules/system-management/user-management.vue

@ -29,10 +29,10 @@
29 29
            </div>
30 30
          </div>
31 31
          <div class="btns">
32
            <t-button color="secondary" class="reset-btn" @click="onReset">重置</t-button>
33 32
            <t-button color="success" icon="search-outline" @click="onSearch">查询</t-button>
33
            <t-button color="secondary" class="reset-btn" @click="onReset">重置</t-button>
34 34
            <t-button color="secondary" icon="upload-outline" @click="toExport">导出至Excel</t-button>
35
            <t-button color="secondary" icon="delete-outline" @click="toExport">删除</t-button>
35
            <t-button color="secondary" icon="delete-outline" @click="toBatchRemove">删除</t-button>
36 36
          </div>
37 37
        </div>
38 38
      </div>
@ -45,12 +45,12 @@
45 45
      </div>
46 46
    </div>
47 47
    <div>
48
      <t-table :data="table.data" @selection-change="handleSelectionChange">
48
      <t-table :loading="tableLoading" :data="table.data" @selection-change="handleSelectionChange">
49 49
        <t-table-column type="selection" width="70"></t-table-column>
50 50
        <t-table-column prop="name" label="姓名"></t-table-column>
51 51
        <t-table-column prop="code" label="员工编号"></t-table-column>
52 52
        <t-table-column prop="orgName" label="部门"></t-table-column>
53
        <t-table-column prop="mainJobPosition" label="职务"></t-table-column>
53
        <t-table-column :formatter="type_formatter" prop="mainJobPosition" label="职务"></t-table-column>
54 54
        <t-table-column prop="age" label="年龄"></t-table-column>
55 55
        <t-table-column prop="mainWirelessCall" label="手机"></t-table-column>
56 56
        <t-table-column
@ -90,10 +90,8 @@
90 90
          ></t-select-tree>
91 91
        </t-form-item>
92 92
        <t-form-item label="职务" prop="job">
93
          <t-select v-model="formValidate.job" label-in-value placeholder="请选择职务">
94
            <t-option value="1">职务1</t-option>
95
            <t-option value="2">职务2</t-option>
96
            <t-option value="3">职务3</t-option>
93
          <t-select v-model="formValidate.job" placeholder="请选择职务">
94
            <t-option v-for="(item, index) in JobPostions" :key="index" :value="item.code">{{ item.value }}</t-option>
97 95
          </t-select>
98 96
        </t-form-item>
99 97
        <t-form-item label="出生年月" prop="age">
@ -110,6 +108,41 @@
110 108
        <t-button class="submit-button" @click="submit">保存</t-button>
111 109
      </div>
112 110
    </t-modal>
111
    <t-modal :visibled.sync="updateModal" :mask-closable="false" title="编辑用户" >
112
      <t-form ref="updateFormValidate" :model="updateFormValidate" :rules="updateRuleValidate" :label-width="80" label-position="left">
113
        <t-form-item label="员工编号" prop="number">
114
          {{ updateFormValidate.number }}
115
        </t-form-item>
116
        <t-form-item label="姓名" prop="name">
117
          <t-input v-model="updateFormValidate.name" placeholder="请输入姓名"></t-input>
118
        </t-form-item>
119
        <t-form-item label="部门" prop="department">
120
          <t-select-tree
121
            v-model="updateFormValidate.department"
122
            :node-data="cloneNodes"
123
            node-key="code"
124
          ></t-select-tree>
125
        </t-form-item>
126
        <t-form-item label="职务" prop="job">
127
          <t-select v-model="updateFormValidate.job" placeholder="请选择职务">
128
            <t-option v-for="(item, index) in JobPostions" :key="index" :value="item.code">{{ item.value }}</t-option>
129
          </t-select>
130
        </t-form-item>
131
        <t-form-item label="出生年月" prop="age">
132
          <!--          <t-input v-model="formValidate.age" placeholder="请输入数字"></t-input>-->
133
          <t-date-picker v-model="updateFormValidate.age"
134
                         placeholder="请选择出生年月"></t-date-picker>
135
        </t-form-item>
136
        <t-form-item label="手机" prop="phone">
137
          <t-input v-model="updateFormValidate.phone" placeholder="请输入手机号码"></t-input>
138
        </t-form-item>
139
      </t-form>
140
      <div slot="footer">
141
        <t-button @click="cancel">取消</t-button>
142
        <t-button class="submit-button" @click="updateSubmit">保存</t-button>
143
      </div>
144
    </t-modal>
145
    <t-loading v-model="fullLoading" fullscreen tip="加载中...."></t-loading>
113 146
  </div>
114 147
</template>
115 148
<script>
@ -128,6 +161,9 @@ export default {
128 161
      },
129 162
      departments: [],
130 163
      selections: [],
164
      JobPostions: [],
165
      fullLoading: false,
166
      tableLoading: true,
131 167
      queryCondition: {
132 168
        type: '',
133 169
        employeeNo: '',
@ -227,6 +263,81 @@ export default {
227 263
            }
228 264
          }
229 265
        ]
266
      },
267
      updateModal: false,
268
      updateFormValidate: {
269
        id: '',
270
        name: '',
271
        number: '',
272
        department: '',
273
        job: '',
274
        age: '',
275
        phone: ''
276
      },
277
      updateRuleValidate: {
278
        name: [
279
          {
280
            required: true,
281
            message: '姓名不能为空',
282
            trigger: 'blur'
283
          }
284
        ],
285
        department: [
286
          {
287
            required: true,
288
            message: '部门不能为空',
289
            trigger: 'change',
290
            validator: function(rule, value, callback) {
291
              // TODO 判断编号重复
292
              if (!value) {
293
                callback(rule.message)
294
              } else {
295
                return true
296
              }
297
            }
298
          }
299
        ],
300
        job: [
301
          {
302
            required: true,
303
            message: '职务不能为空',
304
            trigger: 'change',
305
            validator: function(rule, value, callback) {
306
              // TODO 判断编号重复
307
              if (!value) {
308
                callback(rule.message)
309
              } else {
310
                return true
311
              }
312
            }
313
          }
314
        ],
315
        age: [
316
          {
317
            required: true,
318
            message: '出生年月不能为空',
319
            trigger: 'change'
320
          }
321
        ],
322
        phone: [
323
          {
324
            required: true,
325
            message: '手机不能为空',
326
            trigger: 'blur'
327
          },
328
          {
329
            message: '手机格式不正确',
330
            trigger: 'blur',
331
            validator: function(rule, value, callback) {
332
              let pattern = /^1[3456789]\d{9}$/
333
              if (!pattern.test(value)) {
334
                callback(rule.message)
335
              } else {
336
                return true
337
              }
338
            }
339
          }
340
        ]
230 341
      }
231 342
    }
232 343
  },
@ -247,17 +358,17 @@ export default {
247 358
    }
248 359
  },
249 360
  mounted() {
250
    // this.table.data = this.table.data.concat(this.table.data)
251
    // this.table.pager.total = this.table.data.length
252 361
    this.getList()
253 362
    this.getDepartmentsList()
363
    this.initJobPostion()
254 364
  },
255 365
  methods: {
256 366
    getList: function () {
367
      this.tableLoading = true
257 368
      this.$test
258 369
        .post(services.workEmployee.GET_WORK_EMPLOYEE, {
259 370
          data: {
260
            orgId: this.queryCondition.department,
371
            orgCode: this.queryCondition.department,
261 372
            code: this.queryCondition.employeeNo,
262 373
            name: this.queryCondition.employeeName
263 374
          },
@ -266,13 +377,23 @@ export default {
266 377
        })
267 378
        .then((res) => {
268 379
          // 请求成功处理...
380
          this.tableLoading = false
269 381
          this.table.data = res.data.data
270 382
          this.table.pager.total = res.data.total
271 383
        })
272 384
        .catch((res) => {
273 385
          // 请求失败处理...
386
          this.tableLoading = false
274 387
        })
275 388
    },
389
    type_formatter(row, column) {
390
      var arr = this.JobPostions.filter((item) => {
391
        return item.code === row.mainJobPosition
392
      })
393
      if (arr[0]) {
394
        return arr[0].value
395
      }
396
    },
276 397
    getDepartmentsList: function () {
277 398
      this.$test
278 399
        .post(services.workEmployee.GET_ALL_ORGANIZE, {})
@ -286,7 +407,7 @@ export default {
286 407
                label: res.data[i].name,
287 408
                title: res.data[i].name,
288 409
                id: res.data[i].code,
289
                data: res.data[i].id,
410
                data: res.data[i].code,
290 411
                pid: res.data[i].parentCode
291 412
              })
292 413
            } else {
@ -294,7 +415,7 @@ export default {
294 415
                label: res.data[i].name,
295 416
                title: res.data[i].name,
296 417
                id: res.data[i].code,
297
                data: res.data[i].id
418
                data: res.data[i].code
298 419
              })
299 420
            }
300 421
          }
@ -303,6 +424,17 @@ export default {
303 424
          // 请求失败处理...
304 425
        })
305 426
    },
427
    initJobPostion: function () {
428
      this.$test
429
        .post(services.workEmployee.GET_JOB_POSTION, {})
430
        .then((res) => {
431
          // 请求成功处理...
432
          this.JobPostions = res.data
433
        })
434
        .catch((res) => {
435
          // 请求失败处理...
436
        })
437
    },
306 438
    onChange(value) {
307 439
      console.log('date change:' + value)
308 440
    },
@ -330,68 +462,67 @@ export default {
330 462
      this.getList()
331 463
    },
332 464
    handleClick(row) {
333
      this.modal = true
334
      // var params = new FormData()
335
      // params.append('data', JSON.stringify({
336
      //   FACILITY_ID: row.FACILITY_ID
337
      // }))
338
      // this.$test.post(services.equipment.GET_ONE_EQUIPMENT, params
339
      // ).then(res => {
340
      //   // 请求成功处理...
341
      //   this.updateModal = true
342
      //   this.updateRow = res.data.resultData
343
      //   this.typeChange(2)
344
      // }).catch(res => {
345
      //   // 请求失败处理...
346
      // })
465
      this.updateModal = true
466
      this.$test
467
        .post(services.workEmployee.GET_WORK_EMPLOYEE, {
468
          data: {
469
            id: row.id
470
          },
471
          pageNumber: 1,
472
          pageSize: 1
473
        })
474
        .then((res) => {
475
        // 请求成功处理...
476
          var user = res.data.data[0]
477
          this.updateFormValidate = {
478
            id: user.id,
479
            name: user.name,
480
            number: user.code,
481
            department: user.orgCode,
482
            job: user.mainJobPosition,
483
            age: user.birthday,
484
            phone: user.mainWirelessCall
485
          }
486
        })
487
        .catch((res) => {
488
        // 请求失败处理...
489
        })
347 490
    },
348 491
    remove(row) {
349
      this.$Confirm.confirm({
350
        title: '确认要删除用户张三吗?',
351
        content: '删除后不可恢复',
492
      let confirm = {
493
        title: '确认',
494
        content: '删除后不可恢复,确认删除吗?',
352 495
        ok: () => {
353
          console.log('点击了确定')
354
        },
355
        cancel: () => {
356
          console.log('点击了取消')
496
          this.fullLoading = true
497
          this.$test.post(services.workEmployee.DEL_WORK_EMPLOYEE, {ids: row.id this.$test.post(services.workEmployee.DEL_WORK_EMPLOYEE, {ids: row.id}
498
          ).then(res => {
499
            // 请求成功处理...
500
            this.fullLoading = false
501
            this.$Message.success('操作成功')
502
            this.getList()
503
          }).catch(res => {
504
            // 请求失败处理...
505
            this.fullLoading = false
506
          })
357 507
        }
358
      })
359
      // let that = this
360
      // let confirm = {
361
      //   title: '请确认',
362
      //   content: '删除后不可恢复,确认删除吗?',
363
      //   ok: function () {
364
      //     var params = new FormData()
365
      //     params.append('data', JSON.stringify({
366
      //       params: {
367
      //         FACILITY_ID: row.FACILITY_ID
368
      //       }
369
      //     }))
370
      //     this.$test.post(services.equipment.DEL_EQUIPMENT, params
371
      //     ).then(res => {
372
      //       // 请求成功处理...
373
      //       that.$Message.success('操作成功')
374
      //       that.getList()
375
      //     }).catch(res => {
376
      //       // 请求失败处理...
377
      //     })
378
      //   }
379
      // }
380
      // this.$Confirm.confirm(confirm)
508
      }
509
      this.$Confirm.confirm(confirm)
381 510
    },
382 511
    cancel() {
383 512
      this.modal = false
513
      this.updateModal = false
384 514
      this.$refs['formValidate'].resetFields()
385 515
    },
386 516
    submit() {
387 517
      var that = this
388 518
      this.$refs.formValidate.validate(valid => {
389 519
        if (valid) {
520
          that.fullLoading = true
390 521
          that.$test.post(services.workEmployee.ADD_WORK_EMPLOYEE, {
391 522
            name: that.formValidate.name,
392 523
            code: that.formValidate.number,
393 524
            organizeCode: that.formValidate.department,
394
            mainJobPosition: that.formValidate.job.value,
525
            mainJobPosition: that.formValidate.job,
395 526
            birthday: that.formValidate.age,
396 527
            // cardType: "居民身份证",
397 528
            // cardNo: "43252345455412305567X",
@ -400,16 +531,47 @@ export default {
400 531
          }
401 532
          ).then(res => {
402 533
            // 请求成功处理...
403
            if (res.data) {
404
              that.$Message.success('提交成功!')
405
              that.cancel()
406
              that.getList()
407
            } else {
408
              this.$Message.danger('终端编号重复!')
409
            }
534
            that.fullLoading = false
535
            that.$Message.success('提交成功!')
536
            that.cancel()
537
            that.getList()
410 538
            // this.getList(this.table.pager.currentPage, this.table.pager.size, this.queryCondition.equipmentType, this.queryCondition.equipmentName, this.queryCondition.equipmentNumber)
411 539
          }).catch(res => {
412 540
            // 请求失败处理...
541
            that.fullLoading = false
542
          })
543
        } else {
544
          this.$Message.danger('表单验证失败!')
545
        }
546
      })
547
    },
548
    updateSubmit() {
549
      var that = this
550
      this.$refs.updateFormValidate.validate(valid => {
551
        if (valid) {
552
          that.fullLoading = true
553
          var birthday = that.updateFormValidate.age.replaceAll(' 00:00:00', '')
554
          that.$test.post(services.workEmployee.UPD_WORK_EMPLOYEE, {
555
            id: that.updateFormValidate.id,
556
            name: that.updateFormValidate.name,
557
            code: that.updateFormValidate.number,
558
            organizeCode: that.updateFormValidate.department,
559
            mainJobPosition: that.updateFormValidate.job,
560
            birthday: birthday,
561
            // cardType: "居民身份证",
562
            // cardNo: "43252345455412305567X",
563
            // gender: "男",
564
            mainWirelessCall: that.updateFormValidate.phone
565
          }
566
          ).then(res => {
567
            // 请求成功处理...
568
            this.fullLoading = false
569
            that.$Message.success('提交成功!')
570
            that.cancel()
571
            that.getList()
572
          }).catch(res => {
573
            // 请求失败处理...
574
            this.fullLoading = false
413 575
          })
414 576
        } else {
415 577
          this.$Message.danger('表单验证失败!')
@ -422,6 +584,38 @@ export default {
422 584
    addUser() {
423 585
      this.modal = true
424 586
      this.getDepartmentsList()
587
    },
588
    toBatchRemove(row) { // 批量删除
589
      if (this.selections.length === 0) {
590
        this.$Confirm.info({
591
          title: '提示',
592
          content: '请选中需要删除的人员。'
593
        })
594
      } else {
595
        var ids = ''
596
        for (let i = 0; i < this.selections.length; i++) {
597
          ids += this.selections[i].id + ','
598
        }
599
        ids = ids.substring(0, ids.length - 1)
600
        let confirm = {
601
          title: '请确认',
602
          content: '删除后不可恢复,确认删除吗?',
603
          ok: () => {
604
            this.fullLoading = true
605
            this.$test.post(services.workEmployee.DEL_WORK_EMPLOYEE, {ids: ids}
606
            ).then(res => {
607
              // 请求成功处理...
608
              this.fullLoading = false
609
              this.$Message.success('操作成功')
610
              this.getList()
611
            }).catch(res => {
612
              // 请求失败处理...
613
              this.fullLoading = false
614
            })
615
          }
616
        }
617
        this.$Confirm.confirm(confirm)
618
      }
425 619
    }
426 620
  }
427 621
}

+ 6 - 6
location-rescue-service/pom.xml

@ -6,7 +6,7 @@
6 6
    <parent>
7 7
        <artifactId>components</artifactId>
8 8
        <groupId>com.ai.bss</groupId>
9
        <version>2.1-SNAPSHOT</version>
9
        <version>2.1.5-SNAPSHOT</version>
10 10
    </parent>
11 11
12 12
@ -54,25 +54,25 @@
54 54
        <dependency>
55 55
            <groupId>com.ai.bss</groupId>
56 56
            <artifactId>work-tool-service-api</artifactId>
57
            <version>2.1-SNAPSHOT</version>
57
            <version>2.1.5-SNAPSHOT</version>
58 58
        </dependency>
59 59
60 60
        <dependency>
61 61
            <groupId>com.ai.bss</groupId>
62 62
            <artifactId>work-tool-service</artifactId>
63
            <version>2.1-SNAPSHOT</version>
63
            <version>2.1.5-SNAPSHOT</version>
64 64
        </dependency>
65 65
66 66
        <dependency>
67 67
            <groupId>com.ai.bss</groupId>
68 68
            <artifactId>worker-service</artifactId>
69
            <version>2.1-SNAPSHOT</version>
69
            <version>2.1.5-SNAPSHOT</version>
70 70
        </dependency>
71 71
72 72
		<dependency>
73 73
            <groupId>com.ai.bss</groupId>
74 74
            <artifactId>characteristic-spec-service</artifactId>
75
            <version>2.1-SNAPSHOT</version>
75
            <version>2.1.5-SNAPSHOT</version>
76 76
        </dependency>
77 77
78 78
        <!-- <dependency>
@ -91,7 +91,7 @@
91 91
        <dependency>
92 92
            <groupId>com.ai.bss</groupId>
93 93
            <artifactId>system-user-service</artifactId>
94
            <version>2.1-SNAPSHOT</version>
94
            <version>2.1.5-SNAPSHOT</version>
95 95
            <exclusions>
96 96
                <exclusion>
97 97
                    <groupId>org.springframework.boot</groupId>

+ 3 - 5
location-rescue-service/src/main/java/com/ai/bss/location/rescue/controller/DeviceManageController.java

@ -184,11 +184,9 @@ public class DeviceManageController {
184 184
	 */
185 185
	@ResponseBody
186 186
	@RequestMapping("/queryAssociatInfo")
187
	public Map<String, Object> queryAssociatInfo(@RequestBody Map<String, Object> params) throws Exception {
188
		List<? extends Object> userList =  deviceManageService.queryAssociatInfo(params);
189
		Map<String, Object> result = new HashMap<String, Object>();
190
		result.put("result", userList);
191
		return result;
187
	public CommonResponse<List<? extends Object>> queryAssociatInfo(@RequestBody Map<String, Object> params) throws Exception {
188
		List<? extends Object> resultList =  deviceManageService.queryAssociatInfo(params);
189
		return CommonResponse.ok(resultList);
192 190
	}
193 191
	
194 192
	/**

+ 4 - 3
location-rescue-service/src/main/java/com/ai/bss/location/rescue/controller/MapTagManageController.java

@ -145,11 +145,12 @@ public class MapTagManageController {
145 145
            return CommonResponse.fail("500","删除失败");
146 146
        }
147 147
148
        List<String> mapTagIdsList = null;
148
        List<String> mapTagIdsList = new ArrayList<String>();
149 149
        if (params.get("mapTagIds") instanceof List) {
150
            mapTagIdsList = (List<String>) params.get("mapTagIds");
150
            for (Object object : (List<Object>)params.get("mapTagIds")) {
151
                mapTagIdsList.add(object.toString())   ;
152
            }
151 153
        } else if (params.get("mapTagIds") instanceof String) {
152
            mapTagIdsList = new ArrayList<String>();
153 154
            mapTagIdsList.add((String) params.get("mapTagIds"));
154 155
        } else {
155 156
            return CommonResponse.fail("501","删除失败:标记类型错误");

+ 2 - 2
location-rescue-service/src/main/java/com/ai/bss/location/rescue/service/impl/MapTagManageServiceImpl.java

@ -89,7 +89,7 @@ public class MapTagManageServiceImpl implements MapTagManageService {
89 89
90 90
	@Override
91 91
	public CommonResponse<Void> addMapTagInfo(MapTagInfoDto mapTagInfoDto) throws Exception {
92
		mapTagInfoDto.setMapAreaSetId("0"); //TODO 固定值 所属地图围栏集合标识
92
		mapTagInfoDto.setMapAreaSetId(0L); //TODO 固定值 所属地图围栏集合标识
93 93
		mapTagInfoDto.setPriority("10");  //优先级
94 94
		mapTagInfoDto.setMapType(MapArea.MAP_TYPE_GEOMETRY);	//围栏形状,GEO多边形, RAD 圆形
95 95
@ -105,7 +105,7 @@ public class MapTagManageServiceImpl implements MapTagManageService {
105 105
106 106
	@Override
107 107
	public CommonResponse<Void> modifyMapTagInfo(MapTagInfoDto mapTagInfoDto) throws Exception {
108
		mapTagInfoDto.setMapAreaSetId("0"); //TODO 固定值 所属地图围栏集合标识
108
		mapTagInfoDto.setMapAreaSetId(0L); //TODO 固定值 所属地图围栏集合标识
109 109
		mapTagInfoDto.setPriority("10");  //优先级
110 110
		mapTagInfoDto.setMapType(MapArea.MAP_TYPE_GEOMETRY);	//围栏形状,GEO多边形, RAD 圆形
111 111

+ 41 - 0
location-rescue-service/src/main/java/com/ai/bss/location/rescue/util/CacheUtil.java

@ -0,0 +1,41 @@
1
package com.ai.bss.location.rescue.util;
2
3
import com.ai.ipu.cache.CacheFactory;
4
import com.ai.ipu.cache.ICache;
5
6
public class CacheUtil {
7
    //private static final Logger logger = LoggerFactory.getLogger(CacheUtil.class);
8
9
    private static final String CACHE_NAME = "ssn";
10
11
    public static boolean setCache(String key, Object value) throws Exception {
12
        if (value == null) getCache(key);
13
        if (key == null) new NullPointerException();
14
15
        ICache cache = CacheFactory.getCache(CacheFactory.CacheType.redis, CACHE_NAME);
16
        return cache.put(key, value);
17
    }
18
19
    public static Object getCache(String key) throws Exception {
20
        if (key == null) new NullPointerException();
21
22
        ICache cache = CacheFactory.getCache(CacheFactory.CacheType.redis, CACHE_NAME);
23
        return cache.get(key);
24
    }
25
26
    public static boolean removeCache(String key) throws Exception {
27
        if (key == null) new NullPointerException();
28
29
        ICache cache = CacheFactory.getCache(CacheFactory.CacheType.redis, CACHE_NAME);
30
        return cache.remove(key);
31
        //CacheFactory.close(CACHE_NAME, cache);
32
    }
33
34
    public static boolean keyExists(String value) throws Exception {
35
        if (value == null) new NullPointerException();
36
37
        ICache cache = CacheFactory.getCache(CacheFactory.CacheType.redis, CACHE_NAME);
38
        return cache.keyExists(value);
39
    }
40
41
}

+ 1 - 1
location-rescue-service/src/main/java/com/ai/bss/location/rescue/util/HttpServiceUtil.java

@ -186,7 +186,7 @@ public class HttpServiceUtil {
186 186
		return body;
187 187
	}
188 188
189
	public static String sendGet(String url, Charset encoding) {
189
	public static String sendGet(String url, Charset encoding,Map<String,String> headerMap) {
190 190
		HttpClient httpClient = HttpClients.createDefault();
191 191
		HttpGet httpGet = new HttpGet(url);
192 192
		httpGet.addHeader(HTTP.CONTENT_TYPE, HTTP_CONTENT_TYPE_JSON);

+ 237 - 249
location-rescue-service/src/main/java/com/ai/bss/location/rescue/util/NorthboundInterfaceUtil.java

@ -1,264 +1,252 @@
1 1
package com.ai.bss.location.rescue.util;
2 2
3
import java.nio.charset.Charset;
4
import java.util.HashMap;
5
import java.util.Iterator;
6
import java.util.Map;
7
import java.util.Set;
8
import java.util.concurrent.ConcurrentHashMap;
9
3
import com.alibaba.fastjson.JSON;
4
import com.alibaba.fastjson.JSONObject;
10 5
import org.slf4j.Logger;
11 6
import org.slf4j.LoggerFactory;
12
import org.springframework.beans.factory.annotation.Configurable;
13 7
import org.springframework.beans.factory.annotation.Value;
14 8
import org.springframework.context.annotation.Configuration;
15
import org.springframework.stereotype.Component;
16 9
17
import com.ai.bss.location.rescue.controller.MapTagManageController;
18
import com.alibaba.fastjson.JSON;
10
import java.nio.charset.Charset;
11
import java.util.HashMap;
12
import java.util.Map;
19 13
20 14
/**
21
 *北向接口统一入口
15
 * 北向接口统一入口
16
 *
22 17
 * @date 2010/09/24 23:42
23 18
 */
24 19
@Configuration
25 20
public class NorthboundInterfaceUtil {
26 21
27
	private static final Logger logger = LoggerFactory.getLogger(MapTagManageController.class);
28
	
29
	@Value("${aap.iot.userCode:IOT_ADMIN}")
30
	private String userCode;
31
32
	@Value("${aap.iot.passWord:123456}")
33
	private String passWord;
34
35
	@Value("${url.iot.login:http://47.105.130.83:8083/sso/login}")
36
	private String iotLoginUrl;
37
38
	@Value("${url.iot.service:http://47.105.130.83:8083/dmp/terminalNorthApi/}")
39
	private String iotServiceUrl;
40
41
	// 定义静态存储map空间存放sign与sessionId
42
	private volatile static Map<String, String> cacheMap = new ConcurrentHashMap<String, String>();// 缓存map
43
44
	// set
45
	public void setMapCache(Map<String, String> map) {
46
		Set<String> set = map.keySet();
47
		Iterator<String> it = set.iterator();
48
		while (it.hasNext()) {
49
			String key = it.next();
50
			cacheMap.put(key, map.get(key));
51
		}
52
	}
53
54
	// get
55
	public Map<String, String> getMapCache() {
56
57
		return cacheMap;
58
	}
59
60
	// 清除cache
61
	public void clear() {
62
		cacheMap.clear();
63
	}
64
65
	/**
66
	 * GET请求调用北向接口方法
67
	 * 
68
	 * @param url
69
	 * @param params
70
	 * @return
71
	 * @throws Exception
72
	 */
73
	public Map<String, Object> iotGetCallUtil(String url) throws Exception {
74
		// 调用北向服务的接口
75
		logger.debug("GET调用北向接口");
76
77
		boolean loginFlag = true;
78
79
		// 1.在缓存中获取sessionId与sign
80
		Map<String, String> mapCache = getMapCache();
81
		if (mapCache.isEmpty() || mapCache.get("sign") == null || mapCache.get("session_id") == null) {
82
			// 2.如果没有调用登录接口从新获取
83
			loginFlag = iotLogin();
84
		}
85
86
		if (!loginFlag) {
87
			logger.debug("调用北向接口登录失败");
88
			return new HashMap<String, Object>();
89
		}
90
91
		// 3.调用北向服务接口
92
		// (1)设置字符集
93
		Charset charset = Charset.forName("utf-8");
94
		// (2)调用接口
95
		String resultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset);
96
		// (3)将参数转为Map<String,String>【将返回值统一为String】
97
		Map<String, Object> resultMap = JSON.parseObject(resultJson, Map.class);
98
99
		// 4.登录超时,需重新登录
100
		if ("登录超时".equals(resultMap.get("resultMsg"))) {
101
			logger.info("调用北向接口失败,需重新登录");
102
			// 4.调用不成功可能是登录过期
103
			// (1)清除缓存
104
			clear();
105
			// (2)重新登录
106
			loginFlag = iotLogin();
107
108
			if (!loginFlag) {
109
				logger.debug("再次调用北向接口登录失败");
110
				return new HashMap<String, Object>();
111
			}
112
113
			try {
114
				// (3)再次调用接口
115
				String fianlresultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset);
116
				// (4)获取返回值
117
				resultMap = JSON.parseObject(fianlresultJson, Map.class);
118
			} catch (Exception e) {
119
				logger.error("再次调用北向接口失败: " + e.getMessage());
120
				return new HashMap<String, Object>();
121
			}
122
123
			if (resultMap == null) {
124
				logger.error("再次调用北向接口返回值为空");
125
				return new HashMap<String, Object>();
126
			}
127
		}
128
129
		// 5.判断是否调用成功
130
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
131
			logger.info("调用北向接口成功");
132
		} else {
133
			logger.info("调用北向接口失败");
134
		}
135
136
		return resultMap;
137
	}
138
139
	/**
140
	 * POST请求调用北向接口方法
141
	 * 
142
	 * @param url
143
	 * @param paramsMap
144
	 * @return
145
	 * @throws Exception
146
	 */
147
	public Map<String, Object> iotPostCallUtil(String url, Map<String, Object> paramsMap) throws Exception {
148
		// 调用北向服务的接口
149
		logger.debug("POSt调用北向接口");
150
151
		boolean loginFlag = true;
152
153
		// 1.在缓存中获取sessionId与sign
154
		Map<String, String> mapCache = getMapCache();
155
		if (mapCache.isEmpty() || mapCache.get("sign") == null || mapCache.get("session_id") == null) {
156
			// 2.如果没有调用登录接口从新获取
157
			loginFlag = iotLogin();
158
		}
159
160
		if (!loginFlag) {
161
			logger.debug("调用北向接口登录失败");
162
			return new HashMap<String, Object>();
163
		}
164
165
		// 3.调用北向服务接口
166
		// (1)设置字符集
167
		Charset charset = Charset.forName("utf-8");
168
		// 返回值
169
		Map<String, Object> resultMap = null;
170
		try {
171
			// (2)调用接口
172
			String resultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset, getMapCache());
173
			// (3)将参数转为Map<String,String>【将返回值统一为String】
174
			resultMap = JSON.parseObject(resultJson, Map.class);
175
		} catch (Exception e) {
176
			logger.error("调用北向接口失败: " + e.getMessage());
177
			return new HashMap<String, Object>();
178
		}
179
180
		if (resultMap == null) {
181
			logger.error("调用北向接口返回值为空");
182
			return new HashMap<String, Object>();
183
		}
184
185
		// 4.登录超时,需重新登录
186
		if ("登录超时".equals(resultMap.get("resultMsg"))) {
187
			logger.info("调用北向接口登录超时,需重新登录");
188
			// 4.调用不成功可能是登录过期
189
			// (1)清除缓存
190
			clear();
191
			// (2)重新登录
192
			loginFlag = iotLogin();
193
194
			if (!loginFlag) {
195
				logger.debug("再次调用北向接口登录失败");
196
				return new HashMap<String, Object>();
197
			}
198
199
			try {
200
				// (3)再次调用接口
201
				String fianlresultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset,
202
						getMapCache());
203
				// (4)获取返回值
204
				resultMap = JSON.parseObject(fianlresultJson, Map.class);
205
			} catch (Exception e) {
206
				logger.error("再次调用北向接口失败: " + e.getMessage());
207
				return new HashMap<String, Object>();
208
			}
209
210
			if (resultMap == null) {
211
				logger.error("再次调用北向接口返回值为空");
212
				return new HashMap<String, Object>();
213
			}
214
		}
215
216
		// 5.判断是否调用成功
217
		if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
218
			logger.info("调用北向接口成功");
219
		} else {
220
			logger.info("调用北向接口失败");
221
		}
222
223
		return resultMap;
224
	}
225
226
	/**
227
	 * 调用登录接口获取sessionId与sign
228
	 * 
229
	 * @return
230
	 */
231
	private boolean iotLogin() {
232
		logger.debug("登录北向接口");
233
234
		// 调用登录接口获取sessionId与sign
235
		HashMap<String, Object> loginParamMap = new HashMap<>();
236
		loginParamMap.put("userCode", userCode);
237
		loginParamMap.put("passWord", passWord);
238
239
		// 设置字符集
240
		Charset charset = Charset.forName("utf-8");
241
242
		Map loginResultMap = null;
243
		try {
244
			// 调用登录接口
245
			String loginResult = HttpServiceUtil.sendPost(iotLoginUrl, loginParamMap, charset);
246
			loginResultMap = JSON.parseObject(loginResult, Map.class);
247
		} catch (Exception e) {
248
			logger.error("登录北向接口失败: " + e.getMessage());
249
			return false;
250
		}
251
252
		if (loginResultMap != null && NorthboundInterfaceConstant.resultCode_succeed
253
				.equals(String.valueOf(loginResultMap.get("resultCode")))) {
254
			logger.info("登录北向接口成功");
255
			Map result = (Map) loginResultMap.get("result");
256
			// 将数据存到缓存中
257
			setMapCache(result);
258
			return true;
259
		} else {
260
			logger.info("登录北向接口失败");
261
			return false;
262
		}
263
	}
22
    private static final Logger logger = LoggerFactory.getLogger(NorthboundInterfaceUtil.class);
23
24
    @Value("${aap.iot.userCode:IOT_ADMIN}")
25
    private String userCode;
26
27
    @Value("${aap.iot.passWord:123456}")
28
    private String passWord;
29
30
    @Value("${url.iot.login:http://47.105.130.83:8083/sso/login}")
31
    private String iotLoginUrl;
32
33
    @Value("${url.iot.service:http://47.105.130.83:8083/dmp/terminalNorthApi/}")
34
    private String iotServiceUrl;
35
36
    /**
37
     * GET请求调用北向接口方法
38
     *
39
     * @param url
40
     * @return
41
     * @throws Exception
42
     */
43
    public Map<String, Object> iotGetCallUtil(String url) throws Exception {
44
        logger.debug("GET调用北向接口");
45
        Map<String, Object> resultMap = new HashMap<String, Object>();
46
        Map<String, String> signMap = new HashMap<String, String>();
47
48
        // 1.在缓存中获取sessionId与sign
49
        Object sign =CacheUtil.getCache("ebc_iot_north_sign");
50
        Object session_id = CacheUtil.getCache("ebc_iot_north_session_id");
51
52
        if (sign == null ) {
53
            // 2.如果没有调用登录接口从新获取
54
            signMap = iotLogin();
55
56
            if (signMap == null) {
57
                logger.debug("调用北向接口登录失败");
58
                return resultMap;
59
            }
60
61
        } else {
62
            signMap.put("ebc_iot_north_sign", String.valueOf(sign));
63
            signMap.put("ebc_iot_north_session_id", String.valueOf(session_id));
64
65
        }
66
67
        // 3.调用北向服务接口
68
        // (1)设置字符集
69
        Charset charset = Charset.forName("utf-8");
70
        try {
71
            // (2)调用接口
72
            String resultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset, signMap);
73
            // (3)将参数转为Map<String,String>【将返回值统一为String】
74
            resultMap = JSON.parseObject(resultJson, Map.class);
75
        } catch (Exception e) {
76
            logger.error("调用北向接口失败: " + e.getMessage());
77
            return new HashMap<String, Object>();
78
        }
79
80
        if (resultMap == null) {
81
            logger.error("调用北向接口返回值为空");
82
            return new HashMap<String, Object>();
83
84
        } else if ("登录超时".equals(resultMap.get("resultMsg"))) {
85
            // 4.登录超时,需重新登录
86
            logger.info("调用北向接口失败,需重新登录");
87
            // (1)清除缓存
88
            CacheUtil.removeCache("ebc_iot_north_sign");
89
            CacheUtil.removeCache("ebc_iot_north_session_id");
90
            // (2)重新登录
91
            signMap = iotLogin();
92
93
            if (signMap == null) {
94
                logger.debug("再次调用北向接口登录失败");
95
                return resultMap;
96
            }
97
98
            try {
99
                // (3)再次调用接口
100
                String resultJson = HttpServiceUtil.sendGet(iotServiceUrl + url, charset, signMap);
101
                // (4)获取返回值
102
                resultMap = JSON.parseObject(resultJson, Map.class);
103
            } catch (Exception e) {
104
                logger.error("再次调用北向接口失败: " + e.getMessage());
105
                return new HashMap<String, Object>();
106
            }
107
108
            if (resultMap == null) {
109
                logger.error("再次调用北向接口返回值为空");
110
                return new HashMap<String, Object>();
111
            }
112
        }
113
114
        // 5.判断是否调用成功
115
        if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
116
            logger.info("调用北向接口成功");
117
            return resultMap;
118
        } else {
119
            logger.info("调用北向接口失败");
120
            return new HashMap<String, Object>();
121
        }
122
    }
123
124
    /**
125
     * POST请求调用北向接口方法
126
     *
127
     * @param url
128
     * @param paramsMap
129
     * @return
130
     * @throws Exception
131
     */
132
    public Map<String, Object> iotPostCallUtil(String url, Map<String, Object> paramsMap) throws Exception {
133
        logger.debug("POSt调用北向接口");
134
        Map<String, Object> resultMap = new HashMap<String, Object>();
135
        Map<String, String> signMap = new HashMap<String, String>();
136
137
        // 1.在缓存中获取sessionId与sign
138
        Object sign =CacheUtil.getCache("ebc_iot_north_sign");
139
        Object session_id = CacheUtil.getCache("ebc_iot_north_session_id");
140
141
        if (sign == null ) {
142
            // 2.如果没有调用登录接口从新获取
143
            signMap = iotLogin();
144
145
            if (signMap == null) {
146
                logger.debug("调用北向接口登录失败");
147
                return resultMap;
148
            }
149
150
        } else {
151
            signMap.put("ebc_iot_north_sign", String.valueOf(sign));
152
            signMap.put("ebc_iot_north_session_id", String.valueOf(session_id));
153
154
        }
155
156
        // 3.调用北向服务接口
157
        // (1)设置字符集
158
        Charset charset = Charset.forName("utf-8");
159
        try {
160
            // (2)调用接口
161
            String resultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset, signMap);
162
            // (3)将参数转为Map<String,String>【将返回值统一为String】
163
            resultMap = JSON.parseObject(resultJson, Map.class);
164
        } catch (Exception e) {
165
            logger.error("调用北向接口失败: " + e.getMessage());
166
            return new HashMap<String, Object>();
167
        }
168
169
        if (resultMap == null) {
170
            logger.error("调用北向接口返回值为空");
171
            return new HashMap<String, Object>();
172
        } else if ("登录超时".equals(resultMap.get("resultMsg"))) {
173
            // 4.登录超时,需重新登录
174
            logger.info("调用北向接口登录超时,需重新登录");
175
            // (1)清除缓存
176
            CacheUtil.removeCache("ebc_iot_north_sign");
177
            CacheUtil.removeCache("ebc_iot_north_session_id");
178
            // (2)重新登录
179
            signMap = iotLogin();
180
181
            if (signMap == null) {
182
                logger.debug("再次调用北向接口登录失败");
183
                return resultMap;
184
            }
185
186
            try {
187
                // (3)再次调用接口
188
                String resultJson = HttpServiceUtil.sendPost(iotServiceUrl + url, paramsMap, charset, signMap);
189
                // (4)获取返回值
190
                resultMap = JSON.parseObject(resultJson, Map.class);
191
            } catch (Exception e) {
192
                logger.error("再次调用北向接口失败: " + e.getMessage());
193
                return new HashMap<String, Object>();
194
            }
195
196
            if (resultMap == null) {
197
                logger.error("再次调用北向接口返回值为空");
198
                return new HashMap<String, Object>();
199
            }
200
        }
201
202
        // 5.判断是否调用成功
203
        if (NorthboundInterfaceConstant.resultCode_succeed.equals(resultMap.get("resultCode"))) {
204
            logger.info("调用北向接口成功");
205
            return resultMap;
206
        } else {
207
            logger.info("调用北向接口失败");
208
            return new HashMap<String, Object>();
209
        }
210
    }
211
212
    /**
213
     * 调用登录接口获取sessionId与sign
214
     *
215
     * @return
216
     */
217
    private Map<String, String> iotLogin() throws Exception {
218
        logger.debug("登录北向接口");
219
        HashMap<String, Object> loginParamMap = new HashMap<>();
220
221
        // 调用登录接口获取sessionId与sign
222
        loginParamMap.put("userCode", userCode);
223
        loginParamMap.put("passWord", passWord);
224
225
        // 设置字符集
226
        Charset charset = Charset.forName("utf-8");
227
228
        //Map<String, String> loginResultMap =new HashMap<String,String>();
229
        JSONObject loginResultJsonObject = null;
230
        try {
231
            // 调用登录接口
232
            String loginResult = HttpServiceUtil.sendPost(iotLoginUrl, loginParamMap, charset);
233
            loginResultJsonObject = JSON.parseObject(loginResult);
234
        } catch (Exception e) {
235
            logger.error("登录北向接口失败: " + e.getMessage());
236
            return null;
237
        }
238
239
        if (loginResultJsonObject != null && NorthboundInterfaceConstant.resultCode_succeed.equals(String.valueOf(loginResultJsonObject.get("resultCode")))) {
240
            logger.info("登录北向接口成功");
241
242
            Map<String, String> resultMap = (Map<String, String>) loginResultJsonObject.get("result");
243
            // 将数据存到缓存中
244
            CacheUtil.setCache("ebc_iot_north_sign", resultMap.get("sign"));
245
            CacheUtil.setCache("ebc_iot_north_session_id", resultMap.get("session_id"));
246
            return resultMap;
247
        } else {
248
            logger.info("登录北向接口失败");
249
            return null;
250
        }
251
    }
264 252
}