feat(qms): 新增标准缺陷库功能模块
- 添加标准缺陷实体类 QmsStandardDefect,包含缺陷属性和层级结构信息 - 实现标准缺陷数据访问层 Mapper 和服务接口 IService
This commit is contained in:
parent
b66fdb7404
commit
bece6398d9
|
|
@ -0,0 +1,100 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.nflg.qms.admin.service.QmsStandardDefectControllerService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.dto.QmsStandardDefectImportDTO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsStandardDefectAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsStandardDefectSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsStandardDefectUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsStandardDefectVO;
|
||||
import com.nflg.wms.common.util.EecExcelUtil;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标准缺陷库 接口
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/qms/standardDefect")
|
||||
public class QmsStandardDefectController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private QmsStandardDefectControllerService defectControllerService;
|
||||
|
||||
/**
|
||||
* 新增缺陷
|
||||
*/
|
||||
@PostMapping("add")
|
||||
public ApiResult<Void> add(@Valid @RequestBody QmsStandardDefectAddQO request) {
|
||||
defectControllerService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改缺陷
|
||||
*/
|
||||
@PostMapping("update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody QmsStandardDefectUpdateQO request) {
|
||||
defectControllerService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 逻辑删除缺陷(deleted: 1->0)
|
||||
*
|
||||
* @param id 缺陷ID
|
||||
*/
|
||||
@PostMapping("delete")
|
||||
public ApiResult<Void> delete(@NotNull Long id) {
|
||||
defectControllerService.delete(id);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询缺陷树(对顶级节点分页,子节点随父节点返回,支持 defectCode 精确 / defectName 模糊)
|
||||
*/
|
||||
@PostMapping("search")
|
||||
public ApiResult<PageData<QmsStandardDefectVO>> search(@RequestBody QmsStandardDefectSearchQO request) {
|
||||
return ApiResult.success(defectControllerService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出缺陷列表(扁平表格,含表头)
|
||||
* ids 不传或为空则全量导出,传了则只导出指定 id 的记录
|
||||
*/
|
||||
@PostMapping("export")
|
||||
public void export(@RequestBody(required = false) List<Long> ids, HttpServletResponse response) throws IOException {
|
||||
List<QmsStandardDefectVO> list = defectControllerService.listForExport(ids);
|
||||
EecExcelUtil.export("标准缺陷库", "标准缺陷库", list, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载导入模板
|
||||
*/
|
||||
@GetMapping("downloadTemplate")
|
||||
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
||||
List<String> headers = Arrays.asList("父级故障名称", "故障编码*", "故障名称*", "状态*", "备注");
|
||||
EecExcelUtil.export("标准缺陷导入模板", headers, List.of(), response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入缺陷(根据模板列名解析)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("importExcel")
|
||||
public ApiResult<Void> importExcel(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
List<QmsStandardDefectImportDTO> dtos = EecExcelUtil.readTo(file.getInputStream(), QmsStandardDefectImportDTO.class);
|
||||
defectControllerService.importDefects(dtos);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,391 @@
|
|||
package com.nflg.qms.admin.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.pojo.dto.QmsStandardDefectImportDTO;
|
||||
import com.nflg.wms.common.util.PageUtil;
|
||||
import com.nflg.wms.common.pojo.qo.QmsStandardDefectAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsStandardDefectSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsStandardDefectUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsStandardDefectVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsStandardDefect;
|
||||
import com.nflg.wms.repository.service.IQmsStandardDefectService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
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.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 标准缺陷库 业务逻辑
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class QmsStandardDefectControllerService {
|
||||
|
||||
@Resource
|
||||
private IQmsStandardDefectService defectService;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
/**
|
||||
* 新增缺陷
|
||||
* 父级通过 parentName 查询,自动赋值 parentId/parentCode/level
|
||||
* 若父级 isLeaf=true,则将父级 isLeaf 改为 false
|
||||
* sort 在同父级下自增
|
||||
*/
|
||||
@Transactional
|
||||
public void add(@Valid QmsStandardDefectAddQO request) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 校验 defect_code 唯一性
|
||||
boolean codeExists = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDefectCode, request.getDefectCode())
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.exists();
|
||||
if (codeExists) {
|
||||
throw new NflgException(STATE.BusinessError, "缺陷代码已存在:" + request.getDefectCode());
|
||||
}
|
||||
|
||||
QmsStandardDefect entity = new QmsStandardDefect()
|
||||
.setDefectCode(request.getDefectCode())
|
||||
.setDefectName(request.getDefectName())
|
||||
.setState(request.getState())
|
||||
.setRemark(request.getRemark())
|
||||
.setDeleted(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now);
|
||||
|
||||
if (StrUtil.isBlank(request.getParentName())) {
|
||||
// 顶级节点
|
||||
entity.setParentId(null)
|
||||
.setParentCode(null)
|
||||
.setLevel((short) 1);
|
||||
short sort = calcNextSort(null);
|
||||
entity.setSort(sort).setIsLeaf(true);
|
||||
} else {
|
||||
// 查询父级
|
||||
QmsStandardDefect parent = getParentByName(request.getParentName());
|
||||
entity.setParentId(parent.getId())
|
||||
.setParentCode(parent.getDefectCode())
|
||||
.setLevel((short) (parent.getLevel() + 1));
|
||||
short sort = calcNextSort(parent.getId());
|
||||
entity.setSort(sort).setIsLeaf(true);
|
||||
// 父级若是叶子节点,改为非叶子
|
||||
if (Boolean.TRUE.equals(parent.getIsLeaf())) {
|
||||
defectService.lambdaUpdate()
|
||||
.eq(QmsStandardDefect::getId, parent.getId())
|
||||
.set(QmsStandardDefect::getIsLeaf, false)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
defectService.save(entity);
|
||||
}
|
||||
|
||||
// ========================= 修改 =========================
|
||||
|
||||
/**
|
||||
* 修改缺陷
|
||||
* 若父级变更:处理新父级 isLeaf、旧父级是否需要恢复 isLeaf
|
||||
*/
|
||||
@Transactional
|
||||
public void update(@Valid QmsStandardDefectUpdateQO request) {
|
||||
QmsStandardDefect exist = defectService.getById(request.getId());
|
||||
if (Objects.isNull(exist)) {
|
||||
throw new NflgException(STATE.BusinessError, "缺陷记录不存在");
|
||||
}
|
||||
|
||||
// 校验 defect_code 唯一性(排除自身,仅传了 defectCode 时才校验)
|
||||
if (StrUtil.isNotBlank(request.getDefectCode())) {
|
||||
boolean codeExists = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDefectCode, request.getDefectCode())
|
||||
.ne(QmsStandardDefect::getId, request.getId())
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.exists();
|
||||
if (codeExists) {
|
||||
throw new NflgException(STATE.BusinessError, "缺陷代码已存在:" + request.getDefectCode());
|
||||
}
|
||||
}
|
||||
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
var updateChain = defectService.lambdaUpdate()
|
||||
.eq(QmsStandardDefect::getId, request.getId());
|
||||
|
||||
// 动态 set:只更新传了值的字段
|
||||
if (StrUtil.isNotBlank(request.getDefectCode())) {
|
||||
updateChain.set(QmsStandardDefect::getDefectCode, request.getDefectCode());
|
||||
}
|
||||
if (StrUtil.isNotBlank(request.getDefectName())) {
|
||||
updateChain.set(QmsStandardDefect::getDefectName, request.getDefectName());
|
||||
}
|
||||
if (Objects.nonNull(request.getState())) {
|
||||
updateChain.set(QmsStandardDefect::getState, request.getState());
|
||||
}
|
||||
if (Objects.nonNull(request.getRemark())) {
|
||||
updateChain.set(QmsStandardDefect::getRemark, request.getRemark());
|
||||
}
|
||||
|
||||
// 父级变更:仅当 changeParent=true 时处理
|
||||
boolean parentChanged = false;
|
||||
Long oldParentId = exist.getParentId();
|
||||
if (Boolean.TRUE.equals(request.getChangeParent())) {
|
||||
Long newParentId = null;
|
||||
String newParentCode = null;
|
||||
Short newLevel;
|
||||
|
||||
if (StrUtil.isBlank(request.getParentName())) {
|
||||
// 改为顶级
|
||||
newLevel = 1;
|
||||
} else {
|
||||
QmsStandardDefect newParent = getParentByName(request.getParentName());
|
||||
newParentId = newParent.getId();
|
||||
newParentCode = newParent.getDefectCode();
|
||||
newLevel = (short) (newParent.getLevel() + 1);
|
||||
// 新父级若是叶子节点,改为非叶子
|
||||
if (Boolean.TRUE.equals(newParent.getIsLeaf())) {
|
||||
defectService.lambdaUpdate()
|
||||
.eq(QmsStandardDefect::getId, newParent.getId())
|
||||
.set(QmsStandardDefect::getIsLeaf, false)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
parentChanged = !Objects.equals(oldParentId, newParentId);
|
||||
updateChain.set(QmsStandardDefect::getParentId, newParentId)
|
||||
.set(QmsStandardDefect::getParentCode, newParentCode)
|
||||
.set(QmsStandardDefect::getLevel, newLevel);
|
||||
}
|
||||
|
||||
updateChain.set(QmsStandardDefect::getUpdateBy, operator)
|
||||
.set(QmsStandardDefect::getUpdateTime, now)
|
||||
.update();
|
||||
|
||||
// 若父级变更,检查旧父级是否还有未删除子节点,没有则恢复 isLeaf=true
|
||||
if (parentChanged && Objects.nonNull(oldParentId)) {
|
||||
boolean hasChildren = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getParentId, oldParentId)
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.exists();
|
||||
if (!hasChildren) {
|
||||
defectService.lambdaUpdate()
|
||||
.eq(QmsStandardDefect::getId, oldParentId)
|
||||
.set(QmsStandardDefect::getIsLeaf, true)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 删除(逻辑删除) =========================
|
||||
|
||||
/**
|
||||
* 逻辑删除(deleted: 1->0),同时检查旧父级是否需要恢复 isLeaf
|
||||
*/
|
||||
@Transactional
|
||||
public void delete(Long id) {
|
||||
QmsStandardDefect exist = defectService.getById(id);
|
||||
if (Objects.isNull(exist)) {
|
||||
throw new NflgException(STATE.BusinessError, "缺陷记录不存在");
|
||||
}
|
||||
// 逻辑删除
|
||||
defectService.lambdaUpdate()
|
||||
.eq(QmsStandardDefect::getId, id)
|
||||
.set(QmsStandardDefect::getDeleted, false)
|
||||
.set(QmsStandardDefect::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsStandardDefect::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
|
||||
// 检查父级是否还有未删除子节点
|
||||
if (Objects.nonNull(exist.getParentId())) {
|
||||
boolean hasChildren = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getParentId, exist.getParentId())
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.exists();
|
||||
if (!hasChildren) {
|
||||
defectService.lambdaUpdate()
|
||||
.eq(QmsStandardDefect::getId, exist.getParentId())
|
||||
.set(QmsStandardDefect::getIsLeaf, true)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 查询(树形分页) =========================
|
||||
|
||||
/**
|
||||
* 查询缺陷树,对顶级节点分页,子节点随父节点返回
|
||||
* 有查询条件时:先找匹配节点,再补全其所有祖先,构建完整可见树
|
||||
* 无查询条件时:直接全量构建树
|
||||
*/
|
||||
public PageData<QmsStandardDefectVO> search(QmsStandardDefectSearchQO request) {
|
||||
// 查询所有 deleted=true 的记录(按 id 建 map 方便查找祖先)
|
||||
List<QmsStandardDefect> all = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.list();
|
||||
|
||||
boolean hasCondition = StrUtil.isNotBlank(request.getDefectCode())
|
||||
|| StrUtil.isNotBlank(request.getDefectName());
|
||||
|
||||
List<QmsStandardDefect> visibleList;
|
||||
if (!hasCondition) {
|
||||
// 无条件:全量展示
|
||||
visibleList = all;
|
||||
} else {
|
||||
// 按条件过滤出匹配节点
|
||||
List<QmsStandardDefect> matched = all.stream()
|
||||
.filter(d -> {
|
||||
boolean codeMatch = StrUtil.isBlank(request.getDefectCode())
|
||||
|| request.getDefectCode().equals(d.getDefectCode());
|
||||
boolean nameMatch = StrUtil.isBlank(request.getDefectName())
|
||||
|| d.getDefectName().contains(request.getDefectName());
|
||||
return codeMatch && nameMatch;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 用 id map 方便向上追溯祖先
|
||||
Map<Long, QmsStandardDefect> idMap = all.stream()
|
||||
.collect(Collectors.toMap(QmsStandardDefect::getId, d -> d));
|
||||
|
||||
// 收集匹配节点及其所有祖先节点(去重)
|
||||
Set<Long> visibleIds = new HashSet<>();
|
||||
for (QmsStandardDefect node : matched) {
|
||||
QmsStandardDefect cur = node;
|
||||
while (cur != null) {
|
||||
visibleIds.add(cur.getId());
|
||||
cur = cur.getParentId() != null ? idMap.get(cur.getParentId()) : null;
|
||||
}
|
||||
}
|
||||
visibleList = all.stream()
|
||||
.filter(d -> visibleIds.contains(d.getId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// 转 VO
|
||||
List<QmsStandardDefectVO> voList = visibleList.stream()
|
||||
.map(d -> BeanUtil.copyProperties(d, QmsStandardDefectVO.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建完整树
|
||||
List<QmsStandardDefectVO> tree = buildTree(voList, null);
|
||||
|
||||
// 对顶级节点分页(子节点随父节点返回)
|
||||
return PageUtil.Page(tree, request.getPage(), request.getPageSize());
|
||||
}
|
||||
|
||||
// ========================= 导出 =========================
|
||||
|
||||
/**
|
||||
* 查询未删除记录(扁平列表,用于导出)
|
||||
* ids 为空则全量,否则按 id 过滤
|
||||
*/
|
||||
public List<QmsStandardDefectVO> listForExport(List<Long> ids) {
|
||||
var query = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDeleted, true);
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
query.in(QmsStandardDefect::getId, ids);
|
||||
}
|
||||
return query
|
||||
.orderByAsc(QmsStandardDefect::getLevel)
|
||||
.orderByAsc(QmsStandardDefect::getSort)
|
||||
.list()
|
||||
.stream()
|
||||
.map(d -> BeanUtil.copyProperties(d, QmsStandardDefectVO.class))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// ========================= 导入 =========================
|
||||
|
||||
/**
|
||||
* 批量导入缺陷
|
||||
*/
|
||||
@Transactional
|
||||
public void importDefects(List<QmsStandardDefectImportDTO> dtos) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
for (QmsStandardDefectImportDTO dto : dtos) {
|
||||
if (StrUtil.isBlank(dto.getDefectCode()) || StrUtil.isBlank(dto.getDefectName())) {
|
||||
continue;
|
||||
}
|
||||
QmsStandardDefectAddQO qo = new QmsStandardDefectAddQO();
|
||||
qo.setParentName(dto.getParentName());
|
||||
qo.setDefectCode(dto.getDefectCode());
|
||||
qo.setDefectName(dto.getDefectName());
|
||||
qo.setState(!"禁用".equals(dto.getStateText()));
|
||||
qo.setRemark(dto.getRemark());
|
||||
add(qo);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 私有工具方法 =========================
|
||||
|
||||
/**
|
||||
* 按 defectName 查询父级(deleted=true),不存在则抛出异常
|
||||
*/
|
||||
private QmsStandardDefect getParentByName(String parentName) {
|
||||
QmsStandardDefect parent = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDefectName, parentName)
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.one();
|
||||
if (Objects.isNull(parent)) {
|
||||
throw new NflgException(STATE.BusinessError, "父级故障名称不存在:" + parentName);
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算同父级下下一个 sort 值
|
||||
*/
|
||||
private short calcNextSort(Long parentId) {
|
||||
List<QmsStandardDefect> siblings;
|
||||
if (Objects.isNull(parentId)) {
|
||||
siblings = defectService.lambdaQuery()
|
||||
.isNull(QmsStandardDefect::getParentId)
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.list();
|
||||
} else {
|
||||
siblings = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getParentId, parentId)
|
||||
.eq(QmsStandardDefect::getDeleted, true)
|
||||
.list();
|
||||
}
|
||||
return (short) (siblings.size() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建树形结构
|
||||
*/
|
||||
private List<QmsStandardDefectVO> buildTree(List<QmsStandardDefectVO> all, Long parentId) {
|
||||
List<QmsStandardDefectVO> result = new ArrayList<>();
|
||||
for (QmsStandardDefectVO vo : all) {
|
||||
if (Objects.equals(vo.getParentId(), parentId)) {
|
||||
List<QmsStandardDefectVO> children = buildTree(all, vo.getId());
|
||||
vo.setChildren(children.isEmpty() ? null : children);
|
||||
result.add(vo);
|
||||
}
|
||||
}
|
||||
result.sort((a, b) -> {
|
||||
short sa = a.getSort() == null ? 0 : a.getSort();
|
||||
short sb = b.getSort() == null ? 0 : b.getSort();
|
||||
return Short.compare(sa, sb);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.nflg.wms.common.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
/**
|
||||
* 标准缺陷导入 DTO(表头与模板列名对应)
|
||||
*/
|
||||
@Data
|
||||
public class QmsStandardDefectImportDTO {
|
||||
|
||||
/**
|
||||
* 父级缺陷名称(可为空,表示顶级)
|
||||
*/
|
||||
@ExcelColumn("父级故障名称")
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 缺陷代码
|
||||
*/
|
||||
@ExcelColumn("故障编码*")
|
||||
private String defectCode;
|
||||
|
||||
/**
|
||||
* 缺陷名称
|
||||
*/
|
||||
@ExcelColumn("故障名称*")
|
||||
private String defectName;
|
||||
|
||||
/**
|
||||
* 状态文本:启用/禁用
|
||||
*/
|
||||
@ExcelColumn("状态*")
|
||||
private String stateText;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@ExcelColumn("备注")
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 新增标准缺陷参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsStandardDefectAddQO {
|
||||
|
||||
/**
|
||||
* 父级缺陷名称(查询后自动赋值 parentId/parentCode),顶级时传 null
|
||||
*/
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 缺陷代码
|
||||
*/
|
||||
@NotBlank(message = "缺陷代码不能为空")
|
||||
private String defectCode;
|
||||
|
||||
/**
|
||||
* 缺陷名称
|
||||
*/
|
||||
@NotBlank(message = "缺陷名称不能为空")
|
||||
private String defectName;
|
||||
|
||||
/**
|
||||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Boolean state;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.Min;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 查询标准缺陷参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsStandardDefectSearchQO {
|
||||
|
||||
/**
|
||||
* 缺陷代码(精确)
|
||||
*/
|
||||
private String defectCode;
|
||||
|
||||
/**
|
||||
* 缺陷名称(模糊)
|
||||
*/
|
||||
private String defectName;
|
||||
|
||||
/**
|
||||
* 当前页码,默认第1页
|
||||
*/
|
||||
@Min(value = 1, message = "页码不能小于1")
|
||||
private Integer page = 1;
|
||||
|
||||
/**
|
||||
* 每页条数,默认20
|
||||
*/
|
||||
@Min(value = 1, message = "每页条数不能小于1")
|
||||
private Integer pageSize = 20;
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改标准缺陷参数(只传需要修改的字段,id必传)
|
||||
*/
|
||||
@Data
|
||||
public class QmsStandardDefectUpdateQO {
|
||||
|
||||
/**
|
||||
* 缺陷ID(必传)
|
||||
*/
|
||||
@NotNull(message = "ID不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父级缺陷名称(传 null 表示顶级;变更父级时自动处理旧父级 isLeaf;不传则不修改父级)
|
||||
*/
|
||||
private String parentName;
|
||||
|
||||
/**
|
||||
* 是否修改父级(true=修改父级关系,false=不修改)
|
||||
* 用于区分"不传parentName"是顶级还是不修改
|
||||
*/
|
||||
private Boolean changeParent;
|
||||
|
||||
/**
|
||||
* 缺陷代码(不传则不修改)
|
||||
*/
|
||||
private String defectCode;
|
||||
|
||||
/**
|
||||
* 缺陷名称(不传则不修改)
|
||||
*/
|
||||
private String defectName;
|
||||
|
||||
/**
|
||||
* 状态:true=启用,false=禁用(不传则不修改)
|
||||
*/
|
||||
private Boolean state;
|
||||
|
||||
/**
|
||||
* 备注(不传则不修改)
|
||||
*/
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.ttzero.excel.annotation.ExcelColumn;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标准缺陷 VO
|
||||
*/
|
||||
@Data
|
||||
public class QmsStandardDefectVO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 缺陷代码
|
||||
*/
|
||||
@ExcelColumn("故障代码")
|
||||
private String defectCode;
|
||||
|
||||
/**
|
||||
* 缺陷名称(故障类别名称)
|
||||
*/
|
||||
@ExcelColumn("故障类别名称")
|
||||
private String defectName;
|
||||
|
||||
/**
|
||||
* 父级缺陷id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 父级缺陷代码
|
||||
*/
|
||||
private String parentCode;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
private Short level;
|
||||
|
||||
/**
|
||||
* 排序序号
|
||||
*/
|
||||
private Short sort;
|
||||
|
||||
/**
|
||||
* 是否叶子节点:true=是,false=否
|
||||
*/
|
||||
private Boolean isLeaf;
|
||||
|
||||
/**
|
||||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean state;
|
||||
|
||||
/**
|
||||
* 状态文本(导出用)
|
||||
*/
|
||||
@ExcelColumn("状态")
|
||||
public String getStateText() {
|
||||
if (state == null) return "";
|
||||
return Boolean.TRUE.equals(state) ? "启用" : "禁用";
|
||||
}
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ExcelColumn("创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ExcelColumn(value = "创建日期", format = "yyyy-MM-dd")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
@ExcelColumn("最近修改人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
@ExcelColumn(value = "最近修改日期", format = "yyyy-MM-dd")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 子节点列表(树形结构)
|
||||
*/
|
||||
private List<QmsStandardDefectVO> children;
|
||||
}
|
||||
|
|
@ -0,0 +1,103 @@
|
|||
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>
|
||||
* 标准缺陷库
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@Accessors(chain = true)
|
||||
@TableName("qms_standard_defect")
|
||||
public class QmsStandardDefect implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 缺陷代码
|
||||
*/
|
||||
private String defectCode;
|
||||
|
||||
/**
|
||||
* 缺陷名称
|
||||
*/
|
||||
private String defectName;
|
||||
|
||||
/**
|
||||
* 父级缺陷id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 父级缺陷代码
|
||||
*/
|
||||
private String parentCode;
|
||||
|
||||
/**
|
||||
* 层级
|
||||
*/
|
||||
private Short level;
|
||||
|
||||
/**
|
||||
* 排序序号
|
||||
*/
|
||||
private Short sort;
|
||||
|
||||
/**
|
||||
* 是否叶子节点:true=是,false=否
|
||||
*/
|
||||
private Boolean isLeaf;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean state;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 最后更新人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 逻辑删除:true=未删除,false=已删除
|
||||
*/
|
||||
private Boolean deleted;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nflg.wms.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.wms.repository.entity.QmsStandardDefect;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 标准缺陷库 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface QmsStandardDefectMapper extends BaseMapper<QmsStandardDefect> {
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.repository.entity.QmsStandardDefect;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 标准缺陷库 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface IQmsStandardDefectService extends IService<QmsStandardDefect> {
|
||||
}
|
||||
|
|
@ -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.QmsStandardDefect;
|
||||
import com.nflg.wms.repository.mapper.QmsStandardDefectMapper;
|
||||
import com.nflg.wms.repository.service.IQmsStandardDefectService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 标准缺陷库 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
@Service
|
||||
public class QmsStandardDefectServiceImpl extends ServiceImpl<QmsStandardDefectMapper, QmsStandardDefect>
|
||||
implements IQmsStandardDefectService {
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<?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.nflg.wms.repository.mapper.QmsStandardDefectMapper">
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue