From 9cf12820c816bc27a419531634113a6ed57f7a2a Mon Sep 17 00:00:00 2001 From: 17602169347 Date: Mon, 3 Apr 2023 16:36:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../poundlist/mapper/PoundlistMapper.java | 3 +- .../service/impl/PoundlistServiceImpl.java | 7 +- .../mapper/poundlist/PoundlistMapper.xml | 6 +- .../permission/service/AuthorizeService.java | 2 + .../service/impl/AuthorizeServiceImpl.java | 177 ++++++++++++++++++ 5 files changed, 187 insertions(+), 8 deletions(-) diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/mapper/PoundlistMapper.java b/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/mapper/PoundlistMapper.java index 2a402ae8..58a5eec7 100644 --- a/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/mapper/PoundlistMapper.java +++ b/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/mapper/PoundlistMapper.java @@ -1,6 +1,7 @@ package jnpf.poundlist.mapper; +import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import jnpf.poundlist.entity.PoundlistEntity; @@ -23,7 +24,7 @@ import java.util.List; */ public interface PoundlistMapper extends BaseMapper { - IPage queryByKeyword(@Param("page") Page page, @Param("poundlistPagination") PoundlistPagination poundlistPagination); + IPage queryByKeyword(@Param("page") Page page, @Param("poundlistPagination") PoundlistPagination poundlistPagination, @Param("ew") Wrapper queryWrapper); //销售毛利表 List qureylist(PoundlistSEntity poundlistSEntity); //废钢采购销售统计明细表(按磅单) diff --git a/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/service/impl/PoundlistServiceImpl.java b/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/service/impl/PoundlistServiceImpl.java index c433dc6f..76dcbd94 100644 --- a/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/service/impl/PoundlistServiceImpl.java +++ b/SC-boot/linkage-scm/src/main/java/jnpf/poundlist/service/impl/PoundlistServiceImpl.java @@ -88,13 +88,13 @@ public class PoundlistServiceImpl extends ServiceImpl poundlistQueryWrapper = new QueryWrapper<>(); - poundlistQueryWrapper.lambda().eq(PoundlistEntity::getIsExamine, "1"); + //poundlistQueryWrapper.lambda().eq(PoundlistEntity::getIsExamine, "1"); boolean pcPermission = true; boolean appPermission = true; boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); if (isPc && pcPermission) { if (!userProvider.get().getIsAdministrator()) { - Object poundlistObj = authorizeService.getCondition(new AuthorizeConditionModel(poundlistQueryWrapper, poundlistPagination.getMenuId(), "jg_poundlist")); + Object poundlistObj = authorizeService.getCondition2(new AuthorizeConditionModel(poundlistQueryWrapper, poundlistPagination.getMenuId(), "jg_poundlist")); if (ObjectUtil.isEmpty(poundlistObj)) { return new ArrayList<>(); } else { @@ -162,8 +162,7 @@ public class PoundlistServiceImpl extends ServiceImpl iPage = poundlistMapper.queryByKeyword(page, poundlistPagination); + IPage iPage = poundlistMapper.queryByKeyword(page, poundlistPagination, poundlistQueryWrapper); return poundlistPagination.setData(iPage.getRecords(), iPage.getTotal()); } diff --git a/SC-boot/linkage-scm/src/main/resources/mapper/poundlist/PoundlistMapper.xml b/SC-boot/linkage-scm/src/main/resources/mapper/poundlist/PoundlistMapper.xml index e1215969..72e884f7 100644 --- a/SC-boot/linkage-scm/src/main/resources/mapper/poundlist/PoundlistMapper.xml +++ b/SC-boot/linkage-scm/src/main/resources/mapper/poundlist/PoundlistMapper.xml @@ -69,7 +69,7 @@ WHERE a.delete_mark = 0 and LEFT JOIN jg_natural i on a.natural_id = i.id LEFT JOIN jg_purchaseorder_item0 j on a.id = j.poundlist_id LEFT JOIN jg_salesorder_item0 k on a.id = k.poundlist_id - where a.is_examine = '1' and a.delete_mark = 0 and b.delete_mark = 0 and c.delete_mark = 0 and d.delete_mark = 0 and e.delete_mark = 0 and f.delete_mark = 0 and g.delete_mark = 0 + ${ew.customSqlSegment} and a.is_examine = '1' and a.delete_mark = 0 and b.delete_mark = 0 and c.delete_mark = 0 and d.delete_mark = 0 and e.delete_mark = 0 and f.delete_mark = 0 and g.delete_mark = 0 AND (b.ticketno LIKE CONCAT('%',#{poundlistPagination.keyword},'%') OR c.supplier_name LIKE CONCAT('%',#{poundlistPagination.keyword},'%') OR d.supplier_nm LIKE CONCAT('%',#{poundlistPagination.keyword},'%')) @@ -89,12 +89,12 @@ WHERE a.delete_mark = 0 and AND a.is_pay = #{poundlistPagination.isPay} /*modified by 巴卫*/ - + AND a.is_collection = #{poundlistPagination.isCollection} diff --git a/SC-boot/linkage-system/src/main/java/jnpf/permission/service/AuthorizeService.java b/SC-boot/linkage-system/src/main/java/jnpf/permission/service/AuthorizeService.java index 564c6963..c0de5699 100644 --- a/SC-boot/linkage-system/src/main/java/jnpf/permission/service/AuthorizeService.java +++ b/SC-boot/linkage-system/src/main/java/jnpf/permission/service/AuthorizeService.java @@ -90,5 +90,7 @@ public interface AuthorizeService extends IService { Object getCondition(AuthorizeConditionModel conditionModel); + Object getCondition2(AuthorizeConditionModel conditionModel); + String getConditionSql(UserInfo userInfo, String moduleId ,String mainTable); } diff --git a/SC-boot/linkage-system/src/main/java/jnpf/permission/service/impl/AuthorizeServiceImpl.java b/SC-boot/linkage-system/src/main/java/jnpf/permission/service/impl/AuthorizeServiceImpl.java index 08ba5640..2fff0eef 100644 --- a/SC-boot/linkage-system/src/main/java/jnpf/permission/service/impl/AuthorizeServiceImpl.java +++ b/SC-boot/linkage-system/src/main/java/jnpf/permission/service/impl/AuthorizeServiceImpl.java @@ -491,6 +491,183 @@ public class AuthorizeServiceImpl extends ServiceImpl getCondition2(AuthorizeConditionModel conditionModel) { + Object obj =conditionModel.getObj(); + String moduleId =conditionModel.getModuleId(); + String tableName =conditionModel.getTableName(); + UserInfo userInfo = userProvider.get(); + QueryWrapper queryWhere = (QueryWrapper) obj; + AuthorizeVO model = this.getAuthorize(true); + List resourceList = model.getResourceList().stream().filter(m -> m.getModuleId().equals(moduleId)).collect(Collectors.toList()); + if (resourceList.size() == 0) { + return null; + } + List resourceList1 = new ArrayList<>(); + //拼接计数 + int t = 0; + for (ResourceModel item : resourceList) { + if ("linkage_alldata".equals(item.getEnCode())){ + t=0; + break; + } + List conditionModelList = JsonUtil.getJsonToList(item.getConditionJson(), ConditionModel.class); + for (int i = 0; i < conditionModelList.size(); i++) { + ConditionModel conditionItem = conditionModelList.get(i); + for (int k = 0; k < conditionItem.getGroups().size(); k++) { + ConditionModel.ConditionItemModel fieldItem = conditionItem.getGroups().get(k); + String itemValue = fieldItem.getValue(); + String itemMethod = fieldItem.getOp(); + String itemTable = fieldItem.getBindTable(); + if (StringUtil.isNotEmpty(itemTable) && itemTable.equalsIgnoreCase(tableName)){ + resourceList1.add(item); + } + if (AuthorizeConditionEnum.USER.getCondition().equals(itemValue) + || AuthorizeConditionEnum.ORGANIZE.getCondition().equals(itemValue) + || AuthorizeConditionEnum.USERANDUNDER.getCondition().equals(itemValue) + || AuthorizeConditionEnum.ORGANIZEANDUNDER.getCondition().equals(itemValue) + || itemMethod.equals(SearchMethodEnum.Equal.getMessage()) + || itemMethod.equals(SearchMethodEnum.NotEqual.getMessage()) + || itemMethod.equals(SearchMethodEnum.LessThan.getMessage()) + || itemMethod.equals(SearchMethodEnum.LessThanOrEqual.getMessage()) + || itemMethod.equals(SearchMethodEnum.GreaterThan.getMessage()) + || itemMethod.equals(SearchMethodEnum.GreaterThanOrEqual.getMessage()) + ) { //当前用户Id + t = 1; + } + } + } + } + if (t == 1) { + if (resourceList1.size()>0){ + queryWhere.and(tw -> { + for (ResourceModel item : resourceList1) { + List conditionModelList = JsonUtil.getJsonToList(item.getConditionJson(), ConditionModel.class); + for (int i = 0; i < conditionModelList.size(); i++) { + ConditionModel conditionItem = conditionModelList.get(i); + for (int k = 0; k < conditionItem.getGroups().size(); k++) { + ConditionModel.ConditionItemModel fieldItem = conditionItem.getGroups().get(k); + String itemField = "a." + fieldItem.getField(); + String itemValue = fieldItem.getValue(); + String itemMethod = fieldItem.getOp(); + if ("and".equalsIgnoreCase(conditionItem.getLogic())) { + if (AuthorizeConditionEnum.USER.getCondition().equals(itemValue)) { //当前用户 + tw.eq(itemField, userInfo.getUserId()); + } else if (AuthorizeConditionEnum.ORGANIZE.getCondition().equals(itemValue)) { //当前组织 + String orgId = userInfo.getOrganizeId(); + if (StringUtil.isNotEmpty(userInfo.getDepartmentId())) { + orgId = userInfo.getDepartmentId(); + } + tw.eq(itemField, orgId); + } else if (AuthorizeConditionEnum.ORGANIZEANDUNDER.getCondition().equals(itemValue)) { //组织及子组织 + String orgId = userInfo.getOrganizeId(); + if (StringUtil.isNotEmpty(userInfo.getDepartmentId())) { + orgId = userInfo.getDepartmentId(); + } + List underOrganizations = organizeService.getUnderOrganizations(orgId); + underOrganizations.add(orgId); + tw.in(itemField, underOrganizations); + } else if (AuthorizeConditionEnum.USERANDUNDER.getCondition().equals(itemValue)) { //用户及用户下属 + List idsList = new ArrayList<>(); + if (userInfo.getSubordinateIds().size() > 0) { + idsList = userInfo.getSubordinateIds(); + } + idsList.add(userInfo.getUserId()); + tw.in(itemField, idsList); + } else {//任意文本 + if (itemMethod.equals(SearchMethodEnum.Equal.getMessage())) { + tw.eq(itemField, itemValue); + } else if (itemMethod.equals(SearchMethodEnum.NotEqual.getMessage())) { + tw.ne(itemField, itemValue); + } else if (itemMethod.equals(SearchMethodEnum.LessThan.getMessage())) { + tw.lt(itemField, itemValue); + } else if (itemMethod.equals(SearchMethodEnum.LessThanOrEqual.getMessage())) { + tw.le(itemField, itemValue); + } else if (itemMethod.equals(SearchMethodEnum.GreaterThan.getMessage())) { + tw.gt(itemField, itemValue); + } else if (itemMethod.equals(SearchMethodEnum.GreaterThanOrEqual.getMessage())) { + tw.ge(itemField, itemValue); + } + } + } else { + if (AuthorizeConditionEnum.USER.getCondition().equals(itemValue)) { //当前用户 + tw.or( + qw -> qw.eq(itemField, userInfo.getUserId()) + ); + } else if (AuthorizeConditionEnum.ORGANIZE.getCondition().equals(itemValue)) { //当前组织 + String orgId = userInfo.getOrganizeId(); + if (StringUtil.isNotEmpty(userInfo.getDepartmentId())) { + orgId = userInfo.getDepartmentId(); + } + String finalOrgId = orgId; + tw.or( + qw -> qw.eq(itemField, finalOrgId) + ); + } else if (AuthorizeConditionEnum.ORGANIZEANDUNDER.getCondition().equals(itemValue)) { //组织及子组织 + String orgId = userInfo.getOrganizeId(); + if (StringUtil.isNotEmpty(userInfo.getDepartmentId())) { + orgId = userInfo.getDepartmentId(); + } + List underOrganizations = organizeService.getUnderOrganizations(orgId); + underOrganizations.add(orgId); + tw.or( + qw -> qw.in(itemField, underOrganizations) + ); + } else if (AuthorizeConditionEnum.USERANDUNDER.getCondition().equals(itemValue)) { //用户及用户下属 + List idsList = new ArrayList<>(); + if (userInfo.getSubordinateIds().size() > 0) { + idsList = userInfo.getSubordinateIds(); + } + idsList.add(userInfo.getUserId()); + List finalIdsList = idsList; + tw.or( + qw -> qw.in(itemField, finalIdsList) + ); + } else {//任意文本 + if (itemMethod.equals(SearchMethodEnum.Equal.getMessage())) { + tw.or( + qw -> qw.eq(itemField, itemValue) + ); + } else if (itemMethod.equals(SearchMethodEnum.NotEqual.getMessage())) { + tw.or( + qw -> qw.ne(itemField, itemValue) + ); + } else if (itemMethod.equals(SearchMethodEnum.LessThan.getMessage())) { + tw.or( + qw -> qw.lt(itemField, itemValue) + ); + } else if (itemMethod.equals(SearchMethodEnum.LessThanOrEqual.getMessage())) { + tw.or( + qw -> qw.le(itemField, itemValue) + ); + } else if (itemMethod.equals(SearchMethodEnum.GreaterThan.getMessage())) { + tw.or( + qw -> qw.gt(itemField, itemValue) + ); + } else if (itemMethod.equals(SearchMethodEnum.GreaterThanOrEqual.getMessage())) { + tw.or( + qw -> qw.ge(itemField, itemValue) + ); + } + } + } + } + + } + } + }); + } + } + return queryWhere; + } /** * 获取条件过滤