Преглед изворни кода

Merge remote-tracking branch 'origin/master'

周箭河 пре 5 година
родитељ
комит
7051fc6f6c

+ 10 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamOrganizationRelationDao.java

@@ -53,5 +53,15 @@ public interface ExamOrganizationRelationDao extends BaseDAO<Long, ExamOrganizat
      */
     Set<Integer> getOrganIdsWithExam(@Param("examId") Integer examId);
 
+    /**
+     * @describe 统计指定考级项目与指定分布下的报名人数与累计收款
+     * @author Joburgess
+     * @date 2020.06.28
+     * @param examId:
+     * @param organIds:
+     * @return java.util.List<com.keao.edu.user.entity.ExamOrganizationRelation>
+     */
+    List<ExamOrganizationRelation> countExamOrganStudentAndPayment(@Param("examId") Integer examId,
+                                                                       @Param("organIds") List<Integer> organIds);
 	
 }

+ 11 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamOrganizationRelationService.java

@@ -1,11 +1,22 @@
 package com.keao.edu.user.service;
 
+import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.entity.ExamOrganizationRelation;
+import com.keao.edu.user.page.ExamOrganizationRelationQueryInfo;
 
 public interface ExamOrganizationRelationService extends BaseService<Long, ExamOrganizationRelation> {
 
     /**
+     * @describe 查询考级项目关联合作单位记录
+     * @author Joburgess
+     * @date 2020.06.28
+     * @param queryInfo:
+     * @return com.keao.edu.common.page.PageInfo<com.keao.edu.user.entity.ExamOrganizationRelation>
+     */
+    PageInfo<ExamOrganizationRelation> queryExamOrgans(ExamOrganizationRelationQueryInfo queryInfo);
+
+    /**
      * @describe 更新考级项目与合作单位关联信息
      * @author Joburgess
      * @date 2020.06.18

+ 30 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamOrganizationRelationServiceImpl.java

@@ -12,9 +12,12 @@ import com.keao.edu.user.entity.ExamOrganizationRelation;
 import com.keao.edu.user.entity.ExaminationBasic;
 import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.enums.YesOrNoEnum;
+import com.keao.edu.user.page.ExamOrganizationRelationQueryInfo;
 import com.keao.edu.user.service.ExamOrganizationRelationService;
 import com.keao.edu.user.service.OrganizationService;
+import com.keao.edu.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -41,8 +44,33 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 	}
 
 	@Override
-	public PageInfo<ExamOrganizationRelation> queryPage(QueryInfo queryInfo) {
-		return super.queryPage(queryInfo);
+	public PageInfo<ExamOrganizationRelation> queryExamOrgans(ExamOrganizationRelationQueryInfo queryInfo) {
+		PageInfo<ExamOrganizationRelation> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<Integer> nextLevelOrganIds = organizationService.getNextLevelOrganIds(queryInfo.getOrganId(), true);
+		params.put("organIds", nextLevelOrganIds);
+
+		List<ExamOrganizationRelation> dataList = new ArrayList<>();
+		int count = this.findCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = this.getDAO().queryPage(params);
+			List<Integer> organIds = dataList.stream().map(ExamOrganizationRelation::getOrganId).collect(Collectors.toList());
+			List<ExamOrganizationRelation> countInfos = examOrganizationRelationDao.countExamOrganStudentAndPayment(queryInfo.getExamId(), organIds);
+			Map<Integer, ExamOrganizationRelation> organCountInfoMap = countInfos.stream().collect(Collectors.toMap(ExamOrganizationRelation::getOrganId, e -> e));
+			for (ExamOrganizationRelation examOrganizationRelation : dataList) {
+				ExamOrganizationRelation countInfo = organCountInfoMap.get(examOrganizationRelation.getOrganId());
+				if(Objects.nonNull(countInfo)){
+					examOrganizationRelation.setTotalRegistrationStudentNum(countInfo.getTotalRegistrationStudentNum());
+					examOrganizationRelation.setTotalPaymentAmount(countInfo.getTotalPaymentAmount());
+				}
+			}
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
 	}
 
 	@Override

+ 33 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamOrganizationRelationMapper.xml

@@ -108,6 +108,10 @@
 	<sql id="queryCondition">
 		<where>
 			ear.tenant_id_=#{tenantId}
+			AND ear.orga_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
 			<if test="settlementType!=null">
 				AND ear.settlement_type_=#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
 			</if>
@@ -140,16 +144,45 @@
 		</if>
 		<include refid="queryCondition"/>
 	</select>
+
 	<select id="getWithExam" resultMap="ExamOrganizationRelation">
 		SELECT * FROM exam_organization_relation WHERE examination_basic_id_=#{examId}
 	</select>
+
 	<select id="getOrganIdsWithExam" resultType="int">
 		SELECT organ_id_ FROM exam_organization_relation WHERE examination_basic_id_=#{examId} FOR UPDATE
 	</select>
+
     <select id="getWithExams" resultMap="ExamOrganizationRelation">
 		SELECT * FROM exam_organization_relation WHERE examination_basic_id_ IN
 		<foreach collection="examIds" item="examId" separator="," open="(" close=")">
 			#{examId}
 		</foreach>
     </select>
+	<select id="countExamOrganStudentAndPayment" resultMap="ExamOrganizationRelation">
+		SELECT
+			o.id_ organ_id_,
+			SUM(eor.total_registration_student_num_) total_registration_student_num_,
+			SUM(eor.total_payment_amount_) total_payment_amount_
+		FROM
+			organization o
+			LEFT JOIN (
+			SELECT
+				eor1.id_,
+				eor1.organ_id_,
+				eor1.total_payment_amount_,
+				eor1.total_registration_student_num_,
+				o1.parent_organ_id_tag_
+			FROM
+				exam_organization_relation eor1
+				LEFT JOIN organization o1 ON o1.id_ = eor1.organ_id_
+			WHERE eor1.examination_basic_id_=#{examId}
+			) eor ON eor.parent_organ_id_tag_ LIKE CONCAT( o.parent_organ_id_tag_, '%' )
+		WHERE
+			o.id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+		GROUP BY o.id_
+	</select>
 </mapper>