SpeechLittlePhaseAddDTO.java 2.92 KB
package com.phase;

import lombok.*;
import org.springframework.util.StringUtils;

import java.util.HashMap;

@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class SpeechLittlePhaseAddDTO {

    private int littlePhaseSerialNum;

    private String littlePhaseName;

    //触发条件状态(1 = 开, 2 = 关, 3 = 自定义条件开启)
    private int triggerConditionSwitch;

    //触发条件内容
    private String triggerConditionContent;

    // 环节类型(1 = 问答环节, 2 = 陈述环节, 3 = 文件初始环节, 4 = 证件初始环节, 5 = 通用环节, 6  = 人脸识别环节)
    private int phaseType;

    //肯定答复
    private String sure;

    //否定答复
    private String no;

    //文件出示环节---文件类型(1 = 通用文件)
    private int fileType;

    //证件出示环节---证件类型(1 = 身份证正面, 2 = 身份证反面, 3 = 执业证正面, 4 = 执业证反面)
    private int identityType;

    //身份证证件ocr(正/反)开关(1 = 开, 2 = 关)
    private int idcardOcrSwitch;

    // 环节展示标题
    private String littlePhaseTitle;

    //tts播报内容
    private String ttsContent;

    private int bindBefore;

    private int bindAfter;

    private String bindUnique;

    private Integer popup;

    public SpeechLittlePhaseEditDTO transToVO() {
        return SpeechLittlePhaseEditDTO.builder().hintNum(this.littlePhaseSerialNum).hintName(this.littlePhaseName)
                .hintTitle(this.littlePhaseTitle).tts(this.ttsContent).condition(getConditionMap()).hintType(getHintType())
                .bindBefore(this.bindBefore).bindAfter(this.bindAfter).bindUnique(this.bindUnique)
                .classIndex(0).popup(this.popup).build();
    }

    private HashMap<String, Object> getConditionMap() {
        HashMap<String, Object> conditionMap = new HashMap<>();
        conditionMap.put("conditionType", this.triggerConditionSwitch);
        if (this.triggerConditionSwitch == 3) {
            conditionMap.put("conditionContent", this.triggerConditionContent);
        }
        return conditionMap;
    }

    private HashMap<String, Object> getHintType() {
        HashMap<String, Object> hintTypeMap = new HashMap<>();
        hintTypeMap.put("hintType", this.phaseType);
        if (this.phaseType == 1) {
            if (!StringUtils.isEmpty(this.sure)) {
                hintTypeMap.put("sure", this.sure);
            }
            if (!StringUtils.isEmpty(this.no)) {
                hintTypeMap.put("no", this.no);
            }
        } else if (this.phaseType == 3) {
            hintTypeMap.put("docType", this.fileType);
        } else if (this.phaseType == 4) {
            hintTypeMap.put("certificateType", this.identityType);
            if (this.identityType == 1 || this.identityType == 2) {
                hintTypeMap.put("ocr", this.idcardOcrSwitch);
            }
        }
        return hintTypeMap;
    }
}