¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.vci.ubcs.code.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vci.ubcs.code.annotation.MdmSerialAlgorithm; |
| | | import com.vci.ubcs.code.service.ICodeSerialAlgorithmService; |
| | | import com.vci.ubcs.code.vo.pagemodel.CodeSerialAlgorithmVO; |
| | | import com.vci.ubcs.starter.web.util.ApplicationContextProvider; |
| | | import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springframework.aop.framework.Advised; |
| | | import org.springframework.aop.support.AopUtils; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æµæ°´ç®æ³çæå¡ |
| | | * @author weidy |
| | | * @date 2022-2-17 |
| | | */ |
| | | @Service |
| | | public class CodeSerialAlgorithmServiceImpl implements ICodeSerialAlgorithmService { |
| | | /** |
| | | * è·åæµæ°´ç®æ³çå表 |
| | | * |
| | | * @return æµæ°´ç®æ³çä¿¡æ¯ |
| | | */ |
| | | @Override |
| | | public IPage<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 = AopUtils.getTargetClass(bean); |
| | | //Class<?> targetClass = advised.getTargetSource().getTargetClass(); |
| | | algorithmVO.setClassFullName(targetClass.getName()); |
| | | //algorithmVO.setClassFullName(beanName); |
| | | 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()); |
| | | algorithmVO.setSerialType(serialAlgorithm.serialType()); |
| | | if(StringUtils.isBlank(algorithmVO.getId())){ |
| | | algorithmVO.setId(beanName); |
| | | } |
| | | voList.add(algorithmVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | Query query=new Query(); |
| | | IPage<CodeSerialAlgorithmVO> queryIPage =Condition.getPage(query); |
| | | queryIPage.setRecords(voList); |
| | | return queryIPage; |
| | | } |
| | | } |