package cn.com.countrygarden.bi.main.service.financial;

import cn.com.countrygarden.bi.main.model.financial.PLByMonth;
import cn.com.countrygarden.bi.main.model.financial.PLByProject;
import cn.com.countrygarden.bi.main.model.financial.Reason;
import cn.com.countrygarden.bi.main.model.financial.dto.InCome;
import cn.com.countrygarden.bi.main.model.twerp.ErpNcData;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @Atuhor: Geoffrey
 * @Description: 财务报表
 * @Date: Create in 15:36 2018/7/30
 * @ModifedBy:
 */
public interface FinancialService {
    /**
     * 返回给前端的PLByMonth对象
     *
     * @param year       年份
     * @param startMonth 起始期间
     * @param endMonth   结束期间
     * @param userType   用户类型
     * @return
     * @Author: Geoffrey
     * @Date: 2018年8月21日 11点26分
     */
    List<PLByMonth> getPLByMonth(String organCode, String commId, String year, int startMonth, int endMonth, int userType, int buildingType);

    List<PLByProject> getPLByProject(String organCode, String commId, String year, int userType);

    JSONObject getPLByProfit(String organCode, String year);

    void saveReasonList(List<Reason> reasonList);

    void exportPL(HttpServletResponse response, String organCode, String year, int startMonth, int endMonth, int userType, String commId, int exportType);


    /**
     * ERP收入流水库数据量太大，需要缓存
     * <p>
     * save、get方法 当organCode 传null时，为全部区域数据，即总部数据
     *
     * @param year
     * @param startMonth
     * @param endMonth
     * @param organCode
     * @return
     * @author Geoffrey
     */
    List<InCome> getErpDataFromRedis(String year, int startMonth, int endMonth, String organCode, String commId, int userType, int buildingType);

    void saveErpDataToRedis(String year, String organCode) throws Exception;

    void deleteErpDataFromRedis(String year, String organCode);

    List<InCome> getERPIncomeData(String year, Integer startMonth, Integer endMonth, List<ErpNcData> erpNcDataList, Integer userType, Integer buildingType);

    Map<Integer, Map<Integer, Map<String, String>>> handleERPTONCData(Integer year, Integer startMonth, Integer endMonth, String code, List<Integer> commIDList, Integer buildingType);

    JSONObject getArea(List<String> commIdList, Integer year, Integer startMonth, Integer endMonth);
}
