package com.steerinfo.meterwork.meterworkbelttiminginfo.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.meterworkbelttiminginfo.mapper.MeterWorkBeltTiminginfoMapper;
import com.steerinfo.meterwork.meterworkbelttiminginfo.model.MeterWorkBeltTiminginfo;
import com.steerinfo.meterwork.meterworkbelttiminginfo.service.IMeterWorkBeltTiminginfoService;
import com.steerinfo.util.CommonPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

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

    @Resource
    private MeterWorkBeltTiminginfoMapper meterWorkBeltTiminginfoMapper;

    @Resource
    private ComBaseInfoMapper comBaseInfoMapper;

    @Override
    protected IBaseMapper<MeterWorkBeltTiminginfo, String> getMapper() {
        return meterWorkBeltTiminginfoMapper;
    }

    @Override
    public List<MeterWorkBeltTiminginfo> doQueryWf(CommonPage<MeterWorkBeltTiminginfo> model) {
        HashMap<String, Object> obj = new HashMap<>();
        obj.put("startTime", model.getStartTime());
        obj.put("endTime", model.getEndTime());
        if (model.getParam() != null) {
            obj.put("baseSpotNo", model.getParam().getBaseSpotNo());
            obj.put("scaleName", model.getParam().getScaleName());
            obj.put("valueFlag", model.getParam().getValueFlag());
            obj.put("weightType", model.getParam().getWeightType());
        }
        return meterWorkBeltTiminginfoMapper.doQueryWf(obj);
    }

    @Override
    public int doAddWf(MeterWorkBeltTiminginfo model) {
        String maxID = comBaseInfoMapper.getConfigIDByFive("METER_WORK_BELT_TIMINGINFO","TIMING_NO");
        model.setTimingNo(maxID);
        return meterWorkBeltTiminginfoMapper.insertSelective(model);
    }
}
