shjung 2 سال پیش
والد
کامیت
b9df81392d

+ 6 - 1
src/main/java/com/its/op/controller/its/facility/TbFcltInfrController.java

@@ -91,11 +91,16 @@ public class TbFcltInfrController {
         return this.service.deleteByIds(ids);
     }
 
-    @ApiOperation(value = "신규 ID 조회", response = NewIdLongDto.class)
+    @ApiOperation(value = "신규 시설물 관리번호 조회", response = NewIdLongDto.class)
     @GetMapping(value = "/new-id", produces = {"application/json; charset=utf8"})
     public NewIdLongDto getNewNmbr() {
         return this.service.getNewNmbr();
     }
 
+    @ApiOperation(value = "신규 시설물 ID 조회", response = NewIdLongDto.class)
+    @GetMapping(value = "/fclt/new-id/{type}", produces = {"application/json; charset=utf8"})
+    public NewIdLongDto getNewFcltId(@PathVariable("type") String type) {
+        return this.service.getNewFcltId(type);
+    }
 
 }

+ 3 - 0
src/main/java/com/its/op/dao/repository/its/facility/TbFcltInfrRepository.java

@@ -39,4 +39,7 @@ public interface TbFcltInfrRepository extends JpaRepository<TbFcltInfr, Long>, J
     @Query(value = "SELECT NVL(MAX(FCLT_NMBR), 0) + 1 AS NEWID FROM TB_FCLT_INFR", nativeQuery = true)
     Long getNewNmbr();
 
+    @Query(value = "SELECT :fcltType || LPAD(NVL(MAX(SUBSTR(FCLT_ID, -4)), '0000') + 1, 4, '0') AS NEWID FROM TB_FCLT_INFR WHERE FCLT_TYPE = :fcltType", nativeQuery = true)
+    Long getNewFcltId(@Param("fcltType") String fcltType);
+
 }

+ 10 - 1
src/main/java/com/its/op/service/its/facility/TbFcltInfrService.java

@@ -317,7 +317,7 @@ public class TbFcltInfrService {
     }
 
     /**
-     * 시설물 ID 신규 번호
+     * 시설물 관리번호 신규 번호
      * @return
      */
     @Transactional(readOnly = true)
@@ -326,4 +326,13 @@ public class TbFcltInfrService {
         return NewIdLongDto.builder().newId(newId).build();
     }
 
+    /**
+     * 유형별 시설물 ID 신규 번호
+     * @return
+     */
+    @Transactional(readOnly = true)
+    public NewIdLongDto getNewFcltId(String fcltType) {
+        Long newId = this.repo.getNewFcltId(fcltType);
+        return NewIdLongDto.builder().newId(newId).build();
+    }
 }