Преглед на файлове

09 01 01 全院损益计算

hr преди 4 години
родител
ревизия
c89d61ae4a

+ 5 - 0
src/main/java/com/imed/costaccount/model/ReportForm.java

@@ -74,6 +74,11 @@ public class ReportForm implements Serializable {
      */
     private Long oldId;
 
+    /**
+     * 仅在全院损益必须存在一个值1 的
+     */
+    private Integer isLoss;
+
     /**
      * 创建时间
      */

+ 26 - 0
src/main/java/com/imed/costaccount/service/impl/HospProfitAndLossServiceImpl.java

@@ -34,6 +34,8 @@ import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
+import static com.imed.costaccount.common.constants.Constant.LIMIT;
+
 @Slf4j
 @Service("hospProfitAndLossService")
 public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossMapper, HospProfitAndLoss> implements HospProfitAndLossService {
@@ -363,6 +365,30 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
         int month = DateUtil.month(parse) + 1;
         int startIndex = (current - 1) * pageSize;
         List<HospProfitAndLoss> list = baseMapper.getPageList(startIndex, pageSize, year, month, hospId);
+        // 损益的时候计算下
+        list.forEach(i -> {
+            ReportForm one = reportFormService.getOne(
+                    new LambdaQueryWrapper<ReportForm>().select(ReportForm::getId)
+                            .eq(ReportForm::getNum, i.getReportNum())
+                            .eq(ReportForm::getHospId, hospId)
+                            .eq(ReportForm::getReportType, 3)
+                            .eq(ReportForm::getIsLoss, 1)
+                            .last(LIMIT)
+            );
+            if (Objects.nonNull(one)) {
+                List<CostOtherPaymentsData> byMonth = otherPaymentsDataService.getByMonth(year, month, hospId);
+                AtomicReference<BigDecimal> total = new AtomicReference<>();
+                total.set(BigDecimal.ZERO);
+                byMonth.forEach(j -> {
+                    if (j.getPaymentsType().equals(1)) {
+                        total.set(total.get().add(j.getTotalAmount()));
+                    }else {
+                        total.set(total.get().subtract(j.getTotalAmount()));
+                    }
+                });
+                i.setAmount(i.getAmount().add(total.get()));
+            }
+        });
         int totalCount = baseMapper.getPageCount(year, month, hospId);
         return new PageUtils(list, totalCount, pageSize, current);
     }