Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID-ы в прайсы, компании, факторы #3165

Merged
merged 8 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2949,7 +2949,7 @@ def update_company(request):
company_data.pk,
130002,
request.user.doctorprofile,
{"old_company_data": old_company_data, "new_company_data": new_company_data},
{"old_company_data": str(old_company_data), "new_company_data": str(new_company_data)},
)
return JsonResponse({"ok": True})
else:
Expand Down Expand Up @@ -3023,6 +3023,7 @@ def get_harmful_factors(request):
"title": factor.title,
"description": factor.description,
"template_id": factor.template_id,
"cpp_key": factor.cpp_key,
}
for factor in HarmfulFactor.objects.all().order_by("title")
]
Expand Down
42 changes: 42 additions & 0 deletions clients/management/commands/import_harmful_factors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from django.core.management.base import BaseCommand
from openpyxl import load_workbook

from clients.models import HarmfulFactor


class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('path', type=str)

def handle(self, *args, **kwargs):
"""
:param path - xlsx файл со столбцами:
Идентификатор
Код
Наименование
"""

fp = kwargs["path"]
self.stdout.write("Path: " + fp)
wb = load_workbook(filename=fp)
ws = wb[wb.sheetnames[0]]
starts = False
cpp_key, title, description = '', '', ''
for row in ws.rows:
cells = [str(x.value) for x in row]
if not starts:
if "Идентификатор" in cells:
cpp_key = cells.index("Идентификатор")
title = cells.index("Код")
description = cells.index("Наименование")
starts = True
else:
harmful_factor = HarmfulFactor.objects.filter(title=cells[title]).first()
if harmful_factor:
harmful_factor.cpp_key = cells[cpp_key]
harmful_factor.save()
self.stdout.write(f'Фактор {harmful_factor.title} обновлён, UUID={harmful_factor.cpp_key}')
else:
new_harmful_factor = HarmfulFactor(title=cells[title], description=cells[description], cpp_key=cells[cpp_key])
new_harmful_factor.save()
self.stdout.write(f'Фактор {new_harmful_factor.title} создан, UUID={new_harmful_factor.cpp_key}')
3 changes: 2 additions & 1 deletion clients/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1041,8 +1041,9 @@ class Meta:

class HarmfulFactor(models.Model):
title = models.CharField(max_length=255, help_text='Наименование')
description = models.CharField(max_length=255, help_text='Описание', blank=True, default=None, null=True)
description = models.CharField(max_length=1024, help_text='Описание', blank=True, default=None, null=True)
template = models.ForeignKey(AssignmentTemplates, db_index=True, null=True, blank=True, default=None, on_delete=models.CASCADE)
cpp_key = models.UUIDField(null=True, blank=True, editable=False, help_text="UUID, с справочника", db_index=True)

class Meta:
verbose_name = 'Фактор вредности'
Expand Down
6 changes: 5 additions & 1 deletion contracts/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import calendar
import datetime
import uuid
from decimal import Decimal

from django.db import models
Expand Down Expand Up @@ -33,6 +34,7 @@ class PriceName(models.Model):
external_performer = models.BooleanField(default=False, blank=True, help_text='Прайс внешний исполнитель', db_index=True)
subcontract = models.BooleanField(default=False, blank=True, help_text='Прайс субподряд', db_index=True)
symbol_code = models.CharField(max_length=55, unique=True, blank=True, null=True, default=None, help_text='Код прайса', db_index=True)
uuid = models.UUIDField(default=uuid.uuid4, editable=False, help_text="UUID, генерируется автоматически", db_index=True)

def __str__(self):
return "{}".format(self.title)
Expand Down Expand Up @@ -63,7 +65,7 @@ def as_json(price):
else:
company_title = ""
company_id = ""
json_data = {"id": price.id, "title": price.title, "start": price.date_start, "end": price.date_end, "company": company_id, "companyTitle": company_title}
json_data = {"id": price.id, "title": price.title, "start": price.date_start, "end": price.date_end, "company": company_id, "companyTitle": company_title, "uuid": str(price.uuid)}
return json_data

