Bladeren bron

Merge branch 'master' of huangrui/CostAccount into dev

huangrui 4 jaren geleden
bovenliggende
commit
7b6e52f511

+ 2 - 0
src/main/java/com/imed/costaccount/mapper/CostCostingGroupMapper.java

@@ -93,4 +93,6 @@ public interface CostCostingGroupMapper extends BaseMapper<CostCostingGroup> {
      * @return 总数
      */
     int queryAllocationCount(@Param("year") Integer year, @Param("month") Integer month, @Param("hospId") Long hospId);
+
+    List<CostCostingGroup> getRealData(@Param("maxId") List<Long> maxId, @Param("hospId") Long hospId, @Param("month") Integer month, @Param("year") Integer year);
 }

+ 3 - 0
src/main/java/com/imed/costaccount/service/CostCostingGroupService.java

@@ -69,5 +69,8 @@ public interface CostCostingGroupService extends IService<CostCostingGroup> {
      * @param hospId
      */
     void cancelAllocation(Integer year, Integer month, Long hospId);
+
+    List<CostCostingGroup> getRealData(List<Long> maxId, Long hospId, Integer year, Integer month);
+
 }
 

+ 4 - 2
src/main/java/com/imed/costaccount/service/impl/AllocationServiceImpl.java

@@ -26,6 +26,7 @@ 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;
@@ -207,7 +208,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
         }
 
         // 入cost_allocation_query 表 便于后续操作
-        this.saveAllocationQuery(list, costingGroups, hospId);
+        this.saveAllocationQuery(list, costingGroups, hospId, startDTO.getYear(), startDTO.getMonth());
     }
 
     private void removeData(StartDTO startDTO, Long hospId) {
@@ -226,7 +227,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
     }
 
     @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Throwable.class)
-    public void saveAllocationQuery(List<Allocation> list, List<CostCostingGroup> costingGroups, Long hospId) {
+    public void saveAllocationQuery(List<Allocation> list, List<CostCostingGroup> costingGroups, Long hospId, Integer year, Integer month) {
         List<AllocationQuery> saveList = new ArrayList<>();
         List<Long> maxId = shareLevelService.getMaxId(hospId);
         list = list.stream().filter(i -> maxId.contains(i.getTargetShareLevelId())).collect(Collectors.toList());
@@ -257,6 +258,7 @@ public class AllocationServiceImpl extends ServiceImpl<AllocationMapper, Allocat
             saveList.add(allocationQuery);
         });
 
+        costingGroups = costCostingGroupService.getRealData(maxId, hospId, year, month);
         costingGroups.forEach(i -> {
             AllocationQuery allocationQuery = new AllocationQuery();
             String responsibilityCode = i.getResponsibilityCode();

+ 5 - 0
src/main/java/com/imed/costaccount/service/impl/CostCostingGroupServiceImpl.java

@@ -478,4 +478,9 @@ public class CostCostingGroupServiceImpl extends ServiceImpl<CostCostingGroupMap
                         .eq(AllocationQuery::getHospId, hospId)
         );
     }
+
+    @Override
+    public List<CostCostingGroup> getRealData(List<Long> maxId, Long hospId, Integer year, Integer month) {
+        return baseMapper.getRealData(maxId, hospId, month, year);
+    }
 }

+ 8 - 2
src/main/resources/mapper/AllocationQueryMapper.xml

@@ -27,6 +27,7 @@
         where date_year = #{dateYear}
           and date_month = #{month}
           and hosp_id = #{hospId}
+          and delete_time = 0
     </select>
     <select id="getRespCodeAndName" resultType="com.imed.costaccount.model.vo.CodeAndNameVO">
         select responsibility_code as code, responsibility_name as name
@@ -34,6 +35,7 @@
         where date_year = #{dateYear}
           and date_month = #{month}
           and hosp_id = #{hospId}
+          and delete_time = 0
     </select>
     <select id="getAccountCodeAndName" resultType="com.imed.costaccount.model.vo.CodeAndNameVO">
         select accounting_code as code, accounting_name as name
@@ -41,6 +43,7 @@
         where date_year = #{dateYear}
           and date_month = #{month}
           and hosp_id = #{hospId}
+          and delete_time = 0
     </select>
     <select id="getCountByRespAndAccounts" resultType="java.math.BigDecimal">
         select IFNULL(sum(amount), 0)
@@ -53,6 +56,7 @@
         <foreach collection="accountCodes" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>
+        and delete_time = 0
 
     </select>
     <select id="getTotalByAccountAndResps" resultType="java.math.BigDecimal">
@@ -66,6 +70,7 @@
         <foreach collection="respCodes" item="item" open="(" separator="," close=")">
             #{item}
         </foreach>
+        and delete_time = 0
     </select>
     <select id="getTotalByAccountAndRespCode" resultType="java.math.BigDecimal">
         select IFNULL(sum(amount), 0)
@@ -73,8 +78,9 @@
         where date_year = #{dateYear}
           and date_month = #{month}
           and hosp_id = #{hospId}
-        and accounting_code =  #{accountCode}
-        and responsibility_code = #{responsibilityCode}
+          and accounting_code = #{accountCode}
+          and responsibility_code = #{responsibilityCode}
+          and delete_time = 0
     </select>
 
 

+ 16 - 0
src/main/resources/mapper/CostCostingGroupMapper.xml

@@ -126,5 +126,21 @@
         and hosp_id = #{hospId} group by date_year,date_month) t
     </select>
 
+    <select id="getRealData" resultType="com.imed.costaccount.model.CostCostingGroup">
+        select ccg.*
+        from cost_costing_group ccg
+        left join cost_responsibility cr on ccg.responsibility_code = cr.responsibility_code
+        where ccg.date_year = #{year}
+        and ccg.date_month = #{month}
+        and ccg.delete_time = 0
+        and ccg.hosp_id = #{hospId}
+        and cr.hosp_id = #{hospId}
+        and cr.delete_time = 0
+        and share_id in
+        <foreach collection="maxId" index="item" separator="," open="(" close=")">
+            #{index}
+        </foreach>
+    </select>
+
 
 </mapper>

+ 3 - 2
src/main/resources/mapper/CostShareLevelMapper.xml

@@ -3,7 +3,7 @@
 
 <mapper namespace="com.imed.costaccount.mapper.CostShareLevelMapper">
 
-	<!-- 可根据自己的需求,是否要使用 -->
+    <!-- 可根据自己的需求,是否要使用 -->
     <resultMap type="com.imed.costaccount.model.CostShareLevel" id="costShareLevelMap">
         <result property="id" column="id"/>
         <result property="shareName" column="share_name"/>
@@ -18,7 +18,8 @@
         select *
         from cost_share_level
         where hosp_id = #{hospId}
-          and lever_sort = (select max(lever_sort) from cost_share_level where hosp_id = #{hospId})
+          and lever_sort = (select max(lever_sort) from cost_share_level where hosp_id = #{hospId} and delete_time = 0)
+          and delete_time = 0
     </select>