feat(pl): 吨千克克和升毫升按固定比例折算用证量。
同质量或体积单位不再要求手填系数,普通 http 页面也能生成幂等操作号。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
e7f942b399
commit
da3ec62719
21 files changed
+277
-43
No files matched your search
@@ -286,6 +286,7 @@
|
||||
import { usePlFreightCalc, resolveFreightUnitLabel } from '@/composables/usePlFreightCalc'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { pickBxData } from '@/utils/http/bx'
|
||||
import { randomOperationId } from '@/utils/random-id'
|
||||
import {
|
||||
mapDeliveriesFromApi,
|
||||
mapLegacyPlanToStops,
|
||||
@@ -1641,7 +1642,8 @@
|
||||
try {
|
||||
const archiveBody = { ...frozenBody, confirmOverage }
|
||||
const signature = JSON.stringify({ planId: targetId, archiveBody })
|
||||
if (signature !== quotaArchiveAttempt.signature) quotaArchiveAttempt = { signature, id: crypto.randomUUID() }
|
||||
if (signature !== quotaArchiveAttempt.signature)
|
||||
quotaArchiveAttempt = { signature, id: randomOperationId() }
|
||||
const response = await planApi.archive(
|
||||
targetId,
|
||||
{ ...archiveBody, operationId: quotaArchiveAttempt.id },
|
||||
|
||||
@@ -663,6 +663,7 @@
|
||||
} from '@/api/pl'
|
||||
import { planQuotaApi, type QuotaSourceOption } from '@/api/pl/quota-cert'
|
||||
import { toxicArrangeBlockMessage } from '@/utils/pl-quota-cert-waiver'
|
||||
import { randomOperationId } from '@/utils/random-id'
|
||||
import { arrangeBlockedMessage, isExecutionStarted } from '@/utils/pl-plan-action-guards'
|
||||
import {
|
||||
usePlRemoteCarrierOptions,
|
||||
@@ -2720,7 +2721,7 @@
|
||||
})
|
||||
|
||||
const signature = JSON.stringify({ planId, payload })
|
||||
if (signature !== arrangeAttempt.signature) arrangeAttempt = { signature, id: crypto.randomUUID() }
|
||||
if (signature !== arrangeAttempt.signature) arrangeAttempt = { signature, id: randomOperationId() }
|
||||
try {
|
||||
await submitPlanArrange(
|
||||
planId,
|
||||
|
||||
@@ -36,6 +36,22 @@ export function sameCertUnit(left?: string | null, right?: string | null) {
|
||||
return normalizeProductUnitValue(planUnit) === normalizeProductUnitValue(certUnit)
|
||||
}
|
||||
|
||||
const MASS_IN_GRAMS: Record<string, number> = { g: 1, kg: 1000, dun: 1000000 }
|
||||
const VOLUME_IN_MILLILITRES: Record<string, number> = { hs: 1, sheng: 1000 }
|
||||
|
||||
/** 与后端 standard_conversion_ratio 同一口径:吨/千克/克、升/毫升不用手填系数。 */
|
||||
export function hasStandardUnitConversion(left?: string | null, right?: string | null) {
|
||||
const planUnit = String(left || '').trim()
|
||||
const certUnit = String(right || '').trim()
|
||||
if (!planUnit || !certUnit) return false
|
||||
const source = normalizeProductUnitValue(planUnit)
|
||||
const permit = normalizeProductUnitValue(certUnit)
|
||||
if (!source || !permit || source === permit) return false
|
||||
return [MASS_IN_GRAMS, VOLUME_IN_MILLILITRES].some(
|
||||
(table) => source in table && permit in table
|
||||
)
|
||||
}
|
||||
|
||||
export function coefficientFromQuantities(source: unknown, permit: unknown) {
|
||||
const sourceQty = Number(source)
|
||||
const permitQty = Number(permit)
|
||||
@@ -62,7 +78,13 @@ export function unitConversions(plan: PlanQuota | undefined, sources: QuotaSourc
|
||||
row.sourceStopProductId === source.sourceStopProductId
|
||||
)?.certificates || []
|
||||
return certs
|
||||
.filter((cert) => cert.quantityUnit && source.unit && !sameCertUnit(source.unit, cert.quantityUnit))
|
||||
.filter(
|
||||
(cert) =>
|
||||
cert.quantityUnit &&
|
||||
source.unit &&
|
||||
!sameCertUnit(source.unit, cert.quantityUnit) &&
|
||||
!hasStandardUnitConversion(source.unit, cert.quantityUnit)
|
||||
)
|
||||
.map((cert) => ({
|
||||
sourceId: `${source.sourceStopType}:${source.sourceStopProductId}`,
|
||||
source,
|
||||
|
||||
Reference in new issue
Block a user