소스 검색

Merge remote-tracking branch 'origin/master'

Joburgess 5 년 전
부모
커밋
dbdde0d55b
15개의 변경된 파일269개의 추가작업 그리고 19개의 파일을 삭제
  1. 1 4
      edu-thirdparty/src/main/java/com/keao/edu/thirdparty/ocr/Ocr.java
  2. 11 0
      edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/Student.java
  3. 7 4
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java
  4. 14 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/StudentController.java
  5. 4 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/SysConfigController.java
  6. 6 2
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/TenantInfoController.java
  7. 18 1
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/StudentDao.java
  8. 7 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java
  9. 75 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/StudentExamPaymentDto.java
  10. 15 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/StudentApplyQueryInfo.java
  11. 18 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/StudentService.java
  12. 50 0
      edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/StudentServiceImpl.java
  13. 1 1
      edu-user/edu-user-server/src/main/resources/config/mybatis/EmployeeMapper.xml
  14. 8 0
      edu-user/edu-user-server/src/main/resources/config/mybatis/StudentExamResultMapper.xml
  15. 34 5
      edu-user/edu-user-server/src/main/resources/config/mybatis/StudentMapper.xml

+ 1 - 4
edu-thirdparty/src/main/java/com/keao/edu/thirdparty/ocr/baidu.java → edu-thirdparty/src/main/java/com/keao/edu/thirdparty/ocr/Ocr.java

@@ -1,15 +1,12 @@
 package com.keao.edu.thirdparty.ocr;
 
-import com.baidu.aip.http.AipRequest;
 import com.baidu.aip.ocr.AipOcr;
-import com.baidu.aip.util.Base64Util;
 import org.json.JSONObject;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
-import java.util.HashMap;
 
