Merge branch 'qms/zhangke' into qms/develop

This commit is contained in:
funny 2026-05-21 15:14:29 +08:00
commit d762e1da52
24 changed files with 1845 additions and 1 deletions

View File

@ -0,0 +1,121 @@
package com.nflg.qms.admin.controller;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleAddQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleAuditQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleEditQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleSearchQO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionRuleDetailVO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionRuleVO;
import com.nflg.qms.admin.service.QmsPqcInspectionRuleControllerService;
import com.nflg.wms.common.constant.Constant;
import com.nflg.wms.common.pojo.ApiResult;
import com.nflg.wms.common.pojo.PageData;
import com.nflg.wms.common.util.MultilingualUtil;
import com.nflg.wms.repository.entity.DictionaryItem;
import com.nflg.wms.repository.service.IDictionaryItemService;
import com.nflg.wms.starter.BaseController;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* PQC检验规则管理
*/
@RestController
@RequestMapping("/pqcInspectionRule")
public class QmsPqcInspectionRuleController extends BaseController {
@Resource
private QmsPqcInspectionRuleControllerService ruleControllerService;
@Resource
private IDictionaryItemService dictionaryItemService;
/**
* 分页查询规则列表
*/
@PostMapping("/search")
public ApiResult<PageData<PqcInspectionRuleVO>> search(@RequestBody PqcInspectionRuleSearchQO qo) {
return ApiResult.success(ruleControllerService.search(qo));
}
/**
* 获取规则详情
*/
@GetMapping("/detail")
public ApiResult<PqcInspectionRuleDetailVO> detail(@NotNull Long id) {
return ApiResult.success(ruleControllerService.getDetail(id));
}
/**
* 新增规则
*/
@PostMapping("/add")
@Transactional
public ApiResult<Void> add(@Valid @RequestBody PqcInspectionRuleAddQO qo) {
ruleControllerService.add(qo);
return ApiResult.success();
}
/**
* 编辑规则
*/
@PostMapping("/edit")
@Transactional
public ApiResult<Void> edit(@Valid @RequestBody PqcInspectionRuleEditQO qo) {
ruleControllerService.edit(qo);
return ApiResult.success();
}
/**
* 批量删除规则
*/
@PostMapping("/delete")
@Transactional
public ApiResult<Void> delete(@RequestBody List<Long> ids) {
ruleControllerService.delete(ids);
return ApiResult.success();
}
/**
* 复制规则
*/
@PostMapping("/copy")
@Transactional
public ApiResult<PqcInspectionRuleDetailVO> copy(@NotNull Long id) {
return ApiResult.success(ruleControllerService.copy(id));
}
/**
* 审核/驳回规则
*/
@PostMapping("/audit")
@Transactional
public ApiResult<Void> audit(@Valid @RequestBody PqcInspectionRuleAuditQO qo) {
ruleControllerService.audit(qo);
return ApiResult.success();
}
/**
* 切换启用/禁用状态
*/
@PostMapping("/toggleDisabled")
@Transactional
public ApiResult<Void> toggleDisabled(@NotNull Long id) {
ruleControllerService.toggleDisabled(id);
return ApiResult.success();
}
/**
* 获取步装字典
*/
@GetMapping("/stepPosition")
public ApiResult<List<DictionaryItem>> getStepPosition() {
return ApiResult.success(dictionaryItemService.getListByDictionaryCode(
Constant.DICTIONARY_STEP_POSITION, MultilingualUtil.getLanguage()));
}
}

View File

@ -0,0 +1,100 @@
package com.nflg.qms.admin.pojo.qo;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import java.util.List;
/**
* PQC检验规则新增参数
*/
@Data
public class PqcInspectionRuleAddQO {
/**
* 机型编号必填
*/
@NotBlank(message = "机型编号不能为空")
private String modelNo;
/**
* 规则编号可选后端自动生成
*/
private String pqcRuleCode;
/**
* 检查点列表
*/
@Valid
private List<PqcInspectionPointAddQO> inspectionPoints;
/**
* PQC检查点新增参数
*/
@Data
public static class PqcInspectionPointAddQO {
/**
* 步装名称必填
*/
@NotBlank(message = "步装名称不能为空")
private String stepName;
/**
* 步装字典ID必填
*/
private Long stepDicItemId;
/**
* 检查点编号必填
*/
@NotBlank(message = "检查点编号不能为空")
private String inspectionPointCode;
/**
* 检查点名称必填
*/
@NotBlank(message = "检查点名称不能为空")
private String inspectionPointName;
/**
* 检查项列表
*/
@Valid
private List<PqcInspectionPointItemAddQO> inspectionItems;
}
/**
* PQC检查项新增参数
*/
@Data
public static class PqcInspectionPointItemAddQO {
/**
* 检查内容必填
*/
@NotBlank(message = "检查内容不能为空")
private String inspectionContent;
/**
* 检查类型0=工序检查1=关键物料拍照2=全部必填
*/
private Integer inspectionType;
/**
* 判定类型0=目视1=量具必填
*/
private Integer inspectionMethods;
/**
* 样例图地址
*/
private String inspectionImgUrl;
/**
* 星级1-3级必填
*/
private Integer inspectionLevel;
}
}

View File

