Просмотр исходного кода

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas

yonge 5 лет назад
Родитель
Сommit
f676d03a69

+ 11 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/ExamManualLedgerDao.java

@@ -40,4 +40,15 @@ public interface ExamManualLedgerDao extends BaseDAO<Long, ExamManualLedger> {
      */
     BigDecimal countOrganLedgerWithExam(@Param("examId") Long examId,
                                         @Param("organId") Integer organId);
+
+    /**
+     * @describe 统计合作单位在指定项目中的累计支出
+     * @author Joburgess
+     * @date 2020.08.07
+     * @param examId:
+     * @param organIds:
+     * @return java.util.List<java.util.Map<java.lang.Integer,java.math.BigDecimal>>
+     */
+    List<Map<Integer, BigDecimal>> countOrgansLedgerWithExam(@Param("examId") Long examId,
+                                                             @Param("organIds") List<Integer> organIds);
 }

+ 10 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java

@@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
 
@@ -123,4 +124,13 @@ public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
      * @return int
      */
     int countExamResultRecordNum(@Param("examId") Long examId);
+
+    /**
+     * @describe 获取考级项目中完成考试的学员
+     * @author Joburgess
+     * @date 2020.08.07
+     * @param examId:
+     * @return java.util.Set<java.lang.Long>
+     */
+    Set<Long> getIsFinishedExamRegistIds(@Param("examId") Long examId);
 }

+ 14 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dto/ExamOrganizationRelationExtraDto.java

@@ -1,6 +1,9 @@
 package com.keao.edu.user.dto;
 
 import com.keao.edu.user.entity.ExamOrganizationRelation;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.math.BigDecimal;
 
 /**
  * @Author Joburgess
@@ -12,6 +15,9 @@ public class ExamOrganizationRelationExtraDto extends ExamOrganizationRelation {
 
     private int selfOrgan;
 
+    @ApiModelProperty(value = "实际付款金额")
+    private BigDecimal actualPaymentAmount;
+
     public int getSelfOrgan() {
         return selfOrgan;
     }
@@ -27,4 +33,12 @@ public class ExamOrganizationRelationExtraDto extends ExamOrganizationRelation {
     public void setOrganizationName(String organizationName) {
         this.organizationName = organizationName;
     }
+
+    public BigDecimal getActualPaymentAmount() {
+        return actualPaymentAmount;
+    }
+
+    public void setActualPaymentAmount(BigDecimal actualPaymentAmount) {
+        this.actualPaymentAmount = actualPaymentAmount;
+    }
 }

+ 1 - 2
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/ExamRoomStudentRelationService.java

@@ -36,11 +36,10 @@ public interface ExamRoomStudentRelationService extends BaseService<Long, ExamRo
      * @describe 自动分配学员到考场
      * @author Joburgess
      * @date 2020.08.06
-     * @param examRoomId:
      * @param selfOrganId:
      * @return void
      */
