package com.foreverwin.mesnac.meapi.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.foreverwin.mesnac.meapi.model.CustomFields;
import com.baomidou.mybatisplus.extension.service.IService;
import com.foreverwin.modular.core.util.FrontPage;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务类
 * </p>
 *
 * @author LZP
 * @since 2021-06-01
 */
public interface CustomFieldsService extends IService<CustomFields> {

    /**
     *  分页查询
     * @param frontPage
     * @return
     */
    IPage<CustomFields> selectPage(FrontPage<CustomFields> frontPage, CustomFields customFields);

    List<CustomFields> selectList(CustomFields customFields);


    /**
     * 查找自定义数据
     * @param customFields
     * @return
     */
    CustomFields selectOne(CustomFields customFields);

    /**
     * @Author zero
     * 查询自定义数据
     * @return
     */
    String getCustomFieldsValue(String handle, String attribute);

    /**
     * 查询机型
     * @param site
     * @param resourceType
     * @return
     */
    List<Map<String,Object>> getEquipType(String site, String resourceType);

    /**
     * @Author zero
     * 查询自定义数据
     * @param handle 必需
     * @param attribute 非必需
     * @return
     */
    List<CustomFields> getCustomFields(String handle, String attribute);

    /**
     * 查找自定义数据
     * @param handle
     * @return
     */
    List<CustomFields> getCustomFieldsByHandle(String handle);

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    void setCustomWithNewTransaction(String handle, String attribute, String value);

    /**
     * 更改自定义数据
     * @param handle
     * @param attribute
     * @param value
     */
    void setCustom(String handle, String attribute, String value);

    /**
     * 查询物料组维护的打印模板
     * @param sfcBo
     * @return
     */
    Map<String, Object> getItemGroupPrintTemplate(String sfcBo);

    /**
     * 查询物料组维护的打印模板
     * @param itemBo
     * @return
     */
    Map<String, Object> getItemGroupPrintTemplateByItemBo(String itemBo);

    /**
     * 查询分条前物料的宽度
     * @param itemBo
     * @return
     */
    String selectWidthValue(String site, String itemBo);

    String selectAttributeByItemBo(String itemBo);


    /**
     * 批量保存、更新自定义字段
     *
     * @param customFieldsList
     */
    void saveOrUpdateCustomFields(List<CustomFields> customFieldsList);
}