Commit f656f33b044f285fea57eab9892750d3b292e1ac
1 parent
37a28dcc
Exists in
master
1. F 上报app 升级记录里面添加一个 package_name 的字段
2. F 后台恢复删除的设备,从失败那里授权的设备逻辑要重新调整
Showing
7 changed files
with
144 additions
and
149 deletions
Show diff stats
app-api/controllers/UpgradeController.php
... | ... | @@ -390,11 +390,13 @@ class UpgradeController extends BaseController |
390 | 390 | $deviceId = isset($getPostData['device_id'])? $getPostData['device_id']: ''; |
391 | 391 | $currentVersion = isset($getPostData['current_version'])? $getPostData['current_version']: ''; |
392 | 392 | $targetVersion = isset($getPostData['target_version'])? $getPostData['target_version']: ''; |
393 | + $packageName = isset($getPostData['package_name'])? $getPostData['package_name']: ''; | |
394 | + | |
393 | 395 | $status = isset($getPostData['status'])? $getPostData['status']: ''; |
394 | 396 | $errorCode = isset($getPostData['error_code'])? $getPostData['error_code']: ''; |
395 | 397 | $timestamp = isset($getPostData['timestamp'])? $getPostData['timestamp']: ''; |
396 | 398 | |
397 | - if (empty($barcode) || empty($currentVersion) || empty($targetVersion) || empty($timestamp)) { | |
399 | + if (empty($barcode) || empty($currentVersion) || empty($targetVersion) || empty($timestamp) || empty($packageName)) { | |
398 | 400 | $e->status = 2; |
399 | 401 | $e->message = '部分数据为空'; |
400 | 402 | return $e; |
... | ... | @@ -412,7 +414,7 @@ class UpgradeController extends BaseController |
412 | 414 | $e->message = 'barcode格式有误'; |
413 | 415 | return $e; |
414 | 416 | } |
415 | - $upgradeLogModel = UpgradeLogRepository::findOne(['device_id' => $deviceId, 'current_version' => $currentVersion, 'target_version' => $targetVersion, 'status' => $status, 'type' => UpgradeStatus::TYPE_APP]); | |
417 | + $upgradeLogModel = UpgradeLogRepository::findOne(['device_id' => $deviceId, 'package_name' => $packageName ,'current_version' => $currentVersion, 'target_version' => $targetVersion, 'status' => $status, 'type' => UpgradeStatus::TYPE_APP]); | |
416 | 418 | if ($upgradeLogModel) { |
417 | 419 | $upgradeLogModel->timestamp = $timestamp; |
418 | 420 | $upgradeLogModel->save(); |
... | ... | @@ -442,6 +444,7 @@ class UpgradeController extends BaseController |
442 | 444 | "project_id" => $projectId, |
443 | 445 | "model_id" => $modelId, |
444 | 446 | "current_version" => $currentVersion, |
447 | + "package_name" => $packageName, | |
445 | 448 | "target_version" => $targetVersion, |
446 | 449 | "status" => $status, |
447 | 450 | "error_code" => $errorCode, | ... | ... |
app-ht/modules/datas/controllers/UpgradeLogController.php
... | ... | @@ -43,6 +43,7 @@ class UpgradeLogController extends BaseController |
43 | 43 | $barcode = $request->get('barcode'); |
44 | 44 | $error_code = $request->get('error_code'); |
45 | 45 | $device_device_id = $request->get('device_device_id'); |
46 | + $package_name = $request->get('package_name'); | |
46 | 47 | $dataType = !empty($request->get('type')) ? $request->get('type') : UpgradeStatus::TYPE_APP; |
47 | 48 | |
48 | 49 | $gets = [ |
... | ... | @@ -56,6 +57,7 @@ class UpgradeLogController extends BaseController |
56 | 57 | 'barcode' => $barcode, |
57 | 58 | 'error_code' => $error_code, |
58 | 59 | 'device_device_id' => $device_device_id, |
60 | + 'package_name' => $package_name, | |
59 | 61 | 'type' => $dataType, |
60 | 62 | ]; |
61 | 63 | |
... | ... | @@ -71,6 +73,9 @@ class UpgradeLogController extends BaseController |
71 | 73 | if ($status) { |
72 | 74 | $where[] = ['=', 'ul.status', $status]; |
73 | 75 | } |
76 | + if ($package_name) { | |
77 | + $where[] = ['like', 'ul.package_name', $package_name]; | |
78 | + } | |
74 | 79 | if ($current_version) { |
75 | 80 | $where[] = ['like', 'ul.current_version', $current_version]; |
76 | 81 | } | ... | ... |
app-ht/modules/datas/views/upgrade-log/export.php
... | ... | @@ -23,24 +23,26 @@ $cnt = 0; |
23 | 23 | </head> |
24 | 24 | <body> |
25 | 25 | <div id="Classeur1_16681" align='center' x:publishsource="Excel"> |
26 | - <table border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse"> | |
26 | + <table x:str border='1' cellpadding='0' cellspacing='0' width='100%' style="border-collapse: collapse"> | |
27 | 27 | <thead> |
28 | 28 | <tr> |
29 | 29 | <th width="10%">设备ID</th> |
30 | - <th width="10%">当前版本</th> | |
30 | + <th width="8%">包名</th> | |
31 | + <th width="8%">当前版本</th> | |
31 | 32 | <th width="10%">目标版本</th> |
32 | 33 | <th width="10%">厂商</th> |
33 | 34 | <th width="10%">机器型号</th> |
34 | 35 | <th width="10%">Barcode</th> |
35 | - <th width="10%">升级状态</th> | |
36 | - <th width="15%">升级错误码</th> | |
37 | - <th width="15%">时间</th> | |
36 | + <th width="7%">升级状态</th> | |
37 | + <th width="10%">升级错误码</th> | |
38 | + <th width="10%">时间</th> | |
38 | 39 | </tr> |
39 | 40 | </thead> |
40 | 41 | <tbody> |
41 | 42 | <?php foreach ($listdata as $key => $item) : ?> |
42 | 43 | <tr> |
43 | 44 | <td style="padding:12px;"><?= (isset($item["device_id"]) ? $item["device_id"] : "") ?></td> |
45 | + <td style="padding:12px;"><?= (isset($item["package_name"]) ? $item["package_name"] : "-") ?></td> | |
44 | 46 | <td style="padding:12px;"><?= (isset($item["current_version"]) ? $item["current_version"] : "") ?></td> |
45 | 47 | <td style="padding:12px;"><?= (isset($item["target_version"]) ? $item["target_version"] : "") ?></td> |
46 | 48 | <td style="padding:12px;"><?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "") ?></td> | ... | ... |
app-ht/modules/datas/views/upgrade-log/index.php
... | ... | @@ -77,8 +77,8 @@ $this->params['breadcrumbs'][] = $this->title; |
77 | 77 | <td class="text-left"> |
78 | 78 | <input type="text" class="form-control" name="device_device_id" style="width: 150px;" placeholder="输入设备ID" value="<?php if (!empty($gets['device_device_id'])){ echo $gets['device_device_id']; } ?>"> |
79 | 79 | </td> |
80 | - <td class="text-right"></td> | |
81 | - <td class="text-left"></td> | |
80 | + <td class="text-right">包名</td> | |
81 | + <td class="text-left"> <input type="text" class="form-control" name="package_name" style="width: 150px;" placeholder="包名" value="<?php if (!empty($gets['package_name'])){ echo $gets['package_name']; } ?>"></td> | |
82 | 82 | <td class="text-right"></td> |
83 | 83 | <td class="text-left"></td> |
84 | 84 | <td class="text-right"></td> |
... | ... | @@ -104,14 +104,15 @@ $this->params['breadcrumbs'][] = $this->title; |
104 | 104 | <thead> |
105 | 105 | <tr> |
106 | 106 | <th width="10%">设备ID</th> |
107 | - <th width="10%">当前版本</th> | |
107 | + <th width="8%">包名</th> | |
108 | + <th width="8%">当前版本</th> | |
108 | 109 | <th width="10%">目标版本</th> |
109 | 110 | <th width="10%">厂商</th> |
110 | 111 | <th width="10%">机器型号</th> |
111 | 112 | <th width="10%">Barcode</th> |
112 | - <th width="10%">升级状态</th> | |
113 | - <th width="15%">升级错误码</th> | |
114 | - <th width="15%">时间</th> | |
113 | + <th width="7%">升级状态</th> | |
114 | + <th width="10%">升级错误码</th> | |
115 | + <th width="10%">时间</th> | |
115 | 116 | </tr> |
116 | 117 | </thead> |
117 | 118 | |
... | ... | @@ -120,6 +121,7 @@ $this->params['breadcrumbs'][] = $this->title; |
120 | 121 | <?php foreach ($listdata as $item) : ?> |
121 | 122 | <tr> |
122 | 123 | <td style="padding:12px;"><?= (isset($item["device_id"]) ? $item["device_id"] : "") ?></td> |
124 | + <td style="padding:12px;"><?= (isset($item["package_name"]) ? $item["package_name"] : "-") ?></td> | |
123 | 125 | <td style="padding:12px;"><?= (isset($item["current_version"]) ? $item["current_version"] : "") ?></td> |
124 | 126 | <td style="padding:12px;"><?= (isset($item["target_version"]) ? $item["target_version"] : "") ?></td> |
125 | 127 | <td style="padding:12px;"><?= (isset($item["manufacture_name"]) ? $item["manufacture_name"] : "") ?></td> | ... | ... |
app-ht/modules/device/controllers/DeviceController.php
... | ... | @@ -673,6 +673,8 @@ class DeviceController extends BaseController |
673 | 673 | return $this->renderJson($e); |
674 | 674 | } |
675 | 675 | $batchNo = Device::getBatchNo($deviceFailModel->manufacture_no, $deviceFailModel->project_no, $deviceFailModel->model_no, $deviceFailModel->production_no); |
676 | + $deviceId = $deviceFailModel->device_id; | |
677 | + $tt = time(); | |
676 | 678 | $batchInfo = CreateBatchRepository::findOne(['batch_no' => $batchNo]); |
677 | 679 | if (empty($batchInfo)) { |
678 | 680 | $e->message = '该厂商未生产过该批次的设备无法处理'; |
... | ... | @@ -680,68 +682,68 @@ class DeviceController extends BaseController |
680 | 682 | } |
681 | 683 | $batchId = $batchInfo->id; |
682 | 684 | $deviceModel = DeviceRepository::findOne(['device_id' => $deviceFailModel->device_id , 'is_delete' => 0]); |
685 | + | |
683 | 686 | if ($deviceModel) { |
684 | - $e->message = '该设备已经授权过'; | |
687 | + if (DeviceStatus::HAS_AUTH == $deviceModel->status) { | |
688 | + $e->mac = $deviceModel->mac; | |
689 | + $e->message = '已经存在该授权设备'; | |
690 | + $e->success = false; | |
691 | + } elseif(DeviceStatus::NO_AUTH == $deviceModel->status) { | |
692 | + $deviceModel->status = DeviceStatus::HAS_AUTH; | |
693 | + $deviceModel->auth_at = time(); | |
694 | + $deviceModel->save(); | |
695 | + $e->message = '已经存在该授权设备'; | |
696 | + $e->success = false; | |
697 | + } else { | |
698 | + $e->message = '处理失败'; | |
699 | + } | |
700 | + | |
685 | 701 | return $this->renderJson($e); |
686 | 702 | } |
687 | - $count = DeviceRepository::rowsCount(['batch_id' => $batchId, 'status' => DeviceStatus::HAS_AUTH, 'is_delete' => 0]); | |
688 | 703 | |
689 | - if (($count *1) >= ($batchInfo->num * 1)) { | |
704 | + $needGen = DeviceRepository::checkNeedAutoGen($batchId, $batchInfo->num); | |
705 | + if ($needGen) { | |
690 | 706 | $trans = Yii::$app->getDb()->beginTransaction(); |
691 | 707 | try { |
692 | - | |
693 | - Device::createWithMacSerialNo($batchId, $batchNo, $deviceFailModel->device_id, $deviceFailModel->apply_at, 1, DeviceStatus::HAS_AUTH); | |
694 | - // 设备改为删除了 | |
708 | + $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 0, DeviceStatus::HAS_AUTH); | |
695 | 709 | $deviceFailModel->is_delete = 1; |
696 | 710 | $deviceFailModel->save(); |
697 | 711 | $trans->commit(); |
712 | + $e->message = '处理成功'; | |
698 | 713 | $e->success = true; |
699 | - return $this->renderJson($e); | |
700 | - } catch (Exception $exception) { | |
714 | + } catch(Exception $exception) { | |
701 | 715 | $trans->rollBack(); |
702 | - $e->message = '处理失败,请再尝试一次'; | |
703 | - return $this->renderJson($e); | |
704 | - } | |
705 | - | |
706 | - } else { | |
707 | - $newDeviceModel = DeviceRepository::findOne(['device_id'=> null, 'batch_id' => $batchId, 'is_delete' => 0, 'status' => DeviceStatus::NO_AUTH]); | |
708 | - if (!$newDeviceModel) { | |
709 | - $trans = Yii::$app->getDb()->beginTransaction(); | |
710 | - try { | |
711 | - Device::createWithMacSerialNo($batchId, $batchNo, $deviceFailModel->device_id, $deviceFailModel->apply_at, 1, DeviceStatus::HAS_AUTH); | |
712 | - $deviceFailModel->is_delete = 1; | |
713 | - $deviceFailModel->save(); | |
714 | - $trans->commit(); | |
715 | - $e->success = true; | |
716 | - $e->message = '处理成功'; | |
717 | - } catch (Exception $exception) { | |
718 | - $trans->rollBack(); | |
719 | - $e->message = '处理失败, 生成的设备序列号用完,请再点击处理一次'; | |
720 | - } | |
721 | - return $this->renderJson($e); | |
716 | + $e->message = '处理失败, 请再次重处理!'; | |
717 | + $e->success = false; | |
722 | 718 | } |
723 | 719 | |
724 | - $trans = Yii::$app->getDb()->beginTransaction(); | |
725 | - try { | |
726 | - $newDeviceModel->device_id = $deviceFailModel->device_id; | |
727 | - $newDeviceModel->status = DeviceStatus::HAS_AUTH; | |
728 | - $newDeviceModel->apply_at = $deviceFailModel->apply_at; | |
729 | - $newDeviceModel->auth_at = time(); | |
730 | - $newDeviceModel->status = DeviceStatus::HAS_AUTH; | |
731 | - $newDeviceModel->save(); | |
732 | - | |
733 | - $deviceFailModel->is_delete = 1; | |
734 | - $deviceFailModel->save(); | |
735 | - $trans->commit(); | |
736 | - $e->success = true; | |
737 | - $e->message = '处理成功'; | |
738 | - return $this->renderJson($e); | |
739 | - } catch (Exception $exception) { | |
740 | - $trans->rollBack(); | |
741 | - $e->message = '处理失败,系统错误'; | |
742 | - return $this->renderJson($e); | |
743 | - } | |
720 | + return $this->renderJson($e); | |
721 | + } | |
722 | + // 找到未空白未绑定的设备序列号 | |
723 | + $newDeviceModel = DeviceRepository::findOne(['device_id' => null,'batch_id' => $batchId, 'is_delete' => 0, 'status' => DeviceStatus::NO_AUTH]); | |
724 | + if (empty($newDeviceModel)) { | |
725 | + $e->message = '处理失败,系统参数有误'; | |
726 | + return $this->renderJson($e); | |
727 | + } | |
728 | + $trans = Yii::$app->getDb()->beginTransaction(); | |
729 | + try { | |
730 | + $newDeviceModel->device_id = $deviceId; | |
731 | + $newDeviceModel->status = DeviceStatus::HAS_AUTH; | |
732 | + $newDeviceModel->apply_at = $tt ; | |
733 | + $newDeviceModel->auth_at = $tt; | |
734 | + $newDeviceModel->save(); | |
735 | + $deviceFailModel->is_delete = 1; | |
736 | + $deviceFailModel->save(); | |
737 | + $trans->commit(); | |
738 | + $e->message = '处理成功'; | |
739 | + $e->success = true; | |
740 | + } catch (Exception $exception) { | |
741 | + $trans->rollBack(); | |
742 | + $e->message = '处理失败'; | |
743 | + $e->success = false; | |
744 | 744 | } |
745 | + | |
746 | + return $this->renderJson($e); | |
745 | 747 | } |
746 | 748 | |
747 | 749 | /** |
... | ... | @@ -761,6 +763,7 @@ class DeviceController extends BaseController |
761 | 763 | $e->message = '未找到记录'; |
762 | 764 | return $this->renderJson($e); |
763 | 765 | } |
766 | + $tt = time(); | |
764 | 767 | $exitCount = 0; |
765 | 768 | $successCount = 0; |
766 | 769 | $failCount = 0; |
... | ... | @@ -768,7 +771,7 @@ class DeviceController extends BaseController |
768 | 771 | $deviceExitCount = 0; |
769 | 772 | foreach ($deviceFailModels as $k => $deviceFailModel) { |
770 | 773 | $batchNo = Device::getBatchNo($deviceFailModel->manufacture_no, $deviceFailModel->project_no, $deviceFailModel->model_no, $deviceFailModel->production_no); |
771 | - | |
774 | + $deviceId = $deviceFailModel->device_id ; | |
772 | 775 | $batchInfo = CreateBatchRepository::findOne(['batch_no' => $batchNo]); |
773 | 776 | if (empty($batchInfo)) { |
774 | 777 | //该厂商未生产过该批次的设备无法生成 |
... | ... | @@ -776,103 +779,59 @@ class DeviceController extends BaseController |
776 | 779 | continue; |
777 | 780 | } |
778 | 781 | $batchId = $batchInfo->id; |
779 | - $deviceModel = DeviceRepository::findOne(['device_id' => $deviceFailModel->device_id , 'is_delete' => 0]); | |
782 | + $deviceModel = DeviceRepository::findOne(['device_id' => $deviceId, 'is_delete' => 0]); | |
780 | 783 | if ($deviceModel) { |
781 | 784 | //该设备已经授权过 |
782 | - $deviceExitCount++; | |
785 | + if (DeviceStatus::HAS_AUTH == $deviceModel->status) { | |
786 | + $deviceExitCount++; | |
787 | + } elseif(DeviceStatus::NO_AUTH == $deviceModel->status) { | |
788 | + $deviceModel->status = DeviceStatus::HAS_AUTH; | |
789 | + $deviceModel->auth_at = time(); | |
790 | + $deviceModel->save(); | |
791 | + $deviceExitCount++; | |
792 | + | |
793 | + } else { | |
794 | + $deviceExitCount++; | |
795 | + } | |
796 | + | |
783 | 797 | continue; |
784 | 798 | } |
785 | - $count = DeviceRepository::rowsCount(['batch_id' => $batchId, 'status' => DeviceStatus::HAS_AUTH, 'is_delete' => 0]); | |
786 | - | |
787 | - if (($count *1) >= ($batchInfo->num * 1)) { | |
788 | - $exitDeviceModel = DeviceModel::find(); | |
789 | - $exitDeviceModel->where(['batch_id' => $batchId]); | |
790 | - $exitDeviceModel->orderBy('serial_no desc'); | |
791 | - $exitDevice = $exitDeviceModel->one(); | |
792 | - $serialNo = ''; | |
793 | - if ($exitDevice) { | |
794 | - $numNo = mb_substr($exitDevice->serial_no, -4); | |
795 | - $no1 = hexdec($numNo); | |
796 | - $no =($no1 * 1) + 1; | |
797 | - $newNo = sprintf('%04X', $no); | |
798 | - $serialNo = $batchNo.$newNo; | |
799 | + $needGen = DeviceRepository::checkNeedAutoGen($batchId, $batchInfo->num); | |
800 | + if ($needGen) { | |
801 | + $trans = Yii::$app->getDb()->beginTransaction(); | |
802 | + try { | |
803 | + $genDeviceModel = Device::createWithMacSerialNo($batchId, $batchNo, $deviceId, $tt, 0, DeviceStatus::HAS_AUTH); | |
804 | + $deviceFailModel->is_delete = 1; | |
805 | + $deviceFailModel->save(); | |
806 | + $trans->commit(); | |
807 | + $successCount++; | |
808 | + } catch(Exception $exception) { | |
809 | + $trans->rollBack(); | |
810 | + $failCount++; | |
799 | 811 | } |
800 | 812 | |
801 | - $macAddress = Utils::macGenerate(); | |
802 | - $deviceFind = DeviceModel::find(); | |
803 | - $deviceFind->where( | |
804 | - [ | |
805 | - 'or', | |
806 | - ['=', 'serial_no', $serialNo], | |
807 | - ['=', 'mac', $macAddress] | |
808 | - ] | |
809 | - ); | |
810 | - $checkDevice = $deviceFind->one(); | |
811 | - if ($checkDevice) { | |
812 | - //'MAC地址或序列号已经存在,请再处理一次'; | |
813 | - $exitCount++; | |
813 | + } else { | |
814 | + | |
815 | + $newDeviceModel = DeviceRepository::findOne(['device_id' => null, 'batch_id' => $batchId, 'is_delete' => 0, 'status' => DeviceStatus::NO_AUTH]); | |
816 | + if (empty($newDeviceModel)) { | |
817 | + $failCount++; | |
814 | 818 | continue; |
815 | 819 | } |
816 | - | |
817 | 820 | $trans = Yii::$app->getDb()->beginTransaction(); |
818 | 821 | try { |
819 | - $item = [ | |
820 | - 'serial_no' => $serialNo, | |
821 | - 'mac' => $macAddress, | |
822 | - 'device_id' => $deviceFailModel->device_id, | |
823 | - 'batch_id' => $batchId, | |
824 | - 'status' => DeviceStatus::HAS_AUTH, | |
825 | - 'has_re_auth' => 1, | |
826 | - 'apply_at' => $deviceFailModel->apply_at, | |
827 | - 'auth_at' => time(), | |
828 | - ]; | |
829 | - Device::create($item); | |
830 | - // 设备改为删除了 | |
822 | + $newDeviceModel->device_id = $deviceId; | |
823 | + $newDeviceModel->status = DeviceStatus::HAS_AUTH; | |
824 | + $newDeviceModel->apply_at = $tt ; | |
825 | + $newDeviceModel->auth_at = $tt; | |
826 | + $newDeviceModel->save(); | |
831 | 827 | $deviceFailModel->is_delete = 1; |
832 | 828 | $deviceFailModel->save(); |
833 | 829 | $trans->commit(); |
834 | 830 | $successCount++; |
835 | - | |
836 | 831 | } catch (Exception $exception) { |
837 | 832 | $trans->rollBack(); |
838 | 833 | $failCount++; |
839 | 834 | } |
840 | - } else { | |
841 | - | |
842 | - $newDeviceModel = DeviceRepository::findOne(['device_id'=> null, 'batch_id' => $batchId, 'is_delete' => 0, 'status' => DeviceStatus::NO_AUTH]); | |
843 | - if (!$newDeviceModel) { | |
844 | - | |
845 | - $trans = Yii::$app->getDb()->beginTransaction(); | |
846 | - try { | |
847 | - Device::createWithMacSerialNo($batchId, $batchNo, $deviceFailModel->device_id, $deviceFailModel->apply_at, 1, DeviceStatus::HAS_AUTH); | |
848 | - $deviceFailModel->is_delete = 1; | |
849 | - $deviceFailModel->save(); | |
850 | - $trans->commit(); | |
851 | - $successCount++; | |
852 | - } catch (Exception $exception) { | |
853 | - $trans->rollBack(); | |
854 | - $failCount++; | |
855 | - } | |
856 | - | |
857 | - } else { | |
858 | - $trans = Yii::$app->getDb()->beginTransaction(); | |
859 | - try { | |
860 | - $newDeviceModel->device_id = $deviceFailModel->device_id; | |
861 | - $newDeviceModel->status = DeviceStatus::HAS_AUTH; | |
862 | - $newDeviceModel->apply_at = $deviceFailModel->apply_at; | |
863 | - $newDeviceModel->auth_at = time(); | |
864 | - $newDeviceModel->status = DeviceStatus::HAS_AUTH; | |
865 | - $newDeviceModel->save(); | |
866 | - | |
867 | - $deviceFailModel->is_delete = 1; | |
868 | - $deviceFailModel->save(); | |
869 | - $trans->commit(); | |
870 | - $successCount++; | |
871 | - } catch (Exception $exception) { | |
872 | - $trans->rollBack(); | |
873 | - $failCount++; | |
874 | - } | |
875 | - } | |
876 | 835 | |
877 | 836 | } |
878 | 837 | } |
... | ... | @@ -929,10 +888,16 @@ class DeviceController extends BaseController |
929 | 888 | $e->message = '未找到厂商对应的批次无法恢复'; |
930 | 889 | return $this->renderJson($e); |
931 | 890 | } |
932 | - $count = DeviceRepository::rowsCount(['batch_id' => $batchModel->id, 'status' => DeviceStatus::HAS_AUTH, 'is_delete' => 0]); | |
891 | + $where = [ | |
892 | + 'and', | |
893 | + ['=', 'batch_id' , $batchModel->id], | |
894 | + ['=', 'is_delete', 0], | |
895 | + ['is not', 'device_id', Null] | |
896 | + ]; | |
897 | + $count = DeviceRepository::rowsCount($where); | |
933 | 898 | |
934 | 899 | if (($count *1) >= ($batchModel->num * 1)) { |
935 | - $e->message = '该厂商的批次已经满了无法恢复该设备'; | |
900 | + $e->message = '该厂商的批次已满,无法恢复该设备'; | |
936 | 901 | return $this->renderJson($e); |
937 | 902 | } |
938 | 903 | // 检测当前设备ID是否存在表里面 |
... | ... | @@ -956,6 +921,9 @@ class DeviceController extends BaseController |
956 | 921 | return $this->renderJson($e); |
957 | 922 | } |
958 | 923 | |
924 | + /** | |
925 | + * @return string | |
926 | + */ | |
959 | 927 | public function actionBatchRestoreDevice() |
960 | 928 | { |
961 | 929 | $req = Yii::$app->request; |
... | ... | @@ -978,9 +946,16 @@ class DeviceController extends BaseController |
978 | 946 | if (empty($batchModel)) { |
979 | 947 | continue; |
980 | 948 | } |
981 | - $count = DeviceRepository::rowsCount(['batch_id' => $batchModel->id, 'status' => DeviceStatus::HAS_AUTH, 'is_delete' => 0]); | |
949 | + $where = [ | |
950 | + 'and', | |
951 | + ['=', 'batch_id' , $delDevice->batch_id], | |
952 | + ['=', 'is_delete', 0], | |
953 | + ['is not', 'device_id', Null] | |
954 | + ]; | |
955 | + $count = DeviceRepository::rowsCount($where); | |
982 | 956 | if (($count *1) >= ($batchModel->num * 1)) { |
983 | 957 | $fullCount++; |
958 | + continue; | |
984 | 959 | } |
985 | 960 | // 检测当前设备ID是否存在表里面 |
986 | 961 | $exitDevice = DeviceRepository::findOne(['device_id' => $delDevice->device_id, 'is_delete' => 0]); | ... | ... |
console/controllers/TestController.php
... | ... | @@ -157,17 +157,22 @@ class TestController extends Controller |
157 | 157 | public function actionReportAppEvent() |
158 | 158 | { |
159 | 159 | //actionCheckAppVersion |
160 | - $url = 'http://47.107.95.101/app-api/web/reportAppUpgradeEvent'; | |
161 | - //$url = 'http://kingb:8012/app-api/web/reportAppUpgradeEvent'; | |
160 | + //$url = 'http://47.107.95.101/app-api/web/reportAppUpgradeEvent'; | |
161 | + $url = 'http://kingb:8012/app-api/web/reportAppUpgradeEvent'; | |
162 | 162 | |
163 | 163 | $params = [ |
164 | 164 | 'barcode' => '0001000100010001', |
165 | 165 | 'device_id' => 'DGDEVBICEID00001', |
166 | - 'software_version' => 'V1.0.1', | |
167 | - 'hardware_version' => 'V1.0.1', | |
166 | + 'current_version' => 'V1.0.1', | |
167 | + 'target_version' => 'V1.0.1', | |
168 | + 'package_name' => 'com.app.king.dd', | |
169 | + "status" => 0, | |
170 | + "error_code" => '', | |
171 | + "timestamp" => 1572767677 | |
172 | + | |
168 | 173 | ]; |
169 | 174 | $params = json_encode($params); |
170 | - $params = '{"barcode":"0001000100010001","device_id":"DGDEVBICEID00001","current_version":"1","target_version":"2","status":"5","error_code":"0","timestamp":"1572767677"}'; | |
175 | + //$params = '{"barcode":"0001000100010001","device_id":"DGDEVBICEID00001","current_version":"1","target_version":"2","status":"5","error_code":"0","timestamp":"1572767677"}'; | |
171 | 176 | $postResult = Http::POST($url, $params); |
172 | 177 | echo $postResult; |
173 | 178 | } | ... | ... |
domain/upgrade/UpgradeLog.php
... | ... | @@ -36,6 +36,9 @@ class UpgradeLog |
36 | 36 | if (isset($item["model_id"])) { |
37 | 37 | $upgradeLogModel->model_id = $item["model_id"]; // 设备型号ID |
38 | 38 | } |
39 | + if (isset($item["package_name"])) { | |
40 | + $upgradeLogModel->package_name = $item["package_name"]; // 包名 | |
41 | + } | |
39 | 42 | if (isset($item["current_version"])) { |
40 | 43 | $upgradeLogModel->current_version = $item["current_version"]; // 当前版本 |
41 | 44 | } | ... | ... |