Merge remote-tracking branch 'origin/develop' into develop

master
eason 6 years ago
commit 3e082165ff

@ -124,7 +124,7 @@ public class OpenimClient {
list2.add(obj3);
obj3.setNick("king");
obj3.setIconUrl("https://ss0.baidu.com/73t1bjeh1BF3odCf/it/u=1948403834,955109320&fm=85&s=0D06E5134AD145F30C8D6D680300303A");
obj3.setUserid("kira1");
obj3.setUserid("kira3_PINE");
obj3.setPassword("xxxxxx");
req.setUserinfos(list2);
OpenimUsersAddResponse rsp = null;

@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.BoundListOperations;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Arrays;
@ -118,7 +119,11 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
queryParams.put("clientId", client.getIntValue("client_id"));
}
if (StringUtils.isNotEmpty(userNames)) {
queryParams.put("userNames", Arrays.asList(userNames.split(",")));
List<String> userNams = Arrays.asList(userNames.split(","));
if(CollectionUtils.isEmpty(userNams)){
return Collections.EMPTY_LIST;
}
queryParams.put("userNames",userNams );
}
if (queryParams.size() < 1) {
return Collections.emptyList();

@ -99,7 +99,7 @@
<![CDATA[
SELECT display_name
FROM sys_managers
WHERE role & #{mask} >0 AND org_id IS NULL AND is_valid = 1
WHERE role & #{mask} >0 AND (org_id IS NULL or org_id=1) AND is_valid = 1
]]>
</select>

@ -62,8 +62,8 @@
var cnts = data.data.cnts;
for (var i = cnts.length - 1; i >= 0; i--) {
var unreadmapEle = {msgCount: 0};
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(
cnts[i].from)] = unreadmapEle;
window.sdk.unreadMap[getName(WKIT.Conn.sdk.Base.getNick(
cnts[i].from))] = unreadmapEle;
}
getUnreadMsgCount();
},
@ -78,18 +78,20 @@
WKIT.Conn.sdk.Base.getUnreadMsgCount({
count: 40,
success: function (data) {
console.log(data);
var unreads = data.data;
var uids = "";
for (var i = unreads.length - 1; i >= 0; i--) {
if(window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(unreads[i].contact)]){
window.sdk.unreadMap[getName(WKIT.Conn.sdk.Base.getNick(unreads[i].contact))].msgCount =
unreads[i].msgCount;
var nick = getName(WKIT.Conn.sdk.Base.getNick(unreads[i].contact));
if(nick.length<=6){
uids += nick+",";
}else {
uids += nick.substring(0,uid.length-5) + ",";
}
window.sdk.unreadMap[WKIT.Conn.sdk.Base.getNick(unreads[i].contact)].msgCount =
unreads[i].msgCount;
var nick = WKIT.Conn.sdk.Base.getNick(unreads[i].contact)
uids += nick.substr(0,nick.length-6) + ",";
}
console.log("unreadMap",window.sdk.unreadMap);
window.sdk.loadContactList(uids);
},
error: function (error) {
@ -100,7 +102,9 @@
function updateContractList(data) {
var msg = data.msgs[0];
var msg_uid = WKIT.Conn.sdk.Base.getNick(msg.from);
var msg_uid = getName(WKIT.Conn.sdk.Base.getNick(msg.from))
if (window.sdk.unreadMap[msg_uid]) {
window.sdk.unreadMap[msg_uid].msgCount = window.sdk.unreadMap[msg_uid].msgCount + 1;
} else {
@ -116,6 +120,14 @@
$("#J_wkitPluginFrameWrap").css("margin", "0 0 0 0");
}
function getName(uid) {
if(uid.substring(uid.length-5,uid.length-4)=='_'){
var prefix = uid.substring(0,uid.length-5);
var suffix =uid.substring(uid.length-5,uid.length).toUpperCase();
return prefix+suffix;
}
return uid;
}
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);

@ -5,6 +5,8 @@
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
<![endif]-->
<!-- 自动适配移动端与pc端 -->
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=yes" />
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.4.0/scripts/kit.js"
charset="utf-8"></script>
@ -26,8 +28,12 @@
error: function (jqXHR) {
}
});
$("#back").bind('click',function () {
parent.hideContent();
})
};
function loginOpenim() {
WKIT.init({
container: document.getElementById('J_demo'),
@ -44,7 +50,7 @@
});
initUnreadMsgAndContact();
WKIT.Conn.sdk.Base.startListenAllMsg();
window.sdk = document.getElementById("J_wkitPluginFrame").contentWindow;
window.sdk = parent.document.getElementById("subPageList").contentWindow;
}
});
}
@ -117,11 +123,13 @@
function updateContractList(data) {
var msg = data.msgs[0];
var msg_uid = WKIT.Conn.sdk.Base.getNick(msg.from);
var msg_uid = WKIT.Conn.sdk.Base.getNick(msg.from).toUpperCase();
if (window.sdk.unreadMap[msg_uid]) {
window.sdk.unreadMap[msg_uid].msgCount = window.sdk.unreadMap[msg_uid].msgCount + 1;
window.sdk.unreadMap[msg_uid].lastMsg =msg.msg ;
} else {
var unreadMapEle = {msgCount: 1}
var unreadMapEle = {msgCount: 1,msg:msg.msg}
window.sdk.unreadMap[msg_uid] = unreadMapEle;
}
window.sdk.loadContactList(msg_uid.substr(0, msg_uid - 6));
@ -143,4 +151,9 @@
}
</script>
<body>
<div style="width: 2rem;height: 2rem;position: absolute;z-index:99999;" id="back">
<img style="width: 2rem" src="/static/images/im/back.png">
</div>
</body>
</html>

