Commit f407fb7e by guojx

数据通用接口&指标

parent 237df35a
package com.gic.haoban.manage.web.controller.data;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.util.DataApiUtils;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.data.DataIndexEvaluateLogDTO;
import com.gic.enterprise.api.dto.data.DataIndexExplainDTO;
import com.gic.enterprise.api.service.data.DataIndexApiService;
import com.gic.haoban.manage.web.qo.data.DataIndexExplainVO;
import com.gic.haoban.manage.web.qo.data.DataIndexQO;
import com.gic.haoban.manage.web.qo.data.HandleQO;
import com.gic.haoban.manage.web.utils.StoreAuthUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 数据调用通用接口
* @Author guojx
* @Date 2023/11/14 10:56
*/
@RestController
@RequestMapping("data")
@Slf4j
public class DataController {
@Autowired
private StoreAuthUtils storeAuthUtils;
@Autowired
private DataIndexApiService dataIndexApiService;
/**
* 数据统一调用接口
* 参数与返回字段查询数据组的yapi的对应文档
* @param qo
* @return
*/
@RequestMapping(value = "handle")
public RestResponse handle(@RequestBody HandleQO qo) {
String params = qo.getParams();
JSONObject jsonObject = JSONObject.parseObject(params);
if (jsonObject == null) {
jsonObject = new JSONObject();
}
if (StringUtils.isNotBlank(qo.getEnterpriseId())) {
jsonObject.put("enterpriseId", qo.getWxEnterpriseId());
}
List<String> storeIdList = new ArrayList<>();
String storeId = qo.getStoreId();
if (StringUtils.isBlank(storeId)) {
storeIdList = storeAuthUtils.queryClerkStoreIds(qo.getClerkId(), qo.getWxEnterpriseId());
} else {
storeIdList.add(storeId);
}
if (CollectionUtils.isNotEmpty(storeIdList)) {
//区经有全部门店权限
jsonObject.put("storeId", storeIdList.stream().collect(Collectors.joining(",")));
}
Map<String, Object> res = DataApiUtils.http(params, qo.getApolloKey());
JSONObject data = (JSONObject) res.get("data");
return RestResponse.successResult(data);
}
/**
* 指标字典列表
* @return
*/
@RequestMapping("list-data-index-explain")
public RestResponse<List<DataIndexExplainVO>> listDataIndexExplain() {
List<DataIndexExplainDTO> list = dataIndexApiService.listDataIndexExplain();
return RestResponse.successResult(EntityUtil.changeEntityListNew(DataIndexExplainVO.class, list));
}
/**
* 评价指标
* @param qo
* @return
*/
@RequestMapping("evaluate-data-index")
public RestResponse saveDataIndexEvaluate(@RequestBody DataIndexQO qo) {
DataIndexEvaluateLogDTO log = EntityUtil.changeEntityNew(DataIndexEvaluateLogDTO.class, qo);
log.setAccountId(qo.getClerkId());
log.setSourceType(1);
dataIndexApiService.saveDataIndexEvaluateLog(log);
return RestResponse.successResult();
}
private JSONObject getTotalJson(JSONObject param, String apolloKey) {
Map<String, Object> totalRes = DataApiUtils.http(param.toJSONString(), apolloKey);
List<JSONObject> totalList = DataApiUtils.getPageList(totalRes);
if (CollectionUtils.isEmpty(totalList)) {
return null;
}
JSONObject total = totalList.get(0);
return total;
}
}
package com.gic.haoban.manage.web.qo.data;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author guojx
* @Date 2023/9/27 11:13
*/
@Data
public class DataIndexExplainVO implements Serializable {
private String id;
private String indexCode;
private String indexName;
private String indexExplain;
/**
* 前端使用:指标说明:若指标注释中有需要说明的
*/
private List<String> indexRemarkList;
/**
* 前端使用:指标例子
*/
private List<String> indexExampleList;
/**
* 指标说明:若指标注释中有需要说明的,英文分号隔开,可能多个。
*/
private String indexRemark;
/**
* 指标例子: 英文分号隔开,可能多个
*/
private String indexExample;
/**
* yapi文档上的驼峰字段名称
*/
private String apiColName;
public List<String> getIndexRemarkList() {
if (StringUtils.isNotBlank(indexRemark)) {
return Arrays.stream(indexRemark.split(";")).collect(Collectors.toList());
}
return indexRemarkList;
}
public List<String> getIndexExampleList() {
if (StringUtils.isNotBlank(indexExample)) {
return Arrays.stream(indexExample.split(";")).collect(Collectors.toList());
}
return indexExampleList;
}
}
package com.gic.haoban.manage.web.qo.data;
import lombok.Data;
import java.io.Serializable;
/**
* @Author guojx
* @Date 2023/9/27 11:06
*/
@Data
public class DataIndexQO implements Serializable {
/**
* 指标code
*/
private String indexCode;
/**
* 指标名称
*/
private String indexName;
/**
* 0:不满意 1:满意
*/
private Integer indexEvaluate;
/**
* 不满意原因
*/
private String reason;
/**
* 自定义原因
*/
private String customReason;
private String enterpriseId;
private String clerkId;
}
package com.gic.haoban.manage.web.qo.data;
import lombok.Data;
import java.io.Serializable;
/**
* @Author guojx
* @Date 2023/11/23 9:13
*/
@Data
public class HandleQO implements Serializable {
/**
* 组装的参数,JSON字符串.数据组提供的yapi文档上有.
* 注:门店参数storeId根据storeSelect参数计算
*/
private String params;
/**
* 数据组配置的接口key。数据组提供的yapi文档上有
*/
private String apolloKey;
/**
* 门店查询参数. 区经可以为空,查询所有管辖门店
*/
private String storeId;
/**
* 企业ID.
*/
private String enterpriseId;
/**
* 微信企业
*/
private String wxEnterpriseId;
/**
* 如果是区经,用于查询管辖门店权限
*/
private String clerkId;
}
......@@ -161,4 +161,5 @@
<dubbo:reference interface="com.gic.enterprise.api.service.content.ValueAddedServicesOrderApiService" id="valueAddedServicesOrderApiService"
timeout="10000" retries="0" check="false"/>
<dubbo:reference id="dataIndexApiService" interface="com.gic.enterprise.api.service.data.DataIndexApiService" timeout="10000" retries="0" check="false" />
</beans>
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