|
@@ -13,6 +13,7 @@ import com.imed.costaccount.model.dto.AccountingSaveDTO;
|
|
|
import com.imed.costaccount.model.vo.AccountVO;
|
|
|
import com.imed.costaccount.model.vo.SelectAccountingVO;
|
|
|
import com.imed.costaccount.service.AccountingService;
|
|
|
+import com.imed.costaccount.service.CostShareParamService;
|
|
|
import com.imed.costaccount.utils.BeanUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -26,27 +27,46 @@ import java.util.stream.Collectors;
|
|
|
@Service("accountingService")
|
|
|
public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Accounting> implements AccountingService {
|
|
|
|
|
|
+ private final CostShareParamService shareParamService;
|
|
|
+
|
|
|
+ public AccountingServiceImpl(CostShareParamService shareParamService) {
|
|
|
+ this.shareParamService = shareParamService;
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 获取会计科目列表按收入支出类型
|
|
|
*
|
|
|
- * @param accountType 会计科目类型1.收入,2.支出
|
|
|
+ * @param accountType 会计科目类型1.收入,2.支出
|
|
|
* @param user
|
|
|
+ * @param shareParamId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<AccountVO> getListByAccountType(Integer accountType, User user) {
|
|
|
+ public List<AccountVO> getListByAccountType(Integer accountType, User user, Integer shareParamId) {
|
|
|
// 1. 得到所有的会计科目
|
|
|
List<Accounting> list = this.list(
|
|
|
new LambdaQueryWrapper<Accounting>()
|
|
|
.eq(Accounting::getHospId, user.getHospId())
|
|
|
- .orderByDesc(Accounting::getCreateTime)
|
|
|
+ .eq(Accounting::getAccountingType, accountType)
|
|
|
+ .orderByDesc(Accounting::getCreateTime)
|
|
|
);
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
// 所有的
|
|
|
List<AccountVO> all = list.stream().map(i -> BeanUtil.convertObj(i, AccountVO.class)).collect(Collectors.toList());
|
|
|
+ // 查询所有的已绑定的
|
|
|
+ if (Objects.nonNull(shareParamId)) {
|
|
|
+ List<Integer> ids = shareParamService.selectIsSelect(shareParamId);
|
|
|
+ if (CollUtil.isNotEmpty(ids)) {
|
|
|
+ all.forEach(i -> {
|
|
|
+ if (ids.contains(i.getId())) {
|
|
|
+ i.setIsSelect(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
// 顶层的
|
|
|
List<AccountVO> parents = all.stream().filter(i -> i.getParentId() == 0).collect(Collectors.toList());
|
|
|
List<AccountVO> accountVOS = new ArrayList<>();
|
|
@@ -59,6 +79,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
|
|
|
/**
|
|
|
* 递归处理
|
|
|
+ *
|
|
|
* @param accountVO
|
|
|
* @param list
|
|
|
* @return
|
|
@@ -153,14 +174,14 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
@Override
|
|
|
public List<SelectAccountingVO> selectAccounting(User user) {
|
|
|
List<Accounting> list = this.list(
|
|
|
- new LambdaQueryWrapper<Accounting>().select(Accounting::getId,Accounting::getAccountingName,Accounting::getParentId,Accounting::getAllParentIds)
|
|
|
+ new LambdaQueryWrapper<Accounting>().select(Accounting::getId, Accounting::getAccountingName, Accounting::getParentId, Accounting::getAllParentIds)
|
|
|
.eq(Accounting::getHospId, user.getHospId())
|
|
|
);
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
// 所有的
|
|
|
- List<SelectAccountingVO> all = list.stream().map(i ->{
|
|
|
+ List<SelectAccountingVO> all = list.stream().map(i -> {
|
|
|
SelectAccountingVO vo = new SelectAccountingVO();
|
|
|
vo.setValue(i.getId());
|
|
|
vo.setLabel(i.getAccountingName());
|
|
@@ -205,12 +226,12 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
* @param user
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public void updateAccount(AccountingEditDTO accountingEditDTO, User user) {
|
|
|
// TODO: 2021/7/28 追踪溯源需求不满足
|
|
|
Integer id = accountingEditDTO.getId();
|
|
|
// this.checkAccountingCode(accountingEditDTO.getAccountingCode(), user.getHospId());
|
|
|
- Accounting one = this.baseMapper.selectOne(
|
|
|
+ Accounting one = this.baseMapper.selectOne(
|
|
|
new QueryWrapper<Accounting>().lambda()
|
|
|
.eq(Accounting::getAccountingCode, accountingEditDTO.getAccountingCode())
|
|
|
.eq(Accounting::getHospId, user.getHospId())
|
|
@@ -222,7 +243,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
throw new CostException(500, "当前选中会计科目已被移除");
|
|
|
}
|
|
|
if (Objects.nonNull(one) && !byId.getAccountingCode().equals(one.getAccountingCode())) {
|
|
|
- throw new CostException(500, "会计科目代码已存在,请重新生成");
|
|
|
+ throw new CostException(500, "会计科目代码已存在,请重新生成");
|
|
|
}
|
|
|
// 直接修改
|
|
|
byId.setAccountingCode(accountingEditDTO.getAccountingCode());
|
|
@@ -269,7 +290,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
// return allParentIds;
|
|
|
// }
|
|
|
|
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public void saveAccount(AccountingEditDTO accountingEditDTO, User user, Accounting byId, Accounting accounting) {
|
|
|
this.checkAccountingCode(accountingEditDTO.getAccountingCode(), user.getHospId());
|
|
|
accounting.setAccountingCode(accounting.getAccountingCode());
|
|
@@ -295,6 +316,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
|
|
|
/**
|
|
|
* 得到自己还有所有的子节点
|
|
|
+ *
|
|
|
* @param ids
|
|
|
* @param accounts
|
|
|
* @return
|
|
@@ -303,7 +325,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
|
|
|
List<Accounting> list = this.list(
|
|
|
new LambdaQueryWrapper<Accounting>()
|
|
|
- .in(Accounting::getParentId, ids).eq(Accounting::getHospId,hospId)
|
|
|
+ .in(Accounting::getParentId, ids).eq(Accounting::getHospId, hospId)
|
|
|
);
|
|
|
if (CollUtil.isEmpty(list)) {
|
|
|
return accounts;
|
|
@@ -320,7 +342,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
* @param user
|
|
|
*/
|
|
|
@Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public void deleteAccount(Integer id, User user) {
|
|
|
List<Accounting> list = new ArrayList<>();
|
|
|
List<Accounting> andAllChild = this.getAndAllChild(Arrays.asList(id), user.getHospId(), list);
|