package org.jeecg.modules.appInterface.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import org.jeecg.modules.appInterface.entity.FbsWorkingStatistics;
import org.jeecg.modules.appInterface.mapper.FbsWorkingStatisticsMapper;
import org.jeecg.modules.appInterface.service.IFbsWorkingStatisticsService;
import org.jeecg.modules.fbsWorkshopDispatchList.entity.FbsWorkshopDispatchList;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 工时统计接口
 * @author： jeecg-boot
 * @date：   2020-10-15
 * @version： V1.0
 */
@Service
//@DS("multi-datasource1")
public class FbsWorkingStatisticsServiceImpl extends ServiceImpl<FbsWorkingStatisticsMapper, FbsWorkingStatistics> implements IFbsWorkingStatisticsService {

    @Resource
    FbsWorkingStatisticsMapper fbsWorkingStatisticsMapper;

    @Override
    public Map<String,Object> getByMaterial(String dateString) {
//        List<FbsWorkingStatistics> fbsWorkingStatisticsList=fbsWorkingStatisticsMapper.getByMaterial(dateString);
//        Map<String,Object> map=new HashMap<>();
//        if(fbsWorkingStatisticsList!=null){
//            for(FbsWorkingStatistics fbsWorkingStatistics:fbsWorkingStatisticsList){
//                map.put(fbsWorkingStatistics.getProduct(),fbsWorkingStatistics.getWorkingHours());
//            }
//        }
        Map<String,Object> map=fbsWorkingStatisticsMapper.getByMaterial(dateString);
        Map<String,Object> mapR=new LinkedHashMap<>();
        if(Double.valueOf(String.valueOf(map.get("生产")))>0){
            mapR.put("生产",map.get("生产"));
        }
        if(Double.valueOf(String.valueOf(map.get("其他")))>0){
            mapR.put("其他（5S、会议、培训、研发）",map.get("其他"));

        }
        if(Double.valueOf(String.valueOf(map.get("异常")))>0){
            mapR.put("异常",map.get("异常"));

        }
        if(Double.valueOf(String.valueOf(map.get("仓库")))>0){
            mapR.put("仓库",map.get("仓库"));

        }

        return mapR;
    }

    @Override
    public List<FbsWorkingStatistics> getWorkingHours() {
        return fbsWorkingStatisticsMapper.getWorkingHours();
    }

    @Override
    public List<FbsWorkshopDispatchList> getWorkingHoursGroupProjectName() {
        return fbsWorkingStatisticsMapper.getWorkingHoursGroupProjectName();
    }
}
