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.BacteriaJcgj;
import com.hxhq.business.domain.Cell;
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.CellJcgjMapper;
import com.hxhq.business.domain.CellJcgj;
import com.hxhq.business.service.ICellJcgjService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 细胞-稽查轨迹Service业务层处理
 *
 * @author hxhq
 * @date 2026-01-12
 */
@Service
public class CellJcgjServiceImpl extends ServiceImpl<CellJcgjMapper, CellJcgj> implements ICellJcgjService
{

    @Autowired
    private ISystemLogService systemLogService;
    /**
     * 查询细胞-稽查轨迹列表
     *
     * @param cellJcgj 细胞-稽查轨迹
     * @return 细胞-稽查轨迹
     */
    @Override
    public List<CellJcgj> queryList(CellJcgj cellJcgj)
    {
        QueryWrapper<CellJcgj> queryWrapper = Wrappers.query();
        return this.list(queryWrapper);
    }

    @Override
    public void saveJcgj(Cell cell, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) {
        CellJcgj jcgj = new CellJcgj();
        jcgj.setCellId(cell.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(cell.getBh(), cell.getBh(), jcgj.getJcmc(), jcgj.getJcmcEn(),
                jcgj.getJcnr(), jcgj.getJcnrEn(), jcgj.getQmrId(), jcgj.getQmrMc(), jcgj.getQmrMcEn(), jcgj.getRemark(), date);
    }

    @Override
    public CellJcgj genJcgj(Long cellId, Integer jcgjlx, String jcmc, String jcmcEn, Integer jcmcys, String jcnr, String jcnrEn, SysUser qmr) {
        CellJcgj jcgj = new CellJcgj();
        jcgj.setCellId(cellId);
        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;
    }

}
