package com.bofeng.service;

import com.bofeng.dao.QzTaskDao;
import com.bofeng.entity.UserHelpAnaly;
import com.yvan.platform.Conv;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional(readOnly = true)
public class WuYeService {

    @Autowired
    private QzTaskDao qzTaskDao;

    public UserHelpAnaly queryUserHelpAnaly(Long userId, String queryDate) {
        UserHelpAnaly userHelpAnaly = new UserHelpAnaly();
        List<Map> lstAnaly = qzTaskDao.queryUserHelpAnaly(userId, queryDate);
        String status = "";
        if (lstAnaly != null && lstAnaly.size() > 0) {
            for (Map map : lstAnaly) {
                status = map.get("task_status").toString();
                if (status.equals("3")) {
                    userHelpAnaly.setTotalDo(Conv.NL(map.get("num")));
                    continue;
                }
                if (status.equals("2")) {
                    userHelpAnaly.setTotalDoing(Conv.NL(map.get("num")));
                    continue;
                }
                if (status.equals("1")) {
                    userHelpAnaly.setTotalDonot(Conv.NL(map.get("num")));
                    continue;
                }
            }
        }
        return userHelpAnaly;
    }

}
