Merge branch 'qms/yf' into qms/develop
This commit is contained in:
commit
bc22c096fe
|
|
@ -0,0 +1,112 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorStatusQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorTransferQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorDetailVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO;
|
||||
import com.nflg.wms.repository.service.IQmsQualityInspectorService;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* 质检人员管理
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/qualityInspector")
|
||||
public class QmsQualityInspectorController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private IQmsQualityInspectorService qualityInspectorService;
|
||||
|
||||
/**
|
||||
* 新增质检人员(可同时绑定物料ID和物料类别)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("add")
|
||||
public ApiResult<Void> add(@Valid @RequestBody QmsQualityInspectorAddQO request) {
|
||||
qualityInspectorService.add(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除质检人员(传入 userId,删除该用户所有关联记录,启用状态下不允许删除)
|
||||
*
|
||||
* @param userId 员工ID
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("delete")
|
||||
public ApiResult<Void> delete(@NotNull Long userId) {
|
||||
qualityInspectorService.delete(userId);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改质检人员的物料/物料类别(追加或删除)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("update")
|
||||
public ApiResult<Void> update(@Valid @RequestBody QmsQualityInspectorUpdateQO request) {
|
||||
qualityInspectorService.update(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询质检人员列表(支持员工工号/姓名/物料编号过滤,含转办人名称)
|
||||
*/
|
||||
@PostMapping("search")
|
||||
public ApiResult<PageData<QmsQualityInspectorVO>> search(@Valid @RequestBody QmsQualityInspectorSearchQO request) {
|
||||
return ApiResult.success(qualityInspectorService.search(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按员工ID查询质检人员详情(物料和物料类别分开返回,不分页)
|
||||
*
|
||||
* @param userId 员工ID
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public ApiResult<QmsQualityInspectorDetailVO> detail(@NotNull Long userId) {
|
||||
return ApiResult.success(qualityInspectorService.getDetailByUserId(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改状态(将该质检人的所有记录状态全改)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("updateStatus")
|
||||
public ApiResult<Void> updateStatus(@Valid @RequestBody QmsQualityInspectorStatusQO request) {
|
||||
qualityInspectorService.updateStatus(request.getUserId(), request.getEnable());
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转办(将该质检人所有记录设置转办人)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("transfer")
|
||||
public ApiResult<Void> transfer(@Valid @RequestBody QmsQualityInspectorTransferQO request) {
|
||||
qualityInspectorService.transfer(request);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消转办(将该质检人所有记录的转办人清空)
|
||||
*
|
||||
* @param userId 员工ID
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("cancelTransfer")
|
||||
public ApiResult<Void> cancelTransfer(@NotNull Long userId) {
|
||||
qualityInspectorService.cancelTransfer(userId);
|
||||
return ApiResult.success();
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,7 @@ public class QmsStandardDefectControllerService {
|
|||
QmsStandardDefect entity = new QmsStandardDefect()
|
||||
.setDefectCode(request.getDefectCode())
|
||||
.setDefectName(request.getDefectName())
|
||||
.setState(request.getState())
|
||||
.setEnable(request.getEnable())
|
||||
.setRemark(request.getRemark())
|
||||
.setDeleted(false)
|
||||
.setCreateBy(operator)
|
||||
|
|
@ -137,8 +137,8 @@ public class QmsStandardDefectControllerService {
|
|||
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.getEnable())) {
|
||||
updateChain.set(QmsStandardDefect::getEnable, request.getEnable());
|
||||
}
|
||||
if (Objects.nonNull(request.getRemark())) {
|
||||
updateChain.set(QmsStandardDefect::getRemark, request.getRemark());
|
||||
|
|
@ -179,6 +179,11 @@ public class QmsStandardDefectControllerService {
|
|||
.set(QmsStandardDefect::getUpdateTime, now)
|
||||
.update();
|
||||
|
||||
// 若状态有变更,级联更新所有子孙节点状态
|
||||
if (Objects.nonNull(request.getEnable())) {
|
||||
updateDescendantsEnable(request.getId(), request.getEnable(), operator, now);
|
||||
}
|
||||
|
||||
// 若父级变更,检查旧父级是否还有未删除子节点,没有则恢复 isLeaf=true
|
||||
if (parentChanged && Objects.nonNull(oldParentId)) {
|
||||
boolean hasChildren = defectService.lambdaQuery()
|
||||
|
|
@ -236,9 +241,9 @@ public class QmsStandardDefectControllerService {
|
|||
* 无查询条件时:直接全量构建树
|
||||
*/
|
||||
public PageData<QmsStandardDefectVO> search(QmsStandardDefectSearchQO request) {
|
||||
// 查询所有 deleted=false 的记录(按 id 建 map 方便查找祖先)
|
||||
// 查询所有未逻辑删除的记录(deleted=false 或 null 均视为未删除)
|
||||
List<QmsStandardDefect> all = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDeleted, false)
|
||||
.ne(QmsStandardDefect::getDeleted, true)
|
||||
.list();
|
||||
|
||||
boolean hasCondition = StrUtil.isNotBlank(request.getDefectCode())
|
||||
|
|
@ -298,7 +303,7 @@ public class QmsStandardDefectControllerService {
|
|||
*/
|
||||
public List<QmsStandardDefectVO> listForExport(List<Long> ids) {
|
||||
var query = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getDeleted, 0);
|
||||
.ne(QmsStandardDefect::getDeleted, true);
|
||||
if (ids != null && !ids.isEmpty()) {
|
||||
query.in(QmsStandardDefect::getId, ids);
|
||||
}
|
||||
|
|
@ -328,7 +333,7 @@ public class QmsStandardDefectControllerService {
|
|||
qo.setParentName(dto.getParentName());
|
||||
qo.setDefectCode(dto.getDefectCode());
|
||||
qo.setDefectName(dto.getDefectName());
|
||||
qo.setState(!"禁用".equals(dto.getStateText()));
|
||||
qo.setEnable(!"禁用".equals(dto.getStateText()));
|
||||
qo.setRemark(dto.getRemark());
|
||||
add(qo);
|
||||
}
|
||||
|
|
@ -336,6 +341,33 @@ public class QmsStandardDefectControllerService {
|
|||
|
||||
// ========================= 私有工具方法 =========================
|
||||
|
||||
/**
|
||||
* 递归将某节点的所有子孙节点状态同步为指定值
|
||||
*/
|
||||
private void updateDescendantsEnable(Long parentId, Boolean enable,
|
||||
String operator, LocalDateTime now) {
|
||||
List<QmsStandardDefect> children = defectService.lambdaQuery()
|
||||
.eq(QmsStandardDefect::getParentId, parentId)
|
||||
.eq(QmsStandardDefect::getDeleted, false)
|
||||
.list();
|
||||
if (children.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Long> childIds = children.stream()
|
||||
.map(QmsStandardDefect::getId)
|
||||
.collect(Collectors.toList());
|
||||
defectService.lambdaUpdate()
|
||||
.in(QmsStandardDefect::getId, childIds)
|
||||
.set(QmsStandardDefect::getEnable, enable)
|
||||
.set(QmsStandardDefect::getUpdateBy, operator)
|
||||
.set(QmsStandardDefect::getUpdateTime, now)
|
||||
.update();
|
||||
// 继续递归处理每个子节点的子孙
|
||||
for (Long childId : childIds) {
|
||||
updateDescendantsEnable(childId, enable, operator, now);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按 defectName 查询父级(deleted=0),不存在则抛出异常
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 新增质检人员 请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorAddQO {
|
||||
|
||||
/**
|
||||
* 质检人ID(user.id),必传
|
||||
*/
|
||||
@NotNull(message = "质检人ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 质检类型:0=SQE,1=IQE,必传
|
||||
*/
|
||||
@NotNull(message = "质检类型不能为空")
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 物料ID列表(可选,与物料类别至少传一项或都不传)
|
||||
*/
|
||||
private List<Long> materialIds;
|
||||
|
||||
/**
|
||||
* 物料类别编码列表(可选)
|
||||
*/
|
||||
private List<String> materialCategoryCodes;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 查询质检人员列表 请求参数(分页)
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorSearchQO extends PageQO {
|
||||
|
||||
/**
|
||||
* 员工工号(精确匹配)
|
||||
*/
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 人员名称(模糊匹配)
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 物料编号(模糊匹配)
|
||||
*/
|
||||
private String materialNo;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 修改质检人员状态 请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorStatusQO {
|
||||
|
||||
/**
|
||||
* 质检人ID,必传
|
||||
*/
|
||||
@NotNull(message = "质检人ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Boolean enable;
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 转办质检人员 请求参数
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorTransferQO {
|
||||
|
||||
/**
|
||||
* 当前员工ID,必传
|
||||
*/
|
||||
@NotNull(message = "员工ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 转办人ID(user.id),必传
|
||||
*/
|
||||
@NotNull(message = "转办人ID不能为空")
|
||||
private Long changeUserId;
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.nflg.wms.common.pojo.qo;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 修改质检人员物料关联 请求参数(对某质检人追加或删除物料/物料类别)
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorUpdateQO {
|
||||
|
||||
/**
|
||||
* 质检人ID,必传
|
||||
*/
|
||||
@NotNull(message = "质检人ID不能为空")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 新增的物料ID列表(qms_qc_material.id)
|
||||
*/
|
||||
private List<Long> addMaterialIds;
|
||||
|
||||
/**
|
||||
* 删除的物料ID列表(qms_qc_material.id,即 qms_quality_inspector.material_id)
|
||||
*/
|
||||
private List<Long> removeMaterialIds;
|
||||
|
||||
/**
|
||||
* 新增的物料类别编码列表
|
||||
*/
|
||||
private List<String> addMaterialCategoryCodes;
|
||||
|
||||
/**
|
||||
* 删除的物料类别编码列表
|
||||
*/
|
||||
private List<String> removeMaterialCategoryCodes;
|
||||
}
|
||||
|
|
@ -31,7 +31,7 @@ public class QmsStandardDefectAddQO {
|
|||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
@NotNull(message = "状态不能为空")
|
||||
private Boolean state;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ public class QmsStandardDefectUpdateQO {
|
|||
private String defectName;
|
||||
|
||||
/**
|
||||
* 状态:true=启用,false=禁用(不传则不修改)
|
||||
* 状态:true=启用,false=禁用(不传则不修改;若修改,子孙节点同步更新)
|
||||
*/
|
||||
private Boolean state;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 备注(不传则不修改)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 质检人员关联物料类别信息
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorCategoryVO {
|
||||
|
||||
/**
|
||||
* 关联记录ID(qms_quality_inspector.id)
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 物料类别编码
|
||||
*/
|
||||
private String materialCategoryCode;
|
||||
|
||||
/**
|
||||
* 物料类别名称(来自 material_category 或关联表)
|
||||
*/
|
||||
private String materialCategoryName;
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 按员工ID查询质检人员详情(物料 + 物料类别分开返回)
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorDetailVO {
|
||||
|
||||
/**
|
||||
* 质检人ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 质检人工号
|
||||
*/
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 质检人姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 所属部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 直属领导名称(暂留字段)
|
||||
*/
|
||||
private String deptLeaderName;
|
||||
|
||||
/**
|
||||
* 职位名称
|
||||
*/
|
||||
private String positionName;
|
||||
|
||||
/**
|
||||
* 质检类型:0=SQE,1=IQE
|
||||
*/
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 启用状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 关联的物料列表(material_id 不为空的记录)
|
||||
*/
|
||||
private List<QmsQualityInspectorMaterialVO> materials;
|
||||
|
||||
/**
|
||||
* 关联的物料类别列表(material_category_code 不为空的记录)
|
||||
*/
|
||||
private List<QmsQualityInspectorCategoryVO> categories;
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 质检人员关联物料信息
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorMaterialVO {
|
||||
|
||||
/**
|
||||
* 关联记录ID(qms_quality_inspector.id)
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 物料ID
|
||||
*/
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 物料编号
|
||||
*/
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料类别编码
|
||||
*/
|
||||
private String materialCategoryCode;
|
||||
|
||||
/**
|
||||
* 物料类别名称
|
||||
*/
|
||||
private String materialCategoryName;
|
||||
|
||||
/**
|
||||
* 物料描述(即物料名称,对应 qms_qc_material.material_desc)
|
||||
*/
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 物料规格
|
||||
*/
|
||||
private String materialSpecifications;
|
||||
|
||||
/**
|
||||
* 物料材质
|
||||
*/
|
||||
private String materialTexture;
|
||||
|
||||
/**
|
||||
* 物料状态:true=启用,false=禁用(来自 qms_qc_material)
|
||||
*/
|
||||
private Boolean materialStatus;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 质检人员分页查询 返回VO
|
||||
*/
|
||||
@Data
|
||||
public class QmsQualityInspectorVO {
|
||||
|
||||
/**
|
||||
* 记录ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 质检人ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 质检人工号
|
||||
*/
|
||||
private String userCode;
|
||||
|
||||
/**
|
||||
* 质检人姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 所属部门ID
|
||||
*/
|
||||
private Long deptId;
|
||||
|
||||
/**
|
||||
* 所属部门名称
|
||||
*/
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 部门直属领导ID(暂留字段,后续扩展)
|
||||
*/
|
||||
private Long deptLeaderId;
|
||||
|
||||
/**
|
||||
* 部门直属领导名称(暂留字段,后续扩展)
|
||||
*/
|
||||
private String deptLeaderName;
|
||||
|
||||
/**
|
||||
* 启用状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 质检类型:0=SQE,1=IQE
|
||||
*/
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 转办人ID
|
||||
*/
|
||||
private Long changeUserId;
|
||||
|
||||
/**
|
||||
* 转办人姓名(无转办人则为空)
|
||||
*/
|
||||
private String changeUserName;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
|
||||
|
|
@ -54,15 +54,15 @@ public class QmsStandardDefectVO {
|
|||
/**
|
||||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean state;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 状态文本(导出用)
|
||||
*/
|
||||
@ExcelColumn("状态")
|
||||
public String getStateText() {
|
||||
if (state == null) return "";
|
||||
return Boolean.TRUE.equals(state) ? "启用" : "禁用";
|
||||
if (enable == null) return "";
|
||||
return Boolean.TRUE.equals(enable) ? "启用" : "禁用";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ public class QmsSupplierSqeMapVO {
|
|||
private String positionName;
|
||||
|
||||
/**
|
||||
* 状态:1=启用,2=禁用
|
||||
* 启用状态:true=启用,false=禁用
|
||||
*/
|
||||
private Integer state;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
|
|||
|
|
@ -0,0 +1,123 @@
|
|||
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_qc_material")
|
||||
public class QmsQcMaterial implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 物料编号
|
||||
*/
|
||||
private String materialNo;
|
||||
|
||||
/**
|
||||
* 物料描述
|
||||
*/
|
||||
private String materialDesc;
|
||||
|
||||
/**
|
||||
* 描述是否变更:false=未变更,true=已变更
|
||||
*/
|
||||
private Boolean materialDescIsUpgrade;
|
||||
|
||||
/**
|
||||
* 物料类别
|
||||
*/
|
||||
private String materialCategoryCode;
|
||||
|
||||
/**
|
||||
* 物料类别全路径名称
|
||||
*/
|
||||
private String materialCategoryCodePathName;
|
||||
|
||||
/**
|
||||
* 物料图号
|
||||
*/
|
||||
private String drawingNo;
|
||||
|
||||
/**
|
||||
* 图号版本号
|
||||
*/
|
||||
private String drawingNoVer;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 物料材质
|
||||
*/
|
||||
private String materialTexture;
|
||||
|
||||
/**
|
||||
* 物料规格
|
||||
*/
|
||||
private String materialSpecifications;
|
||||
|
||||
/**
|
||||
* 规则是否已维护:false=未维护,true=已维护
|
||||
*/
|
||||
private Boolean isStandardMaintained;
|
||||
|
||||
/**
|
||||
* 创建方式:0=人工操作,1=系统同步
|
||||
*/
|
||||
private Integer createdType;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 创建人名称
|
||||
*/
|
||||
private String createByName;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 修改人ID
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 修改人名称
|
||||
*/
|
||||
private String updateByName;
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
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_quality_inspector")
|
||||
public class QmsQualityInspector implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 质检人ID (user.id)
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 物料ID (qms_qc_material.id),可为空
|
||||
*/
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 启用状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 质检类型:0=SQE,1=IQE
|
||||
*/
|
||||
private Integer inspectionType;
|
||||
|
||||
/**
|
||||
* 转办人ID (user.id),可为空
|
||||
*/
|
||||
private Long changeUserId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 物料类别编码
|
||||
*/
|
||||
private String materialCategoryCode;
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ public class QmsStandardDefect implements Serializable {
|
|||
/**
|
||||
* 状态:true=启用,false=禁用
|
||||
*/
|
||||
private Boolean state;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
|
|||
|
|
@ -42,9 +42,9 @@ public class QmsSupplierSqeMap implements Serializable {
|
|||
private Long userId;
|
||||
|
||||
/**
|
||||
* 状态:1=启用,2=禁用
|
||||
* 启用状态:true=启用,false=禁用
|
||||
*/
|
||||
private Integer state;
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nflg.wms.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nflg.wms.repository.entity.QmsQcMaterial;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 质检物料 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface QmsQcMaterialMapper extends BaseMapper<QmsQcMaterial> {
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.nflg.wms.repository.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorCategoryVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO;
|
||||
import com.nflg.wms.repository.entity.QmsQualityInspector;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 质检人员物料关系 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface QmsQualityInspectorMapper extends BaseMapper<QmsQualityInspector> {
|
||||
|
||||
/**
|
||||
* 分页查询(JOIN user/user_interior/department,支持动态过滤)
|
||||
*/
|
||||
IPage<QmsQualityInspectorVO> searchPage(@Param("request") QmsQualityInspectorSearchQO request, Page<QmsQualityInspectorVO> page);
|
||||
|
||||
/**
|
||||
* 按 userId 查询关联物料列表(JOIN qms_qc_material)
|
||||
*/
|
||||
List<QmsQualityInspectorMaterialVO> getMaterialsByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 按 userId 查询关联物料类别列表
|
||||
*/
|
||||
List<QmsQualityInspectorCategoryVO> getCategoriesByUserId(@Param("userId") Long userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.repository.entity.QmsQcMaterial;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 质检物料 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface IQmsQcMaterialService extends IService<QmsQcMaterial> {
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package com.nflg.wms.repository.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorTransferQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorDetailVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO;
|
||||
import com.nflg.wms.repository.entity.QmsQualityInspector;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 质检人员物料关系 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
public interface IQmsQualityInspectorService extends IService<QmsQualityInspector> {
|
||||
|
||||
/**
|
||||
* 新增质检人员(可同时绑定物料ID和物料类别)
|
||||
*/
|
||||
void add(QmsQualityInspectorAddQO request);
|
||||
|
||||
/**
|
||||
* 删除质检人员(传入 userId,删除该用户所有关联记录,启用状态不允许删除)
|
||||
*/
|
||||
void delete(Long userId);
|
||||
|
||||
/**
|
||||
* 修改质检人员的物料/物料类别(追加或删除)
|
||||
*/
|
||||
void update(QmsQualityInspectorUpdateQO request);
|
||||
|
||||
/**
|
||||
* 分页查询质检人员列表(支持员工工号/姓名/物料编号过滤)
|
||||
*/
|
||||
IPage<QmsQualityInspectorVO> search(QmsQualityInspectorSearchQO request);
|
||||
|
||||
/**
|
||||
* 按员工ID查询质检人员详情,将物料和物料类别分开返回(不分页)
|
||||
*/
|
||||
QmsQualityInspectorDetailVO getDetailByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 修改状态(将该质检人的所有记录状态全改)
|
||||
*/
|
||||
void updateStatus(Long userId, Boolean enable);
|
||||
|
||||
/**
|
||||
* 转办(将该质检人所有记录设置转办人)
|
||||
*/
|
||||
void transfer(QmsQualityInspectorTransferQO request);
|
||||
|
||||
/**
|
||||
* 取消转办(将该质检人所有记录的转办人清空)
|
||||
*/
|
||||
void cancelTransfer(Long userId);
|
||||
}
|
||||
|
|
@ -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.QmsQcMaterial;
|
||||
import com.nflg.wms.repository.mapper.QmsQcMaterialMapper;
|
||||
import com.nflg.wms.repository.service.IQmsQcMaterialService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 质检物料 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
@Service
|
||||
public class QmsQcMaterialServiceImpl extends ServiceImpl<QmsQcMaterialMapper, QmsQcMaterial>
|
||||
implements IQmsQcMaterialService {
|
||||
}
|
||||
|
|
@ -0,0 +1,307 @@
|
|||
package com.nflg.wms.repository.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.wms.common.constant.STATE;
|
||||
import com.nflg.wms.common.exception.NflgException;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorAddQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorTransferQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsQualityInspectorUpdateQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorCategoryVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorDetailVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsQualityInspector;
|
||||
import com.nflg.wms.repository.entity.User;
|
||||
import com.nflg.wms.repository.mapper.QmsQualityInspectorMapper;
|
||||
import com.nflg.wms.repository.service.IQmsQualityInspectorService;
|
||||
import com.nflg.wms.repository.service.IUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 质检人员物料关系 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 代码生成器生成
|
||||
* @since 2025
|
||||
*/
|
||||
@Service
|
||||
public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspectorMapper, QmsQualityInspector>
|
||||
implements IQmsQualityInspectorService {
|
||||
|
||||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
// ========================= 新增 =========================
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void add(QmsQualityInspectorAddQO request) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<QmsQualityInspector> records = new ArrayList<>();
|
||||
|
||||
boolean hasMaterial = !CollectionUtils.isEmpty(request.getMaterialIds());
|
||||
boolean hasCategory = !CollectionUtils.isEmpty(request.getMaterialCategoryCodes());
|
||||
|
||||
if (hasMaterial) {
|
||||
for (Long materialId : request.getMaterialIds()) {
|
||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
||||
materialId, null, operator, now));
|
||||
}
|
||||
}
|
||||
if (hasCategory) {
|
||||
for (String categoryCode : request.getMaterialCategoryCodes()) {
|
||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
||||
null, categoryCode, operator, now));
|
||||
}
|
||||
}
|
||||
// 物料id和物料类别都不传时,插入一条无物料关联的记录
|
||||
if (!hasMaterial && !hasCategory) {
|
||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
||||
null, null, operator, now));
|
||||
}
|
||||
|
||||
saveBatch(records);
|
||||
}
|
||||
|
||||
private QmsQualityInspector buildRecord(Long userId, Integer inspectionType,
|
||||
Long materialId, String categoryCode,
|
||||
String operator, LocalDateTime now) {
|
||||
return new QmsQualityInspector()
|
||||
.setUserId(userId)
|
||||
.setInspectionType(inspectionType)
|
||||
.setMaterialId(materialId)
|
||||
.setMaterialCategoryCode(categoryCode)
|
||||
.setEnable(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除物料/物料类别关联行。
|
||||
* 若删除后该 userId 下记录数归零,则保留其中一条(清空 materialId 和 materialCategoryCode),
|
||||
* 不做物理删除,确保人员记录始终存在。
|
||||
*/
|
||||
private void removeMaterialOrClear(Long userId, List<QmsQualityInspector> toRemove,
|
||||
String operator, LocalDateTime now) {
|
||||
if (CollectionUtils.isEmpty(toRemove)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 该用户当前全部记录
|
||||
List<QmsQualityInspector> all = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.list();
|
||||
long total = all.size();
|
||||
|
||||
// 待删除的行 ID 集合
|
||||
Set<Long> removeIdSet = toRemove.stream()
|
||||
.map(QmsQualityInspector::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 删除后剩余条数
|
||||
long remaining = total - removeIdSet.size();
|
||||
|
||||
if (remaining <= 0) {
|
||||
// 删完后一条不剩:从所有记录中选一条保留(优先选不在 toRemove 中的,没有则从 toRemove 中选第一条)
|
||||
QmsQualityInspector keep = all.stream()
|
||||
.filter(r -> !removeIdSet.contains(r.getId()))
|
||||
.findFirst()
|
||||
.orElse(toRemove.get(0));
|
||||
|
||||
// 删除其余所有行(保留行除外)
|
||||
List<Long> deleteIds = all.stream()
|
||||
.map(QmsQualityInspector::getId)
|
||||
.filter(id -> !id.equals(keep.getId()))
|
||||
.collect(Collectors.toList());
|
||||
if (!deleteIds.isEmpty()) {
|
||||
removeByIds(deleteIds);
|
||||
}
|
||||
|
||||
// 保留行的物料字段清空
|
||||
lambdaUpdate()
|
||||
.eq(QmsQualityInspector::getId, keep.getId())
|
||||
.set(QmsQualityInspector::getMaterialId, null)
|
||||
.set(QmsQualityInspector::getMaterialCategoryCode, null)
|
||||
.set(QmsQualityInspector::getUpdateBy, operator)
|
||||
.set(QmsQualityInspector::getUpdateTime, now)
|
||||
.update();
|
||||
} else {
|
||||
// 正常物理删除
|
||||
removeByIds(new ArrayList<>(removeIdSet));
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 删除 =========================
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void delete(Long userId) {
|
||||
// 查询该用户是否存在记录
|
||||
List<QmsQualityInspector> records = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.list();
|
||||
if (records.isEmpty()) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||
}
|
||||
// 启用状态下不允许删除
|
||||
boolean enabled = records.stream().anyMatch(r -> Boolean.TRUE.equals(r.getEnable()));
|
||||
if (enabled) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员处于启用状态,不允许删除,请先禁用后再删除");
|
||||
}
|
||||
// 删除该用户所有记录
|
||||
List<Long> ids = records.stream().map(QmsQualityInspector::getId).collect(Collectors.toList());
|
||||
removeByIds(ids);
|
||||
}
|
||||
|
||||
// ========================= 修改物料/物料类别 =========================
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void update(QmsQualityInspectorUpdateQO request) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
Long userId = request.getUserId();
|
||||
|
||||
// 查询当前该质检人的任意一条记录,取 inspectionType(同一人 inspectionType 相同)
|
||||
QmsQualityInspector any = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
if (Objects.isNull(any)) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||
}
|
||||
Integer inspectionType = any.getInspectionType();
|
||||
|
||||
// 追加物料
|
||||
if (!CollectionUtils.isEmpty(request.getAddMaterialIds())) {
|
||||
List<QmsQualityInspector> toAdd = request.getAddMaterialIds().stream()
|
||||
.map(materialId -> buildRecord(userId, inspectionType, materialId, null, operator, now))
|
||||
.collect(Collectors.toList());
|
||||
saveBatch(toAdd);
|
||||
}
|
||||
|
||||
// 追加物料类别
|
||||
if (!CollectionUtils.isEmpty(request.getAddMaterialCategoryCodes())) {
|
||||
List<QmsQualityInspector> toAdd = request.getAddMaterialCategoryCodes().stream()
|
||||
.map(code -> buildRecord(userId, inspectionType, null, code, operator, now))
|
||||
.collect(Collectors.toList());
|
||||
saveBatch(toAdd);
|
||||
}
|
||||
|
||||
// 删除物料(按 userId + material_id)和 物料类别(按 userId + material_category_code)
|
||||
// 两者合并到一次操作,避免分步计算 total 不准确
|
||||
List<QmsQualityInspector> toRemove = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(request.getRemoveMaterialIds())) {
|
||||
toRemove.addAll(lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.in(QmsQualityInspector::getMaterialId, request.getRemoveMaterialIds())
|
||||
.list());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(request.getRemoveMaterialCategoryCodes())) {
|
||||
toRemove.addAll(lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.in(QmsQualityInspector::getMaterialCategoryCode, request.getRemoveMaterialCategoryCodes())
|
||||
.list());
|
||||
}
|
||||
if (!toRemove.isEmpty()) {
|
||||
removeMaterialOrClear(userId, toRemove, operator, now);
|
||||
}
|
||||
}
|
||||
|
||||
// ========================= 查询 =========================
|
||||
|
||||
@Override
|
||||
public IPage<QmsQualityInspectorVO> search(QmsQualityInspectorSearchQO request) {
|
||||
return baseMapper.searchPage(request, new Page<>(request.getPage(), request.getPageSize()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public QmsQualityInspectorDetailVO getDetailByUserId(Long userId) {
|
||||
// 查询该用户的任意一条记录(取 inspectionType/enable)
|
||||
QmsQualityInspector first = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
if (Objects.isNull(first)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 查 user 信息
|
||||
User user = userService.getById(userId);
|
||||
|
||||
QmsQualityInspectorDetailVO detail = new QmsQualityInspectorDetailVO();
|
||||
detail.setUserId(userId);
|
||||
detail.setInspectionType(first.getInspectionType());
|
||||
detail.setEnable(first.getEnable());
|
||||
if (Objects.nonNull(user)) {
|
||||
detail.setUserCode(user.getUserCode());
|
||||
detail.setUserName(user.getUserName());
|
||||
}
|
||||
// 部门领导暂不填充,字段预留
|
||||
detail.setDeptLeaderName(null);
|
||||
|
||||
// 查物料列表
|
||||
detail.setMaterials(baseMapper.getMaterialsByUserId(userId));
|
||||
// 查物料类别列表
|
||||
detail.setCategories(baseMapper.getCategoriesByUserId(userId));
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
// ========================= 状态修改 =========================
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void updateStatus(Long userId, Boolean enable) {
|
||||
lambdaUpdate()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.set(QmsQualityInspector::getEnable, enable)
|
||||
.set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsQualityInspector::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
}
|
||||
|
||||
// ========================= 转办 =========================
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void transfer(QmsQualityInspectorTransferQO request) {
|
||||
lambdaUpdate()
|
||||
.eq(QmsQualityInspector::getUserId, request.getUserId())
|
||||
.set(QmsQualityInspector::getChangeUserId, request.getChangeUserId())
|
||||
.set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsQualityInspector::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
}
|
||||
|
||||
// ========================= 取消转办 =========================
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void cancelTransfer(Long userId) {
|
||||
lambdaUpdate()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.set(QmsQualityInspector::getChangeUserId, null)
|
||||
.set(QmsQualityInspector::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsQualityInspector::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +55,7 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
.map(supplierId -> new QmsSupplierSqeMap()
|
||||
.setSupplierId(supplierId)
|
||||
.setUserId(userId)
|
||||
.setState(1)
|
||||
.setEnable(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
|
|
@ -84,7 +84,7 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
.map(userId -> new QmsSupplierSqeMap()
|
||||
.setSupplierId(supplierId)
|
||||
.setUserId(userId)
|
||||
.setState(1)
|
||||
.setEnable(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
|
|
@ -104,7 +104,7 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
}
|
||||
lambdaUpdate()
|
||||
.eq(QmsSupplierSqeMap::getId, id)
|
||||
.set(QmsSupplierSqeMap::getState, enable ? 1 : 2)
|
||||
.set(QmsSupplierSqeMap::getEnable, enable)
|
||||
.set(QmsSupplierSqeMap::getUpdateBy, UserUtil.getUserName())
|
||||
.set(QmsSupplierSqeMap::getUpdateTime, LocalDateTime.now())
|
||||
.update();
|
||||
|
|
@ -117,7 +117,7 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
if (Objects.isNull(record)) {
|
||||
throw new NflgException(STATE.BusinessError, "关联记录不存在");
|
||||
}
|
||||
if (record.getState() != null && record.getState() == 1) {
|
||||
if (Boolean.TRUE.equals(record.getEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "关联关系处于启用状态,不允许删除,请先禁用后再删除");
|
||||
}
|
||||
removeById(id);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,91 @@
|
|||
<?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.QmsQualityInspectorMapper">
|
||||
|
||||
<!--
|
||||
分页查询:以质检人为主体,每个 user_id 只返回一条记录
|
||||
使用 DISTINCT ON (qi.user_id) 保证每人唯一
|
||||
JOIN user_interior/department 获取部门信息
|
||||
JOIN user AS cu 获取转办人姓名
|
||||
支持动态过滤:员工工号(userCode)、人员名称模糊(userName)、物料编号(materialNo)
|
||||
-->
|
||||
<select id="searchPage" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO">
|
||||
SELECT
|
||||
qi.id,
|
||||
qi.user_id,
|
||||
u.user_code,
|
||||
u.user_name,
|
||||
d.id AS dept_id,
|
||||
d.name AS dept_name,
|
||||
NULL::bigint AS dept_leader_id,
|
||||
NULL::varchar AS dept_leader_name,
|
||||
qi.enable,
|
||||
qi.inspection_type,
|
||||
qi.change_user_id,
|
||||
cu.user_name AS change_user_name,
|
||||
qi.create_by,
|
||||
qi.create_time,
|
||||
qi.update_by,
|
||||
qi.update_time
|
||||
FROM (
|
||||
SELECT DISTINCT ON (user_id) *
|
||||
FROM qms_quality_inspector
|
||||
ORDER BY user_id, id DESC
|
||||
) qi
|
||||
LEFT JOIN "user" u ON u.id = qi.user_id
|
||||
LEFT JOIN user_interior ui ON ui.user_id = qi.user_id
|
||||
LEFT JOIN department d ON d.id = ui.dept_id
|
||||
LEFT JOIN "user" cu ON cu.id = qi.change_user_id
|
||||
<where>
|
||||
<if test="request.userCode != null and request.userCode != ''">
|
||||
AND u.user_code = #{request.userCode}
|
||||
</if>
|
||||
<if test="request.userName != null and request.userName != ''">
|
||||
AND u.user_name ilike concat('%', #{request.userName}, '%')
|
||||
</if>
|
||||
<if test="request.materialNo != null and request.materialNo != ''">
|
||||
AND EXISTS (
|
||||
SELECT 1 FROM qms_quality_inspector qi2
|
||||
LEFT JOIN qms_qc_material m ON m.id = qi2.material_id
|
||||
WHERE qi2.user_id = qi.user_id
|
||||
AND m.material_no ilike concat('%', #{request.materialNo}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY qi.id DESC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询关联物料列表(JOIN qms_qc_material 获取物料详情) -->
|
||||
<select id="getMaterialsByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||
SELECT
|
||||
qi.id,
|
||||
qi.material_id,
|
||||
m.material_no,
|
||||
m.material_category_code,
|
||||
m.material_category_code_path_name AS material_category_name,
|
||||
m.material_desc AS material_name,
|
||||
m.material_specifications,
|
||||
m.material_texture,
|
||||
m.is_standard_maintained AS material_status
|
||||
FROM qms_quality_inspector qi
|
||||
LEFT JOIN qms_qc_material m ON m.id = qi.material_id
|
||||
WHERE qi.user_id = #{userId}
|
||||
AND qi.material_id IS NOT NULL
|
||||
ORDER BY qi.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询关联物料类别列表(JOIN qms_qc_material 取类别名称) -->
|
||||
<select id="getCategoriesByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorCategoryVO">
|
||||
SELECT DISTINCT ON (qi.material_category_code)
|
||||
qi.id,
|
||||
qi.material_category_code,
|
||||
m.material_category_code_path_name AS material_category_name
|
||||
FROM qms_quality_inspector qi
|
||||
LEFT JOIN qms_qc_material m ON m.material_category_code = qi.material_category_code
|
||||
WHERE qi.user_id = #{userId}
|
||||
AND qi.material_category_code IS NOT NULL
|
||||
AND qi.material_id IS NULL
|
||||
ORDER BY qi.material_category_code, qi.id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
u.user_name,
|
||||
u.user_code,
|
||||
p.name AS position_name,
|
||||
qssm.state,
|
||||
qssm.enable,
|
||||
qssm.create_by,
|
||||
qssm.create_time,
|
||||
qssm.update_by,
|
||||
|
|
|
|||
Loading…
Reference in New Issue