Showing
21 changed files
with
485 additions
and
4 deletions
| @@ -2,6 +2,8 @@ package com.lframework.xingyun.sc.procurement.controller.buyoutAccount; | @@ -2,6 +2,8 @@ package com.lframework.xingyun.sc.procurement.controller.buyoutAccount; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.io.resource.ClassPathResource; | 3 | import cn.hutool.core.io.resource.ClassPathResource; |
| 4 | import com.lframework.starter.web.core.annotations.security.HasPermission; | 4 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 5 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | ||
| 6 | +import com.lframework.xingyun.sc.utils.PurchaseDataScopeUtil; | ||
| 5 | import com.lframework.starter.web.core.components.resp.InvokeResult; | 7 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 6 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | 8 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| 7 | import com.lframework.starter.web.core.components.resp.PageResult; | 9 | import com.lframework.starter.web.core.components.resp.PageResult; |
| @@ -77,11 +79,24 @@ public class ProcurementBuyoutAccountOrderController extends DefaultBaseControll | @@ -77,11 +79,24 @@ public class ProcurementBuyoutAccountOrderController extends DefaultBaseControll | ||
| 77 | @Resource | 79 | @Resource |
| 78 | private ProcurementBuyoutAccountOrderService buyoutAccountOrderService; | 80 | private ProcurementBuyoutAccountOrderService buyoutAccountOrderService; |
| 79 | 81 | ||
| 82 | + @Resource | ||
| 83 | + private PurchaseDataScopeUtil purchaseDataScopeUtil; | ||
| 84 | + | ||
| 80 | @ApiOperation("分页查询买断入库核算单") | 85 | @ApiOperation("分页查询买断入库核算单") |
| 81 | @HasPermission({"warehouse-manage:outright-purchase:query"}) | 86 | @HasPermission({"warehouse-manage:outright-purchase:query"}) |
| 82 | @GetMapping("/query") | 87 | @GetMapping("/query") |
| 83 | public InvokeResult<PageResult<GetBuyoutAccountOrderBo>> query( | 88 | public InvokeResult<PageResult<GetBuyoutAccountOrderBo>> query( |
| 84 | @Valid QueryBuyoutAccountOrderVo vo) { | 89 | @Valid QueryBuyoutAccountOrderVo vo) { |
| 90 | + // 采购处侧角色数据权限:Java层先算好角色与部门,SQL仅做常量IN过滤,避免关联子查询影响查询速度 | ||
| 91 | + String curUserId = SecurityUtil.getCurrentUser().getId(); | ||
| 92 | + boolean purchaseScope = purchaseDataScopeUtil.hasAnyRole(curUserId, | ||
| 93 | + PurchaseDataScopeUtil.PURCHASE_DEPT_ROLE_CODES); | ||
| 94 | + boolean regionScope = purchaseDataScopeUtil.hasAnyRole(curUserId, PurchaseDataScopeUtil.REGION_ROLE_CODES); | ||
| 95 | + if (purchaseScope || regionScope) { | ||
| 96 | + vo.setScopePurchase(purchaseScope); | ||
| 97 | + vo.setScopeRegion(regionScope); | ||
| 98 | + vo.setScopeDeptIds(purchaseDataScopeUtil.getDeptIds(curUserId)); | ||
| 99 | + } | ||
| 85 | PageResult<ProcurementBuyoutAccountOrder> result = buyoutAccountOrderService.query( | 100 | PageResult<ProcurementBuyoutAccountOrder> result = buyoutAccountOrderService.query( |
| 86 | getPageIndex(vo), getPageSize(vo), vo); | 101 | getPageIndex(vo), getPageSize(vo), vo); |
| 87 | 102 |
| @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.procurement.controller.settle; | @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.procurement.controller.settle; | ||
| 3 | import cn.hutool.core.io.resource.ClassPathResource; | 3 | import cn.hutool.core.io.resource.ClassPathResource; |
| 4 | import com.lframework.starter.common.utils.StringUtil; | 4 | import com.lframework.starter.common.utils.StringUtil; |
| 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; | 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 6 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | ||
| 7 | +import com.lframework.xingyun.sc.utils.PurchaseDataScopeUtil; | ||
| 6 | import com.lframework.starter.web.core.components.resp.InvokeResult; | 8 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 7 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | 9 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| 8 | import com.lframework.starter.web.core.components.resp.PageResult; | 10 | import com.lframework.starter.web.core.components.resp.PageResult; |
| @@ -92,11 +94,24 @@ public class ProcurementMaterialSettleDetailController extends DefaultBaseContro | @@ -92,11 +94,24 @@ public class ProcurementMaterialSettleDetailController extends DefaultBaseContro | ||
| 92 | @Resource | 94 | @Resource |
| 93 | private ProcurementMaterialSettleDetailService procurementMaterialSettleDetailService; | 95 | private ProcurementMaterialSettleDetailService procurementMaterialSettleDetailService; |
| 94 | 96 | ||
| 97 | + @Resource | ||
| 98 | + private PurchaseDataScopeUtil purchaseDataScopeUtil; | ||
| 99 | + | ||
| 95 | @ApiOperation("分页查询原料结算详情单") | 100 | @ApiOperation("分页查询原料结算详情单") |
| 96 | @HasPermission({"warehouse-manage:material-settlement:query"}) | 101 | @HasPermission({"warehouse-manage:material-settlement:query"}) |
| 97 | @GetMapping("/query") | 102 | @GetMapping("/query") |
| 98 | public InvokeResult<PageResult<GetProcurementMaterialSettleDetailBo>> query( | 103 | public InvokeResult<PageResult<GetProcurementMaterialSettleDetailBo>> query( |
| 99 | @Valid QueryProcurementMaterialSettleDetailVo vo) { | 104 | @Valid QueryProcurementMaterialSettleDetailVo vo) { |
| 105 | + // 采购处侧角色数据权限:Java层先算好角色与部门,SQL仅做常量IN过滤,避免关联子查询影响查询速度 | ||
| 106 | + String curUserId = SecurityUtil.getCurrentUser().getId(); | ||
| 107 | + boolean purchaseScope = purchaseDataScopeUtil.hasAnyRole(curUserId, | ||
| 108 | + PurchaseDataScopeUtil.PURCHASE_DEPT_ROLE_CODES); | ||
| 109 | + boolean regionScope = purchaseDataScopeUtil.hasAnyRole(curUserId, PurchaseDataScopeUtil.REGION_ROLE_CODES); | ||
| 110 | + if (purchaseScope || regionScope) { | ||
| 111 | + vo.setScopePurchase(purchaseScope); | ||
| 112 | + vo.setScopeRegion(regionScope); | ||
| 113 | + vo.setScopeDeptIds(purchaseDataScopeUtil.getDeptIds(curUserId)); | ||
| 114 | + } | ||
| 100 | PageResult<ProcurementMaterialSettleDetail> result = procurementMaterialSettleDetailService.query( | 115 | PageResult<ProcurementMaterialSettleDetail> result = procurementMaterialSettleDetailService.query( |
| 101 | getPageIndex(vo), getPageSize(vo), vo); | 116 | getPageIndex(vo), getPageSize(vo), vo); |
| 102 | 117 |
| @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.procurement.controller.weighing; | @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.procurement.controller.weighing; | ||
| 3 | import cn.hutool.core.io.resource.ClassPathResource; | 3 | import cn.hutool.core.io.resource.ClassPathResource; |
| 4 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; | 4 | import com.lframework.starter.common.exceptions.impl.DefaultClientException; |
| 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; | 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 6 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | ||
| 7 | +import com.lframework.xingyun.sc.utils.PurchaseDataScopeUtil; | ||
| 6 | import com.lframework.starter.web.core.components.resp.InvokeResult; | 8 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 7 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | 9 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| 8 | import com.lframework.starter.web.core.components.resp.PageResult; | 10 | import com.lframework.starter.web.core.components.resp.PageResult; |
| @@ -110,11 +112,24 @@ public class ProcurementAssayReportController extends DefaultBaseController { | @@ -110,11 +112,24 @@ public class ProcurementAssayReportController extends DefaultBaseController { | ||
| 110 | @Resource | 112 | @Resource |
| 111 | private ProcurementAssayReportService procurementAssayReportService; | 113 | private ProcurementAssayReportService procurementAssayReportService; |
| 112 | 114 | ||
| 115 | + @Resource | ||
| 116 | + private PurchaseDataScopeUtil purchaseDataScopeUtil; | ||
| 117 | + | ||
| 113 | @ApiOperation("分页查询原料化验报告单") | 118 | @ApiOperation("分页查询原料化验报告单") |
| 114 | @HasPermission({"warehouse-manage:material-test:query"}) | 119 | @HasPermission({"warehouse-manage:material-test:query"}) |
| 115 | @GetMapping("/query") | 120 | @GetMapping("/query") |
| 116 | public InvokeResult<PageResult<GetProcurementAssayReportBo>> query( | 121 | public InvokeResult<PageResult<GetProcurementAssayReportBo>> query( |
| 117 | @Valid QueryProcurementAssayReportVo vo) { | 122 | @Valid QueryProcurementAssayReportVo vo) { |
| 123 | + // 采购处侧角色数据权限:Java层先算好角色与部门,SQL仅做常量IN过滤,避免关联子查询影响查询速度 | ||
| 124 | + String curUserId = SecurityUtil.getCurrentUser().getId(); | ||
| 125 | + boolean purchaseScope = purchaseDataScopeUtil.hasAnyRole(curUserId, | ||
| 126 | + PurchaseDataScopeUtil.PURCHASE_DEPT_ROLE_CODES); | ||
| 127 | + boolean regionScope = purchaseDataScopeUtil.hasAnyRole(curUserId, PurchaseDataScopeUtil.REGION_ROLE_CODES); | ||
| 128 | + if (purchaseScope || regionScope) { | ||
| 129 | + vo.setScopePurchase(purchaseScope); | ||
| 130 | + vo.setScopeRegion(regionScope); | ||
| 131 | + vo.setScopeDeptIds(purchaseDataScopeUtil.getDeptIds(curUserId)); | ||
| 132 | + } | ||
| 118 | PageResult<ProcurementAssayReport> result = procurementAssayReportService.query( | 133 | PageResult<ProcurementAssayReport> result = procurementAssayReportService.query( |
| 119 | getPageIndex(vo), getPageSize(vo), vo); | 134 | getPageIndex(vo), getPageSize(vo), vo); |
| 120 | 135 |
| @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.procurement.controller.weighing; | @@ -3,6 +3,8 @@ package com.lframework.xingyun.sc.procurement.controller.weighing; | ||
| 3 | import cn.hutool.core.convert.NumberChineseFormatter; | 3 | import cn.hutool.core.convert.NumberChineseFormatter; |
| 4 | import cn.hutool.core.io.resource.ClassPathResource; | 4 | import cn.hutool.core.io.resource.ClassPathResource; |
| 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; | 5 | import com.lframework.starter.web.core.annotations.security.HasPermission; |
| 6 | +import com.lframework.starter.web.core.components.security.SecurityUtil; | ||
| 7 | +import com.lframework.xingyun.sc.utils.PurchaseDataScopeUtil; | ||
| 6 | import com.lframework.starter.web.core.components.resp.InvokeResult; | 8 | import com.lframework.starter.web.core.components.resp.InvokeResult; |
| 7 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; | 9 | import com.lframework.starter.web.core.components.resp.InvokeResultBuilder; |
| 8 | import com.lframework.starter.web.core.components.resp.PageResult; | 10 | import com.lframework.starter.web.core.components.resp.PageResult; |
| @@ -72,11 +74,24 @@ public class ProcurementWeighingTicketController extends DefaultBaseController { | @@ -72,11 +74,24 @@ public class ProcurementWeighingTicketController extends DefaultBaseController { | ||
| 72 | @Resource | 74 | @Resource |
| 73 | private ProcurementWeighingTicketService procurementWeighingTicketService; | 75 | private ProcurementWeighingTicketService procurementWeighingTicketService; |
| 74 | 76 | ||
| 77 | + @Resource | ||
| 78 | + private PurchaseDataScopeUtil purchaseDataScopeUtil; | ||
| 79 | + | ||
| 75 | @ApiOperation("分页查询过磅码单") | 80 | @ApiOperation("分页查询过磅码单") |
| 76 | @HasPermission({"warehouse-manage:weight-ticket:query"}) | 81 | @HasPermission({"warehouse-manage:weight-ticket:query"}) |
| 77 | @GetMapping("/query") | 82 | @GetMapping("/query") |
| 78 | public InvokeResult<PageResult<ProcurementWeighingTicket>> query( | 83 | public InvokeResult<PageResult<ProcurementWeighingTicket>> query( |
| 79 | @Valid QueryProcurementWeighingTicketVo vo) { | 84 | @Valid QueryProcurementWeighingTicketVo vo) { |
| 85 | + // 采购处侧角色数据权限:Java层先算好角色与部门,SQL仅做常量IN过滤,避免关联子查询影响查询速度 | ||
| 86 | + String curUserId = SecurityUtil.getCurrentUser().getId(); | ||
| 87 | + boolean purchaseScope = purchaseDataScopeUtil.hasAnyRole(curUserId, | ||
| 88 | + PurchaseDataScopeUtil.PURCHASE_DEPT_ROLE_CODES); | ||
| 89 | + boolean regionScope = purchaseDataScopeUtil.hasAnyRole(curUserId, PurchaseDataScopeUtil.REGION_ROLE_CODES); | ||
| 90 | + if (purchaseScope || regionScope) { | ||
| 91 | + vo.setScopePurchase(purchaseScope); | ||
| 92 | + vo.setScopeRegion(regionScope); | ||
| 93 | + vo.setScopeDeptIds(purchaseDataScopeUtil.getDeptIds(curUserId)); | ||
| 94 | + } | ||
| 80 | PageResult<ProcurementWeighingTicket> result = procurementWeighingTicketService.query( | 95 | PageResult<ProcurementWeighingTicket> result = procurementWeighingTicketService.query( |
| 81 | getPageIndex(vo), getPageSize(vo), vo); | 96 | getPageIndex(vo), getPageSize(vo), vo); |
| 82 | return InvokeResultBuilder.success(result); | 97 | return InvokeResultBuilder.success(result); |
| @@ -184,7 +184,10 @@ public class ProcurementBuyoutAccountOrderServiceImpl | @@ -184,7 +184,10 @@ public class ProcurementBuyoutAccountOrderServiceImpl | ||
| 184 | public PageResult<ProcurementBuyoutAccountOrder> query(Integer pageIndex, Integer pageSize, | 184 | public PageResult<ProcurementBuyoutAccountOrder> query(Integer pageIndex, Integer pageSize, |
| 185 | QueryBuyoutAccountOrderVo vo) { | 185 | QueryBuyoutAccountOrderVo vo) { |
| 186 | PageHelperUtil.startPage(pageIndex, pageSize); | 186 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 187 | - List<ProcurementBuyoutAccountOrder> datas = buyoutAccountOrderMapper.query(vo); | 187 | + // 采购处侧角色(Controller 已注入 scope 参数):走专用查询,按采购处/区域过滤,与数据权限框架分开 |
| 188 | + List<ProcurementBuyoutAccountOrder> datas = | ||
| 189 | + vo.getScopePurchase() != null || vo.getScopeRegion() != null | ||
| 190 | + ? buyoutAccountOrderMapper.queryPurchaseScope(vo) : buyoutAccountOrderMapper.query(vo); | ||
| 188 | PageResult<ProcurementBuyoutAccountOrder> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); | 191 | PageResult<ProcurementBuyoutAccountOrder> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); |
| 189 | 192 | ||
| 190 | fillOperateFlags(pageResult.getDatas()); | 193 | fillOperateFlags(pageResult.getDatas()); |
| @@ -148,7 +148,10 @@ public class ProcurementMaterialSettleDetailServiceImpl | @@ -148,7 +148,10 @@ public class ProcurementMaterialSettleDetailServiceImpl | ||
| 148 | public PageResult<ProcurementMaterialSettleDetail> query(Integer pageIndex, Integer pageSize, | 148 | public PageResult<ProcurementMaterialSettleDetail> query(Integer pageIndex, Integer pageSize, |
| 149 | QueryProcurementMaterialSettleDetailVo vo) { | 149 | QueryProcurementMaterialSettleDetailVo vo) { |
| 150 | PageHelperUtil.startPage(pageIndex, pageSize); | 150 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 151 | - List<ProcurementMaterialSettleDetail> datas = settleDetailMapper.query(vo); | 151 | + // 采购处侧角色(Controller 已注入 scope 参数):走专用查询,按采购处/区域过滤,与数据权限框架分开 |
| 152 | + List<ProcurementMaterialSettleDetail> datas = | ||
| 153 | + vo.getScopePurchase() != null || vo.getScopeRegion() != null | ||
| 154 | + ? settleDetailMapper.queryPurchaseScope(vo) : settleDetailMapper.query(vo); | ||
| 152 | PageResult<ProcurementMaterialSettleDetail> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); | 155 | PageResult<ProcurementMaterialSettleDetail> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); |
| 153 | 156 | ||
| 154 | fillOperateFlags(pageResult.getDatas()); | 157 | fillOperateFlags(pageResult.getDatas()); |
| @@ -153,7 +153,10 @@ public class ProcurementAssayReportServiceImpl | @@ -153,7 +153,10 @@ public class ProcurementAssayReportServiceImpl | ||
| 153 | public PageResult<ProcurementAssayReport> query(Integer pageIndex, Integer pageSize, | 153 | public PageResult<ProcurementAssayReport> query(Integer pageIndex, Integer pageSize, |
| 154 | QueryProcurementAssayReportVo vo) { | 154 | QueryProcurementAssayReportVo vo) { |
| 155 | PageHelperUtil.startPage(pageIndex, pageSize); | 155 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 156 | - List<ProcurementAssayReport> datas = assayReportMapper.query(vo); | 156 | + // 采购处侧角色(Controller 已注入 scope 参数):走专用查询,按采购处/区域过滤,与数据权限框架分开 |
| 157 | + List<ProcurementAssayReport> datas = | ||
| 158 | + vo.getScopePurchase() != null || vo.getScopeRegion() != null | ||
| 159 | + ? assayReportMapper.queryPurchaseScope(vo) : assayReportMapper.query(vo); | ||
| 157 | PageResult<ProcurementAssayReport> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); | 160 | PageResult<ProcurementAssayReport> pageResult = PageResultUtil.convert(new PageInfo<>(datas)); |
| 158 | 161 | ||
| 159 | fillOperateFlags(pageResult.getDatas()); | 162 | fillOperateFlags(pageResult.getDatas()); |
| @@ -134,7 +134,10 @@ public class ProcurementWeighingTicketServiceImpl | @@ -134,7 +134,10 @@ public class ProcurementWeighingTicketServiceImpl | ||
| 134 | Assert.greaterThanZero(pageSize); | 134 | Assert.greaterThanZero(pageSize); |
| 135 | 135 | ||
| 136 | PageHelperUtil.startPage(pageIndex, pageSize); | 136 | PageHelperUtil.startPage(pageIndex, pageSize); |
| 137 | - List<ProcurementWeighingTicket> datas = this.query(vo); | 137 | + // 采购处侧角色(Controller 已注入 scope 参数):走专用查询,按采购处/区域过滤,与数据权限框架分开 |
| 138 | + List<ProcurementWeighingTicket> datas = | ||
| 139 | + vo.getScopePurchase() != null || vo.getScopeRegion() != null | ||
| 140 | + ? weighingTicketMapper.queryPurchaseScope(vo) : this.query(vo); | ||
| 138 | if (CollectionUtil.isNotEmpty(datas)) { | 141 | if (CollectionUtil.isNotEmpty(datas)) { |
| 139 | fillOperateFlags(datas); | 142 | fillOperateFlags(datas); |
| 140 | } | 143 | } |
| @@ -22,6 +22,12 @@ public interface ProcurementBuyoutAccountOrderMapper | @@ -22,6 +22,12 @@ public interface ProcurementBuyoutAccountOrderMapper | ||
| 22 | List<ProcurementBuyoutAccountOrder> query(@Param("vo") QueryBuyoutAccountOrderVo vo); | 22 | List<ProcurementBuyoutAccountOrder> query(@Param("vo") QueryBuyoutAccountOrderVo vo); |
| 23 | 23 | ||
| 24 | /** | 24 | /** |
| 25 | + * 采购处侧角色专用查询(无数据权限注解,Service 层按角色分流调用): | ||
| 26 | + * 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域 | ||
| 27 | + */ | ||
| 28 | + List<ProcurementBuyoutAccountOrder> queryPurchaseScope(@Param("vo") QueryBuyoutAccountOrderVo vo); | ||
| 29 | + | ||
| 30 | + /** | ||
| 25 | * 单条查询(联表带出分厂编号 workshopCode;实体传给流程引擎/分厂审核节点路由前必须用此方法) | 31 | * 单条查询(联表带出分厂编号 workshopCode;实体传给流程引擎/分厂审核节点路由前必须用此方法) |
| 26 | */ | 32 | */ |
| 27 | ProcurementBuyoutAccountOrder findById(@Param("id") String id); | 33 | ProcurementBuyoutAccountOrder findById(@Param("id") String id); |
| @@ -26,6 +26,13 @@ public interface ProcurementMaterialSettleDetailMapper | @@ -26,6 +26,13 @@ public interface ProcurementMaterialSettleDetailMapper | ||
| 26 | @Param("vo") QueryProcurementMaterialSettleDetailVo vo); | 26 | @Param("vo") QueryProcurementMaterialSettleDetailVo vo); |
| 27 | 27 | ||
| 28 | /** | 28 | /** |
| 29 | + * 采购处侧角色专用查询(无数据权限注解,Service 层按角色分流调用): | ||
| 30 | + * 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域 | ||
| 31 | + */ | ||
| 32 | + List<ProcurementMaterialSettleDetail> queryPurchaseScope( | ||
| 33 | + @Param("vo") QueryProcurementMaterialSettleDetailVo vo); | ||
| 34 | + | ||
| 35 | + /** | ||
| 29 | * 分页查询可制单的过磅码单(审核通过 + 已上传签字凭证 + 码单下每个过磅品种都要有原料化验报告单且全部审核通过,选择码单弹窗) | 36 | * 分页查询可制单的过磅码单(审核通过 + 已上传签字凭证 + 码单下每个过磅品种都要有原料化验报告单且全部审核通过,选择码单弹窗) |
| 30 | */ | 37 | */ |
| 31 | @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | 38 | @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { |
| @@ -24,6 +24,12 @@ public interface ProcurementAssayReportMapper extends BaseMapper<ProcurementAssa | @@ -24,6 +24,12 @@ public interface ProcurementAssayReportMapper extends BaseMapper<ProcurementAssa | ||
| 24 | List<ProcurementAssayReport> query(@Param("vo") QueryProcurementAssayReportVo vo); | 24 | List<ProcurementAssayReport> query(@Param("vo") QueryProcurementAssayReportVo vo); |
| 25 | 25 | ||
| 26 | /** | 26 | /** |
| 27 | + * 采购处侧角色专用查询(无数据权限注解,Service 层按角色分流调用): | ||
| 28 | + * 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域 | ||
| 29 | + */ | ||
| 30 | + List<ProcurementAssayReport> queryPurchaseScope(@Param("vo") QueryProcurementAssayReportVo vo); | ||
| 31 | + | ||
| 32 | + /** | ||
| 27 | * 分页查询可制单的过磅码单(审核通过 + 已上传签字凭证 + 码单下每个过磅品种都有化验送样单且全部审核通过,选择码单弹窗) | 33 | * 分页查询可制单的过磅码单(审核通过 + 已上传签字凭证 + 码单下每个过磅品种都有化验送样单且全部审核通过,选择码单弹窗) |
| 28 | */ | 34 | */ |
| 29 | @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { | 35 | @DataPermissions(type = OrderDataPermissionDataPermissionType.class, value = { |
| @@ -20,6 +20,12 @@ public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementW | @@ -20,6 +20,12 @@ public interface ProcurementWeighingTicketMapper extends BaseMapper<ProcurementW | ||
| 20 | }) | 20 | }) |
| 21 | List<ProcurementWeighingTicket> query(@Param("vo") QueryProcurementWeighingTicketVo vo); | 21 | List<ProcurementWeighingTicket> query(@Param("vo") QueryProcurementWeighingTicketVo vo); |
| 22 | 22 | ||
| 23 | + /** | ||
| 24 | + * 采购处侧角色专用查询(无数据权限注解,Service 层按角色分流调用): | ||
| 25 | + * 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域 | ||
| 26 | + */ | ||
| 27 | + List<ProcurementWeighingTicket> queryPurchaseScope(@Param("vo") QueryProcurementWeighingTicketVo vo); | ||
| 28 | + | ||
| 23 | ProcurementWeighingTicket findById(@Param("id") String id); | 29 | ProcurementWeighingTicket findById(@Param("id") String id); |
| 24 | 30 | ||
| 25 | /** | 31 | /** |
| @@ -10,6 +10,7 @@ import lombok.Data; | @@ -10,6 +10,7 @@ import lombok.Data; | ||
| 10 | 10 | ||
| 11 | import java.io.Serializable; | 11 | import java.io.Serializable; |
| 12 | import java.time.LocalDateTime; | 12 | import java.time.LocalDateTime; |
| 13 | +import java.util.List; | ||
| 13 | 14 | ||
| 14 | @Data | 15 | @Data |
| 15 | @ApiModel("查询买断入库核算单Vo") | 16 | @ApiModel("查询买断入库核算单Vo") |
| @@ -47,4 +48,13 @@ public class QueryBuyoutAccountOrderVo extends SortPageVo implements Serializabl | @@ -47,4 +48,13 @@ public class QueryBuyoutAccountOrderVo extends SortPageVo implements Serializabl | ||
| 47 | 48 | ||
| 48 | @ApiModelProperty("是否作废 true-已作废 false-有效单(不传默认查有效单)") | 49 | @ApiModelProperty("是否作废 true-已作废 false-有效单(不传默认查有效单)") |
| 49 | private Boolean deleted; | 50 | private Boolean deleted; |
| 51 | + | ||
| 52 | + @ApiModelProperty(hidden = true) | ||
| 53 | + private List<String> scopeDeptIds; | ||
| 54 | + | ||
| 55 | + @ApiModelProperty(hidden = true) | ||
| 56 | + private Boolean scopePurchase; | ||
| 57 | + | ||
| 58 | + @ApiModelProperty(hidden = true) | ||
| 59 | + private Boolean scopeRegion; | ||
| 50 | } | 60 | } |
| @@ -46,4 +46,13 @@ public class QueryProcurementMaterialSettleDetailVo extends SortPageVo implement | @@ -46,4 +46,13 @@ public class QueryProcurementMaterialSettleDetailVo extends SortPageVo implement | ||
| 46 | 46 | ||
| 47 | @ApiModelProperty("创建人ID集合(数据权限用,后端注入)") | 47 | @ApiModelProperty("创建人ID集合(数据权限用,后端注入)") |
| 48 | private List<String> createByIdList; | 48 | private List<String> createByIdList; |
| 49 | + | ||
| 50 | + @ApiModelProperty(hidden = true) | ||
| 51 | + private List<String> scopeDeptIds; | ||
| 52 | + | ||
| 53 | + @ApiModelProperty(hidden = true) | ||
| 54 | + private Boolean scopePurchase; | ||
| 55 | + | ||
| 56 | + @ApiModelProperty(hidden = true) | ||
| 57 | + private Boolean scopeRegion; | ||
| 49 | } | 58 | } |
| @@ -57,4 +57,13 @@ public class QueryProcurementAssayReportVo extends SortPageVo implements Seriali | @@ -57,4 +57,13 @@ public class QueryProcurementAssayReportVo extends SortPageVo implements Seriali | ||
| 57 | 57 | ||
| 58 | @ApiModelProperty("创建人ID集合(数据权限用,后端注入)") | 58 | @ApiModelProperty("创建人ID集合(数据权限用,后端注入)") |
| 59 | private List<String> createByIdList; | 59 | private List<String> createByIdList; |
| 60 | + | ||
| 61 | + @ApiModelProperty(hidden = true) | ||
| 62 | + private List<String> scopeDeptIds; | ||
| 63 | + | ||
| 64 | + @ApiModelProperty(hidden = true) | ||
| 65 | + private Boolean scopePurchase; | ||
| 66 | + | ||
| 67 | + @ApiModelProperty(hidden = true) | ||
| 68 | + private Boolean scopeRegion; | ||
| 60 | } | 69 | } |
| @@ -54,4 +54,13 @@ public class QueryProcurementWeighingTicketVo extends SortPageVo implements Seri | @@ -54,4 +54,13 @@ public class QueryProcurementWeighingTicketVo extends SortPageVo implements Seri | ||
| 54 | 54 | ||
| 55 | @ApiModelProperty("是否作废单 true=作废单 false/空=有效单") | 55 | @ApiModelProperty("是否作废单 true=作废单 false/空=有效单") |
| 56 | private Boolean deleted; | 56 | private Boolean deleted; |
| 57 | + | ||
| 58 | + @ApiModelProperty(hidden = true) | ||
| 59 | + private List<String> scopeDeptIds; | ||
| 60 | + | ||
| 61 | + @ApiModelProperty(hidden = true) | ||
| 62 | + private Boolean scopePurchase; | ||
| 63 | + | ||
| 64 | + @ApiModelProperty(hidden = true) | ||
| 65 | + private Boolean scopeRegion; | ||
| 57 | } | 66 | } |
| 1 | +package com.lframework.xingyun.sc.utils; | ||
| 2 | + | ||
| 3 | +import com.lframework.starter.common.utils.CollectionUtil; | ||
| 4 | +import com.lframework.starter.web.inner.entity.SysRole; | ||
| 5 | +import com.lframework.starter.web.inner.entity.SysUserDept; | ||
| 6 | +import com.lframework.starter.web.inner.service.system.SysRoleService; | ||
| 7 | +import com.lframework.starter.web.inner.service.system.SysUserDeptService; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | +import javax.annotation.Resource; | ||
| 11 | +import java.util.Arrays; | ||
| 12 | +import java.util.Collections; | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.stream.Collectors; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 采购处侧角色数据权限工具(与系统数据权限框架分开单独处理): | ||
| 18 | + * 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域;多角色取数据并集; | ||
| 19 | + * 无相关角色时不限制。角色与部门在 Java 层算好,SQL 仅做常量 IN 过滤,不影响查询速度。 | ||
| 20 | + */ | ||
| 21 | +@Component | ||
| 22 | +public class PurchaseDataScopeUtil { | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 采购处主管角色编码(磷铜/紫铜/黄铜一处/黄铜二处) | ||
| 26 | + */ | ||
| 27 | + public static final List<String> PURCHASE_DEPT_ROLE_CODES = | ||
| 28 | + Arrays.asList("ltcgczg", "ztcgczg", "htcgyczg", "htcgeczg"); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 区域角色编码(区域经理/内贸采购科业务员) | ||
| 32 | + */ | ||
| 33 | + public static final List<String> REGION_ROLE_CODES = Arrays.asList("nmcgkywy", "qyjl"); | ||
| 34 | + | ||
| 35 | + @Resource | ||
| 36 | + private SysRoleService sysRoleService; | ||
| 37 | + | ||
| 38 | + @Resource | ||
| 39 | + private SysUserDeptService sysUserDeptService; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 当前用户是否拥有指定角色之一 | ||
| 43 | + */ | ||
| 44 | + public boolean hasAnyRole(String userId, List<String> roleCodes) { | ||
| 45 | + List<SysRole> roles = sysRoleService.getByUserId(userId); | ||
| 46 | + if (CollectionUtil.isEmpty(roles)) { | ||
| 47 | + return false; | ||
| 48 | + } | ||
| 49 | + return roles.stream().map(SysRole::getCode).anyMatch(roleCodes::contains); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 当前用户所属部门ID集合(去重) | ||
| 54 | + */ | ||
| 55 | + public List<String> getDeptIds(String userId) { | ||
| 56 | + List<SysUserDept> userDeptList = sysUserDeptService.getByUserId(userId); | ||
| 57 | + if (CollectionUtil.isEmpty(userDeptList)) { | ||
| 58 | + return Collections.emptyList(); | ||
| 59 | + } | ||
| 60 | + return userDeptList.stream().map(SysUserDept::getDeptId).distinct().collect(Collectors.toList()); | ||
| 61 | + } | ||
| 62 | +} |
| @@ -140,6 +140,74 @@ | @@ -140,6 +140,74 @@ | ||
| 140 | ORDER BY tb.create_time DESC | 140 | ORDER BY tb.create_time DESC |
| 141 | </select> | 141 | </select> |
| 142 | 142 | ||
| 143 | + <!-- 采购处侧角色专用查询(Mapper 方法无 @DataPermissions 注解,避免与框架追加的创建人等条件 AND 冲突): | ||
| 144 | + 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域;多角色取并集 --> | ||
| 145 | + <select id="queryPurchaseScope" resultMap="ProcurementBuyoutAccountOrderResult"> | ||
| 146 | + <include refid="PBAO_sql"/> | ||
| 147 | + <where> | ||
| 148 | + <choose> | ||
| 149 | + <when test="vo.deleted != null"> | ||
| 150 | + tb.deleted = #{vo.deleted} | ||
| 151 | + </when> | ||
| 152 | + <otherwise> | ||
| 153 | + tb.deleted = 0 | ||
| 154 | + </otherwise> | ||
| 155 | + </choose> | ||
| 156 | + <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''"> | ||
| 157 | + AND tb.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%') | ||
| 158 | + </if> | ||
| 159 | + <if test="vo.planCode != null and vo.planCode != ''"> | ||
| 160 | + AND tb.plan_codes LIKE CONCAT('%', #{vo.planCode}, '%') | ||
| 161 | + </if> | ||
| 162 | + <!-- 创建时间筛选(精确到时分秒) --> | ||
| 163 | + <if test="vo.startTime != null"> | ||
| 164 | + AND tb.create_time >= #{vo.startTime} | ||
| 165 | + </if> | ||
| 166 | + <if test="vo.endTime != null"> | ||
| 167 | + AND tb.create_time <= #{vo.endTime} | ||
| 168 | + </if> | ||
| 169 | + <if test="vo.incomingUnit != null and vo.incomingUnit != ''"> | ||
| 170 | + AND tb.incoming_unit LIKE CONCAT('%', #{vo.incomingUnit}, '%') | ||
| 171 | + </if> | ||
| 172 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | ||
| 173 | + AND tb.workshop_id = #{vo.workshopId} | ||
| 174 | + </if> | ||
| 175 | + <if test="vo.flowNode != null and vo.flowNode != ''"> | ||
| 176 | + AND tb.flow_node = #{vo.flowNode} | ||
| 177 | + </if> | ||
| 178 | + <if test="vo.approvalStatus != null and vo.approvalStatus != ''"> | ||
| 179 | + AND tb.approval_status = #{vo.approvalStatus} | ||
| 180 | + </if> | ||
| 181 | + <!-- 采购处/区域过滤(角色/部门已在后端算好,仅做常量IN过滤,不影响查询速度); | ||
| 182 | + 有角色但未挂部门时查不到任何数据 --> | ||
| 183 | + <choose> | ||
| 184 | + <when test="vo.scopeDeptIds != null and vo.scopeDeptIds.size() > 0"> | ||
| 185 | + <choose> | ||
| 186 | + <when test="vo.scopePurchase != null and vo.scopePurchase and vo.scopeRegion != null and vo.scopeRegion"> | ||
| 187 | + AND (tb.purchase_department_id IN | ||
| 188 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 189 | + OR tb.region_id IN | ||
| 190 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 191 | + ) | ||
| 192 | + </when> | ||
| 193 | + <when test="vo.scopePurchase != null and vo.scopePurchase"> | ||
| 194 | + AND tb.purchase_department_id IN | ||
| 195 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 196 | + </when> | ||
| 197 | + <when test="vo.scopeRegion != null and vo.scopeRegion"> | ||
| 198 | + AND tb.region_id IN | ||
| 199 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 200 | + </when> | ||
| 201 | + </choose> | ||
| 202 | + </when> | ||
| 203 | + <otherwise> | ||
| 204 | + AND 1 = 2 | ||
| 205 | + </otherwise> | ||
| 206 | + </choose> | ||
| 207 | + </where> | ||
| 208 | + ORDER BY tb.create_time DESC | ||
| 209 | + </select> | ||
| 210 | + | ||
| 143 | <!-- 单条查询(联表带出分厂编号;分厂审核节点编码 = BUYOUT_ACCOUNT_ORDER_ + 分厂前缀 + 环节缩写,实体传给流程引擎前必须带出) --> | 211 | <!-- 单条查询(联表带出分厂编号;分厂审核节点编码 = BUYOUT_ACCOUNT_ORDER_ + 分厂前缀 + 环节缩写,实体传给流程引擎前必须带出) --> |
| 144 | <select id="findById" resultMap="ProcurementBuyoutAccountOrderResult"> | 212 | <select id="findById" resultMap="ProcurementBuyoutAccountOrderResult"> |
| 145 | <include refid="PBAO_sql"/> | 213 | <include refid="PBAO_sql"/> |
| @@ -134,6 +134,74 @@ | @@ -134,6 +134,74 @@ | ||
| 134 | ORDER BY tb.create_time DESC | 134 | ORDER BY tb.create_time DESC |
| 135 | </select> | 135 | </select> |
| 136 | 136 | ||
| 137 | + <!-- 采购处侧角色专用查询(Mapper 方法无 @DataPermissions 注解,避免与框架追加的创建人等条件 AND 冲突): | ||
| 138 | + 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域;多角色取并集 --> | ||
| 139 | + <select id="queryPurchaseScope" resultMap="ProcurementMaterialSettleDetailResult"> | ||
| 140 | + <include refid="PMSD_sql"/> | ||
| 141 | + <where> | ||
| 142 | + <choose> | ||
| 143 | + <when test="vo.deleted != null"> | ||
| 144 | + tb.deleted = #{vo.deleted} | ||
| 145 | + </when> | ||
| 146 | + <otherwise> | ||
| 147 | + tb.deleted = 0 | ||
| 148 | + </otherwise> | ||
| 149 | + </choose> | ||
| 150 | + <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''"> | ||
| 151 | + AND tb.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%') | ||
| 152 | + </if> | ||
| 153 | + <if test="vo.ticketDateStart != null"> | ||
| 154 | + AND tb.ticket_date >= #{vo.ticketDateStart} | ||
| 155 | + </if> | ||
| 156 | + <if test="vo.ticketDateEnd != null"> | ||
| 157 | + AND tb.ticket_date <= #{vo.ticketDateEnd} | ||
| 158 | + </if> | ||
| 159 | + <if test="vo.planCode != null and vo.planCode != ''"> | ||
| 160 | + AND EXISTS ( | ||
| 161 | + SELECT 1 FROM procurement_material_settle_line pmsl | ||
| 162 | + WHERE pmsl.settle_detail_id = tb.id | ||
| 163 | + AND pmsl.plan_code LIKE CONCAT('%', #{vo.planCode}, '%') | ||
| 164 | + ) | ||
| 165 | + </if> | ||
| 166 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | ||
| 167 | + AND tb.workshop_id = #{vo.workshopId} | ||
| 168 | + </if> | ||
| 169 | + <if test="vo.flowNode != null and vo.flowNode != ''"> | ||
| 170 | + AND tb.flow_node = #{vo.flowNode} | ||
| 171 | + </if> | ||
| 172 | + <if test="vo.approvalStatus != null and vo.approvalStatus != ''"> | ||
| 173 | + AND tb.approval_status = #{vo.approvalStatus} | ||
| 174 | + </if> | ||
| 175 | + <!-- 采购处/区域过滤(角色/部门已在后端算好,仅做常量IN过滤,不影响查询速度); | ||
| 176 | + 有角色但未挂部门时查不到任何数据 --> | ||
| 177 | + <choose> | ||
| 178 | + <when test="vo.scopeDeptIds != null and vo.scopeDeptIds.size() > 0"> | ||
| 179 | + <choose> | ||
| 180 | + <when test="vo.scopePurchase != null and vo.scopePurchase and vo.scopeRegion != null and vo.scopeRegion"> | ||
| 181 | + AND (tb.purchase_department_id IN | ||
| 182 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 183 | + OR tb.region_id IN | ||
| 184 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 185 | + ) | ||
| 186 | + </when> | ||
| 187 | + <when test="vo.scopePurchase != null and vo.scopePurchase"> | ||
| 188 | + AND tb.purchase_department_id IN | ||
| 189 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 190 | + </when> | ||
| 191 | + <when test="vo.scopeRegion != null and vo.scopeRegion"> | ||
| 192 | + AND tb.region_id IN | ||
| 193 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 194 | + </when> | ||
| 195 | + </choose> | ||
| 196 | + </when> | ||
| 197 | + <otherwise> | ||
| 198 | + AND 1 = 2 | ||
| 199 | + </otherwise> | ||
| 200 | + </choose> | ||
| 201 | + </where> | ||
| 202 | + ORDER BY tb.create_time DESC | ||
| 203 | + </select> | ||
| 204 | + | ||
| 137 | <!-- 单条查询(联表带出分厂编号;分厂审核节点编码 = material_settle_ + 分厂前缀 + 环节缩写,实体传给流程引擎前必须带出) --> | 205 | <!-- 单条查询(联表带出分厂编号;分厂审核节点编码 = material_settle_ + 分厂前缀 + 环节缩写,实体传给流程引擎前必须带出) --> |
| 138 | <select id="findById" resultMap="ProcurementMaterialSettleDetailResult"> | 206 | <select id="findById" resultMap="ProcurementMaterialSettleDetailResult"> |
| 139 | <include refid="PMSD_sql"/> | 207 | <include refid="PMSD_sql"/> |
| @@ -140,6 +140,79 @@ | @@ -140,6 +140,79 @@ | ||
| 140 | ORDER BY tb.create_time DESC | 140 | ORDER BY tb.create_time DESC |
| 141 | </select> | 141 | </select> |
| 142 | 142 | ||
| 143 | + <!-- 采购处侧角色专用查询(Mapper 方法无 @DataPermissions 注解,避免与框架追加的创建人等条件 AND 冲突): | ||
| 144 | + 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域;多角色取并集 --> | ||
| 145 | + <select id="queryPurchaseScope" resultMap="ProcurementAssayReportResult"> | ||
| 146 | + <include refid="PAR_sql"/> | ||
| 147 | + <where> | ||
| 148 | + <choose> | ||
| 149 | + <when test="vo.deleted != null"> | ||
| 150 | + tb.deleted = #{vo.deleted} | ||
| 151 | + </when> | ||
| 152 | + <otherwise> | ||
| 153 | + tb.deleted = 0 | ||
| 154 | + </otherwise> | ||
| 155 | + </choose> | ||
| 156 | + <if test="vo.weighingTicketCode != null and vo.weighingTicketCode != ''"> | ||
| 157 | + AND tb.weighing_ticket_code LIKE CONCAT('%', #{vo.weighingTicketCode}, '%') | ||
| 158 | + </if> | ||
| 159 | + <if test="vo.reportDateStart != null"> | ||
| 160 | + AND tb.report_date >= #{vo.reportDateStart} | ||
| 161 | + </if> | ||
| 162 | + <if test="vo.reportDateEnd != null"> | ||
| 163 | + AND tb.report_date <= #{vo.reportDateEnd} | ||
| 164 | + </if> | ||
| 165 | + <if test="vo.supplierName != null and vo.supplierName != ''"> | ||
| 166 | + AND tb.supplier_name LIKE CONCAT('%', #{vo.supplierName}, '%') | ||
| 167 | + </if> | ||
| 168 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | ||
| 169 | + AND tb.workshop_id = #{vo.workshopId} | ||
| 170 | + </if> | ||
| 171 | + <if test="vo.approvalStatus != null and vo.approvalStatus != ''"> | ||
| 172 | + AND tb.approval_status = #{vo.approvalStatus} | ||
| 173 | + </if> | ||
| 174 | + <if test="vo.flowNode != null and vo.flowNode != ''"> | ||
| 175 | + AND tb.flow_node = #{vo.flowNode} | ||
| 176 | + </if> | ||
| 177 | + <if test="vo.createBy != null and vo.createBy != ''"> | ||
| 178 | + AND tb.create_by LIKE CONCAT('%', #{vo.createBy}, '%') | ||
| 179 | + </if> | ||
| 180 | + <if test="vo.startTime != null"> | ||
| 181 | + AND tb.create_time >= #{vo.startTime} | ||
| 182 | + </if> | ||
| 183 | + <if test="vo.endTime != null"> | ||
| 184 | + AND tb.create_time <= #{vo.endTime} | ||
| 185 | + </if> | ||
| 186 | + <!-- 采购处/区域过滤(角色/部门已在后端算好,仅做常量IN过滤,不影响查询速度); | ||
| 187 | + 有角色但未挂部门时查不到任何数据 --> | ||
| 188 | + <choose> | ||
| 189 | + <when test="vo.scopeDeptIds != null and vo.scopeDeptIds.size() > 0"> | ||
| 190 | + <choose> | ||
| 191 | + <when test="vo.scopePurchase != null and vo.scopePurchase and vo.scopeRegion != null and vo.scopeRegion"> | ||
| 192 | + AND (tb.purchase_department_id IN | ||
| 193 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 194 | + OR tb.region_id IN | ||
| 195 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 196 | + ) | ||
| 197 | + </when> | ||
| 198 | + <when test="vo.scopePurchase != null and vo.scopePurchase"> | ||
| 199 | + AND tb.purchase_department_id IN | ||
| 200 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 201 | + </when> | ||
| 202 | + <when test="vo.scopeRegion != null and vo.scopeRegion"> | ||
| 203 | + AND tb.region_id IN | ||
| 204 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 205 | + </when> | ||
| 206 | + </choose> | ||
| 207 | + </when> | ||
| 208 | + <otherwise> | ||
| 209 | + AND 1 = 2 | ||
| 210 | + </otherwise> | ||
| 211 | + </choose> | ||
| 212 | + </where> | ||
| 213 | + ORDER BY tb.create_time DESC | ||
| 214 | + </select> | ||
| 215 | + | ||
| 143 | <resultMap id="AssayReportSelectableTicketResult" type="com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo"> | 216 | <resultMap id="AssayReportSelectableTicketResult" type="com.lframework.xingyun.sc.bo.procurement.GetAssaySelectableTicketBo"> |
| 144 | <id column="id" property="id"/> | 217 | <id column="id" property="id"/> |
| 145 | <result column="code" property="code"/> | 218 | <result column="code" property="code"/> |
| @@ -172,6 +172,82 @@ | @@ -172,6 +172,82 @@ | ||
| 172 | ORDER BY tb.create_time DESC | 172 | ORDER BY tb.create_time DESC |
| 173 | </select> | 173 | </select> |
| 174 | 174 | ||
| 175 | + <!-- 采购处侧角色专用查询(Mapper 方法无 @DataPermissions 注解,避免与框架追加的创建人等条件 AND 冲突): | ||
| 176 | + 采购处主管按所属部门过滤采购处;区域经理/内贸采购科业务员按所属部门过滤区域;多角色取并集 --> | ||
| 177 | + <select id="queryPurchaseScope" resultMap="ProcurementWeighingTicketResult"> | ||
| 178 | + <include refid="PWT_sql"/> | ||
| 179 | + <where> | ||
| 180 | + <choose> | ||
| 181 | + <when test="vo.deleted != null"> | ||
| 182 | + AND tb.deleted = #{vo.deleted} | ||
| 183 | + </when> | ||
| 184 | + <otherwise> | ||
| 185 | + AND tb.deleted = 0 | ||
| 186 | + </otherwise> | ||
| 187 | + </choose> | ||
| 188 | + <if test="vo != null"> | ||
| 189 | + <if test="vo.code != null and vo.code != ''"> | ||
| 190 | + AND tb.code LIKE CONCAT('%', #{vo.code}, '%') | ||
| 191 | + </if> | ||
| 192 | + <if test="vo.planCode != null and vo.planCode != ''"> | ||
| 193 | + AND EXISTS ( | ||
| 194 | + SELECT 1 FROM procurement_weighing_ticket_plan pwtp | ||
| 195 | + WHERE pwtp.weighing_ticket_id = tb.id | ||
| 196 | + AND pwtp.plan_code LIKE CONCAT('%', #{vo.planCode}, '%') | ||
| 197 | + ) | ||
| 198 | + </if> | ||
| 199 | + <if test="vo.supplierName != null and vo.supplierName != ''"> | ||
| 200 | + AND tb.supplier_name LIKE CONCAT('%', #{vo.supplierName}, '%') | ||
| 201 | + </if> | ||
| 202 | + <if test="vo.companyShortId != null and vo.companyShortId != ''"> | ||
| 203 | + AND tb.company_short_id = #{vo.companyShortId} | ||
| 204 | + </if> | ||
| 205 | + <if test="vo.workshopId != null and vo.workshopId != ''"> | ||
| 206 | + AND tb.workshop_id = #{vo.workshopId} | ||
| 207 | + </if> | ||
| 208 | + <if test="vo.approvalStatus != null and vo.approvalStatus != ''"> | ||
| 209 | + AND tb.approval_status = #{vo.approvalStatus} | ||
| 210 | + </if> | ||
| 211 | + <if test="vo.startTime != null"> | ||
| 212 | + AND tb.first_gross_weight_time <![CDATA[ >= ]]> #{vo.startTime} | ||
| 213 | + </if> | ||
| 214 | + <if test="vo.endTime != null"> | ||
| 215 | + AND tb.first_gross_weight_time <![CDATA[ <= ]]> #{vo.endTime} | ||
| 216 | + </if> | ||
| 217 | + <if test="vo.createBy != null and vo.createBy != ''"> | ||
| 218 | + AND tb.create_by LIKE CONCAT('%', #{vo.createBy}, '%') | ||
| 219 | + </if> | ||
| 220 | + </if> | ||
| 221 | + <!-- 采购处/区域过滤(角色/部门已在后端算好,仅做常量IN过滤,不影响查询速度); | ||
| 222 | + 有角色但未挂部门时查不到任何数据 --> | ||
| 223 | + <choose> | ||
| 224 | + <when test="vo.scopeDeptIds != null and vo.scopeDeptIds.size() > 0"> | ||
| 225 | + <choose> | ||
| 226 | + <when test="vo.scopePurchase != null and vo.scopePurchase and vo.scopeRegion != null and vo.scopeRegion"> | ||
| 227 | + AND (tb.purchase_department_id IN | ||
| 228 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 229 | + OR tb.region_id IN | ||
| 230 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 231 | + ) | ||
| 232 | + </when> | ||
| 233 | + <when test="vo.scopePurchase != null and vo.scopePurchase"> | ||
| 234 | + AND tb.purchase_department_id IN | ||
| 235 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 236 | + </when> | ||
| 237 | + <when test="vo.scopeRegion != null and vo.scopeRegion"> | ||
| 238 | + AND tb.region_id IN | ||
| 239 | + <foreach collection="vo.scopeDeptIds" item="deptId" open="(" separator="," close=")">#{deptId}</foreach> | ||
| 240 | + </when> | ||
| 241 | + </choose> | ||
| 242 | + </when> | ||
| 243 | + <otherwise> | ||
| 244 | + AND 1 = 2 | ||
| 245 | + </otherwise> | ||
| 246 | + </choose> | ||
| 247 | + </where> | ||
| 248 | + ORDER BY tb.create_time DESC | ||
| 249 | + </select> | ||
| 250 | + | ||
| 175 | <select id="findById" resultMap="ProcurementWeighingTicketResult"> | 251 | <select id="findById" resultMap="ProcurementWeighingTicketResult"> |
| 176 | <include refid="PWT_sql"/> | 252 | <include refid="PWT_sql"/> |
| 177 | WHERE tb.id = #{id} | 253 | WHERE tb.id = #{id} |