This commit is contained in:
磷叶 2025-01-10 17:43:39 +08:00
parent fec8213db8
commit 8084bff2fe
12 changed files with 116 additions and 58 deletions

View File

@ -8,7 +8,6 @@ import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.collection.CollectionUtils;
import com.ruoyi.framework.security.context.PermissionContextHolder; import com.ruoyi.framework.security.context.PermissionContextHolder;
import java.util.ArrayList; import java.util.ArrayList;
@ -105,31 +104,31 @@ public class DataScopeUtil {
break; break;
} }
// 自定义数据范围 // 自定义数据范围
else if (DATA_SCOPE_CUSTOM.equals(dataScope)) { // else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
if (scopeCustomIds.size() > 1) { // if (scopeCustomIds.size() > 1) {
// 多个自定数据权限使用in查询避免多次拼接 // // 多个自定数据权限使用in查询避免多次拼接
sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptList, String.join(",", scopeCustomIds))); // sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id in ({}) ) ", deptList, String.join(",", scopeCustomIds)));
} else { // } else {
sqlString.append(getForeachSql(" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptList, role.getRoleId())); // 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)) { // else if (DATA_SCOPE_DEPT.equals(dataScope)) {
sqlString.append(getForeachSql(" OR {}.dept_id = {} ", deptList, user.getDeptId())); // sqlString.append(getForeachSql(" OR {}.dept_id = {} ", deptList, user.getDeptId()));
} // }
// 本部门及下级部门 // // 本部门及下级部门
else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) { // 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())); // 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)) { // else if (DATA_SCOPE_SELF.equals(dataScope)) {
if (CollectionUtils.isNotEmpty(userList)) { // if (CollectionUtils.isNotEmpty(userList)) {
sqlString.append(getForeachSql(" OR {}.user_id = {} ", userList, user.getUserId())); // sqlString.append(getForeachSql(" OR {}.user_id = {} ", userList, user.getUserId()));
} else { // } else {
// 数据权限为仅本人且没有userAlias别名不查询任何数据 // // 数据权限为仅本人且没有userAlias别名不查询任何数据
sqlString.append(" OR 1=0 "); // sqlString.append(" OR 1=0 ");
} // }
} // }
// 负责部门数据权限 // 负责部门数据权限
else if (DATA_SCOPE_LEADER_DEPT.equals(dataScope)) { 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()); String sql = getForeachSql(" OR {}.dept_id in ( SELECT dept_id FROM sys_dept WHERE find_in_set({}, leader_ids) )", deptList, user.getUserId());

View File

@ -29,6 +29,10 @@ public class Order extends BaseEntity
@ApiModelProperty("订单号") @ApiModelProperty("订单号")
private String orderNo; private String orderNo;
@Excel(name = "客户订单号")
@ApiModelProperty("客户订单号")
private String customOrderNo;
@Excel(name = "主图") @Excel(name = "主图")
@ApiModelProperty("主图") @ApiModelProperty("主图")
private String picture; private String picture;

View File

@ -37,6 +37,9 @@ public class OrderQuery extends OrderVO{
@ApiModelProperty("精准订单号") @ApiModelProperty("精准订单号")
private String eqOrderNo; private String eqOrderNo;
@ApiModelProperty("精准客户订单号")
private String eqCustomOrderNo;
@ApiModelProperty("排除的ID") @ApiModelProperty("排除的ID")
private Long excludeId; private Long excludeId;
} }

View File

