收入合同权限修改

This commit is contained in:
梁琦涛
2021-10-26 19:15:21 +08:00
parent f1a5b3ac37
commit f857095b4f
3 changed files with 37 additions and 29 deletions
@@ -98,6 +98,10 @@ public class PaySpendingContractController extends JeroController<PaySpendingCon
if(!StringUtils.isBlank(paySpendingContract.getContractNum())){
paySpendingContract.setContractNum(oConvertUtils.replaceAllPercent(paySpendingContract.getContractNum()));
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
paySpendingContract.setPrincipalId(sysUser.getId());
}
Page<PaySpendingContract> page = new Page<>(pageNo, pageSize);
IPage<PaySpendingContract> pageList = paySpendingContractService.queryPageList(page, paySpendingContract,startTime,endTime);
return Result.OK(pageList);
@@ -251,10 +251,8 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
throw new JeroBootException("收入合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContractStatus.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),payIncomeContractStatus.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
// 项目已打包
if(Objects.equals(payIncomeContractStatus.getPack(),PayIncomeContractCommon.PACK1)){
@@ -320,10 +318,8 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
throw new JeroBootException("合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
if(Objects.isNull(payIncomeContract.getAmountReceived())){
payIncomeContract.setAmountReceived(new BigDecimal("0.00"));
@@ -598,10 +594,8 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
throw new JeroBootException("合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),payIncomeContract.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
// 查看项目类型
switch (String.valueOf(payIncomeContractAssociated.getProjectType())){
@@ -750,10 +744,8 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
throw new JeroBootException("合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContractNew.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),payIncomeContractNew.getPrincipalId())){
throw new JeroBootException("收入合同不可操作!");
}
// 验证合同状态是否为草稿或者未通过
if(!Objects.equals(payIncomeContract.getStatus(),PayIncomeContractCommon.STATUS2)
@@ -1010,10 +1002,8 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
throw new JeroBootException("收入合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),payIncomeContractStatus.getPrincipalId())){
throw new JeroBootException(payIncomeContractStatus.getContractName() + "收入合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),payIncomeContractStatus.getPrincipalId())){
throw new JeroBootException(payIncomeContractStatus.getContractName() + "收入合同不可操作!");
}
if(!Objects.equals(payIncomeContractStatus.getStatus(),PayIncomeContractCommon.STATUS1)
&& !Objects.equals(payIncomeContractStatus.getStatus(),PayIncomeContractCommon.STATUS4)){
@@ -1044,14 +1034,12 @@ public class PayIncomeContractServiceImpl extends ServiceImpl<PayIncomeContractM
StringBuilder msg = new StringBuilder();
StringBuilder msg1 = new StringBuilder();
listPayIncomeContractStatus.forEach(p->{
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),p.getPrincipalId())){
msg.append("收入合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),p.getPrincipalId())){
msg.append(p.getContractName() + "收入合同不可操作!");
}
if(!Objects.equals(p.getStatus(),PayIncomeContractCommon.STATUS1)
&& !Objects.equals(p.getStatus(),PayIncomeContractCommon.STATUS4)){
msg1.append("收入合同不可删除!");
msg1.append(p.getContractName() + "收入合同不可删除!");
}
});
if(!StringUtils.isEmpty(msg)){
@@ -159,6 +159,10 @@ public class PaySpendingContractServiceImpl extends ServiceImpl<PaySpendingContr
if(Objects.isNull(paySpendingContractStatus)){
throw new JeroBootException("支出合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),paySpendingContractStatus.getPrincipalId())){
throw new JeroBootException("支出合同不可操作!");
}
List<PaySpendingContractInstallment> listPaySpendingContractInstallment = new ArrayList<>();
if(!CollectionUtils.isEmpty(input.getInstallment())){
listPaySpendingContractInstallment = input.getInstallment();
@@ -221,10 +225,8 @@ public class PaySpendingContractServiceImpl extends ServiceImpl<PaySpendingContr
throw new JeroBootException("支出合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
if(!Objects.equals(sysUser.getId(),paySpendingContractStatus.getPrincipalId())){
throw new JeroBootException(paySpendingContractStatus.getContractName() + "支出合同不可操作!");
}
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY) && !Objects.equals(sysUser.getId(),paySpendingContractStatus.getPrincipalId())){
throw new JeroBootException("支出合同不可操作!");
}
paySpendingContractService.removeById(id);
LambdaUpdateWrapper<PaySpendingContractInstallment> updatePaySpendingContractInstallment = new LambdaUpdateWrapper<>();
@@ -241,6 +243,20 @@ public class PaySpendingContractServiceImpl extends ServiceImpl<PaySpendingContr
if(CollectionUtils.isEmpty(listPaySpendingContractStatus)){
throw new JeroBootException("收入合同不存在!");
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
StringBuilder msg = new StringBuilder();
if(!sysUser.getRoleCode().contains(RoleCommon.CWRY)){
listPaySpendingContractStatus.forEach(p->{
if(!Objects.equals(sysUser.getId(),p.getPrincipalId())){
msg.append(p.getContractName() + "支出合同不可操作!");
}
});
}
if(!StringUtils.isEmpty(msg)){
throw new JeroBootException(msg.toString());
}
paySpendingContractService.removeByIds(ids);
LambdaUpdateWrapper<PaySpendingContractInstallment> updatePaySpendingContractInstallment = new LambdaUpdateWrapper<>();
updatePaySpendingContractInstallment.in(PaySpendingContractInstallment::getContractId,ids);