Browse Source

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

zouxuan 5 years ago
parent
commit
3f94aaadd7

+ 4 - 3
edu-common/src/main/java/com/keao/edu/common/service/impl/BaseServiceImpl.java

@@ -14,6 +14,7 @@ import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.util.collection.MapUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.ibatis.session.ExecutorType;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -125,7 +126,7 @@ public abstract class BaseServiceImpl<PK extends Serializable, T> implements Bas
 		StringBuffer sql=new StringBuffer();
 		Map<Y,Z> result=new HashMap();
 		try {
-			SqlSession sqlSession = sqlSessionFactory.openSession(true);
+			SqlSession sqlSession = sqlSessionFactory.openSession();
 			Connection connection = sqlSession.getConnection();
 			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(StringUtils.join(ids, ",")).append(")");
 			PreparedStatement ps = connection.prepareStatement(sql.toString());
@@ -170,7 +171,7 @@ public abstract class BaseServiceImpl<PK extends Serializable, T> implements Bas
 		StringBuffer sql=new StringBuffer();
 		Map<Y,Z> result = new HashMap();
 		try {
-			Connection connection = sqlSessionFactory.openSession(true).getConnection();
+			Connection connection = sqlSessionFactory.openSession(ExecutorType.BATCH).getConnection();
 			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ");
 			boolean resultFlag = false;
 			for (Map.Entry<String, Object> entry : paramMap.entrySet()) {
@@ -234,7 +235,7 @@ public abstract class BaseServiceImpl<PK extends Serializable, T> implements Bas
 		StringBuffer sql=new StringBuffer();
 		Map<String, String> result=new HashMap();
 		try {
-			Connection connection = sqlSessionFactory.openSession(true).getConnection();
+			Connection connection = sqlSessionFactory.openSession(ExecutorType.BATCH).getConnection();
 			sql.append("SELECT ").append(columnKey).append(",").append(columnValue).append(" FROM ").append(tableName).append(" WHERE ").append(columnKey).append(" IN (").append(StringUtils.join(ids, ",")).append(")");
 			PreparedStatement ps = connection.prepareStatement(sql.toString());
 			ResultSet resultSet = ps.executeQuery();

+ 19 - 3
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamOrganizationRelationController.java

@@ -71,21 +71,37 @@ public class ExamOrganizationRelationController extends BaseController {
     @ApiOperation("更新考级项目与合作单位关联信息")
     @PostMapping(value = "/updateExamOrganizationRelation")
     public HttpResponseResult updateExamOrganizationRelation(@RequestBody ExamOrganizationRelation examOrganizationRelation){
-        examOrganizationRelationService.updateExamOrganizationRelation(examOrganizationRelation);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(Objects.isNull(sysUser)){
+            return failed("请重新登录");
+        }
+        Employee employee = employeeService.get(sysUser.getId());
+        if(Objects.isNull(employee)){
+            return failed("用户异常");
+        }
+        examOrganizationRelationService.updateExamOrganizationRelation(examOrganizationRelation,employee.getOrganId());
         return succeed();
     }
 
     @ApiOperation("发送考级报名链接")
     @PostMapping(value = "/sendUrl")
     public HttpResponseResult sendUrl(Integer examId){
-        examOrganizationRelationService.sendUrl(examId);
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(Objects.isNull(sysUser)){
+            return failed("请重新登录");
+        }
+        Employee employee = employeeService.get(sysUser.getId());
+        if(Objects.isNull(employee)){
+            return failed("用户异常");
+        }
+        examOrganizationRelationService.sendUrl(examId,employee.getOrganId());
         return succeed();
     }
 
     @ApiOperation("删除")
     @PostMapping(value = "/del")
     public HttpResponseResult del(Long id){
-        examOrganizationRelationService.delete(id);
+        examOrganizationRelationService.deleteExamOrgan(id);
         return succeed();
     }
 

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

@@ -110,6 +110,8 @@ public interface ExamOrganizationRelationDao extends BaseDAO<Long, ExamOrganizat
      */
     ExamOrganStatisticsDto getExamOrganizationRelation(@Param("examId") Long examId, @Param("OrganId") Integer OrganId);
 
+    int deleteExamOrgans(@Param("examId") Long examId, @Param("organIds") List<Integer> organIds);
+
     /**
      * 获取考级项目关联合作单位信息
      * @param examId

+ 4 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamOrganizationRelationService.java

@@ -42,6 +42,8 @@ public interface ExamOrganizationRelationService extends BaseService<Long, ExamO
      */
     void addExamOrganizations(List<ExamOrganizationRelation> organizationRelations, Integer selfOrganId);
 
+    void deleteExamOrgan(Long id);
+
     /**
      * @describe 更新考级项目与合作单位关联信息
      * @author Joburgess
@@ -49,7 +51,7 @@ public interface ExamOrganizationRelationService extends BaseService<Long, ExamO
      * @param examOrganizationRelation:
      * @return void
      */
-    void updateExamOrganizationRelation(ExamOrganizationRelation examOrganizationRelation);
+    void updateExamOrganizationRelation(ExamOrganizationRelation examOrganizationRelation, Integer selfOrganId);
 
     /**
      * @describe 发送考级报名链接
@@ -59,7 +61,7 @@ public interface ExamOrganizationRelationService extends BaseService<Long, ExamO
      * @param organIds:
      * @return void
      */
-    void sendUrl(Integer examId);
+    void sendUrl(Integer examId, Integer selfOrganId);
 
     /**
      * @describe 获取本单位统计信息

+ 37 - 4
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamOrganizationRelationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.keao.edu.user.service.impl;
 
+import cfca.sadk.org.bouncycastle.apache.bzip2.BZip2Constants;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
@@ -247,21 +248,53 @@ public class ExamOrganizationRelationServiceImpl extends BaseServiceImpl<Long, E
 
 	@Override
 	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
-	public void updateExamOrganizationRelation(ExamOrganizationRelation examOrganizationRelation) {
+	public void updateExamOrganizationRelation(ExamOrganizationRelation examOrganizationRelation,Integer selfOrganId) {
 		if(Objects.isNull(examOrganizationRelation.getId())){
 			throw new BizException("参数错误");
 		}
-
+		ExamOrganizationRelation organizationRelation = examOrganizationRelationDao.get(examOrganizationRelation.getId());
+		if(Objects.isNull(organizationRelation)){
+			throw new BizException("参数错误");
+		}
+		ExamOrganStatisticsDto selfOrgan = examOrganizationRelationDao.getExamOrganizationRelation(organizationRelation.getExaminationBasicId().longValue(), selfOrganId);
+		if(Objects.isNull(selfOrgan)){
+			throw new BizException("操作异常");
+		}
+		if(selfOrgan.getIsAllowArrangeExam()==0){
+			examOrganizationRelation.setIsAllowArrangeExam(0);
+		}
 		examOrganizationRelationDao.update(examOrganizationRelation);
 	}
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public void sendUrl(Integer examId) {
+	public void deleteExamOrgan(Long id) {
+		if(Objects.isNull(id)){
+			throw new BizException("参数错误");
+		}
+		ExamOrganizationRelation organizationRelation = examOrganizationRelationDao.get(id);
+		if(Objects.isNull(organizationRelation)){
+			throw new BizException("删除失败");
+		}
+		List<Integer> childOrganIds = organizationService.getChildOrganIds(organizationRelation.getOrganId(), true);
+		List<ExamOrganizationRelation> examOrganizationRelations = examOrganizationRelationDao.getExamOrganizationRelations(organizationRelation.getExaminationBasicId().longValue(), childOrganIds);
+		long count = examOrganizationRelations.stream().filter(e -> e.getSendUrlFlag() == 1).count();
+		if(count>0){
+			throw new BizException("删除失败");
+		}
+		examOrganizationRelationDao.deleteExamOrgans(organizationRelation.getExaminationBasicId().longValue(), childOrganIds);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void sendUrl(Integer examId, Integer selfOrganId) {
 		if(Objects.isNull(examId)){
 			throw new BizException("请指定考级项目");
 		}
-		List<ExamOrganizationRelation> examOrgans = examOrganizationRelationDao.getWithExam(examId);
+
+		List<Integer> childOrganIds = organizationService.getChildOrganIds(selfOrganId, true);
+
+		List<ExamOrganizationRelation> examOrgans = examOrganizationRelationDao.getExamOrganizationRelations(examId.longValue(), childOrganIds);
 		Set<Integer> existOrganizationIds = examOrgans.stream().map(ExamOrganizationRelation::getOrganId).collect(Collectors.toSet());
 
 		ExaminationBasic examinationBasic = examinationBasicDao.get(examId.longValue());

+ 9 - 1
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamOrganizationRelationMapper.xml

@@ -187,7 +187,15 @@
 		DELETE FROM exam_organization_relation WHERE id_ = #{id} 
 	</delete>
 
-	<sql id="queryCondition">
+    <delete id="deleteExamOrgans">
+		DELETE FROM exam_organization_relation
+		WHERE examination_basic_id_=#{examId} AND organ_id_ IN
+		<foreach collection="organIds" item="organId" separator="," open="(" close=")">
+			#{organId}
+		</foreach>
+	</delete>
+
+    <sql id="queryCondition">
 		<where>
 			ear.examination_basic_id_=#{examId}
 			<if test="organIds!=null">