 package com.huatek.busi.service.impl.appendix;

 import com.alibaba.dubbo.config.annotation.Service;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.huatek.busi.dao.AppendixAssessmentResultDao;
 import com.huatek.busi.entity.AppendixAssessmentResult;

 import com.huatek.busi.mapper.AppendixAssessmentResultMapper;
 import com.huatek.busi.service.AppendixAssessmentResultService;

 import com.huatek.busi.vo.AppendixAssessmentResultVo;
 import com.huatek.busi.vo.BusiGisCaculateStepVo;
 import com.huatek.torch.frame.tools.ConstantUtil;
 import com.huatek.torch.frame.tools.ResultUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.transaction.annotation.Transactional;

 import java.time.LocalDate;
 import java.util.*;

 /**
 * 附件评估
 * @author vent
 * @date 2023/03/31
 */
@Component
@Service(interfaceClass = AppendixAssessmentResultService.class)
@Transactional(rollbackFor = Exception.class)
public class AppendixAssessmentResultServiceImpl implements AppendixAssessmentResultService {

    @Autowired
    private AppendixAssessmentResultDao appendixAssessmentResultDao;
    @Autowired
    private AppendixAssessmentResultMapper appendixAssessmentResultMapper;


    @Override
    public int saveAppendixAssessmentResult(AppendixAssessmentResult appendixAssessmentResult) {
        return appendixAssessmentResultDao.add(appendixAssessmentResult);
    }

    @Override
    public PageInfo<AppendixAssessmentResultVo> findAppendixAssessmentByMainTreeId(String siteId, String mainTreeId, Integer page, Integer limit, LocalDate startTime, LocalDate endTime, String type) {
    	return PageHelper.startPage(page == null ? 1 :page , limit == null? 1 : limit)
		        .doSelectPageInfo(() -> appendixAssessmentResultMapper.findAppendixAssessmentByMainTreeId(siteId,mainTreeId,startTime,endTime,type));
    }

     @Override
     public Map<String, Object> findCalculateStep(String pid){
         BusiGisCaculateStepVo steps = appendixAssessmentResultMapper.findCalculateStep(pid);
         return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "BUSINESS.QUERY.SUCCESS", steps);
     }


}
