瀏覽代碼

Merge branch 'master' of huangrui/CostAccount into dev

lijiaxi 4 年之前
父節點
當前提交
c8ddd459c6
共有 1 個文件被更改,包括 19 次插入12 次删除
  1. 19 12
      src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

+ 19 - 12
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -26,7 +26,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
-import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
@@ -542,7 +541,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
                 writer.writeCellValue(levelSort, num, allocationReportVOS.get(0).getShareParamName());
                 writer.writeCellValue(levelSort + 1, num, allocationReportVOS.get(0).getShareParamValueNums());
                 writer.writeCellValue(levelSort + 2, num, allocationReportVOS.get(0).getShareParamRates());
-                for (int m = levelSort + 4; m < column; m++) {
+                for (int m = levelSort + 3; m < column; m++) {
                     // x是m y是num
                     // 获取当前这一列对应的责任中心 以及会计科目
                     // 第一行责任中心
@@ -581,11 +580,14 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             String cellValue1 = sheet.getRow(0).getCell(m).getStringCellValue();
             String cellValue2 = sheet.getRow(0).getCell(m + 1).getStringCellValue();
             if (!cellValue1.equals(cellValue2)) {
-                otherData = true;
-                writer.merge(0, 0, cc, m, cellValue1, false);
+                if (cc!=m){
+                    writer.merge(0, 0, cc, m, cellValue1, false);
+                }else {
+                    writer.writeCellValue(cc,0,cellValue1);
+                }
+
                 cc = m + 1;
-            }
-            if (m == column - 2) {
+            }else if (m == column - 2) {
                 writer.merge(0, 0, cc, m + 1, sheet.getRow(0).getCell(m + 1).getStringCellValue(), false);
             }
         }
@@ -596,8 +598,11 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             String cellValue1 = sheet.getRow(i).getCell(0).getStringCellValue();
             String cellValue2 = sheet.getRow(i + 1).getCell(0).getStringCellValue();
             if (!cellValue1.equals(cellValue2)) {
-                otherData = true;
-                writer.merge(jj, i, 0, 0, cellValue1, false);
+                if (jj != i){
+                    writer.merge(jj, i, 0, 0, cellValue1, false);
+                }else {
+                    writer.writeCellValue(0,jj,cellValue1);
+                }
                 jj = i + 1;
             } else if (i == num - 2) {
                 writer.merge(jj, i + 1, 0, 0, cellValue1, false);
@@ -633,7 +638,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         List<Allocation> allocations = baseMapper.selectList(new QueryWrapper<Allocation>().lambda()
                 .eq(Allocation::getHospId, hospId).eq(Allocation::getDateYear, year)
                 .eq(Allocation::getDateMonth, month));
-        Map<String, List<Allocation>> accrepMap = allocations.stream().collect(Collectors.groupingBy(k -> k.getLevelSort() + "cost" + k.getResponsibilityCode()));
+        Map<String, List<Allocation>> accrepMap = allocations.stream().collect(Collectors.groupingBy(k -> k.getLevelSort() + "cost" + k.getTargetResponsibilityCode()));
         LinkedList<String> shareMoney = new LinkedList<>();
 
         List<CostAccountShare> costAccountShareList = accountShareService.list(new QueryWrapper<CostAccountShare>().lambda()
@@ -651,18 +656,20 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             i.setAccountName(costAccountShare.getAccountingNames());
             i.setAlias(costAccountShare.getAlias());
             if (levelSort > 1) {
+                AtomicReference<BigDecimal> money = new AtomicReference<>(new BigDecimal("0.0000"));
+
                 for (int j = 1; j < levelSort; j++) {
-                    AtomicReference<BigDecimal> money = new AtomicReference<>(new BigDecimal("0.0000"));
-                    List<Allocation> allocations1 = accrepMap.get(j + "cost" + i.getResponsibilityCode());
+                    // 每一次计算要设置为0
+                    List<Allocation> allocations1 = accrepMap.get(j + "cost" + i.getTargetResponsibilityCode());
                     if (CollUtil.isNotEmpty(allocations1)) {
                         allocations1.forEach(m -> {
                             money.updateAndGet(v -> v.add(m.getAmount()));
-                            shareMoney.add(month.toString());
                         });
                     } else {
                         // TODO 封装测试数据
                         shareMoney.add("0");
                     }
+                    shareMoney.add(money.toString());
                 }
             }
             i.setTargetShareMoneys(shareMoney);