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

import com.steerinfo.baseinfo.meterbasematterunitmixedloadunloadtime.mapper.MeterBaseMatterUnitMixedLoadUnloadTimeMapper;
import com.steerinfo.baseinfo.meterbasematterunitmixedloadunloadtime.model.MeterBaseMatterUnitMixedLoadUnloadTime;
import com.steerinfo.baseinfo.meterbasematterunitmixedloadunloadtime.service.IMeterBaseMatterUnitMixedLoadUnloadTimeService;
import com.steerinfo.framework.controller.RESTfulResult;
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.util.HashMap;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

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

    @Autowired
    private MeterBaseMatterUnitMixedLoadUnloadTimeMapper meterBaseMatterUnitMixedLoadUnloadTimeMapper;

    @Override
    protected IBaseMapper<MeterBaseMatterUnitMixedLoadUnloadTime, String> getMapper() {
        return meterBaseMatterUnitMixedLoadUnloadTimeMapper;
    }

    @Override
    public int updateSelect(MeterBaseMatterUnitMixedLoadUnloadTime model) {
        int i = meterBaseMatterUnitMixedLoadUnloadTimeMapper.updateByPrimaryKeySelective(model);
        return i;
    }

    @Override
    public RESTfulResult insertSelect(MeterBaseMatterUnitMixedLoadUnloadTime model) {
        RESTfulResult resTfulResult = new RESTfulResult();
        HashMap <String,Object> queryCon = new HashMap<>();
        queryCon.put("matterNo",model.getMatterNo());
        queryCon.put("matterName",model.getMatterName());
        queryCon.put("customerSupplierName",model.getCustomerSupplierName());
        queryCon.put("customerSupplierNo",model.getCustomerSupplierNo());
        queryCon.put("validFlag","1");
        queryCon.put("isloadUnload",model.getIsloadUnload());
        List<MeterBaseMatterUnitMixedLoadUnloadTime> lists = meterBaseMatterUnitMixedLoadUnloadTimeMapper.selectByParameters(queryCon);
        if(lists.size()>0){
            resTfulResult.setFailed();
            resTfulResult.setMessage("存在相同数据！");
            return resTfulResult;
        }
        int i = meterBaseMatterUnitMixedLoadUnloadTimeMapper.insertSelective(model);
        resTfulResult.setSucceed();
        resTfulResult.setData(model);
        return resTfulResult;
    }
}
