Merge remote-tracking branch '惠信/qms/develop' into qms/develop
# Conflicts: # nflg-qms-admin/src/main/java/com/nflg/qms/admin/service/QmsInspectionStandardControllerService.java
This commit is contained in:
commit
54a6056231
|
|
@ -213,6 +213,29 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</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>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.nflg.qms.admin.controller;
|
||||
|
||||
import com.nflg.qms.admin.service.BasdeSerialNumberControllerService;
|
||||
import com.nflg.qms.admin.service.ISendMessageService;
|
||||
import com.nflg.wms.common.pojo.ApiResult;
|
||||
import com.nflg.wms.common.pojo.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.QmsCoaTaskAddQO;
|
||||
|
|
@ -9,7 +11,13 @@ import com.nflg.wms.common.pojo.qo.QmsCoaTaskUpdateQO;
|
|||
import com.nflg.wms.common.pojo.vo.QmsCoaTaskDetailVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsCoaTaskMaterialVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsCoaTaskVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.common.util.VUtil;
|
||||
import com.nflg.wms.repository.entity.QmsCoaTask;
|
||||
import com.nflg.wms.repository.entity.QmsTodoItem;
|
||||
import com.nflg.wms.repository.service.IDictionaryItemService;
|
||||
import com.nflg.wms.repository.service.IQmsCoaTaskService;
|
||||
import com.nflg.wms.repository.service.IQmsTodoItemService;
|
||||
import com.nflg.wms.starter.BaseController;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
|
@ -18,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* COA通知管理
|
||||
|
|
@ -29,6 +38,18 @@ public class QmsCoaTaskController extends BaseController {
|
|||
@Resource
|
||||
private IQmsCoaTaskService coaTaskService;
|
||||
|
||||
@Resource
|
||||
private List<ISendMessageService> sendMessageServices;
|
||||
|
||||
@Resource
|
||||
private IQmsTodoItemService todoItemService;
|
||||
|
||||
@Resource
|
||||
private BasdeSerialNumberControllerService basdeSerialNumberControllerService;
|
||||
|
||||
@Resource
|
||||
private IDictionaryItemService dictionaryItemService;
|
||||
|
||||
/**
|
||||
* 新增COA通知任务
|
||||
* 状态默认为0(待发送)
|
||||
|
|
@ -69,11 +90,23 @@ public class QmsCoaTaskController extends BaseController {
|
|||
@PostMapping("publish")
|
||||
public ApiResult<Void> publish(@Valid @RequestBody QmsCoaTaskAddQO qo) {
|
||||
coaTaskService.publish(qo);
|
||||
Long dictionaryItemServiceId = dictionaryItemService.getId("消息类型", "COANotificationSent");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItemServiceId)).throwMessage("消息类型不存在");
|
||||
// 推送COA通知
|
||||
QmsTodoItem qmsTodoItem = new QmsTodoItem()
|
||||
.setCode(basdeSerialNumberControllerService.generateSerialNumber(32))
|
||||
.setIsRead(false)
|
||||
.setSourceTypeId(dictionaryItemServiceId)
|
||||
.setSourceId(coaTaskService.lambdaQuery().eq(QmsCoaTask::getMaterialId,qo.getMaterialNo()).one().getId())
|
||||
.setCreateUserId(UserUtil.getUserId())
|
||||
.setCreateUserName(UserUtil.getUserName())
|
||||
.setCreateTime(java.time.LocalDateTime.now());
|
||||
todoItemService.save(qmsTodoItem);
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量发送(状态改为1(已发送),填入发送时间)
|
||||
* 批量发送(状态改为1(已发送),填入发送时间,每条任务单独推送一条待办消息)
|
||||
*
|
||||
* @param ids 任务ID列表
|
||||
*/
|
||||
|
|
@ -81,6 +114,23 @@ public class QmsCoaTaskController extends BaseController {
|
|||
@PostMapping("send")
|
||||
public ApiResult<Void> send(@RequestBody List<Long> ids) {
|
||||
coaTaskService.send(ids);
|
||||
Long dictionaryItemServiceId = dictionaryItemService.getId("消息类型", "COANotificationSent");
|
||||
VUtil.trueThrowBusinessError(Objects.isNull(dictionaryItemServiceId)).throwMessage("消息类型不存在");
|
||||
Long currentUserId = UserUtil.getUserId();
|
||||
String currentUserName = UserUtil.getUserName();
|
||||
java.time.LocalDateTime now = java.time.LocalDateTime.now();
|
||||
// 每个任务ID单独推送一条待办消息
|
||||
for (Long taskId : ids) {
|
||||
QmsTodoItem qmsTodoItem = new QmsTodoItem()
|
||||
.setCode(basdeSerialNumberControllerService.generateSerialNumber(32))
|
||||
.setIsRead(false)
|
||||
.setSourceTypeId(dictionaryItemServiceId)
|
||||
.setSourceId(taskId)
|
||||
.setCreateUserId(currentUserId)
|
||||
.setCreateUserName(currentUserName)
|
||||
.setCreateTime(now);
|
||||
todoItemService.save(qmsTodoItem);
|
||||
}
|
||||
return ApiResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public class QmsQualityInspectorController extends BaseController {
|
|||
/**
|
||||
* 按员工ID查询质检人员详情(物料和物料类别分开返回,不分页)
|
||||
*
|
||||
* @param userId 员工ID
|
||||
* @param userId 员工ID(user.id)
|
||||
*/
|
||||
@GetMapping("detail")
|
||||
public ApiResult<QmsQualityInspectorDetailVO> detail(@NotNull Long userId) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class QmsSupplierSqeController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 设置用户(为选中供应商绑定用户,多对多,以供应商为主体)
|
||||
* 设置用户(为选中供应商全量替换负责人,以供应商为主体)
|
||||
*/
|
||||
@Transactional
|
||||
@PostMapping("setUser")
|
||||
|
|
|
|||
|
|
@ -9,10 +9,15 @@ import lombok.Data;
|
|||
public class QmsQualityInspectorCategoryVO {
|
||||
|
||||
/**
|
||||
* 关联记录ID(qms_quality_inspector.id)
|
||||
* 关联记录ID(qms_inspector_material_category_item.id)
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 物料类别ID(qms_qc_material_category.id)
|
||||
*/
|
||||
private Long materialCategoryId;
|
||||
|
||||
/**
|
||||
* 物料类别编码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,8 @@ import lombok.Data;
|
|||
public class QmsQualityInspectorMaterialVO {
|
||||
|
||||
/**
|
||||
* 关联记录ID(qms_quality_inspector.id)
|
||||
* 关联记录ID(qms_inspector_material_item.id)
|
||||
.id)
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,62 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 供应商-用户 关联平铺 VO(每行一条关联记录,供 Service 层聚合用)
|
||||
*/
|
||||
@Data
|
||||
public class QmsSupplierSqeMapFlatVO {
|
||||
|
||||
/**
|
||||
* 供应商ID
|
||||
*/
|
||||
private Long supplierId;
|
||||
|
||||
/**
|
||||
* 供应商编号
|
||||
*/
|
||||
private String supplierCode;
|
||||
|
||||
/**
|
||||
* 供应商名称
|
||||
*/
|
||||
private String supplierName;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Boolean enable;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 修改人
|
||||
*/
|
||||
private String updateBy;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.nflg.wms.common.pojo.vo;
|
|||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 供应商-用户 关联 VO(按供应商聚合,每行一个供应商)
|
||||
|
|
@ -26,9 +27,9 @@ public class QmsSupplierSqeMapVO {
|
|||
private String supplierName;
|
||||
|
||||
/**
|
||||
* SQE用户名称(多个用逗号分隔)
|
||||
* 关联的SQE用户列表(含 userId 和 userName)
|
||||
*/
|
||||
private String userName;
|
||||
private List<QmsSupplierSqeUserVO> users;
|
||||
|
||||
/**
|
||||
* 统一启用状态:所有关联记录均启用时为true,否则为false
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
package com.nflg.wms.common.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* SQE用户简要信息(用于 QmsSupplierSqeMapVO 中的 users 列表)
|
||||
*/
|
||||
@Data
|
||||
public class QmsSupplierSqeUserVO {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
/**
|
||||
* 物料ID (qms_qc_material.id),可为空
|
||||
*/
|
||||
private Long materialId;
|
||||
|
||||
/**
|
||||
* 启用状态:true=启用,false=禁用
|
||||
*/
|
||||
|
|
@ -75,9 +70,4 @@ public class QmsQualityInspector implements Serializable {
|
|||
* 修改时间
|
||||
*/
|
||||
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> {
|
||||
|
||||
}
|
||||
|
|
@ -54,4 +54,14 @@ public interface QmsQualityInspectorMapper extends BaseMapper<QmsQualityInspecto
|
|||
* 按 userId 查询关联物料类别列表
|
||||
*/
|
||||
List<QmsQualityInspectorCategoryVO> getCategoriesByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 按 userId(明细表 inspector_id 存的是 user.id)查询关联物料列表
|
||||
*/
|
||||
List<QmsQualityInspectorMaterialVO> getMaterialsByInspectorId(@Param("inspectorId") Long inspectorId);
|
||||
|
||||
/**
|
||||
* 按 userId(明细表 inspector_id 存的是 user.id)查询关联物料类别列表
|
||||
*/
|
||||
List<QmsQualityInspectorCategoryVO> getCategoriesByInspectorId(@Param("inspectorId") Long inspectorId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nflg.wms.common.pojo.qo.QmsSupplierSqeSearchQO;
|
||||
import com.nflg.wms.common.pojo.qo.QmsUserMaterialsQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapFlatVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsUserSupplierVO;
|
||||
import com.nflg.wms.repository.entity.QmsSupplierSqeMap;
|
||||
|
|
@ -27,6 +28,11 @@ public interface QmsSupplierSqeMapMapper extends BaseMapper<QmsSupplierSqeMap> {
|
|||
*/
|
||||
IPage<QmsSupplierSqeMapVO> searchMap(@Param("request") QmsSupplierSqeSearchQO request, Page<QmsSupplierSqeMapVO> page);
|
||||
|
||||
/**
|
||||
* 平铺查询(每行一条关联记录,含 userId/userName,供 Service 层聚合为 List)
|
||||
*/
|
||||
List<QmsSupplierSqeMapFlatVO> searchMapFlat(@Param("request") QmsSupplierSqeSearchQO request);
|
||||
|
||||
/**
|
||||
* 按 userId 查询关联的供应商列表(支持供应商过滤,分页)
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ public interface IQmsQualityInspectorService extends IService<QmsQualityInspecto
|
|||
IPage<QmsQualityInspectorVO> search(QmsQualityInspectorSearchQO request);
|
||||
|
||||
/**
|
||||
* 按员工ID查询质检人员详情,将物料和物料类别分开返回(不分页)
|
||||
* 按员工ID(user_id)查询质检人员详情,物料和物料类别分开返回(不分页)
|
||||
*/
|
||||
QmsQualityInspectorDetailVO getDetailByUserId(Long userId);
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
|
@ -11,14 +11,23 @@ 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.pojo.vo.*;
|
||||
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.User;
|
||||
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.entity.Department;
|
||||
import com.nflg.wms.repository.entity.Position;
|
||||
import com.nflg.wms.repository.entity.UserInterior;
|
||||
import com.nflg.wms.repository.service.IDepartmentService;
|
||||
import com.nflg.wms.repository.service.IPositionService;
|
||||
import com.nflg.wms.repository.service.IUserInteriorService;
|
||||
import com.nflg.wms.repository.service.IQmsQcMaterialCategoryService;
|
||||
import com.nflg.wms.repository.service.IQmsQualityInspectorService;
|
||||
import com.nflg.wms.repository.service.IUserService;
|
||||
import jakarta.annotation.Resource;
|
||||
|
|
@ -27,10 +36,7 @@ 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.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -48,6 +54,40 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
@Resource
|
||||
private IUserService userService;
|
||||
|
||||
@Resource
|
||||
private IQmsInspectorMaterialItemService materialItemService;
|
||||
|
||||
@Resource
|
||||
private IQmsInspectorMaterialCategoryItemService materialCategoryItemService;
|
||||
|
||||
@Resource
|
||||
private IQmsQcMaterialCategoryService qcMaterialCategoryService;
|
||||
|
||||
@Resource
|
||||
private IUserInteriorService userInteriorService;
|
||||
|
||||
@Resource
|
||||
private IDepartmentService departmentService;
|
||||
|
||||
@Resource
|
||||
private IPositionService positionService;
|
||||
|
||||
// ========================= 工具方法 =========================
|
||||
|
||||
/**
|
||||
* 按物料类别编码列表批量查询 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
|
||||
|
|
@ -55,99 +95,85 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
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());
|
||||
// 校验同一 userId + inspectionType 是否已存在
|
||||
boolean exists = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, request.getUserId())
|
||||
.eq(QmsQualityInspector::getInspectionType, request.getInspectionType())
|
||||
.exists();
|
||||
if (exists) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员已存在相同质检类型,不允许重复新增");
|
||||
}
|
||||
|
||||
if (hasMaterial) {
|
||||
for (Long materialId : request.getMaterialIds()) {
|
||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
||||
materialId, null, operator, now));
|
||||
// 校验物料ID是否已被其他质检员绑定
|
||||
if (!CollectionUtils.isEmpty(request.getMaterialIds())) {
|
||||
List<QmsInspectorMaterialItem> conflictMaterials = materialItemService.lambdaQuery()
|
||||
.in(QmsInspectorMaterialItem::getMaterialId, request.getMaterialIds())
|
||||
.list();
|
||||
if (!conflictMaterials.isEmpty()) {
|
||||
throw new NflgException(STATE.BusinessError, "物料ID已被其他质检员绑定,不允许重复新增");
|
||||
}
|
||||
}
|
||||
if (hasCategory) {
|
||||
for (String categoryCode : request.getMaterialCategoryCodes()) {
|
||||
records.add(buildRecord(request.getUserId(), request.getInspectionType(),
|
||||
null, categoryCode, operator, now));
|
||||
|
||||
// 校验物料类别是否已被其他质检员绑定
|
||||
if (!CollectionUtils.isEmpty(request.getMaterialCategoryCodes())) {
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
// 插入主表
|
||||
QmsQualityInspector inspector = new QmsQualityInspector()
|
||||
.setUserId(request.getUserId())
|
||||
.setInspectionType(request.getInspectionType())
|
||||
.setEnable(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now);
|
||||
}
|
||||
save(inspector);
|
||||
Long inspectorId = inspector.getUserId();
|
||||
|
||||
/**
|
||||
* 删除物料/物料类别关联行。
|
||||
* 若删除后该 userId 下记录数归零,则保留其中一条(清空 materialId 和 materialCategoryCode),
|
||||
* 不做物理删除,确保人员记录始终存在。
|
||||
*/
|
||||
private void removeMaterialOrClear(Long userId, List<QmsQualityInspector> toRemove,
|
||||
String operator, LocalDateTime now) {
|
||||
if (CollectionUtils.isEmpty(toRemove)) {
|
||||
return;
|
||||
// 批量插入物料明细
|
||||
if (!CollectionUtils.isEmpty(request.getMaterialIds())) {
|
||||
List<QmsInspectorMaterialItem> materialItems = request.getMaterialIds().stream()
|
||||
.map(materialId -> new QmsInspectorMaterialItem()
|
||||
.setInspectorId(inspectorId)
|
||||
.setMaterialId(materialId)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now))
|
||||
.collect(Collectors.toList());
|
||||
materialItemService.saveBatch(materialItems);
|
||||
}
|
||||
|
||||
// 该用户当前全部记录
|
||||
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);
|
||||
// 批量插入物料类别明细(按编码查 ID)
|
||||
if (!CollectionUtils.isEmpty(request.getMaterialCategoryCodes())) {
|
||||
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getMaterialCategoryCodes());
|
||||
List<QmsInspectorMaterialCategoryItem> categoryItems = new ArrayList<>();
|
||||
for (String code : request.getMaterialCategoryCodes()) {
|
||||
Long categoryId = codeToIdMap.get(code);
|
||||
if (Objects.nonNull(categoryId)) {
|
||||
categoryItems.add(new QmsInspectorMaterialCategoryItem()
|
||||
.setInspectorId(inspectorId)
|
||||
.setMaterialCategoryId(categoryId)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now));
|
||||
}
|
||||
}
|
||||
if (!categoryItems.isEmpty()) {
|
||||
materialCategoryItemService.saveBatch(categoryItems);
|
||||
}
|
||||
|
||||
// 保留行的物料字段清空
|
||||
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 +182,27 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
@Transactional
|
||||
@Override
|
||||
public void delete(Long userId) {
|
||||
// 查询该用户是否存在记录
|
||||
List<QmsQualityInspector> records = lambdaQuery()
|
||||
// 查询主表记录
|
||||
QmsQualityInspector inspector = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.list();
|
||||
if (records.isEmpty()) {
|
||||
.one();
|
||||
if (Objects.isNull(inspector)) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||
}
|
||||
// 启用状态下不允许删除
|
||||
boolean enabled = records.stream().anyMatch(r -> Boolean.TRUE.equals(r.getEnable()));
|
||||
if (enabled) {
|
||||
if (Boolean.TRUE.equals(inspector.getEnable())) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员处于启用状态,不允许删除,请先禁用后再删除");
|
||||
}
|
||||
// 删除该用户所有记录
|
||||
List<Long> ids = records.stream().map(QmsQualityInspector::getId).collect(Collectors.toList());
|
||||
removeByIds(ids);
|
||||
Long inspectorId = inspector.getId();
|
||||
// 删除两张明细表
|
||||
materialItemService.lambdaUpdate()
|
||||
.eq(QmsInspectorMaterialItem::getInspectorId, inspectorId)
|
||||
.remove();
|
||||
materialCategoryItemService.lambdaUpdate()
|
||||
.eq(QmsInspectorMaterialCategoryItem::getInspectorId, inspectorId)
|
||||
.remove();
|
||||
// 删除主表
|
||||
removeById(inspectorId);
|
||||
}
|
||||
|
||||
// ========================= 修改物料/物料类别 =========================
|
||||
|
|
@ -182,49 +214,85 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
LocalDateTime now = LocalDateTime.now();
|
||||
Long userId = request.getUserId();
|
||||
|
||||
// 查询当前该质检人的任意一条记录,取 inspectionType(同一人 inspectionType 相同)
|
||||
QmsQualityInspector any = lambdaQuery()
|
||||
// 查主表,获取 inspectorId
|
||||
QmsQualityInspector inspector = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
if (Objects.isNull(any)) {
|
||||
if (Objects.isNull(inspector)) {
|
||||
throw new NflgException(STATE.BusinessError, "该质检人员不存在");
|
||||
}
|
||||
Integer inspectionType = any.getInspectionType();
|
||||
Long inspectorId = inspector.getUserId();
|
||||
|
||||
// 追加物料
|
||||
if (!CollectionUtils.isEmpty(request.getAddMaterialIds())) {
|
||||
List<QmsQualityInspector> toAdd = request.getAddMaterialIds().stream()
|
||||
.map(materialId -> buildRecord(userId, inspectionType, materialId, null, operator, now))
|
||||
// 校验这些物料是否已被任意质检员绑定(含自己)
|
||||
List<QmsInspectorMaterialItem> conflictMaterials = materialItemService.lambdaQuery()
|
||||
.in(QmsInspectorMaterialItem::getMaterialId, request.getAddMaterialIds())
|
||||
.list();
|
||||
if (!conflictMaterials.isEmpty()) {
|
||||
throw new NflgException(STATE.BusinessError, "追加的物料中存在已被质检员绑定的物料,不允许重复追加");
|
||||
}
|
||||
List<QmsInspectorMaterialItem> toAdd = request.getAddMaterialIds().stream()
|
||||
.map(materialId -> new QmsInspectorMaterialItem()
|
||||
.setInspectorId(inspectorId)
|
||||
.setMaterialId(materialId)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now))
|
||||
.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())) {
|
||||
toRemove.addAll(lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.in(QmsQualityInspector::getMaterialId, request.getRemoveMaterialIds())
|
||||
.list());
|
||||
materialItemService.lambdaUpdate()
|
||||
.eq(QmsInspectorMaterialItem::getInspectorId, inspectorId)
|
||||
.in(QmsInspectorMaterialItem::getMaterialId, request.getRemoveMaterialIds())
|
||||
.remove();
|
||||
}
|
||||
|
||||
// 追加物料类别(按编码查 ID)
|
||||
if (!CollectionUtils.isEmpty(request.getAddMaterialCategoryCodes())) {
|
||||
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getAddMaterialCategoryCodes());
|
||||
List<Long> addCategoryIds = new ArrayList<>(codeToIdMap.values());
|
||||
// 校验这些物料类别是否已被任意质检员绑定(含自己)
|
||||
if (!addCategoryIds.isEmpty()) {
|
||||
List<QmsInspectorMaterialCategoryItem> conflictCategories = materialCategoryItemService.lambdaQuery()
|
||||
.in(QmsInspectorMaterialCategoryItem::getMaterialCategoryId, addCategoryIds)
|
||||
.list();
|
||||
if (!conflictCategories.isEmpty()) {
|
||||
throw new NflgException(STATE.BusinessError, "追加的物料类别中存在已被质检员绑定的类别,不允许重复追加");
|
||||
}
|
||||
}
|
||||
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())) {
|
||||
toRemove.addAll(lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.in(QmsQualityInspector::getMaterialCategoryCode, request.getRemoveMaterialCategoryCodes())
|
||||
.list());
|
||||
}
|
||||
if (!toRemove.isEmpty()) {
|
||||
removeMaterialOrClear(userId, toRemove, operator, now);
|
||||
Map<String, Long> codeToIdMap = getCategoryCodeToIdMap(request.getRemoveMaterialCategoryCodes());
|
||||
List<Long> removeIds = new ArrayList<>(codeToIdMap.values());
|
||||
if (!removeIds.isEmpty()) {
|
||||
materialCategoryItemService.lambdaUpdate()
|
||||
.eq(QmsInspectorMaterialCategoryItem::getInspectorId, inspectorId)
|
||||
.in(QmsInspectorMaterialCategoryItem::getMaterialCategoryId, removeIds)
|
||||
.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -237,33 +305,55 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
|
||||
@Override
|
||||
public QmsQualityInspectorDetailVO getDetailByUserId(Long userId) {
|
||||
// 查询该用户的任意一条记录(取 inspectionType/enable)
|
||||
QmsQualityInspector first = lambdaQuery()
|
||||
// 按 user_id 查主表,取到 inspector.id 后再查两张明细表
|
||||
QmsQualityInspector inspector = lambdaQuery()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.last("LIMIT 1")
|
||||
.one();
|
||||
if (Objects.isNull(first)) {
|
||||
if (Objects.isNull(inspector)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 查 user 信息
|
||||
User user = userService.getById(userId);
|
||||
|
||||
// 查 user_interior,获取 deptId 和 positionId
|
||||
UserInterior userInterior = userInteriorService.lambdaQuery()
|
||||
.eq(UserInterior::getUserId, userId)
|
||||
.one();
|
||||
|
||||
// 查部门名称
|
||||
String deptName = null;
|
||||
String positionName = null;
|
||||
if (Objects.nonNull(userInterior)) {
|
||||
if (Objects.nonNull(userInterior.getDeptId())) {
|
||||
Department department = departmentService.getById(userInterior.getDeptId());
|
||||
if (Objects.nonNull(department)) {
|
||||
deptName = department.getName();
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(userInterior.getPositionId())) {
|
||||
Position position = positionService.getById(userInterior.getPositionId());
|
||||
if (Objects.nonNull(position)) {
|
||||
positionName = position.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QmsQualityInspectorDetailVO detail = new QmsQualityInspectorDetailVO();
|
||||
detail.setUserId(userId);
|
||||
detail.setInspectionType(first.getInspectionType());
|
||||
detail.setEnable(first.getEnable());
|
||||
detail.setInspectionType(inspector.getInspectionType());
|
||||
detail.setEnable(inspector.getEnable());
|
||||
if (Objects.nonNull(user)) {
|
||||
detail.setUserCode(user.getUserCode());
|
||||
detail.setUserName(user.getUserName());
|
||||
}
|
||||
// 部门领导暂不填充,字段预留
|
||||
detail.setDeptName(deptName);
|
||||
detail.setDeptLeaderName(null);
|
||||
detail.setPositionName(positionName);
|
||||
|
||||
// 查物料列表
|
||||
detail.setMaterials(baseMapper.getMaterialsByUserId(userId));
|
||||
// 查物料类别列表
|
||||
detail.setCategories(baseMapper.getCategoriesByUserId(userId));
|
||||
// 按 userId 查物料列表和物料类别列表(明细表 inspector_id 存的是 user.id)
|
||||
detail.setMaterials(baseMapper.getMaterialsByInspectorId(userId));
|
||||
detail.setCategories(baseMapper.getCategoriesByInspectorId(userId));
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
|
@ -273,6 +363,77 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
@Transactional
|
||||
@Override
|
||||
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()
|
||||
.eq(QmsQualityInspector::getUserId, userId)
|
||||
.set(QmsQualityInspector::getEnable, enable)
|
||||
|
|
@ -308,11 +469,13 @@ public class QmsQualityInspectorServiceImpl extends ServiceImpl<QmsQualityInspec
|
|||
}
|
||||
|
||||
@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();
|
||||
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>()
|
||||
.setPage((int) result.getCurrent())
|
||||
.setPageSize((int) result.getSize())
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
package com.nflg.wms.repository.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
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.PageData;
|
||||
import com.nflg.wms.common.pojo.qo.QmsSupplierSqeSearchQO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapFlatVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsSupplierSqeUserVO;
|
||||
import com.nflg.wms.common.pojo.vo.QmsUserSupplierVO;
|
||||
import com.nflg.wms.common.util.UserUtil;
|
||||
import com.nflg.wms.repository.entity.QmsSupplierSqeMap;
|
||||
|
|
@ -17,7 +20,10 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -36,7 +42,56 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
|
||||
@Override
|
||||
public IPage<QmsSupplierSqeMapVO> searchMap(QmsSupplierSqeSearchQO request) {
|
||||
return baseMapper.searchMap(request, new Page<>(request.getPage(), request.getPageSize()));
|
||||
// 1. 查平铺列表
|
||||
List<QmsSupplierSqeMapFlatVO> flatList = baseMapper.searchMapFlat(request);
|
||||
|
||||
// 2. 按 supplierId 聚合(保持原始排序,LinkedHashMap)
|
||||
Map<Long, QmsSupplierSqeMapVO> grouped = new LinkedHashMap<>();
|
||||
for (QmsSupplierSqeMapFlatVO flat : flatList) {
|
||||
QmsSupplierSqeMapVO vo = grouped.computeIfAbsent(flat.getSupplierId(), id -> {
|
||||
QmsSupplierSqeMapVO newVo = new QmsSupplierSqeMapVO();
|
||||
newVo.setSupplierId(flat.getSupplierId());
|
||||
newVo.setSupplierCode(flat.getSupplierCode());
|
||||
newVo.setSupplierName(flat.getSupplierName());
|
||||
newVo.setEnable(flat.getEnable());
|
||||
newVo.setCreateTime(flat.getCreateTime());
|
||||
newVo.setCreateBy(flat.getCreateBy());
|
||||
newVo.setUpdateTime(flat.getUpdateTime());
|
||||
newVo.setUpdateBy(flat.getUpdateBy());
|
||||
newVo.setUsers(new ArrayList<>());
|
||||
return newVo;
|
||||
});
|
||||
// 追加用户信息
|
||||
if (Objects.nonNull(flat.getUserId())) {
|
||||
QmsSupplierSqeUserVO userVO = new QmsSupplierSqeUserVO();
|
||||
userVO.setUserId(flat.getUserId());
|
||||
userVO.setUserName(flat.getUserName());
|
||||
vo.getUsers().add(userVO);
|
||||
}
|
||||
// enable 取最严格(有一条禁用则整体禁用)
|
||||
if (Boolean.FALSE.equals(flat.getEnable())) {
|
||||
vo.setEnable(false);
|
||||
}
|
||||
// 取最晚修改时间
|
||||
if (flat.getUpdateTime() != null && (vo.getUpdateTime() == null
|
||||
|| flat.getUpdateTime().isAfter(vo.getUpdateTime()))) {
|
||||
vo.setUpdateTime(flat.getUpdateTime());
|
||||
vo.setUpdateBy(flat.getUpdateBy());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. 手动分页
|
||||
List<QmsSupplierSqeMapVO> allList = new ArrayList<>(grouped.values());
|
||||
int page = request.getPage();
|
||||
int pageSize = request.getPageSize();
|
||||
int total = allList.size();
|
||||
int fromIndex = Math.min((page - 1) * pageSize, total);
|
||||
int toIndex = Math.min(fromIndex + pageSize, total);
|
||||
List<QmsSupplierSqeMapVO> pageList = allList.subList(fromIndex, toIndex);
|
||||
|
||||
Page<QmsSupplierSqeMapVO> result = new Page<>(page, pageSize, total);
|
||||
result.setRecords(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
@ -71,28 +126,25 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
|||
@Transactional
|
||||
@Override
|
||||
public void setUser(Long supplierId, List<Long> userIds) {
|
||||
// 查询该供应商已存在的用户ID集合
|
||||
Set<Long> existUserIds = lambdaQuery()
|
||||
// 先删除该供应商所有负责人关联
|
||||
lambdaUpdate()
|
||||
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||
.list()
|
||||
.stream()
|
||||
.map(QmsSupplierSqeMap::getUserId)
|
||||
.collect(Collectors.toSet());
|
||||
// 只插入不存在的记录,跳过重复的
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<QmsSupplierSqeMap> toAdd = userIds.stream()
|
||||
.filter(userId -> !existUserIds.contains(userId))
|
||||
.map(userId -> new QmsSupplierSqeMap()
|
||||
.setSupplierId(supplierId)
|
||||
.setUserId(userId)
|
||||
.setEnable(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now))
|
||||
.collect(Collectors.toList());
|
||||
if (!toAdd.isEmpty()) {
|
||||
.remove();
|
||||
|
||||
// 再全量插入传入的用户列表
|
||||
if (!CollectionUtils.isEmpty(userIds)) {
|
||||
String operator = UserUtil.getUserName();
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
List<QmsSupplierSqeMap> toAdd = userIds.stream()
|
||||
.map(userId -> new QmsSupplierSqeMap()
|
||||
.setSupplierId(supplierId)
|
||||
.setUserId(userId)
|
||||
.setEnable(true)
|
||||
.setCreateBy(operator)
|
||||
.setCreateTime(now)
|
||||
.setUpdateBy(operator)
|
||||
.setUpdateTime(now))
|
||||
.collect(Collectors.toList());
|
||||
saveBatch(toAdd);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
||||
<!--
|
||||
分页查询:以质检人为主体,每个 user_id 只返回一条记录
|
||||
使用 DISTINCT ON (qi.user_id) 保证每人唯一
|
||||
分页查询:以质检人为主体,每个 user_id 只返回一条记录(主表一人一条)
|
||||
JOIN user_interior/department 获取部门信息
|
||||
JOIN user AS cu 获取转办人姓名
|
||||
支持动态过滤:员工工号(userCode)、人员名称模糊(userName)、物料编号(materialNo)
|
||||
|
|
@ -27,11 +26,7 @@
|
|||
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
|
||||
FROM qms_quality_inspector 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
|
||||
|
|
@ -45,9 +40,10 @@
|
|||
</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
|
||||
SELECT 1
|
||||
FROM qms_inspector_material_item imi
|
||||
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}, '%')
|
||||
)
|
||||
</if>
|
||||
|
|
@ -58,8 +54,8 @@
|
|||
<!-- 按 userId 查询关联物料列表(JOIN qms_qc_material 获取物料详情) -->
|
||||
<select id="getMaterialsByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||
SELECT
|
||||
qi.id,
|
||||
qi.material_id,
|
||||
imi.id,
|
||||
imi.material_id,
|
||||
m.material_no,
|
||||
m.material_category_code,
|
||||
m.material_category_code_path_name AS material_category_name,
|
||||
|
|
@ -67,18 +63,19 @@
|
|||
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
|
||||
FROM qms_inspector_material_item imi
|
||||
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||
WHERE imi.inspector_id = (
|
||||
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||
)
|
||||
ORDER BY imi.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询关联物料列表(支持供应商过滤) -->
|
||||
<select id="getMaterialsByUserIdWithSupplier" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||
SELECT
|
||||
qi.id,
|
||||
qi.material_id,
|
||||
imi.id,
|
||||
imi.material_id,
|
||||
m.material_no,
|
||||
m.material_category_code,
|
||||
m.material_category_code_path_name AS material_category_name,
|
||||
|
|
@ -86,29 +83,30 @@
|
|||
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
|
||||
FROM qms_inspector_material_item imi
|
||||
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 user_supplier us ON us.id = cr.supplier_id
|
||||
WHERE qi.user_id = #{userId}
|
||||
AND qi.material_id IS NOT NULL
|
||||
WHERE imi.inspector_id = (
|
||||
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||
)
|
||||
<if test="supplierCode != null and supplierCode != ''">
|
||||
AND us.supplier_code = #{supplierCode}
|
||||
</if>
|
||||
<if test="supplierName != null and supplierName != ''">
|
||||
AND us.supplier_name LIKE CONCAT('%', #{supplierName}, '%')
|
||||
</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_specifications, m.material_texture, m.is_standard_maintained
|
||||
ORDER BY qi.id ASC
|
||||
ORDER BY imi.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询绑定物料列表(支持物料编号/类别/描述过滤) -->
|
||||
<select id="getMaterialsByUserIdWithFilter" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||
SELECT
|
||||
qi.id,
|
||||
qi.material_id,
|
||||
imi.id,
|
||||
imi.material_id,
|
||||
m.material_no,
|
||||
m.drawing_no,
|
||||
m.drawing_no_ver,
|
||||
|
|
@ -118,10 +116,11 @@
|
|||
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
|
||||
FROM qms_inspector_material_item imi
|
||||
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||
WHERE imi.inspector_id = (
|
||||
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||
)
|
||||
<if test="materialNo != null and materialNo != ''">
|
||||
AND m.material_no = #{materialNo}
|
||||
</if>
|
||||
|
|
@ -131,21 +130,55 @@
|
|||
<if test="materialDesc != null and materialDesc != ''">
|
||||
AND m.material_desc LIKE CONCAT('%', #{materialDesc}, '%')
|
||||
</if>
|
||||
ORDER BY qi.id ASC
|
||||
ORDER BY imi.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询关联物料类别列表(JOIN qms_qc_material 取类别名称) -->
|
||||
<!-- 按 userId 查询关联物料类别列表(JOIN qms_qc_material_category 取类别信息) -->
|
||||
<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
|
||||
imci.id,
|
||||
imci.material_category_id,
|
||||
mc.category_code AS material_category_code,
|
||||
mc.category_name AS material_category_name
|
||||
FROM qms_inspector_material_category_item imci
|
||||
LEFT JOIN qms_qc_material_category mc ON mc.id = imci.material_category_id
|
||||
WHERE imci.inspector_id = (
|
||||
SELECT id FROM qms_quality_inspector WHERE user_id = #{userId} LIMIT 1
|
||||
)
|
||||
ORDER BY imci.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 inspectorId 直接查询关联物料列表 -->
|
||||
<select id="getMaterialsByInspectorId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorMaterialVO">
|
||||
SELECT
|
||||
imi.id,
|
||||
imi.material_id,
|
||||
m.material_no,
|
||||
m.drawing_no,
|
||||
m.drawing_no_ver,
|
||||
m.material_category_code,
|
||||
m.material_category_code_path_name AS material_category_name,
|
||||
m.material_name,
|
||||
m.material_specifications,
|
||||
m.material_texture,
|
||||
m.is_standard_maintained AS material_status
|
||||
FROM qms_inspector_material_item imi
|
||||
LEFT JOIN qms_qc_material m ON m.id = imi.material_id
|
||||
WHERE imi.inspector_id = #{inspectorId}
|
||||
ORDER BY imi.id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 inspectorId 直接查询关联物料类别列表(通过 material_category_id JOIN qms_qc_material_category) -->
|
||||
<select id="getCategoriesByInspectorId" resultType="com.nflg.wms.common.pojo.vo.QmsQualityInspectorCategoryVO">
|
||||
SELECT
|
||||
imci.id,
|
||||
imci.material_category_id,
|
||||
mc.category_code AS material_category_code,
|
||||
mc.category_name AS material_category_name
|
||||
FROM qms_inspector_material_category_item imci
|
||||
LEFT JOIN qms_qc_material_category mc ON mc.id = imci.material_category_id
|
||||
WHERE imci.inspector_id = #{inspectorId}
|
||||
ORDER BY imci.id ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,36 @@
|
|||
ORDER BY qssm.supplier_id DESC
|
||||
</select>
|
||||
|
||||
<!-- 平铺查询:每行一条关联记录,含 userId/userName,供 Service 聚合为 List -->
|
||||
<select id="searchMapFlat" resultType="com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapFlatVO">
|
||||
SELECT
|
||||
qssm.supplier_id,
|
||||
us.supplier_code,
|
||||
us.supplier_name,
|
||||
qssm.user_id,
|
||||
u.user_name,
|
||||
qssm.enable,
|
||||
qssm.create_time,
|
||||
qssm.create_by,
|
||||
qssm.update_time,
|
||||
qssm.update_by
|
||||
FROM qms_supplier_sqe_map qssm
|
||||
LEFT JOIN user_supplier us ON us.id = qssm.supplier_id
|
||||
LEFT JOIN "user" u ON u.id = qssm.user_id
|
||||
<where>
|
||||
<if test="request.supplierCode != null and request.supplierCode != ''">
|
||||
AND us.supplier_code ilike concat('%', #{request.supplierCode}, '%')
|
||||
</if>
|
||||
<if test="request.supplierName != null and request.supplierName != ''">
|
||||
AND us.supplier_name ilike concat('%', #{request.supplierName}, '%')
|
||||
</if>
|
||||
<if test="request.userName != null and request.userName != ''">
|
||||
AND u.user_name ilike concat('%', #{request.userName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY qssm.supplier_id DESC, qssm.user_id ASC
|
||||
</select>
|
||||
|
||||
<!-- 按 userId 查询关联的供应商列表(支持供应商过滤) -->
|
||||
<select id="getSuppliersByUserId" resultType="com.nflg.wms.common.pojo.vo.QmsUserSupplierVO">
|
||||
SELECT
|
||||
|
|
|
|||
Loading…
Reference in New Issue