/**
 * Created by zhang on 2018/6/7.
 */
import fs from 'fs';
let _= require('lodash');
const scMathUtil = require('./scMathUtil').getUtil();

let gljNodeUtil = null;
let data = fs.readFileSync(__dirname + '/web/gljUtil.js', 'utf8', 'r');
eval(data + ' ; gljNodeUtil = gljUtil; ');

module.exports = {
    calcProjectGLJQuantity :calcProjectGLJQuantity,
    getGLJPrice:getGLJPrice,
    calcPriceDiff:calcPriceDiff,
    getMarketPrice:getMarketPrice,
    getBasePrice:getBasePrice,
    getAdjustPrice:getAdjustPrice,
    getMainType:getMainType,
    isConcreteType:isConcreteType,
    isCommercialConcreteType:isCommercialConcreteType,
    getIndex:getIndex,
    sortRationGLJ:sortRationGLJ,
    sortProjectGLJ:sortProjectGLJ,
    getCCSProjectGLJ:getCCSProjectGLJ,
    getBaseCCSMixRatio:getBaseCCSMixRatio,
    setMaterialCalcRationFee:setMaterialCalcRationFee
};

function calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal) {
    gljNodeUtil.calcProjectGLJQuantity(projectGLJDatas,rationGLJDatas,rationDatas,billsDatas,q_decimal,_,scMathUtil);
}

function getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false) {
    return gljNodeUtil.getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
}

function setMaterialCalcRationFee(ration,ration_gljs,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,_,scMathUtil) {
    return gljNodeUtil.setMaterialCalcRationFee(ration,ration_gljs,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,_,scMathUtil);
}

function getMarketPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false) {
    return gljNodeUtil.getMarketPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
}

function getBasePrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false) {
    return gljNodeUtil.getBasePrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
}

function getAdjustPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio=false,_,scMathUtil) {
    return gljNodeUtil.getAdjustPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil);
}

function calcPriceDiff(glj,calcOptions) {
    gljNodeUtil.calcPriceDiff(glj,calcOptions);
}

function getMainType() {
    return gljNodeUtil.getMainType();
}
function getIndex(obj, pops) {
    return gljNodeUtil.getIndex(obj, pops);
}

function isConcreteType(type) {
    return gljNodeUtil.isConcreteType(type);
}

function isCommercialConcreteType(type){
    return gljNodeUtil.isCommercialConcreteType(type);
}

function sortRationGLJ(list, std) {
    return gljNodeUtil.sortRationGLJ(list, std);
}

function sortProjectGLJ(list,lodash) {
    return gljNodeUtil.sortProjectGLJ(list,lodash);
}

function getCCSProjectGLJ(unitFileID,project_id) {
    return gljNodeUtil.getCCSProjectGLJ(unitFileID,project_id);
}

function getBaseCCSMixRatio(unitFileID,consumption,connect_key) {
    return gljNodeUtil.getBaseCCSMixRatio(unitFileID,consumption,connect_key)
}