统计、小程序代码提交、加入逻辑删除

main
liuyiliang 4 months ago
parent b9a36ce057
commit b1dc1bc080
  1. 59
      ccic-entity/src/main/java/com/ccic/safeliab/entity/ExAnswers.java
  2. 66
      ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamInfo.java
  3. 53
      ccic-entity/src/main/java/com/ccic/safeliab/entity/ExExamScoures.java
  4. 51
      ccic-entity/src/main/java/com/ccic/safeliab/entity/ExOpenUser.java
  5. 6
      ccic-exam/pom.xml
  6. 20
      ccic-exam/src/main/java/com/ccic/safeliab/config/MybatisPlusConfig.java
  7. 30
      ccic-exam/src/main/java/com/ccic/safeliab/dao/AnswersMapper.java
  8. 30
      ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamInfoMapper.java
  9. 30
      ccic-exam/src/main/java/com/ccic/safeliab/dao/ExamScouresMapper.java
  10. 30
      ccic-exam/src/main/java/com/ccic/safeliab/dao/OpenUserMapper.java
  11. 8
      ccic-exam/src/main/java/com/ccic/safeliab/dao/QuestionMapper.java
  12. 37
      ccic-exam/src/main/java/com/ccic/safeliab/dao/ServiceStatMapper.java
  13. 55
      ccic-exam/src/main/java/com/ccic/safeliab/excel/ServiceStatExcel.java
  14. 13
      ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersService.java
  15. 16
      ccic-exam/src/main/java/com/ccic/safeliab/service/AnswersServiceImpl.java
  16. 32
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamService.java
  17. 136
      ccic-exam/src/main/java/com/ccic/safeliab/service/ExamServiceImpl.java
  18. 9
      ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsService.java
  19. 21
      ccic-exam/src/main/java/com/ccic/safeliab/service/StatisticsServiceImpl.java
  20. 5
      ccic-exam/src/main/java/com/ccic/safeliab/support/BaseServiceImpl.java
  21. 4
      ccic-exam/src/main/java/com/ccic/safeliab/vo/CustomerRetentionVO.java
  22. 59
      ccic-exam/src/main/java/com/ccic/safeliab/vo/ExamPageDataVO.java
  23. 23
      ccic-exam/src/main/java/com/ccic/safeliab/vo/PageQuestionCategoriesVO.java
  24. 64
      ccic-exam/src/main/java/com/ccic/safeliab/vo/ServiceStatVO.java
  25. 39
      ccic-exam/src/main/java/com/ccic/safeliab/vo/UserAnswersVO.java
  26. 66
      ccic-exam/src/main/java/com/ccic/safeliab/web/ExamController.java
  27. 31
      ccic-exam/src/main/java/com/ccic/safeliab/web/OpenUserController.java
  28. 43
      ccic-exam/src/main/java/com/ccic/safeliab/web/StatisticsController.java
  29. 1
      ccic-exam/src/main/resources/bootstrap.yml
  30. 4
      ccic-exam/src/main/resources/mappers/CustomerRetMapper.xml
  31. 32
      ccic-exam/src/main/resources/mappers/QuestionMapper.xml
  32. 112
      ccic-exam/src/main/resources/mappers/ServiceStatMapper.xml

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -182,6 +182,12 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.1</version>
</dependency>
</dependencies>

@ -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();
}
}

@ -0,0 +1,30 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ExAnswers> {
}

@ -0,0 +1,30 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ExExamInfo> {
}

@ -0,0 +1,30 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ExExamScoures> {
}

@ -0,0 +1,30 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ExOpenUser> {
}

@ -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<QuestionCategories> {
* @return 题目详情
*/
QuestionCategories getDetail(@Param("id") Long id);
/**
* 根据试卷id获取题目集合
* @param id
* @return
*/
List<PageQuestionCategoriesVO> getListByPaperId(@Param("paperId") Long id);
}

