package com.zjrs.ggfw.rlzysc.blo.impl;

import org.mohrss.leaf.core.framework.domain.blo.impl.BLOImpl;
import com.zjrs.ggfw.rlzysc.blo.InformationBLO;
import com.zjrs.ggfw.rlzysc.dto.SendInformationDTO;
import com.zjrs.ggfw.rlzysc.entity.VRsSyXxglPOMapper;
import com.zjrs.ggfw.rlzysc.entity.VRsSyXxglSjPOMapper;
import com.zjrs.ggfw.rlzysc.po.VRsSyXxglPO;
import com.zjrs.ggfw.rlzysc.po.VRsSyXxglSjPO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

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

@Service
public class InformationBLOImpl extends BLOImpl implements InformationBLO {

    @Resource
    private VRsSyXxglSjPOMapper vRsSyXxglSjPOMapper;

    @Resource
    private VRsSyXxglPOMapper vRsSyXxglPOMapper;

    @Override
    public void sendInfo(SendInformationDTO dto) {
        VRsSyXxglPO po = new VRsSyXxglPO();

        // 发件表插入数据
        BeanUtils.copyProperties(dto, po);
        vRsSyXxglPOMapper.insert(po);
        String fjid = po.getRssyxxgllsh();
        // 收件表插入数据
        List<String> sjrlist = dto.getSjrid();
        for (int i = 0; i < sjrlist.size(); i++) {
            String sjrid = sjrlist.get(i);
            VRsSyXxglSjPO PO = new VRsSyXxglSjPO();
            PO.setRssyxxgllsh(fjid);
            PO.setSjrid(sjrid);
            vRsSyXxglSjPOMapper.insert(PO);
        }
    }

}



