Prechádzať zdrojové kódy

09 02 01 全院损益计算关于全院损益计算的问题

hr 4 rokov pred
rodič
commit
958f6e9fe3

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

@@ -89,4 +89,5 @@ public class ReportForm implements Serializable {
     @TableLogic(value = "0", delval = "UNIX_TIMESTAMP(NOW()) * 1000")
     private Long deleteTime;
 
+
 }

+ 3 - 0
src/main/java/com/imed/costaccount/model/dto/ReportFormSaveDTO.java

@@ -33,4 +33,7 @@ public class ReportFormSaveDTO {
 
     @ApiModelProperty(name = "calcFormula",value = "计算公式")
     private String calcFormula;
+
+    private Integer isLoss;
+
 }

+ 2 - 0
src/main/java/com/imed/costaccount/model/vo/ReportFormVO.java

@@ -36,6 +36,8 @@ public class ReportFormVO {
 
     private Long hospId;
 
+    private Integer isLoss;
+
     @JsonInclude(JsonInclude.Include.NON_NULL)
     private Integer showAddRelation;
 

+ 7 - 0
src/main/java/com/imed/costaccount/service/ReportFormService.java

@@ -69,5 +69,12 @@ public interface ReportFormService extends IService<ReportForm> {
      * @param hospId 医院id
      */
     List<ReportFormVO> getAllHospList( Long hospId);
+
+    /**
+     * 校验这个医院全院损益计算的时候是否存在默认损益
+     * @param hospId
+     */
+    public void checkExistLoss(Long hospId);
+
 }
 

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

@@ -86,6 +86,8 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
     @Override
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
     public void calc(String date, Long hospId) {
+        reportFormService.checkExistLoss(hospId);
+
         DateTime parse = DateUtil.parse(date);
         int year = DateUtil.year(parse);
         int month = DateUtil.month(parse) + 1;
@@ -326,6 +328,9 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
      * @param year
      */
     private void calcByAccount(Long hospId, ReportForm reportForm, List<IncomeCollection> incomes, List<HospProfitAndLoss> list, List<AllocationQuery> allocationQueries, int month, int year) {
+        // check 这个医院是否有对应的损益标识
+        reportFormService.checkExistLoss(hospId);
+
         // 报表项目关联的会计科目对象
         List<RelationVO> accountRelations = reportRelationService.getAccountRelation(reportForm.getId(), hospId);
         if (accountRelations.isEmpty()) {
@@ -360,6 +365,8 @@ public class HospProfitAndLossServiceImpl extends ServiceImpl<HospProfitAndLossM
      */
     @Override
     public PageUtils getHospProfits(Integer current, Integer pageSize, String date, Long hospId) {
+        reportFormService.checkExistLoss(hospId);
+
         DateTime parse = DateUtil.parse(date);
         int year = DateUtil.year(parse);
         int month = DateUtil.month(parse) + 1;

+ 20 - 0
src/main/java/com/imed/costaccount/service/impl/ReportFormServiceImpl.java

@@ -110,6 +110,7 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
         setDataByParentId(hospId, reportForm, parentId);
 
         this.save(reportForm);
+
     }
 
     /**
@@ -423,4 +424,23 @@ public class ReportFormServiceImpl extends ServiceImpl<ReportFormMapper, ReportF
     private List<ReportFormVO> getSon(ReportFormVO vo, List<ReportFormVO> reportFormVOS) {
         return reportFormVOS.stream().filter(o -> vo.getId().equals(o.getParentId())).collect(Collectors.toList());
     }
+
+    /**
+     * 校验这个医院全院损益计算的时候是否存在默认损益
+     *
+     * @param hospId
+     */
+    @Override
+    @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
+    public void checkExistLoss(Long hospId) {
+        List<ReportForm> list = this.list(
+                new LambdaQueryWrapper<ReportForm>()
+                        .eq(ReportForm::getReportType, ReportTypeEnum.HOSP_PROFIT_LOSS.getType())
+                        .eq(ReportForm::getHospId, hospId)
+                        .eq(ReportForm::getIsLoss, 1)
+        );
+        if (list.size() != 1) {
+            throw new CostException("请先设置默认损益类型,全院损益中默认损益只能有一个");
+        }
+    }
 }