@staticmethod
Expand Down Expand Up @@ -146,6 +148,7 @@ class Company(models.Model):
bik = models.CharField(max_length=9, default='', blank=True)
contract = models.ForeignKey(Contract, blank=True, null=True, db_index=True, on_delete=models.CASCADE)
email = models.CharField(max_length=128, blank=True, default='', help_text="email")
uuid = models.UUIDField(default=uuid.uuid4, editable=False, help_text="UUID, генерируется автоматически", db_index=True)

def __str__(self):
return "{}".format(self.title)
Expand Down Expand Up @@ -186,6 +189,7 @@ def as_json(company):
"kpp": company.kpp,
"bik": company.bik,
"contractId": company.contract_id,
"uuid": company.uuid,
}
return json_data

Expand Down
4 changes: 3 additions & 1 deletion l2-frontend/src/construct/ConstructCompany.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
v-if="!isNewCompany"
class="text-center"
>
{{ originShortTitle }}
{{ originShortTitle }} (<strong>UUID:</strong> {{ company_uuid }})
</h6>
<div class="margin-right margin-left">
<FormulateForm
Expand Down Expand Up @@ -443,6 +443,7 @@ export default {
excludedResearches: [],
researches: [],
month: false,
company_uuid: '',
};
},
computed: {
Expand Down Expand Up @@ -511,6 +512,7 @@ export default {
await this.getDepartments(company.pk);
this.editorCompany = this.currentCompany.data;
this.originShortTitle = this.editorCompany.shortTitle;
this.company_uuid = this.editorCompany.uuid;
},
clearEditCompany() {
this.getContracts();
Expand Down
7 changes: 7 additions & 0 deletions l2-frontend/src/construct/ConstructHarmfulFactor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<colgroup>
<col width="150">
<col>
<col width="285">
<col width="200">
<col width="99">
</colgroup>
Expand All @@ -40,6 +41,9 @@
>
<strong>Описание</strong>
</th>
<th class="text-center">
<strong>UUID</strong>
</th>
<th
class="text-center"
>
Expand Down Expand Up @@ -76,6 +80,9 @@
class="form-control padding-left"
>
</td>
<td class="table-row padding-left">
{{ factor.cpp_key }}
</td>
<td>
<Treeselect
v-model="factor.template_id"
Expand Down
38 changes: 28 additions & 10 deletions l2-frontend/src/construct/ConstructPrice.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<div>
<h4>
Прайс
</h4>
<div class="negative-margin-top">
<div class="radio-button-object">
<RadioField
v-model="searchTypesObject"
Expand Down Expand Up @@ -115,6 +112,20 @@
</div>
</td>
</tr>
<tr
v-if="priceIsSelected"
class="height-row border"
>
<td class="border text-center">
<strong>UUID</strong>
</td>
<td
class=" padding-left"
:colspan="priceIsActive ? 4 : 3"
>
{{ priceData.uuid }}
</td>
</tr>
</table>
</div>
<span v-if="priceIsSelected">
Expand Down Expand Up @@ -256,6 +267,7 @@
<col>
<col width="100">
<col width="100">
<col width="100">
</colgroup>
<tr>
<td class="border">
Expand Down Expand Up @@ -371,6 +383,7 @@ export default {
start: '',
end: '',
company: null,
uuid: '',
};
this.activeStatus.ok = true;
} else {
Expand Down Expand Up @@ -572,9 +585,8 @@ export default {
width: 50%;
margin-left: auto;
margin-right: auto;
margin-top: 2%;
margin-bottom: 2%;
alignment: center;
margin-top: 10px;
margin-bottom: 10px;
}
::v-deep .form-control {
Expand All @@ -590,7 +602,7 @@ export default {
table-layout: fixed;
}
.margin-bottom {
margin-bottom: 20px;
margin-bottom: 10px;
}
.border {
border: 1px solid #ddd;
Expand All @@ -603,11 +615,11 @@ export default {
border: 0;
}
.edit-price {
margin: 20px 0;
margin: 10px 0;
}
.scroll {
min-height: 106px;
max-height: calc(100vh - 600px);
max-height: calc(100vh - 463px);
overflow-y: auto;
}
.sticky {
Expand Down Expand Up @@ -662,4 +674,10 @@ export default {
.r-padding {
padding-right: 10px;
}
.negative-margin-top {
margin-top: -20px;
}
.height-row {
height: 37px;
}
</style>