-    void autoSplitStudentToRoom(Long examRoomId, Integer selfOrganId);
+    void autoSplitStudentToRoom(Long examId, Integer selfOrganId);
 
     /**
      * @describe 更换学员考场

+ 9 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamOrganizationRelationServiceImpl.java

@@ -90,10 +90,13 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 			params.put("offset", pageInfo.getOffset());
 			dataList = examOrganizationRelationDao.queryExamOrgans(params);
 			List<Integer> organIds = dataList.stream().map(ExamOrganizationRelation::getOrganId).collect(Collectors.toList());
+			List<Map<Integer, BigDecimal>> examOrganAmountMaps = examManualLedgerDao.countOrgansLedgerWithExam(queryInfo.getExamId().longValue(), organIds);
+			Map<Integer, BigDecimal> examOrganAmountMap = MapUtil.convertMybatisMap(examOrganAmountMaps, Integer.class, BigDecimal.class);
 			for (ExamOrganizationRelationExtraDto examOrganizationRelation : dataList) {
 				if(examOrganizationRelation.getOrganId().equals(queryInfo.getOrganId())){
 					examOrganizationRelation.setSelfOrgan(1);
 				}
+				examOrganizationRelation.setActualPaymentAmount(examOrganAmountMap.get(examOrganizationRelation.getOrganId()));
 			}
 		}
 		pageInfo.setRows(dataList);
@@ -494,7 +497,12 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 
 		List<Integer> childOrganIds = organizationService.getChildOrganIds(organId, true);
 
-		List<ExamRegistrationPayment> examRegistrationPayments = examRegistrationPaymentDao.getWithExamOrgansAndDay(examId, childOrganIds, days);
+		List<ExamRegistrationPayment> examRegistrationPayments;
+		if(!CollectionUtils.isEmpty(childOrganIds)){
+			examRegistrationPayments = examRegistrationPaymentDao.getWithExamOrgansAndDay(examId, childOrganIds, days);
+		}else{
+			examRegistrationPayments = examRegistrationPaymentDao.getWithExamOrganAndDay(examId, organId, days);
+		}
 		List<ExamManualLedger> examOrganManualLedgers = examManualLedgerDao.getExamOrganManualLedgers(organId, examId, days);
 
 		Map<String, List<ExamRegistrationPayment>> dayPaymentMap = new HashMap<>();

+ 0 - 6
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomServiceImpl.java

@@ -263,8 +263,6 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 		}
 
 		examinationBasicDao.update(examinationBasic);
-
-		examTeacherSalaryService.teacherSalarySettlementWithExam(examinationBasic.getId());
 	}
 
 	@Override
@@ -368,8 +366,6 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			List<Long> registIds = examRoomStudents.stream().map(ExamRoomStudentRelation::getExamRegistrationId).collect(Collectors.toList());
 			examCertificationDao.updateExamAddress(examLocation.getAddress(), registIds);
 		}
-
-		examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId());
 		return examRoom;
 	}
 
@@ -418,8 +414,6 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 			examinationBasic.setActualExamEndTime(DateUtils.ceiling(examRoomExamTime.getExamEndTime(), Calendar.DAY_OF_MONTH));
 		}
 		examinationBasicDao.update(examinationBasic);
-
-		examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId());
 	}
 
 	@Override

+ 9 - 5
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRoomStudentRelationServiceImpl.java

@@ -192,7 +192,6 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		}
 		if(!CollectionUtils.isEmpty(examRoomStudentRelations)){
 			examRoomStudentRelationDao.batchInsert(examRoomStudentRelations);
-			examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId());
 			examRoom.setExamRoomStudentNum(examRoomStudentRelationDao.countStudentsWithRoom(examRoom.getId()));
 			examRoomDao.update(examRoom);
 		}
@@ -266,6 +265,9 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		Set<Integer> subjectIds = subjectRegistMap.keySet();
 		//未排考学员可排考考场
 		List<ExamRoom> examRooms = examRoomDao.getWithExamAndSubjects(examId, new ArrayList<>(subjectIds));
+		if(CollectionUtils.isEmpty(examRooms)){
+			throw new BizException("请先建立考场");
+		}
 		Set<Long> roomIds = examRooms.stream().map(ExamRoom::getId).collect(Collectors.toSet());
 		//未排考学员可排考考场学员
 		List<ExamRoomStudentRelation> examRoomStudents = examRoomStudentRelationDao.getWithExamRooms(new ArrayList<>(roomIds));
@@ -276,15 +278,17 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		//每个考场可分配学员数
 		Integer roomStudentNum=allStudentNum/roomNum;
 
+		Integer existRoomStudentAvgNum = examRoomStudents.size()/roomNum;
+
 		Set<Long> inRoomRegistIds=new HashSet<>();
 
 		List<ExamRoomStudentRelation> newRoomStudents = new ArrayList<>();
 		Map<Long, Integer> roomStudentNumMap = examRooms.stream().collect(Collectors.toMap(ExamRoom::getId, e->Objects.isNull(e.getExamRoomStudentNum())?0:e.getExamRoomStudentNum()));
 
-		if(roomStudentNum>0){
+		if(roomStudentNum>existRoomStudentAvgNum){
 			int startIndex=0;
 			for (ExamRoom examRoom : examRooms) {
-				List<ExamRegistration> examRegistrations = notInRoomStudents.subList(startIndex, roomStudentNum - examRoom.getExamRoomStudentNum());
+				List<ExamRegistration> examRegistrations = notInRoomStudents.subList(startIndex, startIndex + roomStudentNum - examRoom.getExamRoomStudentNum());
 				startIndex = startIndex+examRegistrations.size();
 				for (ExamRegistration examRegistration : examRegistrations) {
 					ExamRoomStudentRelation e=new ExamRoomStudentRelation();
@@ -300,7 +304,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 			}
 		}
 
-		List<ExamRegistration> surplusRegist = notInRoomStudents.stream().filter(e -> !inRoomRegistIds.contains(e.getId())).collect(Collectors.toList());
+		List<ExamRegistration> surplusRegist = notInRoomStudents.stream().filter(e -> !inRoomRegistIds.contains(e.getId().longValue())).collect(Collectors.toList());
 
 		for (ExamRegistration examRegistration : surplusRegist) {
 			List<Long> sortedRoomIds=new LinkedList<>();
@@ -313,6 +317,7 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 				e.setStudentId(examRegistration.getStudentId());
 				e.setTenantId(examinationBasic.getTenantId());
 				newRoomStudents.add(e);
+				break;
 			}
 		}
 
@@ -450,7 +455,6 @@ public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl<Long, Ex
 		studentExamResultDao.deleteWithRegists(registIds);
 		examRoom.setExamRoomStudentNum(examRoomStudentRelationDao.countStudentsWithRoom(examRoom.getId()));
 		examRoomDao.update(examRoom);
-		examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId());
 	}
 
 	@Override

+ 8 - 1
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamTeacherSalaryServiceImpl.java

@@ -38,6 +38,8 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
 	private TeacherDao teacherDao;
 	@Autowired
 	private ExaminationBasicDao examinationBasicDao;
+	@Autowired
+	private StudentExamResultDao studentExamResultDao;
 
 	@Override
 	public BaseDAO<Long, ExamTeacherSalary> getDAO() {
@@ -54,6 +56,9 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
 
 		Map<Integer, List<ExamRoom>> teacherExamRoomMap=new HashMap<>();
 		for (ExamRoom examRoom : examRooms) {
+			if(examRoom.getExamRoomStudentNum()<=0){
+				continue;
+			}
 			if(!teacherExamRoomMap.containsKey(examRoom.getMainTeacherUserId())){
 				teacherExamRoomMap.put(examRoom.getMainTeacherUserId(), new ArrayList<>());
 			}
@@ -71,6 +76,8 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
 
 		List<ExamRoomStudentRelation> examRoomStudentRelations = examRoomStudentRelationDao.getExamRoomStudentRelations(examId, null, null);
 
+		Set<Long> isFinishedExamRegistIds = studentExamResultDao.getIsFinishedExamRegistIds(examId);
+
 		List<ExamTeacherSalary> examTeacherSalaries = examTeacherSalaryDao.queryWithExam(examId);
 		for (ExamTeacherSalary examTeacherSalary : examTeacherSalaries) {
 			List<ExamRoom> teacherExamRooms = teacherExamRoomMap.get(examTeacherSalary.getTeacherId());
@@ -81,7 +88,7 @@ public class ExamTeacherSalaryServiceImpl extends BaseServiceImpl<Long, ExamTeac
 				continue;
 			}
 			Set<Long> examRoomIds = teacherExamRooms.stream().map(ExamRoom::getId).collect(Collectors.toSet());
-			long studentNum = examRoomStudentRelations.stream().filter(e -> examRoomIds.contains(e.getExamRoomId())).count();
+			long studentNum = examRoomStudentRelations.stream().filter(e -> examRoomIds.contains(e.getExamRoomId())&&isFinishedExamRegistIds.contains(e.getExamRegistrationId())).count();
 			examTeacherSalary.setTotalInvigilationNum(examRoomIds.size());
 			examTeacherSalary.setTotalInvigilationStudentNum((int) studentNum);
 			if(TeacherSettlementTypeEnum.SINGLE.equals(examTeacherSalary.getSettlementType())){

+ 17 - 4
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExaminationBasicServiceImpl.java

@@ -16,10 +16,7 @@ import com.keao.edu.user.dto.ExaminationBasicDto;
 import com.keao.edu.user.entity.*;
 import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.page.ExaminationQueryInfo;
-import com.keao.edu.user.service.ExamOrganizationRelationService;
-import com.keao.edu.user.service.ExaminationBasicService;
-import com.keao.edu.user.service.OrganizationService;
-import com.keao.edu.user.service.StudentExamResultService;
+import com.keao.edu.user.service.*;
 import com.keao.edu.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.DateUtils;
@@ -65,6 +62,8 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
     private ExamRoomDao examRoomDao;
     @Autowired
     private TenantInfoDao tenantInfoDao;
+    @Autowired
+    private ExamTeacherSalaryService examTeacherSalaryService;
 
     @Override
     public BaseDAO<Long, ExaminationBasic> getDAO() {
@@ -232,6 +231,7 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
             }
             examLifecycleLogDao.insert(new ExamLifecycleLog(existsExam.getId().intValue(), "确认考试结果", operatorId));
             studentExamResultService.examResultConfirmPush(examId);
+            examTeacherSalaryService.teacherSalarySettlementWithExam(examId);
         }else if(ExamStatusEnum.CLOSE.equals(statusEnum)){
             examLifecycleLogDao.insert(new ExamLifecycleLog(existsExam.getId().intValue(), "关闭考级项目", operatorId));
             examOrganizationRelationService.examStatusChangePush(examId, statusEnum);
@@ -382,6 +382,19 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
         examinationBasic.setActualExamStartTime(existsExam.getActualExamStartTime());
         examinationBasic.setActualExamEndTime(existsExam.getActualExamEndTime());
 
+        if(Objects.isNull(examinationBasic.getPosterBackgroundImg())){
+            examinationBasic.setPosterBackgroundImg(existsExam.getPosterBackgroundImg());
+        }
+        if(Objects.isNull(examinationBasic.getCustomPoster())){
+            examinationBasic.setCustomPoster(existsExam.getCustomPoster());
+        }
+        if(Objects.isNull(examinationBasic.getActualExamStartTime())){
+            examinationBasic.setActualExamStartTime(existsExam.getActualExamStartTime());
+        }
+        if(Objects.isNull(examinationBasic.getActualExamEndTime())){
+            examinationBasic.setActualExamEndTime(existsExam.getActualExamEndTime());
+        }
+
         examinationBasicDao.update(examinationBasic);
         if(examRegistIsChange){
             examOrganizationRelationService.examDateChangePush(examinationBasic.getId());

+ 16 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamManualLedgerMapper.xml

@@ -170,4 +170,20 @@
 			AND organ_id_ = #{organId}
 			AND trans_direction_ = 'EXPENDITURE'
 	</select>
+
+    <select id="countOrgansLedgerWithExam" resultType="java.util.Map">
+		SELECT
+			target_organ_id_ AS 'key',
+			SUM( amount_ ) AS 'value'
+		FROM
+			exam_manual_ledger
+		WHERE
+			examination_basic_id_ = #{examId}
+			AND target_organ_id_ IN
+			<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+				#{organId}
+			</foreach>
+		GROUP BY
+			target_organ_id_;
+    </select>
 </mapper>

+ 4 - 0
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -302,4 +302,8 @@
 		SELECT COUNT(exam_registration_id_) FROM student_exam_result
 		WHERE examination_basic_id_=#{examId}
 	</select>
+
+    <select id="getIsFinishedExamRegistIds" resultType="Long">
+		SELECT exam_registration_id_ FROM student_exam_result WHERE examination_basic_id_=#{examId} AND is_finished_exam_=5;
+    </select>
 </mapper>

+ 2 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRoomStudentRelationController.java

@@ -131,7 +131,7 @@ public class ExamRoomStudentRelationController extends BaseController {
 
     @ApiOperation("自动分配学员到考场")
     @PostMapping(value = "/autoSplitStudentToRoom")
-    public HttpResponseResult autoSplitStudentToRoom(Long examRoomId){
+    public HttpResponseResult autoSplitStudentToRoom(Long examId){
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         Integer organId=null;
         if(!sysUser.getIsSuperAdmin()){
@@ -141,7 +141,7 @@ public class ExamRoomStudentRelationController extends BaseController {
             }
             organId=employee.getOrganId();
         }
-        examRoomStudentRelationService.autoSplitStudentToRoom(examRoomId, organId);
+        examRoomStudentRelationService.autoSplitStudentToRoom(examId, organId);
         return succeed();
     }
 

+ 3 - 4
edu-util/src/main/java/com/keao/edu/util/collection/MapUtil.java

@@ -9,10 +9,7 @@ import java.beans.PropertyDescriptor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 public class MapUtil {
 
@@ -144,6 +141,8 @@ public class MapUtil {
 		int size = 0;
 		if(maps != null){
 			size = maps.size();
+		}else{
+			return Collections.EMPTY_MAP;
 		}
 		Map result=new HashMap(size);
 		try {