@ -0,0 +1,37 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ServiceStatVO> selectPage(IPage page, @Param("policy") ServiceStatVO serviceStatVO);
List<ServiceStatExcel> selectExport(@Param("policy") ServiceStatVO serviceStatVO);
}

@ -0,0 +1,55 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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;
}

@ -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<ExAnswers> {
}

@ -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<AnswersMapper, ExAnswers> implements AnswersService {
}

@ -0,0 +1,32 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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);
}

@ -0,0 +1,136 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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<ExExamInfo> 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<PageQuestionCategoriesVO> 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<ExAnswers> 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<ExAnswers> 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<ExExamScoures> 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);
}
}

@ -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<Customer> findPage(CustomerVO customer, int page, int num);
IPage<ServiceStatVO> findServiceStatPage(ServiceStatVO serviceStatVO, int page, int num);
List<ServiceStatExcel> findServiceStatAll(ServiceStatVO serviceStatVO);
}

@ -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<Customer> findPage(CustomerVO customer, int page, int num) {
@ -65,4 +73,17 @@ public class StatisticsServiceImpl implements StatisticsService {
return iPage;
}
@Override
public IPage<ServiceStatVO> findServiceStatPage(ServiceStatVO serviceStatVO, int page, int num) {
IPage<ServiceStatVO> iPage = new Page<>(page, num);
iPage.setRecords(serviceStatMapper.selectPage(iPage, serviceStatVO));
return iPage;
}
@Override
public List<ServiceStatExcel> findServiceStatAll(ServiceStatVO serviceStatVO) {
return serviceStatMapper.selectExport(serviceStatVO);
}
}

@ -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<M extends BaseMapper<T>, T extends BaseEntity> exte
}
public boolean deleteLogic(List<Long> ids) {
return super.removeByIds(ids);
return baseMapper.deleteBatchIds(ids) > 0;
}
}

@ -1,16 +1,18 @@
package com.ccic.safeliab.vo;
import com.ccic.safeliab.entity.ExCustomerRetention;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* <p>
* 客户留存
* 客户留存视图
* </p>
*
* @author edwong
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CustomerRetentionVO extends ExCustomerRetention {
private String fileUid;

@ -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<PageQuestionCategoriesVO> questionCategoriesList;
}

@ -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;
/**
* <p>
* 试卷题目视图
* </p>
*
* @author edwong
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PageQuestionCategoriesVO extends QuestionCategories {
/**
* 题目编号
*/
private String questionNumber;
}

@ -0,0 +1,64 @@
package com.ccic.safeliab.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* <p>
* 服务统计视图
* </p>
*
* @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;
}

@ -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<ExAnswers> answerList;
/**
* 考试用时
*/
private Integer examTimeSpent;
}

@ -0,0 +1,66 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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);
}
}

