PoiEL.java 1.2 KB
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.lhcredit.common.utils.StringUtils;
import com.lhcredit.project.business.reportMake.ReportMakeService;

import java.util.List;
import java.util.Map;

public class PoiEL {
    public  String map(Object object){
        return map(object,null);
    }
    public  String map(Object object ,String fieldName){
        if (null==object){
            return ReportMakeService.no_data;
        }
        if (object instanceof String){
            return StringUtils.isNotEmpty(object.toString())?object.toString(): ReportMakeService.no_data;
        }
        if (object instanceof List ||object instanceof JSONArray){
            return ReportMakeService.no_data;
        }
        JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object));
        if (!jsonObject.containsKey(fieldName)){
            return ReportMakeService.no_data;
        } else if (StringUtils.isEmpty(jsonObject.getString(fieldName))) {
            return ReportMakeService.no_data;
        } else{
            return jsonObject.getString(fieldName);
        }
    }
    public  String test(){
        return ReportMakeService.no_data;
    }


}