import developments registry
parent
5d45af0a51
commit
c8be83be63
|
|
@ -41,7 +41,7 @@ class RegistryType {
|
|||
self::EXPERTS => ['categories' => true, 'states' => true],
|
||||
self::CERTIFICATES => ['categories' => true, 'properties' => 'entry-properties-certificate', 'states' => true],
|
||||
self::COMPANIES => ['properties' => 'entry-properties-company'],
|
||||
self::DEVELOPMENTS => ['categorized' => true, 'properties' => 'entry-properties-development'],
|
||||
self::DEVELOPMENTS => ['categories' => true, 'properties' => 'entry-properties-development'],
|
||||
self::DISCUSSIONS => ['properties' => 'entry-properties-discussion'],
|
||||
self::RESEARCHES => ['categories' => true, 'properties' => 'entry-properties-research'],
|
||||
self::TECHNICAL_CERTIFICATES => ['properties' => 'entry-properties-technical-certificate', 'states' => true],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace App\Services\Registries;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class DevelopmentsImportService extends RegistryImportService {
|
||||
|
||||
public function test() {
|
||||
}
|
||||
|
||||
public function import() {
|
||||
$nodes = $this->dom->find('#part2 tbody tr')->toArray();
|
||||
foreach ($nodes as $node) {
|
||||
list($num, $name, $year, $developer, $funding) = $node->find('td')->toArray();
|
||||
$type = $this->getOperationType($name->text);
|
||||
$category = $this->registry->addCategory(trim($year->text));
|
||||
$entry = $category->entries()->firstOrCreate(['registry_id' => $category->registry_id, 'name' => trim($name->text)]);
|
||||
$entry->properties->setValues(['operation-type' => ['title' => $type], 'primary-developer' => trim($developer->text),
|
||||
'funding-source' => ['title' => trim($funding->text)], 'plan-year' => intval($year->text)]);
|
||||
}
|
||||
}
|
||||
|
||||
public function getOperationType($name) {
|
||||
$types = ['Пересмотр', 'Изменение'];
|
||||
$result = 'Разработка';
|
||||
foreach ($types as $type) {
|
||||
if (str_contains(Str::lower($name), Str::lower($type))) $result = $type;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -45,6 +45,10 @@ class DictionariesTableSeeder extends Seeder {
|
|||
'title' => 'Виды исследовательских работ',
|
||||
'items' => ['nir' => 'НИР', 'niokr' => 'НИОКР']
|
||||
],
|
||||
'funding-sources' => [
|
||||
'title' => 'Источники финансирования',
|
||||
'items' => ['budget' => 'Федеральный бюджет', 'non-budget' => 'Внебюджетные средства']
|
||||
],
|
||||
'normative-document-types' => [
|
||||
'title' => 'Виды нормативно-техничесих документов',
|
||||
'items' => ['sp' => 'СП', 'gost' => 'ГОСТ', 'sn' => 'СН', 'rk-eek' => 'Решение коллегии ЕЭК', 'gost-r' => 'ГОСТ Р',
|
||||
|
|
|
|||
|
|
@ -234,7 +234,12 @@ class FieldsTableSeeder extends Seeder {
|
|||
],
|
||||
'funding-source' => [
|
||||
'title' => 'Источник финансирования',
|
||||
'type' => FieldType::STRING
|
||||
'type' => FieldType::RELATION,
|
||||
'params' => [
|
||||
'appearance' => 'radio',
|
||||
'related' => DictionaryItem::class, 'transformer' => DictionaryItemTransformer::class,
|
||||
'options' => ['show' => true, 'whereHas' => ['dictionary' => ['name' => 'funding-sources']]]
|
||||
]
|
||||
],
|
||||
'plan-year' => [
|
||||
'title' => 'Год плана',
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use App\Imports\CompaniesImport;
|
|||
use App\Models\Registries\Registry;
|
||||
use App\Models\Registries\RegistryType;
|
||||
use App\Models\User;
|
||||
use App\Services\Registries\DevelopmentsImportService;
|
||||
use App\Services\Registries\RulesetImportService;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
|
@ -36,6 +37,19 @@ Artisan::command('htmlparser:import-rulesets', function() {
|
|||
$service->import();
|
||||
});
|
||||
|
||||
Artisan::command('htmlparser:import-developments', function() {
|
||||
$registry = Registry::query()->where(['type' => RegistryType::DEVELOPMENTS])->first();
|
||||
$urls = [
|
||||
"https://www.faufcc.ru/_deyatelnost/_tehnicheskoe_normirovanie/_razrabotka_svodov_pravil/",
|
||||
"https://www.faufcc.ru/_deyatelnost/_tehnicheskoe_normirovanie/_razrabotka_svodov_pravil/?PAGEN_1=2",
|
||||
"https://www.faufcc.ru/_deyatelnost/_tehnicheskoe_normirovanie/_razrabotka_svodov_pravil/?PAGEN_1=3"
|
||||
];
|
||||
foreach ($urls as $url) {
|
||||
$service = new DevelopmentsImportService($registry, $url);
|
||||
$service->import();
|
||||
}
|
||||
});
|
||||
|
||||
Artisan::command('dev:import-ntd', function() {
|
||||
Excel::import(new \App\Imports\NtdRegistryImport(), Storage::path('import/registries/ntd.xlsx'));
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue