Quellcode durchsuchen

设置统计数据

ljx vor 4 Jahren
Ursprung
Commit
4d6f1f1336

+ 49 - 0
src/main/java/com/imed/costaccount/model/AfterIncomegroup.java

@@ -0,0 +1,49 @@
+package com.imed.costaccount.model;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model
+ * @date 2021-08-10 19:56
+ */
+@Data
+@ApiModel("归集数据标记")
+public class AfterIncomegroup {
+
+    /**
+     * 开单科室状态 1 收益中心 2 执行中心
+     */
+    private Integer openDepartmentStatus;
+    /**
+     * 开单科室比例
+     */
+    private Integer openDepartmentProportion;
+    /**
+     * 开单科室金额
+     */
+    private BigDecimal openDepartmentDecimal;
+    /**
+     * 执行科室状态 1 收益中心 2 执行中心
+     */
+    private Integer startDepartmentStatus;
+    /**
+     * 执行科室比例
+     */
+    private Integer startDepartmentProportion;
+    /**
+     * 执行科室金额
+     */
+    private BigDecimal startDepartmentDecimal;
+    /**
+     * 责任中心代码
+     */
+    private String responsibilityCodes;
+    /**
+     * 是直接还是间接 1直接 2 间接
+     */
+    private Integer directStatus=1;
+}

+ 4 - 0
src/main/java/com/imed/costaccount/model/CostIncomeGroup.java

@@ -148,6 +148,10 @@ public class CostIncomeGroup implements Serializable {
 	 * 月份
 	 */
 	private Integer dateMonth;
+	/**
+	 * 归集后记录数据
+	 */
+	private String afterIncomeGroup;
 	/**
 	 * 创建时间13位时间戳
 	 */

+ 18 - 0
src/main/java/com/imed/costaccount/model/dto/ImportDataByFileTypeDto.java

@@ -0,0 +1,18 @@
+package com.imed.costaccount.model.dto;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.dto
+ * @date 2021-08-10 20:24
+ */
+@Data
+@ApiModel("收入数据导入")
+public class ImportDataByFileTypeDto {
+
+
+    private Integer fileType;
+    private String dateTime;
+}

+ 73 - 21
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java

@@ -2,6 +2,7 @@ package com.imed.costaccount.service.impl;
 
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -56,7 +57,9 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
 
     private final CostIncomeFileService costIncomeFileService;
 
-    public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService) {
+    private final CostIncomeGroupSetService costIncomeGroupSetService;
+
+    public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, ResponsibilityDepartmentService responsibilityDepartmentService, AccountingProductService accountingProductService, CostIncomeFileService costIncomeFileService, CostIncomeGroupSetService costIncomeGroupSetService) {
         this.departmentService = departmentService;
         this.responsibilityService = responsibilityService;
         this.productService = productService;
@@ -64,6 +67,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         this.responsibilityDepartmentService = responsibilityDepartmentService;
         this.accountingProductService = accountingProductService;
         this.costIncomeFileService = costIncomeFileService;
+        this.costIncomeGroupSetService = costIncomeGroupSetService;
     }
 
     /**
@@ -157,8 +161,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         //
         Map<String, Department> departmentMap = getDepartmentByCodeNameMap(hospId);
         Map<String, Product> productMap = getProductByCodeNameMap(hospId);
-        Map<Long, Responsibility> responsibilityMap = getLongResponsibilityMap(hospId);
-        Map<Long, Accounting> accountingMap = getLongAccountingMap(hospId);
+        Map<Long, Responsibility> responsibilityMap = getResponsibilityIdResponsibilityMap(hospId);
+        Map<Long, Accounting> accountingMap = getAccountIdAccountingMap(hospId);
         List<ResponsibilityDepartment> responsibilityDepartmentList = getResponsibilityDepartments(hospId);
         if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
             throw new CostException(500, "没有科室责任中心对照数据");
@@ -203,37 +207,57 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
     }
 
     /**
-     *
+     * Map类型
+     * Key DepartmentId
+     * Value ResponsibilityId
      * @param responsibilityDepartmentList
      * @return
      */
-    @NotNull
-    private Map<Long, Long> getDepartmentIdResponsibilityIdMap(List<ResponsibilityDepartment> responsibilityDepartmentList) {
+    public Map<Long, Long> getDepartmentIdResponsibilityIdMap(List<ResponsibilityDepartment> responsibilityDepartmentList) {
         return responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
     }
 
-    private List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
+    public List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
         return responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
                     .eq(ResponsibilityDepartment::getHospId, hospId));
     }
 
