결재 조회 수정

This commit is contained in:
2025-06-04 12:35:27 +09:00
parent c64c2f1b17
commit 0078a74f7e
4 changed files with 222 additions and 211 deletions

View File

@@ -46,12 +46,11 @@ public class IntegratedApprController {
@GetMapping("/itg/appr/req")
public ResponseEntity findReq(
@Parameter(description = "결재제목") @RequestParam(value="title", required = false) String title,
@Parameter(description = "결재상태") @RequestParam(value="apprStat", required = false) String apprStat,
@Parameter(description = "페이지") @RequestParam("page") int page,
@Parameter(description = "아이템갯수") @RequestParam("row") int row
) {
Pageable pageable = PageRequest.of(page -1, row);
return ResponseEntity.ok(integratedApprService.searchBySabun(title, apprStat, pageable));
return ResponseEntity.ok(integratedApprService.searchBySabun(title, pageable));
}
@Operation(summary = "통합 결재 목록(부서) 조회", description = "통합 결재 목록 조회 (관리자 :전체, 일반사용자 :부서)")

View File

@@ -58,174 +58,183 @@ public interface ApprReqRepository extends JpaRepository<ApprReq, ApprReqId> {
}
@Query(value = "select *\n" +
" from (with cte as (select appr_no,\n" +
" appr_ord,\n" +
" sabun,\n" +
" name,\n" +
" appr_stat_cd,\n" +
" '결재대기' AS appr_stat,\n" +
" row_number() over (partition by appr_no order by appr_ord) as num\n" +
" from appr_req\n" +
" where gubun_cd != ''\n" +
" and appr_stat_cd = '0000')\n" +
" select cte.appr_no,\n" +
" cte.appr_ord,\n" +
" p.title,\n" +
" cte.sabun,\n" +
" cte.name,\n" +
" cte.appr_stat_cd,\n" +
" cte.appr_stat,\n" +
" cte.num,\n" +
" am.reg_dt as reg_dt,\n" +
" 'SVCM' as gubun\n" +
" from cte\n" +
" inner join appr_mst am on cte.appr_no = am.appr_no\n" +
" and am.appr_stat_cd in ('0000', '0100')\n" +
" inner join prcs p on am.prcs_no = p.prcs_no \n" +
" and num = 1 and sabun = :sabun)\n" +
"union all\n" +
"select cc.wkfid, cc.wkfsq, z11.wkftx, cc.bname, cc.btext, cc.wkfst, '결재대기', cc.num, to_char(to_date(cc.erdat||cc.erzet, 'yyyymmddHH24miss'), 'yyyy-mm-dd HH24:mi:ss') as erdt, 'SAP' from (\n" +
"WITH z2_counts AS (SELECT wkfid,\n" +
" sum(case when wkfst = 'A' then 1 else 0 end) as z2_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z2_count\n" +
" FROM zwf0012t group by wkfid),\n" +
" z3_counts AS (SELECT wkfid,\n" +
" sum(case when wkfst = 'A' then 1 else 0 end) as z3_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z3_count\n" +
" FROM zwf0013t group by wkfid),\n" +
" z2_data AS (SELECT wkfid,\n" +
" ROW_NUMBER() OVER (PARTITION BY wkfid ORDER BY lineclsf DESC, wkfsq) AS rn,\n" +
" lineclsf,\n" +
" 0 AS grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" 0 AS wkfsq1\n" +
" FROM zwf0012t\n" +
" WHERE wkfst = 'I'),\n" +
" z3_data AS (SELECT wkfid,\n" +
" RANK() OVER (PARTITION BY grpid ORDER BY lineclsf DESC, wkfsq) AS rk,\n" +
" lineclsf,\n" +
" grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" wkfsq1\n" +
" FROM zwf0013t\n" +
" WHERE wkfst = 'I')\n" +
"SELECT wkfid,\n" +
" num,\n" +
" lineclsf,\n" +
" grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" wkfsq1\n" +
"FROM (SELECT z2.wkfid,\n" +
" CASE\n" +
" WHEN z2c.z2_count <= 1 AND z3c.z3_count > 0 THEN 99\n" +
" ELSE z2.rn\n" +
" END AS num,\n" +
" z2.lineclsf,\n" +
" z2.grpid,\n" +
" z2.wkfsq,\n" +
" z2.wkfst,\n" +
" z2.abscd,\n" +
" z2.bname,\n" +
" z2.btext,\n" +
" z2.posit,\n" +
" z2.deptn,\n" +
" z2.ernam,\n" +
" z2.erdat,\n" +
" z2.erzet,\n" +
" z2.aenam,\n" +
" z2.aedat,\n" +
" z2.aezet,\n" +
" z2.wkfsq1\n" +
" FROM z2_data z2\n" +
" inner JOIN z2_counts z2c on z2c.wkfid = z2.wkfid\n" +
" inner JOIN z3_counts z3c on z3c.wkfid = z2.wkfid\n" +
" WHERE z2c.z2_count > 1\n" +
" OR z3c.z3_count <= 0 \n" +
" UNION ALL\n" +
" SELECT z3.wkfid,\n" +
" z3.rk AS num,\n" +
" z3.lineclsf,\n" +
" z3.grpid,\n" +
" z3.wkfsq,\n" +
" z3.wkfst,\n" +
" z3.abscd,\n" +
" z3.bname,\n" +
" z3.btext,\n" +
" z3.posit,\n" +
" z3.deptn,\n" +
" z3.ernam,\n" +
" z3.erdat,\n" +
" z3.erzet,\n" +
" z3.aenam,\n" +
" z3.aedat,\n" +
" z3.aezet,\n" +
" z3.wkfsq1\n" +
" FROM z3_data z3\n" +
"inner JOIN z2_counts z2c on z2c.wkfid = z3.wkfid \n" +
" WHERE z2c.z2_count = 1) aa\n" +
"WHERE num = 1 and bname = :sabun\n" +
") cc inner join zwf0011t z11 \n" +
" on cc.wkfid = z11.wkfid\n" +
" and z11.wkfst in ('Q', 'I')\n" +
" and (:title is null or :title = '' or z11.wkftx like concat('%', :title, '%'))\n" +
" and (:apprStat is null or :apprStat = '' or (select nm from code where id = 8 and cd = cc.wkfst) = :apprStat)\n" +
"order by reg_dt desc",
countQuery = "select count(appr_no)\n" +
" from (select appr_no,\n" +
" title,\n" +
" sabun,\n" +
" name,\n" +
" appr_stat_cd,\n" +
" appr_stat,\n" +
" num,\n" +
" reg_dt,\n" +
" gubun\n" +
"from (select *\n" +
" from (with cte as (select appr_no,\n" +
" appr_ord,\n" +
" sabun,\n" +
" name,\n" +
" appr_stat_cd,\n" +
" '결재대기' AS\n" +
" appr_stat,\n" +
" row_number() over (partition by appr_no order by appr_ord) as num\n" +
" from appr_req\n" +
" where gubun_cd != ''\n" +
" and appr_stat_cd = '0000')\n" +
" select cte.appr_no,\n" +
" cte.appr_ord,\n" +
" p.title,\n" +
" cte.sabun,\n" +
" cte.name,\n" +
" cte.appr_stat_cd,\n" +
" cte.appr_stat,\n" +
" cte.num,\n" +
" am.reg_dt as reg_dt,\n" +
" 'SVCM'\n" +
" as gubun\n" +
" from cte\n" +
" inner join appr_mst am on cte.appr_no = am.appr_no and am.appr_stat_cd in\n" +
" ('0000', '0100')\n" +
" inner join prcs p on am.prcs_no = p.prcs_no and num = 1 and sabun = :sabun)\n" +
" union all\n" +
" select cc.wkfid,\n" +
" cc.wkfsq,\n" +
" z11.wkftx,\n" +
" cc.bname,\n" +
" cc.btext,\n" +
" cc.wkfst,\n" +
" '결재대기',\n" +
" cc.num,\n" +
" to_char(to_date(cc.erdat || cc.erzet, 'yyyymmddHH24miss'), 'yyyy-mm-dd HH24:mi:ss') as erdt,\n" +
" 'SAP'\n" +
" from (WITH z2_counts AS (SELECT wkfid,\n" +
" sum(case when wkfst = 'A' then 1 else 0 end)\n" +
" as z2_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z2_count\n" +
" FROM zwf0012t\n" +
" group by wkfid),\n" +
" z3_counts AS (SELECT wkfid,\n" +
" sum(case when wkfst = 'A' then 1 else 0 end) as z3_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z3_count\n" +
" FROM zwf0013t\n" +
" group by wkfid),\n" +
" z2_data\n" +
" AS (SELECT wkfid,\n" +
" ROW_NUMBER() OVER (PARTITION BY wkfid ORDER BY lineclsf DESC, wkfsq) AS rn,\n" +
" lineclsf,\n" +
" 0 AS grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" 0 AS wkfsq1\n" +
" FROM zwf0012t\n" +
" WHERE wkfst = 'I'),\n" +
" z3_data AS (SELECT wkfid,\n" +
" RANK() OVER (PARTITION BY grpid ORDER BY lineclsf DESC, wkfsq) AS rk,\n" +
" lineclsf,\n" +
" grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" wkfsq1\n" +
" FROM zwf0013t\n" +
" WHERE wkfst = 'I')\n" +
" SELECT wkfid,\n" +
" num,\n" +
" lineclsf,\n" +
" grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" wkfsq1\n" +
" FROM (SELECT z2.wkfid,\n" +
" CASE WHEN z2c.z2_count <= 1 AND z3c.z3_count > 0 THEN 99 ELSE z2.rn END AS num,\n" +
" z2.lineclsf,\n" +
" z2.grpid,\n" +
" z2.wkfsq,\n" +
" z2.wkfst,\n" +
" z2.abscd,\n" +
" z2.bname,\n" +
" z2.btext,\n" +
" z2.posit,\n" +
" z2.deptn,\n" +
" z2.ernam,\n" +
" z2.erdat,\n" +
" z2.erzet,\n" +
" z2.aenam,\n" +
" z2.aedat,\n" +
" z2.aezet,\n" +
" z2.wkfsq1\n" +
" FROM z2_data z2\n" +
" inner JOIN z2_counts z2c\n" +
" on z2c.wkfid = z2.wkfid\n" +
" inner JOIN z3_counts z3c on z3c.wkfid = z2.wkfid\n" +
" WHERE z2c.z2_count\n" +
" > 1\n" +
" OR z3c.z3_count <= 0\n" +
" UNION ALL\n" +
" SELECT z3.wkfid,\n" +
" z3.rk AS num,\n" +
" z3.lineclsf,\n" +
" z3.grpid,\n" +
" z3.wkfsq,\n" +
" z3.wkfst,\n" +
" z3.abscd,\n" +
" z3.bname,\n" +
" z3.btext,\n" +
" z3.posit,\n" +
" z3.deptn,\n" +
" z3.ernam,\n" +
" z3.erdat,\n" +
" z3.erzet,\n" +
" z3.aenam,\n" +
" z3.aedat,\n" +
" z3.aezet,\n" +
" z3.wkfsq1\n" +
" FROM z3_data z3\n" +
" inner JOIN z2_counts z2c on z2c.wkfid = z3.wkfid\n" +
" WHERE z2c.z2_count = 1) aa\n" +
" WHERE num = 1\n" +
" and bname = :sabun) cc\n" +
" inner join zwf0011t z11\n" +
" on cc.wkfid = z11.wkfid and z11.wkfst in ('Q', 'I'))\n" +
"where (:title is null or :title = '' or title like concat('%', :title, '%'))\n" +
"order by reg_dt desc\n" +
"\n",
countQuery = "select count(*) \n" +
"from (select *\n" +
" from (with cte as (select appr_no,\n" +
" appr_ord,\n" +
" sabun,\n" +
" name,\n" +
" appr_stat_cd,\n" +
" '결재대기' AS appr_stat,\n" +
" '결재대기' AS\n" +
" appr_stat,\n" +
" row_number() over (partition by appr_no order by appr_ord) as num\n" +
" from appr_req\n" +
" where gubun_cd != ''\n" +
" and appr_stat_cd = '0000')\n" +
" select cte.appr_no,\n" +
" cte.appr_ord,\n" +
" p.title,\n" +
" cte.sabun,\n" +
" cte.name,\n" +
@@ -233,14 +242,15 @@ public interface ApprReqRepository extends JpaRepository<ApprReq, ApprReqId> {
" cte.appr_stat,\n" +
" cte.num,\n" +
" am.reg_dt as reg_dt,\n" +
" 'SAP' as gubun\n" +
" 'SVCM'\n" +
" as gubun\n" +
" from cte\n" +
" inner join appr_mst am on cte.appr_no = am.appr_no\n" +
" and am.appr_stat_cd in ('0000', '0100')\n" +
" inner join prcs p on am.prcs_no = p.prcs_no \n" +
" and num = 1 and sabun = :sabun)\n" +
" inner join appr_mst am on cte.appr_no = am.appr_no and am.appr_stat_cd in\n" +
" ('0000', '0100')\n" +
" inner join prcs p on am.prcs_no = p.prcs_no and num = 1 and sabun = :sabun)\n" +
" union all\n" +
" select cc.wkfid,\n" +
" cc.wkfsq,\n" +
" z11.wkftx,\n" +
" cc.bname,\n" +
" cc.btext,\n" +
@@ -250,33 +260,37 @@ public interface ApprReqRepository extends JpaRepository<ApprReq, ApprReqId> {
" to_char(to_date(cc.erdat || cc.erzet, 'yyyymmddHH24miss'), 'yyyy-mm-dd HH24:mi:ss') as erdt,\n" +
" 'SAP'\n" +
" from (WITH z2_counts AS (SELECT wkfid,\n" +
" sum(case when wkfst = 'A' then 1 else 0 end) as z2_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z2_count\n" +
" FROM zwf0012t group by wkfid),\n" +
" sum(case when wkfst = 'A' then 1 else 0 end)\n" +
" as z2_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z2_count\n" +
" FROM zwf0012t\n" +
" group by wkfid),\n" +
" z3_counts AS (SELECT wkfid,\n" +
" sum(case when wkfst = 'A' then 1 else 0 end) as z3_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z3_count\n" +
" FROM zwf0013t group by wkfid),\n" +
" z2_data AS (SELECT wkfid,\n" +
" ROW_NUMBER() OVER (PARTITION BY wkfid ORDER BY lineclsf DESC, wkfsq) AS rn,\n" +
" lineclsf,\n" +
" 0 AS grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" 0 AS wkfsq1\n" +
" FROM zwf0012t\n" +
" WHERE wkfst = 'I'),\n" +
" sum(case when wkfst = 'A' then 1 else 0 end) as z3_acount,\n" +
" sum(case when wkfst = 'I' then 1 else 0 end) as z3_count\n" +
" FROM zwf0013t\n" +
" group by wkfid),\n" +
" z2_data\n" +
" AS (SELECT wkfid,\n" +
" ROW_NUMBER() OVER (PARTITION BY wkfid ORDER BY lineclsf DESC, wkfsq) AS rn,\n" +
" lineclsf,\n" +
" 0 AS grpid,\n" +
" wkfsq,\n" +
" wkfst,\n" +
" abscd,\n" +
" bname,\n" +
" btext,\n" +
" posit,\n" +
" deptn,\n" +
" ernam,\n" +
" erdat,\n" +
" erzet,\n" +
" aenam,\n" +
" aedat,\n" +
" aezet,\n" +
" 0 AS wkfsq1\n" +
" FROM zwf0012t\n" +
" WHERE wkfst = 'I'),\n" +
" z3_data AS (SELECT wkfid,\n" +
" RANK() OVER (PARTITION BY grpid ORDER BY lineclsf DESC, wkfsq) AS rk,\n" +
" lineclsf,\n" +
@@ -316,10 +330,7 @@ public interface ApprReqRepository extends JpaRepository<ApprReq, ApprReqId> {
" aezet,\n" +
" wkfsq1\n" +
" FROM (SELECT z2.wkfid,\n" +
" CASE\n" +
" WHEN z2c.z2_count <= 1 AND z3c.z3_count > 0 THEN 99\n" +
" ELSE z2.rn\n" +
" END AS num,\n" +
" CASE WHEN z2c.z2_count <= 1 AND z3c.z3_count > 0 THEN 99 ELSE z2.rn END AS num,\n" +
" z2.lineclsf,\n" +
" z2.grpid,\n" +
" z2.wkfsq,\n" +
@@ -337,10 +348,12 @@ public interface ApprReqRepository extends JpaRepository<ApprReq, ApprReqId> {
" z2.aezet,\n" +
" z2.wkfsq1\n" +
" FROM z2_data z2\n" +
" inner JOIN z2_counts z2c on z2c.wkfid = z2.wkfid\n" +
" inner JOIN z3_counts z3c on z3c.wkfid = z2.wkfid\n" +
" WHERE z2c.z2_count > 1\n" +
" OR z3c.z3_count <= 0 \n" +
" inner JOIN z2_counts z2c\n" +
" on z2c.wkfid = z2.wkfid\n" +
" inner JOIN z3_counts z3c on z3c.wkfid = z2.wkfid\n" +
" WHERE z2c.z2_count\n" +
" > 1\n" +
" OR z3c.z3_count <= 0\n" +
" UNION ALL\n" +
" SELECT z3.wkfid,\n" +
" z3.rk AS num,\n" +
@@ -361,17 +374,16 @@ public interface ApprReqRepository extends JpaRepository<ApprReq, ApprReqId> {
" z3.aezet,\n" +
" z3.wkfsq1\n" +
" FROM z3_data z3\n" +
" inner join z2_counts z2c \n" +
" on z2c.z2_count = 1) aa\n" +
" inner JOIN z2_counts z2c on z2c.wkfid = z3.wkfid\n" +
" WHERE z2c.z2_count = 1) aa\n" +
" WHERE num = 1\n" +
" and bname = :sabun) cc\n" +
" inner join zwf0011t z11 on cc.wkfid = z11.wkfid\n" +
" and z11.wkfst in ('Q', 'I') \n" +
" and (:title is null or :title = '' or z11.wkftx like concat('%', :title, '%'))\n" +
" and (:apprStat is null or :apprStat = '' or (select nm from code where id = 8 and cd = cc.wkfst) = :apprStat)\n" +
" order by reg_dt desc)",
" inner join zwf0011t z11\n" +
" on cc.wkfid = z11.wkfid and z11.wkfst in ('Q', 'I'))\n" +
"where (:title is null or :title = '' or title like concat('%', :title, '%'))\n" +
"\n",
nativeQuery = true)
Page<igtApprReqDto> igtFindhBySabun(@Param("sabun") String sabun, @Param("title") String title, @Param("apprStat") String apprStat, Pageable pageable);
Page<igtApprReqDto> igtFindhBySabun(@Param("sabun") String sabun, @Param("title") String title, Pageable pageable);
interface igtApprDto {
String getApprNo();

View File

@@ -8,7 +8,7 @@ import org.springframework.data.domain.Pageable;
import java.util.List;
public interface IntegratedApprService {
PageResponse searchBySabun(String title, String apprStat, Pageable pageable);
PageResponse searchBySabun(String title, Pageable pageable);
PageResponse searchList(String title, Pageable pageable);
}

View File

@@ -22,9 +22,9 @@ public class IntegratedApprServiceImpl implements IntegratedApprService {
@Transactional
@Override
public PageResponse searchBySabun(String title, String apprStat, Pageable pageable) {
public PageResponse searchBySabun(String title, Pageable pageable) {
User user = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Page<ApprReqRepository.igtApprReqDto> p = apprReqRepository.igtFindhBySabun(user.getSabun(), title, apprStat, pageable);
Page<ApprReqRepository.igtApprReqDto> p = apprReqRepository.igtFindhBySabun(user.getSabun(), title, pageable);
return PageResponse.builder()
.totalPages(p.getTotalPages())
.totalElements(p.getTotalElements())