Ver código fonte

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

zouxuan 5 anos atrás
pai
commit
e438714692

+ 11 - 0
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/dto/StudentExamResultStatisticsDto.java

@@ -20,6 +20,9 @@ public class StudentExamResultStatisticsDto {
     @ApiModelProperty(value = "不及格人数")
     private int examFailStudentNum;
 
+    @ApiModelProperty(value = "及格人数")
+    private int examNotFailStudentNum;
+
     public int getTotalRegistrationStudentNum() {
         return totalRegistrationStudentNum;
     }
@@ -51,4 +54,12 @@ public class StudentExamResultStatisticsDto {
     public void setExamFailStudentNum(int examFailStudentNum) {
         this.examFailStudentNum = examFailStudentNum;
     }
+
+    public int getExamNotFailStudentNum() {
+        return examNotFailStudentNum;
+    }
+
+    public void setExamNotFailStudentNum(int examNotFailStudentNum) {
+        this.examNotFailStudentNum = examNotFailStudentNum;
+    }
 }

+ 40 - 23
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationServiceImpl.java

@@ -77,10 +77,23 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
             throw new BizException("项目不在报名中,请核对");
         }
 
+        if (examRegistration.getExamSubjectSongId() == null && examRegistration.getExamMusicTheoryId() == null) {
+            throw new BizException("专业级别或乐理必须其一");
+        }
+
         //考试级别信息
