package com.fidms.web.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.fidms.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fidms.web.mapper.FlowFieldInputMapper;
import com.fidms.web.domain.FlowFieldInput;
import com.fidms.web.service.IFlowFieldInputService;

import static java.lang.Math.*;

/**
 * 流场输入Service业务层处理
 * 
 * @author Allen
 * @date 2023-05-08
 */
@Service
public class FlowFieldInputServiceImpl implements IFlowFieldInputService 
{
    @Autowired
    private FlowFieldInputMapper flowFieldInputMapper;

    /**
     * 查询流场输入
     * 
     * @param id 流场输入主键
     * @return 流场输入
     */
    @Override
    public FlowFieldInput selectFlowFieldInputById(Long id)
    {
        return flowFieldInputMapper.selectFlowFieldInputById(id);
    }

    /**
     * 查询流场输入列表
     * 
     * @param flowFieldInput 流场输入
     * @return 流场输入
     */
    @Override
    public List<FlowFieldInput> selectFlowFieldInputList(FlowFieldInput flowFieldInput)
    {
        return flowFieldInputMapper.selectFlowFieldInputList(flowFieldInput);
    }

    /**
     * 新增流场输入
     * 
     * @param flowFieldInput 流场输入
     * @return 结果
     */
    @Override
    public int insertFlowFieldInput(FlowFieldInput flowFieldInput)
    {
        flowFieldInput.setTemperatureAndPressureAndDensityByFlightAltitude();
        flowFieldInput.getFlowVelocity();

        flowFieldInput.setCreateTime(DateUtils.getNowDate());
        flowFieldInput.setUpdateTime(DateUtils.getNowDate());
        return flowFieldInputMapper.insertFlowFieldInput(flowFieldInput);
    }

    /**
     * 修改流场输入
     * 
     * @param flowFieldInput 流场输入
     * @return 结果
     */
    @Override
    public int updateFlowFieldInput(FlowFieldInput flowFieldInput)
    {
        flowFieldInput.setTemperatureAndPressureAndDensityByFlightAltitude();     //先执行，可得温度
        flowFieldInput.getFlowVelocity();                                         //再执行该函数，依据温度等参数计算流速

        flowFieldInput.setUpdateTime(DateUtils.getNowDate());
        return flowFieldInputMapper.updateFlowFieldInput(flowFieldInput);
    }

    /**
     * 批量删除流场输入
     * 
     * @param ids 需要删除的流场输入主键
     * @return 结果
     */
    @Override
    public int deleteFlowFieldInputByIds(Long[] ids)
    {
        return flowFieldInputMapper.deleteFlowFieldInputByIds(ids);
    }

    /**
     * 删除流场输入信息
     * 
     * @param id 流场输入主键
     * @return 结果
     */
    @Override
    public int deleteFlowFieldInputById(Long id)
    {
        return flowFieldInputMapper.deleteFlowFieldInputById(id);
    }

    @Override
    public List getFlowFieldInputList()
    {
        return flowFieldInputMapper.getFlowFieldInputList();
    }
}
