|  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | import com.doumee.dao.business.vo.UnitCodeVo; | 
 |  |  | import com.fasterxml.jackson.annotation.JsonInclude; | 
 |  |  | import com.fasterxml.jackson.core.JsonProcessingException; | 
 |  |  | import com.fasterxml.jackson.databind.ObjectMapper; | 
 |  |  | import com.fasterxml.jackson.databind.PropertyNamingStrategy; | 
 |  |  | import okhttp3.OkHttpClient; | 
 |  |  | import okhttp3.Request; | 
 |  |  | import okhttp3.Response; | 
 |  |  | import org.apache.commons.collections4.CollectionUtils; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.apache.http.client.methods.CloseableHttpResponse; | 
 |  |  | import org.apache.http.client.methods.HttpGet; | 
 |  |  | import org.apache.http.client.utils.URIBuilder; | 
 |  |  | import org.apache.http.impl.client.CloseableHttpClient; | 
 |  |  | import org.apache.http.impl.client.HttpClients; | 
 |  |  | import org.apache.http.util.EntityUtils; | 
 |  |  |  | 
 |  |  | import java.io.ByteArrayInputStream; | 
 |  |  | import java.io.ByteArrayOutputStream; | 
 |  |  | import java.io.IOException; | 
 |  |  | import java.io.InputStream; | 
 |  |  | import java.math.BigDecimal; | 
 |  |  | import java.net.URI; | 
 |  |  | import java.net.URLDecoder; | 
 |  |  | import java.text.SimpleDateFormat; | 
 |  |  | import java.util.*; | 
 |  |  | 
 |  |  |     public static final String HK_ROOTORG_CODE ="HK_ROOTORG_CODE" ; | 
 |  |  |     public static final String HK_ROOTORG_NAME ="HK_ROOTORG_NAME" ; | 
 |  |  |     public static final String REDIS_TOKEN_KEY = "token_"; | 
 |  |  |     public static final String CUSTOMER = "CUSTOMER"; | 
 |  |  |     public static final String BUSINESS = "BUSINESS"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     //被拜访人信息校验方式(0手机号单独校验 1手机号和姓名组合校验) | 
 |  |  |     public static final String ZBOM_CRM_AUTH_API_KEY = "ZBOM_CRM_AUTH_API_KEY"; | 
 |  |  |     public static final String BEVISITED_USER_VALID = "BEVISITED_USER_VALID"; | 
 |  |  |     public static final String LW_BEVISITED_USER_VALID = "LW_BEVISITED_USER_VALID"; | 
 |  |  |     public static final String SELECT_DOORS_VISIT_REQUIRED = "SELECT_DOORS_VISIT_REQUIRED"; | 
 |  |  | 
 |  |  |     public static final String FILE_DIR = ""; | 
 |  |  |     public static final String INITIAL_PASSWORD = "INITIAL_PASSWORD"; | 
 |  |  |     public static final String VALIDATE_VISIT = "VALIDATE_VISIT"; | 
 |  |  |     public static final String PLATFORM = "mp-weixin"; | 
 |  |  |  | 
 |  |  |     // 访客来访配置 | 
 |  |  |     public static final String VISIT_CONFIG = "VISIT_CONFIG"; | 
 |  |  | 
 |  |  |     public static final String ZBOM = "ZBOM" ; | 
 |  |  |     public static final String ZBOM_IAM_APPKEY = "ZBOM_IAM_APPKEY"; | 
 |  |  |     public static final String ZBOM_IAM_APPID = "ZBOM_IAM_APPID"; | 
 |  |  |     public static final String USER_CARD_HEADER_IMG ="USER_CARD_HEADER_IMG" ; | 
 |  |  |     public static final String USER_CARD_PHONE_IMG ="USER_CARD_PHONE_IMG" ; | 
 |  |  |     public static final String USER_CARD_ADDR_IMG ="USER_CARD_ADDR_IMG" ; | 
 |  |  |     public static final String USER_CARD_SHOP_IMG ="USER_CARD_SHOP_IMG" ; | 
 |  |  |     public static final String USER_CARD_LOGO_IMG ="USER_CARD_LOGO_IMG" ; | 
 |  |  |  | 
 |  |  |     public static Integer parseIntByStr(String idtOrgStatus) { | 
 |  |  |         try { | 
 |  |  | 
 |  |  |     public static final String ACCESS_ID="ACCESS_ID"; | 
 |  |  |     public static final String BUCKETNAME = "BUCKETNAME"; | 
 |  |  |     public static final String OBJCET_STORAGE = "OBJCET_STORAGE"; | 
 |  |  |     public static final String ZBOM_CUSTOMIZED = "ZBOM_CUSTOMIZED"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public static final String ACCESS_KEY = "ACCESS_KEY"; | 
 |  |  |     public static final String ENDPOINT = "ENDPOINT"; | 
 |  |  |     public static final String RESOURCE_PATH = "RESOURCE_PATH"; | 
 |  |  |     public static final String WEIXIN_DEFAULT_IMGS = "WEIXIN_DEFAULT_IMGS"; | 
 |  |  |     public static final String USER_CARD_DEFAULT_IMG = "USER_CARD_DEFAULT_IMG"; | 
 |  |  |     public static final String USERS_FILE = "USERS_FILE"; | 
 |  |  |     public static final String NEWS_FILE = "NEWS_FILE"; | 
 |  |  |     public static final String USER_LABEL = "USER_LABEL"; | 
 |  |  |     //发送会议开始  定时提前多少分钟发送 | 
 |  |  |  | 
 |  |  |     public static final String SYSTEM ="SYSTEM"; | 
 |  |  | 
 |  |  |     public static final String WX_PLATFORM = "WX_PLATFORM"; | 
 |  |  |     public static final String ZBOM_ZHONGTAI_API_URL = "ZBOM_ZHONGTAI_API_URL"; | 
 |  |  |     public static final String WX_PLATFORM_ACCESS_TOKEN = "WX_PLATFORM_ACCESS_TOKEN"; | 
 |  |  |     public static final String ZBOM_ENCODE_URL = "ZBOM_ENCODE_URL"; | 
 |  |  |     public static final String WX_PLATFORM_APPID = "WX_PLATFORM_APPID"; | 
 |  |  |     public static final String WX_PLATFORM_SECRET = "WX_PLATFORM_SECRET"; | 
 |  |  |     public static final String WX_PLATFORM_AUDIT_VISIT = "WX_PLATFORM_AUDIT_VISIT"; | 
 |  |  | 
 |  |  |     public static final String WX_SECRET_CUSTOMER = "WX_SECRET_CUSTOMER"; | 
 |  |  |     public static final String WX_APPID_PERSONNEL = "WX_APPID_PERSONNEL"; | 
 |  |  |     public static final String WX_SECRET_PERSONNEL = "WX_SECRET_PERSONNEL"; | 
 |  |  |     public static final String WX_TOKEN_CUSTOMER = "WX_TOKEN_CUSTOMER"; | 
 |  |  |     public static final String WX_TOKEN_PERSONNEL = "WX_TOKEN_PERSONNEL"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public interface CrmSources{ | 
 |  |  |  | 
 |  |  |  | 
 |  |  |        String SOURCE_DKXD = "DKXD";// 代客下单(DKXD) | 
 |  |  |        String SOURCE_LYSJ = "LYSJ";// 零元设计(LYSJ) | 
 |  |  |        String SOURCE_ZBSJSQ = "ZBSJSQ";// 志邦设计申请(ZBSJSQ) | 
 |  |  |        String SOURCE_ZBDXFX = "ZBDXFX";// 志邦短信分享(ZBDXFX) | 
 |  |  |        String SOURCE_ZBLLJL = "ZBLLJL";// 志邦浏览记录分享(ZBLLJL) | 
 |  |  |        String SOURCE_ZBWDSC = "ZBWDSC";// 志邦我的收藏分享(ZBWDSC) | 
 |  |  |        String SOURCE_ZBLYSJ = "ZBLYSJ";// 志邦零元设计(ZBLYSJ) | 
 |  |  |        String SOURCE_ZBLDX = "ZBLDX";// 志邦老带新(ZBLDX) | 
 |  |  |        String SOURCE_ZBFGCS = "ZBFGCS";// 志邦风格测试(ZBFGCS) | 
 |  |  |        String SOURCE_ZBJX = "DSLX22";// 志邦家选(ZBJX) | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public interface RedisKeys { | 
 |  |  |        String IMPORTING_MEMBER ="IMPORTING_MEMBER"; | 
 |  |  | 
 |  |  |        String IMPORTING_USERS ="IMPORTING_USERS"; | 
 |  |  |        String IAM_APPID ="IAM_APPID"; | 
 |  |  |        String ZBOM_CRM_API_KEY ="ZBOM_CRM_API_KEY"; | 
 |  |  |        String ZBOM_CRM_AUTH_API_KEY ="ZBOM_CRM_AUTH_API_KEY"; | 
 |  |  |        String ZBOM_CRM_API_URL ="ZBOM_CRM_API_URL"; | 
 |  |  |        String ZBOM_ENCODE_URL ="ZBOM_ENCODE_URL"; | 
 |  |  |        String ZBOM_SMS_API_KEY ="ZBOM_SMS_API_KEY"; | 
 |  |  |        String ZBOM_ZHONGTAI_API_URL ="ZBOM_ZHONGTAI_API_URL"; | 
 |  |  |        String ZBOM_SMS_API_URL ="ZBOM_SMS_API_URL"; | 
 |  |  | 
 |  |  |     int unPass = 3;//审批未通过 | 
 |  |  |     int otherDeal = 4;//他人已处理 | 
 |  |  | } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 根据配置处理房屋户型信息 | 
 |  |  |      * @param layout | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static String getHouseLayout(String layout){ | 
 |  |  |         if(StringUtils.isBlank(layout)){ | 
 |  |  |             return null; | 
 |  |  |         } | 
 |  |  |         String [] arr = layout.split("-"); | 
 |  |  |         StringBuffer stringBuffer = new StringBuffer(); | 
 |  |  |         for (int i = 0; i < arr.length; i++) { | 
 |  |  |             if(i==0){ | 
 |  |  |                 stringBuffer.append( i + "室"); | 
 |  |  |             }else if(i==1){ | 
 |  |  |                 stringBuffer.append( i + "厅"); | 
 |  |  |             }else if(i==2){ | 
 |  |  |                 stringBuffer.append( i + "厨"); | 
 |  |  |             }else if(i==3){ | 
 |  |  |                 stringBuffer.append( i + "卫"); | 
 |  |  |             }else if(i==4){ | 
 |  |  |                 stringBuffer.append( i + "阳"); | 
 |  |  |             }else { | 
 |  |  |                 break; | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |         } | 
 |  |  |         return stringBuffer.toString(); | 
 |  |  | } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 获取车牌类型信息 | 
 |  |  | 
 |  |  |  | 
 |  |  |         return sb.toString(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public static InputStream generateWxMiniImgStream(String accessToken,String scene,String page) { | 
 |  |  |         //生成图片上传OSS | 
 |  |  |         Map<String,Object> body = new HashMap<>(); | 
 |  |  |         // 场景码,与前端约定,最终是需要前端解析 | 
 |  |  |         body.put("scene", scene); | 
 |  |  |         // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。 | 
 |  |  |         body.put("env_version", "develop"); | 
 |  |  |         body.put("page", page); | 
 |  |  |         // 透明,根据你的场景自行设置body参数 | 
 |  |  |         body.put("is_hyaline", true); | 
 |  |  |         OkHttpClient client = new OkHttpClient().newBuilder().build(); | 
 |  |  |         okhttp3.MediaType mediaType = okhttp3.MediaType.parse("application/json"); | 
 |  |  |         okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(mediaType, JSONObject.toJSONString(body)); | 
 |  |  |         Request request = new Request.Builder().url("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+accessToken) | 
 |  |  |                 .method("POST", requestBody).build(); | 
 |  |  |         try { | 
 |  |  |             Response response = client.newCall(request).execute(); | 
 |  |  |             if (response.isSuccessful()) { | 
 |  |  |                 InputStream inputStream = new ByteArrayInputStream(response.body().bytes()); | 
 |  |  | //                ByteArrayOutputStream baos = new ByteArrayOutputStream(); | 
 |  |  | //                    byte[] buffer = new byte[1024]; | 
 |  |  | //                    int len = -1; | 
 |  |  | //                    while ((len = inputStream.read(buffer)) != -1) { | 
 |  |  | //                        baos.write(buffer, 0, len); | 
 |  |  | //                    } | 
 |  |  | //                System.out.println("data:mediatype;base64," + Base64.getEncoder().encodeToString(baos.toByteArray())); | 
 |  |  |                 return inputStream; | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } | 
 |  |  |         throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"生成图片失败"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 发送get请求 | 
 |  |  |      * @param url 请求URL | 
 |  |  |      * @param param 请求参数 key:value url携带参数 或者无参可不填 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     public static String doGet(String url, Map<String, String> param) { | 
 |  |  |         // 创建Httpclient对象 | 
 |  |  |         CloseableHttpClient httpclient = HttpClients.createDefault(); | 
 |  |  |         String resultString = ""; | 
 |  |  |         CloseableHttpResponse response = null; | 
 |  |  |         try { | 
 |  |  |             // 创建uri | 
 |  |  |             URIBuilder builder = new URIBuilder(url); | 
 |  |  |             if (param != null) { | 
 |  |  |                 for (String key : param.keySet()) { | 
 |  |  |                     builder.addParameter(key, param.get(key)); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             URI uri = builder.build(); | 
 |  |  |             // 创建http GET请求 | 
 |  |  |             HttpGet httpGet = new HttpGet(uri); | 
 |  |  |             // 执行请求 | 
 |  |  |             response = httpclient.execute(httpGet); | 
 |  |  |             // 判断返回状态是否为200 | 
 |  |  |             if (response.getStatusLine().getStatusCode() == 200) { | 
 |  |  |                 resultString = EntityUtils.toString(response.getEntity(), "UTF-8"); | 
 |  |  |             } | 
 |  |  |         } catch (Exception e) { | 
 |  |  |             e.printStackTrace(); | 
 |  |  |         } finally { | 
 |  |  |             try { | 
 |  |  |                 if (response != null) { | 
 |  |  |                     response.close(); | 
 |  |  |                 } | 
 |  |  |                 httpclient.close(); | 
 |  |  |             } catch (IOException e) { | 
 |  |  |                 e.printStackTrace(); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return resultString; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  | } |