@ -0,0 +1,31 @@
/**
* Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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 {
}

@ -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<ServiceStatExcel> 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());
}
}
}

@ -28,6 +28,7 @@ spring:
max-wait: -1ms
application:
name: exam-server
# name: exam-server-hsk
profiles:
active: dev

@ -3,7 +3,7 @@
<mapper namespace="com.ccic.safeliab.dao.CustomerRetMapper">
<!-- 通用查询映射结果 -->
<resultMap id="dictResultMap" type="com.ccic.safeliab.vo.CustomerRetentionVO">
<resultMap id="retResultMap" type="com.ccic.safeliab.vo.CustomerRetentionVO">
<id column="id" property="id"/>
<result column="customer_id" property="customerId"/>
<result column="description" property="description"/>
@ -13,7 +13,7 @@
<result column="file_uid" property="fileUid"/>
</resultMap>
<select id="selectCustomerRetPage" resultMap="dictResultMap">
<select id="selectCustomerRetPage" resultMap="retResultMap">
SELECT
a.id,
a.customer_id,

@ -17,6 +17,17 @@
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
</resultMap>
<resultMap id="PaperQuestionCategoriesMap" type="com.ccic.safeliab.vo.PageQuestionCategoriesVO">
<id column="id" property="id"/>
<result column="question_types" property="questionTypes"/>
<result column="industry_id" property="industryId"/>
<result column="service_type_id" property="serviceTypeId"/>
<result column="question_content" property="questionContent"/>
<result column="answer" property="answer"/>
<result column="options" property="options"/>
<result column="status" property="status"/>
<result column="question_number" property="questionNumber"/>
</resultMap>
<select id="getList" resultMap="QuestionCategoriesResultMap">
SELECT
id,
@ -87,4 +98,25 @@
</if>
</where>
</select>
<select id="getListByPaperId" resultMap="PaperQuestionCategoriesMap">
SELECT
a.id,
a.question_types,
a.industry_id,
a.service_type_id,
a.question_content,
a.answer,
a.options,
a.status,
b.question_number
FROM ex_question_categories a
LEFT JOIN ex_paper_questions b ON b.question_id = a.id AND b.is_deleted = '0'
<where>
a.is_deleted = '0'
<if test="paperId!= null and paperId!= ''">
AND b.paper_id = #{paperId}
</if>
</where>
ORDER BY b.question_number asc
</select>
</mapper>

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccic.safeliab.dao.ServiceStatMapper">
<!-- 通用查询映射结果 -->
<resultMap id="statResultMap" type="com.ccic.safeliab.vo.ServiceStatVO">
<id column="policy_id" property="policyId"/>
<result column="policy_number" property="policyNumber"/>
<result column="insurance_name" property="insuranceName"/>
<result column="other_information" property="remarks"/>
<result column="service_status_name" property="serviceStatusName"/>
</resultMap>
<resultMap id="exportResultMap" type="com.ccic.safeliab.excel.ServiceStatExcel">
<result column="policy_number" property="policyNumber"/>
<result column="insurance_name" property="insuranceName"/>
<result column="other_information" property="remarks"/>
<result column="service_status_name" property="serviceStatusName"/>
</resultMap>
<sql id="selectPageColumn">
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
</sql>
<sql id="selectExportColumn">
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
</sql>
<sql id="baseQuery">
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
<where>
((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))
<if test="policy.serviceStatus != null and policy.serviceStatus != ''">
<if test="policy.serviceStatus == 1">
AND (p.policy_id IS NOT NULL
AND t.service_id IS NULL
AND s.service_apply_id IS NULL)
</if>
<if test="policy.serviceStatus == 2">
AND t.dispatch_status = 2
</if>
<if test="policy.serviceStatus == 3">
AND t.status = 1
</if>
<if test="policy.serviceStatus == 4">
AND t.status = 2
</if>
<if test="policy.serviceStatus == 5">
AND t.status = 10
</if>
</if>
<if test="policy.dateFilter != null and policy.dateFilter != ''">
<if test="policy.dateFilter == 'lastWeek'">
AND p.start_date &gt;= CURRENT_TIMESTAMP - INTERVAL '7 days' AND p.done_date &lt;= CURRENT_TIMESTAMP
</if>
<if test="policy.dateFilter == 'lastMonth'">
AND p.start_date &gt;= CURRENT_TIMESTAMP - INTERVAL '1 month' AND p.done_date &lt;= CURRENT_TIMESTAMP
</if>
<if test="policy.dateFilter == 'last3Months'">
AND p.start_date &gt;= CURRENT_TIMESTAMP - INTERVAL '3 months' AND p.done_date &lt;= CURRENT_TIMESTAMP
</if>
</if>
<if test="policy.startDate != null and policy.startDate != ''">
AND p.start_date &gt;= #{policy.startDate}
</if>
<if test="policy.doneDate != null and policy.doneDate != ''">
AND p.done_date &lt;= #{policy.doneDate}
</if>
</where>
</sql>
<select id="selectPage" resultMap="statResultMap">
<include refid="selectPageColumn" />
<include refid="baseQuery" />
</select>
<select id="selectExport" resultMap="exportResultMap">
<include refid="selectExportColumn" />
<include refid="baseQuery" />
</select>
</mapper>
Loading…
Cancel
Save