dieu chinh update tung doi tuong neu so luong <10

This commit is contained in:
2020-12-25 15:58:02 +07:00
parent dc75b88bd8
commit ddcf67ba9c
6 changed files with 130 additions and 15 deletions

View File

@@ -336,6 +336,7 @@ class ConfigController extends Controller {
\Yii::$app->db->createCommand()->truncateTable('capture_logs')->execute();
\Yii::$app->db->createCommand()->truncateTable('list_management')->execute();
array_map('unlink', glob("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/*.*"));
file_get_contents("http://localhost:2305/update-feature");
}
return Url::to(['/config']);
} else {

View File

@@ -108,7 +108,12 @@ class ControlLogsController extends Controller {
];
$listManagement->image = json_encode($images);
$listManagement->save();
file_get_contents("http://localhost:2305/update-feature");
common::updateFeature([
"cmd" => "update",
"id" => $listManagement->id,
"name" => common::convert_vi_to_en($listManagement->name),
"features" => $listManagement->allFeatures
]);
return ["status" => true];
}
return ["status" => false, "text" => "Hình ảnh này đã được chọn làm mẫu cho đối tượng này!"];

View File

@@ -144,7 +144,12 @@ class ListManagementController extends Controller {
$listManagement->address = $data['address'];
$listManagement->image = json_encode($images);
$listManagement->save();
file_get_contents("http://localhost:2305/update-feature");
common::updateFeature([
"cmd" => "update",
"id" => $listManagement->id,
"name" => common::convert_vi_to_en($listManagement->name),
"features" => $listManagement->allFeatures
]);
return ["status" => true];
}
return ["status" => false, "text" => "Hình ảnh này đã được chọn làm mẫu cho đối tượng này!"];
@@ -237,7 +242,12 @@ class ListManagementController extends Controller {
$model->telephone = $data['telephone'];
$model->address = $data['address'];
$model->save();
file_get_contents("http://localhost:2305/update-feature");
common::updateFeature([
"cmd" => "update",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => $model->allFeatures
]);
return true;
}
}
@@ -250,8 +260,13 @@ class ListManagementController extends Controller {
foreach ($images as $k => $v) {
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url']);
}
common::updateFeature([
"cmd" => "delete",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => []
]);
$model->delete();
file_get_contents("http://localhost:2305/update-feature");
return true;
}
}
@@ -271,7 +286,12 @@ class ListManagementController extends Controller {
}
$model->image = json_encode($features);
$model->save();
file_get_contents("http://localhost:2305/update-feature");
common::updateFeature([
"cmd" => "update",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => $model->allFeatures
]);
return true;
}
}
@@ -295,10 +315,18 @@ class ListManagementController extends Controller {
foreach ($images as $k => $v) {
unlink("/var/www/html/BiFace_Server_Lite/web/data/uploads/face/" . $v['url']);
}
if (count($data['lists']) <= 10)
common::updateFeature([
"cmd" => "delete",
"id" => $staff->id,
"name" => common::convert_vi_to_en($staff->name),
"features" => []
]);
$staff->delete();
}
}
file_get_contents("http://localhost:2305/update-feature");
if (count($data['lists']) > 10)
file_get_contents("http://localhost:2305/update-feature");
return true;
}
}
@@ -385,6 +413,7 @@ class ListManagementController extends Controller {
public function actionSyncFeature() {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$totals = intval(Yii::$app->request->post("totals"));
$server_ip = \app\models\SyncUrl::findOne(['key_config' => 'server_api']);
$ip = "dev-dc.beetai.com";
if ($server_ip)
@@ -438,6 +467,13 @@ class ListManagementController extends Controller {
$model->image = json_encode($ft);
$model->last_modified = time();
$model->save();
if ($totals <= 10)
common::updateFeature([
"cmd" => "update",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => $model->allFeatures
]);
} else {
$model = new ListManagement();
$model->create([
@@ -450,6 +486,13 @@ class ListManagementController extends Controller {
'telephone' => "",
'address' => $data['department']
]);
if ($totals <= 10)
common::updateFeature([
"cmd" => "create",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => $model->allFeatures
]);
}
return ["status" => true];
}
@@ -459,6 +502,7 @@ class ListManagementController extends Controller {
if (Yii::$app->request->post()) {
Yii::$app->response->format = "json";
$data = Yii::$app->request->post();
$totals = intval($data['totals']);
$results = json_decode(file_get_contents("http://" . $data['ip'] . "/api/full-data", false, stream_context_create([
'http' => [
'header' => "Content-Type: application/json",
@@ -494,6 +538,13 @@ class ListManagementController extends Controller {
$model->telephone = $value['telephone'];
$model->address = $value['department'];
$model->save();
if ($totals <= 10)
common::updateFeature([
"cmd" => "update",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => $model->allFeatures
]);
} else {
$model = new ListManagement();
$model->create([
@@ -507,6 +558,13 @@ class ListManagementController extends Controller {
'address' => $value['department'],
'time' => $value['time']
]);
if ($totals <= 10)
common::updateFeature([
"cmd" => "create",
"id" => $model->id,
"name" => common::convert_vi_to_en($model->name),
"features" => $model->allFeatures
]);
}
}
return ["status" => true];
@@ -514,11 +572,11 @@ class ListManagementController extends Controller {
}
public function actionUpdateFeature() {
if (Yii::$app->request->isAjax) {
if (Yii::$app->request->isAjax) {
Yii::$app->response->format = "json";
file_get_contents("http://localhost:2305/update-feature?total=" . ListManagement::find()->count());
return ["status" => true];
}
}
}
public function actionChooseStaff() {