数据权限

product
17602169347 2 years ago
parent a66fe2aa81
commit 9cf12820c8

@ -1,6 +1,7 @@
package jnpf.poundlist.mapper; package jnpf.poundlist.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jnpf.poundlist.entity.PoundlistEntity; import jnpf.poundlist.entity.PoundlistEntity;
@ -23,7 +24,7 @@ import java.util.List;
*/ */
public interface PoundlistMapper extends BaseMapper<PoundlistEntity> { public interface PoundlistMapper extends BaseMapper<PoundlistEntity> {
IPage<PoundlistEntity> queryByKeyword(@Param("page") Page<PoundlistEntity> page, @Param("poundlistPagination") PoundlistPagination poundlistPagination); IPage<PoundlistEntity> queryByKeyword(@Param("page") Page<PoundlistEntity> page, @Param("poundlistPagination") PoundlistPagination poundlistPagination, @Param("ew") Wrapper<PoundlistEntity> queryWrapper);
//销售毛利表 //销售毛利表
List<PoundlistSEntity> qureylist(PoundlistSEntity poundlistSEntity); List<PoundlistSEntity> qureylist(PoundlistSEntity poundlistSEntity);
//废钢采购销售统计明细表(按磅单) //废钢采购销售统计明细表(按磅单)

@ -88,13 +88,13 @@ public class PoundlistServiceImpl extends ServiceImpl<PoundlistMapper, Poundlist
int total = 0; int total = 0;
int poundlistNum = 0; int poundlistNum = 0;
QueryWrapper<PoundlistEntity> poundlistQueryWrapper = new QueryWrapper<>(); QueryWrapper<PoundlistEntity> poundlistQueryWrapper = new QueryWrapper<>();
poundlistQueryWrapper.lambda().eq(PoundlistEntity::getIsExamine, "1"); //poundlistQueryWrapper.lambda().eq(PoundlistEntity::getIsExamine, "1");
boolean pcPermission = true; boolean pcPermission = true;
boolean appPermission = true; boolean appPermission = true;
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc"); boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
if (isPc && pcPermission) { if (isPc && pcPermission) {
if (!userProvider.get().getIsAdministrator()) { 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)) { if (ObjectUtil.isEmpty(poundlistObj)) {
return new ArrayList<>(); return new ArrayList<>();
} else { } else {
@ -162,8 +162,7 @@ public class PoundlistServiceImpl extends ServiceImpl<PoundlistMapper, Poundlist
poundlistPagination.setDepartmentId(detpartment); poundlistPagination.setDepartmentId(detpartment);
} }
/*************************************************************************/ /*************************************************************************/
IPage<PoundlistEntity> iPage = poundlistMapper.queryByKeyword(page, poundlistPagination, poundlistQueryWrapper);
IPage<PoundlistEntity> iPage = poundlistMapper.queryByKeyword(page, poundlistPagination);
return poundlistPagination.setData(iPage.getRecords(), iPage.getTotal()); return poundlistPagination.setData(iPage.getRecords(), iPage.getTotal());
} }

@ -69,7 +69,7 @@ WHERE a.delete_mark = 0 and
LEFT JOIN jg_natural i on a.natural_id = i.id 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_purchaseorder_item0 j on a.id = j.poundlist_id
LEFT JOIN jg_salesorder_item0 k on a.id = k.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
<if test="poundlistPagination.keyword != null and poundlistPagination.keyword != ''"> <if test="poundlistPagination.keyword != null and poundlistPagination.keyword != ''">
AND (b.ticketno LIKE CONCAT('%',#{poundlistPagination.keyword},'%') OR c.supplier_name LIKE CONCAT('%',#{poundlistPagination.keyword},'%') OR d.supplier_nm LIKE CONCAT('%',#{poundlistPagination.keyword},'%')) AND (b.ticketno LIKE CONCAT('%',#{poundlistPagination.keyword},'%') OR c.supplier_name LIKE CONCAT('%',#{poundlistPagination.keyword},'%') OR d.supplier_nm LIKE CONCAT('%',#{poundlistPagination.keyword},'%'))
</if> </if>
@ -89,12 +89,12 @@ WHERE a.delete_mark = 0 and
AND a.is_pay = #{poundlistPagination.isPay} AND a.is_pay = #{poundlistPagination.isPay}
</if> </if>
/*modified by 巴卫*/ /*modified by 巴卫*/
<if test="poundlistPagination.departmentId != null and poundlistPagination.departmentId != ''"> <!--<if test="poundlistPagination.departmentId != null and poundlistPagination.departmentId != ''">
AND a.department_id = #{poundlistPagination.departmentId} AND a.department_id = #{poundlistPagination.departmentId}
</if> </if>
<if test="poundlistPagination.orgnizeId != null and poundlistPagination.orgnizeId != ''"> <if test="poundlistPagination.orgnizeId != null and poundlistPagination.orgnizeId != ''">
AND a.orgnize_id = #{poundlistPagination.orgnizeId} AND a.orgnize_id = #{poundlistPagination.orgnizeId}
</if> </if>-->
<if test="poundlistPagination.isCollection != null and poundlistPagination.isCollection != ''"> <if test="poundlistPagination.isCollection != null and poundlistPagination.isCollection != ''">
AND a.is_collection = #{poundlistPagination.isCollection} AND a.is_collection = #{poundlistPagination.isCollection}
</if> </if>

@ -90,5 +90,7 @@ public interface AuthorizeService extends IService<AuthorizeEntity> {
Object getCondition(AuthorizeConditionModel conditionModel); Object getCondition(AuthorizeConditionModel conditionModel);
Object getCondition2(AuthorizeConditionModel conditionModel);
String getConditionSql(UserInfo userInfo, String moduleId ,String mainTable); String getConditionSql(UserInfo userInfo, String moduleId ,String mainTable);
} }

@ -491,6 +491,183 @@ public class AuthorizeServiceImpl extends ServiceImpl<AuthorizeMapper, Authorize
return queryWhere; return queryWhere;
} }
/**
*
*
* @param userInfo
* @param moduleId Id
* @param tableName
* @return
*/
@Override
public QueryWrapper<T> getCondition2(AuthorizeConditionModel conditionModel) {
Object obj =conditionModel.getObj();
String moduleId =conditionModel.getModuleId();
String tableName =conditionModel.getTableName();
UserInfo userInfo = userProvider.get();
QueryWrapper<T> queryWhere = (QueryWrapper<T>) obj;
AuthorizeVO model = this.getAuthorize(true);
List<ResourceModel> resourceList = model.getResourceList().stream().filter(m -> m.getModuleId().equals(moduleId)).collect(Collectors.toList());
if (resourceList.size() == 0) {
return null;
}
List<ResourceModel> resourceList1 = new ArrayList<>();
//拼接计数
int t = 0;
for (ResourceModel item : resourceList) {
if ("linkage_alldata".equals(item.getEnCode())){
t=0;
break;
}
List<ConditionModel> 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<ConditionModel> 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<String> underOrganizations = organizeService.getUnderOrganizations(orgId);
underOrganizations.add(orgId);
tw.in(itemField, underOrganizations);
} else if (AuthorizeConditionEnum.USERANDUNDER.getCondition().equals(itemValue)) { //用户及用户下属
List<String> 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<String> underOrganizations = organizeService.getUnderOrganizations(orgId);
underOrganizations.add(orgId);
tw.or(
qw -> qw.in(itemField, underOrganizations)
);
} else if (AuthorizeConditionEnum.USERANDUNDER.getCondition().equals(itemValue)) { //用户及用户下属
List<String> idsList = new ArrayList<>();
if (userInfo.getSubordinateIds().size() > 0) {
idsList = userInfo.getSubordinateIds();
}
idsList.add(userInfo.getUserId());
List<String> 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;
}
/** /**
* *

Loading…
Cancel
Save