|
@@ -17,13 +17,11 @@ import com.imed.costaccount.common.util.UserContext;
|
|
|
import com.imed.costaccount.mapper.AllocationMapper;
|
|
|
import com.imed.costaccount.model.*;
|
|
|
import com.imed.costaccount.model.dto.StartDTO;
|
|
|
-import com.imed.costaccount.model.vo.AccountShareVO;
|
|
|
-import com.imed.costaccount.model.vo.AfterAllocationVO;
|
|
|
-import com.imed.costaccount.model.vo.AllocationReportVO;
|
|
|
-import com.imed.costaccount.model.vo.CostShareLevelVO;
|
|
|
+import com.imed.costaccount.model.vo.*;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.jetbrains.annotations.NotNull;
|
|
|
+import org.apache.xmlbeans.impl.xb.xsdschema.All;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -33,7 +31,7 @@ import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
-
|
|
|
+@Slf4j
|
|
|
@Service("allocationService")
|
|
|
public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocation> implements AllocationService {
|
|
|
|
|
@@ -43,15 +41,20 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
private final CostAccountShareService accountShareService;
|
|
|
private final ShareParamValueService shareParamValueService;
|
|
|
private final CostShareParamService shareParamService;
|
|
|
+ private final AllocationQueryService allocationQueryService;
|
|
|
|
|
|
public AllocationServiceImpl(CostCostingGroupService costCostingGroupService,
|
|
|
- CostShareLevelService shareLevelService, ResponsibilityService responsibilityService, CostAccountShareService accountShareService, ShareParamValueService shareParamValueService, CostShareParamService shareParamService) {
|
|
|
+ CostShareLevelService shareLevelService,
|
|
|
+ ResponsibilityService responsibilityService,
|
|
|
+ CostAccountShareService accountShareService,
|
|
|
+ ShareParamValueService shareParamValueService, CostShareParamService shareParamService, AllocationQueryService allocationQueryService, AllocationQueryService allocationQueryService1) {
|
|
|
this.costCostingGroupService = costCostingGroupService;
|
|
|
this.shareLevelService = shareLevelService;
|
|
|
this.responsibilityService = responsibilityService;
|
|
|
this.accountShareService = accountShareService;
|
|
|
this.shareParamValueService = shareParamValueService;
|
|
|
this.shareParamService = shareParamService;
|
|
|
+ this.allocationQueryService = allocationQueryService1;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -178,6 +181,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
.setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
|
|
|
.setShareParamRate(numerator.divide(reduce, 4))
|
|
|
;
|
|
|
+
|
|
|
// todo 目标分摊层级责任中心 就是当前列个表中的责任中心
|
|
|
allocations.add(targetAllocation);
|
|
|
costList.add(targetAllocation);
|
|
@@ -189,6 +193,56 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
}
|
|
|
}
|
|
|
this.saveBatch(allocations);
|
|
|
+ List<Allocation> list = this.list(
|
|
|
+ new LambdaQueryWrapper<Allocation>()
|
|
|
+ .eq(Allocation::getHospId, hospId).eq(Allocation::getDateYear, startDTO.getYear()).eq(Allocation::getDateMonth, startDTO.getMonth())
|
|
|
+ );
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ log.error("未分摊到数据......");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 入cost_allocation_query 表 便于后续操作
|
|
|
+ this.saveAllocationQuery(list, costingGroups, hospId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED,rollbackFor = Throwable.class)
|
|
|
+ public void saveAllocationQuery(List<Allocation> list, List<CostCostingGroup> costingGroups, Long hospId) {
|
|
|
+ List<AllocationQuery> saveList = new ArrayList<>();
|
|
|
+ list.forEach(i -> {
|
|
|
+ Long accountShareId = i.getAccountShareId();
|
|
|
+ CostAccountShare byId = accountShareService.getById(accountShareId);
|
|
|
+ if (Objects.isNull(byId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String accountingCodes = byId.getAccountingCodes();
|
|
|
+ if (StrUtil.isBlank(accountingCodes)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String accountingNames = byId.getAccountingNames();
|
|
|
+ String alias = byId.getAlias();
|
|
|
+ if (StrUtil.isNotBlank(alias)) {
|
|
|
+ accountingNames = alias;
|
|
|
+ }
|
|
|
+ AllocationQuery allocationQuery = new AllocationQuery();
|
|
|
+ allocationQuery.setDateYear(i.getDateYear()).setDateMonth(i.getDateMonth())
|
|
|
+ .setHospId(hospId).setResponsibilityCode(i.getResponsibilityCode()).setResponsibilityName(i.getResponsibilityName())
|
|
|
+ .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount()).setAccountingCode(accountingCodes).setAccountingName(accountingNames)
|
|
|
+ .setCreateTime(System.currentTimeMillis())
|
|
|
+ ;
|
|
|
+ saveList.add(allocationQuery);
|
|
|
+ });
|
|
|
+
|
|
|
+ costingGroups.forEach(i -> {
|
|
|
+ AllocationQuery allocationQuery = new AllocationQuery();
|
|
|
+ allocationQuery.setDateYear(i.getDateYear()).setDateMonth(i.getDateMonth())
|
|
|
+ .setHospId(hospId).setResponsibilityCode(i.getResponsibilityCode()).setResponsibilityName(i.getResponsibilityName())
|
|
|
+ .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount()).setAccountingCode(i.getAccountCode()).setAccountingName(i.getAccountName())
|
|
|
+ .setCreateTime(System.currentTimeMillis())
|
|
|
+ ;
|
|
|
+ saveList.add(allocationQuery);
|
|
|
+ });
|
|
|
+ allocationQueryService.saveBatch(saveList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -488,7 +542,6 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
* @param month
|
|
|
* @return
|
|
|
*/
|
|
|
- @NotNull
|
|
|
private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month) {
|
|
|
Long hospId = UserContext.getHospId();
|
|
|
if (Objects.isNull(levelSort) || Objects.isNull(year) || Objects.isNull(month)) {
|
|
@@ -543,4 +596,15 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
return allocationReportVOList;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 分摊后报表
|
|
|
+ *
|
|
|
+ * @param year 年月(yyyy-MM-dd)
|
|
|
+ * @param responsibilityCode 责任中心代码
|
|
|
+ * @return List
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<CollectDataFormVO> queryAfterAllocationForm(String year, String responsibilityCode) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|