-        ExamSubjectSong examSubjectSong = examSubjectSongDao.get(examRegistration.getExamSubjectSongId());
-        if (examSubjectSong == null) {
-            throw new BizException("请选择专业级别");
+        ExamSubjectSong examSubjectSong = null;
+        Integer level = null;
+        BigDecimal amount = BigDecimal.ZERO;
+        BigDecimal registrationFee = BigDecimal.ZERO;
+        if (examRegistration.getExamSubjectSongId() != null) {
+            examSubjectSong = examSubjectSongDao.get(examRegistration.getExamSubjectSongId());
+            if (examSubjectSong == null) {
+                throw new BizException("您选择的专业级别不存在");
+            }
+            level = examSubjectSong.getLevel();
+            registrationFee = examSubjectSong.getRegistrationFee();
+            amount = amount.add(registrationFee);
         }
 
         if (examRegistration.getOrganId() == null) {
@@ -97,23 +110,27 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         statusEnumList.add(StudentRegistrationStatusEnum.AUDIT_PASS);
         statusEnumList.add(StudentRegistrationStatusEnum.PAY_WAIT);
 
+
         ExamRegistration registration = examRegistrationDao.getRegistration(examinationBasic.getId(),
-                examRegistration.getStudentId(), examRegistration.getSubjectId(), examSubjectSong.getLevel(),
+                examRegistration.getStudentId(), examRegistration.getSubjectId(), level,
                 statusEnumList);
         if (registration != null) {
-            throw new BizException("该考级相同专业及等级您已报名,请勿重复报名");
+            String msg = level != null ? "该考级相同专业及等级您已报名,请勿重复报名" : "该考级相同乐理等级您已报名";
+            throw new BizException(msg);
         }
 
         Date nowDate = new Date();
         String orderNo = idGeneratorService.generatorId("payment") + "";
 
-        examRegistration.setLevel(examSubjectSong.getLevel());
-        BigDecimal amount = examSubjectSong.getRegistrationFee();
+        examRegistration.setLevel(level);
         //乐理考试级别
         ExamMusicTheory examMusicTheory = null;
         BigDecimal theoryLevelFee = BigDecimal.ZERO;
         if (examRegistration.getExamMusicTheoryId() != null) {
             examMusicTheory = examMusicTheoryDao.get(examRegistration.getExamMusicTheoryId());
+            if (examMusicTheory == null) {
+                throw new BizException("你选择的乐理级别不存在");
+            }
         }
         if (examMusicTheory != null) {
             theoryLevelFee = examMusicTheory.getFee();
@@ -123,7 +140,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
 
         examRegistration.setTenantId(organization.getTenantId());
         examRegistration.setStatus(StudentRegistrationStatusEnum.PAY_WAIT);
-        examRegistration.setLevelFee(examSubjectSong.getRegistrationFee());
+        examRegistration.setLevelFee(registrationFee);
         examRegistration.setTheoryLevelFee(theoryLevelFee);
         examRegistration.setCreateTime(nowDate);
         examRegistration.setUpdateTime(nowDate);
@@ -143,7 +160,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         examRegistrationPaymentService.insert(examRegistrationPayment);
 
         HashMap<String, Object> rpMap = new HashMap<>();
-        String baseApiUrl = sysConfigService.findConfigValue("base_api_url",examinationBasic.getTenantId());
+        String baseApiUrl = sysConfigService.findConfigValue("base_api_url", examinationBasic.getTenantId());
         Map<String, Object> payMap = payService.getPayMap(
                 amount,
                 orderNo,
@@ -197,7 +214,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
                 examRegistration.setOrganization(new Organization(examRegistration.getOrganId(), organIdNameMap.get(examRegistration.getOrganId())));
                 examRegistration.getSubject().setName(subjectIdNameMap.get(examRegistration.getSubjectId()));
                 examRegistration.getSysUser().setCertificatePhoto(idPhotoMap.get(examRegistration.getStudentId()));
-                examRegistration.setIsFinishedExam(Objects.isNull(registExamStatusMap.get(examRegistration.getId()))?3:registExamStatusMap.get(examRegistration.getId()));
+                examRegistration.setIsFinishedExam(Objects.isNull(registExamStatusMap.get(examRegistration.getId())) ? 3 : registExamStatusMap.get(examRegistration.getId()));
                 examRegistration.setExaminationBasic(new ExaminationBasic(examRegistration.getExaminationBasicId(), examIdNameMap.get(examRegistration.getExaminationBasicId())));
             }
         }
@@ -222,7 +239,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         Map<String, Object> params = new HashMap<String, Object>();
         MapUtil.populateMap(params, queryInfo);
         SysUser sysUser = sysUserFeignService.queryUserInfo();
-        params.put("studentId",sysUser.getId());
+        params.put("studentId", sysUser.getId());
 
         List<ExamRegistrationDto> dataList = null;
         int count = examRegistrationDao.countStudentList(params);
@@ -287,19 +304,19 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         er.setStatus(status);
         er.setMemo(memo);
 
-        SysConfig baseUrlConfig = sysConfigService.findByParamName(SysConfigService.BASE_H5_URL,er.getTenantId());
-        String baseUrl="";
-        if(Objects.nonNull(baseUrlConfig)){
-            baseUrl=baseUrlConfig.getParanValue();
+        SysConfig baseUrlConfig = sysConfigService.findByParamName(SysConfigService.BASE_H5_URL, er.getTenantId());
+        String baseUrl = "";
+        if (Objects.nonNull(baseUrlConfig)) {
+            baseUrl = baseUrlConfig.getParanValue();
         }
-        baseUrl = "1?" + baseUrl+"/#/appDetail?id=" + registId;
+        baseUrl = "1?" + baseUrl + "/#/appDetail?id=" + registId;
 
         Map<Integer, String> receiverMap = new HashMap<>(1);
         receiverMap.put(er.getStudentId(), er.getStudentId().toString());
-        if(StudentRegistrationStatusEnum.AUDIT_PASS.equals(er.getStatus())){
+        if (StudentRegistrationStatusEnum.AUDIT_PASS.equals(er.getStatus())) {
             sysMessageService.batchSendMessage(MessageTypeEnum.REGIST_PASS_PUSH,
                     receiverMap, null, 0, null, JiguangPushPlugin.PLUGIN_NAME);
-        }else if(StudentRegistrationStatusEnum.AUDIT_REJECT.equals(er.getStatus())){
+        } else if (StudentRegistrationStatusEnum.AUDIT_REJECT.equals(er.getStatus())) {
             sysMessageService.batchSendMessage(MessageTypeEnum.REGIST_REJECT_PUSH,
                     receiverMap, null, 0, baseUrl, JiguangPushPlugin.PLUGIN_NAME);
 
@@ -321,9 +338,9 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         if (Objects.isNull(er)) {
             throw new BizException("学员报名信息有误");
         }
-        if(er.getStudentId().equals(examRegistration.getStudentId())){
+        if (er.getStudentId().equals(examRegistration.getStudentId())) {
             examRegistration.setStatus(StudentRegistrationStatusEnum.AUDIT_WAIT);
-        }else{
+        } else {
             examRegistration.setStatus(null);
         }
         examRegistrationDao.update(examRegistration);
@@ -360,7 +377,7 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
             throw new BizException("项目不在报名中,请核对");
         }
         Map<String, Object> rpMap = new HashMap<>();
-        String baseApiUrl = sysConfigService.findConfigValue("base_api_url",examinationBasic.getTenantId());
+        String baseApiUrl = sysConfigService.findConfigValue("base_api_url", examinationBasic.getTenantId());
         Map<String, Object> payMap = payService.getPayMap(
                 order.getTransAmount(),
                 orderNo,
@@ -384,9 +401,9 @@ public class ExamRegistrationServiceImpl extends BaseServiceImpl<Long, ExamRegis
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
         SysUser sysUser = sysUserFeignService.queryUserInfo();
-        params.put("studentId",sysUser.getId());
+        params.put("studentId", sysUser.getId());
         List<StudentBaseExamsDto> dataList = null;
-        params.put("paymentStatus",1);
+        params.put("paymentStatus", 1);
         int count = examRegistrationDao.countStudentBaseExams(params);
         if (count > 0) {
             pageInfo.setTotal(count);

+ 24 - 5
edu-user/edu-user-biz/src/main/java/com/keao/edu/user/service/impl/ExamSongServiceImpl.java

@@ -3,6 +3,7 @@ package com.keao.edu.user.service.impl;
 import com.keao.edu.auth.api.client.SysUserFeignService;
 import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.entity.UploadReturnBean;
 import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
@@ -13,24 +14,24 @@ import com.keao.edu.user.dao.ExamSongDao;
 import com.keao.edu.user.dao.SubjectDao;
 import com.keao.edu.user.entity.ExamSong;
 import com.keao.edu.user.entity.Subject;
-import com.keao.edu.user.entity.Teacher;
 import com.keao.edu.user.enums.SongTypeEnum;
-import com.keao.edu.user.enums.TeacherSettlementTypeEnum;
 import com.keao.edu.user.page.ExamSongQueryInfo;
 import com.keao.edu.user.service.ExamSongService;
+import com.keao.edu.user.service.UploadFileService;
 import com.keao.edu.util.collection.MapUtil;
 import com.keao.edu.util.excel.POIUtil;
 import com.keao.edu.util.iniFile.IniFileEntity;
 import com.keao.edu.util.iniFile.IniFileUtil;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.PictureData;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.ByteArrayInputStream;
 import java.io.InputStream;
-import java.math.BigDecimal;
 import java.util.*;
 
 @Service
@@ -44,6 +45,8 @@ public class ExamSongServiceImpl extends BaseServiceImpl<Integer, ExamSong> impl
     private SysUserFeignService sysUserFeignService;
     @Autowired
     private SubjectDao subjectDao;
+    @Autowired
+    private UploadFileService uploadFileService;
 
     @Override
     public BaseDAO<Integer, ExamSong> getDAO() {
@@ -142,13 +145,13 @@ public class ExamSongServiceImpl extends BaseServiceImpl<Integer, ExamSong> impl
                                 throw new BizException("专业不能为空");
                             }
                             String[] subjects = row.get(s).toString().split(",");
-                            String subjectIds = "";
+                            StringBuilder subjectIds = new StringBuilder();
                             for (String subject : subjects) {
                                 boolean has = false;
                                 for (Subject subSubject : subSubjects) {
                                     if (subject.equals(subSubject.getName())) {
                                         has = true;
-                                        subjectIds = subjectIds + "," + subSubject.getId();
+                                        subjectIds.append(",").append(subSubject.getId());
                                         break;
                                     }
                                 }
@@ -159,6 +162,22 @@ public class ExamSongServiceImpl extends BaseServiceImpl<Integer, ExamSong> impl
                             objectMap.put("subjectList", subjectIds.substring(1));
                         }
 
+                        StringBuilder pics = new StringBuilder();
+                        if (column.getValue().equals("fileUrlList")) {
+                            List<PictureData> pictureDataList = (ArrayList<PictureData>) row.get(s);
+                            for (PictureData pictureData : pictureDataList) {
+                                InputStream in = new ByteArrayInputStream(pictureData.getData());
+                                UploadReturnBean bean = uploadFileService.uploadFile(in, pictureData.suggestFileExtension());
+                                if (!bean.isStatus()) {
+                                    throw new BizException(objectMap.get("songName") + bean.getMessage());
+                                }
+                                pics.append(",").append(bean.getUrl());
+                            }
+                            if (pics.length() > 0) {
+                                objectMap.put("fileUrlList", pics.substring(1));
+                            }
+                        }
+
                         if (column.getValue().equals("type")) {
                             for (SongTypeEnum songType : SongTypeEnum.values()) {
                                 if (songType.getMsg().equals(row.get(s).toString())) {

+ 2 - 2
edu-user/edu-user-biz/src/main/resources/config/mybatis/ExamSongMapper.xml

@@ -27,7 +27,7 @@
 	
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="ExamSong">
-		SELECT * FROM exam_song WHERE tenant_id_ = #{tenantId} ORDER BY id_
+		SELECT * FROM exam_song WHERE tenant_id_ = #{tenantId} ORDER BY id_ DESC
 	</select>
 	
 	<!-- 向数据库增加一条记录 -->
@@ -103,7 +103,7 @@
 		LEFT JOIN subject s ON FIND_IN_SET(s.id_, es.subject_list_)
 		<include refid="queryCondition"/>
 		GROUP BY es.id_
-		ORDER BY id_
+		ORDER BY id_ DESC
 		<include refid="global.limit"/>
 	</select>
 	

+ 2 - 1
edu-user/edu-user-biz/src/main/resources/config/mybatis/StudentExamResultMapper.xml

@@ -242,8 +242,9 @@
 	<select id="getStudentExamResultStatisticsInfo" resultType="com.keao.edu.user.dto.StudentExamResultStatisticsDto">
 		SELECT
 			COUNT( er.id_ ) totalRegistrationStudentNum,
-			SUM( CASE WHEN ser.is_finished_exam_ = 3 THEN 0 ELSE 1 END ) notExamStudentNum,
+			SUM( CASE WHEN ser.is_finished_exam_ = 3 THEN 1 ELSE 0 END ) notExamStudentNum,
 			SUM( CASE WHEN ser.result_ = 'FAIL' THEN 1 ELSE 0 END ) examFailStudentNum,
+			SUM( CASE WHEN ser.result_ != 'FAIL' THEN 1 ELSE 0 END ) examNotFailStudentNum,
 			SUM( CASE WHEN ser.id_ > 0 THEN 1 ELSE 0 END ) examStudentNum
 		FROM
 			exam_registration er

+ 1 - 0
edu-user/edu-user-server/src/main/resources/columnMapper.ini

@@ -4,6 +4,7 @@
 曲目专业(英文逗号分隔) = subjectList
 曲目级别(填1-10的数字) = levelList
 曲目类别(练习曲or演奏曲) = type
+曲谱图片(插入图片) = fileUrlList
 
 [organization]
 合作机构名字 = name

BIN
edu-user/edu-user-server/src/main/resources/excelTemplate/examSong.xls


+ 86 - 18
edu-util/src/main/java/com/keao/edu/util/excel/POIUtil.java

@@ -1,9 +1,6 @@
 package com.keao.edu.util.excel;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
+import java.io.*;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.text.SimpleDateFormat;
@@ -18,21 +15,12 @@ import java.util.Map.Entry;
 import org.apache.commons.beanutils.NestedNullException;
 import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFFont;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.hssf.usermodel.*;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.streaming.SXSSFWorkbook;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.apache.poi.xssf.usermodel.*;
+import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -481,6 +469,14 @@ public class POIUtil {
             currentRowNum = 0;
             // 顺序取sheet
             sheet = workbook.getSheetAt(i);
+
+            Map<String, List<PictureData>> picMap = null;
+            if (extName.endsWith(".xlsx")) {
+                picMap = getXlsxPictures((XSSFSheet) sheet);
+            } else if (extName.endsWith(".xls")) {
+                picMap = getXlsPictures((HSSFSheet) sheet);
+            }
+
             List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
             rowIter = sheet.iterator();
             while (rowIter.hasNext()) {
@@ -530,6 +526,13 @@ public class POIUtil {
                         currentCellNum++;
                     }
                 }
+                if (picMap != null) {
+                    for (Entry<String, List<PictureData>> pics : picMap.entrySet()) {
+                        String key = pics.getKey();
+                        String[] split = key.split("-");
+                        obj.put(fieldsName[Integer.parseInt(split[1])], pics.getValue());
+                    }
+                }
                 if (obj != null && hasVal)
                     datas.add(obj);
 
@@ -629,4 +632,69 @@ public class POIUtil {
         return list;
     }
 
+    /**
+     * 获取图片和位置 (xls)
+     *
+     * @param sheet
+     * @return
+     * @throws IOException
+     */
+    public static Map<String, List<PictureData>> getXlsPictures(HSSFSheet sheet) throws IOException {
+        Map<String, List<PictureData>> map = new HashMap<>();
+        List<HSSFShape> list = sheet.getDrawingPatriarch().getChildren();
+        for (HSSFShape shape : list) {
+            if (shape instanceof HSSFPicture) {
+                HSSFPicture picture = (HSSFPicture) shape;
+                HSSFClientAnchor cAnchor = (HSSFClientAnchor) picture.getAnchor();
+                PictureData pdata = picture.getPictureData();
+                String key = cAnchor.getRow1() + "-" + cAnchor.getCol1(); // 行号-列号
+                if (map.containsKey(key)) {
+                    List<PictureData> pics = map.get(key);
+                    pics.add(pdata);
+                    map.put(key, pics);
+                } else {
+                    List<PictureData> pics = new ArrayList<>();
+                    pics.add(pdata);
+                    map.put(key, pics);
+                }
+            }
+        }
+        return map;
+    }
+
+    /**
+     * 获取图片和位置 (xlsx)
+     *
+     * @param sheet
+     * @return
+     * @throws IOException
+     */
+    public static Map<String, List<PictureData>> getXlsxPictures(XSSFSheet sheet) throws IOException {
+        Map<String, List<PictureData>> map = new HashMap<>();
+        List<POIXMLDocumentPart> list = sheet.getRelations();
+        for (POIXMLDocumentPart part : list) {
+            if (part instanceof XSSFDrawing) {
+                XSSFDrawing drawing = (XSSFDrawing) part;
+                List<XSSFShape> shapes = drawing.getShapes();
+                for (XSSFShape shape : shapes) {
+                    XSSFPicture picture = (XSSFPicture) shape;
+                    XSSFClientAnchor anchor = picture.getPreferredSize();
+                    CTMarker marker = anchor.getFrom();
+                    String key = marker.getRow() + "-" + marker.getCol();
+
+                    if (map.containsKey(key)) {
+                        List<PictureData> pics = map.get(key);
+                        pics.add(picture.getPictureData());
+                        map.put(key, pics);
+                    } else {
+                        List<PictureData> pics = new ArrayList<>();
+                        pics.add(picture.getPictureData());
+                        map.put(key, pics);
+                    }
+                }
+            }
+        }
+        return map;
+    }
+
 }