package com.rongwei.bscommon.sys.dao;

import com.rongwei.bsentity.request.IssuesReportRequest;
import com.rongwei.bsentity.vo.SrmActionPlanVo;
import com.rongwei.bsentity.domin.SrmIssuesListDo;
import com.rongwei.bsentity.vo.SrmFormCountVo;
import com.rongwei.rwcommon.base.BaseDao;
import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
import com.rongwei.rwcommonentity.commonservers.vo.SysNotifyAnnounceVo;
import dto.SysNoticeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * PSL问题
 * @author Trj
 */
@Mapper
public interface SrmIssuesListDao extends BaseDao<SrmIssuesListDo> {

    // 获取 问题ID/任务SPA并签提交时间
    List<SrmIssuesListDo> getProblemByTaskRun();

    /**
     * 查询行动计划表最晚实际完成时间
     * @param issuesReportRequest
     * @return
     */
    List<SrmActionPlanVo> getMaxRealEdDate(@Param("issuesReportRequest") IssuesReportRequest issuesReportRequest);

    /**
     * 查询行动计划表最晚计划完成时间
     * @param issuesReportRequest
     * @return
     */
    List<SrmActionPlanVo> getMaxTargetCompletionDate(@Param("issuesReportRequest") IssuesReportRequest issuesReportRequest);

    /**
     * 表单总数
     * @param issuesReportRequest
     * @return
     */
    List<SrmFormCountVo> getFormCount(@Param("issuesReportRequest") IssuesReportRequest issuesReportRequest);

    List<SrmIssuesListDo> getListByMesId(@Param("mesIds")List<String> mesIds);

    void insertFile(@Param("model") SysFileItemDo sysFileItemDo);

    @Select("SELECT sna.*,GROUP_CONCAT(snau.RECIPIENTID) as 'recipientIds' FROM sys_notify_announce sna LEFT JOIN sys_notify_announce_user snau ON sna.ID = snau.ANNOUNCEID AND snau.DELETED = 0 where sna.DELETED = 0 AND sna.NOTIFYTITLE like CONCAT('生产问题--','%') AND sna.CREATEDATE >= DATE_FORMAT(NOW(),'%Y-%m-%d %H:00:00') AND sna.CREATEDATE <= NOW() GROUP BY sna.ID")
    List<SysNoticeVo> selectNoticeByProduct();

    void updateNoticeByProduct(@Param("idList") List<String> idList);
}
