فهرست منبع

修改会计不修改Code

ljx 4 سال پیش
والد
کامیت
26cbf699ea

+ 11 - 2
src/main/java/com/imed/costaccount/mapper/CostIncomeGroupMapper.java

@@ -1,9 +1,13 @@
 package com.imed.costaccount.mapper;
 
-import com.imed.costaccount.model.CostIncomeGroup;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.imed.costaccount.model.CostIncomeGroup;
+import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
+import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 /**
  * 收入归集
  * 
@@ -12,5 +16,10 @@ import org.apache.ibatis.annotations.Mapper;
  */
 @Mapper
 public interface CostIncomeGroupMapper extends BaseMapper<CostIncomeGroup> {
-	
+    /**
+     *  按照开单科室  执行科室 成本项目进行筛选相同的金额汇总
+     * @param costIncomeGroupBeforeVOList
+     * @return
+     */
+    List<CostIncomeGroupAllAmountVO> countMoney(List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList);
 }

+ 16 - 0
src/main/java/com/imed/costaccount/model/vo/CostIncomeGroupAllAmountVO.java

@@ -0,0 +1,16 @@
+package com.imed.costaccount.model.vo;
+
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+
+/**
+ * @author 李加喜
+ * @Package com.imed.costaccount.model.vo
+ * @date 2021-08-04 16:35
+ */
+@Data
+@ApiModel("收入归集统计归并后金额的返回实体类")
+public class CostIncomeGroupAllAmountVO extends CostIncomeGroupBeforeVO{
+
+    private String allMoney;
+}

+ 3 - 2
src/main/java/com/imed/costaccount/service/impl/AccountingServiceImpl.java

@@ -145,6 +145,7 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
                 throw new CostException(500, "会计科目类型要与上层一致");
             }
             String oldParentIds = byId.getAllParentIds();
+
             if ("0".equals(oldParentIds)) {
                 allParentIds = parentId + "";
             } else {
@@ -260,8 +261,8 @@ public class AccountingServiceImpl extends ServiceImpl<AccountingMapper, Account
         if (Objects.nonNull(one) && !byId.getAccountingCode().equals(one.getAccountingCode())) {
             throw new CostException(500, "会计科目代码已存在,请重新生成");
         }
-        // 直接修改
-        byId.setAccountingCode(accountingEditDTO.getAccountingCode());
+        // 直接修改 TODO 不修改会计科目Code
+        byId.setAccountingCode(byId.getAccountingCode());
         byId.setAccountingName(accountingEditDTO.getAccountingName());
         byId.setCreateTime(System.currentTimeMillis());
 //        byId.setAccountingType(accountingEditDTO.getAccountingType());

+ 66 - 11
src/main/java/com/imed/costaccount/service/impl/CostIncomeGroupServiceImpl.java

@@ -1,5 +1,6 @@
 package com.imed.costaccount.service.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -7,15 +8,17 @@ import com.imed.costaccount.common.util.BeanUtil;
 import com.imed.costaccount.common.util.DateUtils;
 import com.imed.costaccount.common.util.PageUtils;
 import com.imed.costaccount.mapper.CostIncomeGroupMapper;
-import com.imed.costaccount.model.CostIncomeGroup;
-import com.imed.costaccount.model.Department;
-import com.imed.costaccount.model.Responsibility;
+import com.imed.costaccount.model.*;
+import com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO;
 import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
 import com.imed.costaccount.service.*;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.util.Arrays;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 @Service("costIncomeGroupService")
@@ -29,11 +32,14 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
 
     private final AccountingService accountingService;
 
-    public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService) {
+    private final CostIncomeGroupMapper costIncomeGroupMapper;
+
+    public CostIncomeGroupServiceImpl(DepartmentService departmentService, ResponsibilityService responsibilityService, ProductService productService, AccountingService accountingService, CostIncomeGroupMapper costIncomeGroupMapper) {
         this.departmentService = departmentService;
         this.responsibilityService = responsibilityService;
         this.productService = productService;
         this.accountingService = accountingService;
+        this.costIncomeGroupMapper = costIncomeGroupMapper;
     }
 
     /**
@@ -56,17 +62,66 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
         wrapper.eq("hosp_id",hospId);
         wrapper.eq("date_year",year);
         wrapper.eq("date_month",month);
-        wrapper.like(!StringUtils.isEmpty(responsibilityCode),"open_responsibility_code",responsibilityCode)
-                .or()
-                .like(!StringUtils.isEmpty(responsibilityCode),"start_responsibility_code",responsibilityCode);
-        wrapper.like(!StringUtils.isEmpty(accountCode),"account_code",accountCode);
         Page<CostIncomeGroup> pages = this.page(costIncomeGroupPage, wrapper);
         List<CostIncomeGroup> records = pages.getRecords();
         List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList = BeanUtil.convertList(records, CostIncomeGroupBeforeVO.class);
-        // 查询所有的责任中心 科室 会计科目  成本项目的数据
+        // 查询所有的责任中心 科室 会计科目  成本项目的数据  处理名字
+        setCodeName(hospId, costIncomeGroupBeforeVOList);
+        // 进行金额合并
+        List<CostIncomeGroupAllAmountVO> costIncomeGroupAllAmountVoS =costIncomeGroupMapper.countMoney(costIncomeGroupBeforeVOList);
+        // TODO 对,的金额进行合并
+        costIncomeGroupAllAmountVoS.forEach(i->{
+            String allMoney = i.getAllMoney();
+            if (allMoney.contains(StrUtil.COMMA)){
+                // 存在,在进行求和
+                Long sum;
+                List<Long> list = Arrays.stream(allMoney.split(StrUtil.COMMA)).map(Long::valueOf).collect(Collectors.toList());
+
+            }
+        });
+        List<CostIncomeGroupAllAmountVO> amountVOS = costIncomeGroupAllAmountVoS.stream().map(i -> {
+            if (!StringUtils.isEmpty(responsibilityCode)) {
+                boolean equalsBoolean = i.getOpenResponsibilityCode().equals(responsibilityCode);
+                if (!equalsBoolean) {
+                    i.getStartResponsibilityCode().equals(responsibilityCode);
+                }
+            }
+            if (!StringUtils.isEmpty(accountCode)) {
+                i.getAccountCode().equals(accountCode);
+            }
+            return i;
+        }).collect(Collectors.toList());
+        PageUtils pageUtils = new PageUtils(pages);
+        pageUtils.setList(amountVOS);
+        return pageUtils;
+    }
+
+    /**
+     * 设置相关名称
+     * @param hospId
+     * @param costIncomeGroupBeforeVOList
+     */
+    private void setCodeName(Long hospId, List<CostIncomeGroupBeforeVO> costIncomeGroupBeforeVOList) {
         List<Responsibility> responsibilityList = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId));
