package com.xjrsoft.module.liteflow.node;

import com.xjrsoft.XjrSoftApplication;
import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
import com.xjrsoft.module.hikvision.util.FaceImportUtil;
import com.xjrsoft.module.personnel.entity.TeacherFaceProcess;
import com.xjrsoft.module.personnel.service.ITeacherFaceProcessService;
import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

/**
 * @author dzx
 * @date 2024/5/27
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = XjrSoftApplication.class)
class ImportTeacherFaceNodeTest {


    @Autowired
    private ITeacherFaceProcessService teacherFaceProcessService;
    @Autowired
    private FaceImportMapper faceImportMapper;

    @Autowired
    private HikvisionDataMapper hikvisionDataMapper;
    @Test
    public void process() throws Exception {
        // 获取表单中数据编号
        Long formId = 1793948095216664576L;
        if (formId != null) {
            String fileUrl = faceImportMapper.GetTeacherHikvisionImgById(formId);
            // 数据处理
            TeacherFaceProcess dataObj = teacherFaceProcessService.getById(formId);
            dataObj.setStatus(1);
            dataObj.setExamStatus(1);
            String reslut = FaceImportUtil.ImportTeacherFace(hikvisionDataMapper.getTeacherHikvisionId(dataObj.getUserId()), fileUrl);
            dataObj.setHikvisionResult(reslut);
            teacherFaceProcessService.updateById(dataObj);
        }
    }
}