优化出入库单据和财务的资源权限的控制

This commit is contained in:
季圣华
2020-09-13 19:00:03 +08:00
parent 4fe0fc3970
commit 0f8e54d680
25 changed files with 415 additions and 296 deletions

View File

@@ -31,21 +31,23 @@ public class AccountHeadComponent implements ICommonQuery {
private List<?> getAccountHeadList(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type");
String roleType = StringUtil.getInfo(search, "roleType");
String billNo = StringUtil.getInfo(search, "billNo");
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
String order = QueryUtils.order(map);
return accountHeadService.select(type, billNo, beginTime, endTime, QueryUtils.offset(map), QueryUtils.rows(map));
return accountHeadService.select(type, roleType, billNo, beginTime, endTime, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
public Long counts(Map<String, String> map)throws Exception {
String search = map.get(Constants.SEARCH);
String type = StringUtil.getInfo(search, "type");
String roleType = StringUtil.getInfo(search, "roleType");
String billNo = StringUtil.getInfo(search, "billNo");
String beginTime = StringUtil.getInfo(search, "beginTime");
String endTime = StringUtil.getInfo(search, "endTime");
return accountHeadService.countAccountHead(type, billNo, beginTime, endTime);
return accountHeadService.countAccountHead(type, roleType, billNo, beginTime, endTime);
}
@Override

View File

@@ -11,6 +11,7 @@ import com.jsh.erp.datasource.mappers.AccountItemMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService;
import com.jsh.erp.service.orgaUserRel.OrgaUserRelService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.StringUtil;
import org.slf4j.Logger;
@@ -32,13 +33,13 @@ import static com.jsh.erp.utils.Tools.getCenternTime;
@Service
public class AccountHeadService {
private Logger logger = LoggerFactory.getLogger(AccountHeadService.class);
@Resource
private AccountHeadMapper accountHeadMapper;
@Resource
private AccountHeadMapperEx accountHeadMapperEx;
@Resource
private OrgaUserRelService orgaUserRelService;
@Resource
private UserService userService;
@Resource
private LogService logService;
@@ -79,11 +80,12 @@ public class AccountHeadService {
return list;
}
public List<AccountHeadVo4ListEx> select(String type, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{
public List<AccountHeadVo4ListEx> select(String type, String roleType, String billNo, String beginTime, String endTime, int offset, int rows) throws Exception{
List<AccountHeadVo4ListEx> resList = new ArrayList<AccountHeadVo4ListEx>();
List<AccountHeadVo4ListEx> list=null;
try{
list = accountHeadMapperEx.selectByConditionAccountHead(type, billNo, beginTime, endTime, offset, rows);
String [] creatorArray = getCreatorArray(roleType);
list = accountHeadMapperEx.selectByConditionAccountHead(type, creatorArray, billNo, beginTime, endTime, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -102,21 +104,45 @@ public class AccountHeadService {
return resList;
}
public Long countAccountHead(String type, String billNo, String beginTime, String endTime) throws Exception{
public Long countAccountHead(String type, String roleType, String billNo, String beginTime, String endTime) throws Exception{
Long result=null;
try{
result = accountHeadMapperEx.countsByAccountHead(type, billNo, beginTime, endTime);
String [] creatorArray = getCreatorArray(roleType);
result = accountHeadMapperEx.countsByAccountHead(type, creatorArray, billNo, beginTime, endTime);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
/**
* 根据角色类型获取操作员数组
* @param roleType
* @return
* @throws Exception
*/
private String[] getCreatorArray(String roleType) throws Exception {
String creator = "";
User user = userService.getCurrentUser();
if(BusinessConstants.ROLE_TYPE_PRIVATE.equals(roleType)) {
creator = user.getId().toString();
} else if(BusinessConstants.ROLE_TYPE_THIS_ORG.equals(roleType)) {
creator = orgaUserRelService.getUserIdListByUserId(user.getId());
}
String [] creatorArray=null;
if(StringUtil.isNotEmpty(creator)){
creatorArray = creator.split(",");
}
return creatorArray;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertAccountHead(String beanJson, HttpServletRequest request) throws Exception{
AccountHead accountHead = JSONObject.parseObject(beanJson, AccountHead.class);
int result=0;
try{
User userInfo=userService.getCurrentUser();
accountHead.setCreator(userInfo==null?null:userInfo.getId());
result = accountHeadMapper.insertSelective(accountHead);
logService.insertLog("财务",
new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(accountHead.getBillNo()).toString(), request);
@@ -274,6 +300,7 @@ public class AccountHeadService {
if(ah.getTotalPrice() != null) {
ah.setTotalPrice(ah.getTotalPrice().abs());
}
ah.setBillTimeStr(getCenternTime(ah.getBillTime()));
resList.add(ah);
}
}

View File

@@ -84,11 +84,11 @@ 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 {
String [] handsPersonIdArray = getHandsPersonIdArray(roleType);
List<DepotHeadVo4List> resList = new ArrayList<DepotHeadVo4List>();
List<DepotHeadVo4List> list=null;
try{
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, handsPersonIdArray, number, beginTime, endTime, materialParam, depotIds, offset, rows);
String [] creatorArray = getCreatorArray(roleType);
list=depotHeadMapperEx.selectByConditionDepotHead(type, subType, creatorArray, number, beginTime, endTime, materialParam, depotIds, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -124,10 +124,10 @@ public class DepotHeadService {
public Long countDepotHead(String type, String subType, String roleType,String number, String beginTime, String endTime,
String materialParam, String depotIds) throws Exception{
String [] handsPersonIdArray = getHandsPersonIdArray(roleType);
Long result=null;
try{
result=depotHeadMapperEx.countsByDepotHead(type, subType, handsPersonIdArray, number, beginTime, endTime, materialParam, depotIds);
String [] creatorArray = getCreatorArray(roleType);
result=depotHeadMapperEx.countsByDepotHead(type, subType, creatorArray, number, beginTime, endTime, materialParam, depotIds);
}catch(Exception e){
JshException.readFail(logger, e);
}
@@ -135,36 +135,29 @@ public class DepotHeadService {
}
/**
* 根据角色类型获取经手人数组
* 根据角色类型获取操作员数组
* @param roleType
* @return
* @throws Exception
*/
private String[] getHandsPersonIdArray(String roleType) throws Exception {
String handsPersonIds = "";
private String[] getCreatorArray(String roleType) throws Exception {
String creator = "";
User user = userService.getCurrentUser();
if(BusinessConstants.ROLE_TYPE_PRIVATE.equals(roleType)) {
handsPersonIds = user.getId().toString();
creator = user.getId().toString();
} else if(BusinessConstants.ROLE_TYPE_THIS_ORG.equals(roleType)) {
handsPersonIds = orgaUserRelService.getUserIdListByUserId(user.getId());
creator = orgaUserRelService.getUserIdListByUserId(user.getId());
}
String [] handsPersonIdArray=null;
if(StringUtil.isNotEmpty(handsPersonIds)){
handsPersonIdArray = handsPersonIds.split(",");
String [] creatorArray=null;
if(StringUtil.isNotEmpty(creator)){
creatorArray = creator.split(",");
}
return handsPersonIdArray;
return creatorArray;
}
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int insertDepotHead(String beanJson, HttpServletRequest request)throws Exception {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理
Object userInfo = request.getSession().getAttribute("user");
if (userInfo != null) {
User sessionUser = (User) userInfo;
String uName = sessionUser.getUsername();
depotHead.setOperPersonName(uName);
}
depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
int result=0;
@@ -189,7 +182,6 @@ public class DepotHeadService {
depotHead.setId(id);
depotHead.setStatus(dh.getStatus());
depotHead.setCreateTime(dh.getCreateTime());
depotHead.setOperPersonName(dh.getOperPersonName());
int result=0;
try{
result = depotHeadMapper.updateByPrimaryKey(depotHead);
@@ -282,16 +274,6 @@ public class DepotHeadService {
}
}
public Long getMaxId()throws Exception {
Long result = null;
try{
result = depotHeadMapperEx.getMaxId();
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public String findMaterialsListByHeaderId(Long id)throws Exception {
String result = null;
try{
@@ -490,8 +472,7 @@ public class DepotHeadService {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理
User userInfo=userService.getCurrentUser();
depotHead.setHandsPersonId(userInfo==null?null:userInfo.getId());
depotHead.setOperPersonName(userInfo==null?null:userInfo.getUsername());
depotHead.setCreator(userInfo==null?null:userInfo.getId());
depotHead.setCreateTime(new Timestamp(System.currentTimeMillis()));
depotHead.setStatus(BusinessConstants.BILLS_STATUS_UN_AUDIT);
try{
@@ -550,8 +531,6 @@ public class DepotHeadService {
DepotHead depotHead = JSONObject.parseObject(beanJson, DepotHead.class);
//判断用户是否已经登录过,登录过不再处理
depotHead.setId(id);
User userInfo=userService.getCurrentUser();
depotHead.setOperPersonName(userInfo==null?null:userInfo.getUsername());
try{
depotHeadMapper.updateByPrimaryKeySelective(depotHead);
}catch(Exception e){

View File

@@ -264,7 +264,7 @@ public class PersonService {
* */
List<DepotHead> depotHeadList =null;
try{
depotHeadList=depotHeadMapperEx.getDepotHeadListByHandsPersonIds(idArray);
depotHeadList=depotHeadMapperEx.getDepotHeadListByCreator(idArray);
}catch(Exception e){
JshException.readFail(logger, e);
}