|
|
@ -6,7 +6,6 @@ import cn.estsh.i3plus.platform.common.tool.ClassTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
import cn.estsh.i3plus.platform.common.util.PlatformConstWords;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.BaseResultBean;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.ClassFieldModel;
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.ClassFieldModel;
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.ClassModel;
|
|
|
|
import cn.estsh.i3plus.pojo.model.common.ClassModel;
|
|
|
@ -17,18 +16,14 @@ import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.persistence.Transient;
|
|
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
@ -37,7 +32,7 @@ import java.util.List;
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping(PlatformConstWords.BASE_URL + "/cloud/report")
|
|
|
|
@RequestMapping(PlatformConstWords.BASE_URL + "/cloud/report")
|
|
|
|
@Api(description = "报表服务")
|
|
|
|
@Api(tags = "报表服务")
|
|
|
|
public class CoreReportController extends CoreBaseController {
|
|
|
|
public class CoreReportController extends CoreBaseController {
|
|
|
|
|
|
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(CoreReportController.class);
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(CoreReportController.class);
|
|
|
@ -140,14 +135,7 @@ public class CoreReportController extends CoreBaseController {
|
|
|
|
LOGGER.info("【类信息:{}】", clzNameList);
|
|
|
|
LOGGER.info("【类信息:{}】", clzNameList);
|
|
|
|
List<ClassModel> clzList = new ArrayList<>(clzNameList.size());
|
|
|
|
List<ClassModel> clzList = new ArrayList<>(clzNameList.size());
|
|
|
|
for (String clzName : clzNameList) {
|
|
|
|
for (String clzName : clzNameList) {
|
|
|
|
ClassModel model = getClassModel(clzName);
|
|
|
|
ClassModel model = ClassTool.getClassModel(clzName);
|
|
|
|
if (model != null) {
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(model.getClzFullName())) {
|
|
|
|
|
|
|
|
List<ClassFieldModel> list = getClassFieldModel(model.getClzFullName());
|
|
|
|
|
|
|
|
model.setFieldList(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
clzList.add(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ResultBean.success("获取类:" + clzList.size()).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(clzList);
|
|
|
|
return ResultBean.success("获取类:" + clzList.size()).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultList(clzList);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -161,13 +149,7 @@ public class CoreReportController extends CoreBaseController {
|
|
|
|
@ApiOperation(value = "查询管理后台所有类", notes = "根据核心包路径列出所有类")
|
|
|
|
@ApiOperation(value = "查询管理后台所有类", notes = "根据核心包路径列出所有类")
|
|
|
|
public BaseResultBean<ClassModel> getClzModel(@PathVariable("classPath") String classPath) {
|
|
|
|
public BaseResultBean<ClassModel> getClzModel(@PathVariable("classPath") String classPath) {
|
|
|
|
LOGGER.info("【类路径:{}】", pojoPackagePath);
|
|
|
|
LOGGER.info("【类路径:{}】", pojoPackagePath);
|
|
|
|
ClassModel model = getClassModel(classPath);
|
|
|
|
ClassModel model = ClassTool.getClassModel(classPath);
|
|
|
|
if (model != null) {
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(model.getClzFullName())) {
|
|
|
|
|
|
|
|
List<ClassFieldModel> list = getClassFieldModel(model.getClzFullName());
|
|
|
|
|
|
|
|
model.setFieldList(list);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultBean.success("获取类:" + model.getClzDesc()).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(model);
|
|
|
|
return ResultBean.success("获取类:" + model.getClzDesc()).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -182,7 +164,7 @@ public class CoreReportController extends CoreBaseController {
|
|
|
|
List<String> clzNameList = ClassTool.getClassName(pojoPackagePath, true);
|
|
|
|
List<String> clzNameList = ClassTool.getClassName(pojoPackagePath, true);
|
|
|
|
List<ClassModel> clzList = new ArrayList<>(clzNameList.size());
|
|
|
|
List<ClassModel> clzList = new ArrayList<>(clzNameList.size());
|
|
|
|
for (String clzName : clzNameList) {
|
|
|
|
for (String clzName : clzNameList) {
|
|
|
|
clzList.add(getClassModel(clzName));
|
|
|
|
clzList.add(ClassTool.getClassModel(clzName));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("获取类:" + clzList.size())
|
|
|
|
return ResultBean.success("获取类:" + clzList.size())
|
|
|
@ -199,78 +181,12 @@ public class CoreReportController extends CoreBaseController {
|
|
|
|
@ApiOperation(value = "查询类所有属性")
|
|
|
|
@ApiOperation(value = "查询类所有属性")
|
|
|
|
public ResultBean<ClassFieldModel> testWms(@RequestParam("clzFullName") String clzFullName) {
|
|
|
|
public ResultBean<ClassFieldModel> testWms(@RequestParam("clzFullName") String clzFullName) {
|
|
|
|
LOGGER.info("【查询类属性:{}】", clzFullName);
|
|
|
|
LOGGER.info("【查询类属性:{}】", clzFullName);
|
|
|
|
List<ClassFieldModel> fieldModelList = getClassFieldModel(clzFullName);
|
|
|
|
List<ClassFieldModel> fieldModelList = ClassTool.getClassFieldModel(clzFullName);
|
|
|
|
return ResultBean.success("获取属性:" + fieldModelList.size())
|
|
|
|
return ResultBean.success("获取属性:" + fieldModelList.size())
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
.setResultList(fieldModelList);
|
|
|
|
.setResultList(fieldModelList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取类信息
|
|
|
|
|
|
|
|
* @param clzName 全类名
|
|
|
|
|
|
|
|
* @return 类信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private ClassModel getClassModel(String clzName) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
LOGGER.info("【获取类信息:{}】", clzName);
|
|
|
|
|
|
|
|
//注册类
|
|
|
|
|
|
|
|
Class tmpClz = Class.forName(clzName);
|
|
|
|
|
|
|
|
ClassModel classModel = new ClassModel();
|
|
|
|
|
|
|
|
classModel.setServerId(CommonEnumUtil.SOFT_TYPE.CORE.getValue());
|
|
|
|
|
|
|
|
classModel.setServerName(CommonEnumUtil.SOFT_TYPE.CORE.getCode());
|
|
|
|
|
|
|
|
classModel.setPackageName(pojoPackagePath);
|
|
|
|
|
|
|
|
classModel.setClzFullName(clzName);
|
|
|
|
|
|
|
|
classModel.setClzSimpleName(tmpClz.getSimpleName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Api api = ( Api ) tmpClz.getAnnotation(Api.class);
|
|
|
|
|
|
|
|
if (api != null) {
|
|
|
|
|
|
|
|
classModel.setClzDesc(api.value());
|
|
|
|
|
|
|
|
return classModel;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
LOGGER.warn("不添加类:{},因为没有添加api描述", tmpClz);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
|
|
|
|
LOGGER.error("【类:{}注册出错】", clzName, clzName, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询类型属性
|
|
|
|
|
|
|
|
* @param clzFullName 全类名
|
|
|
|
|
|
|
|
* @return 属性集合
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private List<ClassFieldModel> getClassFieldModel(String clzFullName) {
|
|
|
|
|
|
|
|
List<ClassFieldModel> fieldModelList = new ArrayList<>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
Class tmpClz = Class.forName(clzFullName);
|
|
|
|
|
|
|
|
List<Field> fields = ClassTool.getAllFieldsList(tmpClz);
|
|
|
|
|
|
|
|
ClassFieldModel fieldModel = null;
|
|
|
|
|
|
|
|
ApiParam apiParam;
|
|
|
|
|
|
|
|
Transient tran;
|
|
|
|
|
|
|
|
for (Field f : fields) {
|
|
|
|
|
|
|
|
tran = f.getAnnotation(Transient.class);
|
|
|
|
|
|
|
|
if (tran == null && !"serialVersionUID".equals(f.getName())) {
|
|
|
|
|
|
|
|
// 临时对象不需要处理
|
|
|
|
|
|
|
|
fieldModel = new ClassFieldModel();
|
|
|
|
|
|
|
|
fieldModel.setPackageName(pojoPackagePath);
|
|
|
|
|
|
|
|
fieldModel.setClzFullName(clzFullName);
|
|
|
|
|
|
|
|
fieldModel.setClzSimpleName(tmpClz.getSimpleName());
|
|
|
|
|
|
|
|
fieldModel.setFieldName(f.getName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apiParam = f.getAnnotation(ApiParam.class);
|
|
|
|
|
|
|
|
if (apiParam != null) {
|
|
|
|
|
|
|
|
fieldModel.setFieldDesc(apiParam.value());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fieldModelList.add(fieldModel);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
LOGGER.info("【临时属性:{}】", f.getName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (ClassNotFoundException e) {
|
|
|
|
|
|
|
|
LOGGER.error("【类:{}实例化出错】", clzFullName, e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return fieldModelList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|