@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select select
bo.id, bo.id,
bo.order_no, bo.order_no,
bo.custom_order_no,
bo.picture, bo.picture,
bo.delivery_date, bo.delivery_date,
bo.num, bo.num,
@ -30,6 +31,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="searchCondition"> <sql id="searchCondition">
<if test="query.id != null "> and bo.id = #{query.id}</if> <if test="query.id != null "> and bo.id = #{query.id}</if>
<if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if> <if test="query.orderNo != null and query.orderNo != ''"> and bo.order_no like concat('%', #{query.orderNo}, '%')</if>
<if test="query.customOrderNo != null and query.customOrderNo != ''"> and bo.custom_order_no like concat('%', #{query.customOrderNo}, '%')</if>
<if test="query.customer != null and query.customer != ''"> and bo.customer like concat('%', #{query.customer}, '%')</if> <if test="query.customer != null and query.customer != ''"> and bo.customer like concat('%', #{query.customer}, '%')</if>
<if test="query.remark != null and query.remark != ''"> and bo.remark like concat('%', #{query.remark}, '%')</if> <if test="query.remark != null and query.remark != ''"> and bo.remark like concat('%', #{query.remark}, '%')</if>
<if test="query.createBy != null and query.createBy != ''"> and bo.create_by like concat('%', #{query.createBy}, '%')</if> <if test="query.createBy != null and query.createBy != ''"> and bo.create_by like concat('%', #{query.createBy}, '%')</if>
@ -39,6 +41,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="query.material != null and query.material != ''"> and bo.material like concat('%', #{query.material}, '%')</if> <if test="query.material != null and query.material != ''"> and bo.material like concat('%', #{query.material}, '%')</if>
<if test="query.excludeId != null">and bo.id != #{query.excludeId}</if> <if test="query.excludeId != null">and bo.id != #{query.excludeId}</if>
<if test="query.eqOrderNo != null and query.eqOrderNo != ''">and bo.order_no = #{query.eqOrderNo}</if> <if test="query.eqOrderNo != null and query.eqOrderNo != ''">and bo.order_no = #{query.eqOrderNo}</if>
<if test="query.eqCustomOrderNo != null and query.eqCustomOrderNo != ''">and bo.custom_order_no = #{query.eqCustomOrderNo}</if>
<if test="query.packageSize != null and query.packageSize != ''"> and bo.package_size like concat('%', #{query.packageSize}, '%')</if> <if test="query.packageSize != null and query.packageSize != ''"> and bo.package_size like concat('%', #{query.packageSize}, '%')</if>
<if test="query.name != null and query.name != ''"> and bo.name like concat('%', #{query.name}, '%')</if> <if test="query.name != null and query.name != ''"> and bo.name like concat('%', #{query.name}, '%')</if>
<if test="query.statusList != null and query.statusList.size() > 0"> <if test="query.statusList != null and query.statusList.size() > 0">
@ -80,6 +83,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into bst_order insert into bst_order
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">order_no,</if> <if test="orderNo != null and orderNo != ''">order_no,</if>
<if test="customOrderNo != null">custom_order_no,</if>
<if test="picture != null">picture,</if> <if test="picture != null">picture,</if>
<if test="deliveryDate != null">delivery_date,</if> <if test="deliveryDate != null">delivery_date,</if>
<if test="num != null">num,</if> <if test="num != null">num,</if>
@ -97,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderNo != null and orderNo != ''">#{orderNo},</if> <if test="orderNo != null and orderNo != ''">#{orderNo},</if>
<if test="customOrderNo != null">#{customOrderNo},</if>
<if test="picture != null">#{picture},</if> <if test="picture != null">#{picture},</if>
<if test="deliveryDate != null">#{deliveryDate},</if> <if test="deliveryDate != null">#{deliveryDate},</if>
<if test="num != null">#{num},</if> <if test="num != null">#{num},</if>
@ -134,6 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="updateColumns"> <sql id="updateColumns">
<if test="data.orderNo != null and data.orderNo != ''">order_no = #{data.orderNo},</if> <if test="data.orderNo != null and data.orderNo != ''">order_no = #{data.orderNo},</if>
<if test="data.customOrderNo != null">custom_order_no = #{data.customOrderNo},</if>
<if test="data.picture != null">picture = #{data.picture},</if> <if test="data.picture != null">picture = #{data.picture},</if>
<if test="data.deliveryDate != null">delivery_date = #{data.deliveryDate},</if> <if test="data.deliveryDate != null">delivery_date = #{data.deliveryDate},</if>
<if test="data.num != null">num = #{data.num},</if> <if test="data.num != null">num = #{data.num},</if>

View File

@ -45,6 +45,7 @@ public class OrderConverterImpl implements OrderConverter {
bo.setCreateBy(user.getNickName()); bo.setCreateBy(user.getNickName());
bo.setRemark(data.getRemark()); bo.setRemark(data.getRemark());
bo.setOrderNo(data.getOrderNo()); bo.setOrderNo(data.getOrderNo());
bo.setCustomOrderNo(data.getCustomOrderNo());
bo.setOrderDate(data.getOrderDate()); bo.setOrderDate(data.getOrderDate());
bo.setMaterial(data.getMaterial()); bo.setMaterial(data.getMaterial());
bo.setContentNum(data.getContentNum()); bo.setContentNum(data.getContentNum());
@ -74,6 +75,7 @@ public class OrderConverterImpl implements OrderConverter {
bo.setCustomer(data.getCustomer()); bo.setCustomer(data.getCustomer());
bo.setRemark(data.getRemark()); bo.setRemark(data.getRemark());
bo.setOrderNo(data.getOrderNo()); bo.setOrderNo(data.getOrderNo());
bo.setCustomOrderNo(data.getCustomOrderNo());
bo.setOrderDate(data.getOrderDate()); bo.setOrderDate(data.getOrderDate());
bo.setMaterial(data.getMaterial()); bo.setMaterial(data.getMaterial());
bo.setContentNum(data.getContentNum()); bo.setContentNum(data.getContentNum());

View File

@ -45,6 +45,9 @@ public class OrderValidatorImpl implements OrderValidator {
// 校验订单编号 // 校验订单编号
this.checkOrderNo(data.getId(), data.getOrderNo()); this.checkOrderNo(data.getId(), data.getOrderNo());
// 校验客户订单编号
this.checkCustomOrderNo(data.getId(), data.getCustomOrderNo());
// 有且仅有一个结束的产品 // 有且仅有一个结束的产品
boolean singleEndProd = this.hasSingleEndProd(data.getProdList()); boolean singleEndProd = this.hasSingleEndProd(data.getProdList());
ServiceUtil.assertion(!singleEndProd, "订单中必须有且仅有一个产品为成品"); 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) { private void checkOrderNo(Long id, String orderNo) {
if (StringUtils.isBlank(orderNo)) { if (StringUtils.isBlank(orderNo)) {
return; return;

View File

@ -91,4 +91,10 @@ public class OrderProd extends BaseEntity
@ApiModelProperty("盖子颜色") @ApiModelProperty("盖子颜色")
@Size(max = 50, message = "盖子颜色长度不能超过50个字符") @Size(max = 50, message = "盖子颜色长度不能超过50个字符")
private String coverColor; private String coverColor;
@Excel(name = "装量")
@ApiModelProperty("装量")
@Min(value = 1, message = "装量不能小于1")
@NotNull(message = "装量不能为空", groups = {ValidGroup.Create.class})
private Integer contentNum;
} }

View File

@ -25,6 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
bop.effect, bop.effect,
bop.color, bop.color,
bop.cover_color, bop.cover_color,
bop.content_num,
bo.order_no as order_no bo.order_no as order_no
from bst_order_prod bop from bst_order_prod bop
left join bst_order bo on bo.id = bop.order_id left join bst_order bo on bo.id = bop.order_id
@ -86,6 +87,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="effect != null">effect,</if> <if test="effect != null">effect,</if>
<if test="color != null">color,</if> <if test="color != null">color,</if>
<if test="coverColor != null">cover_color,</if> <if test="coverColor != null">cover_color,</if>
<if test="contentNum != null">content_num,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="orderId != null">#{orderId},</if> <if test="orderId != null">#{orderId},</if>
@ -104,6 +106,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="effect != null">#{effect},</if> <if test="effect != null">#{effect},</if>
<if test="color != null">#{color},</if> <if test="color != null">#{color},</if>
<if test="coverColor != null">#{coverColor},</if> <if test="coverColor != null">#{coverColor},</if>
<if test="contentNum != null">#{contentNum},</if>
</trim> </trim>
</insert> </insert>
@ -126,6 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
effect, effect,
color, color,
cover_color, cover_color,
content_num,
</trim> </trim>
values values
<foreach collection="list" item="i" separator=","> <foreach collection="list" item="i" separator=",">
@ -162,6 +166,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="i.color == null ">default,</if> <if test="i.color == null ">default,</if>
<if test="i.coverColor != null ">#{i.coverColor},</if> <if test="i.coverColor != null ">#{i.coverColor},</if>
<if test="i.coverColor == null ">default,</if> <if test="i.coverColor == null ">default,</if>
<if test="i.contentNum != null ">#{i.contentNum},</if>
<if test="i.contentNum == null ">default,</if>
</trim> </trim>
</foreach> </foreach>
</insert> </insert>
@ -329,6 +335,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</otherwise> </otherwise>
</choose> </choose>
</foreach> </foreach>
<foreach open="content_num = CASE id" collection="list" item="item" close="END,">
<choose>
<when test="item.contentNum != null ">
WHEN #{item.id} THEN #{item.contentNum}
</when>
<otherwise>
WHEN #{item.id} THEN `content_num`
</otherwise>
</choose>
</foreach>
</trim> </trim>
where id in where id in
<foreach item="item" collection="list" open="(" separator="," close=")"> <foreach item="item" collection="list" open="(" separator="," close=")">
@ -377,6 +393,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="data.effect != null">effect = #{data.effect},</if> <if test="data.effect != null">effect = #{data.effect},</if>
<if test="data.color != null">color = #{data.color},</if> <if test="data.color != null">color = #{data.color},</if>
<if test="data.coverColor != null">cover_color = #{data.coverColor},</if> <if test="data.coverColor != null">cover_color = #{data.coverColor},</if>
<if test="data.contentNum != null">content_num = #{data.contentNum},</if>
</sql> </sql>
<delete id="deleteOrderProdById" parameterType="Long"> <delete id="deleteOrderProdById" parameterType="Long">

View File

@ -53,6 +53,7 @@ public class OrderProdConverterImpl implements OrderProdConverter {
bo.setEffect(prod.getEffect()); bo.setEffect(prod.getEffect());
bo.setColor(prod.getColor()); bo.setColor(prod.getColor());
bo.setCoverColor(prod.getCoverColor()); bo.setCoverColor(prod.getCoverColor());
bo.setContentNum(prod.getContentNum());
bo.setProcessList(prodProcessConverter.toBOListByCreate(prod.getProcessList())); bo.setProcessList(prodProcessConverter.toBOListByCreate(prod.getProcessList()));
boList.add(bo); boList.add(bo);
@ -87,6 +88,7 @@ public class OrderProdConverterImpl implements OrderProdConverter {
bo.setEffect(prod.getEffect()); bo.setEffect(prod.getEffect());
bo.setColor(prod.getColor()); bo.setColor(prod.getColor());
bo.setCoverColor(prod.getCoverColor()); bo.setCoverColor(prod.getCoverColor());
bo.setContentNum(prod.getContentNum());
bo.setProcessList(prodProcessConverter.toBOListByUpdate(prod.getProcessList())); bo.setProcessList(prodProcessConverter.toBOListByUpdate(prod.getProcessList()));
boList.add(bo); boList.add(bo);

View File

@ -211,13 +211,13 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override @Override
public int insertDept(SysDept dept) public int insertDept(SysDept dept)
{ {
SysDept info = deptMapper.selectDeptById(dept.getParentId(), false); // SysDept info = deptMapper.selectDeptById(dept.getParentId(), false);
// 如果父节点不为正常状态,则不允许新增子节点 // // 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) // if (!UserConstants.DEPT_NORMAL.equals(info.getStatus()))
{ // {
throw new ServiceException("部门停用,不允许新增"); // throw new ServiceException("部门停用,不允许新增");
} // }
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(String.valueOf(dept.getParentId()));
return deptMapper.insertDept(dept); return deptMapper.insertDept(dept);
} }
@ -231,22 +231,22 @@ public class SysDeptServiceImpl implements ISysDeptService
@Override @Override
public int updateDept(SysDept dept) public int updateDept(SysDept dept)
{ {
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId(), false); // SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId(), false);
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId(), false); // SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId(), false);
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) // if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept))
{ // {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); // String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors(); // String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors); // dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors); // updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
} // }
int result = deptMapper.updateDept(dept); int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) // if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors())) // && !StringUtils.equals("0", dept.getAncestors()))
{ // {
// 如果该部门是启用状态则启用该部门的所有上级部门 // // 如果该部门是启用状态则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept); // updateParentDeptStatusNormal(dept);
} // }
return result; return result;
} }

View File

@ -162,9 +162,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
u.employ_status, u.employ_status,
u.wx_open_id, u.wx_open_id,
d.dept_name, d.dept_name,
d.leader d.leader,
r.role_name
from sys_user u from sys_user u
left join sys_dept d on u.dept_id = d.dept_id 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
</sql> </sql>
<select id="selectUserList" parameterType="SysUserQuery" resultMap="SysUserResult"> <select id="selectUserList" parameterType="SysUserQuery" resultMap="SysUserResult">

View File

@ -127,15 +127,16 @@ public class SysDeptController extends BaseController
@DeleteMapping("/{deptId}") @DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId) public AjaxResult remove(@PathVariable Long deptId)
{ {
if (deptService.hasChildByDeptId(deptId)) // if (deptService.hasChildByDeptId(deptId))
{ // {
return warn("存在下级部门,不允许删除"); // return warn("存在下级部门,不允许删除");
} // }
if (deptService.checkDeptExistUser(deptId)) // if (deptService.checkDeptExistUser(deptId))
{ // {
return warn("部门存在用户,不允许删除"); // return warn("部门存在用户,不允许删除");
} // }
deptService.checkDeptDataScope(deptId); // deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId)); return toAjax(deptService.deleteDeptById(deptId));
} }
} }