Merge branch 'main' of https://code.sdsdev.co.kr/SDSRV-IDP/sbt-idp into fix/20240215
This commit is contained in:
commit
0d6bcddd40
@ -616,6 +616,8 @@ class RequestViewSet(viewsets.ViewSet):
|
||||
|
||||
subscription_request_files = SubscriptionRequestFile.objects.filter(file_query)
|
||||
|
||||
reviewed_result = json.loads(data["reviewed_result"])
|
||||
|
||||
for subscription_request_file in subscription_request_files:
|
||||
if subscription_request_file.doc_type == 'invoice':
|
||||
subscription_request_file.reviewed_result = reviewed_result
|
||||
@ -624,7 +626,6 @@ class RequestViewSet(viewsets.ViewSet):
|
||||
subscription_request_file.reviewed_result = {"retailername": None, "sold_to_party": None, "purchase_date": [], "imei_number": [reviewed_result["imei_number"][subscription_request_file.index_in_request]]}
|
||||
subscription_request_file.save()
|
||||
|
||||
reviewed_result = json.loads(data["reviewed_result"])
|
||||
for field in ['retailername', 'sold_to_party', 'purchase_date', 'imei_number']:
|
||||
if not field in reviewed_result.keys():
|
||||
raise RequiredFieldException(excArgs=f'reviewed_result.{field}')
|
||||
|
83
cope2n-api/fwd_api/management/commands/migrate-review.py
Normal file
83
cope2n-api/fwd_api/management/commands/migrate-review.py
Normal file
@ -0,0 +1,83 @@
|
||||
# myapp/management/commands/mycustomcommand.py
|
||||
from django.core.management.base import BaseCommand
|
||||
from fwd_api.models import SubscriptionRequestFile, SubscriptionRequest
|
||||
import traceback
|
||||
import copy
|
||||
from openpyxl import load_workbook
|
||||
import datetime
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Migrate reviewed result'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
# Add your command-line arguments here
|
||||
parser.add_argument('test', type=str, help='Value for the argument')
|
||||
|
||||
def process_request(self, subscription_request, ws, row):
|
||||
if len(subscription_request.request_id.split(".")[0].split("_")) < 2:
|
||||
return
|
||||
|
||||
try:
|
||||
reviewed_result = copy.deepcopy(subscription_request.reviewed_result)
|
||||
|
||||
if reviewed_result is None:
|
||||
reviewed_result = {
|
||||
'request_id': subscription_request.request_id,
|
||||
"retailername": None,
|
||||
"sold_to_party": None,
|
||||
"purchase_date": None,
|
||||
"imei_number": []
|
||||
}
|
||||
|
||||
# if ws['J' + str(row)].value:
|
||||
# if isinstance(ws['J' + str(row)].value, str):
|
||||
# reviewed_result['purchase_date'] = ws['J' + str(row)].value
|
||||
# else:
|
||||
# reviewed_result['purchase_date'] = datetime.date.strftime(ws['J' + str(row)].value, "%d/%m/%Y")
|
||||
|
||||
# bad_reason = ws['R' + str(row)].value
|
||||
|
||||
if ws['N' + str(row)].value:
|
||||
reviewed_result['retailername'] = ws['N' + str(row)].value
|
||||
|
||||
bad_reason = ws['P' + str(row)].value
|
||||
|
||||
if not bad_reason:
|
||||
bad_reason = ""
|
||||
|
||||
subscription_request_files = SubscriptionRequestFile.objects.filter(request=subscription_request)
|
||||
|
||||
for subscription_request_file in subscription_request_files:
|
||||
if subscription_request_file.doc_type == 'invoice':
|
||||
subscription_request_file.reviewed_result = reviewed_result
|
||||
subscription_request_file.reviewed_result['imei_number'] = []
|
||||
subscription_request_file.reason = bad_reason
|
||||
# elif subscription_request_file.doc_type == 'imei' and len(reviewed_result['imei_number']) > 0:
|
||||
# subscription_request_file.reviewed_result = {"retailername": None, "sold_to_party": None, "purchase_date": None, "imei_number": [reviewed_result["imei_number"][subscription_request_file.index_in_request]]}
|
||||
subscription_request_file.save()
|
||||
|
||||
subscription_request.reviewed_result = reviewed_result
|
||||
subscription_request.is_reviewed = True
|
||||
|
||||
subscription_request.save()
|
||||
|
||||
except Exception as e:
|
||||
self.stdout.write(self.style.ERROR(f"Request: {subscription_request.request_id} failed with {e}"))
|
||||
print(traceback.format_exc())
|
||||
|
||||
def handle(self, *args, **options):
|
||||
test = options['test']
|
||||
#open csv file
|
||||
wb = load_workbook(filename = test)
|
||||
ws = wb['Sheet1']
|
||||
for row in range(2, 84):
|
||||
print(ws['B' + str(row)].value)
|
||||
request = SubscriptionRequest.objects.filter(request_id=ws['B' + str(row)].value).first()
|
||||
if not request:
|
||||
print("Not found ====>", row)
|
||||
else:
|
||||
self.process_request(request, ws, row)
|
||||
print("")
|
||||
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Sample Django management command executed successfully!'))
|
698
cope2n-fe/package-lock.json
generated
698
cope2n-fe/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -31,6 +31,7 @@
|
||||
"@ant-design/plots": "^1.2.3",
|
||||
"@ant-design/pro-layout": "^7.10.3",
|
||||
"@babel/core": "^7.13.10",
|
||||
"@cyntler/react-doc-viewer": "^1.14.1",
|
||||
"@tanstack/react-query": "^4.20.4",
|
||||
"antd": "^5.4.0",
|
||||
"axios": "^1.2.2",
|
||||
|
BIN
cope2n-fe/public/dummy.pdf
Normal file
BIN
cope2n-fe/public/dummy.pdf
Normal file
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
import { AppstoreOutlined, BarChartOutlined, RotateRightOutlined } from '@ant-design/icons';
|
||||
import { AppstoreOutlined, BarChartOutlined, RotateRightOutlined, FileSearchOutlined } from '@ant-design/icons';
|
||||
import { t } from '@lingui/macro';
|
||||
import { Menu, MenuProps } from 'antd';
|
||||
import React from 'react';
|
||||
@ -34,8 +34,8 @@ function LeftMenu() {
|
||||
|
||||
const generalSubItems = [
|
||||
getItem(t`Dashboard`, '/dashboard', <AppstoreOutlined />),
|
||||
// getItem(t`Reviews`, '/reviews', <FileSearchOutlined />),
|
||||
getItem(t`Reports`, '/reports', <BarChartOutlined />),
|
||||
// getItem(t`Review`, '/reviews', <FileSearchOutlined />),
|
||||
getItem(t`Inference`, '/inference', <RotateRightOutlined />),
|
||||
// getItem(t`Users`, '/users', <UsergroupAddOutlined />),
|
||||
];
|
||||
|
@ -69,7 +69,8 @@ const columns: TableColumnsType<DataType> = [
|
||||
width: '130px',
|
||||
className: 'hide-border-right',
|
||||
render: (_, record) => {
|
||||
return <span>{record.snImeiTC + record.invoiceTC}</span>;
|
||||
const value = record.snImeiTC + record.invoiceTC;
|
||||
return <span>{value ? value : '-'}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -81,12 +82,20 @@ const columns: TableColumnsType<DataType> = [
|
||||
key: 'snImeiTC',
|
||||
width: '50px',
|
||||
className: 'show-border-left',
|
||||
render: (_, record) => {
|
||||
const value = record.snImeiTC;
|
||||
return <span>{value ? value : '-'}</span>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: 'Invoice',
|
||||
dataIndex: 'invoiceTC',
|
||||
key: 'invoiceTC',
|
||||
width: '50px',
|
||||
render: (_, record) => {
|
||||
const value = record.invoiceTC;
|
||||
return <span>{value ? value : '-'}</span>;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -1,5 +1,181 @@
|
||||
function Reviews() {
|
||||
return <div>Reviews</div>;
|
||||
}
|
||||
import { t } from '@lingui/macro';
|
||||
import { Button, message, Upload, Input, Table } from 'antd';
|
||||
import { SbtPageHeader } from 'components/page-header';
|
||||
import { useState } from 'react';
|
||||
import { Layout } from 'antd';
|
||||
import FileViewer from '@cyntler/react-doc-viewer';
|
||||
const { Sider, Content } = Layout;
|
||||
|
||||
export default Reviews;
|
||||
const siderStyle: React.CSSProperties = {
|
||||
backgroundColor: '#fafafa',
|
||||
padding: 10,
|
||||
width: 200,
|
||||
};
|
||||
|
||||
|
||||
const fileList = [
|
||||
{
|
||||
name: "invoice.pdf",
|
||||
url: "/dummpy.pdf",
|
||||
type: "invoice",
|
||||
isBadQuality: false,
|
||||
},
|
||||
{
|
||||
name: "invoice.pdf",
|
||||
url: "/dummpy.pdf",
|
||||
type: "imei",
|
||||
isBadQuality: true,
|
||||
}
|
||||
]
|
||||
|
||||
const dataSource = [
|
||||
{
|
||||
key: '1',
|
||||
value: 'Mike',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
value: 'Mike',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
value: 'Mike',
|
||||
},
|
||||
];
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: 'Key',
|
||||
dataIndex: 'key',
|
||||
key: 'key',
|
||||
},
|
||||
{
|
||||
title: 'Predicted',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
},
|
||||
{
|
||||
title: 'Submitted',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
},
|
||||
{
|
||||
title: 'Revised',
|
||||
dataIndex: 'value',
|
||||
key: 'value',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
const FileCard = ({ file, isSelected, onClick }) => {
|
||||
return (
|
||||
<div style={{
|
||||
border: '1px solid #ccc',
|
||||
width: '200px',
|
||||
backgroundColor: isSelected ? '#d4ecff' : '#fff',
|
||||
padding: '4px 8px',
|
||||
marginRight: '4px',
|
||||
marginTop: '4px',
|
||||
}} onClick={onClick}>
|
||||
<div>
|
||||
<span style={{
|
||||
fontSize: '12px',
|
||||
color: '#333',
|
||||
fontWeight: 'bold',
|
||||
padding: '4px 8px',
|
||||
}}>{file.type.toUpperCase()}</span>
|
||||
<span style={{
|
||||
fontSize: '12px',
|
||||
color: '#aaa',
|
||||
fontWeight: 'bold',
|
||||
padding: '4px 8px',
|
||||
}}>{file.name}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
const InferencePage = () => {
|
||||
const [selectedFileId, setSelectedFileId] = useState(0);
|
||||
const selectFileByIndex = (index) => {
|
||||
setSelectedFileId(index);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <SbtPageHeader
|
||||
title={t`Result Review`}
|
||||
/> */}
|
||||
<Layout style={{
|
||||
overflow: 'hidden',
|
||||
width: '100%',
|
||||
maxWidth: '100%',
|
||||
minHeight: 'calc(100vh - 100px)',
|
||||
maxHeight: 'calc(100vh - 100px)',
|
||||
display: 'flex',
|
||||
padding: '8px',
|
||||
}}>
|
||||
<Content style={{
|
||||
textAlign: 'center',
|
||||
color: '#fff',
|
||||
backgroundColor: '#efefef',
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flexGrow: 1,
|
||||
}}>
|
||||
<div style={{
|
||||
border: "1px solid #ccc",
|
||||
flexGrow: 1,
|
||||
height: '500px',
|
||||
}}>
|
||||
<FileViewer documents={
|
||||
[
|
||||
{ uri: "/dummy.pdf" }
|
||||
]
|
||||
} config={{
|
||||
header: {
|
||||
disableHeader: true,
|
||||
disableFileName: true,
|
||||
retainURLParams: true,
|
||||
},
|
||||
csvDelimiter: ",", // "," as default,
|
||||
pdfVerticalScrollByDefault: true, // false as default
|
||||
}} />
|
||||
</div>
|
||||
<div
|
||||
style={{
|
||||
width: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
height: "100px",
|
||||
flexGrow: 0,
|
||||
}}>
|
||||
{fileList.map((file, index) => (
|
||||
<FileCard key={index} file={file} isSelected={index === selectedFileId} onClick={
|
||||
() => {
|
||||
setSelectedFileId(index);
|
||||
}
|
||||
} />
|
||||
))}
|
||||
</div>
|
||||
</Content>
|
||||
<Sider width="400px" style={siderStyle}>
|
||||
<h2 style={{ margin: "0 0 10px 0" }}>Overview</h2>
|
||||
<Input size='small' addonBefore="Request ID" style={{ marginBottom: "4px" }} readOnly />
|
||||
<Input size='small' addonBefore="Redemption" style={{ marginBottom: "4px" }} readOnly />
|
||||
<Input size='small' addonBefore="Uploaded date" style={{ marginBottom: "4px" }} readOnly />
|
||||
<Input size='small' addonBefore="Request time" style={{ marginBottom: "4px" }} readOnly />
|
||||
<Input size='small' addonBefore="Processing time" style={{ marginBottom: "4px" }} readOnly />
|
||||
<div style={{ marginBottom: "8px", marginTop: "8px", display: "flex" }}>
|
||||
<Button type="primary" size='middle'>Confirm result</Button>
|
||||
</div>
|
||||
<Table dataSource={dataSource} columns={columns} />
|
||||
</Sider>
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default InferencePage;
|
||||
|
Loading…
Reference in New Issue
Block a user