tum месяцев назад: 5
Родитель
Сommit
e947a0596f
6 измененных файлов с 147 добавлено и 5 удалено
  1. 20 0
      app/core/utils.py
  2. 27 2
      app/report/views.py
  3. 1 0
      app/static/flowbite.min.css
  4. 2 0
      app/static/flowbite.min.js
  5. 83 0
      app/static/tailwind.js
  6. 14 3
      app/templates/base.html

+ 20 - 0
app/core/utils.py

@@ -242,3 +242,23 @@ SHEET_NAMES = {
242 242
     'thickness_8_point': '9. Thickness 8 Points',
243 243
     'centering': '10. Centering',
244 244
 }
245
+
246
+def convert_mgt_to_mks(mgt_code: str) -> str:
247
+    if not mgt_code:
248
+        raise ValueError("MGT code cannot be empty")
249
+
250
+    last_char = mgt_code[-1]
251
+
252
+    if last_char.isdigit():
253
+        # If last char is digit, code = -01
254
+        base_part = mgt_code[:-1]
255
+        suffix = "-01"
256
+    elif last_char.isalpha():
257
+        # A=1, B=2, ..., Z=26
258
+        code = ord(last_char.upper()) - ord('A') + 1
259
+        base_part = mgt_code[:-1]
260
+        suffix = f"-{code:02d}"
261
+    else:
262
+        raise ValueError("Invalid last character in MGT code")
263
+
264
+    return f"68-{base_part}{suffix}"

+ 27 - 2
app/report/views.py

@@ -4,7 +4,7 @@ from django.contrib import messages
4 4
 from core.models import Report, AllProductDimensionForInsProcess, CustomerTemplateMapping, \
5 5
                 ProductDrawing, MksCodeMap
6 6
 from core.forms import ReportForm, CustomerTemplateMappingForm, ProductDrawingForm
7
-from core.utils import ConfigurableCRUDView, queryFromMaster, SHEET_NAMES
7
+from core.utils import ConfigurableCRUDView, queryFromMaster, SHEET_NAMES, convert_mgt_to_mks
8 8
 from .filters import ReportFilter, CustomerTemplateFilter, ProductDrawingFilter, MksCodeMapFilter
9 9
 from .forms import ExportOptionsForm
10 10
 from pprint import pprint
@@ -1114,12 +1114,32 @@ def create_coi_file(lot_no, sheets, user, md):
1114 1114
         spec = ""
1115 1115
 
1116 1116
     mgt_code = first_result.PRO1 if first_result else "-"
1117
+
1118
+    mks_code = convert_mgt_to_mks(mgt_code)
1119
+    code = f"{mks_code}(MKSコード)  {mgt_code}(参照)"
1120
+    '''
1117 1121
     mks_map = MksCodeMap.objects.filter(mgt_code=mgt_code).first()
1118 1122
     if mks_map:
1119 1123
         code = f"{mks_map.mks_code}(MKSコード)  {mgt_code}(参照)"
1120 1124
     else:
1121 1125
         code = f"{mgt_code}(参照)" or "-"
1126
+    '''
1122 1127
     # first_result.PRO_TOOL = None
