Browse Source

验货单申请

master
常熟吴彦祖 2 months ago
parent
commit
b23e959404
  1. 6
      src/main/java/com/xujie/modules/inspection/data/InspectionRequestItemVO.java
  2. 3
      src/main/java/com/xujie/modules/inspection/entity/InspectionRequestHeader.java
  3. 33
      src/main/java/com/xujie/modules/inspection/service/impl/InspectionRequestServiceImpl.java
  4. 16
      src/main/resources/mapper/inspection/InspectionRequestHeaderMapper.xml

6
src/main/java/com/xujie/modules/inspection/data/InspectionRequestItemVO.java

@ -106,6 +106,12 @@ public class InspectionRequestItemVO extends QueryPage {
*/
private String planner;
/** 内部验货申请页的本人 Planner 查询范围开关 - rqrq */
private Boolean currentPlannerOnly;
/** 精确筛选账号,由 Service 从登录会话覆盖,不能使用 Planner 显示名称 - rqrq */
private String plannerAccount;
/**
* 供应商可申请验货PO明细数量
*/

3
src/main/java/com/xujie/modules/inspection/entity/InspectionRequestHeader.java

@ -92,6 +92,9 @@ public class InspectionRequestHeader extends QueryPage {
// 以下为前端查询条件扩展字段(非数据库字段)
private String supplierName; // 供应商名称
private String plannerAccount; // Planner账号(精确筛选)
/** 内部验货申请页按当前登录账号限定 Planner;供应商及其他页面不启用 - rqrq */
@TableField(exist = false)
private Boolean currentPlannerOnly;
private String requestDateStart; // 申请日期开始
private String requestDateEnd; // 申请日期结束
private String needInspectDateStart; // 建议验货日期开始

33
src/main/java/com/xujie/modules/inspection/service/impl/InspectionRequestServiceImpl.java

@ -97,6 +97,10 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH
@Override
public PageUtils myPage(InspectionRequestHeader data){
// rqrq - 只在内部申请页覆盖精确账号;其他共用页面保留原查询条件。
if (Boolean.TRUE.equals(data.getCurrentPlannerOnly())) {
data.setPlannerAccount(resolveCurrentPlannerAccount(data.getCurrentPlannerOnly()));
}
// 强制使用当前登录工厂,避免前端漏传 site 导致跨工厂数据
SysUserEntity currentUser = (SysUserEntity) SecurityUtils.getSubject().getPrincipal();
if (currentUser == null || !StringUtils.hasText(currentUser.getSite())) {
@ -125,6 +129,8 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH
if (data == null || !StringUtils.hasText(data.getSite())) {
throw new RuntimeException("请前端传site");
}
// rqrq - 服务端限定本人订单;供应商模式不增加 Planner 条件。
data.setPlannerAccount(resolveCurrentPlannerAccount(data.getCurrentPlannerOnly()));
IPage<InspectionRequestItemVO> page =
baseMapper.queryPoPage(new Page<>(data.getPage(), data.getLimit()), data);
return new PageUtils(page);
@ -136,6 +142,8 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH
if (data == null || !StringUtils.hasText(data.getSite())) {
throw new RuntimeException("请前端传site");
}
// rqrq - 补选 PO 与初次选择采用相同的本人范围。
data.setPlannerAccount(resolveCurrentPlannerAccount(data.getCurrentPlannerOnly()));
IPage<InspectionRequestItemVO> page =
baseMapper.queryPoPageExclude(new Page<>(data.getPage(), data.getLimit()), data);
return new PageUtils(page);
@ -147,6 +155,8 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH
if (data == null || !StringUtils.hasText(data.getSite())) {
throw new RuntimeException("请前端传site");
}
// rqrq - 供应商归属按供应商主档 Planner 的账号精确筛选。
data.setPlannerAccount(resolveCurrentPlannerAccount(data.getCurrentPlannerOnly()));
IPage<InspectionRequestItemVO> page =
baseMapper.queryPoSupplierPage(new Page<>(data.getPage(), data.getLimit()), data);
return new PageUtils(page);
@ -158,11 +168,34 @@ public class InspectionRequestServiceImpl extends ServiceImpl<InspectionRequestH
if (data == null || !StringUtils.hasText(data.getSite())) {
throw new RuntimeException("请前端传site");
}
// rqrq - 从订单选择供应商按订单头 Planner 的账号精确筛选。
data.setPlannerAccount(resolveCurrentPlannerAccount(data.getCurrentPlannerOnly()));
IPage<InspectionRequestItemVO> page =
baseMapper.queryPoSupplierOrderPage(new Page<>(data.getPage(), data.getLimit()), data);
return new PageUtils(page);
}
/**
* 解析内部验货申请页的本人 Planner 查询范围 - rqrq。
* 前置条件:调用方已校验业务查询参数;开关仅由内部申请页面启用。
* 步骤:未启用时返回 null 保持共用查询逻辑;启用时读取登录用户 username。
* 此方法只构建查询条件,不写库、不开启事务;缺少有效登录账号时拒绝查询,
* 防止空账号导致精确筛选条件被省略。中文显示名及客户端传入账号均不参与授权范围。
*/
private String resolveCurrentPlannerAccount(Boolean currentPlannerOnly) {
// rqrq - 供应商及其他页面不增加本人 Planner 限制。
if (!Boolean.TRUE.equals(currentPlannerOnly)) {
return null;
}
Object principal = SecurityUtils.getSubject().getPrincipal();
// rqrq - 未登录时不能退化为查询所有 Planner 的数据。
if (!(principal instanceof SysUserEntity)
|| !StringUtils.hasText(((SysUserEntity) principal).getUsername())) {
throw new RuntimeException("当前登录账号不能为空");
}
return ((SysUserEntity) principal).getUsername().trim();
}
@Transactional(rollbackFor = Exception.class)
@Override
public void saveRequest(InspectionRequestSaveVO vo) {

16
src/main/resources/mapper/inspection/InspectionRequestHeaderMapper.xml

@ -110,6 +110,10 @@
ON pod.part_no = p.part_no
AND pod.site = p.site
WHERE pod.site = #{query.site}
<!-- rqrq - 内部申请页面按登录账号精确限定归属,空 Planner 不匹配 -->
<if test="query.plannerAccount != null and query.plannerAccount != ''">
AND poh.c_planner = #{query.plannerAccount}
</if>
AND poh.order_type = 'PO'
AND ISNULL(poh.status, '') NOT IN ('Draft','Shipped','Closed','Cancelled','草稿','已发货','已关闭','已取消')
AND (
@ -196,6 +200,10 @@
ON pod.part_no = p.part_no
AND pod.site = p.site
WHERE pod.site = #{query.site}
<!-- rqrq - 内部申请页面按登录账号精确限定归属,空 Planner 不匹配 -->
<if test="query.plannerAccount != null and query.plannerAccount != ''">
AND poh.c_planner = #{query.plannerAccount}
</if>
AND ISNULL(poh.status, '') NOT IN ('Draft','Shipped','Closed','Cancelled','草稿','已发货','已关闭','已取消')
AND (
ISNULL(pod.qty, 0)
@ -289,6 +297,10 @@
ON pod.part_no = p.part_no
AND pod.site = p.site
WHERE pod.site = #{query.site}
<!-- rqrq - 内部申请页面按登录账号精确限定归属,空 Planner 不匹配 -->
<if test="query.plannerAccount != null and query.plannerAccount != ''">
AND poh.c_planner = #{query.plannerAccount}
</if>
AND poh.order_type = 'PO'
AND ISNULL(poh.status, '') NOT IN ('Draft','Shipped','Closed','Cancelled','草稿','已发货','已关闭','已取消')
AND (
@ -347,6 +359,10 @@
ON ss.site = pod.site
AND ss.supplier_no = poh.supplier_no
WHERE pod.site = #{query.site}
<!-- rqrq - 内部申请页面按登录账号精确限定归属,空 Planner 不匹配 -->
<if test="query.plannerAccount != null and query.plannerAccount != ''">
AND ss.planner = #{query.plannerAccount}
</if>
AND poh.order_type = 'PO'
AND ISNULL(poh.status, '') NOT IN ('Draft','Shipped','Closed','Cancelled','草稿','已发货','已关闭','已取消')
AND (

Loading…
Cancel
Save