package com.bonus.sgzb.material.mapper;

import com.alibaba.fastjson.JSONObject;
import com.bonus.sgzb.base.api.domain.MaLabelBind;
import com.bonus.sgzb.base.api.domain.MaMachine;
import com.bonus.sgzb.base.api.domain.MaMachineLabel;
import com.bonus.sgzb.base.api.domain.MaType;
import com.bonus.sgzb.material.domain.InputApplyDetails;
import com.bonus.sgzb.base.api.domain.MaInputRecord;
import com.bonus.sgzb.base.api.domain.MachinePart;
import com.bonus.sgzb.material.domain.PurchaseMacodeInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 新购验收编号管理purchase_macode_infoMapper接口
 *
 * @author bonus
 * @date 2023-12-10
 */
@Mapper
public interface PurchaseMacodeInfoMapper {
    /**
     * 查询新购验收编号管理purchase_macode_info
     *
     * @param taskId 新购验收编号管理purchase_macode_info主键
     * @return 新购验收编号管理purchase_macode_info
     */
    public PurchaseMacodeInfo selectPurchaseMacodeInfoByTaskId(Long taskId);

    /**
     * 查询新购验收编号管理purchase_macode_info列表
     *
     * @param purchaseMacodeInfo 新购验收编号管理purchase_macode_info
     * @return 新购验收编号管理purchase_macode_info集合
     */
    public List<PurchaseMacodeInfo> selectPurchaseMacodeInfoList(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 新增新购验收编号管理purchase_macode_info
     *
     * @param purchaseMacodeInfo 新购验收编号管理purchase_macode_info
     * @return 结果
     */
    public int insertPurchaseMacodeInfo(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 修改新购验收编号管理purchase_macode_info
     *
     * @param purchaseMacodeInfo 新购验收编号管理purchase_macode_info
     * @return 结果
     */
    public int updatePurchaseMacodeInfo(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 删除新购验收编号管理purchase_macode_info
     *
     * @param taskId 新购验收编号管理purchase_macode_info主键
     * @return 结果
     */
    public int deletePurchaseMacodeInfoByTaskId(Long taskId);

    /**
     * 批量删除新购验收编号管理purchase_macode_info
     *
     * @param taskIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deletePurchaseMacodeInfoByTaskIds(Long[] taskIds);

    /**
     * 查询
     * @param typeId
     * @return
     */
    JSONObject getTypeByTypeId(long typeId);

    /**
     * 查询
     * @param typeId
     * @param nowDate
     * @return
     */

    int getSerialNumber(@Param("typeId") long typeId, @Param("nowDate") Date nowDate);

    /**
     * 查询
     * @param typeId
     * @return
     */
    JSONObject getTypeNameByTypeId(Long typeId);

    /**
     * 删除
     * @param id
     * @return
     */
    int deletePurchaseMacodeInfoById(Long id);

    /**
     * 查询
     * @param fixCode
     * @return
     */
    MaMachine selectMachineByAssetsCode(String fixCode);

    /**
     * 增加机具
     * @param maMachine
     * @return
     */
    int maMachineAdd(MaMachine maMachine);

    /**
     * 当全部为已入库的时候任务改为入库状态
     * @param taskId
     * @return
     */
    Integer selectMacodeInfoStatusByTaskId(Long taskId);

    /**
     * 插入
     * @param maInputRecord
     * @return
     */
    int insertMaInputRecord(MaInputRecord maInputRecord);

    /**
     * 查询
     * @param typeId
     * @return
     */
    MaType selectTypeByTypeId(Long typeId);

    /**
     * 修改
     * @param maType
     * @return
     */
    int updateTypeByTypeId(MaType maType);

    /**
     * 修改
     * @param maMachine
     * @return
     */
    int updateMaMachine(MaMachine maMachine);

    /**
     * 查询
     * @param codingRule
     * @return
     */
    int selectMachineByMaCode(String codingRule);

    /**
     * 根据机具编码删除编码
     * @param maCode
     * @return
     */
    int deletePurchaseMacodeInfoByMaCode(String maCode);

    /**
     * 根据机具编码删除编码
     * @param maCode
     * @return
     */
    int deleteMaMachineInfoByMaCode(String maCode);

    /**
     *根据类型id和任务id查询编码详情
     * @param purchaseMacodeInfo
     * @return
     */
    List<PurchaseMacodeInfo> selectPurchaseMacodeInfo(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 获取入库清单明细
     * @param purchaseMacodeInfo
     * @return
     */
    List<PurchaseMacodeInfo> selectPutinDetails(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 查询
     * @param maCode
     * @return
     */
    int selectMaCode(String maCode);

    /**
     * 修改
     * @param purchaseMacodeInfo
     * @return
     */
    int updateMacodeByType(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 查询
     * @param nowDate
     * @return
     */
    int selectLableNumByMonth(Date nowDate);

    /**
     * 插入
     * @param maMachineLabel
     * @return
     */
    int insertMaMachineLabel(MaMachineLabel maMachineLabel);

    /**
     * 插入
     * @param maLabelBind
     * @return
     */
    int insertMaLabelBind(MaLabelBind maLabelBind);

    /**
     * 插入
     * @param applyDetails
     * @return
     */
    int insertInputApplyDetails(InputApplyDetails applyDetails);

    /**
    * 删除ma_machine表
    * @param maId
    * @return 结果
    */
    int deleteMaMachineInfoByMaId(Long maId);

    /**
    * 删除purchase_macode_info表
    * @param taskId
    * @param typeId
    * @param maCode
    * @return
    */
    int updatetePurchaseMaCodeInfoByMaCodeAndTaskIdAndTypeId(@Param("taskId") Long taskId,@Param("typeId") Long typeId,@Param("maCode") String maCode);

    /**
    * 删除ma_machine_label表
    * @param maId
    * @return int
    */
    int deleteMaMachineLabelByMaId(Long maId);

    /**
    * 删除ma_label_bind表
    * @param maId
    * @return int
    */
    int deleteMaLabelBindByMaId(Long maId);

    /**
    * 新购入库单
    * @param purchaseMacodeInfo
    * @return  List<PurchaseMacodeInfo>
    */
    List<PurchaseMacodeInfo> warehousingEntry(PurchaseMacodeInfo purchaseMacodeInfo);

    List<PurchaseMacodeInfo> selectPutinDetailsAddTypeId(PurchaseMacodeInfo purchaseMacodeInfo);

    /**
     * 判断是否全部已操作（不通过或通过）
     * @param taskId
     * @return int
     */
    int isOperateAll(Long taskId);
    /**
     * 是否为全部不通过
     * @param taskId
     * @return
     */
    int selectPurchaseCheckDetailsStatus(Long taskId);

    int updateMaTypeNum(MachinePart wholeSetDetail);

    List<PurchaseMacodeInfo> selectPurchaseMacodeInfoListDetails(PurchaseMacodeInfo purchaseMacodeInfo);

    List<String> selectKeepUser(Integer typeId);

    int getCountOfMachineByTypeId(Long typeId);
}
