package com.hxhq.business.service.impl;

import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hxhq.business.domain.StudyMethod;
import com.hxhq.business.service.ISystemLogService;
import com.hxhq.common.core.utils.DateUtils;
import com.hxhq.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.hxhq.business.mapper.StudyMethodJcgjMapper;
import com.hxhq.business.domain.StudyMethodJcgj;
import com.hxhq.business.service.IStudyMethodJcgjService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 试验-试验方法-稽查轨迹Service业务层处理
 *
 * @author hxhq
 * @date 2026-03-02
 */
@Service
public class StudyMethodJcgjServiceImpl extends ServiceImpl<StudyMethodJcgjMapper, StudyMethodJcgj> implements IStudyMethodJcgjService
{

    @Autowired
    private ISystemLogService systemLogService;

    /**
     * 查询试验-试验方法-稽查轨迹列表
     *
     * @param studyMethodJcgj 试验-试验方法-稽查轨迹
     * @return 试验-试验方法-稽查轨迹
     */
    @Override
    public List<StudyMethodJcgj> queryList(StudyMethodJcgj studyMethodJcgj)
    {
        QueryWrapper<StudyMethodJcgj> queryWrapper = Wrappers.query();
        return this.list(queryWrapper);
    }

    @Override
    @Async
    public void saveJcgj(StudyMethod studyMethod, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) {
        Date date = new Date();
        StudyMethodJcgj studyMethodJcgj = new StudyMethodJcgj();
        studyMethodJcgj.setStudyMethodId(studyMethod.getId());
        studyMethodJcgj.setJcgjlx(jcgjlx);
        studyMethodJcgj.setJcmc(jcmc);
        studyMethodJcgj.setJcmcEn(jcmcEn);
        studyMethodJcgj.setJcmcys(jcmcys);
        studyMethodJcgj.setJcnr(jcnr);
        studyMethodJcgj.setJcnrEn(jcnrEn);
        studyMethodJcgj.setQmrId(qmr.getUserId());
        studyMethodJcgj.setQmrMc(qmr.getNickName());
        studyMethodJcgj.setQmrMcEn(qmr.getUserName());
        studyMethodJcgj.setCreateTime(date);
        this.save(studyMethodJcgj);

        systemLogService.saveInfoWithData(studyMethod.getFfmc(), studyMethod.getFfmc(), studyMethodJcgj.getJcmc(), studyMethodJcgj.getJcmcEn(),
                studyMethodJcgj.getJcnr(), studyMethodJcgj.getJcnrEn(), studyMethodJcgj.getQmrId(), studyMethodJcgj.getQmrMc(), studyMethodJcgj.getQmrMcEn(), studyMethodJcgj.getRemark(), date);
    }


}
