feat(supply-chain): sync supplier regions
This commit is contained in:
parent
31ef235c80
commit
7558939482
@ -52,6 +52,7 @@
|
||||
| `storageType` | 入库/代发 | | | `SupplyChainProductArchiveWarehouseConfig.storageType` | 按出入库仓库名称匹配配置表 |
|
||||
| `isSeasonal` | 是否季节性产品 | 暂无来源 | 暂无来源 | | 保持空值 |
|
||||
| `replaceCount` | 替换款数量 | 暂无来源 | 暂无来源 | | 保持空值 |
|
||||
| `region` | 区域 | | | `rpt.js_supplier.region` | 按供应商名称匹配后写主表 |
|
||||
| `supplierName` | 供应商 | `rpt.jst_sku.supplier_name` | `archive_supplier_name` | | 原样保留 |
|
||||
| `supplierType` | 供应商类型 | | | `rpt.js_supplier.scmtype` | 按供应商名称匹配后写主表 |
|
||||
| `supplierStatus` | 供应商状态 | | | `rpt.js_supplier.coopersgn` | `1=合作`、`2=不合作` |
|
||||
|
||||
@ -0,0 +1,2 @@
|
||||
ALTER TABLE "SupplyChainProductArchive"
|
||||
ADD COLUMN "region" TEXT NOT NULL DEFAULT '';
|
||||
@ -531,6 +531,7 @@ model SupplyChainProductArchive {
|
||||
storageType String @default("")
|
||||
isSeasonal String @default("")
|
||||
replaceCount String @default("")
|
||||
region String @default("")
|
||||
supplierName String @default("")
|
||||
purchaseOwner String @default("")
|
||||
supplierType String @default("")
|
||||
|
||||
@ -28,6 +28,7 @@ export const PRODUCT_ARCHIVE_CHANGE_FIELDS = [
|
||||
{ key: 'storageType', label: '入库/代发' },
|
||||
{ key: 'isSeasonal', label: '是否季节性产品' },
|
||||
{ key: 'replaceCount', label: '替换款数量' },
|
||||
{ key: 'region', label: '区域' },
|
||||
{ key: 'supplierName', label: '供应商' },
|
||||
{ key: 'supplierType', label: '供应商类型' },
|
||||
{ key: 'supplierStatus', label: '供应商状态' },
|
||||
|
||||
@ -33,6 +33,7 @@ export type SupplyChainProductArchiveRow = {
|
||||
storageType: string
|
||||
isSeasonal: string
|
||||
replaceCount: string
|
||||
region: string
|
||||
supplier: string
|
||||
supplierType: string
|
||||
supplierStatus: string
|
||||
|
||||
@ -2,6 +2,7 @@ import sql from 'mssql'
|
||||
|
||||
export type JstSupplierProfile = {
|
||||
supplierName: string
|
||||
region: string
|
||||
supplierType: string
|
||||
supplierStatusCode: string
|
||||
purchaser: string
|
||||
@ -85,6 +86,7 @@ class JstSupplierProfileRepositoryClass implements JstSupplierProfileRepository
|
||||
WITH ranked_suppliers AS (
|
||||
SELECT
|
||||
LTRIM(RTRIM(CAST(scmname AS nvarchar(255)))) AS supplierName,
|
||||
LTRIM(RTRIM(COALESCE(CAST(region AS nvarchar(255)), N''))) AS region,
|
||||
LTRIM(RTRIM(COALESCE(CAST(scmtype AS nvarchar(255)), N''))) AS supplierType,
|
||||
LTRIM(RTRIM(COALESCE(CAST(coopersgn AS nvarchar(20)), N''))) AS supplierStatusCode,
|
||||
LTRIM(RTRIM(COALESCE(CAST(buyer AS nvarchar(255)), N''))) AS purchaser,
|
||||
@ -100,6 +102,7 @@ class JstSupplierProfileRepositoryClass implements JstSupplierProfileRepository
|
||||
)
|
||||
SELECT
|
||||
supplierName,
|
||||
region,
|
||||
supplierType,
|
||||
supplierStatusCode,
|
||||
purchaser,
|
||||
|
||||
@ -12,6 +12,7 @@ import {
|
||||
} from '@/lib/supply-chain-product-archive-field-source'
|
||||
|
||||
export const PRODUCT_ARCHIVE_ENRICHMENT_FIELDS = [
|
||||
'region',
|
||||
'supplierType',
|
||||
'supplierStatus',
|
||||
'purchaseOwner',
|
||||
@ -67,6 +68,7 @@ const currentArchiveSelect = {
|
||||
barcode: true,
|
||||
spu: true,
|
||||
fieldSourceMap: true,
|
||||
region: true,
|
||||
supplierType: true,
|
||||
supplierStatus: true,
|
||||
purchaseOwner: true,
|
||||
|
||||
@ -36,6 +36,7 @@ const productArchiveSelect = {
|
||||
storageType: true,
|
||||
isSeasonal: true,
|
||||
replaceCount: true,
|
||||
region: true,
|
||||
supplierName: true,
|
||||
supplierType: true,
|
||||
supplierStatus: true,
|
||||
|
||||
@ -57,6 +57,7 @@ describe('supply-chain product archive enrichment sync', () => {
|
||||
const supplierRepository = {
|
||||
listByNames: jest.fn().mockResolvedValue([{
|
||||
supplierName: '源沃家具',
|
||||
region: '河北',
|
||||
supplierType: '家具厂',
|
||||
supplierStatusCode: '1',
|
||||
purchaser: '千里眼',
|
||||
@ -126,10 +127,15 @@ describe('supply-chain product archive enrichment sync', () => {
|
||||
expect.objectContaining({
|
||||
archiveId: 'archive-1',
|
||||
patch: expect.objectContaining({
|
||||
region: '河北',
|
||||
supplierType: '家具厂',
|
||||
supplierStatus: '合作',
|
||||
purchaseOwner: '千里眼',
|
||||
}),
|
||||
source: expect.objectContaining({
|
||||
sourceObject: 'js_supplier',
|
||||
sourceColumns: expect.objectContaining({ region: 'region' }),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
expect(repository.applyPatch).toHaveBeenCalledWith(
|
||||
|
||||
@ -113,6 +113,7 @@ export function buildProductArchiveEnrichmentUpdates(
|
||||
return [
|
||||
{
|
||||
patch: {
|
||||
region: supplierProfile?.region ?? '',
|
||||
supplierType: supplierProfile?.supplierType ?? '',
|
||||
supplierStatus: supplierStatusLabel(supplierProfile?.supplierStatusCode ?? ''),
|
||||
...(supplierProfile?.purchaser ? { purchaseOwner: supplierProfile.purchaser } : {}),
|
||||
@ -127,6 +128,7 @@ export function buildProductArchiveEnrichmentUpdates(
|
||||
'js_supplier',
|
||||
supplierProfile?.supplierName || target.supplierName || target.barcode,
|
||||
{
|
||||
region: 'region',
|
||||
supplierType: 'scmtype',
|
||||
supplierStatus: 'coopersgn',
|
||||
purchaseOwner: 'buyer',
|
||||
|
||||
@ -66,6 +66,7 @@ export function mapProductArchiveRow({
|
||||
storageType: storageTypeLabel(record.storageType),
|
||||
isSeasonal: record.isSeasonal,
|
||||
replaceCount: record.replaceCount,
|
||||
region: record.region,
|
||||
supplier: record.supplierName,
|
||||
supplierType: record.supplierType,
|
||||
supplierStatus: record.supplierStatus,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user