@ -0,0 +1,28 @@
package com.nflg.qms.admin.pojo.qo;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**
* PQC检验规则审核参数
*/
@Data
public class PqcInspectionRuleAuditQO {
/**
* 规则ID必填
*/
@NotNull(message = "规则ID不能为空")
private Long id;
/**
* 审核结果1=通过2=驳回必填
*/
@NotNull(message = "审核结果不能为空")
private Integer auditStatus;
/**
* 驳回原因驳回时必填
*/
private String auditRemark;
}

View File

@ -0,0 +1,113 @@
package com.nflg.qms.admin.pojo.qo;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.List;
/**
* PQC检验规则编辑参数
*/
@Data
public class PqcInspectionRuleEditQO {
/**
* 规则ID必填
*/
@NotNull(message = "规则ID不能为空")
private Long id;
/**
* 机型编号必填
*/
@NotBlank(message = "机型编号不能为空")
private String modelNo;
/**
* 检查点列表
*/
@Valid
private List<PqcInspectionPointEditQO> inspectionPoints;
/**
* PQC检查点编辑参数
*/
@Data
public static class PqcInspectionPointEditQO {
/**
* 检查点ID编辑时必填
*/
private Long id;
/**
* 步装名称
*/
private String stepName;
/**
* 步装字典ID
*/
private Long stepDicItemId;
/**
* 检查点编号
*/
private String inspectionPointCode;
/**
* 检查点名称
*/
private String inspectionPointName;
/**
* 检查项列表
*/
@Valid
private List<PqcInspectionPointItemEditQO> inspectionItems;
}
/**
* PQC检查项编辑参数
*/
@Data
public static class PqcInspectionPointItemEditQO {
/**
* 检查项ID编辑时必填
*/
private Long id;
/**
* 检查内容
*/
private String inspectionContent;
/**
* 检查类型
*/
private Integer inspectionType;
/**
* 判定类型
*/
private Integer inspectionMethods;
/**
* 样例图地址
*/
private String inspectionImgUrl;
/**
* 星级
*/
private Integer inspectionLevel;
/**
* 排序
*/
private Integer sort;
}
}

View File

@ -0,0 +1,45 @@
package com.nflg.qms.admin.pojo.qo;
import com.nflg.wms.common.pojo.qo.PageQO;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
/**
* PQC检验规则搜索参数
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class PqcInspectionRuleSearchQO extends PageQO {
/**
* 机型编号模糊搜索
*/
private String modelNo;
/**
* 规则编号
*/
private String pqcRuleCode;
/**
* 启用状态true=启用false=禁用
*/
private Boolean isDisabled;
/**
* 审核状态0=未审核1=已审核2=已驳回
*/
private Integer auditStatus;
/**
* 创建时间开始
*/
private LocalDateTime createTimeStart;
/**
* 创建时间结束
*/
private LocalDateTime createTimeEnd;
}

View File

@ -0,0 +1,109 @@
package com.nflg.qms.admin.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* 检查项VO
*/
@Data
@Accessors(chain = true)
public class PqcInspectionPointItemVO {
/**
* 主键ID
*/
private Long id;
/**
* 检查点ID
*/
private Long pointId;
/**
* 检验规则ID
*/
private Long ruleId;
/**
* 检查项名称
*/
private String itemName;
/**
* 检查项编码
*/
private String itemCode;
/**
* 检验标准
*/
private String standard;
/**
* 检验方法
*/
private String inspectionMethod;
/**
* 上限值
*/
private String upperLimit;
/**
* 下限值
*/
private String lowerLimit;
/**
* 单位
*/
private String unit;
/**
* 检查顺序
*/
private Integer sort;
/**
* 是否必填0-1-
*/
private Short isRequired;
/**
* 备注
*/
private String remark;
/**
* 创建人ID
*/
private Long createId;
/**
* 创建人名称
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改人ID
*/
private Long modifyId;
/**
* 修改人名称
*/
private String modifyName;
/**
* 修改时间
*/
private LocalDateTime modifyTime;
}

View File

@ -0,0 +1,80 @@
package com.nflg.qms.admin.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
/**
* 检查点VO
*/
@Data
@Accessors(chain = true)
public class PqcInspectionPointVO {
/**
* 主键ID
*/
private Long id;
/**
* 检验规则ID
*/
private Long ruleId;
/**
* 检查点名称
*/
private String pointName;
/**
* 检查点编码
*/
private String pointCode;
/**
* 检查顺序
*/
private Integer sort;
/**
* 备注
*/
private String remark;
/**
* 创建人ID
*/
private Long createId;
/**
* 创建人名称
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改人ID
*/
private Long modifyId;
/**
* 修改人名称
*/
private String modifyName;
/**
* 修改时间
*/
private LocalDateTime modifyTime;
/**
* 检查项列表
*/
private List<PqcInspectionPointItemVO> inspectionItems;
}

View File

