|
@@ -8,23 +8,22 @@ import com.imed.costaccount.common.exception.CostException;
|
|
|
import com.imed.costaccount.mapper.AccountingMapper;
|
|
|
import com.imed.costaccount.model.Accounting;
|
|
|
import com.imed.costaccount.model.User;
|
|
|
+import com.imed.costaccount.model.dto.AccountingEditDTO;
|
|
|
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.utils.BeanUtil;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.beanutils.BeanUtilsBean;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-
|
|
|
+@Slf4j
|
|
|
@Service("accountingService")
|
|
|
public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Accounting> implements AccountingService {
|
|
|
|
|
@@ -180,4 +179,45 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
|
|
|
}
|
|
|
return accountVOS;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑科目代码
|
|
|
+ *
|
|
|
+ * @param accountingEditDTO
|
|
|
+ * @param user
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void updateAccount(AccountingEditDTO accountingEditDTO, User user) {
|
|
|
+ Integer id = accountingEditDTO.getId();
|
|
|
+ List<Accounting> accounts = new ArrayList<>();
|
|
|
+ Accounting byId = this.getById(id);
|
|
|
+ // TODO: 2021/7/28 校验
|
|
|
+ accounts.add(byId);
|
|
|
+ // 如果是顶层的修改
|
|
|
+ getAndAllChild(Arrays.asList(id), user.getHospId(), accounts);
|
|
|
+ log.info("得到所有的这个下面的列表:{}", accounts);
|
|
|
+ Map<Integer, List<Accounting>> map = accounts.stream().collect(Collectors.groupingBy(Accounting::getId));
|
|
|
+ // 删除所有的列表
|
|
|
+// this.remove
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 得到自己还有所有的子节点
|
|
|
+ * @param ids
|
|
|
+ * @param accounts
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<Accounting> getAndAllChild(List<Integer> ids, Integer hospId, List<Accounting> accounts) {
|
|
|
+
|
|
|
+ List<Accounting> list = this.list(
|
|
|
+ new LambdaQueryWrapper<Accounting>()
|
|
|
+ .in(Accounting::getParentId, ids).eq(Accounting::getHospId,hospId)
|
|
|
+ );
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
+ return accounts;
|
|
|
+ }
|
|
|
+ accounts.addAll(list);
|
|
|
+ this.getAndAllChild(list.stream().map(Accounting::getId).collect(Collectors.toList()), hospId, accounts);
|
|
|
+ return accounts;
|
|
|
+ }
|
|
|
}
|