package com.steerinfo.baseinfo.meterbaserailwaycarriageweight.service.impl;

import com.steerinfo.framework.mapper.IBaseMapper;
import com.steerinfo.framework.service.impl.BaseServiceImpl;
import com.steerinfo.baseinfo.meterbaserailwaycarriageweight.model.MeterBaseRailwayCarriageWeight;
import com.steerinfo.baseinfo.meterbaserailwaycarriageweight.mapper.MeterBaseRailwayCarriageWeightMapper;
import com.steerinfo.baseinfo.meterbaserailwaycarriageweight.service.IMeterBaseRailwayCarriageWeightService;
import com.steerinfo.framework.service.pagehelper.PageHelper;
import com.steerinfo.framework.service.pagehelper.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

    @Resource
    private MeterBaseRailwayCarriageWeightMapper meterBaseRailwayCarriageWeightMapper;

    @Override
    protected IBaseMapper<MeterBaseRailwayCarriageWeight, String> getMapper() {
        return meterBaseRailwayCarriageWeightMapper;
    }

    @Override
    public String creatId() {
        String id =   new SimpleDateFormat("yyyyMMdd").format(new Date()) + meterBaseRailwayCarriageWeightMapper.GetNewID();
        //System.out.println(id);
        return id;
    }

    @Override
    public PageList<MeterBaseRailwayCarriageWeight> queryByTimeForPage(HashMap map, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<MeterBaseRailwayCarriageWeight> rows = meterBaseRailwayCarriageWeightMapper.queryByTime(map);
        PageList pageInfo = new PageList(rows);
        return pageInfo;
    }

    @Override
    public void deleteByLogic(MeterBaseRailwayCarriageWeight meterBaseRailwayCarriageWeight) {
        meterBaseRailwayCarriageWeightMapper.updateByPrimaryKeySelective(meterBaseRailwayCarriageWeight);
    }

    @Override
    public MeterBaseRailwayCarriageWeight queryById(String id) {
        return meterBaseRailwayCarriageWeightMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<MeterBaseRailwayCarriageWeight> queryList(HashMap<String, Object> map) {
        return meterBaseRailwayCarriageWeightMapper.queryByTime(map);
    }

}