-    @NotNull
-    private Map<Long, Accounting> getLongAccountingMap(Long hospId) {
+    /**
+     * Key AccountId
+     * Value Accounting对象
+     * @param hospId
+     * @return
+     */
+    public Map<Long, Accounting> getAccountIdAccountingMap(Long hospId) {
         return accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
     }
 
-    @NotNull
-    private Map<Long, Responsibility> getLongResponsibilityMap(Long hospId) {
+    /**
+     * Key responsibilityId 责任中心Id
+     * Value Responsibility对象
+     * @param hospId
+     * @return
+     */
+    public Map<Long, Responsibility> getResponsibilityIdResponsibilityMap(Long hospId) {
         return responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
     }
 
-    @NotNull
-    private Map<String, Product> getProductByCodeNameMap(Long hospId) {
+    /**
+     * Key 成本项目Code+Name
+     * Value 成本项目对象
+     * @param hospId
+     * @return
+     */
+    public Map<String, Product> getProductByCodeNameMap(Long hospId) {
         return productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
     }
-
-    @NotNull
-    private Map<String, Department> getDepartmentByCodeNameMap(Long hospId) {
+    /**
+     * Key 科室项目Code+Name
+     * Value 科室对象
+     * @param hospId
+     * @return
+     */
+    public Map<String, Department> getDepartmentByCodeNameMap(Long hospId) {
         return departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
     }
 
@@ -269,6 +293,7 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
     private void checkImportData(List<List<Object>> list, List<IncomeErrorMessage> incomeErrorMessageList, List<CostIncomeGroup> costIncomeGroupArrayList, Map<String, Department> departmentMap, Map<String, Product> productMap, Map<Long, Responsibility> responsibilityMap, Map<Long, Accounting> accountingMap, Map<Long, Long> responsibilityDepMap, Map<Long, Long> accountProMap, Long hospId,Integer year,Integer month) {
         for (int i = 0; i < list.size(); i++) {
             CostIncomeGroup costIncomeGroup = new CostIncomeGroup();
+            AfterIncomegroup afterIncomegroup = new AfterIncomegroup();
             // 用来检验数据合理性的循环
             IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
             List<Object> data = list.get(i);
@@ -344,10 +369,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
                             incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
                             incomeErrorMessageList.add(incomeErrorMessage);
                         } else {
+                            Responsibility responsibility = responsibilityMap.get(responsibilityId);
                             costIncomeGroup.setOpenDepartmentCode(openDepartmentCode);
                             costIncomeGroup.setOpenDepartmentName(openDepartmentName);
-                            costIncomeGroup.setOpenResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
-                            costIncomeGroup.setOpenResponsibilityName(responsibilityMap.get(responsibilityId).getResponsibilityName());
+                            costIncomeGroup.setOpenResponsibilityCode(responsibility.getResponsibilityCode());
+                            costIncomeGroup.setOpenResponsibilityName(responsibility.getResponsibilityName());
+                            afterIncomegroup.setOpenDepartmentStatus(responsibility.getResponsibilityType());
                         }
                     }
                 }else {
@@ -373,10 +400,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
                             incomeErrorMessage.setErrMessage("代码:" + openDepartmentCode + " 名称:" + openDepartmentName + "科室对应的责任中心不存在");
                             incomeErrorMessageList.add(incomeErrorMessage);
                         } else {
+                            Responsibility responsibility = responsibilityMap.get(responsibilityId);
                             costIncomeGroup.setStartDepartmentCode(startDepartmentCode);
                             costIncomeGroup.setStartDepartmentName(startDepartmentName);
-                            costIncomeGroup.setStartResponsibilityCode(responsibilityMap.get(responsibilityId).getResponsibilityCode());
-                            costIncomeGroup.setStartResponsibilityName(responsibilityMap.get(responsibilityId).getResponsibilityName());
+                            costIncomeGroup.setStartResponsibilityCode(responsibility.getResponsibilityCode());
+                            costIncomeGroup.setStartResponsibilityName(responsibility.getResponsibilityName());
+                            afterIncomegroup.setStartDepartmentStatus(responsibility.getResponsibilityType());
                         }
                     }
                 }else {
@@ -391,12 +420,35 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
                     .setPatientName(data.get(10).toString()).setPatientFee(data.get(11).toString()).setReceiptFee(data.get(12).toString())
                     .setTotalNumber(Integer.parseInt(data.get(13).toString())).setUnit(data.get(14).toString())
                     .setFeeDatetime(DateUtils.StringToDate(data.get(16).toString(), DateStyleEnum.YYYY_MM_DD_HH_MM_SS_EN));
-            //
+            if (StrUtil.isNotBlank(costIncomeGroup.getOpenResponsibilityCode())){
+
+            }
             costIncomeGroup.setHospId(hospId);
             costIncomeGroup.setCreateTime(System.currentTimeMillis());
             costIncomeGroup.setDateYear(year);
             costIncomeGroup.setDateMonth(month);
             costIncomeGroup.setAmount(beforeMoney);
+            // 检验数据
+            Integer openDepartmentStatus = afterIncomegroup.getOpenDepartmentStatus();
+            Integer startDepartmentStatus = afterIncomegroup.getStartDepartmentStatus();
+            Map<String, CostIncomeGroupSet> incomeGroupSetMap = costIncomeGroupSetService.list(new QueryWrapper<CostIncomeGroupSet>().lambda().eq(CostIncomeGroupSet::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getOpenDepartmentStatus().toString() + k.getStartDepartmentStatus().toString(), synOe -> synOe));
+            CostIncomeGroupSet costIncomeGroupSet = incomeGroupSetMap.get(openDepartmentStatus.toString() + startDepartmentStatus.toString());
+            if (Objects.nonNull(costIncomeGroupSet)){
+                afterIncomegroup.setOpenDepartmentStatus(costIncomeGroupSet.getOpenDepartmentStatus());
+                afterIncomegroup.setOpenDepartmentProportion(costIncomeGroupSet.getOpenDepartmentProportion());
+                // TODO 金额
+//                afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply();
+                afterIncomegroup.setStartDepartmentStatus(costIncomeGroupSet.getStartDepartmentStatus());
+                afterIncomegroup.setStartDepartmentProportion(costIncomeGroupSet.getStartDepartmentProportion());
+                // TODO 金额
+//                afterIncomegroup.setOpenDepartmentDecimal(beforeMoney.multiply();
+                if (NumberConstant.ZERO.equals(costIncomeGroupSet.getOpenDepartmentProportion()) && NumberConstant.ZERO.equals(costIncomeGroupSet.getStartDepartmentProportion())){
+                    afterIncomegroup.setResponsibilityCodes(costIncomeGroupSet.getResponsibilityCodes());
+                    afterIncomegroup.setDirectStatus(NumberConstant.TWO);
+                }
+                costIncomeGroup.setAfterIncomeGroup(JSON.toJSONString(afterIncomegroup));
+            }
+
             costIncomeGroupArrayList.add(costIncomeGroup);
         }
     }

