yangyj 1 год назад
Родитель
Сommit
a872edc4ba

+ 84 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/DataModel.java

@@ -1,12 +1,20 @@
 package org.springblade.manager.vo;
 import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.annotation.JSONField;
+
+import java.io.File;
+import java.lang.reflect.Modifier;
 import org.springblade.common.utils.BaseUtils;
 import org.springblade.common.utils.SystemUtils;
 import org.springblade.core.tool.utils.StringPool;
 
+import java.io.IOException;
 import java.lang.reflect.Field;
+import java.net.JarURLConnection;
+import java.net.URL;
 import java.util.*;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
 import java.util.stream.Collectors;
 
 /**
@@ -106,7 +114,7 @@ public  interface DataModel {
         }
 
         /*扫描指定包,并获取所有实现DataModel的类,按照ID排序返回*/
-        static List<Class<?>> findClassesByInterface(String packageName, Class<?> interfaceClass) {
+        /*static List<Class<?>> findClassesByInterface(String packageName, Class<?> interfaceClass) {
             List<Class<?>> targetList = new ArrayList<>();
             Map<Class<?>, String> classIdMap = new HashMap<>();
             try {
@@ -154,6 +162,81 @@ public  interface DataModel {
                 return id1.compareTo(id2);
             });
             return targetList;
+        }*/
+
+     static List<Class<?>> findClassesByInterface(String packageName, Class<?> interfaceClass) {
+        List<Class<?>> targetList = new ArrayList<>();
+        Map<Class<?>, String> classIdMap = new HashMap<>();
+        try {
+            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+            String path = packageName.replace('.', '/');
+            Enumeration<URL> resources = classLoader.getResources(path);
+
+            while (resources.hasMoreElements()) {
+                URL resource = resources.nextElement();
+                if (resource == null) {
+                    continue;
+                }
+
+                if (resource.getProtocol().equals("file")) {
+                    File dir = new File(resource.getFile());
+                    if (!dir.exists()) {
+                        continue;
+                    }
+                    File[] files = dir.listFiles();
+                    if (files == null) {
+                        continue;
+                    }
+                    for (File file : files) {
+                        String fileName = file.getName();
+                        if (fileName.endsWith(".class")) {
+                            String className = packageName + '.' + fileName.substring(0, fileName.length() - 6);
+                            loadClass(interfaceClass, targetList, classIdMap, className);
+                        }
+                    }
+                } else if (resource.getProtocol().equals("jar")) {
+                    JarURLConnection jarConnection = (JarURLConnection) resource.openConnection();
+                    try (JarFile jarFile = jarConnection.getJarFile()) {
+                        Enumeration<JarEntry> entries = jarFile.entries();
+                        while (entries.hasMoreElements()) {
+                            JarEntry entry = entries.nextElement();
+                            String entryName = entry.getName();
+                            if (entryName.startsWith(path) && entryName.endsWith(".class") && !entryName.contains("$")) {
+                                String className = entryName.replace('/', '.').substring(0, entryName.length() - 6);
+                                loadClass(interfaceClass, targetList, classIdMap, className);
+                            }
+                        }
+                    }
+                }
+            }
+        } catch (IOException e) {
+            StaticLog.error("IOException: " + e.getMessage());
+        }
+
+        targetList.sort((c1, c2) -> {
+            String id1 = classIdMap.get(c1);
+            String id2 = classIdMap.get(c2);
+            return id1.compareTo(id2);
+        });
+        return targetList;
+    }
+
+     static void loadClass(Class<?> interfaceClass, List<Class<?>> targetList, Map<Class<?>, String> classIdMap, String className) {
+        try {
+            Class<?> clazz = Class.forName(className);
+            if (interfaceClass.isAssignableFrom(clazz) && !clazz.isInterface() && java.lang.reflect.Modifier.isPublic(clazz.getModifiers())) {
+                try {
+                    Field idField = clazz.getField("ID");
+                    String idValue = (String) idField.get(null);
+                    classIdMap.put(clazz, idValue);
+                } catch (NoSuchFieldException | IllegalAccessException e) {
+                    StaticLog.error(e.getMessage());
+                }
+                targetList.add(clazz);
+            }
+        } catch (ClassNotFoundException e) {
+            StaticLog.error("ClassNotFoundException: " + e.getMessage());
         }
+    }
 
 }

