package com.mvc.service.aihcxd;

import com.mvc.dao.TAiTargetboxMapper;
import com.mvc.entity.TAiTargetbox;
import com.mvc.utils.NumberUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class TAiTargetBoxService {

    @Autowired(required = false)
    private TAiTargetboxMapper tAiTargetBoxMapper;

    public TAiTargetbox saveTAiTargetBox(TAiTargetbox targetBox) {
        if(targetBox.getTargetclass()!=null){
            targetBox.setTargetclass(NumberUtil.getDoubleScale(targetBox.getTargetclass(),2));
        }

        targetBox.setConf(NumberUtil.getDoubleScale(targetBox.getConf(),2));
        targetBox.setXmin(NumberUtil.getDoubleScale(targetBox.getXmin(),2));
        targetBox.setYmin(NumberUtil.getDoubleScale(targetBox.getYmin(),2));
        targetBox.setXmax(NumberUtil.getDoubleScale(targetBox.getXmax(),2));
        targetBox.setYmax(NumberUtil.getDoubleScale(targetBox.getYmax(),2));
        if(targetBox.getIsvalid()!=null){
            targetBox.setIsvalid(NumberUtil.getDoubleScale(targetBox.getIsvalid(),2));
        }

        int insert = tAiTargetBoxMapper.insert(targetBox);
        targetBox.setId(targetBox.getId());
        return targetBox;
    }
}
