package org.springblade.code.service.impl;
|
|
import com.vci.mdm.annotation.MdmSerialAlgorithm;
|
import com.vci.mdm.pagemodel.CodeSerialAlgorithmVO;
|
import com.vci.mdm.service.CodeSerialAlgorithmServiceI;
|
import com.vci.starter.web.pagemodel.DataGrid;
|
import com.vci.starter.web.util.ApplicationContextProvider;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.aop.framework.Advised;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* 流水算法的服务
|
* @author weidy
|
* @date 2022-2-17
|
*/
|
@Service
|
public class CodeSerialAlgorithmServiceImpl implements CodeSerialAlgorithmServiceI {
|
/**
|
* 获取流水算法的列表
|
*
|
* @return 流水算法的信息
|
*/
|
@Override
|
public DataGrid<CodeSerialAlgorithmVO> gridSerialAlgorithm() {
|
//使用主键去扫描
|
String[] beanNames = ApplicationContextProvider.getApplicationContext().getBeanNamesForAnnotation(MdmSerialAlgorithm.class);
|
List<CodeSerialAlgorithmVO> voList = new ArrayList<>();
|
if(beanNames!=null && beanNames.length>0){
|
for(String beanName : beanNames){
|
Object bean = ApplicationContextProvider.getApplicationContext().getBean(beanName);
|
if(bean!=null){
|
CodeSerialAlgorithmVO algorithmVO = new CodeSerialAlgorithmVO();
|
Advised advised = (Advised)bean;
|
Class<?> targetClass = advised.getTargetSource().getTargetClass();
|
algorithmVO.setClassFullName(targetClass.getName());
|
MdmSerialAlgorithm serialAlgorithm = targetClass.getDeclaredAnnotation(MdmSerialAlgorithm.class);
|
if(serialAlgorithm==null){
|
serialAlgorithm = targetClass.getAnnotation(MdmSerialAlgorithm.class);
|
}
|
if(serialAlgorithm !=null) {
|
algorithmVO.setName(serialAlgorithm.text());
|
algorithmVO.setDescription(serialAlgorithm.description());
|
algorithmVO.setId(serialAlgorithm.value());
|
if(StringUtils.isBlank(algorithmVO.getId())){
|
algorithmVO.setId(beanName);
|
}
|
voList.add(algorithmVO);
|
}
|
}
|
}
|
}
|
DataGrid<CodeSerialAlgorithmVO> dataGrid = new DataGrid<>();
|
dataGrid.setData(voList);
|
dataGrid.setTotal(voList.size());
|
return dataGrid;
|
}
|
}
|