Commit f5c2ea2f by guojx

流失数据接口

parent 0ce3dd7c
......@@ -229,7 +229,6 @@ public class WechatWorkController extends NewBaseController {
}
if (total != null) {
total.put("clerkName", "合计(" + list.size() + ")");
storeAuthUtils.setChannelGroupList(total);
list.add(0, total);
}
vo.setRows(list);
......
......@@ -45,7 +45,6 @@ public class WechatWorkLostClerkHandle extends DownloadHandlerAbstract<WechatWor
}
if (total != null) {
total.put("clerkName", "合计(" + list.size() + ")");
storeAuthUtils.setChannelGroupList(total);
list.add(0, total);
}
if (CollectionUtils.isNotEmpty(list)) {
......
......@@ -187,14 +187,12 @@ public class StoreAuthUtils {
}
recycle.put("storeGroupId", "all");
List<JSONObject> list = new ArrayList<>();
setChannelGroupList(recycle);
list.add(recycle);
JSONObject temp = JSONObject.parseObject(recycle.toJSONString());
temp.remove("channelGroupList");
temp.put("storeGroupName", "回收站门店");
temp.put("storeGroupId", "-3");
setChannelGroupList(temp);
list.add(temp);
vo.setRows(list);
......@@ -208,59 +206,13 @@ public class StoreAuthUtils {
getRecycleStore = (List<String>) jsonObject.get("recycleStoreIdList");
}
jsonObject.put("pageSize", Integer.MAX_VALUE);
jsonObject.put("pageNum", 1);
Map<String, Object> res = DataApiUtils.http(jsonObject.toJSONString(), apolloKey);
List<JSONObject> list = DataApiUtils.getCirclePageData(jsonObject, apolloKey, true);
Integer totalCount = (CollectionUtils.isEmpty(list) ? 0 : list.size());
Page page = DataApiUtils.getPageData(res);
List<JSONObject> list = DataApiUtils.getPageList(res);
Integer totalCount = page.getTotalCount();
vo.setTotalNum(totalCount);
vo.setPageSize(pageSize);
vo.setPageNum(currentPage);
String channelMapKey = jsonObject.containsKey("orderChannel") ? "orderChannel" : "mbrChannel";
if (CollectionUtils.isNotEmpty(list)) {
vo.setPageSize(pageSize);
vo.setPageNum(currentPage);
Map<String, List<JSONObject>> jsonGroup = new HashMap<>();
List<String> idList = new ArrayList<>();
for (JSONObject tempMap : list) {
String id = tempMap.getString(isStore ? "storeId" : "storeGroupId");
if (jsonGroup.containsKey(id)) {
jsonGroup.get(id).add(tempMap);
} else {
idList.add(id);
List<JSONObject> mapJson = new ArrayList<>();
mapJson.add(tempMap);
jsonGroup.put(id, mapJson);
}
}
vo.setTotalNum(jsonGroup.size());
int totalPage = (vo.getTotalNum() % pageSize != 0 ? (vo.getTotalNum() / pageSize + 1) : (vo.getTotalNum() / pageSize));
int start = (currentPage - 1) * pageSize;
int end = currentPage * pageSize;
if (end > idList.size()) {
end = idList.size();
}
List<JSONObject> tempList = new ArrayList<>();
Set<String> tempSet = new HashSet<>();
for (int i = start; i < end; i ++) {
String indexId = idList.get(i);
if (tempSet.contains(indexId)) {
continue;
}
List<JSONObject> channelGroupList = jsonGroup.get(indexId);
JSONObject copyJson = JSONObject.parseObject(channelGroupList.get(0).toJSONString());
copyJson.put("channelGroupList", sortChannel(channelGroupList, (List<String>) jsonObject.get(channelMapKey)));
tempSet.add(indexId);
tempList.add(copyJson);
}
list = tempList;
}
//调用一次合计
if (hasCountPerPage || (isFirst && CollectionUtils.isNotEmpty(list))) {
if (hasCountPerPage && CollectionUtils.isEmpty(list)) {
......@@ -282,12 +234,12 @@ public class StoreAuthUtils {
total = new JSONObject();
}
if (isStore) {
total.put("storeName", "合计(" + (hasCountPerPage ? vo.getTotalNum() : totalCount) + ")");
total.put("storeName", "合计(" + totalCount + ")");
} else {
total.put("storeGroupName", "合计(" + (hasCountPerPage ? vo.getTotalNum() : totalCount) + ")");
total.put("storeGroupName", "合计(" + totalCount + ")");
}
total.put("storeGroupId", "all");
setChannelGroupList(total);
list.add(0, total);
if (hasRecycle) {
......@@ -299,7 +251,6 @@ public class StoreAuthUtils {
recycle.put("storeGroupName", "回收站门店");
recycle.put("storeGroupId", "-3");
setChannelGroupList(recycle);
list.add(1, recycle);
}
}
......@@ -393,10 +344,6 @@ public class StoreAuthUtils {
return list;
}
public void setChannelGroupList(JSONObject jsonObject) {
jsonObject.put("channelGroupList", Arrays.asList(JSONObject.parseObject(jsonObject.toJSONString())));
}
public JSONObject getTotalJson(JSONObject param, String apolloKey) {
Map<String, Object> totalRes = DataApiUtils.http(param.toJSONString(), apolloKey);
List<JSONObject> totalList = DataApiUtils.getPageList(totalRes);
......@@ -406,33 +353,4 @@ public class StoreAuthUtils {
JSONObject total = totalList.get(0);
return total;
}
public static List<JSONObject> sortChannel(List<JSONObject> channelGroupList, List<String> mbrChannel) {
if (CollectionUtils.isNotEmpty(channelGroupList)) {
for (JSONObject temp : channelGroupList) {
if ("c_all".equals(temp.getString("channelCode")) && StringUtils.isBlank(temp.getString("channelName"))) {
temp.put("channelName", "全渠道");
} else if (!temp.containsKey("channelCode")) {
temp.put("channelName", "全渠道");
}
}
if (channelGroupList.stream().noneMatch(e -> e.containsKey("channelCode"))) {
return channelGroupList;
}
}
if (CollectionUtils.isEmpty(mbrChannel)) {
return channelGroupList;
}
List<JSONObject> result = new ArrayList<>();
for (String str : mbrChannel) {
for (JSONObject jsonObject : channelGroupList) {
if (str.equals(jsonObject.getString("channelCode"))) {
result.add(jsonObject);
}
}
}
return result;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment