gongchunyi
2 天以前 14999b3d001b6eff1220f7a6701c0796eee1089c
feat: 工序绑定参数列表
已添加8个文件
已修改5个文件
646 ■■■■ 文件已修改
doc/宁夏-中盛建材.sql 67 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/pojo/BaseParam.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/basic/service/impl/BaseParamServiceImpl.java 125 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/controller/ProductProcessParamController.java 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductProcessParamDto.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/dto/ProductProcessParamSortDTO.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/mapper/ProductProcessParamMapper.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/ProductProcess.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/pojo/ProductProcessParam.java 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/ProductProcessParamService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/production/service/impl/ProductProcessParamServiceImpl.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/basic/BaseParamMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/production/ProductProcessParamMapper.xml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
doc/ÄþÏÄ-ÖÐÊ¢½¨²Ä.sql
@@ -177,26 +177,59 @@
    DROP COLUMN `data_sync_type`,
    MODIFY COLUMN `data_source_type` tinyint NULL DEFAULT 1 COMMENT '数据来源类型:1=钉钉同步 2=手动新增' AFTER `form_modified_time`;
-- åˆ é™¤æ—§è¡¨
DROP TABLE IF EXISTS `base_param`;
DROP TABLE IF EXISTS `product_process_param`;
CREATE TABLE `base_param`
(
    id            BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
    param_key     VARCHAR(100) NOT NULL COMMENT '参数唯一标识',
    param_name    VARCHAR(100) NOT NULL COMMENT '参数名称',
    param_type    TINYINT      NOT NULL COMMENT '参数类型(1数字 2文本)',
    value_mode    TINYINT DEFAULT 1 COMMENT '值模式(1单值 2区间)',
    unit          VARCHAR(50) COMMENT '单位',
    default_value VARCHAR(200) COMMENT '默认值(单值参数)',
    default_min   DECIMAL(10, 2) COMMENT '默认最小值(区间参数)',
    default_max   DECIMAL(10, 2) COMMENT '默认最大值(区间参数)',
    is_required   TINYINT DEFAULT 0 COMMENT '是否必填(0否 1是)',
    remark        VARCHAR(255) COMMENT '备注',
    create_user   VARCHAR(64) COMMENT '创建人',
    create_time   DATETIME COMMENT '创建时间',
    update_user   VARCHAR(64) COMMENT '修改人',
    update_time   DATETIME COMMENT '修改时间',
    tenant_id     BIGINT       NOT NULL COMMENT '租户ID'
) COMMENT = '基础参数定义表';
    `id`           bigint                                                        NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `param_key`    varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '参数唯一标识',
    `param_name`   varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '参数名称',
    `param_type`   tinyint                                                       NOT NULL COMMENT '参数类型(1数字 2文本 3下拉选择 4时间)',
    `param_format` varchar(255)                                                  DEFAULT NULL COMMENT '参数格式',
    `value_mode`   tinyint                                                       DEFAULT '1' COMMENT '值模式(1单值 2区间)',
    `unit`         varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci  DEFAULT NULL COMMENT '单位',
    `is_required`  tinyint                                                       DEFAULT '0' COMMENT '是否必填',
    `remark`       varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
    `create_user`  varchar(64)                                                   DEFAULT NULL COMMENT '创建人',
    `create_time`  datetime                                                      DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_user`  varchar(64)                                                   DEFAULT NULL COMMENT '修改人',
    `update_time`  datetime                                                      DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
    `tenant_id`    bigint                                                        DEFAULT NULL COMMENT '租户ID',
    PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 10
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci COMMENT ='基础参数定义表';
CREATE TABLE `product_process_param`
(
    `id`             bigint  NOT NULL AUTO_INCREMENT COMMENT '主键ID',
    `process_id`     bigint  NOT NULL COMMENT '所属工序ID (product_process.id)',
    `param_id`       bigint  NOT NULL COMMENT '关联基础参数ID (base_param.id)',
    `standard_value` varchar(200)     DEFAULT NULL COMMENT '在此工序设定的标准值(单值模式)',
    `min_value`      decimal(10, 2)   DEFAULT NULL COMMENT '在此工序设定的标准最小值(区间模式)',
    `max_value`      decimal(10, 2)   DEFAULT NULL COMMENT '在此工序设定的标准最大值(区间模式)',
    `is_required`    tinyint NOT NULL DEFAULT '0' COMMENT '在此工序中是否必填(0-否, 1-是)',
    `sort`           int     NOT NULL DEFAULT '0' COMMENT '排序号',
    `tenant_id`      bigint           DEFAULT NULL COMMENT '租户ID',
    `create_time`    datetime         DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
    `update_time`    datetime         DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
    PRIMARY KEY (`id`) USING BTREE,
    KEY `idx_process_id` (`process_id`) USING BTREE,
    KEY `idx_param_id` (`param_id`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8mb4
  COLLATE = utf8mb4_0900_ai_ci COMMENT ='工序绑定参数表';
ALTER TABLE `product_process` MODIFY COLUMN `name` varchar(255) COMMENT '工序名称';
ALTER TABLE `product_process` MODIFY COLUMN `no` varchar(255) COMMENT '工序编号';
ALTER TABLE `product_process` ADD COLUMN `status` tinyint(1) DEFAULT '1' COMMENT '状态:0-停用,1-启用' AFTER `no`;
ALTER TABLE `product_process` MODIFY COLUMN `type` bigint COMMENT '类型:0-计时,1-计件';
ALTER TABLE `product_process` MODIFY COLUMN `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间';
ALTER TABLE `product_process` MODIFY COLUMN `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间';
ALTER TABLE `product-inventory-management-zsjc`.`customer`
    ADD COLUMN `form_instance_id` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '宜搭表单实例ID' AFTER `customer_type`,
src/main/java/com/ruoyi/basic/pojo/BaseParam.java
@@ -36,7 +36,7 @@
    @ApiModelProperty("参数名称")
    private String paramName;
    @ApiModelProperty("参数类型(1数字 2文本)")
    @ApiModelProperty("参数类型(1数字 2文本 3下拉选择 4时间)")
    private Integer paramType;
    @ApiModelProperty("参数格式")
@@ -47,15 +47,6 @@
    @ApiModelProperty("单位")
    private String unit;
    @ApiModelProperty("默认值(单值参数)")
    private String defaultValue;
    @ApiModelProperty("默认最小值(区间参数)")
    private BigDecimal defaultMin;
    @ApiModelProperty("默认最大值(区间参数)")
    private BigDecimal defaultMax;
    @ApiModelProperty("是否必填(0否 1是)")
    private Integer isRequired;
src/main/java/com/ruoyi/basic/service/impl/BaseParamServiceImpl.java
@@ -11,8 +11,8 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -41,21 +41,31 @@
        if (list == null || list.isEmpty()) {
            return new ArrayList<>(0);
        }
        // å¤„理日期格式展示
        list.forEach(item -> {
            if (Integer.valueOf(4).equals(item.getParamType()) && StringUtils.isNotEmpty(item.getParamFormat())) {
                item.setParamFormat(toUpperCasePattern(item.getParamFormat()));
            }
        });
        return list;
    }
    @Override
    public int addBaseParam(BaseParam baseParam) {
        if (baseParam == null) {
            throw new RuntimeException("新增参数不能为空");
        }
        // å‚数校验
        checkBaseParam(baseParam, false);
        checkBaseParam(baseParam);
        // è‡ªåŠ¨ç”ŸæˆparamKey
        baseParam.setParamKey(generateParamKey());
        baseParam.setCreateUser(SecurityUtils.getUsername());
        baseParam.setCreateTime(LocalDateTime.now());
        // è®¾ç½®é»˜è®¤å€¼
        if (baseParam.getIsRequired() == null) baseParam.setIsRequired(0);
        if (baseParam.getValueMode() == null) baseParam.setValueMode(1);
        return baseMapper.insert(baseParam);
    }
@@ -66,7 +76,7 @@
            throw new RuntimeException("修改参数ID不能为空");
        }
        // å‚数校验
        checkBaseParam(baseParam, true);
        checkBaseParam(baseParam);
        baseParam.setUpdateUser(SecurityUtils.getUsername());
        baseParam.setUpdateTime(LocalDateTime.now());
@@ -74,76 +84,76 @@
    }
    /**
     * ç”Ÿæˆå‚数唯一key
     * å‚数定义合法校验
     */
    private void checkBaseParam(BaseParam baseParam) {
        if (StringUtils.isEmpty(baseParam.getParamName())) {
            throw new RuntimeException("参数名称不能为空");
        }
        // ç±»åž‹æ ¡éªŒ (1:数字, 2:文本, 3:下拉选择, 4:日期时间)
        List<Integer> validTypes = Arrays.asList(1, 2, 3, 4);
        if (baseParam.getParamType() == null || !validTypes.contains(baseParam.getParamType())) {
            throw new RuntimeException("非法参数类型");
        }
        // å¦‚果是日期类型,校验日期格式配置
        if (Integer.valueOf(4).equals(baseParam.getParamType())) {
            if (StringUtils.isEmpty(baseParam.getParamFormat())) {
                throw new RuntimeException("日期类型必须配置参数格式(如: yyyy-MM-dd)");
            }
            try {
                String standardPattern = normalizePattern(baseParam.getParamFormat());
                DateTimeFormatter.ofPattern(standardPattern);
                baseParam.setParamFormat(standardPattern);
            } catch (Exception e) {
                throw new RuntimeException("日期格式非法: " + baseParam.getParamFormat());
            }
        }
    }
    /**
     * ç”Ÿæˆå‚数唯一key (PARAM_XXX)
     */
    private String generateParamKey() {
        String prefix = "PARAM_";
        // æŸ¥è¯¢å½“前最大key
        LambdaQueryWrapper<BaseParam> wrapper = new LambdaQueryWrapper<>();
        wrapper.select(BaseParam::getParamKey)
                .likeRight(BaseParam::getParamKey, prefix)
                .orderByDesc(BaseParam::getParamKey)
                .last("limit 1");
        BaseParam last = baseMapper.selectOne(wrapper);
        int nextNum = 1;
        if (last != null) {
            String lastKey = last.getParamKey();
            String numStr = lastKey.replace(prefix, "");
            nextNum = Integer.parseInt(numStr) + 1;
        if (last != null && StringUtils.isNotEmpty(last.getParamKey())) {
            try {
                String numStr = last.getParamKey().replace(prefix, "");
                nextNum = Integer.parseInt(numStr) + 1;
            } catch (Exception e) {
                log.error("解析ParamKey异常", e);
            }
        }
        return prefix + String.format("%04d", nextNum);
    }
    /**
     * å‚数合法性校验
     * æ—¥æœŸæ ¼å¼åŒ–
     */
    private void checkBaseParam(BaseParam baseParam, boolean isUpdate) {
        if (baseParam == null) {
            throw new RuntimeException("参数对象不能为空");
        }
        if (StringUtils.isEmpty(baseParam.getParamName())) {
            throw new RuntimeException("参数名称不能为空");
        }
        if (baseParam.getParamType() == null ||
                !(baseParam.getParamType() == 1 || baseParam.getParamType() == 2)) {
            throw new RuntimeException("参数类型必须为1(数字)或2(文本)");
        }
        if (baseParam.getValueMode() == null ||
                !(baseParam.getValueMode() == 1 || baseParam.getValueMode() == 2)) {
            throw new RuntimeException("值模式必须为1(单值)或2(区间)");
        }
    private String normalizePattern(String pattern) {
        if (StringUtils.isEmpty(pattern)) return "yyyy-MM-dd";
        return pattern.replace("YYYY", "yyyy")
                .replace("DD", "dd")
                .replace("SS", "ss");
    }
        // å•值模式
        if (baseParam.getValueMode() == 1) {
            if (StringUtils.isEmpty(baseParam.getDefaultValue())) {
                throw new RuntimeException("单值参数默认值不能为空");
            }
            if (baseParam.getParamType() == 1) {
                try {
                    new BigDecimal(baseParam.getDefaultValue());
                } catch (Exception e) {
                    throw new RuntimeException("默认值必须为数字");
                }
            }
            baseParam.setDefaultMin(null);
            baseParam.setDefaultMax(null);
        }
        // åŒºé—´æ¨¡å¼
        if (baseParam.getValueMode() == 2) {
            if (baseParam.getParamType() != 1) {
                throw new RuntimeException("只有数字类型才能使用区间模式");
            }
            if (baseParam.getDefaultMin() == null || baseParam.getDefaultMax() == null) {
                throw new RuntimeException("区间参数最小值和最大值不能为空");
            }
            if (baseParam.getDefaultMin().compareTo(baseParam.getDefaultMax()) > 0) {
                throw new RuntimeException("最小值不能大于最大值");
            }
            baseParam.setDefaultValue(null);
        }
    /**
     * è½¬æ¢ä¸ºå…¨å¤§å†™æ˜¾ç¤º
     */
    private String toUpperCasePattern(String pattern) {
        if (StringUtils.isEmpty(pattern)) return "";
        return pattern.replace("yyyy", "YYYY")
                .replace("dd", "DD")
                .replace("ss", "SS");
    }
    @Override
@@ -151,7 +161,6 @@
        if (ids == null || ids.length == 0) {
            throw new RuntimeException("删除ID不能为空");
        }
        return baseMapper.deleteBatchIds(Arrays.asList(ids));
    }
}
src/main/java/com/ruoyi/production/controller/ProductProcessParamController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,71 @@
package com.ruoyi.production.controller;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.production.dto.ProductProcessParamSortDTO;
import com.ruoyi.production.pojo.ProductProcessParam;
import com.ruoyi.production.service.ProductProcessParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * <br>
 * å·¥åºç»‘定参数控制层
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 13:33
 */
@RestController
@RequestMapping("/productProcessParam")
@Api(tags = "工序参数绑定管理")
public class ProductProcessParamController {
    @Autowired
    private ProductProcessParamService productProcessParamService;
    @GetMapping("/list/{productProcessId}")
    @Log(title = "根据工序ID查询对应的参数", businessType = BusinessType.OTHER)
    @ApiOperation("根据工序ID查询对应的参数")
    public AjaxResult listByProcessId(@PathVariable("productProcessId") Long productProcessId) {
        return AjaxResult.success(productProcessParamService.listByProcessId(productProcessId));
    }
    @PostMapping("/add")
    @Log(title = "新增工序绑定参数", businessType = BusinessType.INSERT)
    @ApiOperation("新增工序绑定参数")
    public AjaxResult add(@RequestBody ProductProcessParam productProcessParam) {
        productProcessParamService.add(productProcessParam);
        return AjaxResult.success();
    }
    @PutMapping("/edit")
    @Log(title = "修改工序绑定参数", businessType = BusinessType.UPDATE)
    @ApiOperation("修改工序绑定参数")
    public AjaxResult edit(@RequestBody ProductProcessParam productProcessParam) {
        productProcessParamService.edit(productProcessParam);
        return AjaxResult.success();
    }
    @DeleteMapping("/{ids}")
    @Log(title = "删除工序绑定参数", businessType = BusinessType.DELETE)
    @ApiOperation("删除工序绑定参数")
    public AjaxResult remove(@PathVariable List<Long> ids) {
        productProcessParamService.deleteByIds(ids);
        return AjaxResult.success();
    }
    @PutMapping("/sort")
    @Log(title = "更新工序参数排序", businessType = BusinessType.UPDATE)
    @ApiOperation("更新工序参数排序")
    public AjaxResult updateSort(@RequestBody ProductProcessParamSortDTO dto) {
        productProcessParamService.updateSort(dto);
        return AjaxResult.success();
    }
}
src/main/java/com/ruoyi/production/dto/ProductProcessParamDto.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,73 @@
package com.ruoyi.production.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
 * <br>
 * å·¥åºç»‘定参数Dto
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 15:33
 */
@Data
@ApiModel(value = "ProductProcessParamDto对象", description = "工序绑定参数Dto")
public class ProductProcessParamDto {
    @ApiModelProperty("主键ID")
    private Long id;
    @ApiModelProperty("所属工序ID (product_process.id)")
    private Long processId;
    @ApiModelProperty("关联基础参数ID (base_param.id)")
    private Long paramId;
    @ApiModelProperty("在此工序设定的标准值(单值模式使用)")
    private String standardValue;
    @ApiModelProperty("在此工序设定的标准最小值(区间模式使用)")
    private BigDecimal minValue;
    @ApiModelProperty("在此工序设定的标准最大值(区间模式使用)")
    private BigDecimal maxValue;
    @ApiModelProperty("在此工序中是否必填(0-否, 1-是)")
    private Integer isRequired;
    @ApiModelProperty("排序号")
    private Integer sort;
    @ApiModelProperty("参数名称")
    private String paramName;
    @ApiModelProperty("参数类型(1数字 2文本 3下拉选择 4时间)")
    private Integer paramType;
    @ApiModelProperty("参数格式")
    private String paramFormat;
    @ApiModelProperty("值模式(1单值 2区间)")
    private Integer valueMode;
    @ApiModelProperty("单位")
    private String unit;
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
}
src/main/java/com/ruoyi/production/dto/ProductProcessParamSortDTO.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
package com.ruoyi.production.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
 * <br>
 * å·¥åºå‚数排序 DTO
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 14:25
 */
@Data
@ApiModel("工序参数排序入参")
public class ProductProcessParamSortDTO {
    @ApiModelProperty("排序项列表")
    private List<SortItem> items;
    @Data
    @ApiModel("排序项")
    public static class SortItem {
        @ApiModelProperty("记录ID")
        private Long id;
        @ApiModelProperty("排序号")
        private Integer sort;
    }
}
src/main/java/com/ruoyi/production/mapper/ProductProcessParamMapper.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,24 @@
package com.ruoyi.production.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.production.dto.ProductProcessParamDto;
import com.ruoyi.production.pojo.ProductProcessParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
 * <br>
 * å·¥åºç»‘定参数 Mapper æŽ¥å£
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 13:16
 */
public interface ProductProcessParamMapper extends BaseMapper<ProductProcessParam> {
    List<ProductProcessParamDto> selectDtoListByProcessId(@Param("processId") Long processId);
}
src/main/java/com/ruoyi/production/pojo/ProductProcess.java
@@ -42,6 +42,11 @@
    @Excel(name = "备注")
    private String remark;
    /**
     * çŠ¶æ€ï¼š0-停用,1-启用
     */
    private Boolean status;
    /**
     * å·¥èµ„定额
@@ -75,7 +80,7 @@
    @TableField(fill = FieldFill.INSERT)
    private Long tenantId;
    @ApiModelProperty(value ="是否质检")
    @ApiModelProperty(value = "是否质检")
    private Boolean isQuality;
src/main/java/com/ruoyi/production/pojo/ProductProcessParam.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,64 @@
package com.ruoyi.production.pojo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
 * å·¥åºç»‘定参数实体类
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 13:14
 */
@Data
@TableName("product_process_param")
@ApiModel(value = "ProductProcessParam对象", description = "工序绑定参数表")
public class ProductProcessParam implements Serializable {
    private static final long serialVersionUID = 1L;
    @ApiModelProperty("主键ID")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @ApiModelProperty("所属工序ID (product_process.id)")
    private Long processId;
    @ApiModelProperty("关联基础参数ID (base_param.id)")
    private Long paramId;
    @ApiModelProperty("在此工序设定的标准值(单值模式使用)")
    private String standardValue;
    @ApiModelProperty("在此工序设定的标准最小值(区间模式使用)")
    private BigDecimal minValue;
    @ApiModelProperty("在此工序设定的标准最大值(区间模式使用)")
    private BigDecimal maxValue;
    @ApiModelProperty("在此工序中是否必填(0-否, 1-是)")
    private Integer isRequired;
    @ApiModelProperty("排序号")
    private Integer sort;
    @ApiModelProperty("租户ID")
    private Long tenantId;
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
}
src/main/java/com/ruoyi/production/service/ProductProcessParamService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,30 @@
package com.ruoyi.production.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.production.dto.ProductProcessParamDto;
import com.ruoyi.production.dto.ProductProcessParamSortDTO;
import com.ruoyi.production.pojo.ProductProcessParam;
import java.util.List;
/**
 * <br>
 * å·¥åºç»‘定参数接口
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 13:17
 */
public interface ProductProcessParamService extends IService<ProductProcessParam> {
    List<ProductProcessParamDto> listByProcessId(Long processId);
    void add(ProductProcessParam productProcessParam);
    void edit(ProductProcessParam productProcessParam);
    void deleteByIds(List<Long> ids);
    void updateSort(ProductProcessParamSortDTO dto);
}
src/main/java/com/ruoyi/production/service/impl/ProductProcessParamServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,91 @@
package com.ruoyi.production.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.service.BaseParamService;
import com.ruoyi.production.dto.ProductProcessParamDto;
import com.ruoyi.production.dto.ProductProcessParamSortDTO;
import com.ruoyi.production.mapper.ProductProcessParamMapper;
import com.ruoyi.production.pojo.ProductProcessParam;
import com.ruoyi.production.service.ProductProcessParamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
 * <br>
 * å·¥åºç»‘定参数接口实现类
 * </br>
 *
 * @author deslrey
 * @version 1.0
 * @since 2026/03/14 13:18
 */
@Slf4j
@Service
public class ProductProcessParamServiceImpl extends ServiceImpl<ProductProcessParamMapper, ProductProcessParam> implements ProductProcessParamService {
    @Autowired
    private BaseParamService baseParamService;
    @Override
    public List<ProductProcessParamDto> listByProcessId(Long processId) {
        if (processId == null) {
            throw new IllegalArgumentException("工序ID不能为空");
        }
        return baseMapper.selectDtoListByProcessId(processId);
    }
    @Override
    public void add(ProductProcessParam productProcessParam) {
        if (productProcessParam.getProcessId() == null) {
            throw new IllegalArgumentException("关联工序ID不能为空");
        }
        if (productProcessParam.getParamId() == null) {
            throw new IllegalArgumentException("关联基础参数ID不能为空");
        }
        productProcessParam.setCreateTime(new Date());
        if (!this.save(productProcessParam)) {
            throw new RuntimeException("新增失败");
        }
    }
    @Override
    public void edit(ProductProcessParam productProcessParam) {
        if (productProcessParam.getId() == null) {
            throw new IllegalArgumentException("ID不能为空");
        }
        productProcessParam.setUpdateTime(new Date());
        if (!this.updateById(productProcessParam)) {
            throw new RuntimeException("修改失败");
        }
    }
    @Override
    public void deleteByIds(List<Long> ids) {
        if (ids == null || ids.isEmpty()) {
            throw new IllegalArgumentException("ID不能为空");
        }
        if (!this.removeByIds(ids)) {
            throw new RuntimeException("删除失败");
        }
    }
    @Override
    public void updateSort(ProductProcessParamSortDTO dto) {
        if (dto == null || dto.getItems() == null || dto.getItems().isEmpty()) {
            throw new IllegalArgumentException("排序数据不能为空");
        }
        List<ProductProcessParam> list = new ArrayList<>();
        for (ProductProcessParamSortDTO.SortItem item : dto.getItems()) {
            ProductProcessParam param = new ProductProcessParam();
            param.setId(item.getId());
            param.setSort(item.getSort());
            list.add(param);
        }
        this.updateBatchById(list);
    }
}
src/main/resources/mapper/basic/BaseParamMapper.xml
@@ -10,9 +10,6 @@
        <result column="param_format" property="paramFormat"/>
        <result column="value_mode" property="valueMode"/>
        <result column="unit" property="unit"/>
        <result column="default_value" property="defaultValue"/>
        <result column="default_min" property="defaultMin"/>
        <result column="default_max" property="defaultMax"/>
        <result column="is_required" property="isRequired"/>
        <result column="remark" property="remark"/>
        <result column="create_user" property="createUser"/>
src/main/resources/mapper/production/ProductProcessParamMapper.xml
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.production.mapper.ProductProcessParamMapper">
    <resultMap id="ProductProcessParamResult" type="com.ruoyi.production.pojo.ProductProcessParam">
        <id property="id" column="id"/>
        <result property="processId" column="process_id"/>
        <result property="paramId" column="param_id"/>
        <result property="standardValue" column="standard_value"/>
        <result property="minValue" column="min_value"/>
        <result property="maxValue" column="max_value"/>
        <result property="isRequired" column="is_required"/>
        <result property="sort" column="sort"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
    <select id="selectDtoListByProcessId" resultType="com.ruoyi.production.dto.ProductProcessParamDto"
            parameterType="java.lang.Long">
        SELECT ppp.id,
               ppp.process_id,
               ppp.param_id,
               ppp.standard_value,
               ppp.min_value,
               ppp.max_value,
               ppp.is_required,
               ppp.sort,
               ppp.create_time,
               ppp.update_time,
               bp.param_name,
               bp.param_type,
               bp.param_format,
               bp.value_mode,
               bp.unit
        FROM product_process_param ppp
                 LEFT JOIN base_param bp ON ppp.param_id = bp.id
        WHERE ppp.process_id = #{processId}
        ORDER BY ppp.sort ASC
    </select>
</mapper>