增加本机构数据权限的逻辑
This commit is contained in:
@@ -104,7 +104,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
用户排序
|
||||
排序
|
||||
</td>
|
||||
<td style="padding:5px">
|
||||
<input name="userBlngOrgaDsplSeq" id="userBlngOrgaDsplSeq" class="easyui-textbox" style="width: 230px;"/>
|
||||
@@ -175,7 +175,7 @@
|
||||
title: '操作', field: 'isystem', align: "center", width: 80,
|
||||
formatter: function (value, rec, index) {
|
||||
var str = '';
|
||||
if(rec.loginName != "jsh") {
|
||||
if(rec.userType != "演示用户") {
|
||||
str += '<img src="/js/easyui/themes/icons/pencil.png" style="cursor: pointer;" onclick="editUser(\'' + index + '\');"/> ';
|
||||
}
|
||||
if(isShowOpFun()) {
|
||||
@@ -188,19 +188,7 @@
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '用户类型', field: 'userType', width: 80, formatter: function (value, rec, index) {
|
||||
var str = '';
|
||||
if (rec.id == rec.tenantId) {
|
||||
str = "租户";
|
||||
} else if(rec.tenantId == null){
|
||||
str = "超管";
|
||||
} else {
|
||||
str = "普通";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
},
|
||||
{title: '用户类型', field: 'userType', width: 80},
|
||||
{title: '登录名称', field: 'loginName', width: 80, align: "center"},
|
||||
{title: '用户姓名', field: 'username', width: 80, align: "center"},
|
||||
{title: '角色', field: 'roleName', width: 80, align: "center"},
|
||||
@@ -208,7 +196,7 @@
|
||||
{title: '机构', field: 'orgAbr', width: 115, align: "center"},
|
||||
{title: '电子邮箱', field: 'email', width: 150, align: "center"},
|
||||
{title: '电话号码', field: 'phonenum', width: 150, align: "center"},
|
||||
{title: '用户排序', field: 'userBlngOrgaDsplSeq', width: 80, align: "center"},
|
||||
{title: '排序', field: 'userBlngOrgaDsplSeq', width: 80, align: "center"},
|
||||
{title: '描述', field: 'description', width: 130},
|
||||
{field: 'orgaId',hidden:true, width: 10}
|
||||
]],
|
||||
|
||||
@@ -18,6 +18,8 @@ public class UserEx extends User{
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String userType;
|
||||
|
||||
public String getOrgAbr() {
|
||||
return orgAbr;
|
||||
}
|
||||
@@ -57,4 +59,12 @@ public class UserEx extends User{
|
||||
public void setRoleName(String roleName) {
|
||||
this.roleName = roleName;
|
||||
}
|
||||
|
||||
public String getUserType() {
|
||||
return userType;
|
||||
}
|
||||
|
||||
public void setUserType(String userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface DepotHeadMapperEx {
|
||||
List<DepotHeadVo4List> selectByConditionDepotHead(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("handsPersonId") Long handsPersonId,
|
||||
@Param("handsPersonIds") String[] handsPersonIds,
|
||||
@Param("number") String number,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
@@ -33,7 +33,7 @@ public interface DepotHeadMapperEx {
|
||||
Long countsByDepotHead(
|
||||
@Param("type") String type,
|
||||
@Param("subType") String subType,
|
||||
@Param("handsPersonId") Long handsPersonId,
|
||||
@Param("handsPersonIds") String[] handsPersonIds,
|
||||
@Param("number") String number,
|
||||
@Param("beginTime") String beginTime,
|
||||
@Param("endTime") String endTime,
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.log.LogService;
|
||||
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
|
||||
import com.jsh.erp.service.serialNumber.SerialNumberService;
|
||||
import com.jsh.erp.service.supplier.SupplierService;
|
||||
import com.jsh.erp.service.user.UserService;
|
||||
@@ -53,6 +54,8 @@ public class DepotHeadService {
|
||||
@Resource
|
||||
private SerialNumberService serialNumberService;
|
||||
@Resource
|
||||
private OrgaUserRelService orgaUserRelService;
|
||||
@Resource
|
||||
DepotItemMapperEx depotItemMapperEx;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
@@ -81,15 +84,21 @@ public class DepotHeadService {
|
||||
|
||||
public List<DepotHeadVo4List> select(String type, String subType, String roleType, String number, String beginTime, String endTime,
|
||||
String materialParam, String depotIds, int offset, int rows)throws Exception {
|
||||
Long handsPersonId = null;
|
||||
String handsPersonIds = "";
|
||||
User user = userService.getCurrentUser();
|
||||
if("个人数据".equals(roleType)) {
|
||||
handsPersonId = user.getId();
|
||||
handsPersonIds = user.getId().toString();
|
||||
} else if("本机构数据".equals(roleType)) {
|
||||
handsPersonIds = orgaUserRelService.getUserIdListByUserId(user.getId());
|
||||
}
|
||||
String [] handsPersonIdArray=null;
|
||||
if(StringUtil.isNotEmpty(handsPersonIds)){
|
||||
handsPersonIdArray = handsPersonIds.split(",");
|
||||
}
|
||||
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
|
||||
List<DepotHeadVo4List> list=null;
|
||||
try{
|
||||
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, handsPersonId, number, beginTime, endTime, materialParam, depotIds, offset, rows);
|
||||
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, handsPersonIdArray, number, beginTime, endTime, materialParam, depotIds, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -125,14 +134,20 @@ public class DepotHeadService {
|
||||
|
||||
public Long countDepotHead(String type, String subType, String roleType,String number, String beginTime, String endTime,
|
||||
String materialParam, String depotIds) throws Exception{
|
||||
Long handsPersonId = null;
|
||||
String handsPersonIds = "";
|
||||
User user = userService.getCurrentUser();
|
||||
if("个人数据".equals(roleType)) {
|
||||
handsPersonId = user.getId();
|
||||
handsPersonIds = user.getId().toString();
|
||||
} else if("本机构数据".equals(roleType)) {
|
||||
handsPersonIds = orgaUserRelService.getUserIdListByUserId(user.getId());
|
||||
}
|
||||
String [] handsPersonIdArray=null;
|
||||
if(StringUtil.isNotEmpty(handsPersonIds)){
|
||||
handsPersonIdArray = handsPersonIds.split(",");
|
||||
}
|
||||
Long result=null;
|
||||
try{
|
||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, handsPersonId, number, beginTime, endTime, materialParam, depotIds);
|
||||
result=depotHeadMapperEx.countsByDepotHead(type, subType, handsPersonIdArray, number, beginTime, endTime, materialParam, depotIds);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -41,6 +42,8 @@ public class OrgaUserRelService {
|
||||
@Resource
|
||||
private UserService userService;
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
@Resource
|
||||
private LogService logService;
|
||||
|
||||
public OrgaUserRel getOrgaUserRel(long id) throws Exception{
|
||||
@@ -169,4 +172,48 @@ public class OrgaUserRelService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取用户id列表
|
||||
* @param userId
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public String getUserIdListByUserId(Long userId) throws Exception{
|
||||
OrgaUserRel our = new OrgaUserRel();
|
||||
OrgaUserRelExample example = new OrgaUserRelExample();
|
||||
example.createCriteria().andUserIdEqualTo(userId);
|
||||
List<OrgaUserRel> list = orgaUserRelMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
our = list.get(0);
|
||||
}
|
||||
List<Long> userIdList = getUserIdListByOrgId(our.getOrgaId());
|
||||
String users = "";
|
||||
for(Long u: userIdList){
|
||||
users = users + u + ",";
|
||||
}
|
||||
if(users.length()>0){
|
||||
users = users.substring(0,users.length()-1);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组织id获取所属的用户id列表(包含组织的递归)
|
||||
* @param orgId
|
||||
* @return
|
||||
*/
|
||||
public List<Long> getUserIdListByOrgId(Long orgId) {
|
||||
List<Long> orgIdList = organizationService.getOrgIdByParentId(orgId);
|
||||
List<Long> userIdList = new ArrayList<Long>();
|
||||
OrgaUserRelExample example = new OrgaUserRelExample();
|
||||
example.createCriteria().andOrgaIdIn(orgIdList).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
List<OrgaUserRel> list = orgaUserRelMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
for(OrgaUserRel our: list) {
|
||||
userIdList.add(our.getUserId());
|
||||
}
|
||||
}
|
||||
return userIdList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,4 +273,38 @@ public class OrganizationService {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据父级id递归获取子集组织id
|
||||
* @return
|
||||
*/
|
||||
public List<Long> getOrgIdByParentId(Long orgId) {
|
||||
List<Long> idList = new ArrayList<Long>();
|
||||
OrganizationExample example = new OrganizationExample();
|
||||
example.createCriteria().andIdEqualTo(orgId).andOrgStcdNotEqualTo(BusinessConstants.ORGANIZATION_STCD_REMOVED);
|
||||
List<Organization> orgList = organizationMapper.selectByExample(example);
|
||||
if(orgList!=null && orgList.size()>0) {
|
||||
idList.add(orgId);
|
||||
getOrgIdByParentNo(idList, orgList.get(0).getOrgNo());
|
||||
}
|
||||
return idList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据组织编号递归获取下级编号
|
||||
* @param orgNo
|
||||
* @return
|
||||
*/
|
||||
public void getOrgIdByParentNo(List<Long> idList,String orgNo) {
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
OrganizationExample example = new OrganizationExample();
|
||||
example.createCriteria().andOrgParentNoEqualTo(orgNo).andOrgStcdNotEqualTo(BusinessConstants.ORGANIZATION_STCD_REMOVED);
|
||||
List<Organization> orgList = organizationMapper.selectByExample(example);
|
||||
if(orgList!=null && orgList.size()>0) {
|
||||
for(Organization o: orgList) {
|
||||
idList.add(o.getId());
|
||||
getOrgIdByParentNo(idList, o.getOrgNo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,21 @@ public class UserService {
|
||||
List<UserEx> list=null;
|
||||
try{
|
||||
list=userMapperEx.selectByConditionUser(userName, loginName, offset, rows);
|
||||
for(UserEx ue: list){
|
||||
String userType = "";
|
||||
if(demonstrateOpen && TEST_USER.equals(ue.getLoginName())){
|
||||
userType = "演示用户";
|
||||
} else {
|
||||
if (ue.getId().equals(ue.getTenantId())) {
|
||||
userType = "租户";
|
||||
} else if(ue.getTenantId() == null){
|
||||
userType = "超管";
|
||||
} else {
|
||||
userType = "普通";
|
||||
}
|
||||
}
|
||||
ue.setUserType(userType);
|
||||
}
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
@@ -55,9 +55,6 @@
|
||||
<if test="subType != null">
|
||||
and dh.sub_type='${subType}'
|
||||
</if>
|
||||
<if test="handsPersonId != null">
|
||||
and dh.hands_person_id='${handsPersonId}'
|
||||
</if>
|
||||
<if test="number != null">
|
||||
and dh.number like '%${number}%'
|
||||
</if>
|
||||
@@ -73,6 +70,13 @@
|
||||
<if test="depotIds != null">
|
||||
and di.depot_id in (${depotIds})
|
||||
</if>
|
||||
<if test="handsPersonIds != null">
|
||||
and dh.hands_person_id in (
|
||||
<foreach collection="handsPersonIds" item="handsPersonId" separator=",">
|
||||
#{handsPersonId}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
and ifnull(dh.delete_flag,'0') !='1'
|
||||
order by dh.id desc
|
||||
<if test="offset != null and rows != null">
|
||||
@@ -92,9 +96,6 @@
|
||||
<if test="subType != null">
|
||||
and sub_type='${subType}'
|
||||
</if>
|
||||
<if test="handsPersonId != null">
|
||||
and hands_person_id='${handsPersonId}'
|
||||
</if>
|
||||
<if test="number != null">
|
||||
and number like '%${number}%'
|
||||
</if>
|
||||
@@ -110,6 +111,13 @@
|
||||
<if test="depotIds != null">
|
||||
and di.depot_id in (${depotIds})
|
||||
</if>
|
||||
<if test="handsPersonIds != null">
|
||||
and hands_person_id in (
|
||||
<foreach collection="handsPersonIds" item="handsPersonId" separator=",">
|
||||
#{handsPersonId}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
and ifnull(jsh_depot_head.delete_Flag,'0') !='1') tb
|
||||
</select>
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<if test="loginName != null">
|
||||
and user.login_name like '%${loginName}%'
|
||||
</if>
|
||||
order by user.id desc
|
||||
order by rel.user_blng_orga_dspl_seq,user.id desc
|
||||
<if test="offset != null and rows != null">
|
||||
limit #{offset},#{rows}
|
||||
</if>
|
||||
|
||||
Reference in New Issue
Block a user