@ -7,17 +7,25 @@
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
<![endif]-->
<!-- 自动适配移动端与pc端 -->
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" name="viewport" />
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=yes" />
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.4.0/scripts/kit.js"
charset="utf-8"></script>
<script src="https://g.alicdn.com/aliww/h5.openim.sdk/1.0.6/scripts/wsdk.js"></script>
<style>
.content{
width: 99%;
height: 99%;
}
</style>
<script>
window.onload = function () {
$('#submit').bind("click", function () {
var data = {};
data.loginId = $("#uid").val();
data.password = $("#pwd").val();
data.verifyCode = 'jhd7';
data.verifyCode = 'noop';
$.ajax({
url: '/sys/openim/signin',
method: 'POST',
@ -29,14 +37,25 @@
document.getElementById("subPageList").contentWindow;
window.subPage.location.href = "/service_client_app.html";
window.subPageList.location.href = "/service_contact_list_app.html";
$("#loginInput").hide();
$("#subPageListDiv").hide();
$("#subPageDiv").show();
hideList();
},
error: function (jqXHR) {
}
});
});
}
function hideList() {
$("#loginInput").hide();
$("#subPageDiv").show();
$("#subPageListDiv").hide();
}
function hideContent() {
$("#loginInput").hide();
$("#subPageDiv").hide();
$("#subPageListDiv").show();
}
</script>
<body>
@ -60,12 +79,13 @@
</div>
<div id="subPageDiv">
<iframe id="subPage">
<div id="subPageDiv" style="display: none" class="content">
<iframe id="subPage" class="content">
</iframe>
</div>
<div id="subPageListDiv">
<iframe id="subPageList">
<div id="subPageListDiv" style="display: none" class="content">
<iframe id="subPageList" class="content">
</iframe>
</div>
</body>

