Browse Source

20210128导入试题和试题的类型

recovery
zy_Java 5 years ago
parent
commit
330c724025
  1. 60
      tcm/src/main/java/com/ccsens/tcm/api/ImportController.java
  2. 12
      tcm/src/main/java/com/ccsens/tcm/bean/po/Question.java
  3. 58
      tcm/src/main/java/com/ccsens/tcm/bean/po/QuestionExample.java
  4. 19
      tcm/src/main/java/com/ccsens/tcm/persist/dao/QuestionDao.java
  5. 19
      tcm/src/main/java/com/ccsens/tcm/persist/dao/QuestionOptionDao.java
  6. 19
      tcm/src/main/java/com/ccsens/tcm/persist/dao/ReportCodeDao.java
  7. 21
      tcm/src/main/java/com/ccsens/tcm/service/IImportService.java
  8. 223
      tcm/src/main/java/com/ccsens/tcm/service/ImportService.java
  9. 56
      tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java
  10. 4
      tcm/src/main/resources/application-dev.yml
  11. 31
      tcm/src/main/resources/mapper_dao/QuestionDao.xml
  12. 26
      tcm/src/main/resources/mapper_dao/QuestionOptionDao.xml
  13. 32
      tcm/src/main/resources/mapper_dao/ReportCodeDao.xml
  14. 28
      tcm/src/main/resources/mapper_raw/QuestionMapper.xml

60
tcm/src/main/java/com/ccsens/tcm/api/ImportController.java

@ -0,0 +1,60 @@
package com.ccsens.tcm.api;
import com.ccsens.tcm.service.IImportService;
import com.ccsens.tcm.uitl.Constant;
import com.ccsens.util.JsonResponse;
import com.ccsens.util.PropUtil;
import com.ccsens.util.UploadFileUtil_Servlet3;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.Part;
import java.io.File;
/**
* @author
*/
@Slf4j
@Api(tags = "试题相关接口")
@RestController
@RequestMapping("/import")
public class ImportController {
@Resource
private IImportService importService;
@ApiOperation(value = "导入试题类型",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx")
@ApiImplicitParams({})
@RequestMapping(value = "/code", method = RequestMethod.POST)
public JsonResponse importCode(@RequestParam(required = true) Part file) throws Exception{
//1.上传文件
String allowedExts = "xls,xlsx";
String dir = PropUtil.path;
String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir);
File excelFile = new File(dir+path);
importService.importReport(excelFile);
log.info("导入试题类型成功");
return JsonResponse.newInstance().ok();
}
@ApiOperation(value = "导入病史相关",notes = "文件大小不能超过20M,支持后缀:.xls|.xlsx")
@ApiImplicitParams({})
@RequestMapping(value = "/BSXG", method = RequestMethod.POST)
public JsonResponse importBsxg(@RequestParam(required = true) Part file) throws Exception{
//1.上传文件
String allowedExts = "xls,xlsx";
String dir = PropUtil.path;
String path = UploadFileUtil_Servlet3.uploadFile(file, allowedExts, dir);
File excelFile = new File(dir+path);
importService.importBsxg(excelFile, Constant.Report.CODE_BSXG);
log.info("导入病史相关成功");
return JsonResponse.newInstance().ok();
}
}

12
tcm/src/main/java/com/ccsens/tcm/bean/po/Question.java

@ -8,7 +8,7 @@ public class Question implements Serializable {
private String question;
private Long codeId;
private String code;
private Integer sort;
@ -48,12 +48,12 @@ public class Question implements Serializable {
this.question = question == null ? null : question.trim();
}
public Long getCodeId() {
return codeId;
public String getCode() {
return code;
}
public void setCodeId(Long codeId) {
this.codeId = codeId;
public void setCode(String code) {
this.code = code == null ? null : code.trim();
}
public Integer getSort() {
@ -144,7 +144,7 @@ public class Question implements Serializable {
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", question=").append(question);
sb.append(", codeId=").append(codeId);
sb.append(", code=").append(code);
sb.append(", sort=").append(sort);
sb.append(", units=").append(units);
sb.append(", type=").append(type);

58
tcm/src/main/java/com/ccsens/tcm/bean/po/QuestionExample.java

@ -235,63 +235,73 @@ public class QuestionExample {
return (Criteria) this;
}
public Criteria andCodeIdIsNull() {
addCriterion("code_id is null");
public Criteria andCodeIsNull() {
addCriterion("code is null");
return (Criteria) this;
}
public Criteria andCodeIdIsNotNull() {
addCriterion("code_id is not null");
public Criteria andCodeIsNotNull() {
addCriterion("code is not null");
return (Criteria) this;
}
public Criteria andCodeIdEqualTo(Long value) {
addCriterion("code_id =", value, "codeId");
public Criteria andCodeEqualTo(String value) {
addCriterion("code =", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdNotEqualTo(Long value) {
addCriterion("code_id <>", value, "codeId");
public Criteria andCodeNotEqualTo(String value) {
addCriterion("code <>", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdGreaterThan(Long value) {
addCriterion("code_id >", value, "codeId");
public Criteria andCodeGreaterThan(String value) {
addCriterion("code >", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdGreaterThanOrEqualTo(Long value) {
addCriterion("code_id >=", value, "codeId");
public Criteria andCodeGreaterThanOrEqualTo(String value) {
addCriterion("code >=", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdLessThan(Long value) {
addCriterion("code_id <", value, "codeId");
public Criteria andCodeLessThan(String value) {
addCriterion("code <", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdLessThanOrEqualTo(Long value) {
addCriterion("code_id <=", value, "codeId");
public Criteria andCodeLessThanOrEqualTo(String value) {
addCriterion("code <=", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdIn(List<Long> values) {
addCriterion("code_id in", values, "codeId");
public Criteria andCodeLike(String value) {
addCriterion("code like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdNotIn(List<Long> values) {
addCriterion("code_id not in", values, "codeId");
public Criteria andCodeNotLike(String value) {
addCriterion("code not like", value, "code");
return (Criteria) this;
}
public Criteria andCodeIdBetween(Long value1, Long value2) {
addCriterion("code_id between", value1, value2, "codeId");
public Criteria andCodeIn(List<String> values) {
addCriterion("code in", values, "code");
return (Criteria) this;
}
public Criteria andCodeIdNotBetween(Long value1, Long value2) {
addCriterion("code_id not between", value1, value2, "codeId");
public Criteria andCodeNotIn(List<String> values) {
addCriterion("code not in", values, "code");
return (Criteria) this;
}
public Criteria andCodeBetween(String value1, String value2) {
addCriterion("code between", value1, value2, "code");
return (Criteria) this;
}
public Criteria andCodeNotBetween(String value1, String value2) {
addCriterion("code not between", value1, value2, "code");
return (Criteria) this;
}

19
tcm/src/main/java/com/ccsens/tcm/persist/dao/QuestionDao.java

@ -0,0 +1,19 @@
package com.ccsens.tcm.persist.dao;
import com.ccsens.tcm.bean.po.Question;
import com.ccsens.tcm.persist.mapper.QuestionMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author
*/
@Repository
public interface QuestionDao extends QuestionMapper {
/**
* 批量添加题目
* @param questionList 读取的题目
*/
void insertBatch(List<Question> questionList);
}

19
tcm/src/main/java/com/ccsens/tcm/persist/dao/QuestionOptionDao.java

@ -0,0 +1,19 @@
package com.ccsens.tcm.persist.dao;
import com.ccsens.tcm.bean.po.QuestionOption;
import com.ccsens.tcm.persist.mapper.QuestionOptionMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author
*/
@Repository
public interface QuestionOptionDao extends QuestionOptionMapper {
/**
* 批量添加题目选项
* @param optionList 选项
*/
void insertBatch(List<QuestionOption> optionList);
}

19
tcm/src/main/java/com/ccsens/tcm/persist/dao/ReportCodeDao.java

@ -0,0 +1,19 @@
package com.ccsens.tcm.persist.dao;
import com.ccsens.tcm.bean.po.ReportCode;
import com.ccsens.tcm.persist.mapper.ReportCodeMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author
*/
@Repository
public interface ReportCodeDao extends ReportCodeMapper {
/**
* 批量添加测试类型
* @param reportList 从表里读取的类型对象数组
*/
void insertBatch(List<ReportCode> reportList);
}

21
tcm/src/main/java/com/ccsens/tcm/service/IImportService.java

@ -0,0 +1,21 @@
package com.ccsens.tcm.service;
import java.io.File;
/**
* @author
*/
public interface IImportService {
/**
* 导入测试的类型
* @param excelFile excel文件
*/
void importReport(File excelFile) throws Exception;
/**
* 导入病史相关试题
* @param excelFile excel文件
* @param codeBsxg sheet名
*/
void importBsxg(File excelFile, String codeBsxg) throws Exception;
}

223
tcm/src/main/java/com/ccsens/tcm/service/ImportService.java

@ -0,0 +1,223 @@
package com.ccsens.tcm.service;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.ccsens.tcm.bean.po.*;
import com.ccsens.tcm.persist.dao.QuestionDao;
import com.ccsens.tcm.persist.dao.QuestionOptionDao;
import com.ccsens.tcm.persist.dao.ReportCodeDao;
import com.ccsens.tcm.uitl.Constant;
import com.ccsens.util.PoiUtil;
import com.ccsens.util.PropUtil;
import com.ccsens.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.io.File;
import java.util.*;
/**
* @author
*/
@Slf4j
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class ImportService implements IImportService {
@Resource
private ReportCodeDao reportCodeDao;
@Resource
private Snowflake snowflake;
@Resource
private QuestionDao questionDao;
@Resource
private QuestionOptionDao questionOptionDao;
@Override
public void importReport(File excelFile) throws Exception {
List<Object[]> reports = PoiUtil.readExce(excelFile, 0, null,1, false);
log.info("读取数据完成");
List<ReportCode> reportList = new ArrayList<>();
for (Object[] objs: reports) {
if (!(objs != null && objs.length >= 2 && !StringUtils.isEmpty(objs[0]) && !StringUtils.isEmpty(objs[1]))) {
log.info("测评报告单数据不足,跳转下一行");
continue;
}
ReportCode report = initReport(objs);
reportList.add(report);
}
if (!reportList.isEmpty()) {
reportCodeDao.insertBatch(reportList);
}
}
@Override
public void importBsxg(File excelFile, String codeBsxg) throws Exception {
log.info("导入试题参数:{}, {}", excelFile, codeBsxg);
List<String> types = new ArrayList<>();
if (Constant.Question.ALL.equalsIgnoreCase(codeBsxg)) {
types.addAll(Constant.Question.QUESTION_TYPE);
} else {
types.add(codeBsxg);
}
log.info("导入试题类型:{}", types);
for (String sheetName: types) {
List<Object[]> questions = PoiUtil.readExce(excelFile, -1, sheetName,1, true);
saveQuestions(questions, sheetName);
}
}
/**
* 保存试题
* */
private void saveQuestions(List<Object[]> questions , String evaluationCode) throws Exception{
List<Question> questionList = new ArrayList<>();
List<QuestionOption> optionList = new ArrayList<>();
//关联的选项的id
Long optionId = null;
for(Object[] objs : questions) {
if (objs == null || objs.length < 4 || StringUtils.isEmpty(objs[2])) {
log.info("数据不足,跳转下一行");
continue;
}
int sort = StringUtil.checkNum(String.valueOf(objs[3]), false) ? Integer.parseInt(String.valueOf(objs[3])) : 1;
String code = StringUtils.isEmpty(objs[1]) ? Constant.STRING_DEFAULT : String.valueOf(objs[1]);
String type = String.valueOf(objs[0]);
switch (type) {
case "题目" :
Question question = initQuestion(objs, code, sort,null);
questionList.add(question);
break;
case "选项" :
if (questionList.isEmpty()) {
break;
}
QuestionOption option = initOption(objs, questionList.get(questionList.size()-1).getId(), sort);
optionList.add(option);
optionId = option.getId();
break;
case "关联题目" :
if (optionList.isEmpty()) {
break;
}
Question relevanceQuestion = initQuestion(objs, code, sort, optionId);
questionList.add(relevanceQuestion);
break;
case "关联题目的选项" :
if (questionList.isEmpty()) {
break;
}
QuestionOption relevanceOption = initOption(objs, questionList.get(questionList.size()-1).getId(), sort);
optionList.add(relevanceOption);
break;
default:
log.info("{}类型未知,不解析", type);
break;
}
}
if (!questionList.isEmpty()) {
questionDao.insertBatch(questionList);
}
if (!optionList.isEmpty()) {
questionOptionDao.insertBatch(optionList);
}
}
/**
* 初始化选项
* @param objs 表格内读取的数据
* @param questionId 试题id
* @param sort 排序
* @return 返回选项
*/
private QuestionOption initOption(Object[] objs, Long questionId, int sort) {
QuestionOptionExample example = new QuestionOptionExample();
example.createCriteria().andQuestionIdEqualTo(questionId).andSortEqualTo(sort);
List<QuestionOption> options = questionOptionDao.selectByExample(example);
//转化option
QuestionOption option;
if (CollectionUtils.isEmpty(options)) {
option = new QuestionOption();
option.setId(snowflake.nextId());
} else {
option = options.get(0);
}
option.setQuestionId(questionId);
option.setSort(sort);
String value = objs.length>2 && StringUtils.isEmpty(objs[2]) ? Constant.STRING_DEFAULT : String.valueOf(objs[2]);
option.setShowValue(value);
option.setSubmitValue(value);
option.setAfterOperation(objs.length>7 && StringUtil.checkNum(String.valueOf(objs[7]), false) ? Byte.parseByte(String.valueOf(objs[7])) : Constant.NUMBER_DEFAULT);
log.info("导入选项:{}", option);
return option;
}
/**
* 初始化报告单对象若该对象已存在则返回null
* @param objs 表格内读取的数据
* @return 返回测试类型
*/
private ReportCode initReport(Object[] objs) {
ReportCodeExample example = new ReportCodeExample();
example.createCriteria().andCodeEqualTo((String) objs[0]);
List<ReportCode> list = reportCodeDao.selectByExample(example);
ReportCode report;
if (!CollectionUtils.isEmpty(list)) {
report = list.get(0);
} else {
report = new ReportCode();
report.setId(snowflake.nextId());
}
report.setCode((String) objs[0]);
report.setName((String) objs[1]);
report.setParentCode(objs.length > 2 && !StringUtils.isEmpty(objs[2]) ? (String) objs[2] : Constant.STRING_DEFAULT);
report.setReportType(objs.length > 3 && StringUtil.checkNum(String.valueOf(objs[3]),false)? Byte.parseByte((String) objs[3]) : Constant.NUMBER_DEFAULT);
report.setMust(objs.length > 4 && StringUtil.checkNum(String.valueOf(objs[4]), false) ? Byte.parseByte((String) (objs[4])) : Constant.NUMBER_DEFAULT);
report.setSort(objs.length > 5 && StringUtil.checkNum(String.valueOf(objs[5]), false) ? Integer.parseInt((String) (objs[5])) : Constant.NUMBER_DEFAULT_SORT);
report.setLevel(objs.length > 6 && StringUtil.checkNum(String.valueOf(objs[6]), false) ? Byte.parseByte((String)(objs[6])) : Constant.NUMBER_DEFAULT_SORT);
report.setRemark(objs.length > 7 && !StringUtils.isEmpty(objs[7]) ? (String) objs[7] : Constant.STRING_DEFAULT);
return report;
}
/**
* 初始化试题
* @param objs 表格内读取的数据
* @param evaluationCode 试题类型
* @param sort 排序
* @return 返回试题
*/
private Question initQuestion(Object[] objs, String evaluationCode, int sort,Long optionId) {
QuestionExample example = new QuestionExample();
example.createCriteria().andCodeEqualTo(evaluationCode).andSortEqualTo(sort);
List<Question> questions = questionDao.selectByExample(example);
Question question;
if (CollectionUtils.isEmpty(questions)) {
question = new Question();
question.setId(snowflake.nextId());
} else {
question = questions.get(0);
}
question.setCode(StringUtils.isEmpty(objs[1]) ? Constant.STRING_DEFAULT : String.valueOf(objs[1]));
question.setQuestion(StringUtils.isEmpty(objs[2]) ? Constant.STRING_DEFAULT : String.valueOf(objs[2]));
question.setSort(sort);
question.setType(objs.length>4 && StringUtil.checkNum(String.valueOf(objs[4]), false) ? Byte.parseByte(String.valueOf(objs[4])) : Constant.Question.QUESTION_SHOW_TYPE);
question.setUnits(objs.length>5 && StringUtils.isEmpty(objs[5]) ? Constant.STRING_DEFAULT : String.valueOf(objs[5]));
question.setSearchCriteria(objs.length>6 && StringUtil.checkNum(String.valueOf(objs[6]), false) ? Byte.parseByte(String.valueOf(objs[6])) : Constant.Question.QUESTION_SHOW_TYPE);
question.setRemark(objs.length > 8 && !StringUtils.isEmpty(objs[8]) ? (String) objs[8] : Constant.STRING_DEFAULT);
question.setRelevanceOptionId(optionId == null ? 0 : optionId);
log.info("导入试题:{}", question);
return question;
}
}

56
tcm/src/main/java/com/ccsens/tcm/uitl/Constant.java

@ -0,0 +1,56 @@
package com.ccsens.tcm.uitl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: wuHuiJuan
* @create: 2019/11/29 17:21
*/
public class Constant {
/**逗号*/
public static final String COMMA = "[,,]";
/**图片*/
public static final String IMG = ".png,.jpg,.jpeg,.gif,.bmp";
/**视频音频*/
public static final String VIDEO = ".flv,swf,mkv,avi,rm,rmvb,mpeg,mpg,.ogg,ogv,mov,wmv,mp4,webm,mp3,wav,mid,.wma";
/**上传图片访问路径*/
public static final String UPLOAD_URL = "uploads/";
/**数字默认值*/
public final static byte NUMBER_DEFAULT = 0;
/**排序默认值*/
public final static byte NUMBER_DEFAULT_SORT = 1;
/**数字默认值*/
public final static BigDecimal NUMBER_DEFAULT_BIGDECIMAL = BigDecimal.valueOf(0);
/**字符串默认值*/
public final static String STRING_DEFAULT = "";
public final static byte SEX_MAN = 0;
public final static byte SEX_WOMAN = 1;
public static class Report{
public final static String PARENT_CODE = "TCM";
public final static String CODE_BSXG = "BSXG";
}
public static class Question {
public final static String ALL = "all";
/**默认题目类型*/
public final static byte QUESTION_SHOW_TYPE = 1;
/**默认选项类型*/
public final static byte RULE_TYPE_DEFAULT = 1;
/**测评分类*/
public final static List<String> QUESTION_TYPE = new ArrayList<>();
public final static Map<String, Byte> TYPE = new HashMap<>();
static {
QUESTION_TYPE.add("TCM");
QUESTION_TYPE.add("BSXG");
}
}
}

4
tcm/src/main/resources/application-dev.yml

@ -29,9 +29,9 @@ spring:
swagger:
enable: true
file:
path: /home/cloud/beneficiation/uploads/
path: /home/cloud/tcm/uploads/
domain: https://test.tall.wiki/gateway/mt/
imgDomain: https://test.tall.wiki/gateway/beneficiation/uploads/
imgDomain: https://test.tall.wiki/gateway/tcm/uploads/
#gameMqName: game_status_wisdom
logging:
path:

31
tcm/src/main/resources/mapper_dao/QuestionDao.xml

@ -0,0 +1,31 @@
<?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.ccsens.tcm.persist.dao.QuestionDao">
<resultMap id="BaseResultMap" type="com.ccsens.tcm.bean.po.Question">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="question" jdbcType="VARCHAR" property="question" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="units" jdbcType="VARCHAR" property="units" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="relevance_option_id" jdbcType="BIGINT" property="relevanceOptionId" />
<result column="search_criteria" jdbcType="TINYINT" property="searchCriteria" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<insert id="insertBatch">
replace into t_question (id, question, code,
sort, units, type,
relevance_option_id, search_criteria, remark)
values
<foreach collection="list" item="question" separator=",">
(#{question.id,jdbcType=BIGINT}, #{question.question,jdbcType=VARCHAR}, #{question.code,jdbcType=VARCHAR},
#{question.sort,jdbcType=INTEGER}, #{question.units,jdbcType=VARCHAR}, #{question.type,jdbcType=TINYINT},
#{question.relevanceOptionId,jdbcType=BIGINT}, #{question.searchCriteria,jdbcType=TINYINT}, #{question.remark,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>

26
tcm/src/main/resources/mapper_dao/QuestionOptionDao.xml

@ -0,0 +1,26 @@
<?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.ccsens.tcm.persist.dao.QuestionOptionDao">
<resultMap id="BaseResultMap" type="com.ccsens.tcm.bean.po.QuestionOption">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="question_id" jdbcType="BIGINT" property="questionId" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="show_value" jdbcType="VARCHAR" property="showValue" />
<result column="submit_value" jdbcType="VARCHAR" property="submitValue" />
<result column="after_operation" jdbcType="TINYINT" property="afterOperation" />
<result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<insert id="insertBatch">
replace into t_question_option (id, question_id, sort,
show_value, submit_value, after_operation)
values
<foreach collection="list" item="option" separator=",">
(#{option.id,jdbcType=BIGINT}, #{option.questionId,jdbcType=BIGINT}, #{option.sort,jdbcType=INTEGER},
#{option.showValue,jdbcType=VARCHAR}, #{option.submitValue,jdbcType=VARCHAR}, #{option.afterOperation,jdbcType=TINYINT})
</foreach>
</insert>
</mapper>

32
tcm/src/main/resources/mapper_dao/ReportCodeDao.xml

@ -0,0 +1,32 @@
<?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.ccsens.tcm.persist.dao.ReportCodeDao">
<resultMap id="BaseResultMap" type="com.ccsens.tcm.bean.po.ReportCode">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="parent_code" jdbcType="VARCHAR" property="parentCode" />
<result column="must" jdbcType="TINYINT" property="must" />
<result column="level" jdbcType="TINYINT" property="level" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="report_type" jdbcType="TINYINT" property="reportType" />
<result column="operator" jdbcType="BIGINT" property="operator" />
<result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
<result column="updated_at" jdbcType="TIMESTAMP" property="updatedAt" />
<result column="rec_status" jdbcType="TINYINT" property="recStatus" />
</resultMap>
<insert id="insertBatch">
replace into t_report_code (id, code, name,
parent_code, must, level,
sort, remark, report_type)
values
<foreach collection="list" item="report" separator=",">
(#{report.id,jdbcType=BIGINT}, #{report.code,jdbcType=VARCHAR}, #{report.name,jdbcType=VARCHAR},
#{report.parentCode,jdbcType=VARCHAR}, #{report.must,jdbcType=TINYINT}, #{report.level,jdbcType=TINYINT},
#{report.sort,jdbcType=INTEGER}, #{report.remark,jdbcType=VARCHAR}, #{report.reportType,jdbcType=TINYINT})
</foreach>
</insert>
</mapper>

28
tcm/src/main/resources/mapper_raw/QuestionMapper.xml

@ -4,7 +4,7 @@
<resultMap id="BaseResultMap" type="com.ccsens.tcm.bean.po.Question">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="question" jdbcType="VARCHAR" property="question" />
<result column="code_id" jdbcType="BIGINT" property="codeId" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="units" jdbcType="VARCHAR" property="units" />
<result column="type" jdbcType="TINYINT" property="type" />
@ -75,7 +75,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, question, code_id, sort, units, type, relevance_option_id, search_criteria, remark,
id, question, code, sort, units, type, relevance_option_id, search_criteria, remark,
operator, created_at, updated_at, rec_status
</sql>
<select id="selectByExample" parameterType="com.ccsens.tcm.bean.po.QuestionExample" resultMap="BaseResultMap">
@ -109,12 +109,12 @@
</if>
</delete>
<insert id="insert" parameterType="com.ccsens.tcm.bean.po.Question">
insert into t_question (id, question, code_id,
insert into t_question (id, question, code,
sort, units, type,
relevance_option_id, search_criteria, remark,
operator, created_at, updated_at,
rec_status)
values (#{id,jdbcType=BIGINT}, #{question,jdbcType=VARCHAR}, #{codeId,jdbcType=BIGINT},
values (#{id,jdbcType=BIGINT}, #{question,jdbcType=VARCHAR}, #{code,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{units,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT},
#{relevanceOptionId,jdbcType=BIGINT}, #{searchCriteria,jdbcType=TINYINT}, #{remark,jdbcType=VARCHAR},
#{operator,jdbcType=BIGINT}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP},
@ -129,8 +129,8 @@
<if test="question != null">
question,
</if>
<if test="codeId != null">
code_id,
<if test="code != null">
code,
</if>
<if test="sort != null">
sort,
@ -170,8 +170,8 @@
<if test="question != null">
#{question,jdbcType=VARCHAR},
</if>
<if test="codeId != null">
#{codeId,jdbcType=BIGINT},
<if test="code != null">
#{code,jdbcType=VARCHAR},
</if>
<if test="sort != null">
#{sort,jdbcType=INTEGER},
@ -220,8 +220,8 @@
<if test="record.question != null">
question = #{record.question,jdbcType=VARCHAR},
</if>
<if test="record.codeId != null">
code_id = #{record.codeId,jdbcType=BIGINT},
<if test="record.code != null">
code = #{record.code,jdbcType=VARCHAR},
</if>
<if test="record.sort != null">
sort = #{record.sort,jdbcType=INTEGER},
@ -262,7 +262,7 @@
update t_question
set id = #{record.id,jdbcType=BIGINT},
question = #{record.question,jdbcType=VARCHAR},
code_id = #{record.codeId,jdbcType=BIGINT},
code = #{record.code,jdbcType=VARCHAR},
sort = #{record.sort,jdbcType=INTEGER},
units = #{record.units,jdbcType=VARCHAR},
type = #{record.type,jdbcType=TINYINT},
@ -283,8 +283,8 @@
<if test="question != null">
question = #{question,jdbcType=VARCHAR},
</if>
<if test="codeId != null">
code_id = #{codeId,jdbcType=BIGINT},
<if test="code != null">
code = #{code,jdbcType=VARCHAR},
</if>
<if test="sort != null">
sort = #{sort,jdbcType=INTEGER},
@ -322,7 +322,7 @@
<update id="updateByPrimaryKey" parameterType="com.ccsens.tcm.bean.po.Question">
update t_question
set question = #{question,jdbcType=VARCHAR},
code_id = #{codeId,jdbcType=BIGINT},
code = #{code,jdbcType=VARCHAR},
sort = #{sort,jdbcType=INTEGER},
units = #{units,jdbcType=VARCHAR},
type = #{type,jdbcType=TINYINT},

Loading…
Cancel
Save