|
@@ -8,8 +8,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.imed.costaccount.common.exception.CostException;
|
|
|
import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
|
+import com.imed.costaccount.common.util.UserContext;
|
|
|
import com.imed.costaccount.constants.NumberConstant;
|
|
|
+import com.imed.costaccount.mapper.AccountingMapper;
|
|
|
import com.imed.costaccount.mapper.CostShareParamMapper;
|
|
|
+import com.imed.costaccount.model.Accounting;
|
|
|
import com.imed.costaccount.model.CostShareParam;
|
|
|
import com.imed.costaccount.model.dto.CostShareParamAccountDto;
|
|
|
import com.imed.costaccount.model.dto.CostShareParamEditDto;
|
|
@@ -30,6 +33,12 @@ import java.util.stream.Collectors;
|
|
|
@Service("costShareParamService")
|
|
|
public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper, CostShareParam> implements CostShareParamService {
|
|
|
|
|
|
+ private final AccountingMapper accountingMapper;
|
|
|
+
|
|
|
+ public CostShareParamServiceImpl(AccountingMapper accountingMapper) {
|
|
|
+ this.accountingMapper = accountingMapper;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 分页查询相关的分摊参数数据
|
|
|
*
|
|
@@ -119,15 +128,23 @@ public class CostShareParamServiceImpl extends ServiceImpl<CostShareParamMapper,
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
|
|
|
public CostShareParam updateCostShareParamByAccountId(CostShareParamAccountDto costShareParamAccountDto) {
|
|
|
+ Long hospId = UserContext.getHospId();
|
|
|
Long costShareParamId = costShareParamAccountDto.getCostShareParamId();
|
|
|
CostShareParam costShareParam = baseMapper.selectById(costShareParamId);
|
|
|
+ List<String> accoutingCodes = new LinkedList<>();
|
|
|
+ Map<Long, String> accountingMap = accountingMapper.selectList(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, Accounting::getAccountingCode));
|
|
|
// 判断当前操作的分层参数的计算方式是不是按科目计算
|
|
|
if (NumberConstant.TWO.equals(costShareParam.getCalcType())){
|
|
|
String[] accountIds = costShareParamAccountDto.getAccountIds();
|
|
|
List<String> accountList = Arrays.asList(accountIds);
|
|
|
if (!CollectionUtil.isEmpty(accountList)){
|
|
|
- String accounds = accountList.stream().map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
|
|
|
- costShareParam.setAccountingId(accounds);
|
|
|
+ String accountingIds = accountList.stream().map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA));
|
|
|
+ costShareParam.setAccountingId(accountingIds);
|
|
|
+ accountList.forEach(i->{
|
|
|
+ String accountCode = accountingMap.get(i);
|
|
|
+ accoutingCodes.add(accountCode);
|
|
|
+ });
|
|
|
+ costShareParam.setAccountingCodes(accoutingCodes.stream().map(String::valueOf).collect(Collectors.joining(StrUtil.COMMA)));
|
|
|
}else {
|
|
|
costShareParam.setAccountingId(null);
|
|
|
}
|