@ -15,12 +15,18 @@
transition: background-color .1s;
margin-bottom: 13px;
width: 100%;
height: 2rem;
}
ul {
padding: 0;
}
body{
width: 98%;
height: 98%;
}
.search-div {
height: 3%;
}
@ -60,26 +66,30 @@
}
.avatar {
margin-top: 8px;
padding-left: 27px;
margin-top: 11px;
padding-left: 42px;
}
.msg {
margin-top: 11px;
padding-left: 42px;
}
.notice {
width: 15px;
height: 15px;
line-height: 15px;
width: 1.2rem;
height: 1.2rem;
line-height: 1.2rem;
font-size: 10px;
color: #fff;
text-align: center;
background-color: #f00;
border-radius: 50%;
position: relative;
right: -16px;
top: -7px;
right: -23px;
top: -8px;
}
.frm_search {
width: 133px;
width: 98%;
height: 32px;
line-height: 32px;
border: 0;
@ -94,7 +104,7 @@
.search_bar {
position: relative;
width: 137px;
width: 100%;
margin: 0 auto 6px;
}
@ -161,31 +171,31 @@
function showContactList(map) {
var contact_list = '';
for (var key in map) {
var css = 'hover';
if (key == parent.window.uid) {
css = 'active';
}
var ele= map[key];
var headImUrl = '';
if (map[key].headimg) {
headImUrl = map[key].headimg;
if (ele.headimg) {
headImUrl = ele.headimg;
} else {
headImUrl = "/static/images/act/encourage_money/default_headimg.png";
}
contact_list +=
"<li " + " class=\"" + css + "\" onclick=switchToUser('" + key
"<li onclick=switchToUser('" + key
+ "')>"
+ "<div class=\"headimg\" style='background-image:url(" + headImUrl
+ "')>"
+ "<div class=\"notice\">" + map[key].msgCount + "</div>"
+ "<div class=\"notice\">" + ele.msgCount + "</div>"
+ "</div>"
+ "<div class=\"avatar\">" + key + "</div>"
+ "</li>"
+ "<div class=\"avatar\">" + key + "</div>";
if(ele.lastMsg){
contact_list +="<div class=\"msg\">" + ele.lastMsg + "</div>";
}
contact_list+= "</li>";
}
$("#contact_list").html(contact_list);
}
function switchToUser(touid) {
parent.switchTouid(touid);
parent.document.getElementById("subPage").contentWindow.switchTouid(touid);
parent.hideList();
}
</script>

@ -0,0 +1,23 @@
<html>
<!--[if lt IE 9]>
<meta charset="utf-8" />
<script src="https://g.alicdn.com/aliww/ww/json/json.js" charset="utf-8"></script>
<![endif]-->
<!-- 自动适配移动端与pc端 -->
<script src="https://g.alicdn.com/aliww/??h5.openim.sdk/1.0.6/scripts/wsdk.js,h5.openim.kit/0.3.3/scripts/kit.js"
charset="utf-8"></script>
<script>
window.onload = function () {
WKIT.init({
container: document.getElementById('J_demo'),
width: 700,
height: 500,
uid: 'kira3_PINE',
appkey: 24980715,
credential: 'xxxxxx',
touid: 'kira7',
logo: 'http://img.alicdn.com/tps/i3/TB12LD9IFXXXXb3XpXXSyFWJXXX-82-82.png',
});
}
</script>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

@ -14,6 +14,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.ss.usermodel.Cell;
@ -22,16 +23,14 @@ import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.ArrayList;
@ -49,9 +48,9 @@ import cn.yixblog.platform.http.HttpRequestResult;
/**
* Created by wangning on 05/01/2018.
*/
@SpringBootTest
@ActiveProfiles({ "proxy", "alipay", "wechat", "jd", "bestpay" })
@RunWith(SpringRunner.class)
// @SpringBootTest
// @ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" })
// @RunWith(SpringRunner.class)
public class CustomerImpressionImplTest {
@Resource
private OrderMapper orderMapper;
@ -181,7 +180,7 @@ public class CustomerImpressionImplTest {
sendMail.setContent("<html><p>Hi</p ></html>");
List<String> list = new ArrayList<>();
list.add("testTag");
// sendMail.setTags(list);
// sendMail.setTags(list);
Set<String> mailCCs = new HashSet<>();
mailCCs.add("asd1159111@163.com");
sendMail.setMailCcs(mailCCs);
@ -202,15 +201,15 @@ public class CustomerImpressionImplTest {
JSONObject var = new JSONObject();
var.put("client_moniker", client.getString("client_moniker"));
var.put("short_name", client.getString("short_name"));
JSONObject result = mailGunClient.addListMember(client.getString("contact_email"), "merchants@mail.royalpay.com.au", client.getString("contact_person"),"",
var);
JSONObject result = mailGunClient.addListMember(client.getString("contact_email"), "merchants@mail.royalpay.com.au", client.getString("contact_person"),
"", var);
}
@Test
public void fd(){
public void fd() {
List<String> asd12eq = new ArrayList<>();
asd12eq.add("9");
JSONObject asd = clientManager.getByEmail("164851225@qq.com",1,1,asd12eq);
JSONObject asd = clientManager.getByEmail("164851225@qq.com", 1, 1, asd12eq);
JSONArray qwe = asd.getJSONArray("data");
System.out.println(asd.getJSONArray("data"));
System.out.println(qwe);
@ -231,27 +230,27 @@ public class CustomerImpressionImplTest {
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(1);
if(cell==null){
if (cell == null) {
continue;
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
CellStyle cellStyle = cell.getCellStyle();
if(cellStyle.getFillForegroundColor()==0){
if (cellStyle.getFillForegroundColor() == 0) {
continue;
}
String clientMonikers = cell.getStringCellValue().trim();
if(clientMonikers.contains("/")){
String [] clientMonikerArr = clientMonikers.split("/");
if (clientMonikers.contains("/")) {
String[] clientMonikerArr = clientMonikers.split("/");
for (String s : clientMonikerArr) {
String tmp = s.trim().toUpperCase();
if(tmp.length()>4 || tmp.length()==0){
if (tmp.length() > 4 || tmp.length() == 0) {
continue;
}
mailService.addUnsub(s.trim().toUpperCase());
}
}else {
} else {
String tmp = clientMonikers.trim().toUpperCase();
if(tmp.length()>4 || tmp.length()==0){
if (tmp.length() > 4 || tmp.length() == 0) {
continue;
}
mailService.addUnsub(clientMonikers.trim().toUpperCase());
@ -263,7 +262,118 @@ public class CustomerImpressionImplTest {
}
@Test
public void zxc(){
weekReporter.generateReport("2018-06-04",false);
public void zxc() {
weekReporter.generateReport("2018-06-04", false);
}
@Test
public void royalpayIndustryTransform() {
String json = "[\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"机票\",\n"
+ " \"mccCode\": \"10001\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"旅游行业\",\n"
+ " \"mccCode\": \"10002\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"私人定制旅游\",\n"
+ " \"mccCode\": \"10003\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"租车\",\n"
+ " \"mccCode\": \"10004\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"巴士\",\n"
+ " \"mccCode\": \"10005\"\n" + " }\n" + " ],\n" + " \"label\": \"旅游出行\",\n" + " \"mccCode\": \"1\"\n" + " },\n" + " {\n"
+ " \"children\": [\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"饭店\",\n" + " \"mccCode\": \"20001\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"奶茶店\",\n" + " \"mccCode\": \"20002\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"烧烤\",\n" + " \"mccCode\": \"20003\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"火锅\",\n" + " \"mccCode\": \"20004\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"Coffee\",\n" + " \"mccCode\": \"20005\"\n"
+ " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"酒吧\",\n" + " \"mccCode\": \"20006\"\n" + " }\n"
+ " ],\n" + " \"label\": \"餐饮\",\n" + " \"mccCode\": \"2\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"培训类\",\n" + " \"mccCode\": \"30001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"移民留学\",\n" + " \"mccCode\": \"30002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"私人幼儿园\",\n" + " \"mccCode\": \"30003\"\n" + " }\n" + " ],\n"
+ " \"label\": \"教育\",\n" + " \"mccCode\": \"3\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"换汇\",\n" + " \"mccCode\": \"40001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"房产\",\n" + " \"mccCode\": \"40002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"商务咨询\",\n" + " \"mccCode\": \"4\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"公众号服务商\",\n" + " \"mccCode\": \"50001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"各种媒体类宣传\",\n" + " \"mccCode\": \"50002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"传媒\",\n" + " \"mccCode\": \"5\",\n"
+ " \"value\": \"{\\\"category\\\":\\\"SERVICE\\\",\\\"code\\\":\\\"7542\\\",\\\"description\\\":\\\"Car Washes\\\",\\\"parentCode\\\":\\\"S10\\\"}\"\n"
+ " },\n" + " {\n" + " \"children\": [\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"美容院\",\n"
+ " \"mccCode\": \"60001\"\n" + " },\n" + " {\n" + " \"children\": [],\n" + " \"label\": \"医疗美容\",\n"
+ " \"mccCode\": \"60002\"\n" + " }\n" + " ],\n" + " \"label\": \"医美\",\n" + " \"mccCode\": \"6\"\n" + " },\n" + " {\n"
+ " \"children\": [\n" + " {\n" + " \"label\": \"超市\",\n" + " \"mccCode\": \"70001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"服装店\",\n" + " \"mccCode\": \"70002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"鞋店\",\n" + " \"mccCode\": \"70003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"珠宝店\",\n" + " \"mccCode\": \"70004\"\n" + " },{\n"
+ " \"children\": [],\n" + " \"label\": \"箱包\",\n" + " \"mccCode\": \"70005\"\n" + " }\n" + " ],\n"
+ " \"label\": \"零售\",\n" + " \"mccCode\": \"7\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"桌游吧\",\n" + " \"mccCode\": \"80001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"演唱会\",\n" + " \"mccCode\": \"80002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"马术训练\",\n" + " \"mccCode\": \"80003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"瑜伽\",\n" + " \"mccCode\": \"80004\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"健身\",\n" + " \"mccCode\": \"80005\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"社团\",\n" + " \"mccCode\": \"80006\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"网吧\",\n" + " \"mccCode\": \"80007\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"KTV\",\n" + " \"mccCode\": \"80008\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"电影\",\n" + " \"mccCode\": \"80009\"\n" + " }\n" + " ],\n"
+ " \"label\": \"休闲娱乐\",\n" + " \"mccCode\": \"8\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"摄影\",\n" + " \"mccCode\": \"90001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"massage\",\n" + " \"mccCode\": \"90002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"通讯运营商\",\n" + " \"mccCode\": \"90003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"车行\",\n" + " \"mccCode\": \"90004\"\n" + " },\n" + " {\n"
+ " \"children:\":[],\n" + " \"label\":\"软件服务\",\n" + " \"mccCode\":\"90005\"\n" + " }\n" + " ],\n"
+ " \"label\": \"其他服务类\",\n" + " \"mccCode\": \"9\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"Hotel\",\n" + " \"mccCode\": \"100001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"Motel\",\n" + " \"mccCode\": \"100002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"酒店\",\n" + " \"mccCode\": \"10\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"代购\",\n" + " \"mccCode\": \"110001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"物流(大宗出口贸易)\",\n" + " \"mccCode\": \"110002\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"红酒出口\",\n" + " \"mccCode\": \"110003\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"综合电商\",\n" + " \"mccCode\": \"110004\"\n" + " }\n" + " ],\n"
+ " \"label\": \"出口贸易\",\n" + " \"mccCode\": \"11\"\n" + " },\n" + " {\n" + " \"children\": [\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"建材\",\n" + " \"mccCode\": \"120001\"\n" + " },\n" + " {\n"
+ " \"children\": [],\n" + " \"label\": \"家居\",\n" + " \"mccCode\": \"120002\"\n" + " }\n" + " ],\n"
+ " \"label\": \"家居建材\",\n" + " \"mccCode\": \"12\"\n" + " }\n" + "]";
JSONArray jsonArray = JSONObject.parseArray(json);
try {
XSSFWorkbook workbook = new XSSFWorkbook(new FileInputStream(new File("/Users/wangning/Desktop/asd.xlsx")));
XSSFSheet sheet = workbook.getSheetAt(0);
Iterator<Row> rowIterator = sheet.rowIterator();
Row row = null;
Cell cell = null;
while (rowIterator.hasNext()) {
row = rowIterator.next();
cell = row.getCell(2);
if (cell == null) {
continue;
}
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
String industryChinese = recursionIndustry(jsonArray, cell.getStringCellValue());
cell.setCellValue(industryChinese);
}
OutputStream out = new FileOutputStream("/Users/wangning/Desktop/qwe.xlsx");
workbook.write(out);
workbook.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public String recursionIndustry(JSONArray jsonArray, String mccCode) {
String result = "";
for (Object o : jsonArray) {
if(StringUtils.isNotEmpty(result)){
break;
}
JSONObject tmp = (JSONObject) o;
if (tmp.getString("mccCode").equals(mccCode)) {
result = tmp.getString("label");
}else {
if(tmp.getJSONArray("children")!=null){
result = recursionIndustry(tmp.getJSONArray("children"), mccCode);
}else {
result = "";
}
}
}
return result;
}
}
Loading…
Cancel
Save