Skip to content

POST /dm-store/partMain/add

Content-Type: application/json

触发按钮:partMainAdd

入参

传递对象:PartMainVo

字段类型必填多选校验规则说明
partCodeString-物料编码
bigCategoryString-大类
smallCategoryString-小类
sonCategoryString-子类
partNameString-物料名称
specString-物料规格
uomString-单位
controlTypeInteger-控制类型
currencyInteger-币种
priceBigDecimal-价格
preferredSupplierString-首选供应商
isPeriodInteger-是否有效期件
isLifeInteger-是否寿命件
maxLifeBigDecimal-最大寿命值
maxLifeUomString-最大寿命单位
useModelString-使用机型
preciousTypeInteger-ABC分类
validFlagInteger-是否可用
descriptionString-备注
packageNumberLong-包装数量
serialRuleInteger-序列号生成规则 1 自动生成 2手动输入

实际入参

json
{
    "partCode": "xxx",
    "partName": "xxx",
    "spec": "xx",
    "bigCategory": "xx",
    "smallCategory": "xx",
    "sonCategory": "xx",
    "currency": 1,
    "preferredSupplier": "FACILITIES CORP",
    "uom": "KW",
    "price": "111",
    "controlType": 1,
    "useModel": "ss",
    "validFlag": 1,
    "description": "22",
    "attachmentVoList": [
        {
            "id": 64634,
            "createTime": "2026-05-21 02:11:17",
            "createUser": "zhongmg2",
            "updateTime": "2026-05-21 02:11:17",
            "updateUser": "zhongmg2",
            "factoryNo": "000027",
            "isDelete": 0,
            "fileId": "DEVICEMATE_PART_MAIN/tst_zmg.png",
            "filePath": "DEVICEMATE_PART_MAIN/tst_zmg.png",
            "fileSize": 458237,
            "fileName": "tst_zmg.png",
            "fileType": "image/png",
            "scope": null,
            "businesskey": "DEVICEMATE_PART_MAIN",
            "targetId": null,
            "baseUrl": "https://10.188.132.96/lemes-api/common/oss/get/",
            "isDelOrUp": null
        }
    ],
    "packageNumber": null,
    "preciousType": 1,
    "maxLife": null,
    "serialRule": 1,
    "maxLifeUom": "",
    "isPeriod": 0,
    "isLife": 0
}

出参

传递对象:ResultData

json
{
    "code": 200,
    "msg": "success"
}

前端校验规则

前端校验
├── 权限校验
│   └── 新增按钮权限
│       └── v-auth: 'information:partMain:add:popup'
├── 表单校验
│   ├── partCode
│   │   └── required: true, trigger: blur
│   ├── partName
│   │   └── required: true, trigger: blur
│   ├── spec
│   │   └── required: true, trigger: blur
│   ├── uom
│   │   └── required: true, trigger: change
│   ├── controlType
│   │   └── required: true, trigger: change
│   ├── price
│   │   ├── required: true, trigger: blur
│   │   ├── 仅允许数字和小数点输入
│   │   ├── 首字符禁止为小数点
│   │   ├── 多个小数点时仅保留一个
│   │   ├── 最多 3 位小数
│   │   └── 失焦时值为 0 或空值触发 warning
│   ├── packageNumber
│   │   ├── required: true(form.controlType == 3 时生效), trigger: blur
│   │   ├── 仅允许整数输入
│   │   └── 失焦时值为 0 或空值触发 warning
│   ├── maxLife
│   │   ├── required: true(form.controlType == 2 && form.isLife == 1 时生效), trigger: blur
│   │   ├── 仅允许数字和小数点输入
│   │   ├── 首字符禁止为小数点
│   │   ├── 多个小数点时仅保留一个
│   │   └── 最多 1 位小数
│   ├── maxLifeUom
│   │   └── required: true(form.controlType == 2 && form.isLife == 1 时生效), trigger: blur
│   └── serialRule
│       └── required: true(form.controlType == 2 时生效), trigger: change
├── 提交拦截校验
│   └── 表单 validate 未通过时不触发 addAction
├── 文件上传校验
│   └── attachmentVoList
│       ├── 仅允许 image/jpeg、image/png、image/gif、image/jpg
│       └── 文件大小限制:小于 5MB

后端逻辑

业务流程:先校验物料是否可新增,再生成物料编号并保存主数据,最后回写附件归属
├── 校验物料可新增:validData :256
│   ├── 校验库存台账占用:findAllList :284
│   ├── 校验物料名称唯一:checkPartMainNameExist :292-295
│   └── 校验物料编码唯一:checkPartMainCodeExist :298-301
├── 生成物料编号:getCommonSeqNo :258
├── 保存物料主记录:save :262
└── 回写附件归属:updateFile :271
    └── 设置附件 targetId

后端校验规则

后端校验
├── 占用与冲突校验
│   └── 校验传入物料代号是否已被库存台账使用:validData :283-289
│       ├── 从库存台账按 partNo 命中即拦截
│       └── StoreExceptionCode.EX201059
└── 业务唯一性校验
    ├── 校验物料名称是否重复:validData :292-295
    │   ├── 按 partName 且 isDelete=0 判重
    │   └── StoreExceptionCode.EX201024
    └── 校验物料编码是否重复:validData :298-301
        ├── 按 partCode 且 isDelete=0 判重
        └── StoreExceptionCode.EX201025

涉及数据库表

库名.表名mapper.statement描述
tools.GLOBAL_SERIALGlobalSerialMapper.updateCurrentValue更新序列号
tools.attachmentAttachmentMapper.update更新附件
store.part_mainPartMainMapper.insert新增物料