修改质检人员管理功能
This commit is contained in:
parent
83098677eb
commit
e3b86df482
|
|
@ -207,6 +207,29 @@
|
||||||
<artifactId>minio</artifactId>
|
<artifactId>minio</artifactId>
|
||||||
<version>8.5.17</version>
|
<version>8.5.17</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- ==================== OnlyOffice JWT ==================== -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-api</artifactId>
|
||||||
|
<version>0.12.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-impl</artifactId>
|
||||||
|
<version>0.12.6</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.jsonwebtoken</groupId>
|
||||||
|
<artifactId>jjwt-jackson</artifactId>
|
||||||
|
<version>0.12.6</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>software.amazon.awssdk</groupId>
|
||||||
|
<artifactId>s3</artifactId>
|
||||||
|
<version>2.39.5</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||||
public class QmsQualityInspectorCategoryVO {
|
public class QmsQualityInspectorCategoryVO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联记录ID(qms_quality_inspector.id)
|
* 关联记录ID(qms_inspector_material_category_item.id)
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
||||||
public class QmsQualityInspectorMaterialVO {
|
public class QmsQualityInspectorMaterialVO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关联记录ID(qms_quality_inspector.id)
|
* 关联记录ID(qms_inspector_material_item.id)
|
||||||
*/
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
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_inspector_material_category_item")
|
||||||
|
public class QmsInspectorMaterialCategoryItem implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 质检员ID (qms_quality_inspector.id)
|
||||||
|
*/
|
||||||
|
private Long inspectorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料类别ID (qms_qc_material_category.id)
|
||||||
|
*/
|
||||||
|
private Long materialCategoryId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
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_inspector_material_item")
|
||||||
|
public class QmsInspectorMaterialItem implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_ID)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 质检员ID (qms_quality_inspector.id)
|
||||||
|
*/
|
||||||
|
private Long inspectorId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物料ID (qms_qc_material.id)
|
||||||
|
*/
|
||||||
|
private Long materialId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改人
|
||||||
|
*/
|
||||||
|
private String updateBy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
}
|
||||||
|
|
@ -36,11 +36,6 @@ public class QmsQualityInspector implements Serializable {
|
||||||
*/
|
*/
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 物料ID (qms_qc_material.id),可为空
|
|
||||||
*/
|
|
||||||
private Long materialId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用状态:true=启用,false=禁用
|
* 启用状态:true=启用,false=禁用
|
||||||
*/
|
*/
|
||||||
|
|
@ -75,9 +70,4 @@ public class QmsQualityInspector implements Serializable {
|
||||||
* 修改时间
|
* 修改时间
|
||||||
*/
|
*/
|
||||||
private LocalDateTime updateTime;
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
/**
|
|
||||||
* 物料类别编码
|
|
||||||
*/
|
|
||||||
private String materialCategoryCode;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialCategoryItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 质检员物料类别明细 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface QmsInspectorMaterialCategoryItemMapper extends BaseMapper<QmsInspectorMaterialCategoryItem> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.repository.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 质检员物料明细 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface QmsInspectorMaterialItemMapper extends BaseMapper<QmsInspectorMaterialItem> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.repository.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialCategoryItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 质检员物料类别明细 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface IQmsInspectorMaterialCategoryItemService extends IService<QmsInspectorMaterialCategoryItem> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.repository.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialItem;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 质检员物料明细 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
public interface IQmsInspectorMaterialItemService extends IService<QmsInspectorMaterialItem> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.nflg.wms.repository.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialCategoryItem;
|
||||||
|
import com.nflg.wms.repository.mapper.QmsInspectorMaterialCategoryItemMapper;
|
||||||
|
import com.nflg.wms.repository.service.IQmsInspectorMaterialCategoryItemService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 质检员物料类别明细 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class QmsInspectorMaterialCategoryItemServiceImpl
|
||||||
|
extends ServiceImpl<QmsInspectorMaterialCategoryItemMapper, QmsInspectorMaterialCategoryItem>
|
||||||
|
implements IQmsInspectorMaterialCategoryItemService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.nflg.wms.repository.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialItem;
|
||||||
|
import com.nflg.wms.repository.mapper.QmsInspectorMaterialItemMapper;
|
||||||
|
import com.nflg.wms.repository.service.IQmsInspectorMaterialItemService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 质检员物料明细 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author 代码生成器生成
|
||||||
|
* @since 2025
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class QmsInspectorMaterialItemServiceImpl
|
||||||
|
extends ServiceImpl<QmsInspectorMaterialItemMapper, QmsInspectorMaterialItem>
|
||||||
|
implements IQmsInspectorMaterialItemService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -16,9 +16,15 @@ import com.nflg.wms.common.pojo.vo.QmsQualityInspectorDetailVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO;
|
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO;
|
||||||
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO;
|
import com.nflg.wms.common.pojo.vo.QmsQualityInspectorVO;
|
||||||
import com.nflg.wms.common.util.UserUtil;
|
import com.nflg.wms.common.util.UserUtil;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialCategoryItem;
|
||||||
|
import com.nflg.wms.repository.entity.QmsInspectorMaterialItem;
|
||||||
|
import com.nflg.wms.repository.entity.QmsQcMaterialCategory;
|
||||||
import com.nflg.wms.repository.entity.QmsQualityInspector;
|
import com.nflg.wms.repository.entity.QmsQualityInspector;
|
||||||
import com.nflg.wms.repository.entity.User;
|
import com.nflg.wms.repository.entity.User;
|
||||||
import com.nflg.wms.repository.mapper.QmsQualityInspectorMapper;
|
import com.nflg.wms.repository.mapper.QmsQualityInspectorMapper;
|
||||||
|
import com.nflg.wms.repository.service.IQmsInspectorMaterialCategoryItemService;
|
||||||
|
import com.nflg.wms.repository.service.IQmsInspectorMaterialItemService;
|
||||||
|
import com.nflg.wms.repository.service.IQmsQcMaterialCategoryService;
|
||||||
import com.nflg.wms.repository.service.IQmsQualityInspectorService;
|
import com.nflg.wms.repository.service.IQmsQualityInspectorService;
|
||||||
import com.nflg.wms.repository.service.IUserService;
|
import com.nflg.wms.repository.service.IUserService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
|
@ -29,8 +35,8 @@ import org.springframework.util.CollectionUtils;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -48,6 +54,31 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
@Resource
|
@Resource
|
||||||
private IUserService userService;
|
private IUserService userService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IQmsInspectorMaterialItemService materialItemService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IQmsInspectorMaterialCategoryItemService materialCategoryItemService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IQmsQcMaterialCategoryService qcMaterialCategoryService;
|
||||||
|
|
||||||
|
// ========================= 工具方法 =========================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按物料类别编码列表批量查询 id 映射(code -> id)
|
||||||
|
*/
|
||||||
|
private Map<String, Long> getCategoryCodeToIdMap(List<String> codes) {
|
||||||
|
if (CollectionUtils.isEmpty(codes)) {
|
||||||
|
return Map.of();
|
||||||
|
}
|
||||||
|
List<QmsQcMaterialCategory> categories = qcMaterialCategoryService.lambdaQuery()
|
||||||
|
.in(QmsQcMaterialCategory::getCategoryCode, codes)
|
||||||
|
.list();
|
||||||
|
return categories.stream()
|
||||||
|
.collect(Collectors.toMap(QmsQcMaterialCategory::getCategoryCode, QmsQcMaterialCategory::getId));
|
||||||
|
}
|
||||||
|
|
||||||
// ========================= 新增 =========================
|
// ========================= 新增 =========================
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
@ -55,99 +86,76 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
public void add(QmsQualityInspectorAddQO request) {
|
public void add(QmsQualityInspectorAddQO request) {
|
||||||
String operator = UserUtil.getUserName();
|
String operator = UserUtil.getUserName();
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
List<QmsQualityInspector> records = new ArrayList<>();
|
|
||||||
|
|
||||||
boolean hasMaterial = !CollectionUtils.isEmpty(request.getMaterialIds());
|
// 校验物料ID是否已被其他质检员绑定
|
||||||
boolean hasCategory = !CollectionUtils.isEmpty(request.getMaterialCategoryCodes());
|
if (!CollectionUtils.isEmpty(request.getMaterialIds())) {
|
||||||
|
List<QmsInspectorMaterialItem> conflictMaterials = materialItemService.lambdaQuery()
|
||||||
if (hasMaterial) {
|
.in(QmsInspectorMaterialItem::getMaterialId, request.getMaterialIds())
|
||||||
for (Long materialId : request.getMaterialIds()) {
|
.list();
|
||||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
if (!conflictMaterials.isEmpty()) {
|
||||||
materialId, null, operator, now));
|
throw new NflgException(STATE.BusinessError, "物料ID已被其他质检员绑定,不允许重复新增");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasCategory) {
|
|
||||||
for (String categoryCode : request.getMaterialCategoryCodes()) {
|
// 校验物料类别是否已被其他质检员绑定
|
||||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
if (!CollectionUtils.isEmpty(request.getMaterialCategoryCodes())) {
|
||||||
null, categoryCode, operator, now));
|
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getMaterialCategoryCodes());
|
||||||
|
List<Long> categoryIds = new ArrayList<>(codeToIdMap.values());
|
||||||
|
if (!categoryIds.isEmpty()) {
|
||||||
|
List<QmsInspectorMaterialCategoryItem> conflictCategories = materialCategoryItemService.lambdaQuery()
|
||||||
|
.in(QmsInspectorMaterialCategoryItem::getMaterialCategoryId, categoryIds)
|
||||||
|
.list();
|
||||||
|
if (!conflictCategories.isEmpty()) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "物料类别已被其他质检员绑定,不允许重复新增");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 物料id和物料类别都不传时,插入一条无物料关联的记录
|
|
||||||
if (!hasMaterial && !hasCategory) {
|
|
||||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
|
||||||
null, null, operator, now));
|
|
||||||
}
|
|
||||||
|
|
||||||
saveBatch(records);
|
// 插入主表
|
||||||
}
|
QmsQualityInspector inspector = new QmsQualityInspector()
|
||||||
|
.setUserId(request.getUserId())
|
||||||
private QmsQualityInspector buildRecord(Long userId, Integer inspectionType,
|
.setInspectionType(request.getInspectionType())
|
||||||
Long materialId, String categoryCode,
|
|
||||||
String operator, LocalDateTime now) {
|
|
||||||
return new QmsQualityInspector()
|
|
||||||
.setUserId(userId)
|
|
||||||
.setInspectionType(inspectionType)
|
|
||||||
.setMaterialId(materialId)
|
|
||||||
.setMaterialCategoryCode(categoryCode)
|
|
||||||
.setEnable(true)
|
.setEnable(true)
|
||||||
.setCreateBy(operator)
|
.setCreateBy(operator)
|
||||||
.setCreateTime(now)
|
.setCreateTime(now)
|
||||||
.setUpdateBy(operator)
|
.setUpdateBy(operator)
|
||||||
.setUpdateTime(now);
|
.setUpdateTime(now);
|
||||||
}
|
save(inspector);
|
||||||
|
Long inspectorId = inspector.getId();
|
||||||
|
|
||||||
/**
|
// 批量插入物料明细
|
||||||
* 删除物料/物料类别关联行。
|
if (!CollectionUtils.isEmpty(request.getMaterialIds())) {
|
||||||
* 若删除后该 userId 下记录数归零,则保留其中一条(清空 materialId 和 materialCategoryCode),
|
List<QmsInspectorMaterialItem> materialItems = request.getMaterialIds().stream()
|
||||||
* 不做物理删除,确保人员记录始终存在。
|
.map(materialId -> new QmsInspectorMaterialItem()
|
||||||
*/
|
.setInspectorId(inspectorId)
|
||||||
private void removeMaterialOrClear(Long userId, List<QmsQualityInspector> toRemove,
|
.setMaterialId(materialId)
|
||||||
String operator, LocalDateTime now) {
|
.setCreateBy(operator)
|
||||||
if (CollectionUtils.isEmpty(toRemove)) {
|
.setCreateTime(now)
|
||||||
return;
|
.setUpdateBy(operator)
|
||||||
|
.setUpdateTime(now))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
materialItemService.saveBatch(materialItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 该用户当前全部记录
|
// 批量插入物料类别明细(按编码查 ID)
|
||||||
List<QmsQualityInspector> all = lambdaQuery()
|
if (!CollectionUtils.isEmpty(request.getMaterialCategoryCodes())) {
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getMaterialCategoryCodes());
|
||||||
.list();
|
List<QmsInspectorMaterialCategoryItem> categoryItems = new ArrayList<>();
|
||||||
long total = all.size();
|
for (String code : request.getMaterialCategoryCodes()) {
|
||||||
|
Long categoryId = codeToIdMap.get(code);
|
||||||
// 待删除的行 ID 集合
|
if (Objects.nonNull(categoryId)) {
|
||||||
Set<Long> removeIdSet = toRemove.stream()
|
categoryItems.add(new QmsInspectorMaterialCategoryItem()
|
||||||
.map(QmsQualityInspector::getId)
|
.setInspectorId(inspectorId)
|
||||||
.collect(Collectors.toSet());
|
.setMaterialCategoryId(categoryId)
|
||||||
|
.setCreateBy(operator)
|
||||||
// 删除后剩余条数
|
.setCreateTime(now)
|
||||||
long remaining = total - removeIdSet.size();
|
.setUpdateBy(operator)
|
||||||
|
.setUpdateTime(now));
|
||||||
if (remaining <= 0) {
|
}
|
||||||
// 删完后一条不剩:从所有记录中选一条保留(优先选不在 toRemove 中的,没有则从 toRemove 中选第一条)
|
}
|
||||||
QmsQualityInspector keep = all.stream()
|
if (!categoryItems.isEmpty()) {
|
||||||
.filter(r -> !removeIdSet.contains(r.getId()))
|
materialCategoryItemService.saveBatch(categoryItems);
|
||||||
.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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -156,21 +164,27 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void delete(Long userId) {
|
public void delete(Long userId) {
|
||||||
// 查询该用户是否存在记录
|
// 查询主表记录
|
||||||
List<QmsQualityInspector> records = lambdaQuery()
|
QmsQualityInspector inspector = lambdaQuery()
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
.eq(QmsQualityInspector::getUserId, userId)
|
||||||
.list();
|
.one();
|
||||||
if (records.isEmpty()) {
|
if (Objects.isNull(inspector)) {
|
||||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||||
}
|
}
|
||||||
// 启用状态下不允许删除
|
// 启用状态下不允许删除
|
||||||
boolean enabled = records.stream().anyMatch(r -> Boolean.TRUE.equals(r.getEnable()));
|
if (Boolean.TRUE.equals(inspector.getEnable())) {
|
||||||
if (enabled) {
|
|
||||||
throw new NflgException(STATE.BusinessError, "该质检人员处于启用状态,不允许删除,请先禁用后再删除");
|
throw new NflgException(STATE.BusinessError, "该质检人员处于启用状态,不允许删除,请先禁用后再删除");
|
||||||
}
|
}
|
||||||
// 删除该用户所有记录
|
Long inspectorId = inspector.getId();
|
||||||
List<Long> ids = records.stream().map(QmsQualityInspector::getId).collect(Collectors.toList());
|
// 删除两张明细表
|
||||||
removeByIds(ids);
|
materialItemService.lambdaUpdate()
|
||||||
|
.eq(QmsInspectorMaterialItem::getInspectorId, inspectorId)
|
||||||
|
.remove();
|
||||||
|
materialCategoryItemService.lambdaUpdate()
|
||||||
|
.eq(QmsInspectorMaterialCategoryItem::getInspectorId, inspectorId)
|
||||||
|
.remove();
|
||||||
|
// 删除主表
|
||||||
|
removeById(inspectorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================= 修改物料/物料类别 =========================
|
// ========================= 修改物料/物料类别 =========================
|
||||||
|
|
@ -182,49 +196,68 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
LocalDateTime now = LocalDateTime.now();
|
LocalDateTime now = LocalDateTime.now();
|
||||||
Long userId = request.getUserId();
|
Long userId = request.getUserId();
|
||||||
|
|
||||||
// 查询当前该质检人的任意一条记录,取 inspectionType(同一人 inspectionType 相同)
|
// 查主表,获取 inspectorId
|
||||||
QmsQualityInspector any = lambdaQuery()
|
QmsQualityInspector inspector = lambdaQuery()
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
.eq(QmsQualityInspector::getUserId, userId)
|
||||||
.last("LIMIT 1")
|
|
||||||
.one();
|
.one();
|
||||||
if (Objects.isNull(any)) {
|
if (Objects.isNull(inspector)) {
|
||||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||||
}
|
}
|
||||||
Integer inspectionType = any.getInspectionType();
|
Long inspectorId = inspector.getId();
|
||||||
|
|
||||||
// 追加物料
|
// 追加物料
|
||||||
if (!CollectionUtils.isEmpty(request.getAddMaterialIds())) {
|
if (!CollectionUtils.isEmpty(request.getAddMaterialIds())) {
|
||||||
List<QmsQualityInspector> toAdd = request.getAddMaterialIds().stream()
|
List<QmsInspectorMaterialItem> toAdd = request.getAddMaterialIds().stream()
|
||||||
.map(materialId -> buildRecord(userId, inspectionType, materialId, null, operator, now))
|
.map(materialId -> new QmsInspectorMaterialItem()
|
||||||
|
.setInspectorId(inspectorId)
|
||||||
|
.setMaterialId(materialId)
|
||||||
|
.setCreateBy(operator)
|
||||||
|
.setCreateTime(now)
|
||||||
|
.setUpdateBy(operator)
|
||||||
|
.setUpdateTime(now))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
saveBatch(toAdd);
|
materialItemService.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())) {
|
if (!CollectionUtils.isEmpty(request.getRemoveMaterialIds())) {
|
||||||
toRemove.addAll(lambdaQuery()
|
materialItemService.lambdaUpdate()
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
.eq(QmsInspectorMaterialItem::getInspectorId, inspectorId)
|
||||||
.in(QmsQualityInspector::getMaterialId, request.getRemoveMaterialIds())
|
.in(QmsInspectorMaterialItem::getMaterialId, request.getRemoveMaterialIds())
|
||||||
.list());
|
.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 追加物料类别(按编码查 ID)
|
||||||
|
if (!CollectionUtils.isEmpty(request.getAddMaterialCategoryCodes())) {
|
||||||
|
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getAddMaterialCategoryCodes());
|
||||||
|
List<QmsInspectorMaterialCategoryItem> toAdd = new ArrayList<>();
|
||||||
|
for (String code : request.getAddMaterialCategoryCodes()) {
|
||||||
|
Long categoryId = codeToIdMap.get(code);
|
||||||
|
if (Objects.nonNull(categoryId)) {
|
||||||
|
toAdd.add(new QmsInspectorMaterialCategoryItem()
|
||||||
|
.setInspectorId(inspectorId)
|
||||||
|
.setMaterialCategoryId(categoryId)
|
||||||
|
.setCreateBy(operator)
|
||||||
|
.setCreateTime(now)
|
||||||
|
.setUpdateBy(operator)
|
||||||
|
.setUpdateTime(now));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!toAdd.isEmpty()) {
|
||||||
|
materialCategoryItemService.saveBatch(toAdd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除物料类别(按编码查 ID)
|
||||||
if (!CollectionUtils.isEmpty(request.getRemoveMaterialCategoryCodes())) {
|
if (!CollectionUtils.isEmpty(request.getRemoveMaterialCategoryCodes())) {
|
||||||
toRemove.addAll(lambdaQuery()
|
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getRemoveMaterialCategoryCodes());
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
List<Long> removeIds = new ArrayList<>(codeToIdMap.values());
|
||||||
.in(QmsQualityInspector::getMaterialCategoryCode, request.getRemoveMaterialCategoryCodes())
|
if (!removeIds.isEmpty()) {
|
||||||
.list());
|
materialCategoryItemService.lambdaUpdate()
|
||||||
}
|
.eq(QmsInspectorMaterialCategoryItem::getInspectorId, inspectorId)
|
||||||
if (!toRemove.isEmpty()) {
|
.in(QmsInspectorMaterialCategoryItem::getMaterialCategoryId, removeIds)
|
||||||
removeMaterialOrClear(userId, toRemove, operator, now);
|
.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -237,12 +270,11 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QmsQualityInspectorDetailVO getDetailByUserId(Long userId) {
|
public QmsQualityInspectorDetailVO getDetailByUserId(Long userId) {
|
||||||
// 查询该用户的任意一条记录(取 inspectionType/enable)
|
// 查主表
|
||||||
QmsQualityInspector first = lambdaQuery()
|
QmsQualityInspector inspector = lambdaQuery()
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
.eq(QmsQualityInspector::getUserId, userId)
|
||||||
.last("LIMIT 1")
|
|
||||||
.one();
|
.one();
|
||||||
if (Objects.isNull(first)) {
|
if (Objects.isNull(inspector)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,13 +283,12 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
|
|
||||||
QmsQualityInspectorDetailVO detail = new QmsQualityInspectorDetailVO();
|
QmsQualityInspectorDetailVO detail = new QmsQualityInspectorDetailVO();
|
||||||
detail.setUserId(userId);
|
detail.setUserId(userId);
|
||||||
detail.setInspectionType(first.getInspectionType());
|
detail.setInspectionType(inspector.getInspectionType());
|
||||||
detail.setEnable(first.getEnable());
|
detail.setEnable(inspector.getEnable());
|
||||||
if (Objects.nonNull(user)) {
|
if (Objects.nonNull(user)) {
|
||||||
detail.setUserCode(user.getUserCode());
|
detail.setUserCode(user.getUserCode());
|
||||||
detail.setUserName(user.getUserName());
|
detail.setUserName(user.getUserName());
|
||||||
}
|
}
|
||||||
// 部门领导暂不填充,字段预留
|
|
||||||
detail.setDeptLeaderName(null);
|
detail.setDeptLeaderName(null);
|
||||||
|
|
||||||
// 查物料列表
|
// 查物料列表
|
||||||
|
|
@ -273,6 +304,77 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void updateStatus(Long userId, Boolean enable) {
|
public void updateStatus(Long userId, Boolean enable) {
|
||||||
|
// 仅在改为启用时做校验
|
||||||
|
if (Boolean.TRUE.equals(enable)) {
|
||||||
|
QmsQualityInspector inspector = lambdaQuery()
|
||||||
|
.eq(QmsQualityInspector::getUserId, userId)
|
||||||
|
.one();
|
||||||
|
if (Objects.isNull(inspector)) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||||
|
}
|
||||||
|
Long inspectorId = inspector.getId();
|
||||||
|
|
||||||
|
// 查当前人员绑定的物料ID列表
|
||||||
|
List<QmsInspectorMaterialItem> myMaterials = materialItemService.lambdaQuery()
|
||||||
|
.eq(QmsInspectorMaterialItem::getInspectorId, inspectorId)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
// 查当前人员绑定的物料类别ID列表
|
||||||
|
List<QmsInspectorMaterialCategoryItem> myCategories = materialCategoryItemService.lambdaQuery()
|
||||||
|
.eq(QmsInspectorMaterialCategoryItem::getInspectorId, inspectorId)
|
||||||
|
.list();
|
||||||
|
|
||||||
|
// 校验物料是否已被其他启用的质检员接管
|
||||||
|
if (!myMaterials.isEmpty()) {
|
||||||
|
List<Long> myMaterialIds = myMaterials.stream()
|
||||||
|
.map(QmsInspectorMaterialItem::getMaterialId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
// 查其他人员中是否有相同物料绑定(排除自己)
|
||||||
|
List<QmsInspectorMaterialItem> conflictItems = materialItemService.lambdaQuery()
|
||||||
|
.in(QmsInspectorMaterialItem::getMaterialId, myMaterialIds)
|
||||||
|
.ne(QmsInspectorMaterialItem::getInspectorId, inspectorId)
|
||||||
|
.list();
|
||||||
|
if (!conflictItems.isEmpty()) {
|
||||||
|
// 进一步判断接管人员是否处于启用状态
|
||||||
|
List<Long> conflictInspectorIds = conflictItems.stream()
|
||||||
|
.map(QmsInspectorMaterialItem::getInspectorId)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
long enabledCount = lambdaQuery()
|
||||||
|
.in(QmsQualityInspector::getId, conflictInspectorIds)
|
||||||
|
.eq(QmsQualityInspector::getEnable, true)
|
||||||
|
.count();
|
||||||
|
if (enabledCount > 0) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "该质检员的部分物料已被其他启用的质检员接管,不允许启用");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 校验物料类别是否已被其他启用的质检员接管
|
||||||
|
if (!myCategories.isEmpty()) {
|
||||||
|
List<Long> myCategoryIds = myCategories.stream()
|
||||||
|
.map(QmsInspectorMaterialCategoryItem::getMaterialCategoryId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
List<QmsInspectorMaterialCategoryItem> conflictItems = materialCategoryItemService.lambdaQuery()
|
||||||
|
.in(QmsInspectorMaterialCategoryItem::getMaterialCategoryId, myCategoryIds)
|
||||||
|
.ne(QmsInspectorMaterialCategoryItem::getInspectorId, inspectorId)
|
||||||
|
.list();
|
||||||
|
if (!conflictItems.isEmpty()) {
|
||||||
|
List<Long> conflictInspectorIds = conflictItems.stream()
|
||||||
|
.map(QmsInspectorMaterialCategoryItem::getInspectorId)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
long enabledCount = lambdaQuery()
|
||||||
|
.in(QmsQualityInspector::getId, conflictInspectorIds)
|
||||||
|
.eq(QmsQualityInspector::getEnable, true)
|
||||||
|
.count();
|
||||||
|
if (enabledCount > 0) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "该质检员的部分物料类别已被其他启用的质检员接管,不允许启用");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lambdaUpdate()
|
lambdaUpdate()
|
||||||
.eq(QmsQualityInspector::getUserId, userId)
|
.eq(QmsQualityInspector::getUserId, userId)
|
||||||
.set(QmsQualityInspector::getEnable, enable)
|
.set(QmsQualityInspector::getEnable, enable)
|
||||||
|
|
@ -308,11 +410,13 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageData<QmsQualityInspectorMaterialVO> getMaterialsByUserId(String materialNo, String materialCategoryCode, String materialDesc, Integer pageNum, Integer pageSize) {
|
public PageData<QmsQualityInspectorMaterialVO> getMaterialsByUserId(String materialNo, String materialCategoryCode,
|
||||||
|
String materialDesc, Integer pageNum, Integer pageSize) {
|
||||||
Long userId = UserUtil.getUserId();
|
Long userId = UserUtil.getUserId();
|
||||||
Page<QmsQualityInspectorMaterialVO> page = new Page<>(pageNum, pageSize);
|
Page<QmsQualityInspectorMaterialVO> page = new Page<>(pageNum, pageSize);
|
||||||
IPage<QmsQualityInspectorMaterialVO> result = baseMapper.getMaterialsByUserIdWithFilter(page, userId, materialNo, materialCategoryCode, materialDesc);
|
IPage<QmsQualityInspectorMaterialVO> result = baseMapper.getMaterialsByUserIdWithFilter(
|
||||||
|
page, userId, materialNo, materialCategoryCode, materialDesc);
|
||||||
|
|
||||||
return new PageData<QmsQualityInspectorMaterialVO>()
|
return new PageData<QmsQualityInspectorMaterialVO>()
|
||||||
.setPage((int) result.getCurrent())
|
.setPage((int) result.getCurrent())
|
||||||
.setPageSize((int) result.getSize())
|
.setPageSize((int) result.getSize())
|
||||||
|
|
|
||||||
|
|
@ -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.QmsInspectorMaterialCategoryItemMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -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.QmsInspectorMaterialItemMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
<mapper namespace="com.nflg.wms.repository.mapper.QmsQualityInspectorMapper">
|
<mapper namespace="com.nflg.wms.repository.mapper.QmsQualityInspectorMapper">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
分页查询:以质检人为主体,每个 user_id 只返回一条记录
|
分页查询:以质检人为主体,每个 user_id 只返回一条记录(主表一人一条)
|
||||||
使用 DISTINCT ON (qi.user_id) 保证每人唯一
|
|
||||||
JOIN user_interior/department 获取部门信息
|
JOIN user_interior/department 获取部门信息
|
||||||
JOIN user AS cu 获取转办人姓名
|
JOIN user AS cu 获取转办人姓名
|
||||||
支持动态过滤:员工工号(userCode)、人员名称模糊(userName)、物料编号(materialNo)
|
支持动态过滤:员工工号(userCode)、人员名称模糊(userName)、物料编号(materialNo)
|
||||||
|
|
@ -27,11 +26,7 @@
|
||||||
qi.create_time,
|
qi.create_time,
|
||||||
qi.update_by,
|
qi.update_by,
|
||||||
qi.update_time
|
qi.update_time
|
||||||
FROM (
|
FROM qms_quality_inspector qi
|
||||||
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" u ON u.id = qi.user_id
|
||||||
LEFT JOIN user_interior ui ON ui.user_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 department d ON d.id = ui.dept_id
|
||||||
|
|
@ -45,9 +40,10 @@
|
||||||
</if>
|
</if>
|
||||||
<if test="request.materialNo != null and request.materialNo != ''">
|
<if test="request.materialNo != null and request.materialNo != ''">
|
||||||
AND EXISTS (
|
AND EXISTS (
|
||||||
SELECT 1 FROM qms_quality_inspector qi2
|
SELECT 1
|
||||||
LEFT JOIN qms_qc_material m ON m.id = qi2.material_id
|
FROM qms_inspector_material_item imi
|
||||||
WHERE qi2.user_id = qi.user_id
|
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||||
|
WHERE imi.inspector_id = qi.id
|
||||||
AND m.material_no ilike concat('%', #{request.materialNo}, '%')
|
AND m.material_no ilike concat('%', #{request.materialNo}, '%')
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -58,8 +54,8 @@
|
||||||
<!-- 按 userId 查询关联物料列表(JOIN qms_qc_material 获取物料详情) -->
|
<!-- 按 userId 查询关联物料列表(JOIN qms_qc_material 获取物料详情) -->
|
||||||
<select id="getMaterialsByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
<select id="getMaterialsByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||||
SELECT
|
SELECT
|
||||||
qi.id,
|
imi.id,
|
||||||
qi.material_id,
|
imi.material_id,
|
||||||
m.material_no,
|
m.material_no,
|
||||||
m.material_category_code,
|
m.material_category_code,
|
||||||
m.material_category_code_path_name AS material_category_name,
|
m.material_category_code_path_name AS material_category_name,
|
||||||
|
|
@ -67,18 +63,19 @@
|
||||||
m.material_specifications,
|
m.material_specifications,
|
||||||
m.material_texture,
|
m.material_texture,
|
||||||
m.is_standard_maintained AS material_status
|
m.is_standard_maintained AS material_status
|
||||||
FROM qms_quality_inspector qi
|
FROM qms_inspector_material_item imi
|
||||||
LEFT JOIN qms_qc_material m ON m.id = qi.material_id
|
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||||
WHERE qi.user_id = #{userId}
|
WHERE imi.inspector_id = (
|
||||||
AND qi.material_id IS NOT NULL
|
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||||
ORDER BY qi.id ASC
|
)
|
||||||
|
ORDER BY imi.id ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 按 userId 查询关联物料列表(支持供应商过滤) -->
|
<!-- 按 userId 查询关联物料列表(支持供应商过滤) -->
|
||||||
<select id="getMaterialsByUserIdWithSupplier" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
<select id="getMaterialsByUserIdWithSupplier" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||||
SELECT
|
SELECT
|
||||||
qi.id,
|
imi.id,
|
||||||
qi.material_id,
|
imi.material_id,
|
||||||
m.material_no,
|
m.material_no,
|
||||||
m.material_category_code,
|
m.material_category_code,
|
||||||
m.material_category_code_path_name AS material_category_name,
|
m.material_category_code_path_name AS material_category_name,
|
||||||
|
|
@ -86,29 +83,30 @@
|
||||||
m.material_specifications,
|
m.material_specifications,
|
||||||
m.material_texture,
|
m.material_texture,
|
||||||
m.is_standard_maintained AS material_status
|
m.is_standard_maintained AS material_status
|
||||||
FROM qms_quality_inspector qi
|
FROM qms_inspector_material_item imi
|
||||||
LEFT JOIN qms_qc_material m ON m.id = qi.material_id
|
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||||
LEFT JOIN qms_coa_review cr ON cr.material_id = m.id
|
LEFT JOIN qms_coa_review cr ON cr.material_id = m.id
|
||||||
LEFT JOIN user_supplier us ON us.id = cr.supplier_id
|
LEFT JOIN user_supplier us ON us.id = cr.supplier_id
|
||||||
WHERE qi.user_id = #{userId}
|
WHERE imi.inspector_id = (
|
||||||
AND qi.material_id IS NOT NULL
|
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||||
|
)
|
||||||
<if test="supplierCode != null and supplierCode != ''">
|
<if test="supplierCode != null and supplierCode != ''">
|
||||||
AND us.supplier_code = #{supplierCode}
|
AND us.supplier_code = #{supplierCode}
|
||||||
</if>
|
</if>
|
||||||
<if test="supplierName != null and supplierName != ''">
|
<if test="supplierName != null and supplierName != ''">
|
||||||
AND us.supplier_name LIKE CONCAT('%', #{supplierName}, '%')
|
AND us.supplier_name LIKE CONCAT('%', #{supplierName}, '%')
|
||||||
</if>
|
</if>
|
||||||
GROUP BY qi.id, qi.material_id, m.material_no, m.material_category_code,
|
GROUP BY imi.id, imi.material_id, m.material_no, m.material_category_code,
|
||||||
m.material_category_code_path_name, m.material_desc,
|
m.material_category_code_path_name, m.material_desc,
|
||||||
m.material_specifications, m.material_texture, m.is_standard_maintained
|
m.material_specifications, m.material_texture, m.is_standard_maintained
|
||||||
ORDER BY qi.id ASC
|
ORDER BY imi.id ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 按 userId 查询绑定物料列表(支持物料编号/类别/描述过滤) -->
|
<!-- 按 userId 查询绑定物料列表(支持物料编号/类别/描述过滤) -->
|
||||||
<select id="getMaterialsByUserIdWithFilter" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
<select id="getMaterialsByUserIdWithFilter" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||||
SELECT
|
SELECT
|
||||||
qi.id,
|
imi.id,
|
||||||
qi.material_id,
|
imi.material_id,
|
||||||
m.material_no,
|
m.material_no,
|
||||||
m.drawing_no,
|
m.drawing_no,
|
||||||
m.drawing_no_ver,
|
m.drawing_no_ver,
|
||||||
|
|
@ -118,10 +116,11 @@
|
||||||
m.material_specifications,
|
m.material_specifications,
|
||||||
m.material_texture,
|
m.material_texture,
|
||||||
m.is_standard_maintained AS material_status
|
m.is_standard_maintained AS material_status
|
||||||
FROM qms_quality_inspector qi
|
FROM qms_inspector_material_item imi
|
||||||
LEFT JOIN qms_qc_material m ON m.id = qi.material_id
|
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||||
WHERE qi.user_id = #{userId}
|
WHERE imi.inspector_id = (
|
||||||
AND qi.material_id IS NOT NULL
|
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||||
|
)
|
||||||
<if test="materialNo != null and materialNo != ''">
|
<if test="materialNo != null and materialNo != ''">
|
||||||
AND m.material_no = #{materialNo}
|
AND m.material_no = #{materialNo}
|
||||||
</if>
|
</if>
|
||||||
|
|
@ -131,21 +130,21 @@
|
||||||
<if test="materialDesc != null and materialDesc != ''">
|
<if test="materialDesc != null and materialDesc != ''">
|
||||||
AND m.material_desc LIKE CONCAT('%', #{materialDesc}, '%')
|
AND m.material_desc LIKE CONCAT('%', #{materialDesc}, '%')
|
||||||
</if>
|
</if>
|
||||||
ORDER BY qi.id ASC
|
ORDER BY imi.id ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 按 userId 查询关联物料类别列表(JOIN qms_qc_material 取类别名称) -->
|
<!-- 按 userId 查询关联物料类别列表(JOIN qms_qc_material_category 取类别信息) -->
|
||||||
<select id="getCategoriesByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorCategoryVO">
|
<select id="getCategoriesByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorCategoryVO">
|
||||||
SELECT DISTINCT ON (qi.material_category_code)
|
SELECT
|
||||||
qi.id,
|
imci.id,
|
||||||
qi.material_category_code,
|
mc.category_code AS material_category_code,
|
||||||
m.material_category_code_path_name AS material_category_name
|
mc.category_name AS material_category_name
|
||||||
FROM qms_quality_inspector qi
|
FROM qms_inspector_material_category_item imci
|
||||||
LEFT JOIN qms_qc_material m ON m.material_category_code = qi.material_category_code
|
LEFT JOIN qms_qc_material_category mc ON mc.id = imci.material_category_id
|
||||||
WHERE qi.user_id = #{userId}
|
WHERE imci.inspector_id = (
|
||||||
AND qi.material_category_code IS NOT NULL
|
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||||
AND qi.material_id IS NULL
|
)
|
||||||
ORDER BY qi.material_category_code, qi.id ASC
|
ORDER BY imci.id ASC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue