|
@@ -9,6 +9,7 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.JSONValidator;
|
|
|
import com.baomidou.mybatisplus.annotation.TableField;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import org.aspectj.weaver.ast.Or;
|
|
@@ -299,9 +300,10 @@ public class SysScreeningAssessmentConfigServiceImpl implements ISysScreeningAss
|
|
|
JSONObject jsonObject = JSON.parseObject(content);
|
|
|
|
|
|
SysScreeningAssessmentConfigBo config = new SysScreeningAssessmentConfigBo();
|
|
|
- config.setName(jsonObject.getString("title"));
|
|
|
- config.setPurpose(jsonObject.getString("purpose"));
|
|
|
+ config.setName(jsonObject.getString("purpose"));
|
|
|
+ config.setPurpose("import");
|
|
|
config.setSource(jsonObject.getString("source"));
|
|
|
+ config.setRemark(jsonObject.getString("title"));
|
|
|
config.setType(configType);
|
|
|
|
|
|
if (jsonObject.containsKey("scoring")) {
|
|
@@ -323,7 +325,10 @@ public class SysScreeningAssessmentConfigServiceImpl implements ISysScreeningAss
|
|
|
SysScreeningAssessmentQuestionBo questionBo = new SysScreeningAssessmentQuestionBo();
|
|
|
otherInfo.add(questionBo);
|
|
|
|
|
|
- questionBo.setTitle(question.getString("text"));
|
|
|
+ if (question.containsKey("text")) {
|
|
|
+ questionBo.setTitle(question.getString("text"));
|
|
|
+ }
|
|
|
+
|
|
|
setQId(questionBo, question);
|
|
|
questionBo.setArrangement("2");
|
|
|
if ("单选".equals(type)) {
|
|
@@ -340,7 +345,11 @@ public class SysScreeningAssessmentConfigServiceImpl implements ISysScreeningAss
|
|
|
for (int j = 0, len2 = options.size(); j < len2; j++) {
|
|
|
SysScreeningAssessmentQuestionBo.QuestionAttrBo questionAttrBo = new SysScreeningAssessmentQuestionBo.QuestionAttrBo();
|
|
|
JSONObject op = options.getJSONObject(j);
|
|
|
- questionAttrBo.setLabel(StrUtil.emptyToDefault(op.getString("text"), op.getString("input_tex")));
|
|
|
+ if (op.containsKey("text")) {
|
|
|
+ questionAttrBo.setLabel(op.getString("text"));
|
|
|
+ } else if (op.containsKey("input_text")) {
|
|
|
+ questionAttrBo.setLabel(op.getString("input_text"));
|
|
|
+ }
|
|
|
questionAttrBo.setScore(op.getString("score"));
|
|
|
if ("单选".equals(type)) {
|
|
|
questionAttrBo.setNameEn("single" + j);
|
|
@@ -356,20 +365,27 @@ public class SysScreeningAssessmentConfigServiceImpl implements ISysScreeningAss
|
|
|
SysScreeningAssessmentQuestionBo questionBo = new SysScreeningAssessmentQuestionBo();
|
|
|
otherInfo.add(questionBo);
|
|
|
|
|
|
- questionBo.setTitle(question.getString("text"));
|
|
|
+ if (question.containsKey("text")) {
|
|
|
+ questionBo.setTitle(question.getString("text"));
|
|
|
+ }
|
|
|
+
|
|
|
questionBo.setArrangement("2");
|
|
|
setQId(questionBo, question);
|
|
|
questionBo.setQuestionType(QuestionsList.QUESTION_TYPE_SELECTION.getCode());
|
|
|
questionBo.setQuestionChildType(QuestionsList.SINGLE_CHOICE.getCode());
|
|
|
- questionBo.setRequired(Boolean.TRUE);
|
|
|
JSONArray options = question.getJSONArray("options");
|
|
|
+ questionBo.setRequired(CollUtil.isNotEmpty(options));
|
|
|
List<SysScreeningAssessmentQuestionBo.QuestionAttrBo> contentList = CollUtil.newArrayList();
|
|
|
|
|
|
if (CollUtil.isNotEmpty(options)) {
|
|
|
for (int j = 0, len2 = options.size(); j < len2; j++) {
|
|
|
SysScreeningAssessmentQuestionBo.QuestionAttrBo questionAttrBo = new SysScreeningAssessmentQuestionBo.QuestionAttrBo();
|
|
|
JSONObject op = options.getJSONObject(j);
|
|
|
- questionAttrBo.setLabel(StrUtil.emptyToDefault(op.getString("text"), op.getString("input_tex")));
|
|
|
+ if (op.containsKey("text")) {
|
|
|
+ questionAttrBo.setLabel(op.getString("text"));
|
|
|
+ } else if (op.containsKey("input_text")) {
|
|
|
+ questionAttrBo.setLabel(op.getString("input_text"));
|
|
|
+ }
|
|
|
questionAttrBo.setScore(op.getString("score"));
|
|
|
questionAttrBo.setNameEn("single" + j);
|
|
|
questionAttrBo.setAllowFillBlank(Boolean.FALSE);
|
|
@@ -391,6 +407,124 @@ public class SysScreeningAssessmentConfigServiceImpl implements ISysScreeningAss
|
|
|
}
|
|
|
questionBo.setContentList(contentList);
|
|
|
questionBo.setContent(JSON.toJSONString(contentList));
|
|
|
+ } else if ("multiple_choice".equalsIgnoreCase(type) || "single_choice".equalsIgnoreCase(type)) {
|
|
|
+ SysScreeningAssessmentQuestionBo questionBo = new SysScreeningAssessmentQuestionBo();
|
|
|
+ otherInfo.add(questionBo);
|
|
|
+
|
|
|
+ if (question.containsKey("text")) {
|
|
|
+ questionBo.setTitle(question.getString("text"));
|
|
|
+ } else if (question.containsKey("title")) {
|
|
|
+ questionBo.setTitle(question.getString("title"));
|
|
|
+ }
|
|
|
+
|
|
|
+ setQId(questionBo, question);
|
|
|
+ questionBo.setArrangement("2");
|
|
|
+
|
|
|
+ if ("single_choice".equalsIgnoreCase(type)) {
|
|
|
+ questionBo.setQuestionType(QuestionsList.QUESTION_TYPE_SELECTION.getCode());
|
|
|
+ questionBo.setQuestionChildType(QuestionsList.SINGLE_CHOICE.getCode());
|
|
|
+ } else if ("multiple_choice".equalsIgnoreCase(type)) {
|
|
|
+ questionBo.setQuestionType(QuestionsList.QUESTION_TYPE_SELECTION.getCode());
|
|
|
+ questionBo.setQuestionChildType(QuestionsList.MULTIPLE_CHOICE.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONArray options = question.getJSONArray("options");
|
|
|
+ List<SysScreeningAssessmentQuestionBo.QuestionAttrBo> contentList = CollUtil.newArrayList();
|
|
|
+ for (int j = 0, len2 = options.size(); j < len2; j++) {
|
|
|
+ SysScreeningAssessmentQuestionBo.QuestionAttrBo questionAttrBo = new SysScreeningAssessmentQuestionBo.QuestionAttrBo();
|
|
|
+ Object op = options.get(j);
|
|
|
+ String opStr = JSON.toJSONString(op);
|
|
|
+ if (JSONValidator.Type.Value.equals(JSONValidator.from(opStr).getType())) {
|
|
|
+ questionAttrBo.setLabel(String.valueOf(op));
|
|
|
+ questionAttrBo.setScore("0");
|
|
|
+ questionAttrBo.setAllowFillBlank(Boolean.FALSE);
|
|
|
+ questionBo.setRequired(Boolean.FALSE);
|
|
|
+ } else {
|
|
|
+ questionBo.setRequired(Boolean.TRUE);
|
|
|
+ JSONObject opObj = (JSONObject) op;
|
|
|
+ if (opObj.containsKey("label")) {
|
|
|
+ questionAttrBo.setLabel(opObj.getString("label"));
|
|
|
+ } else if (opObj.containsKey("text")) {
|
|
|
+ questionAttrBo.setLabel(opObj.getString("text"));
|
|
|
+ } else if (opObj.containsKey("value")) {
|
|
|
+ questionAttrBo.setLabel(opObj.getString("value"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (opObj.containsKey("score")) {
|
|
|
+ questionAttrBo.setScore(opObj.getString("score"));
|
|
|
+ } else if (opObj.containsKey("value")) {
|
|
|
+ questionAttrBo.setScore(opObj.getString("value"));
|
|
|
+ }
|
|
|
+
|
|
|
+ String val = opObj.getString("input_text");
|
|
|
+ questionAttrBo.setAllowFillBlank(String.valueOf(Boolean.TRUE).equalsIgnoreCase(val));
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("single_choice".equalsIgnoreCase(type)) {
|
|
|
+ questionAttrBo.setNameEn("single" + j);
|
|
|
+ } else if ("multiple_choice".equalsIgnoreCase(type)) {
|
|
|
+ questionAttrBo.setNameEn("multiple" + j);
|
|
|
+ }
|
|
|
+
|
|
|
+ contentList.add(questionAttrBo);
|
|
|
+ }
|
|
|
+ questionBo.setContentList(contentList);
|
|
|
+ questionBo.setContent(JSON.toJSONString(contentList));
|
|
|
+ } else if ("input_number".equalsIgnoreCase(type) || "input_text".equalsIgnoreCase(type) || "calculated".equalsIgnoreCase(type)) {
|
|
|
+ SysScreeningAssessmentQuestionBo questionBo = new SysScreeningAssessmentQuestionBo();
|
|
|
+ otherInfo.add(questionBo);
|
|
|
+
|
|
|
+ questionBo.setQId("Q" + i);
|
|
|
+ setQId(questionBo, question);
|
|
|
+
|
|
|
+ if ("input_number".equalsIgnoreCase(type)) {
|
|
|
+ questionBo.setQuestionType(QuestionsList.INPUT_BOX.getCode());
|
|
|
+ questionBo.setQuestionChildType(QuestionsList.INPUT_NUMBER.getCode());
|
|
|
+ } else if ("input_text".equalsIgnoreCase(type)) {
|
|
|
+ questionBo.setQuestionType(QuestionsList.INPUT_BOX.getCode());
|
|
|
+ questionBo.setQuestionChildType(QuestionsList.INPUT_TEXT.getCode());
|
|
|
+ } else if ("calculated".equalsIgnoreCase(type)) {
|
|
|
+ questionBo.setQuestionType(QuestionsList.INPUT_BOX.getCode());
|
|
|
+ questionBo.setQuestionChildType(QuestionsList.CALCULATED.getCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (question.containsKey("text")) {
|
|
|
+ questionBo.setTitle(question.getString("text"));
|
|
|
+ } else if (question.containsKey("title")) {
|
|
|
+ questionBo.setTitle(question.getString("title"));
|
|
|
+ }
|
|
|
+
|
|
|
+ questionBo.setRequired(Boolean.FALSE);
|
|
|
+
|
|
|
+ } else if (StrUtil.isBlank(type) && question.containsKey("question_text")) {
|
|
|
+ SysScreeningAssessmentQuestionBo questionBo = new SysScreeningAssessmentQuestionBo();
|
|
|
+ otherInfo.add(questionBo);
|
|
|
+
|
|
|
+ if (question.containsKey("question_text")) {
|
|
|
+ questionBo.setTitle(question.getString("question_text"));
|
|
|
+ }
|
|
|
+
|
|
|
+ questionBo.setQId("Q" + i);
|
|
|
+ setQId(questionBo, question);
|
|
|
+ questionBo.setArrangement("2");
|
|
|
+ questionBo.setQuestionType(QuestionsList.QUESTION_TYPE_SELECTION.getCode());
|
|
|
+ questionBo.setQuestionChildType(QuestionsList.SINGLE_CHOICE.getCode());
|
|
|
+ questionBo.setRequired(Boolean.TRUE);
|
|
|
+
|
|
|
+ JSONArray options = question.getJSONArray("options");
|
|
|
+ List<SysScreeningAssessmentQuestionBo.QuestionAttrBo> contentList = CollUtil.newArrayList();
|
|
|
+ for (int j = 0, len2 = options.size(); j < len2; j++) {
|
|
|
+ SysScreeningAssessmentQuestionBo.QuestionAttrBo questionAttrBo = new SysScreeningAssessmentQuestionBo.QuestionAttrBo();
|
|
|
+ JSONObject op = options.getJSONObject(j);
|
|
|
+ questionAttrBo.setLabel(op.getString("input_text"));
|
|
|
+ questionAttrBo.setScore(op.getString("score"));
|
|
|
+ questionAttrBo.setNameEn("single" + j);
|
|
|
+ String inputType = op.getString("input_type");
|
|
|
+ questionAttrBo.setAllowFillBlank(StrUtil.isNotBlank(inputType) && "input_text".equalsIgnoreCase(inputType));
|
|
|
+ contentList.add(questionAttrBo);
|
|
|
+ }
|
|
|
+ questionBo.setContentList(contentList);
|
|
|
+ questionBo.setContent(JSON.toJSONString(contentList));
|
|
|
}
|
|
|
}
|
|
|
|