/**
 * Copyright &copy; 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.sg.financial.expense.service;

import com.jeeplus.common.utils.StringUtils;
import com.jeeplus.core.persistence.Page;
import com.jeeplus.core.service.CrudService;
import com.jeeplus.modules.sg.audit.information.entity.Information;
import com.jeeplus.modules.sg.audit.information.service.InformationService;
import com.jeeplus.modules.sg.financial.erpcredit.entity.ErpCredit;
import com.jeeplus.modules.sg.financial.erpcredit.entity.ErpCreditEquipment;
import com.jeeplus.modules.sg.financial.erpcredit.entity.ErpCreditMaterial;
import com.jeeplus.modules.sg.financial.erpcredit.entity.ErpJudge;
import com.jeeplus.modules.sg.financial.erpcredit.mapper.ErpCreditEquipmentMapper;
import com.jeeplus.modules.sg.financial.erpcredit.mapper.ErpCreditMapper;
import com.jeeplus.modules.sg.financial.erpcredit.mapper.ErpCreditMaterialMapper;
import com.jeeplus.modules.sg.financial.erpcredit.util.ErpInfo;
import com.jeeplus.modules.sg.financial.erpcredit.util.ExportTemplate;
import com.jeeplus.modules.sg.financial.erpcredit.util.ExportUtil;
import com.jeeplus.modules.sg.financial.expense.entity.Expense;
import com.jeeplus.modules.sg.financial.expense.mapper.ExpenseMapper;
import com.jeeplus.modules.sg.financial.settlement.entity.MaintainData;
import com.jeeplus.modules.sg.financial.settlement.mapper.DataMaintenanceMapper;
import com.jeeplus.modules.sg.financial.settlement.service.DataMaintenanceService;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;


@Service
@Transactional(readOnly = true)
public class ExpenseService extends CrudService<ExpenseMapper, Expense> {
    @Autowired
    private ExpenseMapper expenseMapper;

    @Override
    public Expense get(String id) {
        return super.get(id);
    }

    @Override
    public List<Expense> findList(Expense entity) {
        return super.findList(entity);
    }

    @Override
    public List<Expense> findListBy(List<Expense> entity) {
        return super.findListBy(entity);
    }

    @Override
    public Page<Expense> findPage(Page<Expense> page, Expense entity) {
        return super.findPage(page, entity);
    }

    @Override
    public void save(Expense entity) {
        super.save(entity);
    }

    @Override
    public void delete(Expense entity) {
        super.delete(entity);
    }

    @Transactional(readOnly = false)
    public void deleteDatas(List<String> ids){
        expenseMapper.deleteDatas(ids);
    }

    @Transactional(readOnly = false)
    public void insertData(Expense expense) {
        expense.preInsert();
        expenseMapper.insertData(expense);

    }

    @Transactional(readOnly = false)
    public void updateData(Expense expense) {
        expenseMapper.updateData(expense);
    }

    public Expense selectByProjectId(String projectId) {
        return expenseMapper.selectByProjectId(projectId);
    }

    @Transactional(readOnly = false)
    public void insertList(@Param("expense") List<Expense> expenseList) {
        for (Expense e : expenseList) {
            e.preInsert();
        }
        expenseMapper.insertList(expenseList);
    }

    /**
     * 根据id查找相应费用入账信息
     * @param strings
     * @return
     */
    public List<Expense> getFindListMain(List<String> strings){
        return expenseMapper.findListMain(strings);
    }
}