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.Bacteria;
import com.hxhq.business.domain.CellJcgj;
import com.hxhq.business.domain.GspJcgj;
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.stereotype.Service;
import com.hxhq.business.mapper.BacteriaJcgjMapper;
import com.hxhq.business.domain.BacteriaJcgj;
import com.hxhq.business.service.IBacteriaJcgjService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 细菌-稽查轨迹Service业务层处理
 *
 * @author hxhq
 * @date 2026-01-12
 */
@Service
public class BacteriaJcgjServiceImpl extends ServiceImpl<BacteriaJcgjMapper, BacteriaJcgj> implements IBacteriaJcgjService
{

    @Autowired
    private ISystemLogService systemLogService;

    /**
     * 查询细菌-稽查轨迹列表
     *
     * @param bacteriaJcgj 细菌-稽查轨迹
     * @return 细菌-稽查轨迹
     */
    @Override
    public List<BacteriaJcgj> queryList(BacteriaJcgj bacteriaJcgj)
    {
        QueryWrapper<BacteriaJcgj> queryWrapper = Wrappers.query();
        return this.list(queryWrapper);
    }

    @Override
    public void saveJcgj(Bacteria bacteria, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) {
        BacteriaJcgj jcgj = new BacteriaJcgj();
        jcgj.setBacteriaId(bacteria.getId());
        jcgj.setJcgjlx(jcgjlx);
        jcgj.setJcmc(jcmc);
        jcgj.setJcmcEn(jcmcEn);
        jcgj.setJcmcys(jcmcys);
        jcgj.setJcnr(jcnr);
        jcgj.setJcnrEn(jcnrEn);
        jcgj.setQmrId(qmr.getUserId());
        jcgj.setQmrMc(qmr.getNickName());
        jcgj.setQmrMcEn(qmr.getUserName());
        Date date = new Date();
        jcgj.setCreateTime(date);
        this.save(jcgj);

        systemLogService.saveInfoWithData(bacteria.getBh(), bacteria.getBh(), jcgj.getJcmc(), jcgj.getJcmcEn(),
                jcgj.getJcnr(), jcgj.getJcnrEn(), jcgj.getQmrId(), jcgj.getQmrMc(), jcgj.getQmrMcEn(), jcgj.getRemark(), date);
    }

    @Override
    public BacteriaJcgj genJcgj(Long bacteriaId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) {
        BacteriaJcgj jcgj = new BacteriaJcgj();
        jcgj.setBacteriaId(bacteriaId);
        jcgj.setJcgjlx(jcgjlx);
        jcgj.setJcmc(jcmc);
        jcgj.setJcmcEn(jcmcEn);
        jcgj.setJcmcys(jcmcys);
        jcgj.setJcnr(jcnr);
        jcgj.setJcnrEn(jcnrEn);
        jcgj.setQmrId(qmr.getUserId());
        jcgj.setQmrMc(qmr.getNickName());
        jcgj.setQmrMcEn(qmr.getUserName());
        return jcgj;
    }

}
