增加仓库和角色类型的数据权限控制
This commit is contained in:
@@ -1,18 +1,24 @@
|
||||
package com.jsh.erp.service.depot;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.*;
|
||||
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx;
|
||||
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
|
||||
import com.jsh.erp.datasource.mappers.DepotMapper;
|
||||
import com.jsh.erp.datasource.mappers.DepotMapperEx;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.systemConfig.SystemConfigService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||
import com.jsh.erp.utils.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
@@ -23,7 +29,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class DepotService {
|
||||
@@ -37,6 +42,10 @@ public class DepotService {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private SystemConfigService systemConfigService;
|
||||
@Resource
|
||||
private UserBusinessService userBusinessService;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
@Resource
|
||||
private DepotHeadMapperEx depotHeadMapperEx;
|
||||
@@ -264,4 +273,51 @@ public class DepotService {
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public JSONArray findDepotByCurrentUser() throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
String type = "UserDepot";
|
||||
Long userId = userService.getCurrentUser().getId();
|
||||
List<Depot> dataList = findUserDepot();
|
||||
//开始拼接json数据
|
||||
if (null != dataList) {
|
||||
boolean depotFlag = systemConfigService.getDepotFlag();
|
||||
for (Depot depot : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
//勾选判断1
|
||||
Boolean flag = false;
|
||||
try {
|
||||
flag = userBusinessService.checkIsUserBusinessExist(type, userId.toString(), "[" + depot.getId().toString() + "]");
|
||||
} catch (DataAccessException e) {
|
||||
logger.error(">>>>>>>>>>>>>>>>>查询用户对应的仓库:类型" + type + " KeyId为: " + userId + " 存在异常!");
|
||||
}
|
||||
if (!depotFlag || flag) {
|
||||
item.put("id", depot.getId());
|
||||
item.put("depotName", depot.getName());
|
||||
item.put("isDefault", depot.getIsDefault());
|
||||
arr.add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前用户有权限使用的仓库列表的id,用逗号隔开
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String findDepotStrByCurrentUser() throws Exception {
|
||||
JSONArray arr = findDepotByCurrentUser();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for(Object object: arr) {
|
||||
JSONObject obj = (JSONObject)object;
|
||||
sb.append(obj.getLong("id")).append(",");
|
||||
}
|
||||
String depotStr = sb.toString();
|
||||
if(StringUtil.isNotEmpty(depotStr)){
|
||||
depotStr = depotStr.substring(0, depotStr.length()-1);
|
||||
}
|
||||
return depotStr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,8 +39,7 @@ public class DepotHeadComponent implements ICommonQuery {
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String materialParam = StringUtil.getInfo(search, "materialParam");
|
||||
String depotIds = StringUtil.getInfo(search, "depotIds");
|
||||
return depotHeadService.select(type, subType, roleType, status, number, beginTime, endTime, materialParam, depotIds, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
return depotHeadService.select(type, subType, roleType, status, number, beginTime, endTime, materialParam, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,8 +53,7 @@ public class DepotHeadComponent implements ICommonQuery {
|
||||
String beginTime = StringUtil.getInfo(search, "beginTime");
|
||||
String endTime = StringUtil.getInfo(search, "endTime");
|
||||
String materialParam = StringUtil.getInfo(search, "materialParam");
|
||||
String depotIds = StringUtil.getInfo(search, "depotIds");
|
||||
return depotHeadService.countDepotHead(type, subType, roleType, status, number, beginTime, endTime, materialParam, depotIds);
|
||||
return depotHeadService.countDepotHead(type, subType, roleType, status, number, beginTime, endTime, materialParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.jsh.erp.datasource.vo.DepotHeadVo4StatementAccount;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.account.AccountService;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
|
||||
@@ -49,6 +50,8 @@ public class DepotHeadService {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private DepotService depotService;
|
||||
@Resource
|
||||
DepotItemService depotItemService;
|
||||
@Resource
|
||||
private SupplierService supplierService;
|
||||
@@ -90,10 +93,11 @@ public class DepotHeadService {
|
||||
}
|
||||
|
||||
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
|
||||
String materialParam, String depotIds, int offset, int rows)throws Exception {
|
||||
String materialParam, int offset, int rows)throws Exception {
|
||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||
List<DepotHeadVo4List> list=new ArrayList<>();
|
||||
try{
|
||||
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
Map<Long,String> personMap = personService.getPersonMap();
|
||||
Map<Long,String> accountMap = accountService.getAccountMap();
|
||||
@@ -135,9 +139,10 @@ public class DepotHeadService {
|
||||
}
|
||||
|
||||
public Long countDepotHead(String type, String subType, String roleType, String status, String number, String beginTime, String endTime,
|
||||
String materialParam, String depotIds) throws Exception{
|
||||
String materialParam) throws Exception{
|
||||
Long result=null;
|
||||
try{
|
||||
String depotIds = depotService.findDepotStrByCurrentUser();
|
||||
String [] creatorArray = getCreatorArray(roleType);
|
||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, status, number, beginTime, endTime, materialParam, depotIds);
|
||||
}catch(Exception e){
|
||||
|
||||
Reference in New Issue
Block a user