|
@@ -107,7 +107,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
// 计算方式 0是合并计算 1是分开计算
|
|
|
Integer calcType = shareLevelVO.getCalcType();
|
|
|
// 得到该分摊层级下责任中心列表,如果不存在,下一个
|
|
|
- List<Responsibility> responsibilities = responsibilityService.getByLevelId(levelId, hospId);
|
|
|
+ List<Responsibility> responsibilities = responsibilityService.getLevelIdByCode(levelId, hospId);
|
|
|
if (responsibilities.isEmpty()) {
|
|
|
continue;
|
|
|
}
|
|
@@ -173,13 +173,17 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
Allocation targetAllocation = new Allocation();
|
|
|
String valueResponsibilityCode = paramValue.getResponsibilityCode();
|
|
|
String targetRespName = responsibilityService.getByCode(valueResponsibilityCode, hospId);
|
|
|
+ Long targetShareLevelId = responsibilityService.getLevelIdByCode(valueResponsibilityCode, hospId);
|
|
|
+ if (Objects.isNull(targetShareLevelId)) {
|
|
|
+ throw new CostException("目标责任中心分摊层级异常");
|
|
|
+ }
|
|
|
String shareParamName = shareParamService.getByCode(paramValue.getShareParamCode(), hospId);
|
|
|
targetAllocation.setDateMonth(startDTO.getMonth()).setDateYear(startDTO.getYear()).setLevelSort(shareLevelVO.getLeverSort())
|
|
|
.setLevelName(shareLevelVO.getShareName()).setHospId(hospId).setResponsibilityCode(responsibility.getResponsibilityCode())
|
|
|
.setResponsibilityName(responsibility.getResponsibilityName()).setAccountShareId(accountShareId).setAmount(targetAmount)
|
|
|
.setCreateTime(timeMillis).setTargetResponsibilityCode(valueResponsibilityCode).setTargetResponsibilityName(targetRespName)
|
|
|
.setShareParamCode(paramValue.getShareParamCode()).setShareParamName(shareParamName).setTotalAmount(totalAmount).setShareParamValueNum(paramValue.getValueNum())
|
|
|
- .setShareParamRate(numerator.divide(reduce, 4)).setShareLevelId(levelId)
|
|
|
+ .setShareParamRate(numerator.divide(reduce, 4)).setShareLevelId(levelId).setTargetShareLevelId(targetShareLevelId)
|
|
|
;
|
|
|
|
|
|
// todo 目标分摊层级责任中心 就是当前列个表中的责任中心
|
|
@@ -224,6 +228,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
@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);
|
|
@@ -241,8 +246,9 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
}
|
|
|
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())
|
|
|
+ .setHospId(hospId).setResponsibilityCode(i.getResponsibilityCode())
|
|
|
+ .setResponsibilityName(i.getResponsibilityName())
|
|
|
+ .setOriginId(i.getId()).setOriginType(1L).setAmount(i.getAmount())
|
|
|
.setAccountingCode(accountingCodes).setAccountingName(accountingNames)
|
|
|
.setCreateTime(System.currentTimeMillis())
|
|
|
.setLevelSort(i.getLevelSort()).setLevelName(i.getLevelName())
|
|
@@ -253,7 +259,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
costingGroups.forEach(i -> {
|
|
|
AllocationQuery allocationQuery = new AllocationQuery();
|
|
|
String responsibilityCode = i.getResponsibilityCode();
|
|
|
- Long levelId = responsibilityService.getByLevelId(responsibilityCode, hospId);
|
|
|
+ Long levelId = responsibilityService.getLevelIdByCode(responsibilityCode, hospId);
|
|
|
if (Objects.isNull(levelId)) {
|
|
|
throw new CostException("责任中心" + i.getResponsibilityName() + "数据异常");
|
|
|
}
|
|
@@ -263,7 +269,8 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
}
|
|
|
allocationQuery.setDateYear(i.getDateYear()).setDateMonth(i.getDateMonth())
|
|
|
.setHospId(hospId).setResponsibilityCode(responsibilityCode).setResponsibilityName(i.getResponsibilityName())
|
|
|
- .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount()).setAccountingCode(i.getAccountCode()).setAccountingName(i.getAccountName())
|
|
|
+ .setOriginId(i.getId()).setOriginType(2L).setAmount(i.getAmount())
|
|
|
+ .setAccountingCode(i.getAccountCode()).setAccountingName(i.getAccountName())
|
|
|
.setCreateTime(System.currentTimeMillis())
|
|
|
.setLevelSort(byId.getLeverSort()).setLevelName(byId.getShareName())
|
|
|
;
|
|
@@ -396,18 +403,18 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
/**
|
|
|
* 分摊报表导出
|
|
|
*
|
|
|
- * @param writer {@link ExcelWriter}
|
|
|
- * @param levelSort 分摊层级 就是第几次分摊
|
|
|
- * @param sheet 报表
|
|
|
- * @param year 年
|
|
|
- * @param month 月
|
|
|
+ * @param writer {@link ExcelWriter}
|
|
|
+ * @param levelSort 分摊层级 就是第几次分摊
|
|
|
+ * @param sheet 报表
|
|
|
+ * @param year 年
|
|
|
+ * @param month 月
|
|
|
* @param shareLevelId
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public ExcelWriter getShareReportTemplate(ExcelWriter writer, Integer levelSort, Sheet sheet, Integer year, Integer month, Long shareLevelId) {
|
|
|
// 获取数据
|
|
|
- List<AllocationReportVO> allocationReportVOList = getAllocationReportVOS(levelSort, year, month,shareLevelId);
|
|
|
+ List<AllocationReportVO> allocationReportVOList = getAllocationReportVOS(levelSort, year, month, shareLevelId);
|
|
|
// 设置导出
|
|
|
Map<String, List<AllocationReportVO>> responsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getResponsibilityCode));
|
|
|
Map<String, List<AllocationReportVO>> targetResponsibilityMap = allocationReportVOList.stream().collect(Collectors.groupingBy(AllocationReportVO::getTargetResponsibilityCode));
|
|
@@ -606,14 +613,14 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
|
|
|
* @param month
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month,Long shareLevelId) {
|
|
|
+ private List<AllocationReportVO> getAllocationReportVOS(Integer levelSort, Integer year, Integer month, Long shareLevelId) {
|
|
|
Long hospId = UserContext.getHospId();
|
|
|
if (Objects.isNull(levelSort) || Objects.isNull(year) || Objects.isNull(month)) {
|
|
|
throw new CostException(500, "参数异常");
|
|
|
}
|
|
|
// 处理第几次分摊计算值
|
|
|
List<Allocation> allocationList = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
|
|
|
- .eq(Allocation::getHospId, hospId).eq(Allocation::getLevelSort, levelSort).eq(Allocation::getShareLevelId,shareLevelId).eq(Allocation::getDateYear, year)
|
|
|
+ .eq(Allocation::getHospId, hospId).eq(Allocation::getLevelSort, levelSort).eq(Allocation::getShareLevelId, shareLevelId).eq(Allocation::getDateYear, year)
|
|
|
.eq(Allocation::getDateMonth, month));
|
|
|
// 找会计科室的时候使用的
|
|
|
List<Allocation> allocations = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
|