feat(stock): 商品新增拣货/复核要求与要求合并开关(pick/recheck/merge_requirements)
This commit is contained in:
parent
cbd8d5bb78
commit
0bfc1ab5b2
@ -43,6 +43,20 @@ module.exports = app => {
|
||||
type: TEXT,
|
||||
comment: '打包要求',
|
||||
},
|
||||
pick_requirements: {
|
||||
type: TEXT,
|
||||
comment: '拣货要求',
|
||||
},
|
||||
recheck_requirements: {
|
||||
type: TEXT,
|
||||
comment: '眼球复核要求',
|
||||
},
|
||||
merge_requirements: {
|
||||
type: CHAR(1),
|
||||
allowNull: false,
|
||||
defaultValue: 'Y',
|
||||
comment: '要求是否合并:Y=合并(拣货/复核要求统一输出打包要求),N=不合并',
|
||||
},
|
||||
|
||||
brand_name: {
|
||||
type: STRING(100),
|
||||
|
||||
@ -260,7 +260,7 @@ ${historyContext}
|
||||
- searchStock/searchWarehouseStock 返回的 image_url 为图片URL数组(可能多张),has_images 为 true 时给出链接
|
||||
- searchStock/searchWarehouseStock 返回的 barcodes 为关联条码,回复时可列出帮助核对
|
||||
- searchStock/searchWarehouseStock 返回的管理标识 is_sn_mgmt/is_shelf_life_mgmt/is_batch_mgmt 分别表示SN管理/效期管理/批次管理
|
||||
- searchStock/searchWarehouseStock 返回的 box_spec 为箱规(长宽高体积毛净重装箱数),packing_requirements 为打包要求,用户问及时告知
|
||||
- searchStock/searchWarehouseStock 返回的 box_spec 为箱规(长宽高体积毛净重装箱数),packing_requirements 为打包要求,pick_requirements 为拣货要求、recheck_requirements 为眼球复核要求(merge_requirements=Y 要求合并时均与打包要求一致),用户问及时告知
|
||||
- searchStock/searchWarehouseStock 返回的 prohibited_type 为违禁品类型,非空时告知用户
|
||||
- 用户说"第1个""第2个"时,按 searchStock 返回的顺序对应选择
|
||||
- 需要上下文但记忆不足时,主动调用 recallHistory 回顾对话历史
|
||||
|
||||
@ -419,7 +419,7 @@ class InboxFunctionsService extends Service {
|
||||
});
|
||||
|
||||
this.register('searchStock', {
|
||||
description: '搜索仓库商品(货主级)。返回商品ID/编码/名称/品牌/单位/毛重/管理标识/库存/图片/关联条码/箱规/违禁品/打包要求',
|
||||
description: '搜索仓库商品(货主级)。返回商品ID/编码/名称/品牌/单位/毛重/管理标识/库存/图片/关联条码/箱规/违禁品/打包要求/拣货要求/眼球复核要求/要求合并',
|
||||
params: {
|
||||
keyword: { type: 'string', required: true, description: '搜索关键词:商品编码(item_code)、条码(barcode)、商品名称(item_name)' },
|
||||
},
|
||||
@ -455,7 +455,7 @@ class InboxFunctionsService extends Service {
|
||||
}
|
||||
|
||||
const items = await ctx.model.StockWarehouse.findAll({
|
||||
attributes: [ 'id', 'item_code', 'item_name', 'brand_name', 'stock_unit', 'gross_weight', 'quantity', 'locked_quantity', 'is_images', 'is_sn_mgmt', 'is_shelf_life_mgmt', 'is_batch_mgmt', 'prohibited_id', 'enable_box_spec', 'box_gross_weight', 'box_net_weight', 'box_length', 'box_width', 'box_height', 'quantity_per_box', 'box_volume', 'packing_requirements' ],
|
||||
attributes: [ 'id', 'item_code', 'item_name', 'brand_name', 'stock_unit', 'gross_weight', 'quantity', 'locked_quantity', 'is_images', 'is_sn_mgmt', 'is_shelf_life_mgmt', 'is_batch_mgmt', 'prohibited_id', 'enable_box_spec', 'box_gross_weight', 'box_net_weight', 'box_length', 'box_width', 'box_height', 'quantity_per_box', 'box_volume', 'packing_requirements', 'pick_requirements', 'recheck_requirements', 'merge_requirements' ],
|
||||
where: {
|
||||
store_id: storeId,
|
||||
[Op.or]: orConditions,
|
||||
@ -548,6 +548,13 @@ class InboxFunctionsService extends Service {
|
||||
net_weight: i.box_net_weight || 0, quantity_per_box: i.quantity_per_box || 0,
|
||||
} : null,
|
||||
packing_requirements: i.packing_requirements || '',
|
||||
pick_requirements: (i.merge_requirements || 'Y') === 'Y'
|
||||
? (i.packing_requirements || '')
|
||||
: (i.pick_requirements || ''),
|
||||
recheck_requirements: (i.merge_requirements || 'Y') === 'Y'
|
||||
? (i.packing_requirements || '')
|
||||
: (i.recheck_requirements || ''),
|
||||
merge_requirements: i.merge_requirements || 'Y',
|
||||
prohibited_type: prohibitedMap[i.prohibited_id] || '',
|
||||
})),
|
||||
},
|
||||
@ -559,7 +566,7 @@ class InboxFunctionsService extends Service {
|
||||
});
|
||||
|
||||
this.register('searchWarehouseStock', {
|
||||
description: '搜索仓库商品(仓库级,不限货主)。返回商品ID/货主/编码/名称/条码/品牌/单位/毛重/管理标识/库存/图片/关联条码/箱规/违禁品/打包要求',
|
||||
description: '搜索仓库商品(仓库级,不限货主)。返回商品ID/货主/编码/名称/条码/品牌/单位/毛重/管理标识/库存/图片/关联条码/箱规/违禁品/打包要求/拣货要求/眼球复核要求/要求合并',
|
||||
params: {
|
||||
keyword: { type: 'string', required: true, description: '搜索关键词:商品编码(item_code)、条码(barcode)、商品名称(item_name)' },
|
||||
},
|
||||
@ -594,7 +601,7 @@ class InboxFunctionsService extends Service {
|
||||
}
|
||||
|
||||
const items = await ctx.model.StockWarehouse.findAll({
|
||||
attributes: [ 'id', 'store_id', 'item_code', 'item_name', 'brand_name', 'stock_unit', 'gross_weight', 'quantity', 'locked_quantity', 'is_images', 'is_sn_mgmt', 'is_shelf_life_mgmt', 'is_batch_mgmt', 'prohibited_id', 'enable_box_spec', 'box_gross_weight', 'box_net_weight', 'box_length', 'box_width', 'box_height', 'quantity_per_box', 'box_volume', 'packing_requirements' ],
|
||||
attributes: [ 'id', 'store_id', 'item_code', 'item_name', 'brand_name', 'stock_unit', 'gross_weight', 'quantity', 'locked_quantity', 'is_images', 'is_sn_mgmt', 'is_shelf_life_mgmt', 'is_batch_mgmt', 'prohibited_id', 'enable_box_spec', 'box_gross_weight', 'box_net_weight', 'box_length', 'box_width', 'box_height', 'quantity_per_box', 'box_volume', 'packing_requirements', 'pick_requirements', 'recheck_requirements', 'merge_requirements' ],
|
||||
where: {
|
||||
[Op.or]: orConditions,
|
||||
},
|
||||
@ -686,6 +693,13 @@ class InboxFunctionsService extends Service {
|
||||
net_weight: i.box_net_weight || 0, quantity_per_box: i.quantity_per_box || 0,
|
||||
} : null,
|
||||
packing_requirements: i.packing_requirements || '',
|
||||
pick_requirements: (i.merge_requirements || 'Y') === 'Y'
|
||||
? (i.packing_requirements || '')
|
||||
: (i.pick_requirements || ''),
|
||||
recheck_requirements: (i.merge_requirements || 'Y') === 'Y'
|
||||
? (i.packing_requirements || '')
|
||||
: (i.recheck_requirements || ''),
|
||||
merge_requirements: i.merge_requirements || 'Y',
|
||||
prohibited_type: prohibitedMap[i.prohibited_id] || '',
|
||||
})),
|
||||
},
|
||||
|
||||
@ -1991,7 +1991,8 @@ class OrderBaseService extends MainService {
|
||||
'id', 'item_code', 'item_name', 'sku_property',
|
||||
'quantity', 'locked_quantity', 'is_batch_mgmt',
|
||||
'is_shelf_life_mgmt', 'is_images',
|
||||
'store_id', 'packing_requirements', 'stock_unit',
|
||||
'store_id', 'packing_requirements', 'pick_requirements',
|
||||
'recheck_requirements', 'merge_requirements', 'stock_unit',
|
||||
],
|
||||
raw: true,
|
||||
}),
|
||||
@ -2053,6 +2054,13 @@ class OrderBaseService extends MainService {
|
||||
is_images: row.is_images || 'N',
|
||||
store_id: row.store_id != null ? Number(row.store_id) : 0,
|
||||
packing_requirements: row.packing_requirements || '',
|
||||
pick_requirements: (row.merge_requirements || 'Y') === 'Y'
|
||||
? (row.packing_requirements || '')
|
||||
: (row.pick_requirements || ''),
|
||||
recheck_requirements: (row.merge_requirements || 'Y') === 'Y'
|
||||
? (row.packing_requirements || '')
|
||||
: (row.recheck_requirements || ''),
|
||||
merge_requirements: row.merge_requirements || 'Y',
|
||||
stock_unit: row.stock_unit || '',
|
||||
image_url: fallbackImageUrlMap.get(row.id) || [],
|
||||
barcodes: fallbackBarcodeMap.get(row.id) || [],
|
||||
@ -2084,6 +2092,9 @@ class OrderBaseService extends MainService {
|
||||
is_images: 'N',
|
||||
store_id: 0,
|
||||
packing_requirements: '',
|
||||
pick_requirements: '',
|
||||
recheck_requirements: '',
|
||||
merge_requirements: 'Y',
|
||||
stock_unit: '',
|
||||
image_url: [],
|
||||
barcodes: [],
|
||||
@ -2107,6 +2118,9 @@ class OrderBaseService extends MainService {
|
||||
is_images: stockDetail.is_images || 'N',
|
||||
store_id: stockDetail.store_id != null ? Number(stockDetail.store_id) : 0,
|
||||
packing_requirements: stockDetail.packing_requirements || '',
|
||||
pick_requirements: stockDetail.pick_requirements || '',
|
||||
recheck_requirements: stockDetail.recheck_requirements || '',
|
||||
merge_requirements: stockDetail.merge_requirements || 'Y',
|
||||
stock_unit: stockDetail.stock_unit || '',
|
||||
image_url: Array.isArray(stockDetail.image_url) ? [ ...stockDetail.image_url ] : [],
|
||||
barcodes: Array.isArray(stockDetail.barcodes) ? [ ...stockDetail.barcodes ] : [],
|
||||
|
||||
@ -859,6 +859,9 @@ class RecheckOrderService extends OrderBaseService {
|
||||
item_name: String(item.item_name || '').trim(),
|
||||
sku_property: String(item.sku_property || '').trim(),
|
||||
packing_requirements: String(item.packing_requirements || '').trim(),
|
||||
pick_requirements: String(item.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(item.recheck_requirements || '').trim(),
|
||||
merge_requirements: String(item.merge_requirements || 'Y').trim(),
|
||||
barcodes: Array.isArray(item.barcodes) ? [ ...item.barcodes ] : [],
|
||||
images: Array.isArray(item.images) ? [ ...item.images ] : [],
|
||||
has_shared_barcode: Boolean(item.has_shared_barcode),
|
||||
@ -1535,6 +1538,9 @@ class RecheckOrderService extends OrderBaseService {
|
||||
item_name: String(stockInfo.item_name || item.item_name || '').trim(),
|
||||
sku_property: String(stockInfo.sku_property || '').trim(),
|
||||
packing_requirements: String(stockInfo.packing_requirements || '').trim(),
|
||||
pick_requirements: String(stockInfo.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(stockInfo.recheck_requirements || '').trim(),
|
||||
merge_requirements: String(stockInfo.merge_requirements || 'Y').trim(),
|
||||
barcodes,
|
||||
images,
|
||||
has_shared_barcode: hasSharedBarcode,
|
||||
|
||||
@ -81,6 +81,9 @@ class WarehouseService extends MainService {
|
||||
bucket: 'storeOutStock',
|
||||
field: 'stock_id',
|
||||
},
|
||||
has_requirements: {
|
||||
bucket: 'requirement',
|
||||
},
|
||||
},
|
||||
});
|
||||
const result = await service.systems.stockStore.getWarehouseStock(where, pagination, sortParams);
|
||||
@ -130,6 +133,9 @@ class WarehouseService extends MainService {
|
||||
bucket: 'storeOutStock',
|
||||
field: 'stock_id',
|
||||
},
|
||||
has_requirements: {
|
||||
bucket: 'requirement',
|
||||
},
|
||||
},
|
||||
});
|
||||
// 始终按当前货主维度查(store_id = self)
|
||||
@ -184,6 +190,9 @@ class WarehouseService extends MainService {
|
||||
bucket: 'storeOutStock',
|
||||
field: 'stock_id',
|
||||
},
|
||||
has_requirements: {
|
||||
bucket: 'requirement',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -268,6 +277,9 @@ class WarehouseService extends MainService {
|
||||
bucket: 'storeOutStock',
|
||||
field: 'stock_id',
|
||||
},
|
||||
has_requirements: {
|
||||
bucket: 'requirement',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -513,6 +525,9 @@ class WarehouseService extends MainService {
|
||||
sku_property,
|
||||
stock_unit,
|
||||
packing_requirements,
|
||||
pick_requirements,
|
||||
recheck_requirements,
|
||||
merge_requirements,
|
||||
length,
|
||||
width,
|
||||
height,
|
||||
@ -556,6 +571,9 @@ class WarehouseService extends MainService {
|
||||
sku_property,
|
||||
stock_unit,
|
||||
packing_requirements,
|
||||
pick_requirements,
|
||||
recheck_requirements,
|
||||
merge_requirements,
|
||||
length,
|
||||
width,
|
||||
height,
|
||||
|
||||
@ -618,6 +618,9 @@ class AfterSaleService extends Service {
|
||||
is_images: stock.is_images || 'N',
|
||||
store_id: stock.store_id || null,
|
||||
packing_requirements: stock.packing_requirements || '',
|
||||
pick_requirements: stock.pick_requirements || '',
|
||||
recheck_requirements: stock.recheck_requirements || '',
|
||||
merge_requirements: stock.merge_requirements || 'Y',
|
||||
stock_unit: stock.stock_unit || '',
|
||||
image_url: stock.image_url || [],
|
||||
barcodes: stock.barcodes || [],
|
||||
|
||||
@ -1506,6 +1506,9 @@ class stockStoreService extends Service {
|
||||
|
||||
// 其他字段
|
||||
packing_requirements: sourceData.packing_requirements || '',
|
||||
pick_requirements: sourceData.pick_requirements || '',
|
||||
recheck_requirements: sourceData.recheck_requirements || '',
|
||||
merge_requirements: sourceData.merge_requirements || 'Y',
|
||||
create_at: now,
|
||||
update_at: now,
|
||||
is_valid: 'Y',
|
||||
@ -1729,6 +1732,9 @@ class stockStoreService extends Service {
|
||||
bucket: 'storeOutStock',
|
||||
field: 'stock_id',
|
||||
},
|
||||
has_requirements: {
|
||||
bucket: 'requirement',
|
||||
},
|
||||
keyword: {
|
||||
bucket: 'keyword',
|
||||
},
|
||||
@ -1798,6 +1804,39 @@ class stockStoreService extends Service {
|
||||
[Op.and]: dynamicConditions,
|
||||
});
|
||||
}
|
||||
|
||||
// 作业要求虚拟筛选:是否有作业要求
|
||||
// 值:Y=有作业要求(拣货/复核/打包任一非空),N=无作业要求,
|
||||
// pick/recheck/packing=对应要求不为空(大小写不敏感)
|
||||
const rawRequirementCondition = rawConditionsByField.has_requirements;
|
||||
if (rawRequirementCondition) {
|
||||
const flagValue = rawRequirementCondition.value;
|
||||
const normalizedFlag = String(flagValue === undefined || flagValue === null ? '' : flagValue).trim().toLowerCase();
|
||||
const isYes = flagValue === true || flagValue === 1 || normalizedFlag === 'y'
|
||||
|| normalizedFlag === 'true' || normalizedFlag === '1'
|
||||
|| normalizedFlag === '是' || normalizedFlag === '有';
|
||||
const isNo = flagValue === false || flagValue === 0 || normalizedFlag === 'n'
|
||||
|| normalizedFlag === 'false' || normalizedFlag === '0'
|
||||
|| normalizedFlag === '否' || normalizedFlag === '无';
|
||||
const singleFieldNameMap = {
|
||||
packing: 'packing_requirements',
|
||||
pick: 'pick_requirements',
|
||||
recheck: 'recheck_requirements',
|
||||
};
|
||||
const singleFieldName = singleFieldNameMap[normalizedFlag] || '';
|
||||
|
||||
if (isYes || isNo || singleFieldName) {
|
||||
const requirementFieldNames = singleFieldName
|
||||
? [ singleFieldName ]
|
||||
: [ 'packing_requirements', 'pick_requirements', 'recheck_requirements' ];
|
||||
const requirementFieldConditions = requirementFieldNames.map(fieldName => (isNo
|
||||
? { [fieldName]: { [Op.or]: [ null, '' ] } }
|
||||
: { [fieldName]: { [Op.and]: [{ [Op.ne]: '' }, { [Op.not]: null }] } }));
|
||||
queryOptions.where[Op.and].push(isNo
|
||||
? { [Op.and]: requirementFieldConditions }
|
||||
: { [Op.or]: requirementFieldConditions });
|
||||
}
|
||||
}
|
||||
if (barcodeDynamicConditions.length > 0) {
|
||||
barcodeQueryOptions.where[Op.and].push({
|
||||
[Op.and]: barcodeDynamicConditions,
|
||||
@ -2549,7 +2588,7 @@ class stockStoreService extends Service {
|
||||
const { ctx, app } = this;
|
||||
const { Op } = app.Sequelize;
|
||||
|
||||
const canChangeFlide = [ 'brand_name', 'prohibited_id', 'gross_weight', 'packing_requirements', 'managementFlags', 'stock_unit', 'need_recheck' ];
|
||||
const canChangeFlide = [ 'brand_name', 'prohibited_id', 'gross_weight', 'packing_requirements', 'pick_requirements', 'recheck_requirements', 'merge_requirements', 'managementFlags', 'stock_unit', 'need_recheck' ];
|
||||
|
||||
const { ids, method, value } = ctx.request.body;
|
||||
|
||||
@ -2632,6 +2671,18 @@ class stockStoreService extends Service {
|
||||
update_by: ctx.user.id || ctx.user.username,
|
||||
};
|
||||
|
||||
} else if (method === 'merge_requirements') {
|
||||
// 要求是否合并:Y=合并,N=不合并
|
||||
const updateValue = String(value).trim().toUpperCase();
|
||||
if (![ 'Y', 'N' ].includes(updateValue)) {
|
||||
return { message: '要求合并必须是 Y(合并)或 N(不合并)', code: 405 };
|
||||
}
|
||||
updateData = {
|
||||
merge_requirements: updateValue,
|
||||
update_at: new Date(),
|
||||
update_by: ctx.user.id || ctx.user.username,
|
||||
};
|
||||
|
||||
} else if (method === 'managementFlags') {
|
||||
// 管理标识是对象格式,需要更新三个独立字段
|
||||
if (typeof value !== 'object') {
|
||||
@ -3050,6 +3101,9 @@ class stockStoreService extends Service {
|
||||
'length',
|
||||
'net_weight',
|
||||
'packing_requirements',
|
||||
'pick_requirements',
|
||||
'recheck_requirements',
|
||||
'merge_requirements',
|
||||
'prohibited_id',
|
||||
'retail_price',
|
||||
'sku_property',
|
||||
@ -3075,6 +3129,15 @@ class stockStoreService extends Service {
|
||||
raw: true,
|
||||
});
|
||||
stock.enable_box_spec = !!stock.enable_box_spec;
|
||||
// 要求合并开关归一化(默认合并);合并时拣货/复核要求统一用打包要求覆盖输出
|
||||
stock.packing_requirements = stock.packing_requirements || '';
|
||||
stock.merge_requirements = stock.merge_requirements || 'Y';
|
||||
stock.pick_requirements = stock.merge_requirements === 'Y'
|
||||
? stock.packing_requirements
|
||||
: (stock.pick_requirements || '');
|
||||
stock.recheck_requirements = stock.merge_requirements === 'Y'
|
||||
? stock.packing_requirements
|
||||
: (stock.recheck_requirements || '');
|
||||
return stock;
|
||||
}
|
||||
/**
|
||||
@ -3088,7 +3151,7 @@ class stockStoreService extends Service {
|
||||
const warehouseId = ctx.user.store_id;
|
||||
const {
|
||||
item_code, item_name, goods_code, sku_property, stock_unit,
|
||||
packing_requirements, length, width, height, volume,
|
||||
packing_requirements, pick_requirements, recheck_requirements, merge_requirements, length, width, height, volume,
|
||||
volume_cm3, volumeCm3,
|
||||
gross_weight, net_weight, tag_price, retail_price,
|
||||
is_sn_mgmt, is_shelf_life_mgmt, is_batch_mgmt,
|
||||
@ -3160,6 +3223,9 @@ class stockStoreService extends Service {
|
||||
sku_property,
|
||||
stock_unit,
|
||||
packing_requirements,
|
||||
pick_requirements,
|
||||
recheck_requirements,
|
||||
merge_requirements,
|
||||
length,
|
||||
width,
|
||||
height,
|
||||
@ -3256,7 +3322,7 @@ class stockStoreService extends Service {
|
||||
const warehouseId = ctx.user.store_id;
|
||||
const {
|
||||
item_code, store_id, item_name, goods_code, sku_property, stock_unit,
|
||||
packing_requirements, length, width, height, volume,
|
||||
packing_requirements, pick_requirements, recheck_requirements, merge_requirements, length, width, height, volume,
|
||||
gross_weight, net_weight, tag_price, retail_price,
|
||||
is_sn_mgmt, is_shelf_life_mgmt, is_batch_mgmt,
|
||||
prohibited_id, brand_name, managementFlags,
|
||||
@ -3284,6 +3350,9 @@ class stockStoreService extends Service {
|
||||
sku_property,
|
||||
stock_unit,
|
||||
packing_requirements,
|
||||
pick_requirements,
|
||||
recheck_requirements,
|
||||
merge_requirements: merge_requirements || 'Y',
|
||||
length,
|
||||
width,
|
||||
height,
|
||||
@ -3363,6 +3432,11 @@ class stockStoreService extends Service {
|
||||
throw new Error('need_recheck 必须是 Y(需要复核)或 N(不需要复核)');
|
||||
}
|
||||
|
||||
// 要求是否合并:仅允许 Y(合并)/ N(不合并)
|
||||
if (data.merge_requirements !== undefined && data.merge_requirements !== null && ![ 'Y', 'N' ].includes(String(data.merge_requirements).trim())) {
|
||||
throw new Error('merge_requirements 必须是 Y(合并)或 N(不合并)');
|
||||
}
|
||||
|
||||
// 数值类型验证
|
||||
const numericFields = [ 'length', 'width', 'height', 'volume', 'gross_weight', 'net_weight' ];
|
||||
for (const field of numericFields) {
|
||||
|
||||
@ -35,7 +35,7 @@ class StockWarehouseService extends Service {
|
||||
* @param {Object} [options={}] 选项
|
||||
* @param {number} [options.warehouseId] 仓库ID(优先使用 options.warehouseId,否则兜底 ctx.user.store_id)
|
||||
* @param {number} [options.cacheTTL=300] 缓存过期时间(秒)
|
||||
* @return {Promise<Array<{id: number, item_code: string, item_name: string, sku_property: string, quantity: number, locked_quantity: number, is_batch_mgmt: string, is_shelf_life_mgmt: string, is_images: string, need_recheck: string, store_id: number, packing_requirements: string, stock_unit: string, image_url: string[], barcodes: Array<{id: number, barcode: string}>}>>} 商品详情列表
|
||||
* @return {Promise<Array<{id: number, item_code: string, item_name: string, sku_property: string, quantity: number, locked_quantity: number, is_batch_mgmt: string, is_shelf_life_mgmt: string, is_images: string, need_recheck: string, store_id: number, packing_requirements: string, pick_requirements: string, recheck_requirements: string, merge_requirements: string, stock_unit: string, image_url: string[], barcodes: Array<{id: number, barcode: string}>}>>} 商品详情列表
|
||||
*/
|
||||
async getStockDetails(stockIds, options = {}) {
|
||||
const { ctx, app } = this;
|
||||
@ -90,7 +90,8 @@ class StockWarehouseService extends Service {
|
||||
'id', 'item_code', 'item_name', 'sku_property',
|
||||
'quantity', 'locked_quantity', 'is_batch_mgmt',
|
||||
'is_shelf_life_mgmt', 'is_images', 'need_recheck',
|
||||
'store_id', 'packing_requirements', 'stock_unit',
|
||||
'store_id', 'packing_requirements', 'pick_requirements',
|
||||
'recheck_requirements', 'merge_requirements', 'stock_unit',
|
||||
],
|
||||
raw: true,
|
||||
}),
|
||||
@ -157,6 +158,13 @@ class StockWarehouseService extends Service {
|
||||
need_recheck: row.need_recheck || 'Y',
|
||||
store_id: row.store_id != null ? Number(row.store_id) : 0,
|
||||
packing_requirements: row.packing_requirements || '',
|
||||
pick_requirements: (row.merge_requirements || 'Y') === 'Y'
|
||||
? (row.packing_requirements || '')
|
||||
: (row.pick_requirements || ''),
|
||||
recheck_requirements: (row.merge_requirements || 'Y') === 'Y'
|
||||
? (row.packing_requirements || '')
|
||||
: (row.recheck_requirements || ''),
|
||||
merge_requirements: row.merge_requirements || 'Y',
|
||||
stock_unit: row.stock_unit || '',
|
||||
image_url: imageUrlMap.get(row.id) || [],
|
||||
barcodes: barcodeMap.get(row.id) || [],
|
||||
@ -208,6 +216,20 @@ class StockWarehouseService extends Service {
|
||||
if (cached && cached.need_recheck == null) {
|
||||
cached.need_recheck = 'Y';
|
||||
}
|
||||
// 兼容旧缓存:无要求合并开关时按默认合并处理;无拣货/复核要求时按合并规则回退为打包要求
|
||||
if (cached && cached.merge_requirements == null) {
|
||||
cached.merge_requirements = 'Y';
|
||||
}
|
||||
if (cached && cached.pick_requirements == null) {
|
||||
cached.pick_requirements = (cached.merge_requirements || 'Y') === 'Y'
|
||||
? (cached.packing_requirements || '')
|
||||
: '';
|
||||
}
|
||||
if (cached && cached.recheck_requirements == null) {
|
||||
cached.recheck_requirements = (cached.merge_requirements || 'Y') === 'Y'
|
||||
? (cached.packing_requirements || '')
|
||||
: '';
|
||||
}
|
||||
result.push(cached);
|
||||
}
|
||||
} else if (dbResults.has(stockId)) {
|
||||
|
||||
@ -31,7 +31,7 @@ class StockWarehouseService extends Service {
|
||||
* @param {Object} [options={}] 选项
|
||||
* @param {number} [options.warehouseId] 仓库ID(优先使用 options.warehouseId,否则兜底 ctx.user.store_id)
|
||||
* @param {number} [options.cacheTTL=300] 缓存过期时间(秒)
|
||||
* @return {Promise<Array<{id: number, item_code: string, item_name: string, sku_property: string, quantity: number, locked_quantity: number, is_batch_mgmt: string, is_shelf_life_mgmt: string, image_url: string, is_images: string, need_recheck: string, store_id: number, packing_requirements: string, stock_unit: string, barcodes: Array<{id: number, barcode: string, sku_property: string}>}>>} 商品详情列表
|
||||
* @return {Promise<Array<{id: number, item_code: string, item_name: string, sku_property: string, quantity: number, locked_quantity: number, is_batch_mgmt: string, is_shelf_life_mgmt: string, image_url: string, is_images: string, need_recheck: string, store_id: number, packing_requirements: string, pick_requirements: string, recheck_requirements: string, merge_requirements: string, stock_unit: string, barcodes: Array<{id: number, barcode: string, sku_property: string}>}>>} 商品详情列表
|
||||
*/
|
||||
async getStockDetails(stockIds, options = {}) {
|
||||
const { ctx, app } = this;
|
||||
@ -78,7 +78,8 @@ class StockWarehouseService extends Service {
|
||||
'quantity', 'locked_quantity', 'is_batch_mgmt',
|
||||
'is_shelf_life_mgmt', 'image_url', 'is_images',
|
||||
'need_recheck',
|
||||
'store_id', 'packing_requirements', 'stock_unit',
|
||||
'store_id', 'packing_requirements', 'pick_requirements',
|
||||
'recheck_requirements', 'merge_requirements', 'stock_unit',
|
||||
],
|
||||
raw: true,
|
||||
});
|
||||
@ -120,6 +121,13 @@ class StockWarehouseService extends Service {
|
||||
need_recheck: row.need_recheck || 'Y',
|
||||
store_id: row.store_id != null ? Number(row.store_id) : 0,
|
||||
packing_requirements: row.packing_requirements || '',
|
||||
pick_requirements: (row.merge_requirements || 'Y') === 'Y'
|
||||
? (row.packing_requirements || '')
|
||||
: (row.pick_requirements || ''),
|
||||
recheck_requirements: (row.merge_requirements || 'Y') === 'Y'
|
||||
? (row.packing_requirements || '')
|
||||
: (row.recheck_requirements || ''),
|
||||
merge_requirements: row.merge_requirements || 'Y',
|
||||
stock_unit: row.stock_unit || '',
|
||||
barcodes: barcodeMap.get(row.id) || [],
|
||||
};
|
||||
@ -159,6 +167,20 @@ class StockWarehouseService extends Service {
|
||||
if (cached.need_recheck == null) {
|
||||
cached.need_recheck = 'Y';
|
||||
}
|
||||
// 兼容旧缓存:无要求合并开关时按默认合并处理;无拣货/复核要求时按合并规则回退为打包要求
|
||||
if (cached.merge_requirements == null) {
|
||||
cached.merge_requirements = 'Y';
|
||||
}
|
||||
if (cached.pick_requirements == null) {
|
||||
cached.pick_requirements = (cached.merge_requirements || 'Y') === 'Y'
|
||||
? (cached.packing_requirements || '')
|
||||
: '';
|
||||
}
|
||||
if (cached.recheck_requirements == null) {
|
||||
cached.recheck_requirements = (cached.merge_requirements || 'Y') === 'Y'
|
||||
? (cached.packing_requirements || '')
|
||||
: '';
|
||||
}
|
||||
result.push(cached);
|
||||
}
|
||||
} else if (dbResults.has(stockId)) {
|
||||
|
||||
@ -1984,6 +1984,9 @@ class WorkbenchService extends Service {
|
||||
barcodes: stock.barcodes || [],
|
||||
image_url: stock.image_url || [],
|
||||
packing_requirements: String(stock.packing_requirements || '').trim(),
|
||||
pick_requirements: String(stock.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(stock.recheck_requirements || '').trim(),
|
||||
merge_requirements: String(stock.merge_requirements || 'Y').trim(),
|
||||
need_recheck: String(stock.need_recheck || 'Y').trim(),
|
||||
is_wave_summary: true,
|
||||
};
|
||||
@ -2103,6 +2106,9 @@ class WorkbenchService extends Service {
|
||||
barcodes: stock.barcodes || [],
|
||||
image_url: stock.image_url || '',
|
||||
packing_requirements: String(stock.packing_requirements || '').trim(),
|
||||
pick_requirements: String(stock.pick_requirements || '').trim(),
|
||||
recheck_requirements: String(stock.recheck_requirements || '').trim(),
|
||||
merge_requirements: String(stock.merge_requirements || 'Y').trim(),
|
||||
need_recheck: String(stock.need_recheck || 'Y').trim(),
|
||||
};
|
||||
});
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('wms_stock_warehouse', 'pick_recheck_requirements', {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
comment: '拣货眼球复核要求',
|
||||
after: 'packing_requirements',
|
||||
});
|
||||
await queryInterface.addColumn('wms_stock_warehouse', 'three_in_one_switch', {
|
||||
type: Sequelize.CHAR(1),
|
||||
allowNull: false,
|
||||
defaultValue: 'Y',
|
||||
comment: '三合一开关:Y=开启,N=关闭',
|
||||
after: 'pick_recheck_requirements',
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeColumn('wms_stock_warehouse', 'three_in_one_switch');
|
||||
await queryInterface.removeColumn('wms_stock_warehouse', 'pick_recheck_requirements');
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('wms_stock_warehouse', 'pick_requirements', {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
comment: '拣货要求',
|
||||
after: 'packing_requirements',
|
||||
});
|
||||
await queryInterface.addColumn('wms_stock_warehouse', 'recheck_requirements', {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
comment: '眼球复核要求',
|
||||
after: 'pick_requirements',
|
||||
});
|
||||
await queryInterface.removeColumn('wms_stock_warehouse', 'pick_recheck_requirements');
|
||||
},
|
||||
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.addColumn('wms_stock_warehouse', 'pick_recheck_requirements', {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
comment: '拣货眼球复核要求',
|
||||
after: 'packing_requirements',
|
||||
});
|
||||
await queryInterface.removeColumn('wms_stock_warehouse', 'recheck_requirements');
|
||||
await queryInterface.removeColumn('wms_stock_warehouse', 'pick_requirements');
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,40 @@
|
||||
'use strict';
|
||||
|
||||
const TABLE_NAME = 'wms_stock_warehouse';
|
||||
const OLD_COLUMN = 'three_in_one_switch';
|
||||
const NEW_COLUMN = 'merge_requirements';
|
||||
|
||||
/**
|
||||
* 将 three_in_one_switch 重命名为 merge_requirements(要求是否合并)。
|
||||
* 语义:Y=合并(拣货/复核要求统一输出打包要求),N=不合并,默认 Y。
|
||||
*/
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
const columns = await queryInterface.describeTable(TABLE_NAME);
|
||||
if (!Object.prototype.hasOwnProperty.call(columns, OLD_COLUMN)) {
|
||||
// 旧列不存在,视为已执行(幂等)
|
||||
return;
|
||||
}
|
||||
await queryInterface.renameColumn(TABLE_NAME, OLD_COLUMN, NEW_COLUMN);
|
||||
await queryInterface.changeColumn(TABLE_NAME, NEW_COLUMN, {
|
||||
type: Sequelize.CHAR(1),
|
||||
allowNull: false,
|
||||
defaultValue: 'Y',
|
||||
comment: '要求是否合并:Y=合并(拣货/复核要求统一输出打包要求),N=不合并',
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
const columns = await queryInterface.describeTable(TABLE_NAME);
|
||||
if (!Object.prototype.hasOwnProperty.call(columns, NEW_COLUMN)) {
|
||||
return;
|
||||
}
|
||||
await queryInterface.renameColumn(TABLE_NAME, NEW_COLUMN, OLD_COLUMN);
|
||||
await queryInterface.changeColumn(TABLE_NAME, OLD_COLUMN, {
|
||||
type: Sequelize.CHAR(1),
|
||||
allowNull: false,
|
||||
defaultValue: 'Y',
|
||||
comment: '三合一开关:Y=开启,N=关闭',
|
||||
});
|
||||
},
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user