Răsfoiți Sursa

Merge branch 'dev' of licailing/uwip into master

licailing 4 ani în urmă
părinte
comite
cbfcc0b89f

+ 2 - 0
src/main/java/com/izouma/uwip/repo/PatentRepo.java

@@ -16,4 +16,6 @@ public interface PatentRepo extends JpaRepository<Patent, Long>, JpaSpecificatio
 
     @Query(nativeQuery = true, value = "select ifnull(max(sort + 1),1) from  patent where del = false")
     int findMax();
+
+    Patent findByApplyNo(String applyNo);
 }

+ 20 - 12
src/main/java/com/izouma/uwip/utils/JpaUtils.java

@@ -230,16 +230,17 @@ public class JpaUtils {
                 String[] arr = ((String) value).split(",");
                 List<Predicate> and = new ArrayList<>();
                 LocalDateTime start = DateTimeUtils.toLocalDateTime(arr[0], "yyyy-MM-dd HH:mm:ss");
+                LocalDateTime end = DateTimeUtils.toLocalDateTime(arr[1], "yyyy-MM-dd HH:mm:ss");
+
                 if (isPatent) {
                     and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("patent")
                             .get(property), start));
-                }
-                and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
-                LocalDateTime end = DateTimeUtils.toLocalDateTime(arr[1], "yyyy-MM-dd HH:mm:ss");
-                if (isPatent) {
                     and.add(criteriaBuilder.lessThanOrEqualTo(root.get("patent").get(property), end));
+                } else {
+                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                    and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
                 }
-                and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
+
                 return criteriaBuilder.and(and.toArray(new Predicate[0]));
             } else {
                 if (isPatent) {
@@ -262,27 +263,34 @@ public class JpaUtils {
                     }
                     return criteriaBuilder.greaterThanOrEqualTo(root.get(property), start);
                 } else if (list.size() == 2) {
+                    List<Predicate> and = new ArrayList<>();
+                    LocalDate start = DateTimeUtils
+                            .toLocalDate((String) list.get(0), "yyyy-MM-dd");
                     LocalDate end = DateTimeUtils
                             .toLocalDate((String) list.get(1), "yyyy-MM-dd");
                     if (isPatent) {
-                        return criteriaBuilder.lessThanOrEqualTo(root.get("patent").get(property), end);
+                        and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("patent").get(property), start));
+                        and.add(criteriaBuilder.lessThanOrEqualTo(root.get("patent").get(property), end));
+                    } else {
+                        and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                        and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
                     }
-                    return criteriaBuilder.lessThanOrEqualTo(root.get(property), end);
+
+                    return criteriaBuilder.and(and.toArray(new Predicate[0]));
                 }
             } else if (value instanceof String && Pattern
                     .matches("^\\d{4}-\\d{2}-\\d{2},\\d{4}-\\d{2}-\\d{2}$", (String) value)) {
                 String[] arr = ((String) value).split(",");
                 List<Predicate> and = new ArrayList<>();
                 LocalDate start = DateTimeUtils.toLocalDate(arr[0], "yyyy-MM-dd");
-                if (isPatent) {
-                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("patent").get(property), start));
-                }
-                and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
                 LocalDate end = DateTimeUtils.toLocalDate(arr[1], "yyyy-MM-dd");
                 if (isPatent) {
+                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get("patent").get(property), start));
                     and.add(criteriaBuilder.lessThanOrEqualTo(root.get("patent").get(property), end));
+                } else {
+                    and.add(criteriaBuilder.greaterThanOrEqualTo(root.get(property), start));
+                    and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
                 }
-                and.add(criteriaBuilder.lessThanOrEqualTo(root.get(property), end));
                 return criteriaBuilder.and(and.toArray(new Predicate[0]));
             } else {
                 if (isPatent) {

+ 1 - 1
src/main/vue/src/views/Maintenances.vue

@@ -135,7 +135,7 @@ export default {
                         '/maintenance/save',
                         {
                             ...data,
-                            active: false,
+                            del: true,
                             children: null
                         },
                         { body: 'json' }

+ 3 - 1
src/test/java/com/izouma/uwip/service/CountryPatentServiceTest.java

@@ -1,5 +1,6 @@
 package com.izouma.uwip.service;
 
+import cn.hutool.core.collection.CollUtil;
 import com.izouma.uwip.ApplicationTests;
 import com.izouma.uwip.domain.CountryPatent;
 import com.izouma.uwip.dto.CountryPatentDTO;
@@ -37,7 +38,8 @@ public class CountryPatentServiceTest extends ApplicationTests {
     @Test
     public void allDTO() {
         PageQuery pageQuery = new PageQuery();
-        pageQuery.getQuery().put("applyStatus","APPLY_STAGE");
+//        pageQuery.getQuery().put("applyStatus","APPLY_STAGE");
+        pageQuery.getQuery().put("applyDate",CollUtil.newArrayList("2021-06-06","2021-06-07"));
         List<CountryPatent> content = countryPatentService.allDTO(pageQuery).getContent();
         content.forEach(System.out::println);
     }