|
@@ -25,6 +25,7 @@ import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
|
import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
|
|
|
import com.fjhx.tenant.service.dict.DictTenantDataService;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -75,6 +76,10 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
.like(AccountManagement::getOpeningBank, dto.getKeyword());
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ //权限过滤:资金账户
|
|
|
+ wrapper.eq(AccountManagement::getCompanyId, SecurityUtils.getCompanyId());
|
|
|
+
|
|
|
Page<AccountManagementVo> page = baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
List<AccountManagementVo> records = page.getRecords();
|
|
|
//赋值归属公司名称
|
|
@@ -110,10 +115,13 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = {Exception.class})
|
|
|
public void add(AccountManagementDto accountManagementDto) {
|
|
|
+ //赋值归属公司
|
|
|
+ accountManagementDto.setCompanyId(SecurityUtils.getCompanyId());
|
|
|
+
|
|
|
//判断账户的别名是否已存在
|
|
|
List<AccountManagement> accountManagements = this.list(Wrappers.<AccountManagement>lambdaQuery()
|
|
|
.eq(AccountManagement::getAlias, accountManagementDto.getAlias()));
|
|
|
- if (accountManagements.size()>0){
|
|
|
+ if (accountManagements.size() > 0) {
|
|
|
throw new ServiceException("数据错误:账户别名已存在请重新创建");
|
|
|
}
|
|
|
//添加账户管理表的信息
|
|
@@ -132,15 +140,15 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
//判断账户的别名是否已存在
|
|
|
List<AccountManagement> accountManagements = this.list(Wrappers.<AccountManagement>lambdaQuery()
|
|
|
.eq(AccountManagement::getAlias, accountManagementDto.getAlias()));
|
|
|
- if (accountManagements.size()>1){
|
|
|
+ if (accountManagements.size() > 1) {
|
|
|
throw new ServiceException("数据错误:账户别名已存在请重新创建");
|
|
|
}
|
|
|
//删除账户-余额表的信息
|
|
|
List<AccountRemainder> accountRemainderList = accountManagementDto.getAccountRemainderList();
|
|
|
List<Long> ids = accountRemainderList.stream().map(accountRemainder -> accountRemainder.getId()).collect(Collectors.toList());
|
|
|
accountRemainderService.remove(Wrappers.<AccountRemainder>lambdaQuery()
|
|
|
- .eq(AccountRemainder::getAccountManagementId,accountManagementDto.getId())
|
|
|
- .notIn(AccountRemainder::getId,ids)
|
|
|
+ .eq(AccountRemainder::getAccountManagementId, accountManagementDto.getId())
|
|
|
+ .notIn(AccountRemainder::getId, ids)
|
|
|
);
|
|
|
//添加账户余额表的信息
|
|
|
saveAccountRemainder(accountManagementDto);
|
|
@@ -156,21 +164,21 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
List<AccountRunningWater> accountRunningWaterList = accountRunningWaterService.list(Wrappers.<AccountRunningWater>lambdaQuery()
|
|
|
.eq(AccountRunningWater::getAccountManagementId, id));
|
|
|
//如果存在流水表的数据则不能删除账户表的信息
|
|
|
- if (accountRunningWaterList.size()>0){
|
|
|
+ if (accountRunningWaterList.size() > 0) {
|
|
|
throw new ServiceException("无法删除,该账户已存在流水数据");
|
|
|
}
|
|
|
//删除账户-管理表的信息
|
|
|
this.removeById(id);
|
|
|
//删除账户-余额表的信息
|
|
|
accountRemainderService.remove(Wrappers.<AccountRemainder>lambdaQuery()
|
|
|
- .eq(AccountRemainder::getAccountManagementId,id));
|
|
|
+ .eq(AccountRemainder::getAccountManagementId, id));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 账户统计(账户列表)
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<Map<String, Object>> managementStatistics(AccountManagementSelectDto dto) {
|
|
|
+ public List<Map<String, Object>> managementStatistics(AccountManagementSelectDto dto) {
|
|
|
//存放账户统计数据
|
|
|
List<Map<String, Object>> list = new ArrayList<>();
|
|
|
|
|
@@ -185,24 +193,24 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
List<DictTenantDataVo> dictTenantDataVos = getDict("customer_source");
|
|
|
DynamicDataSourceContextHolder.poll();
|
|
|
|
|
|
- if (dictTenantDataVos.size()==0){
|
|
|
+ if (dictTenantDataVos.size() == 0) {
|
|
|
throw new ServiceException("数据有误:没有配置币种字典,请先配置");
|
|
|
}
|
|
|
|
|
|
//赋值
|
|
|
for (DictTenantDataVo dictTenantDataVo : dictTenantDataVos) {
|
|
|
//赋初始值信息
|
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
- map.put("currencyKey",dictTenantDataVo.getDictKey());
|
|
|
- map.put("currencyValue",dictTenantDataVo.getDictValue());
|
|
|
- map.put("remainder",new BigDecimal(0));
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("currencyKey", dictTenantDataVo.getDictKey());
|
|
|
+ map.put("currencyValue", dictTenantDataVo.getDictValue());
|
|
|
+ map.put("remainder", new BigDecimal(0));
|
|
|
//赋值余额信息
|
|
|
- if (accountRemainderList.size()>0){
|
|
|
+ if (accountRemainderList.size() > 0) {
|
|
|
Map<String, List<AccountRemainder>> accountRemainderMap = accountRemainderList.stream()
|
|
|
.collect(Collectors.groupingBy(AccountRemainder::getCurrency));
|
|
|
List<AccountRemainder> accountRemainderList1 = accountRemainderMap.get(dictTenantDataVo.getDictKey());
|
|
|
- if (ObjectUtil.isNotEmpty(accountRemainderList1)){
|
|
|
- map.put("remainder",accountRemainderList1.get(0).getRemainder());
|
|
|
+ if (ObjectUtil.isNotEmpty(accountRemainderList1)) {
|
|
|
+ map.put("remainder", accountRemainderList1.get(0).getRemainder());
|
|
|
}
|
|
|
}
|
|
|
list.add(map);
|
|
@@ -212,7 +220,7 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
}
|
|
|
|
|
|
//根据字典编码获取字典的数据
|
|
|
- private List<DictTenantDataVo> getDict(String code){
|
|
|
+ private List<DictTenantDataVo> getDict(String code) {
|
|
|
DictTenantDataSelectDto dto = new DictTenantDataSelectDto();
|
|
|
dto.setDictCode(code);
|
|
|
return dictTenantDataService.getList(dto);
|
|
@@ -319,7 +327,7 @@ public class AccountManagementServiceImpl extends ServiceImpl<AccountManagementM
|
|
|
/**
|
|
|
* 添加账户-余额表的信息
|
|
|
*/
|
|
|
- private void saveAccountRemainder(AccountManagementDto accountManagementDto){
|
|
|
+ private void saveAccountRemainder(AccountManagementDto accountManagementDto) {
|
|
|
List<AccountRemainder> accountRemainderList = accountManagementDto.getAccountRemainderList();
|
|
|
accountRemainderList.forEach(accountRemainder -> {
|
|
|
accountRemainder.setAccountManagementId(accountManagementDto.getId());
|