package com.hz.pm.api.workbench.converter;

import cn.hutool.core.bean.BeanUtil;
import com.hz.pm.api.projectdeclared.model.po.DeclaredProjectStatisticsPO;
import com.hz.pm.api.todocenter.model.vo.ResToBeProcessedVO;
import com.hz.pm.api.todocenter.model.vo.TodoVO;
import com.hz.pm.api.workbench.model.vo.WorkbenchVO;

import java.util.Objects;

/**
 * @Classname WorkbenchConverter
 * @Description
 * @Date 2023/3/20 17:23
 * @Author PoffyZhang
 */
public class WorkbenchConverter {

    public static WorkbenchVO.DeclaredStatistics convert(DeclaredProjectStatisticsPO po,DeclaredProjectStatisticsPO lastYearPo) {
        WorkbenchVO.DeclaredStatistics res = BeanUtil.copyProperties(po,WorkbenchVO.DeclaredStatistics.class);
        if(Objects.nonNull(lastYearPo)){
            res.setDeclaredAmountLastYear(lastYearPo.getDeclaredAmount());
            res.setApprovalAmountLastYear(lastYearPo.getApprovalAmount());
        }
        return res;
    }

    public static TodoVO convert(ResToBeProcessedVO vo) {
        TodoVO res = new TodoVO();
        res.setNodeId(vo.getNodeId());
        res.setProjectId(vo.getProjectId());
        res.setProjectName(vo.getProjectName());
        return res;
    }
}
