package com.seeyon.apps.src_flowIntegration.util;

import com.alibaba.fastjson.JSONObject;
import com.seeyon.apps.addressbook.po.AddressBook;
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
import www.seeyon.com.utils.StringUtil;

import java.text.SimpleDateFormat;

public class AddressBookUtil {

    public static JSONObject appleAddressBook(AddressBook addressBook, EnumManager enumManagerNew) throws BusinessException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        JSONObject jsonObject = new JSONObject();
        if(StringUtil.isNotEmpty(addressBook.getExtAttr1())){
            jsonObject.put("EXT_ATTR_1",addressBook.getExtAttr1());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr2())){
            jsonObject.put("EXT_ATTR_2",addressBook.getExtAttr2());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr3())){
            jsonObject.put("EXT_ATTR_3",addressBook.getExtAttr3());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr4())){
            jsonObject.put("EXT_ATTR_4",addressBook.getExtAttr4());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr5())){
            jsonObject.put("EXT_ATTR_5",addressBook.getExtAttr5());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr6())){
            jsonObject.put("EXT_ATTR_6",addressBook.getExtAttr6());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr7())){
            jsonObject.put("EXT_ATTR_7",addressBook.getExtAttr7());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr8())){
            jsonObject.put("EXT_ATTR_8",addressBook.getExtAttr8());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr9())){
            jsonObject.put("EXT_ATTR_9",addressBook.getExtAttr9());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr10())){
            jsonObject.put("EXT_ATTR_10",addressBook.getExtAttr10());
        }if( addressBook.getExtAttr11()!=null){
            jsonObject.put("EXT_ATTR_11",addressBook.getExtAttr11());
        }if( addressBook.getExtAttr12()!=null){
            jsonObject.put("EXT_ATTR_12",addressBook.getExtAttr12());
        }if(addressBook.getExtAttr13()!=null){
            jsonObject.put("EXT_ATTR_13",addressBook.getExtAttr13());
        }if(addressBook.getExtAttr14()!=null){
            jsonObject.put("EXT_ATTR_14",addressBook.getExtAttr14());
        }if(addressBook.getExtAttr15()!=null){
            jsonObject.put("EXT_ATTR_15",addressBook.getExtAttr15());
        }if(addressBook.getExtAttr16()!=null){
            jsonObject.put("EXT_ATTR_16",addressBook.getExtAttr16());
        }if(addressBook.getExtAttr17()!=null){
            jsonObject.put("EXT_ATTR_17",addressBook.getExtAttr17());
        }if(addressBook.getExtAttr18()!=null){
            jsonObject.put("EXT_ATTR_18",addressBook.getExtAttr18());
        }if(addressBook.getExtAttr19()!=null){
            jsonObject.put("EXT_ATTR_19",addressBook.getExtAttr19());
        }if(addressBook.getExtAttr20()!=null){
            jsonObject.put("EXT_ATTR_20",addressBook.getExtAttr20());
        }if(addressBook.getExtAttr21()!=null){
            jsonObject.put("EXT_ATTR_21",sdf.format(addressBook.getExtAttr21()));
        }if(addressBook.getExtAttr22()!=null){
            jsonObject.put("EXT_ATTR_22",sdf.format(addressBook.getExtAttr22()));
        }if(addressBook.getExtAttr23()!=null){
            jsonObject.put("EXT_ATTR_23",sdf.format(addressBook.getExtAttr23()));
        }if(addressBook.getExtAttr24()!=null){
            jsonObject.put("EXT_ATTR_24",sdf.format(addressBook.getExtAttr24()));
        }if(addressBook.getExtAttr25()!=null){
            jsonObject.put("EXT_ATTR_25",sdf.format(addressBook.getExtAttr25()));
        }if(addressBook.getExtAttr26()!=null){
            jsonObject.put("EXT_ATTR_26",sdf.format(addressBook.getExtAttr26()));
        }if(addressBook.getExtAttr27()!=null){
            jsonObject.put("EXT_ATTR_27",sdf.format(addressBook.getExtAttr27()));
        }if(addressBook.getExtAttr28()!=null){
            jsonObject.put("EXT_ATTR_28",sdf.format(addressBook.getExtAttr28()));
        }if(addressBook.getExtAttr29()!=null){
            jsonObject.put("EXT_ATTR_29",sdf.format(addressBook.getExtAttr29()));
        }if(addressBook.getExtAttr30()!=null){
            jsonObject.put("EXT_ATTR_30",sdf.format(addressBook.getExtAttr30()));
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr31())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr31()));
            jsonObject.put("EXT_ATTR_31",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr32())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr32()));
            jsonObject.put("EXT_ATTR_32",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr33())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr33()));
            jsonObject.put("EXT_ATTR_33",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr34())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr34()));
            jsonObject.put("EXT_ATTR_34",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr35())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr35()));
            jsonObject.put("EXT_ATTR_35",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr36())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr36()));
            jsonObject.put("EXT_ATTR_36",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr37())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr37()));
            jsonObject.put("EXT_ATTR_37",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr38())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr38()));
            jsonObject.put("EXT_ATTR_38",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr39())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr39()));
            jsonObject.put("EXT_ATTR_39",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr40())){
            CtpEnumItem ctpEnumItem = enumManagerNew.getCtpEnumItem(Long.parseLong(addressBook.getExtAttr40()));
            jsonObject.put("EXT_ATTR_40",ctpEnumItem.getShowvalue());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr41())){
            jsonObject.put("EXT_ATTR_41",addressBook.getExtAttr41());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr42())){
            jsonObject.put("EXT_ATTR_42",addressBook.getExtAttr42());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr43())){
            jsonObject.put("EXT_ATTR_43",addressBook.getExtAttr43());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr44())){
            jsonObject.put("EXT_ATTR_44",addressBook.getExtAttr44());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr45())){
            jsonObject.put("EXT_ATTR_45",addressBook.getExtAttr45());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr46())){
            jsonObject.put("EXT_ATTR_46",addressBook.getExtAttr46());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr47())){
            jsonObject.put("EXT_ATTR_47",addressBook.getExtAttr47());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr48())){
            jsonObject.put("EXT_ATTR_48",addressBook.getExtAttr48());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr49())){
            jsonObject.put("EXT_ATTR_49",addressBook.getExtAttr49());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr50())){
            jsonObject.put("EXT_ATTR_50",addressBook.getExtAttr50());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr51())){
            jsonObject.put("EXT_ATTR_51",addressBook.getExtAttr51());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr52())){
            jsonObject.put("EXT_ATTR_52",addressBook.getExtAttr52());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr53())){
            jsonObject.put("EXT_ATTR_53",addressBook.getExtAttr53());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr54())){
            jsonObject.put("EXT_ATTR_54",addressBook.getExtAttr54());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr55())){
            jsonObject.put("EXT_ATTR_55",addressBook.getExtAttr55());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr56())){
            jsonObject.put("EXT_ATTR_56",addressBook.getExtAttr56());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr57())){
            jsonObject.put("EXT_ATTR_57",addressBook.getExtAttr57());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr58())){
            jsonObject.put("EXT_ATTR_58",addressBook.getExtAttr58());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr59())){
            jsonObject.put("EXT_ATTR_59",addressBook.getExtAttr59());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr60())){
            jsonObject.put("EXT_ATTR_60",addressBook.getExtAttr60());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr61())){
            jsonObject.put("EXT_ATTR_61",addressBook.getExtAttr61());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr62())){
            jsonObject.put("EXT_ATTR_62",addressBook.getExtAttr62());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr63())){
            jsonObject.put("EXT_ATTR_63",addressBook.getExtAttr63());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr64())){
            jsonObject.put("EXT_ATTR_64",addressBook.getExtAttr64());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr65())){
            jsonObject.put("EXT_ATTR_65",addressBook.getExtAttr65());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr66())){
            jsonObject.put("EXT_ATTR_66",addressBook.getExtAttr66());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr67())){
            jsonObject.put("EXT_ATTR_67",addressBook.getExtAttr67());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr68())){
            jsonObject.put("EXT_ATTR_68",addressBook.getExtAttr68());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr69())){
            jsonObject.put("EXT_ATTR_69",addressBook.getExtAttr69());
        }if(StringUtil.isNotEmpty(addressBook.getExtAttr70())){
            jsonObject.put("EXT_ATTR_70",addressBook.getExtAttr70());
        }
        return jsonObject;
    }


}