@ -0,0 +1,130 @@
package com.nflg.qms.admin.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.List;
/**
* 检验规则详情VO
*/
@Data
@Accessors(chain = true)
public class PqcInspectionRuleDetailVO {
/**
* 主键ID
*/
private Long id;
/**
* 规则编码
*/
private String ruleCode;
/**
* 规则名称
*/
private String ruleName;
/**
* 物料编码
*/
private String materialCode;
/**
* 物料描述
*/
private String materialName;
/**
* 规则类型
*/
private Short ruleType;
/**
* 规则类型名称
*/
private String ruleTypeName;
/**
* 适用工序
*/
private String processCode;
/**
* 适用工序名称
*/
private String processName;
/**
* 审核状态0-待审核1-审核通过2-审核不通过
*/
private Short auditStatus;
/**
* 审核状态名称
*/
private String auditStatusName;
/**
* 启用状态0-停用1-启用
*/
private Short enableStatus;
/**
* 备注
*/
private String remark;
/**
* 创建人ID
*/
private Long createId;
/**
* 创建人名称
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改人ID
*/
private Long modifyId;
/**
* 修改人名称
*/
private String modifyName;
/**
* 修改时间
*/
private LocalDateTime modifyTime;
/**
* 审核人
*/
private String auditBy;
/**
* 审核时间
*/
private LocalDateTime auditTime;
/**
* 审核说明
*/
private String auditMsg;
/**
* 检查点列表
*/
private List<PqcInspectionPointVO> inspectionPoints;
}

View File

