package com.chinaitop.depot.intelligent.grainsituation.service.impl;

import com.chinaitop.depot.intelligent.grainsituation.mapper.TTestdataMapper;
import com.chinaitop.depot.intelligent.grainsituation.service.TPointsService;
import com.chinaitop.depot.intelligent.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

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

/**
 * @author qingsong.han
 * @description: 点粮情
 * 温度, X: 测温点在仓内的X坐标代表长度 代表列
 * Y: 测温点在仓内的Y坐标宽度方向 代表行
 * Z: 测温点在仓内的Z坐标高度
 * @create 2019-01-12 10:55
 */
@Service
public class TPointsServiceImpl implements TPointsService {

    @Resource
    private TTestdataMapper tTestdataMapper;

    @Override
    public List<Map<String, Object>> getGrainPointAll(String storehouse, String time, String id, String orgId) {
        Map<String, Object> map = new HashMap<>();
        if (StringUtils.isNotBlank(orgId)) {
            map.put("orgId", orgId);
        }
        if (StringUtils.isNotBlank(storehouse)) {
            map.put("tHouse", storehouse);
        }
        if (StringUtils.isNotBlank(time)) {
            map.put("startTime", time + DateUtils.startTime);
            map.put("endTime", time + DateUtils.endTime);
        } else {
            map.put("startTime", DateUtils.formatDate(DateUtils.getDate()) + DateUtils.startTime);
            map.put("endTime", DateUtils.formatDate(DateUtils.getDate()) + DateUtils.endTime);
        }
        List list =new ArrayList();
        if(StringUtils.isNotBlank(id)) {
            String[] split = id.split(",");
            for (String s : split) {
                list.add(s);
            }
            map.put("lqIds", list);
        }
        return tTestdataMapper.getGrainPointAll(map);
    }
}
