package com.sooka.system.medicine.plant.service.impl;


import com.sooka.common.core.text.Convert;
import com.sooka.common.utils.DateUtils;
import com.sooka.framework.util.ShiroUtils;
import com.sooka.system.medicine.plant.domain.TGuijiMedicinePlant;
import com.sooka.system.medicine.plant.mapper.TGuijiMedicinePlantMapper;
import com.sooka.system.medicine.plant.service.ITGuijiMedicinePlantService;
import com.sooka.system.service.impl.Guiji_Base_Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * 种植采集数Service业务层处理
 *
 * @author lei
 * @date 2022-08-22
 */
@Service
public class TGuijiMedicinePlantServiceImpl extends Guiji_Base_Service implements ITGuijiMedicinePlantService
{
    @Resource
    private TGuijiMedicinePlantMapper tGuijiMedicinePlantMapper;

    /**
     * 查询种植采集数
     *
     * @param id 种植采集数ID
     * @return 种植采集数
     */
    @Override
    public TGuijiMedicinePlant selectTGuijiMedicinePlantById(String id)
    {
        return tGuijiMedicinePlantMapper.selectTGuijiMedicinePlantById(id);
    }

    /**
     * 查询种植采集数列表
     *
     * @param tGuijiMedicinePlant 种植采集数
     * @return 种植采集数
     */
    @Override
    public List<TGuijiMedicinePlant> selectTGuijiMedicinePlantList(TGuijiMedicinePlant tGuijiMedicinePlant)
    {
        try{
            tGuijiMedicinePlant.setOperationStatus(1L);
            tGuijiMedicinePlant.setParam(tGuijiMedicinePlant.toString());
            tGuijiMedicinePlant.setInterfacetype("platform_interfacetype_1");//1 共享 2归集
            tGuijiMedicinePlant.setInterfaceinfoId("bc812f6e-8516-4177-aa3a-6332d6788d35");
            tGuijiMedicinePlant.setInterfaceinfoName("共享（市）-市医药-种植采集数");
            Long deptId = ShiroUtils.getSysUser().getDept().getDeptId();
            String deptName = ShiroUtils.getSysUser().getDept().getDeptName();
            tGuijiMedicinePlant.setDeptId(deptId);
            tGuijiMedicinePlant.setDeptName(deptName);
            return tGuijiMedicinePlantMapper.selectTGuijiMedicinePlantList(tGuijiMedicinePlant);
        }catch (Exception e){
            e.printStackTrace();
            tGuijiMedicinePlant.setOperationStatus(0L);
            tGuijiMedicinePlant.setExceptionLog(e.toString());
        }finally {
            add_log(tGuijiMedicinePlant);
        }
        return new ArrayList();
    }

    /**
     * 新增种植采集数
     *
     * @param tGuijiMedicinePlant 种植采集数
     * @return 结果
     */
    @Override
    public int insertTGuijiMedicinePlant(TGuijiMedicinePlant tGuijiMedicinePlant)
    {
        tGuijiMedicinePlant.setCreateTime(DateUtils.getNowDate());
        return tGuijiMedicinePlantMapper.insertTGuijiMedicinePlant(tGuijiMedicinePlant);
    }

    /**
     * 修改种植采集数
     *
     * @param tGuijiMedicinePlant 种植采集数
     * @return 结果
     */
    @Override
    public int updateTGuijiMedicinePlant(TGuijiMedicinePlant tGuijiMedicinePlant)
    {
        return tGuijiMedicinePlantMapper.updateTGuijiMedicinePlant(tGuijiMedicinePlant);
    }

    /**
     * 删除种植采集数对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTGuijiMedicinePlantByIds(String ids)
    {
        return tGuijiMedicinePlantMapper.deleteTGuijiMedicinePlantByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除种植采集数信息
     *
     * @param id 种植采集数ID
     * @return 结果
     */
    @Override
    public int deleteTGuijiMedicinePlantById(String id)
    {
        return tGuijiMedicinePlantMapper.deleteTGuijiMedicinePlantById(id);
    }
}