+        Map<String, List<Responsibility>> responsibilityMap = responsibilityList.stream().collect(Collectors.groupingBy(Responsibility::getResponsibilityCode));
         List<Department> departmentList = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId));
-
-        return null;
+        Map<String, List<Department>> departmentMap = departmentList.stream().collect(Collectors.groupingBy(Department::getDepartmentCode));
+        List<Product> productList = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId));
+        Map<String, List<Product>> productMap = productList.stream().collect(Collectors.groupingBy(Product::getProductCode));
+        List<Accounting> accountingList = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId));
+        Map<String, List<Accounting>> accountMap = accountingList.stream().collect(Collectors.groupingBy(Accounting::getAccountingCode));
+        costIncomeGroupBeforeVOList.forEach(i->{
+            // 以为这里的数据导入的  在导入的时候进行数据校验
+            // 设置开单科室名称 执行科室名称  开单责任中心名称  执行责任中心名称 成本项目的名称 会计科目名称
+            i.setOpenDepartmentCodeName("["+i.getOpenDepartmentCode()+"]"+departmentMap.get(i.getOpenDepartmentCode()).get(0).getDepartmentName());
+            i.setOpenResponsibilityCodeName("["+i.getOpenResponsibilityCode()+"]"+responsibilityMap.get(i.getOpenResponsibilityCode()).get(0).getResponsibilityName());
+            i.setStartDepartmentCodeName("["+i.getStartDepartmentCode()+"]"+departmentMap.get(i.getStartDepartmentCode()).get(0).getDepartmentName());
+            i.setStartResponsibilityCodeName("["+i.getStartResponsibilityCode()+"]"+responsibilityMap.get(i.getStartResponsibilityCode()).get(0).getResponsibilityName());
+            i.setProductCodeName("["+i.getProductCode()+"]"+productMap.get(i.getProductCode()).get(0).getProductName());
+            i.setAccountCodeName("["+i.getAccountCode()+"]"+accountMap.get(i.getAccountCode()).get(0).getAccountingName());
+        });
     }
+    /**
+     * 根据年月查询所有的数据
+     */
 }

+ 1 - 1
src/main/java/com/imed/costaccount/web/CostIncomeGroupController.java

@@ -34,7 +34,7 @@ public class CostIncomeGroupController {
     @ApiOperation("分页获取收入归集前数据")
     public Result list(@RequestParam(defaultValue = "1", value = "current") Integer current,
                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
-                       @RequestParam(value = "dateTime",required = false) String dateTime,
+                       @RequestParam(value = "dateTime") String dateTime,
                        @RequestParam(value = "responsibilityCode",required = false) String responsibilityCode,
                        @RequestParam(value = "accountCode",required = false) String accountCode){
         Long hospId = UserContext.getHospId();

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

@@ -22,6 +22,19 @@
         <result property="createTime" column="create_time"/>
         <result property="deleteTime" column="delete_time"/>
     </resultMap>
+    <sql id="Base_Column_List" >
+    id, open_department_code, open_responsibility_code, start_department_code, start_responsibility_code, product_code, account_code, is_income,
+    open_department_amount, start_department_amount, amount, hosp_id, date_year, date_month, create_time,
+    delete_time
+  </sql>
+
+    <select id="countMoney" resultType="com.imed.costaccount.model.vo.CostIncomeGroupAllAmountVO">
+        select
+        <include refid="Base_Column_List"/>
+        ,group_concat(amount) as addMoney
+        from cost_income_group
+        group by open_department_code , start_department_code , product_code;
+    </select>
 
 
 </mapper>