Commit 3dbdc53b by 王祖波

cms数据接口迁移

parent a27c753f
...@@ -17,9 +17,7 @@ import com.gic.haoban.manage.api.enums.content.MaterialReportType; ...@@ -17,9 +17,7 @@ import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.web.controller.content.adaptor.ClerkStoreAdaptor; import com.gic.haoban.manage.web.controller.content.adaptor.ClerkStoreAdaptor;
import com.gic.haoban.manage.web.controller.content.adaptor.MaterialDataAdaptor; import com.gic.haoban.manage.web.controller.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.web.qo.content.ContentMaterialBaseQO; import com.gic.haoban.manage.web.qo.content.ContentMaterialBaseQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO; import com.gic.haoban.manage.web.qo.content.statistics.*;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialReportQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialStatisticsBaseQO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialAreaUsedDataVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialAreaUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialDataOverviewVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialDataOverviewVO;
...@@ -171,8 +169,7 @@ public class MaterialDataStaticsController { ...@@ -171,8 +169,7 @@ public class MaterialDataStaticsController {
} else { } else {
storeIds.add(materialStatisticsBaseQO.getStoreId()); storeIds.add(materialStatisticsBaseQO.getStoreId());
} }
Page<MaterialClerkUsedDataVO> clerkUsedData = materialDataAdaptor.queryMaterialClerkUsedData(materialStatisticsBaseQO.getEnterpriseId(), storeIds, Page<MaterialClerkUsedDataVO> clerkUsedData = materialDataAdaptor.queryMaterialClerkUsedData(materialStatisticsBaseQO,storeIds);
materialStatisticsBaseQO.getFixedDateDiff(), materialStatisticsBaseQO.getOrderByField(), materialStatisticsBaseQO.getOrder(), materialStatisticsBaseQO.getPageNum(), materialStatisticsBaseQO.getPageSize());
return RestResponse.successResult(clerkUsedData); return RestResponse.successResult(clerkUsedData);
} }
...@@ -182,15 +179,14 @@ public class MaterialDataStaticsController { ...@@ -182,15 +179,14 @@ public class MaterialDataStaticsController {
* @return * @return
*/ */
@RequestMapping(path = "/content/material/store/data") @RequestMapping(path = "/content/material/store/data")
public RestResponse<Page<MaterialStoreUsedDataVO>> queryMaterialStoreUsedData(@RequestBody MaterialAnalyzeDataQO materialStatisticsBaseQO) { public RestResponse<Page<MaterialStoreUsedDataVO>> queryMaterialStoreUsedData(@RequestBody MaterialStoreAnalyzeDataQO materialStatisticsBaseQO) {
List<String> storeIds = new ArrayList<>(); List<String> storeIds = new ArrayList<>();
if (StringUtils.isBlank(materialStatisticsBaseQO.getStoreId())) { if (StringUtils.isBlank(materialStatisticsBaseQO.getStoreId())) {
storeIds = clerkStoreAdaptor.queryClerkStoreIds(materialStatisticsBaseQO.getClerkId(), materialStatisticsBaseQO.getWxEnterpriseId()); storeIds = clerkStoreAdaptor.queryClerkStoreIds(materialStatisticsBaseQO.getClerkId(), materialStatisticsBaseQO.getWxEnterpriseId());
} else { } else {
storeIds.add(materialStatisticsBaseQO.getStoreId()); storeIds.add(materialStatisticsBaseQO.getStoreId());
} }
Page<MaterialStoreUsedDataVO> storeUsedData = materialDataAdaptor.queryMaterialStoreUsedData(materialStatisticsBaseQO.getEnterpriseId(), storeIds, Page<MaterialStoreUsedDataVO> storeUsedData = materialDataAdaptor.queryMaterialStoreUsedData(materialStatisticsBaseQO,storeIds);
materialStatisticsBaseQO.getFixedDateDiff(), materialStatisticsBaseQO.getOrderByField(), materialStatisticsBaseQO.getOrder(), materialStatisticsBaseQO.getPageNum(), materialStatisticsBaseQO.getPageSize());
if (CollectionUtils.isNotEmpty(storeUsedData.getResult())) { if (CollectionUtils.isNotEmpty(storeUsedData.getResult())) {
List<String> tempStoreIds = storeUsedData.getResult() List<String> tempStoreIds = storeUsedData.getResult()
.stream() .stream()
...@@ -273,7 +269,7 @@ public class MaterialDataStaticsController { ...@@ -273,7 +269,7 @@ public class MaterialDataStaticsController {
* @return * @return
*/ */
@RequestMapping(path = "/content/material/store/used/data") @RequestMapping(path = "/content/material/store/used/data")
public RestResponse<MaterialStoreUsedDataVO> queryMaterialStoreUseReport(@RequestBody MaterialReportQO materialReportQO) { public RestResponse<MaterialStoreUsedDataVO> queryMaterialStoreUseReport(@RequestBody MaterialStoreReportQO materialReportQO) {
List<String> storeIds = new ArrayList<>(); List<String> storeIds = new ArrayList<>();
if (StringUtils.isBlank(materialReportQO.getStoreId())) { if (StringUtils.isBlank(materialReportQO.getStoreId())) {
...@@ -391,7 +387,7 @@ public class MaterialDataStaticsController { ...@@ -391,7 +387,7 @@ public class MaterialDataStaticsController {
* @return * @return
*/ */
@RequestMapping(path = "/content/material/store/used/data/list") @RequestMapping(path = "/content/material/store/used/data/list")
public RestResponse<Page<MaterialStoreUsedDataVO>> queryMaterialStoreUseReportList(@RequestBody MaterialReportQO materialReportQO) { public RestResponse<Page<MaterialStoreUsedDataVO>> queryMaterialStoreUseReportList(@RequestBody MaterialStoreReportQO materialReportQO) {
List<String> storeIds = new ArrayList<>(); List<String> storeIds = new ArrayList<>();
if (StringUtils.isBlank(materialReportQO.getStoreId())) { if (StringUtils.isBlank(materialReportQO.getStoreId())) {
storeIds = clerkStoreAdaptor.queryClerkStoreIds(materialReportQO.getClerkId(), materialReportQO.getWxEnterpriseId()); storeIds = clerkStoreAdaptor.queryClerkStoreIds(materialReportQO.getClerkId(), materialReportQO.getWxEnterpriseId());
......
...@@ -6,10 +6,15 @@ import cn.hutool.core.date.DateUtil; ...@@ -6,10 +6,15 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.Page; import com.gic.api.base.commons.Page;
import com.gic.commons.util.DataApiUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO; import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService; import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.enums.content.MaterialReportType; import com.gic.haoban.manage.api.enums.content.MaterialReportType;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialAnalyzeDataQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialReportQO; import com.gic.haoban.manage.web.qo.content.statistics.MaterialReportQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialStoreAnalyzeDataQO;
import com.gic.haoban.manage.web.qo.content.statistics.MaterialStoreReportQO;
import com.gic.haoban.manage.web.utils.target.DataTargetHttpUtils; import com.gic.haoban.manage.web.utils.target.DataTargetHttpUtils;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialAreaUsedDataVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialAreaUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
...@@ -101,19 +106,16 @@ public class MaterialDataAdaptor { ...@@ -101,19 +106,16 @@ public class MaterialDataAdaptor {
* @return * @return
*/ */
public MaterialTodayDataBO queryMaterialTodayData(String enterpriseId, List<String> storeIds) { public MaterialTodayDataBO queryMaterialTodayData(String enterpriseId, List<String> storeIds) {
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("inFields", inlineParams);
inlineParams.put("enterpriseId", enterpriseId); inlineParams.put("enterpriseId", enterpriseId);
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_INDEX_DATA); Map<String, Object> result = DataApiUtils.http(inlineParams.toString(), MATERIAL_INDEX_DATA);
if (result.get("data") == null) { if (result.get("data") == null) {
return MaterialTodayDataBO.empty(); return MaterialTodayDataBO.empty();
} }
List<MaterialTodayDataBO> datas = JSON.parseArray(JSON.toJSONString(result.get("data")), MaterialTodayDataBO.class); List<MaterialTodayDataBO> datas = DataApiUtils.parseDataList(result, MaterialTodayDataBO.class);
if (CollectionUtils.isEmpty(datas)) { if (CollectionUtils.isEmpty(datas)) {
return MaterialTodayDataBO.empty(); return MaterialTodayDataBO.empty();
} }
...@@ -131,20 +133,15 @@ public class MaterialDataAdaptor { ...@@ -131,20 +133,15 @@ public class MaterialDataAdaptor {
* @return * @return
*/ */
public MaterialDataOverviewVO queryMaterialDataOverview(String enterpriseId, List<String> storeIds, Integer fixedDateDiff) { public MaterialDataOverviewVO queryMaterialDataOverview(String enterpriseId, List<String> storeIds, Integer fixedDateDiff) {
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("inFields", inlineParams);
inlineParams.put("enterpriseId", enterpriseId); inlineParams.put("enterpriseId", enterpriseId);
inlineParams.put("fixedDateDiff", fixedDateDiff); inlineParams.put("fixedDateDiff", fixedDateDiff);
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_OVERVIEW_DATA); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), MATERIAL_OVERVIEW_DATA);
if (result.get("data") == null) { List<MaterialDataOverviewVO> datas = DataApiUtils.parseDataList(result, MaterialDataOverviewVO.class);
return new MaterialDataOverviewVO();
}
List<MaterialDataOverviewVO> datas = JSON.parseArray(JSON.toJSONString(result.get("data")), MaterialDataOverviewVO.class);
if (CollectionUtils.isEmpty(datas)) { if (CollectionUtils.isEmpty(datas)) {
return new MaterialDataOverviewVO(); return new MaterialDataOverviewVO();
} }
...@@ -155,44 +152,30 @@ public class MaterialDataAdaptor { ...@@ -155,44 +152,30 @@ public class MaterialDataAdaptor {
/** /**
* 导购纬度数据统计 * 导购纬度数据统计
* *
* @param enterpriseId
* @param storeIds * @param storeIds
* @param fixedDateDiff
* @param orderStr
* @return * @return
*/ */
public Page<MaterialClerkUsedDataVO> queryMaterialClerkUsedData(String enterpriseId, List<String> storeIds, Integer fixedDateDiff, public Page<MaterialClerkUsedDataVO> queryMaterialClerkUsedData(MaterialAnalyzeDataQO dataQO,List<String> storeIds) {
String orderField, String orderStr, Integer pageNo, Integer pageSize) { int pageNum = dataQO.getPageNum();
Map<String, Object> params = new HashMap<>(); int pageSize = dataQO.getPageSize();
String enterpriseId = dataQO.getEnterpriseId();
Integer fixedDateDiff = dataQO.getFixedDateDiff();
String orderByField = dataQO.getOrderByField();
String order = dataQO.getOrder();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("pageNo", pageNo); inlineParams.put("pageNum", pageNum);
params.put("pageSize", pageSize); inlineParams.put("pageSize", pageSize);
params.put("inFields", inlineParams);
inlineParams.put("enterpriseId", enterpriseId); inlineParams.put("enterpriseId", enterpriseId);
inlineParams.put("fixedDateDiff", fixedDateDiff); inlineParams.put("fixedDateDiff", fixedDateDiff);
if (StringUtils.isNotBlank(orderField)) { int orderByFields = DataApiUtils.getOrderByFields(orderByField, "enterpriseId", dataQO.getFieldsOrder());
inlineParams.put("orderByField", orderField + " " +orderStr); inlineParams.put("orderByFields", orderByFields);
}else { inlineParams.put("orderByType", DataApiUtils.getOrderByType(order));
inlineParams.put("orderByField", "enterpriseId asc ");
}
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_CLERK_DATA); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), MATERIAL_CLERK_DATA);
if (result.get("data") == null) { Page<MaterialClerkUsedDataVO> pageData = DataApiUtils.getPageData(result, MaterialClerkUsedDataVO.class);
return new Page<>(); return pageData;
}
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(result.get("page")), JSONObject.class);
int totalCount = jsonObject.getIntValue("totalCount");
int totalPage = jsonObject.getIntValue("totalPage");
List<MaterialClerkUsedDataVO> dataVOS = JSON.parseArray(JSON.toJSONString(result.get("data")), MaterialClerkUsedDataVO.class);
Page<MaterialClerkUsedDataVO> pageResult = new Page<>();
pageResult.setTotalCount(totalCount);
pageResult.setTotalPage(totalPage);
pageResult.setCurrentPage(pageNo);
pageResult.setPageSize(pageSize);
pageResult.setResult(dataVOS);
return pageResult;
} }
/** /**
...@@ -204,40 +187,26 @@ public class MaterialDataAdaptor { ...@@ -204,40 +187,26 @@ public class MaterialDataAdaptor {
* @param orderStr * @param orderStr
* @return * @return
*/ */
public Page<MaterialStoreUsedDataVO> queryMaterialStoreUsedData(String enterpriseId, List<String> storeIds, Integer fixedDateDiff, public Page<MaterialStoreUsedDataVO> queryMaterialStoreUsedData(MaterialStoreAnalyzeDataQO dataQO, List<String> storeIds) {
String orderField, String orderStr, Integer pageNo, Integer pageSize) { int pageNum = dataQO.getPageNum();
Map<String, Object> params = new HashMap<>(); int pageSize = dataQO.getPageSize();
String enterpriseId = dataQO.getEnterpriseId();
Integer fixedDateDiff = dataQO.getFixedDateDiff();
String order = dataQO.getOrder();
String orderByField = dataQO.getOrderByField();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("pageNo", pageNo); inlineParams.put("pageNum", pageNum);
params.put("pageSize", pageSize); inlineParams.put("pageSize", pageSize);
params.put("inFields", inlineParams);
inlineParams.put("enterpriseId", enterpriseId); inlineParams.put("enterpriseId", enterpriseId);
inlineParams.put("fixedDateDiff", fixedDateDiff); inlineParams.put("fixedDateDiff", fixedDateDiff);
if (StringUtils.isNotBlank(orderField)) { inlineParams.put("orderByFields", DataApiUtils.getOrderByFields(orderByField, "enterpriseId", dataQO.getFieldsOrder()));
inlineParams.put("orderByField", orderField + " " + orderStr); inlineParams.put("orderByType", DataApiUtils.getOrderByType(order));
}else {
inlineParams.put("orderByField", "enterpriseId asc ");
}
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MATERIAL_STORE_DATA); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), MATERIAL_STORE_DATA);
if (result.get("data") == null) { Page<MaterialStoreUsedDataVO> pageData = DataApiUtils.getPageData(result, MaterialStoreUsedDataVO.class);
return new Page<>(); return pageData;
}
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(result.get("page")), JSONObject.class);
int totalCount = jsonObject.getIntValue("totalCount");
int totalPage = jsonObject.getIntValue("totalPage");
List<MaterialStoreUsedDataVO> dataVOS = JSON.parseArray(JSON.toJSONString(result.get("data")), MaterialStoreUsedDataVO.class);
Page<MaterialStoreUsedDataVO> pageResult = new Page<>();
pageResult.setTotalCount(totalCount);
pageResult.setTotalPage(totalPage);
pageResult.setCurrentPage(pageNo);
pageResult.setPageSize(pageSize);
pageResult.setResult(dataVOS);
return pageResult;
} }
...@@ -255,8 +224,8 @@ public class MaterialDataAdaptor { ...@@ -255,8 +224,8 @@ public class MaterialDataAdaptor {
Integer pageSize = materialReportQO.getPageSize(); Integer pageSize = materialReportQO.getPageSize();
String clerkId = materialReportQO.getClerkId(); String clerkId = materialReportQO.getClerkId();
String enterpriseId = materialReportQO.getEnterpriseId(); String enterpriseId = materialReportQO.getEnterpriseId();
String orderField = materialReportQO.getOrderByField(); String orderByField = materialReportQO.getOrderByField();
String orderStr = materialReportQO.getOrder(); String order = materialReportQO.getOrder();
// 获取当前时间周期 // 获取当前时间周期
DateTime startTime = null; DateTime startTime = null;
DateTime endTime = null; DateTime endTime = null;
...@@ -271,11 +240,9 @@ public class MaterialDataAdaptor { ...@@ -271,11 +240,9 @@ public class MaterialDataAdaptor {
endTime = DateUtil.endOfMonth(DateUtil.lastMonth()); endTime = DateUtil.endOfMonth(DateUtil.lastMonth());
apolloKey = MATERIAL_CLERK_MONTH_DATA; apolloKey = MATERIAL_CLERK_MONTH_DATA;
} }
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("pageNo", pageNo); inlineParams.put("pageNum", pageNo);
params.put("pageSize", pageSize); inlineParams.put("pageSize", pageSize);
params.put("inFields", inlineParams);
if (StringUtils.isNotBlank(clerkId)) { if (StringUtils.isNotBlank(clerkId)) {
inlineParams.put("clerkId", clerkId); inlineParams.put("clerkId", clerkId);
} }
...@@ -284,33 +251,15 @@ public class MaterialDataAdaptor { ...@@ -284,33 +251,15 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
if (StringUtils.isNotBlank(orderField)) { inlineParams.put("orderByFields", DataApiUtils.getOrderByFields(orderByField, "enterpriseId", materialReportQO.getFieldsOrder()));
inlineParams.put("orderByField", orderField + " " + orderStr); inlineParams.put("orderByType", DataApiUtils.getOrderByType(order));
}else { Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), apolloKey);
inlineParams.put("orderByField", "enterpriseId asc "); Page<MaterialPersonalUsedDataVO> pageData = DataApiUtils.getPageData(result, MaterialPersonalUsedDataVO.class);
} for (MaterialPersonalUsedDataVO materialPersonalUsedDataVo : pageData.getResult()) {
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), apolloKey);
if (result.get("data") == null) {
return new Page<>();
}
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(result.get("page")), JSONObject.class);
int totalCount = jsonObject.getIntValue("totalCount");
int totalPage = jsonObject.getIntValue("totalPage");
Page<MaterialPersonalUsedDataVO> pageResult = new Page<>();
pageResult.setTotalCount(totalCount);
pageResult.setTotalPage(totalPage);
pageResult.setCurrentPage(pageNo);
pageResult.setPageSize(pageSize);
List<MaterialPersonalUsedDataVO> materialPersonalUsedDataVos = JSON.parseArray(JSON.toJSONString(result.get("data")), MaterialPersonalUsedDataVO.class);
if (CollectionUtils.isEmpty(materialPersonalUsedDataVos)) {
return new Page<>();
}
for (MaterialPersonalUsedDataVO materialPersonalUsedDataVo : materialPersonalUsedDataVos) {
materialPersonalUsedDataVo.setStartTime(startTime); materialPersonalUsedDataVo.setStartTime(startTime);
materialPersonalUsedDataVo.setEndTime(endTime); materialPersonalUsedDataVo.setEndTime(endTime);
} }
pageResult.setResult(materialPersonalUsedDataVos); return pageData;
return pageResult;
} }
/** /**
...@@ -319,14 +268,14 @@ public class MaterialDataAdaptor { ...@@ -319,14 +268,14 @@ public class MaterialDataAdaptor {
* @param storeIds * @param storeIds
* @return * @return
*/ */
public Page<MaterialStoreUsedDataVO> queryMaterialStoreUseReport(MaterialReportQO materialReportQO, List<String> storeIds) { public Page<MaterialStoreUsedDataVO> queryMaterialStoreUseReport(MaterialStoreReportQO materialReportQO, List<String> storeIds) {
Integer reportType = materialReportQO.getReportType(); Integer reportType = materialReportQO.getReportType();
Integer pageNo = materialReportQO.getPageNum(); Integer pageNo = materialReportQO.getPageNum();
Integer pageSize = materialReportQO.getPageSize(); Integer pageSize = materialReportQO.getPageSize();
String clerkId = materialReportQO.getClerkId(); String clerkId = materialReportQO.getClerkId();
String enterpriseId = materialReportQO.getEnterpriseId(); String enterpriseId = materialReportQO.getEnterpriseId();
String orderField = materialReportQO.getOrderByField(); String orderByField = materialReportQO.getOrderByField();
String order = materialReportQO.getOrder(); String order = materialReportQO.getOrder();
// 获取当前时间周期 // 获取当前时间周期
DateTime startTime = null; DateTime startTime = null;
...@@ -342,11 +291,9 @@ public class MaterialDataAdaptor { ...@@ -342,11 +291,9 @@ public class MaterialDataAdaptor {
endTime = DateUtil.endOfMonth(DateUtil.lastMonth()); endTime = DateUtil.endOfMonth(DateUtil.lastMonth());
apolloKey = MATERIAL_STORE_MONTH_DATA; apolloKey = MATERIAL_STORE_MONTH_DATA;
} }
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("pageNo", pageNo); inlineParams.put("pageNum", pageNo);
params.put("pageSize", pageSize); inlineParams.put("pageSize", pageSize);
params.put("inFields", inlineParams);
if (StringUtils.isNotBlank(clerkId)) { if (StringUtils.isNotBlank(clerkId)) {
inlineParams.put("clerkId", clerkId); inlineParams.put("clerkId", clerkId);
} }
...@@ -355,18 +302,11 @@ public class MaterialDataAdaptor { ...@@ -355,18 +302,11 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
if (StringUtils.isNotBlank(orderField)) { inlineParams.put("orderByFields", DataApiUtils.getOrderByFields(orderByField, "enterpriseId", materialReportQO.getFieldsOrder()));
String orderStr = " " + order; inlineParams.put("orderByType", DataApiUtils.getOrderByType(order));
inlineParams.put("orderByField", orderField + orderStr); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), apolloKey);
}else { Page pageData = DataApiUtils.getPageData(result);
inlineParams.put("orderByField", "enterpriseId asc "); List<JSONObject> jsonObjects = (List<JSONObject>) pageData.getResult();
}
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), apolloKey);
if (result.get("data") == null) {
return new Page<>();
}
Page<MaterialStoreUsedDataVO> pageResult = new Page<>();
List<JSONObject> jsonObjects = JSON.parseArray(JSON.toJSONString(result.get("data")), JSONObject.class);
if (CollectionUtils.isEmpty(jsonObjects)) { if (CollectionUtils.isEmpty(jsonObjects)) {
return new Page<>(); return new Page<>();
} }
...@@ -383,15 +323,8 @@ public class MaterialDataAdaptor { ...@@ -383,15 +323,8 @@ public class MaterialDataAdaptor {
materialStoreUsedDataVO.setStartTime(startTime); materialStoreUsedDataVO.setStartTime(startTime);
materialStoreUsedDataVO.setEndTime(endTime); materialStoreUsedDataVO.setEndTime(endTime);
} }
JSONObject jsonObject = JSON.parseObject(JSON.toJSONString(result.get("page")), JSONObject.class); pageData.setResult(materialStoreUsedDataVOS);
int totalCount = jsonObject.getIntValue("totalCount"); return pageData;
int totalPage = jsonObject.getIntValue("totalPage");
pageResult.setTotalCount(totalCount);
pageResult.setTotalPage(totalPage);
pageResult.setCurrentPage(pageNo);
pageResult.setPageSize(pageSize);
pageResult.setResult(materialStoreUsedDataVOS);
return pageResult;
} }
/** /**
...@@ -426,9 +359,7 @@ public class MaterialDataAdaptor { ...@@ -426,9 +359,7 @@ public class MaterialDataAdaptor {
} }
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("inFields", inlineParams);
if (StringUtils.isNotBlank(clerkId)) { if (StringUtils.isNotBlank(clerkId)) {
inlineParams.put("clerkId", clerkId); inlineParams.put("clerkId", clerkId);
} }
...@@ -437,7 +368,7 @@ public class MaterialDataAdaptor { ...@@ -437,7 +368,7 @@ public class MaterialDataAdaptor {
if (CollectionUtil.isNotEmpty(storeIds)) { if (CollectionUtil.isNotEmpty(storeIds)) {
inlineParams.put("storeId", StringUtils.join(storeIds, ",")); inlineParams.put("storeId", StringUtils.join(storeIds, ","));
} }
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), apolloKey); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), apolloKey);
if (result.get("data") == null) { if (result.get("data") == null) {
MaterialAreaUsedDataVO materialAreaUsedDataVO = new MaterialAreaUsedDataVO(); MaterialAreaUsedDataVO materialAreaUsedDataVO = new MaterialAreaUsedDataVO();
materialAreaUsedDataVO.setStartTime(startTime); materialAreaUsedDataVO.setStartTime(startTime);
...@@ -445,7 +376,7 @@ public class MaterialDataAdaptor { ...@@ -445,7 +376,7 @@ public class MaterialDataAdaptor {
materialAreaUsedDataVO.setBrandName(enterpriseDTO.getBrandName()); materialAreaUsedDataVO.setBrandName(enterpriseDTO.getBrandName());
return materialAreaUsedDataVO; return materialAreaUsedDataVO;
} }
List<JSONObject> jsonObjects = JSON.parseArray(JSON.toJSONString(result.get("data")), JSONObject.class); List<JSONObject> jsonObjects = DataApiUtils.getDataList(result);
if (CollectionUtils.isEmpty(jsonObjects)) { if (CollectionUtils.isEmpty(jsonObjects)) {
MaterialAreaUsedDataVO materialAreaUsedDataVO = new MaterialAreaUsedDataVO(); MaterialAreaUsedDataVO materialAreaUsedDataVO = new MaterialAreaUsedDataVO();
materialAreaUsedDataVO.setStartTime(startTime); materialAreaUsedDataVO.setStartTime(startTime);
...@@ -469,21 +400,6 @@ public class MaterialDataAdaptor { ...@@ -469,21 +400,6 @@ public class MaterialDataAdaptor {
return materialAreaUsedDataVO; return materialAreaUsedDataVO;
} }
private Map<String, Object> doHttp(String jsonParam, String apolloKey) {
try {
log.info("调用接口 apolloKey:{}, 参数:{}", apolloKey, jsonParam);
Map<String, Object> result = DataTargetHttpUtils.http(jsonParam, apolloKey);
if (result == null) {
return Collections.emptyMap();
}
return result;
} catch (Exception ex) {
log.info("请求接口失败 apolloKey:{}", apolloKey, ex);
}
return Collections.emptyMap();
}
/** /**
* 会员最近30天的浏览素材数量 * 会员最近30天的浏览素材数量
* *
...@@ -495,19 +411,14 @@ public class MaterialDataAdaptor { ...@@ -495,19 +411,14 @@ public class MaterialDataAdaptor {
*/ */
public Map<String, Integer> queryMemberVisitMap(String enterpriseId, String storeId, String clerkId, List<String> memberIds) { public Map<String, Integer> queryMemberVisitMap(String enterpriseId, String storeId, String clerkId, List<String> memberIds) {
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>(); Map<String, Object> inlineParams = new HashMap<>();
params.put("inFields", inlineParams);
if (StringUtils.isNotBlank(clerkId)) { if (StringUtils.isNotBlank(clerkId)) {
inlineParams.put("clerkId", clerkId); inlineParams.put("clerkId", clerkId);
} }
inlineParams.put("enterpriseId", enterpriseId); inlineParams.put("enterpriseId", enterpriseId);
inlineParams.put("customerId", StringUtils.join(memberIds, ",")); inlineParams.put("customerId", StringUtils.join(memberIds, ","));
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MEMBER_RECENTLY_30_DAY_VISIT); Map<String, Object> result = DataApiUtils.http(JSON.toJSONString(inlineParams), MEMBER_RECENTLY_30_DAY_VISIT);
if (result.get("data") == null) { List<MemberVisitMaterialBO> memberVisitMaterialBos = DataApiUtils.parseDataList(result, MemberVisitMaterialBO.class);
return Collections.emptyMap();
}
List<MemberVisitMaterialBO> memberVisitMaterialBos = JSON.parseArray(JSON.toJSONString(result.get("data")), MemberVisitMaterialBO.class);
if (CollectionUtils.isEmpty(memberVisitMaterialBos)) { if (CollectionUtils.isEmpty(memberVisitMaterialBos)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
......
package com.gic.haoban.manage.web.exception; package com.gic.haoban.manage.web.exception;
import com.gic.commons.exception.DataApiException;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.haoban.base.api.common.ShowFrontMessageException; import com.gic.haoban.base.api.common.ShowFrontMessageException;
import com.gic.haoban.common.utils.HaobanResponse; import com.gic.haoban.common.utils.HaobanResponse;
...@@ -133,4 +134,17 @@ public class GlobalExceptionHandler extends WebBaseController { ...@@ -133,4 +134,17 @@ public class GlobalExceptionHandler extends WebBaseController {
public HaobanResponse controllerNoLoginException(HttpServletResponse response, NoLoginException ex) { public HaobanResponse controllerNoLoginException(HttpServletResponse response, NoLoginException ex) {
return resultResponse(HaoBanErrCode.ERR_4); return resultResponse(HaoBanErrCode.ERR_4);
} }
/**
* 数据组API错误
* @param response
* @param ex
* @return
*/
@ResponseBody
@ExceptionHandler(DataApiException.class)
public HaobanResponse dataApiException(HttpServletResponse response, DataApiException ex) {
logger.info("DataApiException异常信息", ex);
return resultResponse(HaoBanErrCode.ERR_3);
}
} }
...@@ -2,6 +2,9 @@ package com.gic.haoban.manage.web.qo.content.statistics; ...@@ -2,6 +2,9 @@ package com.gic.haoban.manage.web.qo.content.statistics;
import lombok.Data; import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Author MUSI * @Author MUSI
* @Date 2023/3/23 1:00 PM * @Date 2023/3/23 1:00 PM
...@@ -30,4 +33,17 @@ public class MaterialAnalyzeDataQO extends MaterialStatisticsBaseQO { ...@@ -30,4 +33,17 @@ public class MaterialAnalyzeDataQO extends MaterialStatisticsBaseQO {
* desc * desc
*/ */
private String order; private String order;
public Map<String, Integer> getFieldsOrder() {
Map<String, Integer> map = new HashMap<>();
map.put("enterpriseId", 1);
map.put("useMatlDayNum", 11);
map.put("useMatlNum", 12);
map.put("singleMatlAvgCnt", 13);
return map;
}
public String getDefaultFields() {
return "enterpriseId";
}
} }
...@@ -2,6 +2,9 @@ package com.gic.haoban.manage.web.qo.content.statistics; ...@@ -2,6 +2,9 @@ package com.gic.haoban.manage.web.qo.content.statistics;
import lombok.Data; import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/** /**
* @Author MUSI * @Author MUSI
* @Date 2023/3/23 12:48 PM * @Date 2023/3/23 12:48 PM
...@@ -38,4 +41,24 @@ public class MaterialReportQO extends MaterialStatisticsBaseQO { ...@@ -38,4 +41,24 @@ public class MaterialReportQO extends MaterialStatisticsBaseQO {
* 业务周期 * 业务周期
*/ */
private String bizDate; private String bizDate;
public Map<String, Integer> getFieldsOrder() {
Map<String, Integer> map = new HashMap<>();
map.put("enterpriseId", 1);
map.put("useMatlNum", 5);
map.put("useMatlNumRank", 6);
map.put("useMatlNumRatio", 7);
map.put("userClickNum", 8);
map.put("userClickNumRatio", 9);
map.put("convUserNum", 10);
map.put("convUserNumRatio", 11);
map.put("convSalesAmt", 12);
map.put("convSalesAmtRank", 13);
map.put("convSalesAmtRatio", 14);
return map;
}
public String getDefaultFields() {
return "enterpriseId";
}
} }
package com.gic.haoban.manage.web.qo.content.statistics;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* @Author MUSI
* @Date 2023/3/23 1:00 PM
* @Description
* @Version
**/
@Data
public class MaterialStoreAnalyzeDataQO extends MaterialStatisticsBaseQO {
private static final long serialVersionUID = 3422937373665522931L;
/**
* 时间筛选
* 1 过去7天(默认选中),2 过去30天,3 过去60天,4 过去90天,5本周,6 本月,7 上月,8 上上月,9 上上上月
*/
private Integer fixedDateDiff;
/**
* 排序字段
* 日均使用导购占比
* 转化客户数
*/
private String orderByField;
/**
* asc
* desc
*/
private String order;
public Map<String, Integer> getFieldsOrder() {
Map<String, Integer> map = new HashMap<>();
map.put("enterpriseId", 1);
map.put("dayAvgUseMatlNum", 5);
map.put("dayAvgUseRate", 6);
map.put("clickUserNum", 7);
map.put("convUserNum", 8);
map.put("convSalesNmt", 9);
return map;
}
public String getDefaultFields() {
return "enterpriseId";
}
}
package com.gic.haoban.manage.web.qo.content.statistics;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
/**
* @Author MUSI
* @Date 2023/3/23 12:48 PM
* @Description
* @Version
* 素材
**/
@Data
public class MaterialStoreReportQO extends MaterialStatisticsBaseQO {
private static final long serialVersionUID = -4105397589798480404L;
/**
* 数据类型
* 1 周报; 2 月报
* @see com.gic.haoban.manage.api.enums.content.MaterialReportType
*/
private Integer reportType;
/**
* 排序字段
* 日均使用导购占比
* 转化客户数
*/
private String orderByField;
/**
* asc
* desc
*/
private String order;
/**
* 业务周期
*/
private String bizDate;
public Map<String, Integer> getFieldsOrder() {
Map<String, Integer> map = new HashMap<>();
map.put("enterpriseId", 1);
map.put("dayAvgUseMatlNum", 4);
map.put("dayAvgUseMatlNumRatio", 5);
map.put("dayAvgUseBindProportion", 6);
map.put("dayAvgUseBindProportionRatio", 7);
map.put("userClickNum", 8);
map.put("userClickNumRatio", 9);
map.put("convUserNum", 10);
map.put("convUserNumRatio", 11);
map.put("convSalesAmt", 12);
map.put("convSalesAmtRank", 13);
map.put("convSalesAmtRatio", 14);
return map;
}
public String getDefaultFields() {
return "enterpriseId";
}
}
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