Files
FTC25009/scripts/verify-inventory-cancel-and-injob.js

103 lines
4.1 KiB
JavaScript

const fs = require('fs')
const path = require('path')
const root = path.resolve(__dirname, '..')
function read(file) {
return fs.readFileSync(path.join(root, file), 'utf8')
}
function assertMatch(message, content, pattern) {
if (!pattern.test(content)) {
throw new Error(message)
}
}
function assertNotMatch(message, content, pattern) {
if (pattern.test(content)) {
throw new Error(message)
}
}
const inventoryProc = read('sql/20260626_inventory_status_proc.sql')
assertMatch(
'盘点作废必须把主单插入历史表',
inventoryProc,
/IF\s+@target_status\s*=\s*N'5'[\s\S]*INSERT\s+INTO\s+dbo\.pd_stockpd_finish/i
)
assertMatch(
'盘点作废必须把明细插入历史表',
inventoryProc,
/IF\s+@target_status\s*=\s*N'5'[\s\S]*INSERT\s+INTO\s+dbo\.pd_stockpd_detail_finish/i
)
assertMatch(
'盘点作废必须删除业务明细',
inventoryProc,
/IF\s+@target_status\s*=\s*N'5'[\s\S]*DELETE\s+FROM\s+dbo\.pd_stockpd_detail/i
)
assertMatch(
'盘点作废必须删除业务主单',
inventoryProc,
/IF\s+@target_status\s*=\s*N'5'[\s\S]*DELETE\s+FROM\s+dbo\.pd_stockpd/i
)
assertNotMatch(
'盘点作废不能只更新业务表状态',
inventoryProc,
/IF\s+@target_status\s*=\s*N'5'[\s\S]*UPDATE\s+dbo\.pd_stockpd[\s\S]*SET\s+status\s*=\s*N'5'/i
)
const pdInController = read('ruoyi-admin/src/main/java/com/ruoyi/pd/job/controller/PdOutMydoJobController.java')
assertMatch(
'/pd/inJob 当前控制器必须查询盘点入库作业列表',
pdInController,
/@RequestMapping\("\/pd\/inJob"\)[\s\S]*selectInventoryInMydoJobList\(mydoJob\)/
)
assertMatch(
'/pd/inJob 当前控制器必须查询盘点入库历史作业列表',
pdInController,
/@RequestMapping\("\/pd\/inJob"\)[\s\S]*selectInventoryInMydoJobFinishList\(mydoJob\)/
)
assertNotMatch(
'/pd/inJob 当前控制器不能使用出库列表口径',
pdInController,
/@RequestMapping\("\/pd\/inJob"\)[\s\S]*selectOutMydoJobList\(mydoJob\)/
)
assertMatch(
'/pd/inJob 手动作废必须走入库作业过程',
pdInController,
/cancelJob\(jobId,\s*"1"\)/
)
assertMatch(
'/pd/inJob 手动完成必须走入库作业过程',
pdInController,
/completeJob\(jobId,\s*"1"\)/
)
const pdOutController = read('ruoyi-admin/src/main/java/com/ruoyi/pd/job/controller/PdInMydoJobController.java')
assertMatch(
'/pd/outJob 当前控制器必须查询盘点出库作业列表',
pdOutController,
/@RequestMapping\("\/pd\/outJob"\)[\s\S]*selectInventoryOutMydoJobList\(mydoJob\)/
)
assertMatch(
'/pd/outJob 当前控制器必须查询盘点出库历史作业列表',
pdOutController,
/@RequestMapping\("\/pd\/outJob"\)[\s\S]*selectInventoryOutMydoJobFinishList\(mydoJob\)/
)
const mydoJobMapper = read('ruoyi-admin/src/main/resources/mapper/in/MydoJobMapper.xml')
assertMatch('盘点入库作业列表必须限定 in_or_out in (10, 11)', mydoJobMapper, /id="selectInventoryInMydoJobList"[\s\S]*in_or_out\s+in\s+\(10,\s*11\)/i)
assertMatch('盘点入库历史作业列表必须限定 in_or_out in (10, 11)', mydoJobMapper, /id="selectInventoryInMydoJobFinishList"[\s\S]*in_or_out\s+in\s+\(10,\s*11\)/i)
assertMatch('盘点出库作业列表必须限定 in_or_out in (30, 31)', mydoJobMapper, /id="selectInventoryOutMydoJobList"[\s\S]*in_or_out\s+in\s+\(30,\s*31\)/i)
assertMatch('盘点出库历史作业列表必须限定 in_or_out in (30, 31)', mydoJobMapper, /id="selectInventoryOutMydoJobFinishList"[\s\S]*in_or_out\s+in\s+\(30,\s*31\)/i)
const pdInPage = read('ruoyi-ui/src/views/pd/job/in/index.vue')
assertMatch('盘点入库页面必须加载盘点入库任务类型字典', pdInPage, /dicts:\s*\[[^\]]*'pd_in_job_type'/)
assertMatch('盘点入库页面任务类型筛选必须使用盘点入库字典', pdInPage, /dict\.type\.pd_in_job_type/)
const pdOutPage = read('ruoyi-ui/src/views/pd/job/out/index.vue')
assertMatch('盘点出库页面必须加载盘点出库任务类型字典', pdOutPage, /dicts:\s*\[[^\]]*'pd_out_job_type'/)
assertMatch('盘点出库页面任务类型筛选必须使用盘点出库字典', pdOutPage, /dict\.type\.pd_out_job_type/)
console.log('Inventory cancel and inbound job checks passed')