+ 4 - 1
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/vo/MeterPeriodInfo.java

@@ -33,6 +33,8 @@ public class MeterPeriodInfo implements  DataModel{
     private String year;
     @JSONField(name = "key_13",label="当期月份",ordinal = 3)
     private String month;
+    @JSONField(name = "key_15",label="月日",ordinal = 3)
+    private String day;
     /**上期累计金额*/
     @JSONField(name = "key_4",label="上期累计金额",ordinal = 4)
     private String  preTotal;
@@ -70,7 +72,8 @@ public class MeterPeriodInfo implements  DataModel{
     private LocalDate endDate;
 
     public void init(){
-        this.month= String.valueOf(formPrintDate.getMonth());
+        this.month= String.valueOf(formPrintDate.getMonthValue());
         this.year= String.valueOf(formPrintDate.getYear());
+        this.day=String.valueOf(formPrintDate.getDayOfMonth());
     }
 }

+ 22 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeController.java

@@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
 import org.hibernate.validator.internal.engine.messageinterpolation.InterpolationTermType;
 import org.springblade.common.utils.CommonUtil;
+import org.springblade.common.utils.SystemUtils;
 import org.springblade.core.cache.utils.CacheUtil;
 import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.log.exception.ServiceException;
@@ -45,6 +46,7 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.io.IOException;
+import java.net.URL;
 import java.util.*;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
@@ -335,11 +337,30 @@ public class WbsTreeController extends BladeController {
     @GetMapping("/test5")
     public R test(Integer type) {
         if(type==1){
-          return    R.data(DataModel.getTreeNodeList());
+            return    R.data(DataModel.getTreeNodeList());
         }else if(type==2){
             return R.data(DataModel.findClassesByInterface(DataModel.PATH, DataModel.class));
         }else if(type==3){
             return R.data(!DataModel.once);
+        }else if(type==5){
+            return R.data(SystemUtils.getOsName());
+        }else if(type==6){
+            List<String> url=new ArrayList<>();
+            try {
+                ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+                String path = DataModel.PATH.replace('.', '/');
+                Enumeration<URL> resources = classLoader.getResources(path);
+                while (resources.hasMoreElements()) {
+                    URL resource = resources.nextElement();
+                    if (resource == null) {
+                        continue;
+                    }
+                    url.add(resource.getProtocol());
+                }
+            }catch(Exception e){
+                e.printStackTrace();
+            }
+              return R.data(url);
         }else {
             return R.data(DataModel.classes.size()==0);
         }

+ 3 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/ExecutorMeter.java

@@ -701,7 +701,7 @@ public class ExecutorMeter extends FormulaExecutor {
                          ic.setChapterSeq(certificate.getChapterSeq());
                            if(certificate.getIsSummary()){
                                peerMap.put(certificate,ic);
-                           }else if(certificate.getNoApply()!=1){
+                           }else if(StringUtils.isNotEquals(certificate.getNoApply(),1)){
                                InterimPayCertificateItem pre =previousMap.get(certificate.getChapterSeq());
                                if(pre!=null){
                                    ic.setPreviousPeriodEndPay(pre.getCurrentPeriodEndPay());
@@ -1012,10 +1012,12 @@ public class ExecutorMeter extends FormulaExecutor {
             totalList.forEach(e->{
                 subprojectInterimPaymentSummary.add(e.copy());
             });
+            /*按章节分组*/
             LinkedHashMap<String,List<SubprojectInterimPaymentSummary>> chapterGroup= totalList.stream().sorted(Comparator.comparing(e->getPrefix(e.getFormNumber()))).collect(Collectors.groupingBy(e->getPrefix(e.getFormNumber()),LinkedHashMap::new,Collectors.toList()));
             AtomicInteger loop = new AtomicInteger(chapterGroup.size());
             List<String> chapterNames= new ArrayList<>();
             chapterGroup.forEach((k,v)->{
+                /*判断是否是最后一章*/
                 int extra=loop.getAndDecrement()>1?1:2;
                 /*每章小结或总结等价一行数据*/
                 int dataLength=v.size()+extra;