package com.chinaitop.depot.intelligent.fumigation.service.impl;

import com.chinaitop.depot.intelligent.fumigation.mapper.TFumigationPesticideMapper;
import com.chinaitop.depot.intelligent.fumigation.model.TFumigationPesticide;
import com.chinaitop.depot.intelligent.fumigation.model.TFumigationPesticideExample;
import com.chinaitop.depot.intelligent.fumigation.service.PesticidePlanService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author lvzhikai
 * @description: 施药管理
 * @create 2018-12-15 11:00
 */
@Service
public class PesiticidePlanServiceImpl implements PesticidePlanService {

    @Resource
    private TFumigationPesticideMapper tFumigationPesticideMapper;

    @Override
    public List<Map<String,Object>> getPesticidePlanList(Map<String, Object> map) {
        return tFumigationPesticideMapper.getPesticidePlanList(map);
    }

    @Override
    public List<Map<String,Object>> getPesticidePlanLists(Map<String, Object> map) {
        return tFumigationPesticideMapper.getPesticidePlanLists(map);
    }

    @Override
    public List<TFumigationPesticide> getFumigationPesticideList(TFumigationPesticideExample example) {
        return tFumigationPesticideMapper.selectByExample(example);
    }

    @Override
    public TFumigationPesticide findById(String pesticideId) {
        return tFumigationPesticideMapper.selectByPrimaryKey(pesticideId);
    }

    @Override
    public void add(TFumigationPesticide tFumigationPesticide) {
        tFumigationPesticideMapper.insert(tFumigationPesticide);
    }

    @Override
    public void update(TFumigationPesticide tFumigationPesticide) {
        tFumigationPesticideMapper.updateByPrimaryKeySelective(tFumigationPesticide);
    }

    @Override
    public void updateByExample(TFumigationPesticide tFumigationPesticide, TFumigationPesticideExample example) {
        tFumigationPesticideMapper.updateByExampleSelective(tFumigationPesticide, example);
    }

    /**
     * 提交
     */
    @Override
    public void submit(String id, Integer approvalStatus) {
        //施药修改审批状态
        TFumigationPesticide tFumigationPesticide = new TFumigationPesticide();

        tFumigationPesticide.setApproveTime(new Date());
        tFumigationPesticide.setState(approvalStatus);
        tFumigationPesticide.setId(id);
        // 修改.
        tFumigationPesticideMapper.updateByPrimaryKeySelective(tFumigationPesticide);
    }
}
