package com.zcloud.service.keyProjects.impl;

import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.mapper.datasource.keyProjects.KeyprojectHiddenMapper;
import com.zcloud.mapper.datasource.keyProjects.KeyprojectPunishMapper;
import com.zcloud.service.keyProjects.KeyprojectHiddenService;
import com.zcloud.service.system.ImgFilesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 说明：隐患表
 */
@Service
@Transactional //开启事物
public class KeyprojectHiddenServiceImpl implements KeyprojectHiddenService {

	@Autowired
	private KeyprojectHiddenMapper hiddenMapper;
	@Autowired
	private ImgFilesService imgFilesService;
	@Autowired
	private KeyprojectPunishMapper keyprojectpunishMapper;

	/**新增
	 * @param pd
	 * @throws Exception
	 */
	public void save(PageData pd)throws Exception{
		hiddenMapper.save(pd);
	}

	/**删除
	 * @param pd
	 * @throws Exception
	 */
	public void delete(PageData pd)throws Exception{
		hiddenMapper.delete(pd);
	}

	/**修改
	 * @param pd
	 * @throws Exception
	 */
	public void edit(PageData pd)throws Exception{
		hiddenMapper.edit(pd);
	}

	/**修改
	 * @param pd
	 * @throws Exception
	 */
	public void editstate(PageData pd)throws Exception{
		hiddenMapper.editstate(pd);
	}

	/**列表
	 * @param page
	 * @throws Exception
	 */
	public List<PageData> list(Page page)throws Exception{
		return hiddenMapper.datalistPage(page);
	}

	public List<PageData> majorList(Page page)throws Exception{
		return hiddenMapper.majorlistPage(page);
	}

	/*@Override
	public List<PageData> majorlHiddenlistPage(Page page) throws Exception {
		return null;
	}*/


	/**列表(全部)
	 * @param pd
	 * @throws Exception
	 */
	public List<PageData> listAll(PageData pd)throws Exception{
		return hiddenMapper.listAll(pd);
	}

	/**通过id获取数据
	 * @param pd
	 * @throws Exception
	 */
	public PageData findById(PageData pd)throws Exception{
		return hiddenMapper.findById(pd);
	}

	/**批量删除
	 * @param ArrayDATA_IDS
	 * @throws Exception
	 */
	public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
		hiddenMapper.deleteAll(ArrayDATA_IDS);
	}

	/**通过id获取数据
	 * @param page
	 * @throws Exception
	 */
	public List<PageData> specialByCorpInfoId(Page page)throws Exception{
		return hiddenMapper.specialByIdlistPage(page);
	}

	/**上报隐患统计
	 * @throws Exception
	 */
	@Override
	public List<PageData> reportedChart(PageData pd) throws Exception {
		return hiddenMapper.reportedChart(pd);
	}

	/**隐患统计（折线图）
	 * @throws Exception
	 */
	@Override
	public List<PageData> lineChart(PageData pd) throws Exception {
		return hiddenMapper.lineChart(pd);
	}
    @Override
    public PageData yhpcCountForApp(PageData pd) throws Exception{
        return hiddenMapper.yhpcCountForApp(pd);
    }
    /**
     * 清单其他隐患
     * @return
     * @throws Exception
     */
    @Override
    public List<PageData> getOtherHidden(PageData pd) throws Exception {
        return hiddenMapper.getOtherHidden(pd);
    }
    public List<PageData> getListForApp (Page page) throws Exception{
        return hiddenMapper.getListForApplistPage(page);
    }
  public List<PageData> mainStatistics(PageData pd) throws Exception{
		return hiddenMapper.mainStatistics(pd);
    }
    public List<PageData> mainStatisticsForApp(PageData pd) throws Exception{
        return hiddenMapper.mainStatistics(pd);
    }


	/**隐患导出EXCEL（企业隐患管理使用）
	 * @param pd
	 * @throws Exception
	 */
	public List<PageData> listExcelHidden(PageData pd)throws Exception{
		return hiddenMapper.listExcelHidden(pd);
	}


	@Override
	public List<PageData> verifylist(Page page) throws Exception {
		return hiddenMapper.verifydatalistPage(page);
	}

	@Override
	public List<PageData> checkandaccept(Page page) throws Exception {
		return hiddenMapper.checkandacceptdatalistPage(page);
	}



	@Override
	public List<PageData> listAllInspection(PageData pd) throws Exception {
		List<PageData> hiddenList = hiddenMapper.listAllInspection(pd);
		for (PageData hd : hiddenList) {
			PageData pd2 = new PageData();
			pd2.put("FOREIGN_KEY",hd.getString("HIDDEN_ID"));
			pd2.put("TYPE",3);	//隐患图片
			hd.put("hiddenImgs", imgFilesService.listAll(pd2));
			if(imgFilesService.listAll(pd2).size()==0){
				pd2.put("TYPE",114);	//AI隐患图片
				hd.put("hiddenImgs", imgFilesService.listAll(pd2));
			}
			pd2.put("TYPE",102);	//隐患视频
			hd.put("hiddenVideos", imgFilesService.listAll(pd2));
			pd2.put("TYPE",4);
			hd.put("zgImgs", imgFilesService.listAll(pd2));//整改图片
			pd2.put("TYPE",5);
			hd.put("ysImgs", imgFilesService.listAll(pd2));//整改图片

			PageData findTicketData = new PageData();
			findTicketData.put("HIDDEN_ID",hd.getString("HIDDEN_ID"));
			hd.put("punishForm",keyprojectpunishMapper.findById(findTicketData));
		}
		return hiddenList;
	}

	@Override
	public void editStateInspection(PageData pd) throws Exception {
		hiddenMapper.editStateInspection(pd);
	}

	@Override
	public List<PageData> listForSafetyEnvironmental(Page page) throws Exception {
		return hiddenMapper.hiddenInspectionlistPage(page);
	}

	/**安全环保检查验收
	 * @param pd
	 * @throws Exception
	 */
	@Override
	public void finalcheck(PageData pd)throws Exception{
		hiddenMapper.finalcheck(pd);
	}

	@Override
	public List<PageData> listOtherNotAccept(PageData pd) throws Exception {
		return hiddenMapper.listOtherNotAccept(pd);
	}

	/**修改
	 * @param pd
	 * @throws Exception
	 */
	public void changeState(PageData pd)throws Exception{
		hiddenMapper.changeState(pd);
	}

	@Override
	public void deleteByKey(PageData key) throws Exception {
		hiddenMapper.deleteByKey(key);
	}

	@Override
	public PageData keyprojectcount(PageData pd) throws Exception {
	  return hiddenMapper.keyprojectcount(pd);
	}

	public List<PageData> getpunishlist(Page page) {
		return hiddenMapper.getpunishlistPage(page);
	}

	@Override
	public List<PageData> getSmsList(PageData pd) {
		return hiddenMapper.getSmsList(pd);
	}

	@Override
	public String getPUNISHTHEPERSON(PageData pd) {
		return hiddenMapper.getPUNISHTHEPERSON(pd);
	}

	@Override
	public List<String> getPhone(PageData pd) {
		return hiddenMapper.getPhone(pd);
	}

	@Override
	public List<PageData> hiddenList(Page page) {
		return hiddenMapper.hiddenlistPage(page);
	}

	@Override
	public String getCorpInfoIdByHiddenId(PageData pd) {
		return hiddenMapper.getCorpInfoIdByHiddenId(pd);
	}

}

