package com.steerinfo.meterwork.meterworkbeltxiaopi.service.impl;

import com.steerinfo.baseinfo.combaseinfo.mapper.ComBaseInfoMapper;
import com.steerinfo.framework.mapper.IBaseMapper;
import com.steerinfo.framework.service.impl.BaseServiceImpl;
import com.steerinfo.meterwork.meterworkbeltxiaopi.mapper.MeterWorkBeltXiaopiMapper;
import com.steerinfo.meterwork.meterworkbeltxiaopi.model.MeterWorkBeltXiaopi;
import com.steerinfo.meterwork.meterworkbeltxiaopi.service.IMeterWorkBeltXiaopiService;
import com.steerinfo.util.CommonPage;
import org.springframework.stereotype.Service;

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

/**
 * MeterWorkBeltXiaopi服务实现：
 * @author generator
 * @version 1.0-SNAPSHORT 2021-11-06 11:04
 * 类描述
 * 修订历史：
 * 日期：2021-11-06
 * 作者：generator
 * 参考：
 * 描述：MeterWorkBeltXiaopi服务实现
 * @see null
 * @Copyright 湖南视拓信息技术股份有限公司. All rights reserved.
 */
@Service(value = "meterWorkBeltXiaopiService")
public class MeterWorkBeltXiaopiServiceImpl extends BaseServiceImpl<MeterWorkBeltXiaopi, String> implements IMeterWorkBeltXiaopiService {

    @Resource
    private MeterWorkBeltXiaopiMapper meterWorkBeltXiaopiMapper;

    @Resource
    private ComBaseInfoMapper comBaseInfoMapper;

    @Override
    protected IBaseMapper<MeterWorkBeltXiaopi, String> getMapper() {
        return meterWorkBeltXiaopiMapper;
    }


    @Override
    public int doAddWf(MeterWorkBeltXiaopi model) {
        String maxID = comBaseInfoMapper.getConfigID("METER_WORK_BELT_XIAOPI","CHECKBELT_NO");
        model.setCheckbeltNo(maxID);
        return meterWorkBeltXiaopiMapper.insertSelective(model);
    }

    @Override
    public List<MeterWorkBeltXiaopi> doQueryWf(CommonPage<MeterWorkBeltXiaopi> model) {
        HashMap<String, Object> obj = new HashMap<>();
        String str = "";
        if(model.getStartTime()!=null&&model.getEndTime()!=null){
            obj.put("startTime", model.getStartTime());
            obj.put("endTime", model.getEndTime());
        }
        if(model.getMemo1()!=null){
            str = model.getMemo1();
        }
        if (model.getParam().getBaseSpotNo() != null) {
            obj.put("baseSpotNo", model.getParam().getBaseSpotNo());
        }
        if(model.getParam().getScaleName()!=null){
            obj.put("scaleName", model.getParam().getScaleName());
        }
        if(str.equals("1")){
            return meterWorkBeltXiaopiMapper.doQueryWf(obj);
        }else if (str.equals("2")){
            return meterWorkBeltXiaopiMapper.doQueryWf_One(obj);
        }
        return null;
    }
}
