Compare commits
4 Commits
5f8eb1058a
...
e7027087c1
| Author | SHA1 | Date |
|---|---|---|
|
|
e7027087c1 | |
|
|
0918a6e0bf | |
|
|
121fda4454 | |
|
|
66f89161b8 |
|
|
@ -3,7 +3,7 @@ package com.nflg.qms.admin.controller;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.nflg.wms.common.pojo.ApiResult;
|
import com.nflg.wms.common.pojo.ApiResult;
|
||||||
import com.nflg.wms.common.pojo.PageData;
|
import com.nflg.wms.common.pojo.PageData;
|
||||||
import com.nflg.wms.common.pojo.qo.EnableQO;
|
import com.nflg.wms.common.pojo.qo.EnableSupplierQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsSupplierSqeSearchQO;
|
import com.nflg.wms.common.pojo.qo.QmsSupplierSqeSearchQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsSetSupplierQO;
|
import com.nflg.wms.common.pojo.qo.QmsSetSupplierQO;
|
||||||
import com.nflg.wms.common.pojo.qo.QmsSetUserQO;
|
import com.nflg.wms.common.pojo.qo.QmsSetUserQO;
|
||||||
|
|
@ -59,24 +59,26 @@ public class QmsSupplierSqeController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用/禁用供应商-用户关联关系
|
* 启用/禁用供应商所有关联关系
|
||||||
|
*
|
||||||
|
* @param request supplierId=供应商ID,enable=启用/禁用
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@PostMapping("enable")
|
@PostMapping("enable")
|
||||||
public ApiResult<Void> enable(@Valid @RequestBody EnableQO request) {
|
public ApiResult<Void> enable(@Valid @RequestBody EnableSupplierQO request) {
|
||||||
supplierSqeMapService.enable(request.getId(), request.getEnable());
|
supplierSqeMapService.enableBySupplierId(request.getSupplierId(), request.getEnable());
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除供应商-用户关联关系(启用状态下不允许删除)
|
* 删除供应商所有关联关系(启用状态下不允许删除)
|
||||||
*
|
*
|
||||||
* @param id 关联记录ID
|
* @param supplierId 供应商ID
|
||||||
*/
|
*/
|
||||||
@Transactional
|
@Transactional
|
||||||
@PostMapping("delete")
|
@PostMapping("delete")
|
||||||
public ApiResult<Void> delete(@NotNull Long id) {
|
public ApiResult<Void> delete(@NotNull Long supplierId) {
|
||||||
supplierSqeMapService.deleteById(id);
|
supplierSqeMapService.deleteBySupplierId(supplierId);
|
||||||
return ApiResult.success();
|
return ApiResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,37 +147,6 @@ public class QmsStandardDefectControllerService {
|
||||||
updateChain.set(QmsStandardDefect::getRemark, request.getRemark());
|
updateChain.set(QmsStandardDefect::getRemark, request.getRemark());
|
||||||
}
|
}
|
||||||
|
|
||||||
// 父级变更:仅当 changeParent=true 时处理
|
|
||||||
boolean parentChanged = false;
|
|
||||||
Long oldParentId = exist.getParentId();
|
|
||||||
if (Boolean.TRUE.equals(request.getChangeParent())) {
|
|
||||||
Long newParentId = null;
|
|
||||||
String newParentCode = null;
|
|
||||||
Short newLevel;
|
|
||||||
|
|
||||||
if (StrUtil.isBlank(request.getParentName())) {
|
|
||||||
// 改为顶级
|
|
||||||
newLevel = 1;
|
|
||||||
} else {
|
|
||||||
QmsStandardDefect newParent = getParentByName(request.getParentName());
|
|
||||||
newParentId = newParent.getId();
|
|
||||||
newParentCode = newParent.getDefectCode();
|
|
||||||
newLevel = (short) (newParent.getLevel() + 1);
|
|
||||||
// 新父级若是叶子节点,改为非叶子
|
|
||||||
if (Boolean.TRUE.equals(newParent.getIsLeaf())) {
|
|
||||||
defectService.lambdaUpdate()
|
|
||||||
.eq(QmsStandardDefect::getId, newParent.getId())
|
|
||||||
.set(QmsStandardDefect::getIsLeaf, false)
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
parentChanged = !Objects.equals(oldParentId, newParentId);
|
|
||||||
updateChain.set(QmsStandardDefect::getParentId, newParentId)
|
|
||||||
.set(QmsStandardDefect::getParentCode, newParentCode)
|
|
||||||
.set(QmsStandardDefect::getLevel, newLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateChain.set(QmsStandardDefect::getUpdateBy, operator)
|
updateChain.set(QmsStandardDefect::getUpdateBy, operator)
|
||||||
.set(QmsStandardDefect::getUpdateTime, now)
|
.set(QmsStandardDefect::getUpdateTime, now)
|
||||||
.update();
|
.update();
|
||||||
|
|
@ -186,20 +155,6 @@ public class QmsStandardDefectControllerService {
|
||||||
if (Objects.nonNull(request.getEnable())) {
|
if (Objects.nonNull(request.getEnable())) {
|
||||||
updateDescendantsEnable(request.getId(), request.getEnable(), operator, now);
|
updateDescendantsEnable(request.getId(), request.getEnable(), operator, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 若父级变更,检查旧父级是否还有未删除子节点,没有则恢复 isLeaf=true
|
|
||||||
if (parentChanged && Objects.nonNull(oldParentId)) {
|
|
||||||
boolean hasChildren = defectService.lambdaQuery()
|
|
||||||
.eq(QmsStandardDefect::getParentId, oldParentId)
|
|
||||||
.eq(QmsStandardDefect::getDeleted, false)
|
|
||||||
.exists();
|
|
||||||
if (!hasChildren) {
|
|
||||||
defectService.lambdaUpdate()
|
|
||||||
.eq(QmsStandardDefect::getId, oldParentId)
|
|
||||||
.set(QmsStandardDefect::getIsLeaf, true)
|
|
||||||
.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================= 删除(逻辑删除) =========================
|
// ========================= 删除(逻辑删除) =========================
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.nflg.wms.common.pojo.qo;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class EnableSupplierQO {
|
||||||
|
|
||||||
|
// 供应商ID
|
||||||
|
@NotNull
|
||||||
|
private Long supplierId;
|
||||||
|
|
||||||
|
// 是否启用
|
||||||
|
@NotNull
|
||||||
|
private Boolean enable;
|
||||||
|
}
|
||||||
|
|
@ -15,17 +15,6 @@ public class QmsStandardDefectUpdateQO {
|
||||||
@NotNull(message = "ID不能为空")
|
@NotNull(message = "ID不能为空")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
|
||||||
* 父级缺陷名称(传 null 表示顶级;变更父级时自动处理旧父级 isLeaf;不传则不修改父级)
|
|
||||||
*/
|
|
||||||
private String parentName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否修改父级(true=修改父级关系,false=不修改)
|
|
||||||
* 用于区分"不传parentName"是顶级还是不修改
|
|
||||||
*/
|
|
||||||
private Boolean changeParent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 缺陷代码(不传则不修改)
|
* 缺陷代码(不传则不修改)
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,12 @@ package com.nflg.wms.common.pojo.vo;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 供应商-用户 关联记录 VO(以关联表为主体,每行一条关联记录)
|
* 供应商-用户 关联 VO(按供应商聚合,每行一个供应商)
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class QmsSupplierSqeMapVO {
|
public class QmsSupplierSqeMapVO {
|
||||||
|
|
||||||
/**
|
|
||||||
* 关联记录ID(qms_supplier_sqe_map.id)
|
|
||||||
*/
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 供应商ID
|
* 供应商ID
|
||||||
*/
|
*/
|
||||||
|
|
@ -31,47 +24,12 @@ public class QmsSupplierSqeMapVO {
|
||||||
private String supplierName;
|
private String supplierName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户ID
|
* SQE用户名称(多个用逗号分隔)
|
||||||
*/
|
|
||||||
private Long userId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户名称
|
|
||||||
*/
|
*/
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户工号
|
* 统一启用状态:所有关联记录均启用时为true,否则为false
|
||||||
*/
|
|
||||||
private String userCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 职位名称
|
|
||||||
*/
|
|
||||||
private String positionName;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 启用状态:true=启用,false=禁用
|
|
||||||
*/
|
*/
|
||||||
private Boolean enable;
|
private Boolean enable;
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建人
|
|
||||||
*/
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime createTime;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后更新人
|
|
||||||
*/
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 最后更新时间
|
|
||||||
*/
|
|
||||||
private LocalDateTime updateTime;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,14 @@ public interface IQmsSupplierSqeMapService extends IService<QmsSupplierSqeMap> {
|
||||||
void setUser(Long supplierId, List<Long> userIds);
|
void setUser(Long supplierId, List<Long> userIds);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 启用/禁用单条供应商-用户关联
|
* 按供应商ID启用/禁用该供应商所有关联记录
|
||||||
*/
|
*/
|
||||||
void enable(Long id, Boolean enable);
|
void enableBySupplierId(Long supplierId, Boolean enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除单条供应商-用户关联(启用状态下不允许删除)
|
* 按供应商ID删除该供应商所有关联记录(启用状态下不允许删除)
|
||||||
*/
|
*/
|
||||||
void deleteById(Long id);
|
void deleteBySupplierId(Long supplierId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按 userId 查询该用户关联的供应商列表(支持供应商过滤,分页)
|
* 按 userId 查询该用户关联的供应商列表(支持供应商过滤,分页)
|
||||||
|
|
|
||||||
|
|
@ -99,13 +99,15 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void enable(Long id, Boolean enable) {
|
public void enableBySupplierId(Long supplierId, Boolean enable) {
|
||||||
QmsSupplierSqeMap record = getById(id);
|
boolean exists = lambdaQuery()
|
||||||
if (Objects.isNull(record)) {
|
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||||
throw new NflgException(STATE.BusinessError, "关联记录不存在");
|
.exists();
|
||||||
|
if (!exists) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "该供应商无关联记录");
|
||||||
}
|
}
|
||||||
lambdaUpdate()
|
lambdaUpdate()
|
||||||
.eq(QmsSupplierSqeMap::getId, id)
|
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||||
.set(QmsSupplierSqeMap::getEnable, enable)
|
.set(QmsSupplierSqeMap::getEnable, enable)
|
||||||
.set(QmsSupplierSqeMap::getUpdateBy, UserUtil.getUserName())
|
.set(QmsSupplierSqeMap::getUpdateBy, UserUtil.getUserName())
|
||||||
.set(QmsSupplierSqeMap::getUpdateTime, LocalDateTime.now())
|
.set(QmsSupplierSqeMap::getUpdateTime, LocalDateTime.now())
|
||||||
|
|
@ -114,15 +116,17 @@ public class QmsSupplierSqeMapServiceImpl extends ServiceImpl<QmsSupplierSqeMapM
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void deleteById(Long id) {
|
public void deleteBySupplierId(Long supplierId) {
|
||||||
QmsSupplierSqeMap record = getById(id);
|
boolean hasEnabled = lambdaQuery()
|
||||||
if (Objects.isNull(record)) {
|
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||||
throw new NflgException(STATE.BusinessError, "关联记录不存在");
|
.eq(QmsSupplierSqeMap::getEnable, true)
|
||||||
|
.exists();
|
||||||
|
if (hasEnabled) {
|
||||||
|
throw new NflgException(STATE.BusinessError, "该供应商关联关系处于启用状态,不允许删除,请先禁用后再删除");
|
||||||
}
|
}
|
||||||
if (Boolean.TRUE.equals(record.getEnable())) {
|
lambdaUpdate()
|
||||||
throw new NflgException(STATE.BusinessError, "关联关系处于启用状态,不允许删除,请先禁用后再删除");
|
.eq(QmsSupplierSqeMap::getSupplierId, supplierId)
|
||||||
}
|
.remove();
|
||||||
removeById(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -5,24 +5,14 @@
|
||||||
<!-- 分页查询关联表,JOIN 供应商/user/user_interior/position,动态过滤 -->
|
<!-- 分页查询关联表,JOIN 供应商/user/user_interior/position,动态过滤 -->
|
||||||
<select id="searchMap" resultType="com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapVO">
|
<select id="searchMap" resultType="com.nflg.wms.common.pojo.vo.QmsSupplierSqeMapVO">
|
||||||
SELECT
|
SELECT
|
||||||
qssm.id,
|
|
||||||
qssm.supplier_id,
|
qssm.supplier_id,
|
||||||
us.supplier_code,
|
us.supplier_code,
|
||||||
us.supplier_name,
|
us.supplier_name,
|
||||||
qssm.user_id,
|
STRING_AGG(DISTINCT u.user_name, ',' ORDER BY u.user_name) AS user_name,
|
||||||
u.user_name,
|
BOOL_AND(qssm.enable) AS enable
|
||||||
u.user_code,
|
|
||||||
p.name AS position_name,
|
|
||||||
qssm.enable,
|
|
||||||
qssm.create_by,
|
|
||||||
qssm.create_time,
|
|
||||||
qssm.update_by,
|
|
||||||
qssm.update_time
|
|
||||||
FROM qms_supplier_sqe_map qssm
|
FROM qms_supplier_sqe_map qssm
|
||||||
LEFT JOIN user_supplier us ON us.id = qssm.supplier_id
|
LEFT JOIN user_supplier us ON us.id = qssm.supplier_id
|
||||||
LEFT JOIN "user" u ON u.id = qssm.user_id
|
LEFT JOIN "user" u ON u.id = qssm.user_id
|
||||||
LEFT JOIN user_interior ui ON ui.user_id = qssm.user_id
|
|
||||||
LEFT JOIN position p ON p.id = ui.position_id
|
|
||||||
<where>
|
<where>
|
||||||
<if test="request.supplierCode != null and request.supplierCode != ''">
|
<if test="request.supplierCode != null and request.supplierCode != ''">
|
||||||
AND us.supplier_code ilike concat('%', #{request.supplierCode}, '%')
|
AND us.supplier_code ilike concat('%', #{request.supplierCode}, '%')
|
||||||
|
|
@ -34,7 +24,8 @@
|
||||||
AND u.user_name ilike concat('%', #{request.userName}, '%')
|
AND u.user_name ilike concat('%', #{request.userName}, '%')
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
ORDER BY qssm.id DESC
|
GROUP BY qssm.supplier_id, us.supplier_code, us.supplier_name
|
||||||
|
ORDER BY qssm.supplier_id DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 按 userId 查询关联的供应商列表(支持供应商过滤) -->
|
<!-- 按 userId 查询关联的供应商列表(支持供应商过滤) -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue