From 8084bff2fe8a23a2ce5c7d76bdb35d5ac8ef839b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=A3=B7=E5=8F=B6?=
<14103883+leaf-phos@user.noreply.gitee.com>
Date: Fri, 10 Jan 2025 17:43:39 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ruoyi/framework/util/DataScopeUtil.java | 51 +++++++++----------
.../com/ruoyi/bst/order/domain/Order.java | 4 ++
.../ruoyi/bst/order/domain/OrderQuery.java | 3 ++
.../ruoyi/bst/order/mapper/OrderMapper.xml | 6 +++
.../service/impl/OrderConverterImpl.java | 2 +
.../service/impl/OrderValidatorImpl.java | 15 ++++++
.../ruoyi/bst/orderProd/domain/OrderProd.java | 6 +++
.../bst/orderProd/mapper/OrderProdMapper.xml | 17 +++++++
.../service/impl/OrderProdConverterImpl.java | 2 +
.../dept/service/impl/SysDeptServiceImpl.java | 44 ++++++++--------
.../system/user/mapper/SysUserMapper.xml | 5 +-
.../ruoyi/web/system/SysDeptController.java | 19 +++----
12 files changed, 116 insertions(+), 58 deletions(-)
diff --git a/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/util/DataScopeUtil.java b/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/util/DataScopeUtil.java
index beea773..9e780e2 100644
--- a/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/util/DataScopeUtil.java
+++ b/common-ruoyi/ruoyi-framework/src/main/java/com/ruoyi/framework/util/DataScopeUtil.java
@@ -8,7 +8,6 @@ import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.framework.security.context.PermissionContextHolder;
import java.util.ArrayList;
@@ -105,31 +104,31 @@ public class DataScopeUtil {
break;
}
// 自定义数据范围
- else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
- if (scopeCustomIds.size() > 1) {
- // 多个自定数据权限使用in查询,避免多次拼接。
- sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptList, String.join(",", scopeCustomIds)));
- } else {
- sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptList, role.getRoleId()));
- }
- }
- // 仅本部门
- else if (DATA_SCOPE_DEPT.equals(dataScope)) {
- sqlString.append(getForeachSql(" OR {}.dept_id = {} ", deptList, user.getDeptId()));
- }
- // 本部门及下级部门
- else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
- sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptList, user.getDeptId(), user.getDeptId()));
- }
- // 仅本人
- else if (DATA_SCOPE_SELF.equals(dataScope)) {
- if (CollectionUtils.isNotEmpty(userList)) {
- sqlString.append(getForeachSql(" OR {}.user_id = {} ", userList, user.getUserId()));
- } else {
- // 数据权限为仅本人且没有userAlias别名不查询任何数据
- sqlString.append(" OR 1=0 ");
- }
- }
+// else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
+// if (scopeCustomIds.size() > 1) {
+// // 多个自定数据权限使用in查询,避免多次拼接。
+// sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptList, String.join(",", scopeCustomIds)));
+// } else {
+// sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptList, role.getRoleId()));
+// }
+// }
+// // 仅本部门
+// else if (DATA_SCOPE_DEPT.equals(dataScope)) {
+// sqlString.append(getForeachSql(" OR {}.dept_id = {} ", deptList, user.getDeptId()));
+// }
+// // 本部门及下级部门
+// else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
+// sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptList, user.getDeptId(), user.getDeptId()));
+// }
+// // 仅本人
+// else if (DATA_SCOPE_SELF.equals(dataScope)) {
+// if (CollectionUtils.isNotEmpty(userList)) {
+// sqlString.append(getForeachSql(" OR {}.user_id = {} ", userList, user.getUserId()));
+// } else {
+// // 数据权限为仅本人且没有userAlias别名不查询任何数据
+// sqlString.append(" OR 1=0 ");
+// }
+// }
// 负责部门数据权限
else if (DATA_SCOPE_LEADER_DEPT.equals(dataScope)) {
String sql = getForeachSql(" OR {}.dept_id in ( SELECT dept_id FROM sys_dept WHERE find_in_set({}, leader_ids) )", deptList, user.getUserId());
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java
index 3a48021..0901952 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/Order.java
@@ -29,6 +29,10 @@ public class Order extends BaseEntity
@ApiModelProperty("订单号")
private String orderNo;
+ @Excel(name = "客户订单号")
+ @ApiModelProperty("客户订单号")
+ private String customOrderNo;
+
@Excel(name = "主图")
@ApiModelProperty("主图")
private String picture;
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderQuery.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderQuery.java
index 49587bd..1c51ae9 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderQuery.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/domain/OrderQuery.java
@@ -37,6 +37,9 @@ public class OrderQuery extends OrderVO{
@ApiModelProperty("精准订单号")
private String eqOrderNo;
+ @ApiModelProperty("精准客户订单号")
+ private String eqCustomOrderNo;
+
@ApiModelProperty("排除的ID")
private Long excludeId;
}
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml
index 129b2b9..1b853bf 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/mapper/OrderMapper.xml
@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select
bo.id,
bo.order_no,
+ bo.custom_order_no,
bo.picture,
bo.delivery_date,
bo.num,
@@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and bo.id = #{query.id}
and bo.order_no like concat('%', #{query.orderNo}, '%')
+ and bo.custom_order_no like concat('%', #{query.customOrderNo}, '%')
and bo.customer like concat('%', #{query.customer}, '%')
and bo.remark like concat('%', #{query.remark}, '%')
and bo.create_by like concat('%', #{query.createBy}, '%')
@@ -39,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
and bo.material like concat('%', #{query.material}, '%')
and bo.id != #{query.excludeId}
and bo.order_no = #{query.eqOrderNo}
+ and bo.custom_order_no = #{query.eqCustomOrderNo}
and bo.package_size like concat('%', #{query.packageSize}, '%')
and bo.name like concat('%', #{query.name}, '%')
@@ -80,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into bst_order
order_no,
+ custom_order_no,
picture,
delivery_date,
num,
@@ -97,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{orderNo},
+ #{customOrderNo},
#{picture},
#{deliveryDate},
#{num},
@@ -134,6 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order_no = #{data.orderNo},
+ custom_order_no = #{data.customOrderNo},
picture = #{data.picture},
delivery_date = #{data.deliveryDate},
num = #{data.num},
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java
index ba5e7e4..3314d8e 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderConverterImpl.java
@@ -45,6 +45,7 @@ public class OrderConverterImpl implements OrderConverter {
bo.setCreateBy(user.getNickName());
bo.setRemark(data.getRemark());
bo.setOrderNo(data.getOrderNo());
+ bo.setCustomOrderNo(data.getCustomOrderNo());
bo.setOrderDate(data.getOrderDate());
bo.setMaterial(data.getMaterial());
bo.setContentNum(data.getContentNum());
@@ -74,6 +75,7 @@ public class OrderConverterImpl implements OrderConverter {
bo.setCustomer(data.getCustomer());
bo.setRemark(data.getRemark());
bo.setOrderNo(data.getOrderNo());
+ bo.setCustomOrderNo(data.getCustomOrderNo());
bo.setOrderDate(data.getOrderDate());
bo.setMaterial(data.getMaterial());
bo.setContentNum(data.getContentNum());
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java
index dcac36f..6e3f071 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/order/service/impl/OrderValidatorImpl.java
@@ -45,6 +45,9 @@ public class OrderValidatorImpl implements OrderValidator {
// 校验订单编号
this.checkOrderNo(data.getId(), data.getOrderNo());
+ // 校验客户订单编号
+ this.checkCustomOrderNo(data.getId(), data.getCustomOrderNo());
+
// 有且仅有一个结束的产品
boolean singleEndProd = this.hasSingleEndProd(data.getProdList());
ServiceUtil.assertion(!singleEndProd, "订单中必须有且仅有一个产品为成品");
@@ -63,6 +66,18 @@ public class OrderValidatorImpl implements OrderValidator {
}
}
+ private void checkCustomOrderNo(Long id, String customOrderNo) {
+ if (StringUtils.isBlank(customOrderNo)) {
+ return;
+ }
+
+ OrderQuery query = new OrderQuery();
+ query.setEqCustomOrderNo(customOrderNo);
+ query.setExcludeId(id);
+ int unique = orderService.selectCount(query);
+ ServiceUtil.assertion(unique > 0, "客户订单编号%s已存在", customOrderNo);
+ }
+
private void checkOrderNo(Long id, String orderNo) {
if (StringUtils.isBlank(orderNo)) {
return;
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java
index 1f50f94..34025ac 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/domain/OrderProd.java
@@ -91,4 +91,10 @@ public class OrderProd extends BaseEntity
@ApiModelProperty("盖子颜色")
@Size(max = 50, message = "盖子颜色长度不能超过50个字符")
private String coverColor;
+
+ @Excel(name = "装量")
+ @ApiModelProperty("装量")
+ @Min(value = 1, message = "装量不能小于1")
+ @NotNull(message = "装量不能为空", groups = {ValidGroup.Create.class})
+ private Integer contentNum;
}
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml
index 96a45a6..908137b 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/mapper/OrderProdMapper.xml
@@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bop.effect,
bop.color,
bop.cover_color,
+ bop.content_num,
bo.order_no as order_no
from bst_order_prod bop
left join bst_order bo on bo.id = bop.order_id
@@ -86,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
effect,
color,
cover_color,
+ content_num,
#{orderId},
@@ -104,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{effect},
#{color},
#{coverColor},
+ #{contentNum},
@@ -126,6 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
effect,
color,
cover_color,
+ content_num,
values
@@ -162,6 +166,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
default,
#{i.coverColor},
default,
+ #{i.contentNum},
+ default,
@@ -329,6 +335,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+
+
+
+ WHEN #{item.id} THEN #{item.contentNum}
+
+
+ WHEN #{item.id} THEN `content_num`
+
+
+
where id in
@@ -377,6 +393,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
effect = #{data.effect},
color = #{data.color},
cover_color = #{data.coverColor},
+ content_num = #{data.contentNum},
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java
index 22ae372..a73f694 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/bst/orderProd/service/impl/OrderProdConverterImpl.java
@@ -53,6 +53,7 @@ public class OrderProdConverterImpl implements OrderProdConverter {
bo.setEffect(prod.getEffect());
bo.setColor(prod.getColor());
bo.setCoverColor(prod.getCoverColor());
+ bo.setContentNum(prod.getContentNum());
bo.setProcessList(prodProcessConverter.toBOListByCreate(prod.getProcessList()));
boList.add(bo);
@@ -87,6 +88,7 @@ public class OrderProdConverterImpl implements OrderProdConverter {
bo.setEffect(prod.getEffect());
bo.setColor(prod.getColor());
bo.setCoverColor(prod.getCoverColor());
+ bo.setContentNum(prod.getContentNum());
bo.setProcessList(prodProcessConverter.toBOListByUpdate(prod.getProcessList()));
boList.add(bo);
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/dept/service/impl/SysDeptServiceImpl.java b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/dept/service/impl/SysDeptServiceImpl.java
index 0ae59a2..9488c17 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/dept/service/impl/SysDeptServiceImpl.java
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/dept/service/impl/SysDeptServiceImpl.java
@@ -211,13 +211,13 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override
public int insertDept(SysDept dept)
{
- SysDept info = deptMapper.selectDeptById(dept.getParentId(), false);
- // 如果父节点不为正常状态,则不允许新增子节点
- if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
- {
- throw new ServiceException("部门停用,不允许新增");
- }
- dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
+// SysDept info = deptMapper.selectDeptById(dept.getParentId(), false);
+// // 如果父节点不为正常状态,则不允许新增子节点
+// if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
+// {
+// throw new ServiceException("部门停用,不允许新增");
+// }
+ dept.setAncestors(String.valueOf(dept.getParentId()));
return deptMapper.insertDept(dept);
}
@@ -231,22 +231,22 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override
public int updateDept(SysDept dept)
{
- SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId(), false);
- SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId(), false);
- if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
- {
- String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
- String oldAncestors = oldDept.getAncestors();
- dept.setAncestors(newAncestors);
- updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
- }
+// SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId(), false);
+// SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId(), false);
+// if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
+// {
+// String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
+// String oldAncestors = oldDept.getAncestors();
+// dept.setAncestors(newAncestors);
+// updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
+// }
int result = deptMapper.updateDept(dept);
- if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
- && !StringUtils.equals("0", dept.getAncestors()))
- {
- // 如果该部门是启用状态,则启用该部门的所有上级部门
- updateParentDeptStatusNormal(dept);
- }
+// if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
+// && !StringUtils.equals("0", dept.getAncestors()))
+// {
+// // 如果该部门是启用状态,则启用该部门的所有上级部门
+// updateParentDeptStatusNormal(dept);
+// }
return result;
}
diff --git a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml
index 1946e3c..469085b 100644
--- a/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml
+++ b/common-ruoyi/ruoyi-system/src/main/java/com/ruoyi/system/user/mapper/SysUserMapper.xml
@@ -162,9 +162,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
u.employ_status,
u.wx_open_id,
d.dept_name,
- d.leader
+ d.leader,
+ r.role_name
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
+ left join sys_user_role ur on u.user_id = ur.user_id
+ left join sys_role r on r.role_id = ur.role_id