1128
+    def get_tool_no(code_number: str) -> str:
1129
+        tool_map = {
1130
+            "547870587D": "A中 内径195",
1131
+            "547870585K": "仕上用",
1132
+            "547870586C": "粗",
1133
+            "547870586F": "A粗 内径195",
1134
+            "547870586H": "B粗",
1135
+            "547870587C": "チュウケンヨウ"
1136
+        }
1137
+        pprint(f"code_number {code_number}")        
1138
+        return tool_map.get(code_number, None)
1139
+    tn = get_tool_no(mgt_code)
1140
+    if tn is None:
1141
+        tn = first_result.PRO_TOOL if first_result and first_result.PRO_TOOL else "-"
1142
+
1123 1143
     data = {
1124 1144
         # "code": first_result.PRO1 if first_result else "-",
1125 1145
         "code": code,
@@ -1133,7 +1153,7 @@ def create_coi_file(lot_no, sheets, user, md):
1133 1153
         # "hardness_out.spe_acc": False,  # Hide rows 24 to 28 if the prefix is "0"
1134 1154
         "acc": accept,  # Hide rows 24 to 28 if the prefix is "0"
1135 1155
         "spe_acc": specialAccept,  # Hide rows 24 to 28 if the prefix is "0"
1136
-        "tool": first_result.PRO_TOOL if first_result and first_result.PRO_TOOL else "-",
1156
+        "tool": tn,
1137 1157
         # "hardness_out.qa1": f"{qa1.first_name} {qa1.last_name}",
1138 1158
         # "hardness_out.qa2": f"{qa2.first_name} {qa2.last_name}",
1139 1159
         "qa1": f"{qa1.first_name} {qa1.last_name}",
@@ -1266,11 +1286,16 @@ def coi_view(request):
1266 1286
                     selected_templates = mapping.template_names if mapping else []
1267 1287
 
1268 1288
                     mgt_code = first_result.PRO1 if first_result else "-"
1289
+                    mks_code = convert_mgt_to_mks(mgt_code)
1290
+                    code = f"{mks_code}(MKSコード)  {mgt_code}(参照)"
1291
+                    
1292
+                    '''
1269 1293
                     mks_map = MksCodeMap.objects.filter(mgt_code=mgt_code).first()
1270 1294
                     if mks_map:
1271 1295
                         code = f"{mks_map.mks_code}(MKSコード)  {mgt_code}(参照)"
1272 1296
                     else:
1273 1297
                         code = f"{mgt_code}(参照)" or "-"
1298
+                    '''
1274 1299
                 else:
1275 1300
                     size_str = ""
1276 1301
                     spec = ""

Разница между файлами не показана из-за своего большого размера
+ 1 - 0
app/static/flowbite.min.css


Разница между файлами не показана из-за своего большого размера
+ 2 - 0
app/static/flowbite.min.js


Разница между файлами не показана из-за своего большого размера
+ 83 - 0
app/static/tailwind.js


+ 14 - 3
app/templates/base.html

@@ -10,12 +10,18 @@
10 10
     <title>{% block title %}COI System{% endblock %}</title>
11 11
 
12 12
     <!-- TailwindCSS -->
13
-    
13
+    <!--
14 14
     <script src="https://cdn.tailwindcss.com"></script> 
15
+    -->
16
+    <script src="{% static "tailwind.js" %}"></script> 
17
+
15 18
   
16 19
     <link href="{% static "font-awesome/css/font-awesome.css" %}" rel="stylesheet" />
17 20
     <script type="text/javascript" defer src="{% static "alpinejs/dist/cdn.min.js" %}"></script>
21
+    <!--
18 22
     <link href="https://cdn.jsdelivr.net/npm/flowbite@2.5.2/dist/flowbite.min.css" rel="stylesheet" />
23
+    -->
24
+    <link href="{% static "flowbite.min.css" %}" rel="stylesheet" />
19 25
     <script type="text/javascript"  src="{% static "axios/dist/axios.js" %}"></script>
20 26
     <script type="text/javascript"  src="{% static "js/main.js" %}"></script>
21 27
 </head>
@@ -32,7 +38,8 @@
32 38
                         </svg>
33 39
                     </button>
34 40
                     <a href="/" class="flex items-center ml-2">
35
-                        <img src="https://flowbite.com/docs/images/logo.svg" class="h-8 mr-3" alt="Logo" />
41
+                      <!--
42
+                        <img src="https://flowbite.com/docs/images/logo.svg" class="h-8 mr-3" alt="Logo" /> -->
36 43
                         <span class="self-center text-xl font-semibold text-black dark:text-white">MGT COI</span>
37 44
                     </a>
38 45
                 </div>
@@ -50,7 +57,8 @@
50 57
                     <div class="ml-3">
51 58
                         <button type="button" class="flex text-sm bg-gray-800 rounded-full focus:ring-4 focus:ring-gray-300 dark:focus:ring-gray-600">
52 59
                             <span class="sr-only">Open user menu</span>
53
-                            <img class="w-8 h-8 rounded-full" src="https://flowbite.com/docs/images/people/profile-picture-5.jpg" alt="User">
60
+                            <!--
61
+                            <img class="w-8 h-8 rounded-full" src="https://flowbite.com/docs/images/people/profile-picture-5.jpg" alt="User"> -->
54 62
                         </button>
55 63
                     </div>
56 64
                 </div>
@@ -219,7 +227,10 @@
219 227
         <p class="text-sm text-gray-600">&copy; 2024 Simplico Co., Ltd. All rights reserved.</p>
220 228
     </footer>
221 229
     <script type="text/javascript" src="{% static "underscore/underscore-min.js" %}"></script>
230
+    <!--
222 231
     <script src="https://cdn.jsdelivr.net/npm/flowbite@2.5.2/dist/flowbite.min.js"></script>
232
+    -->
233
+    <script src="{% static "flowbite.min.js" %}"></script>
223 234
 
224 235
     {% django_browser_reload_script %}
225 236
     <script>