@ -0,0 +1,79 @@
package com.nflg.qms.admin.pojo.vo;
import lombok.Data;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
/**
* PQC检验规则列表VO
*/
@Data
@Accessors(chain = true)
public class PqcInspectionRuleVO {
/**
* 主键ID
*/
private Long id;
/**
* 机型编号
*/
private String modelNo;
/**
* 规则编号
*/
private String pqcRuleCode;
/**
* 版本号
*/
private Integer ruleVersion;
/**
* 启用状态true=启用false=禁用
*/
private Boolean isDisabled;
/**
* 审核状态0=未审核1=已审核2=已驳回
*/
private Integer auditStatus;
/**
* 驳回原因
*/
private String auditRemark;
/**
* 审核人姓名
*/
private String auditUserName;
/**
* 审核时间
*/
private LocalDateTime auditDateTime;
/**
* 创建人姓名
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 最后修改人姓名
*/
private String updateName;
/**
* 最后修改时间
*/
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,58 @@
package com.nflg.qms.admin.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleAddQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleAuditQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleEditQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleSearchQO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionRuleDetailVO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionRuleVO;
import com.nflg.wms.common.pojo.PageData;
import java.util.List;
/**
* PQC检验规则 业务逻辑接口
*/
public interface QmsPqcInspectionRuleControllerService {
/**
* 分页查询规则列表
*/
PageData<PqcInspectionRuleVO> search(PqcInspectionRuleSearchQO qo);
/**
* 获取规则详情含检查点和检查项
*/
PqcInspectionRuleDetailVO getDetail(Long id);
/**
* 新增规则
*/
void add(PqcInspectionRuleAddQO qo);
/**
* 编辑规则含版本管理
*/
void edit(PqcInspectionRuleEditQO qo);
/**
* 批量删除规则只能删除未审核的
*/
void delete(List<Long> ids);
/**
* 复制规则
*/
PqcInspectionRuleDetailVO copy(Long id);
/**
* 审核/驳回规则
*/
void audit(PqcInspectionRuleAuditQO qo);
/**
* 切换启用/禁用状态
*/
void toggleDisabled(Long id);
}

View File

@ -0,0 +1,537 @@
package com.nflg.qms.admin.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleAddQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleAuditQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleEditQO;
import com.nflg.qms.admin.pojo.qo.PqcInspectionRuleSearchQO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionPointItemVO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionPointVO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionRuleDetailVO;
import com.nflg.qms.admin.pojo.vo.PqcInspectionRuleVO;
import com.nflg.qms.admin.service.QmsPqcInspectionRuleControllerService;
import com.nflg.wms.common.constant.STATE;
import com.nflg.wms.common.exception.NflgException;
import com.nflg.wms.common.pojo.PageData;
import com.nflg.wms.common.util.PageUtil;
import com.nflg.wms.common.util.UserUtil;
import com.nflg.wms.repository.entity.QmsPqcInspectionPoint;
import com.nflg.wms.repository.entity.QmsPqcInspectionPointItems;
import com.nflg.wms.repository.entity.QmsPqcInspectionRule;
import com.nflg.wms.repository.service.IQmsPqcInspectionPointItemsService;
import com.nflg.wms.repository.service.IQmsPqcInspectionPointService;
import com.nflg.wms.repository.service.IQmsPqcInspectionRuleService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* PQC检验规则 业务逻辑实现类
*/
@Slf4j
@Component
public class QmsPqcInspectionRuleControllerServiceImpl implements QmsPqcInspectionRuleControllerService {
@Resource
private IQmsPqcInspectionRuleService ruleService;
@Resource
private IQmsPqcInspectionPointService pointService;
@Resource
private IQmsPqcInspectionPointItemsService itemsService;
@Override
public PageData<PqcInspectionRuleVO> search(PqcInspectionRuleSearchQO qo) {
LambdaQueryWrapper<QmsPqcInspectionRule> queryWrapper = new LambdaQueryWrapper<>();
// 查询条件
queryWrapper.like(StrUtil.isNotBlank(qo.getModelNo()), QmsPqcInspectionRule::getModelNo, qo.getModelNo())
.like(StrUtil.isNotBlank(qo.getPqcRuleCode()), QmsPqcInspectionRule::getPqcRuleCode, qo.getPqcRuleCode())
.eq(Objects.nonNull(qo.getIsDisabled()), QmsPqcInspectionRule::getIsDisabled, qo.getIsDisabled())
.eq(Objects.nonNull(qo.getAuditStatus()), QmsPqcInspectionRule::getAuditStatus, qo.getAuditStatus())
.ge(Objects.nonNull(qo.getCreateTimeStart()), QmsPqcInspectionRule::getCreateTime, qo.getCreateTimeStart())
.le(Objects.nonNull(qo.getCreateTimeEnd()), QmsPqcInspectionRule::getCreateTime, qo.getCreateTimeEnd())
.orderByDesc(QmsPqcInspectionRule::getCreateTime);
Page<QmsPqcInspectionRule> page = ruleService.page(new Page<>(qo.getPage(), qo.getPageSize()), queryWrapper);
List<PqcInspectionRuleVO> voList = page.getRecords().stream()
.map(rule -> BeanUtil.copyProperties(rule, PqcInspectionRuleVO.class))
.collect(Collectors.toList());
return PageUtil.Page(voList, (int) page.getCurrent(), (int) page.getSize());
}
@Override
public PqcInspectionRuleDetailVO getDetail(Long id) {
QmsPqcInspectionRule rule = ruleService.getById(id);
if (Objects.isNull(rule)) {
throw new NflgException(STATE.BusinessError, "规则不存在");
}
PqcInspectionRuleDetailVO detailVO = BeanUtil.copyProperties(rule, PqcInspectionRuleDetailVO.class);
// 查询检查点
List<QmsPqcInspectionPoint> points = pointService.lambdaQuery()
.eq(QmsPqcInspectionPoint::getPqcRuleId, id)
.list();
List<PqcInspectionPointVO> pointVOs = new ArrayList<>();
for (QmsPqcInspectionPoint point : points) {
PqcInspectionPointVO pointVO = BeanUtil.copyProperties(point, PqcInspectionPointVO.class);
// 查询检查项
List<QmsPqcInspectionPointItems> items = itemsService.lambdaQuery()
.eq(QmsPqcInspectionPointItems::getInspectionCodeId, point.getId())
.orderByAsc(QmsPqcInspectionPointItems::getSort)
.list();
List<PqcInspectionPointItemVO> itemVOs = items.stream()
.map(item -> BeanUtil.copyProperties(item, PqcInspectionPointItemVO.class))
.collect(Collectors.toList());
pointVO.setInspectionItems(itemVOs);
pointVOs.add(pointVO);
}
detailVO.setInspectionPoints(pointVOs);
return detailVO;
}
@Override
@Transactional
public void add(PqcInspectionRuleAddQO qo) {
String operator = UserUtil.getUserName();
Long operatorId = UserUtil.getUserId();
LocalDateTime now = LocalDateTime.now();
// 创建规则主表
QmsPqcInspectionRule rule = new QmsPqcInspectionRule();
rule.setModelNo(qo.getModelNo());
rule.setPqcRuleCode(qo.getPqcRuleCode());
rule.setRuleVersion(1);
rule.setIsDisabled(true); // 默认启用
rule.setAuditStatus(0); // 默认未审核
rule.setCreateBy(operatorId);
rule.setCreateName(operator);
rule.setCreateTime(now);
ruleService.save(rule);
// 保存检查点和检查项
savePointsAndItems(rule.getId(), qo.getInspectionPoints(), operator, operatorId, now);
}
@Override
@Transactional
public void edit(PqcInspectionRuleEditQO qo) {
QmsPqcInspectionRule existRule = ruleService.getById(qo.getId());
if (Objects.isNull(existRule)) {
throw new NflgException(STATE.BusinessError, "规则不存在");
}
String operator = UserUtil.getUserName();
Long operatorId = UserUtil.getUserId();
LocalDateTime now = LocalDateTime.now();
// 如果已审核需要比对数据是否变化决定是更新还是创建新版本
if (existRule.getAuditStatus() == 1) {
// 比对数据是否变化
boolean hasChanged = checkDataChanged(existRule.getId(), qo);
if (hasChanged) {
// 有变化创建新版本
QmsPqcInspectionRule newRule = new QmsPqcInspectionRule();
BeanUtil.copyProperties(existRule, newRule);
newRule.setId(null);
newRule.setRuleVersion(existRule.getRuleVersion() + 1);
newRule.setAuditStatus(0); // 新版本默认未审核
newRule.setAuditUserId(null);
newRule.setAuditUserName(null);
newRule.setAuditDateTime(null);
newRule.setAuditRemark(null);
newRule.setUpdateBy(operatorId);
newRule.setUpdateName(operator);
newRule.setUpdateTime(now);
newRule.setModelNo(qo.getModelNo());
ruleService.save(newRule);
// 保存新版本的检查点和检查项
savePointsAndItemsFromEditQO(newRule.getId(), qo.getInspectionPoints(), operator, operatorId, now);
} else {
// 无变化直接更新
existRule.setModelNo(qo.getModelNo());
existRule.setUpdateBy(operatorId);
existRule.setUpdateName(operator);
existRule.setUpdateTime(now);
ruleService.updateById(existRule);
// 更新检查点和检查项
updatePointsAndItems(existRule.getId(), qo.getInspectionPoints(), operator, operatorId, now);
}
} else {
// 未审核直接更新
existRule.setModelNo(qo.getModelNo());
existRule.setUpdateBy(operatorId);
existRule.setUpdateName(operator);
existRule.setUpdateTime(now);
ruleService.updateById(existRule);
// 更新检查点和检查项
updatePointsAndItems(existRule.getId(), qo.getInspectionPoints(), operator, operatorId, now);
}
}
@Override
@Transactional
public void delete(List<Long> ids) {
// 检查是否有已审核的数据
List<QmsPqcInspectionRule> rules = ruleService.listByIds(ids);
for (QmsPqcInspectionRule rule : rules) {
if (rule.getAuditStatus() == 1) {
throw new NflgException(STATE.BusinessError, "已审核的规则不能删除:" + rule.getPqcRuleCode());
}
}
// 删除规则检查点检查项
for (Long id : ids) {
// 删除检查项
List<QmsPqcInspectionPoint> points = pointService.lambdaQuery()
.eq(QmsPqcInspectionPoint::getPqcRuleId, id)
.list();
for (QmsPqcInspectionPoint point : points) {
itemsService.lambdaUpdate()
.eq(QmsPqcInspectionPointItems::getInspectionCodeId, point.getId())
.remove();
}
// 删除检查点
pointService.lambdaUpdate()
.eq(QmsPqcInspectionPoint::getPqcRuleId, id)
.remove();
// 删除规则
ruleService.removeById(id);
}
}
@Override
@Transactional
public PqcInspectionRuleDetailVO copy(Long id) {
QmsPqcInspectionRule existRule = ruleService.getById(id);
if (Objects.isNull(existRule)) {
throw new NflgException(STATE.BusinessError, "规则不存在");
}
String operator = UserUtil.getUserName();
Long operatorId = UserUtil.getUserId();
LocalDateTime now = LocalDateTime.now();
// 创建新规则
QmsPqcInspectionRule newRule = new QmsPqcInspectionRule();
newRule.setModelNo(null); // 清空机型编号
newRule.setRuleVersion(1);
newRule.setIsDisabled(true);
newRule.setAuditStatus(0);
newRule.setCreateBy(operatorId);
newRule.setCreateName(operator);
newRule.setCreateTime(now);
ruleService.save(newRule);
// 复制检查点和检查项
List<QmsPqcInspectionPoint> points = pointService.lambdaQuery()
.eq(QmsPqcInspectionPoint::getPqcRuleId, id)
.list();
for (QmsPqcInspectionPoint point : points) {
QmsPqcInspectionPoint newPoint = new QmsPqcInspectionPoint();
BeanUtil.copyProperties(point, newPoint);
newPoint.setId(null);
newPoint.setPqcRuleId(newRule.getId());
newPoint.setCreateBy(operatorId);
newPoint.setCreateName(operator);
newPoint.setCreateTime(now);
pointService.save(newPoint);
// 复制检查项
List<QmsPqcInspectionPointItems> items = itemsService.lambdaQuery()
.eq(QmsPqcInspectionPointItems::getInspectionCodeId, point.getId())
.list();
for (QmsPqcInspectionPointItems item : items) {
QmsPqcInspectionPointItems newItem = new QmsPqcInspectionPointItems();
BeanUtil.copyProperties(item, newItem);
newItem.setId(null);
newItem.setInspectionCodeId(newPoint.getId());
newItem.setCreateBy(operatorId);
newItem.setCreateName(operator);
newItem.setCreateTime(now);
itemsService.save(newItem);
}
}
return getDetail(newRule.getId());
}
@Override
@Transactional
public void audit(PqcInspectionRuleAuditQO qo) {
QmsPqcInspectionRule rule = ruleService.getById(qo.getId());
if (Objects.isNull(rule)) {
throw new NflgException(STATE.BusinessError, "规则不存在");
}
// 已审核的数据不能再审核
if (rule.getAuditStatus() == 1) {
throw new NflgException(STATE.BusinessError, "该规则已审核,无法重复审核");
}
// 驳回时必填驳回原因
if (qo.getAuditStatus() == 2 && StrUtil.isBlank(qo.getAuditRemark())) {
throw new NflgException(STATE.BusinessError, "驳回时必须填写驳回原因");
}
String operator = UserUtil.getUserName();
Long operatorId = UserUtil.getUserId();
LocalDateTime now = LocalDateTime.now();
rule.setAuditStatus(qo.getAuditStatus());
rule.setAuditUserId(operatorId);
rule.setAuditUserName(operator);
rule.setAuditDateTime(now);
// 如果是审核通过且之前是驳回状态清空驳回原因
if (qo.getAuditStatus() == 1) {
rule.setAuditRemark(null);
} else {
rule.setAuditRemark(qo.getAuditRemark());
}
ruleService.updateById(rule);
}
@Override
@Transactional
public void toggleDisabled(Long id) {
QmsPqcInspectionRule rule = ruleService.getById(id);
if (Objects.isNull(rule)) {
throw new NflgException(STATE.BusinessError, "规则不存在");
}
rule.setIsDisabled(!rule.getIsDisabled());
ruleService.updateById(rule);
}
// ========================= 私有方法 =========================
/**
* 保存检查点和检查项
*/
private void savePointsAndItems(Long ruleId, List<PqcInspectionRuleAddQO.PqcInspectionPointAddQO> points,
String operator, Long operatorId, LocalDateTime now) {
if (points == null || points.isEmpty()) {
return;
}
for (PqcInspectionRuleAddQO.PqcInspectionPointAddQO pointQO : points) {
QmsPqcInspectionPoint point = new QmsPqcInspectionPoint();
point.setPqcRuleId(ruleId);
point.setStepName(pointQO.getStepName());
point.setStepDicItemId(pointQO.getStepDicItemId());
point.setInspectionPointCode(pointQO.getInspectionPointCode());
point.setInspectionPointName(pointQO.getInspectionPointName());
point.setCreateBy(operatorId);
point.setCreateName(operator);
point.setCreateTime(now);
pointService.save(point);
// 保存检查项
if (pointQO.getInspectionItems() != null && !pointQO.getInspectionItems().isEmpty()) {
int sort = 1;
for (PqcInspectionRuleAddQO.PqcInspectionPointItemAddQO itemQO : pointQO.getInspectionItems()) {
QmsPqcInspectionPointItems item = new QmsPqcInspectionPointItems();
item.setInspectionCodeId(point.getId());
item.setSort(sort++);
item.setInspectionContent(itemQO.getInspectionContent());
item.setInspectionType(itemQO.getInspectionType());
item.setInspectionMethods(itemQO.getInspectionMethods());
item.setInspectionImgUrl(itemQO.getInspectionImgUrl());
item.setInspectionLevel(itemQO.getInspectionLevel());
item.setCreateBy(operatorId);
item.setCreateName(operator);
item.setCreateTime(now);
itemsService.save(item);
}
}
}
}
/**
* 保存检查点和检查项从EditQO
*/
private void savePointsAndItemsFromEditQO(Long ruleId, List<PqcInspectionRuleEditQO.PqcInspectionPointEditQO> points,
String operator, Long operatorId, LocalDateTime now) {
if (points == null || points.isEmpty()) {
return;
}
for (PqcInspectionRuleEditQO.PqcInspectionPointEditQO pointQO : points) {
QmsPqcInspectionPoint point = new QmsPqcInspectionPoint();
point.setPqcRuleId(ruleId);
point.setStepName(pointQO.getStepName());
point.setStepDicItemId(pointQO.getStepDicItemId());
point.setInspectionPointCode(pointQO.getInspectionPointCode());
point.setInspectionPointName(pointQO.getInspectionPointName());
point.setCreateBy(operatorId);
point.setCreateName(operator);
point.setCreateTime(now);
pointService.save(point);
// 保存检查项
if (pointQO.getInspectionItems() != null && !pointQO.getInspectionItems().isEmpty()) {
int sort = 1;
for (PqcInspectionRuleEditQO.PqcInspectionPointItemEditQO itemQO : pointQO.getInspectionItems()) {
QmsPqcInspectionPointItems item = new QmsPqcInspectionPointItems();
item.setInspectionCodeId(point.getId());
item.setSort(itemQO.getSort() != null ? itemQO.getSort() : sort++);
item.setInspectionContent(itemQO.getInspectionContent());
item.setInspectionType(itemQO.getInspectionType());
item.setInspectionMethods(itemQO.getInspectionMethods());
item.setInspectionImgUrl(itemQO.getInspectionImgUrl());
item.setInspectionLevel(itemQO.getInspectionLevel());
item.setCreateBy(operatorId);
item.setCreateName(operator);
item.setCreateTime(now);
itemsService.save(item);
}
}
}
}
/**
* 更新检查点和检查项先删除旧的再插入新的
*/
private void updatePointsAndItems(Long ruleId, List<PqcInspectionRuleEditQO.PqcInspectionPointEditQO> points,
String operator, Long operatorId, LocalDateTime now) {
// 删除旧的检查项
List<QmsPqcInspectionPoint> oldPoints = pointService.lambdaQuery()
.eq(QmsPqcInspectionPoint::getPqcRuleId, ruleId)
.list();
for (QmsPqcInspectionPoint oldPoint : oldPoints) {
itemsService.lambdaUpdate()
.eq(QmsPqcInspectionPointItems::getInspectionCodeId, oldPoint.getId())
.remove();
}
// 删除旧的检查点
pointService.lambdaUpdate()
.eq(QmsPqcInspectionPoint::getPqcRuleId, ruleId)
.remove();
// 重新保存
if (points == null || points.isEmpty()) {
return;
}
for (PqcInspectionRuleEditQO.PqcInspectionPointEditQO pointQO : points) {
QmsPqcInspectionPoint point = new QmsPqcInspectionPoint();
point.setPqcRuleId(ruleId);
point.setStepName(pointQO.getStepName());
point.setStepDicItemId(pointQO.getStepDicItemId());
point.setInspectionPointCode(pointQO.getInspectionPointCode());
point.setInspectionPointName(pointQO.getInspectionPointName());
point.setCreateBy(operatorId);
point.setCreateName(operator);
point.setCreateTime(now);
pointService.save(point);
// 保存检查项
if (pointQO.getInspectionItems() != null && !pointQO.getInspectionItems().isEmpty()) {
int sort = 1;
for (PqcInspectionRuleEditQO.PqcInspectionPointItemEditQO itemQO : pointQO.getInspectionItems()) {
QmsPqcInspectionPointItems item = new QmsPqcInspectionPointItems();
item.setInspectionCodeId(point.getId());
item.setSort(itemQO.getSort() != null ? itemQO.getSort() : sort++);
item.setInspectionContent(itemQO.getInspectionContent());
item.setInspectionType(itemQO.getInspectionType());
item.setInspectionMethods(itemQO.getInspectionMethods());
item.setInspectionImgUrl(itemQO.getInspectionImgUrl());
item.setInspectionLevel(itemQO.getInspectionLevel());
item.setCreateBy(operatorId);
item.setCreateName(operator);
item.setCreateTime(now);
itemsService.save(item);
}
}
}
}
/**
* 比对数据是否发生变化
*/
private boolean checkDataChanged(Long ruleId, PqcInspectionRuleEditQO qo) {
// 获取现有的检查点
List<QmsPqcInspectionPoint> existPoints = pointService.lambdaQuery()
.eq(QmsPqcInspectionPoint::getPqcRuleId, ruleId)
.list();
// 如果检查点数量不同说明有变化
if (qo.getInspectionPoints() == null || qo.getInspectionPoints().size() != existPoints.size()) {
return true;
}
// 比对每个检查点
Map<Long, QmsPqcInspectionPoint> existPointMap = existPoints.stream()
.collect(Collectors.toMap(QmsPqcInspectionPoint::getId, p -> p));
for (PqcInspectionRuleEditQO.PqcInspectionPointEditQO pointQO : qo.getInspectionPoints()) {
if (pointQO.getId() == null || !existPointMap.containsKey(pointQO.getId())) {
return true; // 新增的检查点或ID不存在
}
QmsPqcInspectionPoint existPoint = existPointMap.get(pointQO.getId());
// 比对关键字段
if (!Objects.equals(existPoint.getStepName(), pointQO.getStepName()) ||
!Objects.equals(existPoint.getInspectionPointCode(), pointQO.getInspectionPointCode()) ||
!Objects.equals(existPoint.getInspectionPointName(), pointQO.getInspectionPointName())) {
return true;
}
// 比对检查项
List<QmsPqcInspectionPointItems> existItems = itemsService.lambdaQuery()
.eq(QmsPqcInspectionPointItems::getInspectionCodeId, pointQO.getId())
.list();
if (pointQO.getInspectionItems() == null ||
pointQO.getInspectionItems().size() != existItems.size()) {
return true;
}
// 简单比对检查项数量和内容
for (int i = 0; i < existItems.size(); i++) {
QmsPqcInspectionPointItems existItem = existItems.get(i);
PqcInspectionRuleEditQO.PqcInspectionPointItemEditQO itemQO = pointQO.getInspectionItems().get(i);
if (!Objects.equals(existItem.getInspectionContent(), itemQO.getInspectionContent()) ||
!Objects.equals(existItem.getInspectionType(), itemQO.getInspectionType()) ||
!Objects.equals(existItem.getInspectionMethods(), itemQO.getInspectionMethods()) ||
!Objects.equals(existItem.getInspectionLevel(), itemQO.getInspectionLevel())) {
return true;
}
}
}
return false;
}
}

View File

@ -39,7 +39,7 @@ public class Constant {
public static final String DICTIONARY_AD_TYPE ="AdvertisementType";
public static final String DICTIONARY_AD_POSITION ="AdvertisementPosition";
public static final String DICTIONARY_STEP_POSITION ="step";
/**
* 仓库管理员角色代码
*/

View File

@ -0,0 +1,88 @@
package com.nflg.wms.repository.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* PQC检查点详情表
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("qms_pqc_inspection_point")
public class QmsPqcInspectionPoint implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 规则主表ID
*/
private Long pqcRuleId;
/**
* 步装名称
*/
private String stepName;
/**
* 步装字典ID
*/
private Long stepDicItemId;
/**
* 检查点编号
*/
private String inspectionPointCode;
/**
* 检查点名称
*/
private String inspectionPointName;
/**
* 创建人编号
*/
private Long createBy;
/**
* 创建人姓名
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改人编号
*/
private Long updateBy;
/**
* 修改人姓名
*/
private String updateName;
/**
* 修改时间
*/
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,98 @@
package com.nflg.wms.repository.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* PQC检查点检查项内容表
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("qms_pqc_inspection_point_items")
public class QmsPqcInspectionPointItems implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 检查点ID关联qms_pqc_inspection_point的ID
*/
private Long inspectionCodeId;
/**
* 排序
*/
private Integer sort;
/**
* 检查内容
*/
private String inspectionContent;
/**
* 检查类型0=工序检查1=关键物料拍照2=全部
*/
private Integer inspectionType;
/**
* 判定类型0=目视1=量具
*/
private Integer inspectionMethods;
/**
* 样例图地址
*/
private String inspectionImgUrl;
/**
* 星级1-3级
*/
private Integer inspectionLevel;
/**
* 创建人编号
*/
private Long createBy;
/**
* 创建人姓名
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改人编号
*/
private Long updateBy;
/**
* 修改人姓名
*/
private String updateName;
/**
* 修改时间
*/
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,108 @@
package com.nflg.wms.repository.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* PQC检验规则主表
* </p>
*
* @author 代码生成器生成
* @since 2026
*/
@Getter
@Setter
@ToString
@Accessors(chain = true)
@TableName("qms_pqc_inspection_rule")
public class QmsPqcInspectionRule implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
/**
* 机型编号
*/
private String modelNo;
/**
* 规则编号
*/
private String pqcRuleCode;
/**
* 版本号
*/
private Integer ruleVersion;
/**
* 是否禁用true=启用false=禁用
*/
private Boolean isDisabled;
/**
* 审核状态0=未审核1=已审核2=已驳回
*/
private Integer auditStatus;
/**
* 审核人ID
*/
private Long auditUserId;
/**
* 审核人姓名
*/
private String auditUserName;
/**
* 审核时间
*/
private LocalDateTime auditDateTime;
/**
* 驳回原因
*/
private String auditRemark;
/**
* 创建人编号
*/
private Long createBy;
/**
* 创建人姓名
*/
private String createName;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 修改人编号
*/
private Long updateBy;
/**
* 修改人姓名
*/
private String updateName;
/**
* 修改时间
*/
private LocalDateTime updateTime;
}

View File

@ -0,0 +1,15 @@
package com.nflg.wms.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nflg.wms.repository.entity.QmsPqcInspectionPointItems;
/**
* <p>
* PQC检查点检查项内容表 Mapper 接口
* </p>
*
* @author QMS
* @since 2026
*/
public interface QmsPqcInspectionPointItemsMapper extends BaseMapper<QmsPqcInspectionPointItems> {
}

View File

@ -0,0 +1,15 @@
package com.nflg.wms.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nflg.wms.repository.entity.QmsPqcInspectionPoint;
/**
* <p>
* PQC检查点详情表 Mapper 接口
* </p>
*
* @author QMS
* @since 2026
*/
public interface QmsPqcInspectionPointMapper extends BaseMapper<QmsPqcInspectionPoint> {
}

View File

@ -0,0 +1,15 @@
package com.nflg.wms.repository.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nflg.wms.repository.entity.QmsPqcInspectionRule;
/**
* <p>
* PQC检验规则主表 Mapper 接口
* </p>
*
* @author QMS
* @since 2026
*/
public interface QmsPqcInspectionRuleMapper extends BaseMapper<QmsPqcInspectionRule> {
}

View File

@ -0,0 +1,15 @@
package com.nflg.wms.repository.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nflg.wms.repository.entity.QmsPqcInspectionPointItems;
/**
* <p>
* PQC检查点检查项内容表 服务类
* </p>
*
* @author QMS
* @since 2026
*/
public interface IQmsPqcInspectionPointItemsService extends IService<QmsPqcInspectionPointItems> {
}

View File

@ -0,0 +1,15 @@
package com.nflg.wms.repository.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nflg.wms.repository.entity.QmsPqcInspectionPoint;
/**
* <p>
* PQC检查点详情表 服务类
* </p>
*
* @author QMS
* @since 2026
*/
public interface IQmsPqcInspectionPointService extends IService<QmsPqcInspectionPoint> {
}

View File

@ -0,0 +1,15 @@
package com.nflg.wms.repository.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nflg.wms.repository.entity.QmsPqcInspectionRule;
/**
* <p>
* PQC检验规则主表 服务类
* </p>
*
* @author QMS
* @since 2026
*/
public interface IQmsPqcInspectionRuleService extends IService<QmsPqcInspectionRule> {
}

View File

@ -0,0 +1,20 @@
package com.nflg.wms.repository.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.wms.repository.entity.QmsPqcInspectionPointItems;
import com.nflg.wms.repository.mapper.QmsPqcInspectionPointItemsMapper;
import com.nflg.wms.repository.service.IQmsPqcInspectionPointItemsService;
import org.springframework.stereotype.Service;
/**
* <p>
* PQC检查点检查项内容表 服务实现类
* </p>
*
* @author QMS
* @since 2026
*/
@Service
public class QmsPqcInspectionPointItemsServiceImpl extends ServiceImpl<QmsPqcInspectionPointItemsMapper, QmsPqcInspectionPointItems>
implements IQmsPqcInspectionPointItemsService {
}

View File

@ -0,0 +1,20 @@
package com.nflg.wms.repository.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.wms.repository.entity.QmsPqcInspectionPoint;
import com.nflg.wms.repository.mapper.QmsPqcInspectionPointMapper;
import com.nflg.wms.repository.service.IQmsPqcInspectionPointService;
import org.springframework.stereotype.Service;
/**
* <p>
* PQC检查点详情表 服务实现类
* </p>
*
* @author QMS
* @since 2026
*/
@Service
public class QmsPqcInspectionPointServiceImpl extends ServiceImpl<QmsPqcInspectionPointMapper, QmsPqcInspectionPoint>
implements IQmsPqcInspectionPointService {
}

View File

@ -0,0 +1,20 @@
package com.nflg.wms.repository.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.wms.repository.entity.QmsPqcInspectionRule;
import com.nflg.wms.repository.mapper.QmsPqcInspectionRuleMapper;
import com.nflg.wms.repository.service.IQmsPqcInspectionRuleService;
import org.springframework.stereotype.Service;
/**
* <p>
* PQC检验规则主表 服务实现类
* </p>
*
* @author QMS
* @since 2026
*/
@Service
public class QmsPqcInspectionRuleServiceImpl extends ServiceImpl<QmsPqcInspectionRuleMapper, QmsPqcInspectionRule>
implements IQmsPqcInspectionRuleService {
}