package com.xhkjedu.smarking.service.stupaper;

import com.alibaba.fastjson.JSON;
import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentQuestionMapper;
import com.xhkjedu.smarking.model.stupaper.MsPaperStudentQuestion;
import com.xhkjedu.smarking.utils.ConvertUtil;
import com.xhkjedu.utils.N_Utils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 阅卷试卷学生试题表 服务实现类
 * @Author auto
 * @Date 2024-10-15
 */
@Service
public class MsPaperStudentQuestionService {
    @Resource
    private MsPaperStudentQuestionMapper msPaperStudentQuestionMapper;
    @Resource
    private ConvertUtil convertUtil;

    /*
     * @Description 定时任务-合并
     * @Date 2024/11/15 14:18:36
     * @Author WN
     * @Param []
     * @Return void
     **/
    public void paperStuQuestionAnswerMerge() {
        //获取试卷中未合并图片
        List<MsPaperStudentQuestion> list = msPaperStudentQuestionMapper.listNoMergeStupic();
        if (N_Utils.isListEmpty(list)) return;
            for (MsPaperStudentQuestion sq : list) {
                List<String> stuanswer = JSON.parseArray(sq.getStuanswer(), String.class);
                if (N_Utils.isListNotEmpty(stuanswer) && stuanswer.size() > 1) {
                    convertUtil.imgMerge(sq.getMpsqid(), stuanswer);
                }
            }
    }
}
