package com.steerinfo.ems.bfhyd.service.impl;

import com.steerinfo.ems.bfhyd.mapper.BfhydMapper;
import com.steerinfo.ems.bfhyd.model.Bfhyd;
import com.steerinfo.ems.bfhyd.service.IBfhydService;
import com.steerinfo.feigen.service.BfhydFeigenService;
import com.steerinfo.framework.controller.RESTfulResult;
import com.steerinfo.framework.datasource.DataSourceKey;
import com.steerinfo.framework.datasource.TargetDataSource;
import com.steerinfo.framework.mapper.IBaseMapper;
import com.steerinfo.framework.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.annotation.Target;
import java.util.Date;
import java.math.BigDecimal;
import java.util.List;

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

    @Autowired
    private BfhydMapper bfhydMapper;
    @Autowired
    private BfhydFeigenService bfhydFeigenService;

    @Override
    protected IBaseMapper<Bfhyd, String> getMapper() {
        return bfhydMapper;
    }

    //获取最新的数据
    public  void getBfhyds(){
        List<Bfhyd> all = bfhydFeigenService.getAll();
        if (all.size()>0) {
            for (Bfhyd bfhyd : all) {
                Bfhyd modle =  new Bfhyd();
                modle.setBfhydZjdh(bfhyd.getBfhydZjdh());
                modle.setBfhydHyrq(bfhyd.getBfhydHyrq());
                modle.setBfhydSyrq(bfhyd.getBfhydSyrq());
                modle.setBfhydZjr(bfhyd.getBfhydZjr());
                modle.setBfhyd01(bfhyd.getBfhyd01());
                modle.setBfhyd02(bfhyd.getBfhyd02());
                modle.setBfhyd03(bfhyd.getBfhyd03());
                modle.setBfhyd04(bfhyd.getBfhyd04());
                modle.setBfhyd05(bfhyd.getBfhyd05());
                modle.setBfhyd06(bfhyd.getBfhyd06());
                modle.setBfhyd07(bfhyd.getBfhyd07());
                modle.setBfhyd08(bfhyd.getBfhyd08());
                modle.setBfhyd09(bfhyd.getBfhyd09());
                modle.setBfhyd10(bfhyd.getBfhyd10());
                modle.setBfhyd11(bfhyd.getBfhyd11());
                modle.setBfhyd12(bfhyd.getBfhyd12());
                modle.setBfhyd26(bfhyd.getBfhyd26());
                modle.setBfhyd27(bfhyd.getBfhyd27());
                modle.setTs(bfhyd.getTs());
                Bfhyd bfhyd1 = bfhydMapper.selectByPrimaryKey(bfhyd.getBfhydZjdh());
                if (bfhyd1 != null ) {
                    bfhydMapper.updateByPrimaryKeySelective(modle);
                }else {
                    bfhydMapper.insert(modle);
                }
            }
        }
    }

    @Override
    public List<Bfhyd> getnewNo(String startTime) {
        return bfhydMapper.getnewNo(startTime);
    }

}