+ 3 - 2
src/main/java/com/imed/costaccount/web/ExcelController.java

@@ -14,6 +14,7 @@ import com.imed.costaccount.common.util.Result;
 import com.imed.costaccount.common.util.UserContext;
 import com.imed.costaccount.constants.NumberConstant;
 import com.imed.costaccount.model.*;
+import com.imed.costaccount.model.dto.ImportDataByFileTypeDto;
 import com.imed.costaccount.service.*;
 import com.imed.costaccount.service.impl.DepartmentServiceImpl;
 import com.imed.costaccount.service.impl.ProductServiceImpl;
@@ -447,11 +448,11 @@ public class ExcelController {
     /**
      * 导入 收入数据导入
      *
-     * @param file 导入的文件
+     * @param
      */
     @PostMapping("/importDataByFileType")
     @ApiOperation("批量导入指定类型数据信息")
-    public Result importProductAccount(@RequestParam("file") MultipartFile file,Integer fileType, String dateTime) {
+    public Result importProductAccount(@RequestParam("file") MultipartFile file ,Integer fileType,String dateTime) {
         if (Objects.isNull(file)) {
             throw new CostException(500, "请选择文件");
         }

+ 1 - 0
src/main/resources/mapper/CostIncomeGroupMapper.xml

@@ -33,6 +33,7 @@
         <result property="totalNumber" column="total_number"/>
         <result property="unit" column="unit"/>
         <result property="feeDatetime" column="fee_datetime"/>
+        <result property="afterIncomeGroup" column="after_income_group"/>
         <result property="dateYear" column="date_year"/>
         <result property="dateMonth" column="date_month"/>
         <result property="createTime" column="create_time"/>