-public class baidu {
+public class Ocr {
 
     public static final String APP_ID = "20569335";
     public static final String API_KEY = "82FCqipUDtTqmy2qbrCRaHCo";

+ 11 - 0
edu-user/edu-user-client-api/src/main/java/com/keao/edu/user/api/entity/Student.java

@@ -23,6 +23,9 @@ public class Student{
 
 	private Integer organId;
 
+	@ApiModelProperty(value = "考试次数")
+	private Integer examNum;
+
 	private SysUser sysUser;
 
 	public Student(Integer organId, String phone) {
@@ -37,6 +40,14 @@ public class Student{
 		super();
 	}
 
+	public Integer getExamNum() {
+		return examNum;
+	}
+
+	public void setExamNum(Integer examNum) {
+		this.examNum = examNum;
+	}
+
 	public Integer getOrganId() {
 		return organId;
 	}

+ 7 - 4
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamRegistrationController.java

@@ -5,14 +5,15 @@ import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
-import com.keao.edu.thirdparty.ocr.baidu;
+import com.keao.edu.thirdparty.ocr.Ocr;
 import com.keao.edu.user.dto.ExamRegistrationStatisticsDto;
 import com.keao.edu.user.entity.ExamRegistration;
 import com.keao.edu.user.page.ExamRegistrationQueryInfo;
 import com.keao.edu.user.service.ExamRegistrationService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
@@ -73,10 +74,12 @@ public class ExamRegistrationController extends BaseController {
     }
 
 
-    @ApiOperation(value = "修改学员报名信息")
+    @ApiOperation(value = "ocr")
     @PostMapping(value = "ocr")
+    @ApiImplicitParams({ @ApiImplicitParam(name = "file", value = "身份证图片", required = true, dataType = "file"),
+            @ApiImplicitParam(name = "idCardSide", value = "身份证(front-人像面 back-国徽面)", required = true, dataType = "String") })
     public HttpResponseResult ocr(@RequestParam("file") MultipartFile file,String idCardSide) throws IOException {
-        return succeed(baidu.idcard(file,idCardSide));
+        return succeed(Ocr.idcard(file,idCardSide));
     }
 
 

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

@@ -6,12 +6,17 @@ import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.user.api.entity.Student;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
+import com.keao.edu.user.page.StudentApplyQueryInfo;
 import com.keao.edu.user.service.StudentService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 系统配置控制层
@@ -28,7 +33,14 @@ public class StudentController extends BaseController {
 	@GetMapping(value = "list")
     @PreAuthorize("@pcs.hasPermissions('student/list')")
 	public HttpResponseResult<PageInfo<Student>> list(QueryInfo queryInfo) {
-		return succeed(studentService.queryPage(queryInfo));
+		return succeed(studentService.queryStudentPage(queryInfo));
+	}
+
+	@ApiOperation(value = "学员报考列表")
+	@GetMapping(value = "applyList")
+    @PreAuthorize("@pcs.hasPermissions('student/applyList')")
+	public HttpResponseResult<PageInfo<StudentExamPaymentDto>> applyList(StudentApplyQueryInfo queryInfo) {
+		return succeed(studentService.queryApplyList(queryInfo));
 	}
 
 	@ApiOperation(value = "查询学员")

+ 4 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/SysConfigController.java

@@ -3,6 +3,8 @@ package com.keao.edu.user.controller;
 
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.SysConfig;
+import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.common.tenant.TenantContextHolder;
 import com.keao.edu.user.service.SysConfigService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -34,8 +36,10 @@ public class SysConfigController extends BaseController {
 	@GetMapping(value = "list")
     @PreAuthorize("@pcs.hasPermissions('sysConfig/list')")
 	public Object configList(String group) {
+		String tenantId = TenantContextHolder.getTenantId().toString();
 		Map<String,Object> params = new HashMap<String, Object>();
 		params.put("group", group);
+		params.put("tenantId", tenantId);
 		List<SysConfig> configs = sysConfigService.findAll(params);
 		return succeed(configs);
 	}

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

@@ -5,6 +5,7 @@ import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
+import com.keao.edu.common.tenant.TenantContextHolder;
 import com.keao.edu.user.entity.TenantInfo;
 import com.keao.edu.user.service.TenantInfoService;
 import io.swagger.annotations.Api;
@@ -32,8 +33,9 @@ public class TenantInfoController extends BaseController {
 	@ApiOperation("查询机构详情")
 	@ApiImplicitParam(name = "id", value = "机构ID", required = true, dataType = "Integer", paramType = "path")
 	@GetMapping(value = "/query")
-	public HttpResponseResult<TenantInfo> query(Integer id) {
-		return succeed(tenantInfoService.get(id));
+	public HttpResponseResult<TenantInfo> query() {
+		String tenantId = TenantContextHolder.getTenantId().toString();
+		return succeed(tenantInfoService.get(Integer.parseInt(tenantId)));
 	}
 
 	@ApiOperation("新增机构")
@@ -46,7 +48,9 @@ public class TenantInfoController extends BaseController {
 	@ApiOperation("更新机构")
 	@PostMapping(value = "/update")
 	public HttpResponseResult update(TenantInfo tenantInfo) {
+		String tenantId = TenantContextHolder.getTenantId().toString();
 		tenantInfo.setUpdateTime(new Date());
+		tenantInfo.setId(Integer.parseInt(tenantId));
 		tenantInfoService.update(tenantInfo);
 		return succeed();
 	}

+ 18 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/StudentDao.java

@@ -2,8 +2,25 @@ package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.user.api.entity.Student;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
+
+import java.util.List;
+import java.util.Map;
 
 public interface StudentDao extends BaseDAO<Integer, Student> {
 
-	
+
+    /**
+     * COUNT学员报名详情列表
+     * @param params
+     * @return
+     */
+    int countApplyList(Map<String, Object> params);
+
+    /**
+     * 获取学员报名详情列表
+     * @param params
+     * @return
+     */
+    List<StudentExamPaymentDto> queryApplyList(Map<String, Object> params);
 }

+ 7 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/StudentExamResultDao.java

@@ -33,4 +33,11 @@ public interface StudentExamResultDao extends BaseDAO<Long, StudentExamResult> {
     StudentExamResultStatisticsDto getStudentExamResultStatisticsInfo(@Param("organIds") List<Integer> organIds,
                                                                       @Param("examId") Integer examId);
 
+    /**
+     * 获取考试次数
+     * @param studentIds
+     * @param tenantId
+     * @return
+     */
+    List<Map> countExamNum(@Param("studentIds") List<Integer> studentIds, @Param("tenantId") String tenantId);
 }

+ 75 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/StudentExamPaymentDto.java

@@ -0,0 +1,75 @@
+package com.keao.edu.user.dto;
+
+import com.keao.edu.user.entity.ExamRegistration;
+import com.keao.edu.user.entity.ExamRegistrationPayment;
+import com.keao.edu.user.entity.StudentExamResult;
+import io.swagger.annotations.ApiModelProperty;
+
+public class StudentExamPaymentDto {
+
+    @ApiModelProperty(value = "考试项目")
+    private String examBaseName;
+
+    @ApiModelProperty(value = "学员报名数据")
+    private ExamRegistration examRegistration;
+
+    @ApiModelProperty(value = "学员考试结果")
+    private StudentExamResult studentExamResult;
+
+    @ApiModelProperty(value = "学员报名订单数据")
+    private ExamRegistrationPayment examRegistrationPayment;
+
+    @ApiModelProperty(value = "合作单位")
+    private String organName;
+
+    @ApiModelProperty(value = "报考专业")
+    private String subjectName;
+
+    public String getExamBaseName() {
+        return examBaseName;
+    }
+
+    public void setExamBaseName(String examBaseName) {
+        this.examBaseName = examBaseName;
+    }
+
+    public ExamRegistration getExamRegistration() {
+        return examRegistration;
+    }
+
+    public void setExamRegistration(ExamRegistration examRegistration) {
+        this.examRegistration = examRegistration;
+    }
+
+    public StudentExamResult getStudentExamResult() {
+        return studentExamResult;
+    }
+
+    public void setStudentExamResult(StudentExamResult studentExamResult) {
+        this.studentExamResult = studentExamResult;
+    }
+
+    public ExamRegistrationPayment getExamRegistrationPayment() {
+        return examRegistrationPayment;
+    }
+
+    public void setExamRegistrationPayment(ExamRegistrationPayment examRegistrationPayment) {
+        this.examRegistrationPayment = examRegistrationPayment;
+    }
+
+    public String getOrganName() {
+        return organName;
+    }
+
+    public void setOrganName(String organName) {
+        this.organName = organName;
+    }
+
+    public String getSubjectName() {
+        return subjectName;
+    }
+
+    public void setSubjectName(String subjectName) {
+        this.subjectName = subjectName;
+    }
+}

+ 15 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/StudentApplyQueryInfo.java

@@ -0,0 +1,15 @@
+package com.keao.edu.user.page;
+
+import com.keao.edu.common.page.QueryInfo;
+
+public class StudentApplyQueryInfo extends QueryInfo {
+    private Integer studentId;
+
+    public Integer getStudentId() {
+        return studentId;
+    }
+
+    public void setStudentId(Integer studentId) {
+        this.studentId = studentId;
+    }
+}

+ 18 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/StudentService.java

@@ -1,7 +1,11 @@
 package com.keao.edu.user.service;
 
+import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.BaseService;
 import com.keao.edu.user.api.entity.Student;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
+import com.keao.edu.user.page.StudentApplyQueryInfo;
 
 /**
  * @Author Joburgess
@@ -26,4 +30,18 @@ public interface StudentService extends BaseService<Integer, Student> {
      * @return void
      */
     void updateStudent(Student student);
+
+    /**
+     * 获取学员列表
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<Student> queryStudentPage(QueryInfo queryInfo);
+
+    /**
+     * 获取学员成功报名的数据详情
+     * @param queryInfo
+     * @return
+     */
+    PageInfo<StudentExamPaymentDto> queryApplyList(StudentApplyQueryInfo queryInfo);
 }

+ 50 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/StudentServiceImpl.java

@@ -3,22 +3,35 @@ package com.keao.edu.user.service.impl;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.common.exception.BizException;
+import com.keao.edu.common.page.PageInfo;
+import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.im.api.client.ImFeignService;
 import com.keao.edu.im.api.entity.ImResult;
 import com.keao.edu.im.api.entity.ImUserModel;
 import com.keao.edu.user.dao.StudentDao;
+import com.keao.edu.user.dao.StudentExamResultDao;
 import com.keao.edu.user.dao.SysUserDao;
 import com.keao.edu.user.api.entity.Student;
+import com.keao.edu.user.dto.StudentExamPaymentDto;
 import com.keao.edu.user.entity.Organization;
 import com.keao.edu.user.enums.YesOrNoEnum;
+import com.keao.edu.user.page.StudentApplyQueryInfo;
 import com.keao.edu.user.service.OrganizationService;
 import com.keao.edu.user.service.StudentService;
+import com.keao.edu.util.collection.MapUtil;
+import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * @Author Joburgess
  * @Date 2020.06.18
@@ -31,6 +44,8 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     @Autowired
     private SysUserDao sysUserDao;
     @Autowired
+    private StudentExamResultDao studentExamResultDao;
+    @Autowired
     private OrganizationService organizationService;
     @Autowired
     private ImFeignService imFeignService;
@@ -88,4 +103,39 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
         sysUserDao.update(sysUser);
         studentDao.update(student);
     }
+
+    @Override
+    public PageInfo<Student> queryStudentPage(QueryInfo queryInfo) {
+        PageInfo<Student> studentPageInfo = queryPage(queryInfo);
+        List<Student> rows = studentPageInfo.getRows();
+        if(rows != null && rows.size() > 0){
+            List<Integer> studentIds = rows.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+            //获取考试次数
+            Map<Integer,Integer> examNumMap = MapUtil.convertIntegerMap(studentExamResultDao.countExamNum(studentIds, queryInfo.getTenantId()));
+            rows.forEach(e->{
+                e.setExamNum(examNumMap.get(e.getUserId()));
+            });
+        }
+        return studentPageInfo;
+    }
+
+    @Override
+    public PageInfo<StudentExamPaymentDto> queryApplyList(StudentApplyQueryInfo queryInfo) {
+        PageInfo<StudentExamPaymentDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<StudentExamPaymentDto> dataList = null;
+        int count = studentDao.countApplyList(params);
+        if (count > 0) {
+            pageInfo.setTotal(count);
+            params.put("offset", pageInfo.getOffset());
+            dataList = studentDao.queryApplyList(params);
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
 }

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

@@ -101,7 +101,7 @@
 	</update>
 	<sql id="employeeQueryPage">
 		<where>
-				e.del_flag_ = 1 AND tenant_id_ = #{tenantId}
+				e.del_flag_ = 1 AND e.tenant_id_ = #{tenantId}
 			<if test="search != null and search != ''">
 				AND (e.user_id_ = #{search} OR su.phone_ LIKE CONCAT('%',#{search},'%') OR su.real_name_ LIKE CONCAT('%',#{search},'%'))
 			</if>

+ 8 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -155,4 +155,12 @@
 		GROUP BY
 			er.examination_basic_id_
 	</select>
+	<select id="countExamNum" resultType="java.util.HashMap">
+		SELECT ser.student_id_ 'key',COUNT(ser.id_) 'value' FROM student_exam_result ser
+		WHERE ser.tenant_id_ = #{tenantId} AND ser.is_finished_exam_ = 1 AND ser.student_id_ IN
+		<foreach collection="studentIds" item="item" open="(" close=")" separator=",">
+			#{item}
+		</foreach>
+		GROUP BY ser.student_id_
+	</select>
 </mapper>

+ 34 - 5
edu-user/edu-user-server/src/main/resources/config/mybatis/StudentMapper.xml

@@ -56,9 +56,9 @@
 
 	<sql id="queryCondition">
 		<where>
-			tenant_id_=#{tenantId}
-			<if test="search!=null">
-				AND (stu.user_id_=#{search} OR su.real_name_ LIKE CONCAT (#{search}, '%'))
+			stu.tenant_id_ = #{tenantId}
+			<if test="search != null and search != ''">
+				AND (stu.user_id_ = #{search} OR su.real_name_ LIKE CONCAT (#{search}, '%'))
 			</if>
 		</where>
 	</sql>
@@ -73,8 +73,37 @@
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM student
-		LEFT JOIN sys_user su ON su.id_=stu.user_id_
+		SELECT COUNT(*) FROM student stu
+		LEFT JOIN sys_user su ON su.id_ = stu.user_id_
 		<include refid="queryCondition"/>
 	</select>
+	<resultMap id="queryApplyListMap" type="com.keao.edu.user.dto.StudentExamPaymentDto">
+		<association property="examRegistration" resultMap="com.keao.edu.user.dao.ExamRegistrationDao.ExamRegistration"/>
+		<association property="studentExamResult" resultMap="com.keao.edu.user.dao.StudentExamResultDao.StudentExamResult"/>
+		<association property="examRegistrationPayment" resultMap="com.keao.edu.user.dao.ExamRegistrationPaymentDao.ExamRegistrationPayment"/>
+	</resultMap>
+    <select id="queryApplyList" resultMap="queryApplyListMap">
+		SELECT * FROM exam_registration er
+		LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
+		LEFT JOIN student_exam_result ser ON ser.examination_basic_id_ = er.examination_basic_id_
+		<include refid="queryApplyListSql"/>
+		<include refid="global.limit"/>
+	</select>
+	<select id="countApplyList" resultType="java.lang.Integer">
+		SELECT COUNT(er.id_) FROM exam_registration er
+		LEFT JOIN exam_registration_payment erp ON er.id_ = erp.exam_registration_id_
+		LEFT JOIN student_exam_result ser ON ser.examination_basic_id_ = er.examination_basic_id_
+		<include refid="queryApplyListSql"/>
+	</select>
+	<sql id="queryApplyListSql">
+		<where>
+			er.student_id_ = erp.student_id_ AND er.student_id_ = ser.student_id_ AND erp.trans_status_ = 'SUCCESS'
+			<if test="studentId != null">
+				AND er.student_id_ = #{studentId}
+			</if>
+			<if test="tenantId != null">
+				AND er.tenant_id_ = #{tenantId}
+			</if>
+		</where>
+	</sql>
 </mapper>