/**
 * Created by zhang on 2018/6/7.
 */
const fs = require('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,
    getGljTypeSeq:getGljTypeSeq,
    sortRationGLJ:sortRationGLJ,
    getEngineerCostData:getEngineerCostData,
    getEconomicDatas:getEconomicDatas,
    getMainMaterialDatas:getMainMaterialDatas,
    getQuantityDatas:getQuantityDatas,
    getTenderPriceCoe:getTenderPriceCoe,
    getPriceCoeDatas:getPriceCoeDatas,
    getPirceInfoDatas: getPirceInfoDatas,
};

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,tenderCoe, isReport) {
    return gljNodeUtil.getGLJPrice(glj,projectGLJDatas,calcOptions,labourCoeDatas,decimalObj,isRadio,_,scMathUtil,tenderCoe, isReport);
}

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

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 getGljTypeSeq() {
    return gljNodeUtil.getGljTypeSeq();
}

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

function getEngineerCostData(property,bills,fixedFlag,scMathUtil) {
    return gljNodeUtil.getEngineerCostData(property,bills,fixedFlag,scMathUtil);
}

function getEconomicDatas(engineerFeatures,economics,bills,fixedFlag,_,scMathUtil,decimal) {
    return gljNodeUtil.getEconomicDatas(engineerFeatures,economics,bills,fixedFlag,_,scMathUtil,decimal);
}

function getMainMaterialDatas(projectProperty,engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil) {
    return gljNodeUtil.getMainMaterialDatas(projectProperty,engineerFeatures,materials,projectGLJData,calcOptions,decimalObj,isRadio,_,scMathUtil);
}

function getQuantityDatas(engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,decimal) {
    return gljNodeUtil.getQuantityDatas(engineerFeatures,mainQuantities,billsList,fixedFlag,_,scMathUtil,decimal);
}

function getTenderPriceCoe(glj,tproperty){
  return gljNodeUtil.getTenderPriceCoe(glj,tproperty);
}

function getPriceCoeDatas(pgljList, contractorList, totalFee, tprojectProperty,_,scMathUtil){
   return gljNodeUtil.getPriceCoeDatas(pgljList, contractorList, totalFee, tprojectProperty,_,scMathUtil);
}

function getPirceInfoDatas(projectGLJList, contractor_list, labourCoeDatas, projectProperty, _, scMathUtil) {
    return gljNodeUtil.getPirceInfoDatas(projectGLJList, contractor_list, labourCoeDatas, projectProperty, _, scMathUtil);
}