diff --git a/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExAnswers.java b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExAnswers.java new file mode 100644 index 0000000..1491c29 --- /dev/null +++ b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExAnswers.java @@ -0,0 +1,59 @@ +package com.ccic.safeliab.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("ex_answers") +public class ExAnswers extends BaseEntity implements Serializable { + + /** + * ID + */ + @TableId(value = "id", type = IdType.ID_WORKER) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + + /** + * 用户ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long userId; + + /** + * 试卷ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long paperId; + + /** + * 考试ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long examId; + + /** + * 题目ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long questionId; + + /** + * 用户选择的答案 + */ + private String selectedAnswer; + + /** + * 是否正确 + */ + private Integer isCorrect; +} diff --git a/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamInfo.java b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamInfo.java new file mode 100644 index 0000000..edea484 --- /dev/null +++ b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamInfo.java @@ -0,0 +1,66 @@ +package com.ccic.safeliab.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("ex_exam_info") +public class ExExamInfo extends BaseEntity implements Serializable { + + /** + * ID + */ + @TableId(value = "id", type = IdType.ID_WORKER) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + + /** + * 考试名称 + */ + private String examName; + + /** + * 试卷ID + */ + private Long paperId; + + /** + * 监管行业ID + */ + private Long industryId; + + /** + * 考试区域 + */ + private String examRegion; + + /** + * 考试有效时间 + */ + private String validFrom; + + /** + * 考试失效时间 + */ + private String validTo; + + /** + * 发布状态 + */ + private Integer publishStatus; + + /** + * 内容描述 + */ + private String remark; + +} diff --git a/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamScoures.java b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamScoures.java new file mode 100644 index 0000000..245e448 --- /dev/null +++ b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamScoures.java @@ -0,0 +1,53 @@ +package com.ccic.safeliab.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("ex_exam_scores") +public class ExExamScoures extends BaseEntity implements Serializable { + + /** + * ID + */ + @TableId(value = "id", type = IdType.ID_WORKER) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + + /** + * 用户ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long userId; + + /** + * 试卷ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long paperId; + + /** + * 考试ID + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long examId; + + /** + * 总分 + */ + private Integer totalScore; + + /** + * 考试用时 + */ + private Integer examTimeSpent; +} diff --git a/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExOpenUser.java b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExOpenUser.java new file mode 100644 index 0000000..6a625c5 --- /dev/null +++ b/ccic-entity/src/main/java/com/ccic/safeliab/entity/ExOpenUser.java @@ -0,0 +1,51 @@ +package com.ccic.safeliab.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +import java.io.Serializable; + +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@TableName("ex_open_user") +public class ExOpenUser extends BaseEntity implements Serializable { + + /** + * ID + */ + @TableId(value = "id", type = IdType.ID_WORKER) + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long id; + + /** + * 小程序唯一标识 + */ + private String openid; + + /** + * 用户昵称 + */ + private String nickname; + + /** + * 用户头像URL + */ + private String avatarUrl; + + /** + * 用户性别 + */ + private Integer gender; + + /** + * 用户电话 + */ + private String phoneNumber; + +} diff --git a/ccic-exam/pom.xml b/ccic-exam/pom.xml index 2cce39f..7f62376 100644 --- a/ccic-exam/pom.xml +++ b/ccic-exam/pom.xml @@ -182,6 +182,12 @@ compile + + com.alibaba + easyexcel + 3.1.1 + + diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/config/MybatisPlusConfig.java b/ccic-exam/src/main/java/com/ccic/safeliab/config/MybatisPlusConfig.java new file mode 100644 index 0000000..c85b6b1 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/config/MybatisPlusConfig.java @@ -0,0 +1,20 @@ +package com.ccic.safeliab.config; + +import com.baomidou.mybatisplus.core.injector.ISqlInjector; +import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MybatisPlusConfig { + + /** + * 注册 LogicSqlInjector 来支持逻辑删除功能 + * 只有在 MyBatis-Plus 版本低于 3.2.0 时需要添加该配置。 + * @return + */ + @Bean + public ISqlInjector sqlInjector(){ + return new LogicSqlInjector(); + } +} \ No newline at end of file diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/dao/AnswersMapper.java b/ccic-exam/src/main/java/com/ccic/safeliab/dao/AnswersMapper.java new file mode 100644 index 0000000..c8ee2e4 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/dao/AnswersMapper.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ccic.safeliab.entity.ExAnswers; +import org.apache.ibatis.annotations.Mapper; + +/** + * Mapper 接口 + * + * @author edwong + */ +@Mapper +public interface AnswersMapper extends BaseMapper { + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamInfoMapper.java b/ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamInfoMapper.java new file mode 100644 index 0000000..730ebb4 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamInfoMapper.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ccic.safeliab.entity.ExExamInfo; +import org.apache.ibatis.annotations.Mapper; + +/** + * Mapper 接口 + * + * @author edwong + */ +@Mapper +public interface ExamInfoMapper extends BaseMapper { + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamScouresMapper.java b/ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamScouresMapper.java new file mode 100644 index 0000000..dc3111a --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamScouresMapper.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ccic.safeliab.entity.ExExamScoures; +import org.apache.ibatis.annotations.Mapper; + +/** + * Mapper 接口 + * + * @author edwong + */ +@Mapper +public interface ExamScouresMapper extends BaseMapper { + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/dao/OpenUserMapper.java b/ccic-exam/src/main/java/com/ccic/safeliab/dao/OpenUserMapper.java new file mode 100644 index 0000000..40be5a9 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/dao/OpenUserMapper.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.ccic.safeliab.entity.ExOpenUser; +import org.apache.ibatis.annotations.Mapper; + +/** + * Mapper 接口 + * + * @author edwong + */ +@Mapper +public interface OpenUserMapper extends BaseMapper { + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java b/ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java index d853c09..cfba572 100644 --- a/ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java +++ b/ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ccic.safeliab.entity.ExDict; import com.ccic.safeliab.entity.Industry; import com.ccic.safeliab.entity.QuestionCategories; +import com.ccic.safeliab.vo.PageQuestionCategoriesVO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -66,4 +67,11 @@ public interface QuestionMapper extends BaseMapper { * @return 题目详情 */ QuestionCategories getDetail(@Param("id") Long id); + + /** + * 根据试卷id获取题目集合 + * @param id + * @return + */ + List getListByPaperId(@Param("paperId") Long id); } diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/dao/ServiceStatMapper.java b/ccic-exam/src/main/java/com/ccic/safeliab/dao/ServiceStatMapper.java new file mode 100644 index 0000000..148d755 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/dao/ServiceStatMapper.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.dao; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.ccic.safeliab.excel.ServiceStatExcel; +import com.ccic.safeliab.vo.ServiceStatVO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Mapper 接口 + * + * @author edwong + */ +@Mapper +public interface ServiceStatMapper { + + List selectPage(IPage page, @Param("policy") ServiceStatVO serviceStatVO); + + List selectExport(@Param("policy") ServiceStatVO serviceStatVO); +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/excel/ServiceStatExcel.java b/ccic-exam/src/main/java/com/ccic/safeliab/excel/ServiceStatExcel.java new file mode 100644 index 0000000..2acad30 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/excel/ServiceStatExcel.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.excel; + +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.alibaba.excel.annotation.write.style.ContentRowHeight; +import com.alibaba.excel.annotation.write.style.HeadRowHeight; +import lombok.Data; + +import java.io.Serializable; + +/** + * model 保单服务统计 + * + * @author edwong + */ +@Data +@ColumnWidth(25) +@HeadRowHeight(20) +@ContentRowHeight(18) +public class ServiceStatExcel implements Serializable { + private static final long serialVersionUID = 1L; + + @ColumnWidth(23) + @ExcelProperty("保单号") + private String policyNumber; + + @ColumnWidth(40) + @ExcelProperty("归属机构") + private String insuranceName; + + @ColumnWidth(23) + @ExcelProperty("事故预防状态") + private String serviceStatusName; + + @ColumnWidth(20) + @ExcelProperty("备注") + private String remarks; + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersService.java b/ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersService.java new file mode 100644 index 0000000..0f76202 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersService.java @@ -0,0 +1,13 @@ +package com.ccic.safeliab.service; + +import com.ccic.safeliab.entity.ExAnswers; +import com.ccic.safeliab.support.BaseService; + +/** + * 服务类 + * + * @author edwong + */ +public interface AnswersService extends BaseService { + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersServiceImpl.java b/ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersServiceImpl.java new file mode 100644 index 0000000..30aad6d --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersServiceImpl.java @@ -0,0 +1,16 @@ +package com.ccic.safeliab.service; + +import com.ccic.safeliab.dao.AnswersMapper; +import com.ccic.safeliab.entity.ExAnswers; +import com.ccic.safeliab.support.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * 服务实现类 + * + * @author edwong + */ +@Service +public class AnswersServiceImpl extends BaseServiceImpl implements AnswersService { + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/service/ExamService.java b/ccic-exam/src/main/java/com/ccic/safeliab/service/ExamService.java new file mode 100644 index 0000000..ad00d4a --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/service/ExamService.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.service; + +import com.ccic.safeliab.util.R; +import com.ccic.safeliab.vo.UserAnswersVO; + +/** + * 服务类 + * + * @author edwong + */ +public interface ExamService { + + R findExamPageData(Long examId); + + R saveUserAnswers(UserAnswersVO userAnswersVO); + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/service/ExamServiceImpl.java b/ccic-exam/src/main/java/com/ccic/safeliab/service/ExamServiceImpl.java new file mode 100644 index 0000000..8462cc8 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/service/ExamServiceImpl.java @@ -0,0 +1,136 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.service; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.ccic.safeliab.dao.AnswersMapper; +import com.ccic.safeliab.dao.ExamInfoMapper; +import com.ccic.safeliab.dao.ExamScouresMapper; +import com.ccic.safeliab.dao.QuestionMapper; +import com.ccic.safeliab.entity.ExAnswers; +import com.ccic.safeliab.entity.ExExamInfo; +import com.ccic.safeliab.entity.ExExamScoures; +import com.ccic.safeliab.entity.ExamPapers; +import com.ccic.safeliab.vo.ExamPageDataVO; +import com.ccic.safeliab.vo.PageQuestionCategoriesVO; +import com.ccic.safeliab.vo.UserAnswersVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import com.ccic.safeliab.util.R; + + +/** + * 服务实现类 + * + * @author edwong + */ +@Slf4j +@Service +public class ExamServiceImpl implements ExamService { + + @Autowired + private ExamInfoMapper examInfoMapper; + + @Autowired + private QuestionMapper questionCategoriesMapper; + + @Autowired + private AnswersService answersService; + + @Autowired + private ExamScouresMapper examScouresMapper; + + @Autowired + private ExamPaperService paperService; + + @Override + public R findExamPageData(Long examId) { + QueryWrapper examScouresWrapper = new QueryWrapper<>(); + examScouresWrapper.lambda().eq(ExExamInfo::getId, examId); + examScouresWrapper.lambda().eq(ExExamInfo::getPublishStatus, 1);// 已发布 + ExExamInfo examInfo = examInfoMapper.selectOne(examScouresWrapper); + if (examInfo == null) { + log.error("获取考试信息失败,examId: {}", examId); + return R.error().message("获取考试信息失败"); + } + + ExamPapers examPapers = paperService.getById(examInfo.getPaperId()); + if (examPapers == null) { + log.error("获取试卷信息失败,examId: {}", examInfo.getPaperId()); + return R.error().message("获取试卷信息失败"); + } + + List pageQuestionCategoriesList = questionCategoriesMapper.getListByPaperId(examInfo.getPaperId()); + if (pageQuestionCategoriesList == null || pageQuestionCategoriesList.size() == 0) { + log.error("获取试卷关联数据失败,paperId: {}", examInfo.getPaperId()); + return R.error().message("获取试卷关联数据失败"); + } + + ExamPageDataVO examPageDataVO = new ExamPageDataVO(); + examPageDataVO.setExamId(examInfo.getId()); + examPageDataVO.setExamName(examInfo.getExamName()); + examPageDataVO.setPaperId(examInfo.getPaperId()); + examPageDataVO.setPaperName(examPapers.getPaperName()); + examPageDataVO.setTotalScore(examPapers.getTotalScore()); + examPageDataVO.setExamDuration(examPapers.getExamDuration()); + examPageDataVO.setPaperContent(examPapers.getPaperContent()); + examPageDataVO.setQuestionCategoriesList(pageQuestionCategoriesList); + return R.ok().data(examPageDataVO); + } + + @Override + public R saveUserAnswers(UserAnswersVO userAnswersVO) { + QueryWrapper answersQueryWrapper = new QueryWrapper<>(); + answersQueryWrapper.lambda().eq(ExAnswers::getUserId, userAnswersVO.getUserId()); + answersQueryWrapper.lambda().eq(ExAnswers::getExamId, userAnswersVO.getExamId()); + Integer selectCount = answersService.count(answersQueryWrapper); + if (selectCount > 0) { + answersService.remove(answersQueryWrapper);// 清空历史做题 + } + Integer totalScore = 0; + List answersList = userAnswersVO.getAnswerList(); + if (answersList != null && answersList.size() > 0) { + for (ExAnswers exAnswers: answersList) { + if (exAnswers.getIsCorrect() == 1) { + totalScore ++; + } + exAnswers.setUserId(userAnswersVO.getUserId()); + exAnswers.setExamId(userAnswersVO.getExamId()); + } + } + answersService.saveBatch(answersList); + QueryWrapper examScouresQueryWrapper = new QueryWrapper<>(); + examScouresQueryWrapper.lambda().eq(ExExamScoures::getUserId, userAnswersVO.getUserId()); + examScouresQueryWrapper.lambda().eq(ExExamScoures::getExamId, userAnswersVO.getExamId()); + examScouresQueryWrapper.lambda().eq(ExExamScoures::getPaperId, userAnswersVO.getPaperId()); + Integer examScouresCount = examScouresMapper.selectCount(examScouresQueryWrapper); + if (examScouresCount > 0) { + examScouresMapper.delete(examScouresQueryWrapper);// 清空历史记录 + } + ExExamScoures examScoures = new ExExamScoures(); + examScoures.setUserId(userAnswersVO.getUserId()); + examScoures.setPaperId(userAnswersVO.getPaperId()); + examScoures.setExamId(userAnswersVO.getExamId()); + examScoures.setTotalScore(totalScore); + examScoures.setExamTimeSpent(userAnswersVO.getExamTimeSpent()); + examScouresMapper.insert(examScoures); + return R.ok().data(true); + } + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsService.java b/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsService.java index 4c3d413..96e60db 100644 --- a/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsService.java +++ b/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsService.java @@ -15,11 +15,14 @@ */ package com.ccic.safeliab.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ccic.safeliab.entity.Customer; +import com.ccic.safeliab.excel.ServiceStatExcel; import com.ccic.safeliab.vo.CustomerVO; +import com.ccic.safeliab.vo.ServiceStatVO; -import java.util.Map; +import java.util.List; /** @@ -30,4 +33,8 @@ import java.util.Map; public interface StatisticsService { Page findPage(CustomerVO customer, int page, int num); + + IPage findServiceStatPage(ServiceStatVO serviceStatVO, int page, int num); + + List findServiceStatAll(ServiceStatVO serviceStatVO); } diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsServiceImpl.java b/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsServiceImpl.java index 954c5c5..3333dc3 100644 --- a/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsServiceImpl.java +++ b/ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsServiceImpl.java @@ -16,17 +16,23 @@ package com.ccic.safeliab.service; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ccic.safeliab.dao.ServiceStatMapper; import com.ccic.safeliab.entity.Customer; import com.ccic.safeliab.entity.Device; import com.ccic.safeliab.entity.User; +import com.ccic.safeliab.excel.ServiceStatExcel; import com.ccic.safeliab.support.Condition; import com.ccic.safeliab.util.CcicUtill; +import com.ccic.safeliab.vo.CustomerRetentionVO; import com.ccic.safeliab.vo.CustomerVO; +import com.ccic.safeliab.vo.ServiceStatVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; +import java.util.List; import java.util.Map; @@ -40,6 +46,8 @@ public class StatisticsServiceImpl implements StatisticsService { @Autowired private ICustomerService customerService; + @Autowired + private ServiceStatMapper serviceStatMapper; @Override public Page findPage(CustomerVO customer, int page, int num) { @@ -65,4 +73,17 @@ public class StatisticsServiceImpl implements StatisticsService { return iPage; } + + @Override + public IPage findServiceStatPage(ServiceStatVO serviceStatVO, int page, int num) { + IPage iPage = new Page<>(page, num); + iPage.setRecords(serviceStatMapper.selectPage(iPage, serviceStatVO)); + return iPage; + } + + @Override + public List findServiceStatAll(ServiceStatVO serviceStatVO) { + return serviceStatMapper.selectExport(serviceStatVO); + } + } diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/support/BaseServiceImpl.java b/ccic-exam/src/main/java/com/ccic/safeliab/support/BaseServiceImpl.java index 0bc3bd3..1871e39 100644 --- a/ccic-exam/src/main/java/com/ccic/safeliab/support/BaseServiceImpl.java +++ b/ccic-exam/src/main/java/com/ccic/safeliab/support/BaseServiceImpl.java @@ -1,12 +1,14 @@ package com.ccic.safeliab.support; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ccic.safeliab.entity.BaseEntity; import com.ccic.safeliab.entity.Customer; import org.springframework.validation.annotation.Validated; +import java.util.Collection; import java.util.Date; import java.util.List; @@ -45,6 +47,7 @@ public class BaseServiceImpl, T extends BaseEntity> exte } public boolean deleteLogic(List ids) { - return super.removeByIds(ids); + return baseMapper.deleteBatchIds(ids) > 0; } + } diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/vo/CustomerRetentionVO.java b/ccic-exam/src/main/java/com/ccic/safeliab/vo/CustomerRetentionVO.java index 367be37..ebce3f1 100644 --- a/ccic-exam/src/main/java/com/ccic/safeliab/vo/CustomerRetentionVO.java +++ b/ccic-exam/src/main/java/com/ccic/safeliab/vo/CustomerRetentionVO.java @@ -1,16 +1,18 @@ package com.ccic.safeliab.vo; import com.ccic.safeliab.entity.ExCustomerRetention; +import com.fasterxml.jackson.annotation.JsonInclude; import lombok.Data; /** *

- * 客户留存表 + * 客户留存视图 *

* * @author edwong */ @Data +@JsonInclude(JsonInclude.Include.NON_NULL) public class CustomerRetentionVO extends ExCustomerRetention { private String fileUid; diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/vo/ExamPageDataVO.java b/ccic-exam/src/main/java/com/ccic/safeliab/vo/ExamPageDataVO.java new file mode 100644 index 0000000..04e69af --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/vo/ExamPageDataVO.java @@ -0,0 +1,59 @@ +package com.ccic.safeliab.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.List; + +@Data +public class ExamPageDataVO { + + /** + * 试卷id + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long examId; + + /** + * 考试名称 + */ + private String examName; + + /** + * 试卷id + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long paperId; + + /** + * 试卷名称 + */ + private String paperName; + + /** + * 题目数量 + */ + private Integer questionCount; + + /** + * 总分值 + */ + private Integer totalScore; + + /** + * 考试时长 + */ + private Long examDuration; + + /** + * 试卷内容 + */ + private String paperContent; + + /** + * 考卷题目集合 + */ + private List questionCategoriesList; + + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/vo/PageQuestionCategoriesVO.java b/ccic-exam/src/main/java/com/ccic/safeliab/vo/PageQuestionCategoriesVO.java new file mode 100644 index 0000000..52a9540 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/vo/PageQuestionCategoriesVO.java @@ -0,0 +1,23 @@ +package com.ccic.safeliab.vo; + +import com.ccic.safeliab.entity.QuestionCategories; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + *

+ * 试卷题目视图 + *

+ * + * @author edwong + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class PageQuestionCategoriesVO extends QuestionCategories { + + /** + * 题目编号 + */ + private String questionNumber; +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/vo/ServiceStatVO.java b/ccic-exam/src/main/java/com/ccic/safeliab/vo/ServiceStatVO.java new file mode 100644 index 0000000..bb5ac7c --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/vo/ServiceStatVO.java @@ -0,0 +1,64 @@ +package com.ccic.safeliab.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +/** + *

+ * 服务统计视图 + *

+ * + * @author edwong + */ +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ServiceStatVO { + + /** + * 保单id + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long policyId; + + /** + * 保单号 + */ + private String policyNumber; + + /** + * 归属机构 + */ + private String insuranceName; + + /** + * 备注 + */ + private String remarks; + + /** + * 事故预防状态 + */ + private Integer serviceStatus; + + /** + * 事故预防状态名称 + */ + private String serviceStatusName; + + /** + * 开始时间 + */ + private String startDate; + + /** + * 结束时间 + */ + private String doneDate; + + /** + * 日期过滤 + */ + private String dateFilter; + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/vo/UserAnswersVO.java b/ccic-exam/src/main/java/com/ccic/safeliab/vo/UserAnswersVO.java new file mode 100644 index 0000000..ea3ed36 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/vo/UserAnswersVO.java @@ -0,0 +1,39 @@ +package com.ccic.safeliab.vo; + +import com.ccic.safeliab.entity.ExAnswers; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.List; + +@Data +public class UserAnswersVO { + + /** + * 用户id + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long userId; + + /** + * 试卷id + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long examId; + + /** + * 试卷id + */ + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long paperId; + + /** + * 答题记录表 + */ + private List answerList; + + /** + * 考试用时 + */ + private Integer examTimeSpent; +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/web/ExamController.java b/ccic-exam/src/main/java/com/ccic/safeliab/web/ExamController.java new file mode 100644 index 0000000..fd05157 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/web/ExamController.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.web; + +import com.ccic.safeliab.service.ExamService; +import com.ccic.safeliab.service.QuestionService; +import com.ccic.safeliab.util.R; +import com.ccic.safeliab.vo.UserAnswersVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + + +/** + * 控制器 + * + * @author edwong + */ +@RestController +@RequestMapping("/ex/exam") +public class ExamController { + + + @Autowired + private ExamService examService; + + @Autowired + private QuestionService questionService; + + /** + * 获取考试与试卷信息 + * @param examId + * @return + */ + @GetMapping("/findExamPageData") + public R findExamPageData(Long examId) { + return examService.findExamPageData(examId); + } + + /** + * 保存用户考试记录 + * @param userAnswersVO + * @return + */ + @PostMapping("/submitUserAnswers") + public R submitUserAnswers(@RequestBody UserAnswersVO userAnswersVO) { + return examService.saveUserAnswers(userAnswersVO); + } + + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/web/OpenUserController.java b/ccic-exam/src/main/java/com/ccic/safeliab/web/OpenUserController.java new file mode 100644 index 0000000..08cef63 --- /dev/null +++ b/ccic-exam/src/main/java/com/ccic/safeliab/web/OpenUserController.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com). + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.ccic.safeliab.web; + +import org.springframework.web.bind.annotation.*; + + +/** + * 控制器 + * + * @author edwong + */ +@RestController +@RequestMapping("/ex/openUser") +public class OpenUserController { + + +} diff --git a/ccic-exam/src/main/java/com/ccic/safeliab/web/StatisticsController.java b/ccic-exam/src/main/java/com/ccic/safeliab/web/StatisticsController.java index b6f8f09..0f70c6d 100644 --- a/ccic-exam/src/main/java/com/ccic/safeliab/web/StatisticsController.java +++ b/ccic-exam/src/main/java/com/ccic/safeliab/web/StatisticsController.java @@ -1,21 +1,31 @@ package com.ccic.safeliab.web; +import com.alibaba.excel.EasyExcel; import com.ccic.safeliab.entity.ExCustomerRetention; +import com.ccic.safeliab.excel.ServiceStatExcel; import com.ccic.safeliab.service.CustomerRetService; import com.ccic.safeliab.service.StatisticsService; import com.ccic.safeliab.util.R; import com.ccic.safeliab.vo.CustomerRetentionVO; import com.ccic.safeliab.vo.CustomerVO; +import com.ccic.safeliab.vo.ServiceStatVO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.Charsets; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.net.URLEncoder; import java.util.Date; +import java.util.List; /** * 客户统计控制器 * * @author edwong */ +@Slf4j @RestController @RequestMapping("/ex/statistics") public class StatisticsController { @@ -27,23 +37,25 @@ public class StatisticsController { /** * 分页 客户列表(统计动态看板) + * * @param customer * @return */ @PostMapping("/page") public R page(@RequestBody CustomerVO customer, - @RequestParam int page,@RequestParam int num) { + @RequestParam int page, @RequestParam int num) { return R.ok().dataPage(statisticsService.findPage(customer, page, num)); } /** * 分页 客户留存 + * * @param customerRetention * @return */ @PostMapping("/customerRetPage") public R customerRetPage(@RequestBody CustomerRetentionVO customerRetention, - @RequestParam int page,@RequestParam int num) { + @RequestParam int page, @RequestParam int num) { return R.ok().data(customerRetService.findPage(customerRetention, page, num)); } @@ -56,5 +68,32 @@ public class StatisticsController { return R.ok().data(customerRetService.save(customerRetention)); } + /** + * 分页 保单服务统计 + * + * @param serviceStatVO + * @return + */ + @PostMapping("/serviceStatPage") + public R serviceStatPage(@RequestBody ServiceStatVO serviceStatVO, + @RequestParam int page, @RequestParam int num) { + return R.ok().data(statisticsService.findServiceStatPage(serviceStatVO, page, num)); + } + /** + * 导出 保单服务统计 + */ + @GetMapping("exportServiceStatList") + public void exportServiceStatList(ServiceStatVO serviceStatVO, HttpServletResponse response) { + List list = statisticsService.findServiceStatAll(serviceStatVO); + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding(Charsets.UTF_8.name()); + try { + String fileName = URLEncoder.encode("服务统计导出", Charsets.UTF_8.name()); + response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); + EasyExcel.write(response.getOutputStream(), ServiceStatExcel.class).sheet("sheet1").doWrite(list); + } catch (IOException e) { + log.error("exportServiceStatList, error message:" + e.getMessage()); + } + } } diff --git a/ccic-exam/src/main/resources/bootstrap.yml b/ccic-exam/src/main/resources/bootstrap.yml index acfd355..48a6ba7 100644 --- a/ccic-exam/src/main/resources/bootstrap.yml +++ b/ccic-exam/src/main/resources/bootstrap.yml @@ -28,6 +28,7 @@ spring: max-wait: -1ms application: name: exam-server +# name: exam-server-hsk profiles: active: dev diff --git a/ccic-exam/src/main/resources/mappers/CustomerRetMapper.xml b/ccic-exam/src/main/resources/mappers/CustomerRetMapper.xml index 3ff9747..b15d8e2 100644 --- a/ccic-exam/src/main/resources/mappers/CustomerRetMapper.xml +++ b/ccic-exam/src/main/resources/mappers/CustomerRetMapper.xml @@ -3,7 +3,7 @@ - + @@ -13,7 +13,7 @@ - SELECT a.id, a.customer_id, diff --git a/ccic-exam/src/main/resources/mappers/QuestionMapper.xml b/ccic-exam/src/main/resources/mappers/QuestionMapper.xml index 7c64868..248c963 100644 --- a/ccic-exam/src/main/resources/mappers/QuestionMapper.xml +++ b/ccic-exam/src/main/resources/mappers/QuestionMapper.xml @@ -17,6 +17,17 @@ + + + + + + + + + + + + diff --git a/ccic-exam/src/main/resources/mappers/ServiceStatMapper.xml b/ccic-exam/src/main/resources/mappers/ServiceStatMapper.xml new file mode 100644 index 0000000..d6f000f --- /dev/null +++ b/ccic-exam/src/main/resources/mappers/ServiceStatMapper.xml @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + SELECT + p.policy_id, + p.policy_number, + p.insurance_name, + p.other_information, + CASE + WHEN p.policy_id IS NOT NULL AND t.service_id IS NULL AND s.service_apply_id IS NULL THEN '保单未分配(在中支节点)' + WHEN t.dispatch_status = 2 THEN '已推送服务机构(待服务机构领取任务)' + WHEN t.status = 1 THEN '任务已分配至XX服务专家(待开展)' + WHEN t.status = 2 THEN '服务专家已签到(事故预防服务中)' + WHEN t.status = 10 THEN '服务报告已上传' + ELSE '-1' + END AS service_status_name + + + + SELECT + p.policy_number, + p.insurance_name, + p.other_information, + CASE + WHEN p.policy_id IS NOT NULL AND t.service_id IS NULL AND s.service_apply_id IS NULL THEN '保单未分配(在中支节点)' + WHEN t.dispatch_status = 2 THEN '已推送服务机构(待服务机构领取任务)' + WHEN t.status = 1 THEN '任务已分配至XX服务专家(待开展)' + WHEN t.status = 2 THEN '服务专家已签到(事故预防服务中)' + WHEN t.status = 10 THEN '服务报告已上传' + ELSE '-1' + END AS service_status_name + + + + FROM + tbl_policy p + LEFT JOIN tbl_service_apply s ON p.policy_id = s.policy_id + LEFT JOIN tbl_service t ON s.service_apply_id = t.service_apply_id + + ((p.policy_id IS NOT NULL + AND t.service_id IS NULL + AND s.service_apply_id IS NULL) + OR t.dispatch_status = 2 + OR t.status IN (1, 2, 10)) + + + AND (p.policy_id IS NOT NULL + AND t.service_id IS NULL + AND s.service_apply_id IS NULL) + + + AND t.dispatch_status = 2 + + + AND t.status = 1 + + + AND t.status = 2 + + + AND t.status = 10 + + + + + AND p.start_date >= CURRENT_TIMESTAMP - INTERVAL '7 days' AND p.done_date <= CURRENT_TIMESTAMP + + + AND p.start_date >= CURRENT_TIMESTAMP - INTERVAL '1 month' AND p.done_date <= CURRENT_TIMESTAMP + + + AND p.start_date >= CURRENT_TIMESTAMP - INTERVAL '3 months' AND p.done_date <= CURRENT_TIMESTAMP + + + + AND p.start_date >= #{policy.startDate} + + + AND p.done_date <= #{policy.doneDate} + + + + + + + + +