From cae71a93d43d11f1b902377aee2bc6171660f9a3 Mon Sep 17 00:00:00 2001 From: "Lim\\jun" Date: Tue, 9 May 2023 16:24:41 +0900 Subject: [PATCH 1/5] =?UTF-8?q?=EC=98=88=EC=82=B0=20html=20=EC=97=85?= =?UTF-8?q?=EB=8E=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/budget/assign.html | 184 +++++++------- .../templates/budget/assignEditModal.html | 159 ++++++++++++ .../resources/templates/budget/budgeting.html | 140 ++++------- .../templates/budget/budgetingEditModal.html | 63 +++++ .../templates/budget/budgetingOrgModal.html | 62 +++++ .../resources/templates/budget/expense.html | 231 +++++++++--------- .../templates/budget/expenseEditModal.html | 142 +++++++++++ .../resources/templates/budget/stats.html | 120 +++------ .../templates/budget/statsDetail.html | 124 ++++++++++ .../resources/templates/budget/statsOrg.html | 182 ++++++++++++++ 10 files changed, 1027 insertions(+), 380 deletions(-) create mode 100644 src/main/resources/templates/budget/assignEditModal.html create mode 100644 src/main/resources/templates/budget/budgetingEditModal.html create mode 100644 src/main/resources/templates/budget/budgetingOrgModal.html create mode 100644 src/main/resources/templates/budget/expenseEditModal.html create mode 100644 src/main/resources/templates/budget/statsDetail.html create mode 100644 src/main/resources/templates/budget/statsOrg.html diff --git a/src/main/resources/templates/budget/assign.html b/src/main/resources/templates/budget/assign.html index ae8827b6..dd9cb767 100644 --- a/src/main/resources/templates/budget/assign.html +++ b/src/main/resources/templates/budget/assign.html @@ -3,8 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> - +
@@ -25,40 +24,28 @@
- +
@@ -78,61 +65,77 @@ - - - - - - + + + - - - - - - - - - - - - + + + + - - + + + + + + + + + + + + + + + + + +
세부내역 예산총액 예산총배정액
(누적)
본청중부청서해청남해청동해청제주청
기간배정액누적액기간배정액누적액기간배정액누적액기간배정액누적액기간배정액누적액기간배정액누적액기간배정액누적액
@@ -140,32 +143,15 @@
-
- + +
+
+ +
diff --git a/src/main/resources/templates/budget/assignEditModal.html b/src/main/resources/templates/budget/assignEditModal.html new file mode 100644 index 00000000..6e16dcd9 --- /dev/null +++ b/src/main/resources/templates/budget/assignEditModal.html @@ -0,0 +1,159 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/budget/budgeting.html b/src/main/resources/templates/budget/budgeting.html index 382550e0..673a7695 100644 --- a/src/main/resources/templates/budget/budgeting.html +++ b/src/main/resources/templates/budget/budgeting.html @@ -3,8 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> - +
@@ -25,49 +24,30 @@
- +
@@ -81,71 +61,51 @@ - + + + + + + + + + + + + +
합계
-
- + + +
- + +
+
+ + +
+
+ + +
diff --git a/src/main/resources/templates/budget/budgetingEditModal.html b/src/main/resources/templates/budget/budgetingEditModal.html new file mode 100644 index 00000000..0e64011a --- /dev/null +++ b/src/main/resources/templates/budget/budgetingEditModal.html @@ -0,0 +1,63 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/budget/budgetingOrgModal.html b/src/main/resources/templates/budget/budgetingOrgModal.html new file mode 100644 index 00000000..c2141ae7 --- /dev/null +++ b/src/main/resources/templates/budget/budgetingOrgModal.html @@ -0,0 +1,62 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/budget/expense.html b/src/main/resources/templates/budget/expense.html index 7f43e339..a4eb3e0d 100644 --- a/src/main/resources/templates/budget/expense.html +++ b/src/main/resources/templates/budget/expense.html @@ -3,8 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> - +
@@ -25,40 +24,32 @@
- +
-
+
@@ -79,75 +70,118 @@ - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + +
예산총액 예산총배정액
(누적)
집행액(총계)본청중부청서해청남해청동해청제주청
지출총액 보유잔액배정액지출총액잔액집행률배정액지출총액잔액집행률배정액지출총액잔액집행률배정액지출총액잔액집행률배정액지출총액잔액집행률배정액지출총액잔액집행률배정액지출총액잔액집행률
@@ -155,29 +189,6 @@
-
diff --git a/src/main/resources/templates/budget/expenseEditModal.html b/src/main/resources/templates/budget/expenseEditModal.html new file mode 100644 index 00000000..f7b7db70 --- /dev/null +++ b/src/main/resources/templates/budget/expenseEditModal.html @@ -0,0 +1,142 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/budget/stats.html b/src/main/resources/templates/budget/stats.html index ca0ad72b..1838d31e 100644 --- a/src/main/resources/templates/budget/stats.html +++ b/src/main/resources/templates/budget/stats.html @@ -3,8 +3,7 @@ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout/layout}"> - +
@@ -25,40 +24,52 @@
- +
@@ -82,38 +93,8 @@ - + +
@@ -121,29 +102,6 @@
-
diff --git a/src/main/resources/templates/budget/statsDetail.html b/src/main/resources/templates/budget/statsDetail.html new file mode 100644 index 00000000..94677aa1 --- /dev/null +++ b/src/main/resources/templates/budget/statsDetail.html @@ -0,0 +1,124 @@ + + + + + +
+
+ +
+
+
+
+
예산통계
+
+
+
+

정보예산관리 > 예산통계

+
+
+ + +
+
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
재무관서예산총액예산배정액
(누적)
집행액(총계)
지출액보유잔액집행비율
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ \ No newline at end of file diff --git a/src/main/resources/templates/budget/statsOrg.html b/src/main/resources/templates/budget/statsOrg.html new file mode 100644 index 00000000..991b143e --- /dev/null +++ b/src/main/resources/templates/budget/statsOrg.html @@ -0,0 +1,182 @@ + + + + + +
+
+ +
+
+
+
+
예산통계
+
+
+
+

정보예산관리 > 예산통계

+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+ + +
+
+
+ +
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
사업명구분세부내역예산총액예산총배정액
(누적)
집행액(총계)
지출총액보유잔액진행률배정액지출총액잔액집행률
11
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+ \ No newline at end of file From e5310450d9c6446eacb41251ab05e9be12f653b4 Mon Sep 17 00:00:00 2001 From: "Lim\\jun" Date: Tue, 9 May 2023 16:26:34 +0900 Subject: [PATCH 2/5] =?UTF-8?q?=EC=98=88=EC=82=B0=20js=20=EC=97=85?= =?UTF-8?q?=EB=8E=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/budget/assign.js | 388 ++++++++++++++++ .../resources/static/js/budget/budgeting.js | 422 ++++++++++++++++++ .../resources/static/js/budget/expense.js | 321 +++++++++++++ .../resources/static/js/budget/statsDetail.js | 297 ++++++++++++ .../resources/static/js/budget/statsOrg.js | 316 +++++++++++++ 5 files changed, 1744 insertions(+) create mode 100644 src/main/resources/static/js/budget/assign.js create mode 100644 src/main/resources/static/js/budget/budgeting.js create mode 100644 src/main/resources/static/js/budget/expense.js create mode 100644 src/main/resources/static/js/budget/statsDetail.js create mode 100644 src/main/resources/static/js/budget/statsOrg.js diff --git a/src/main/resources/static/js/budget/assign.js b/src/main/resources/static/js/budget/assign.js new file mode 100644 index 00000000..db3ff932 --- /dev/null +++ b/src/main/resources/static/js/budget/assign.js @@ -0,0 +1,388 @@ +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); +}) + +$(document).on('click', '#addBtn', function (){ + if($("#assignlistcnt").val() == 0){ + alert('조회된 내역이 없습니다.'); + return; + } + getEditModal(0) +}) + +$(document).ready(function(){ + if ($("#ResultRow").text().trim() == "") { + assignSearch(); + } else { + WithoutMask(); + } +}); + +$(document).on('click', '#searchBtn', function () { + assignSearch(); +}) + +function assignSearch() { + let stDate = $("#stDate").val() + let edDate = $("#edDate").val() + if ($("#stDate").val() == "") { + alert('시작일을 선택해주세요'); + return; + } + + if ($("#edDate").val() == "") { + alert('종료일을 선택해주세요'); + return; + } + + stDate = new Date(stDate); + edDate = new Date(edDate); + + if (stDate.getFullYear() != edDate.getFullYear()) { + alert('같은 년도의 데이터만 조회가능합니다. ex)2021-01-01 ~ 2021-12-31'); + return; + } + + $("#year").val(stDate.getFullYear()); + + LoadingWithMask(); + location.href = "/budget/assign?year=" + $("#year").val() + "&stDate=" + $("#stDate").val() + "&edDate=" + $("#edDate").val() + "&code=" + $("#code").val(); +} +$(document).on('click', '#deleteBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('삭제할 항목을 선택해주세요'); + return; + } + console.dir($("input[name='budget']:checked")[0].dataset.name1); + console.dir($("input[name='budget']:checked")[0].dataset.name2); + console.dir($("input[name='budget']:checked")[0].dataset.name3); + if(confirm('삭제하시겠습니까?')){ + let params = {}; + params.year = $("#searchYear").val(); + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + console.dir(params); + $.ajax({ + type : 'DELETE', + data : params, + + url : "/budget/budgeting/code", + + + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(data) { + if(data.code == "200"){ + alert("삭제되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("삭제에 실패하였습니다."); + } + }) + } + +}) + +$(document).on('click', '#updateBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('수정할 항목을 선택해주세요'); + return; + } + params = {} + params.year = $("#searchYear").val() + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); +}) + + +// +// function getList(){ +// $.ajax({ +// type : 'GET', +// data : {}, +// url : "/pds/ship/list", +// processData: false, +// contentType: false, +// beforeSend: function (xhr){ +// xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); +// }, +// success : function(response) { +// console.dir(response) +// +// }, +// error : function() { +// alert("저장에 실패하였습니다."); +// }, +// complete : function () { +// loaddingOff(); +// } +// }) +// } +// function getViewModal(no){ +// params = {} +// params.no = no; +// $.ajax({ +// url: '/pds/ship/modal/view', +// data: params, +// type: 'GET', +// dataType:"html", +// success: function(html){ +// $("#editModalContent").empty().append(html); +// $(".dateSelector").datepicker({ +// format: "yyyy-mm-dd", +// language: "ko", +// autoclose: true +// }); +// $("#editModal").modal('show'); +// }, +// error:function(){ +// +// } +// }); +// } + +// $(document).on('click', '.grid', function(event) { +// const target = event.target; +// const no = (Number($(this).find(".key").val())); +// +// }) + +function getEditModal(no){ + + params = {} + params.stDate = $("#stDate").val(); + params.edDate = $("#edDate").val(); + + let stDate = new Date($("#stDate").val()); + params.year = stDate.getFullYear(); + params.code = $("#code").val(); + + + $.ajax({ + url: '/budget/assign/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); + + +} + + +$(document).on('click', '#saveBtn', function (){ + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + + if(confirm("저장하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + + +$(document).on('click', '#modifyBtn', function (){ + + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + if(confirm("수정하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'PUT', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } + + +}); + +$(document).on('click', '#tempBtn', function (){ + if(confirm("임시 저장하시겠습니까?")){ + $("#status").val("TEMP"); + const formData = new FormData($("#investigationEditForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/pds/ship", + processData: false, + contentType: false, + success : function(data) { + alert("저장되었습니다."); + location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + + +$(document).on('click', '#assignSaveBtn', function (){ + let success = 0; + let fail =0; + let fail1 =0; + if($("#assignCount").val()==0){ + alert('저장할 내역이 없습니다.'); + } + for(let i =0 ; i < $("#assignCount").val() ; i ++){ + for(let j=0 ; j < $("#orgCount").val() ; j ++){ + params = {} + params.year = $("#orgYear").val(); + // console.dir($("#org"+j+"_amount"+i)[0].dataset.code); + params.code = $("#org"+j+"_amount"+i)[0].dataset.code; + params.amount = $("#org"+j+"_amount"+i).val() == "" ? 0 :$("#org"+j+"_amount"+i).val() + params.org = $("#code").val(); + params.org1 = $("#orgSave"+j).text(); + // console.dir(params.org); + + $.ajax({ + type : 'POST', + data : JSON.stringify(params), + url : "/budget/assign/save", + processData: false, + contentType: 'application/json', + async : false, + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + + success : function(data) { + // console.log(data.code); + if(data.code == "200"){ + success ++; + }else if(data.code == "911"){ + fail1 ++; + }else{ + fail++; + } + //location.reload(); + }, + error : function(xhr) { + //alert("저장에 실패하였습니다."); + fail++; + } + }) + } + } + + // console.dir("success: "+ success +", fail:" + fail+fail1); + if (fail1 > 0 || fail > 0) { + alert("저장에 성공하였습니다. \n일부는 저장에 실패 (금액 초과 [" + fail1 + "건], 에러 [" + fail + "건]) 하였습니다."); + } else { + alert("저장에 성공하였습니다."); + } + location.reload(); + + + +}); diff --git a/src/main/resources/static/js/budget/budgeting.js b/src/main/resources/static/js/budget/budgeting.js new file mode 100644 index 00000000..a5e21e20 --- /dev/null +++ b/src/main/resources/static/js/budget/budgeting.js @@ -0,0 +1,422 @@ +$(document).on('click', '#addBtn', function () { + getEditModal(0) +}) +$(document).on('click', '#deleteBtn', function () { + if ($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val() == null) { + alert('삭제할 항목을 선택해주세요'); + return; + } + // console.dir($("input[name='budget']:checked")[0].dataset.name1); + // console.dir($("input[name='budget']:checked")[0].dataset.name2); + // console.dir($("input[name='budget']:checked")[0].dataset.name3); + if (confirm('삭제하시겠습니까?')) { + let params = {}; + params.year = $("#searchYear").val(); + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + console.dir(params); + $.ajax({ + type: 'DELETE', + data: params, + url: "/budget/budgeting/code", + beforeSend: function (xhr) { + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success: function (data) { + if (data.code == "200") { + alert("삭제되었습니다."); + location.reload(); + } else { + alert(data.message); + } + //location.reload(); + }, + error: function (xhr) { + alert("삭제에 실패하였습니다."); + } + }) + } + +}) + +// 예산편성 - 엑셀 다운로드(버튼) +$(document).on('click', '#excelDownload', function (){ + let selected_year = $("#searchYear").val(); + exportExcel(selected_year+"년 예산편성", "data-table-default"); +}); + +// 예산편성 - 연도추가(버튼) +$(document).on('click', '#copyYearBtn', function () { + // let now = new Date(); + let selected_year = $("#searchYear").val(); + if (confirm(parseInt(selected_year) + 1 + '년도 예산을 생성하시겠습니까?')) { + let params = {}; + params.copyYear = selected_year; + params.year = parseInt(selected_year) + 1; + // console.dir(params); + $.ajax({ + type: 'POST', + url: "/budget/budgeting/year", + data: JSON.stringify(params), + contentType: 'application/json; charset=utf-8', + beforeSend: function (xhr) { + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success: function (data) { + if (data.code == "200") { + alert("생성되었습니다."); + location.reload(); + } else { + alert(data.message); + } + //location.reload(); + }, + error: function (xhr) { + alert("생성에 실패하였습니다."); + } + }) + } +}) + +// 예산편성 - 예산삭제(버튼) +$(document).on('click', '#deleteYearBtn', function () { + let selected_year = $("#searchYear").val(); + if (confirm(selected_year + "년도 예산 삭제시 관련된 모든 예산 이력 정보가 삭제됩니다.\n그래도 삭제하시겠습니까?")) { + let params = {}; + //params.copyYear = "??"; + params.year = selected_year; + console.dir(params); + $.ajax({ + type: 'DELETE', + data: params, + // data: JSON.stringify(params), + // contentType: 'application/json; charset=utf-8', + url: "/budget/budgeting/year", + beforeSend: function (xhr) { + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success: function (data) { + if (data.code == "200") { + alert("삭제되었습니다."); + location.href = '/budget/budgeting?year='+(parseInt(selected_year)-1); + // location.reload(); + } else { + alert(data.message); + } + //location.reload(); + }, + error: function (xhr) { + alert("삭제에 실패하였습니다."); + } + // error:function(xhr,status,error){ + // alert("code:"+status+"\n"+"xhr:"+xhr+"\n"+"error:"+error); + // } + }) + } +}) + +$(document).on('click', '#budgetDeleteBtn', function () { + if (confirm("예산을 삭제하시겠습니까? 삭제된 예산은 복구할수 없습니다.")) { + let params = {}; + params.year = $("#searchYear").val(); + // console.dir(params); + $.ajax({ + type: 'DELETE', + data: params, + url: "/budget/budgeting", + beforeSend: function (xhr) { + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success: function (data) { + if (data.code == "200") { + alert("삭제되었습니다."); + location.reload(); + } else { + alert(data.message); + } + //location.reload(); + }, + error: function (xhr) { + alert("삭제에 실패하였습니다."); + } + }) + } + +}) + +$(document).on('click', '#updateBtn', function () { + if ($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val() == null) { + alert('수정할 항목을 선택해주세요'); + return; + } + params = {} + params.year = $("#searchYear").val() + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType: "html", + success: function (html) { + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()); + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + + }, + error: function () { + + } + }); +}) + +$(document).on('click', '#budgetBtn', function () { + getBudgetModal(); +}); + +function getList() { + $.ajax({ + type: 'GET', + data: {}, + url: "/pds/ship/list", + processData: false, + contentType: false, + beforeSend: function (xhr) { + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success: function (response) { + console.dir(response) + + }, + error: function () { + alert("저장에 실패하였습니다."); + }, + complete: function () { + loaddingOff(); + } + }) +} + +function getBudgetModal(no) { + params = {} + params.no = no; + params.year = $("#searchYear").val(); + $.ajax({ + url: '/budget/budgeting/modal/org', + data: params, + type: 'GET', + dataType: "html", + success: function (html) { + $("#budgetModalContent").empty().append(html); + $("#orgYear").val($("#searchYear").val()); + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + // $("#budgetYear").val(params.year); + + $("#budgetModal").modal('show'); + }, + error: function () { + + } + }); +} + +$(document).on('click', '.grid', function (event) { + const target = event.target; + const no = (Number($(this).find(".key").val())); + +}) + +function getEditModal(no) { + + params = {} + params.no = no; + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType: "html", + success: function (html) { + + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + + $("#editModal").modal('show'); + + }, + error: function () { + + } + }); + + +} + +$(document).on('click', '#budgetSaveBtn', function () { + let success = 0; + let fail = 0; + for (let i = 0; i < $("#budgetCount").val(); i++) { + (function(i) { + params = {} + params.year = $("#orgYear").val(); + params.nameL1 = $("#amount" + i)[0].dataset.name1; + params.nameL2 = $("#amount" + i)[0].dataset.name2; + params.nameL3 = $("#amount" + i)[0].dataset.name3; + params.amount = $("#amount" + i).val() == "" ? 0 : $("#amount" + i).val() + + $.ajax({ + type: 'POST', + data: JSON.stringify(params), + url: "/budget/budgeting/save", + processData: false, + contentType: 'application/json', + async: false, + beforeSend: function (xhr) { + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success: function (data) { + if (data.code == "200") { + success++; + } else { + fail++; + } + }, + error: function (xhr) { + fail++; + }, + }); + })(i); + } + // console.dir("success: " + success + ", fail:" + fail); + if (fail > 0) { + alert("저장이 성공하였습니다. [" + fail + "건 오류]"); + } else { + alert("저장에 성공하였습니다."); + } + location.reload(); +}); + +$(document).on('change', '#searchYear', function () { + location.href = '/budget/budgeting?year=' + $("#searchYear").val(); +}); +$(document).on('click', '#saveBtn', function () { + if ($("#nameL1").val() == "") { + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if ($("#nameL2").val() == "") { + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if ($("#nameL3").val() == "") { + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + + if (confirm("저장하시겠습니까?")) { + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type: 'POST', + data: formData, + url: "/budget/budgeting/code", + processData: false, + contentType: false, + success: function (data) { + if (data.code == "200") { + alert("저장되었습니다."); + location.reload(); + } else { + alert(data.message); + } + //location.reload(); + }, + error: function (xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + + +$(document).on('click', '#modifyBtn', function () { + + if ($("#nameL1").val() == "") { + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if ($("#nameL2").val() == "") { + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if ($("#nameL3").val() == "") { + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + if (confirm("수정하시겠습니까?")) { + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type: 'PUT', + data: formData, + url: "/budget/budgeting/code", + processData: false, + contentType: false, + success: function (data) { + if (data.code == "200") { + alert("저장되었습니다."); + location.reload(); + } else { + alert(data.message); + } + //location.reload(); + }, + error: function (xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + +$(document).on('click', '#tempBtn', function () { + if (confirm("임시 저장하시겠습니까?")) { + $("#status").val("TEMP"); + const formData = new FormData($("#investigationEditForm")[0]); + $.ajax({ + type: 'POST', + data: formData, + url: "/pds/ship", + processData: false, + contentType: false, + success: function (data) { + alert("저장되었습니다."); + location.reload(); + }, + error: function (xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); diff --git a/src/main/resources/static/js/budget/expense.js b/src/main/resources/static/js/budget/expense.js new file mode 100644 index 00000000..efb996c9 --- /dev/null +++ b/src/main/resources/static/js/budget/expense.js @@ -0,0 +1,321 @@ +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); +}) + +$(document).on('click', '#addBtn', function (){ + getEditModal(0) +}) + +$(document).on('click', '#searchBtn', function (){ + var stDate = $("#stDate").val() + var edDate = $("#edDate").val() + if($("#stDate").val() ==""){ + alert('시작일을 선택해주세요'); + return; + } + + if($("#edDate").val() ==""){ + alert('종료일을 선택해주세요'); + return; + } + + stDate = new Date(stDate); + edDate = new Date(edDate); + + if(stDate.getFullYear() != edDate.getFullYear()){ + alert('같은 년도의 데이터만 조회가능합니다. ex)2021-01-01 ~ 2021-12-31'); + return; + } + + $("#year").val(stDate.getFullYear()); + + location.href="/budget/expense?year="+$("#year").val() + "&stDate=" + $("#stDate").val() + "&edDate=" + $("#edDate").val() + "&code=" +$("#code").val(); + +}) +$(document).on('click', '#deleteBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('삭제할 항목을 선택해주세요'); + return; + } + console.dir($("input[name='budget']:checked")[0].dataset.name1); + console.dir($("input[name='budget']:checked")[0].dataset.name2); + console.dir($("input[name='budget']:checked")[0].dataset.name3); + if(confirm('삭제하시겠습니까?')){ + var params = {}; + params.year = $("#searchYear").val(); + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + console.dir(params); + $.ajax({ + type : 'DELETE', + data : params, + + url : "/budget/budgeting/code", + + + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(data) { + if(data.code == "200"){ + alert("삭제되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("삭제에 실패하였습니다."); + } + }) + } + +}) + +$(document).on('click', '#updateBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('수정할 항목을 선택해주세요'); + return; + } + params = {} + params.year = $("#searchYear").val() + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); +}) + + + +function getList(){ + $.ajax({ + type : 'GET', + data : {}, + url : "/pds/ship/list", + processData: false, + contentType: false, + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(response) { + console.dir(response) + + }, + error : function() { + alert("저장에 실패하였습니다."); + }, + complete : function () { + loaddingOff(); + } + }) +} +function getViewModal(no){ + params = {} + params.no = no; + $.ajax({ + url: '/pds/ship/modal/view', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + }, + error:function(){ + + } + }); +} + +$(document).on('click', '.grid', function(event) { + const target = event.target; + const no = (Number($(this).find(".key").val())); + +}) + +function getEditModal(v){ + + params = {} + + params.year = $("#year").val(); + params.nameL1 = v.dataset.name1 + params.nameL2 = v.dataset.name2 + params.nameL3 = v.dataset.name3 + $.ajax({ + url: '/budget/expense/modal/view', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + + $("#editModalContent").empty().append(html); + + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); + + +} + + +$(document).on('click', '#expenseSaveBtn', function (){ + if($("#item").val() == ""){ + alert('집행내역을 입력해주세요.'); + $("#item").focus(); + return; + } + if($("#amount").val() == ""){ + alert('집행액을 입력해주세요.'); + $("#amount").focus(); + return; + } + if($("#expenseDate").val() == ""){ + alert('등록일을 입력해주세요.'); + $("#expenseDate").focus(); + return; + } + + var params = {} + params.item = $("#item").val(); + params.amount = $("#amount").val(); + params.expenseDate = $("#expenseDate").val(); + params.nameL1 = $("#prevNameL1").val(); + params.nameL2 = $("#prevNameL2").val(); + params.nameL3 = $("#prevNameL3").val(); + params.year = $("#prevYear").val(); + + + + if(confirm("저장하시겠습니까?")){ + + $.ajax({ + type : 'POST', + data : JSON.stringify(params), + url : "/budget/expense", + processData: false, + contentType: 'application/json', + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + + +$(document).on('click', '#modifyBtn', function (){ + + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + if(confirm("수정하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'PUT', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } + + +}); + +$(document).on('click', '#tempBtn', function (){ + if(confirm("임시 저장하시겠습니까?")){ + $("#status").val("TEMP"); + const formData = new FormData($("#investigationEditForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/pds/ship", + processData: false, + contentType: false, + success : function(data) { + alert("저장되었습니다."); + location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); diff --git a/src/main/resources/static/js/budget/statsDetail.js b/src/main/resources/static/js/budget/statsDetail.js new file mode 100644 index 00000000..7454c78d --- /dev/null +++ b/src/main/resources/static/js/budget/statsDetail.js @@ -0,0 +1,297 @@ +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); +}) + +$(document).on('click', '#addBtn', function (){ + getEditModal(0) +}) + +$(document).on('click', '#searchBtn', function (){ + var stDate = $("#stDate").val() + var edDate = $("#edDate").val() + if($("#stDate").val() ==""){ + alert('시작일을 선택해주세요'); + return; + } + + if($("#edDate").val() ==""){ + alert('종료일을 선택해주세요'); + return; + } + + stDate = new Date(stDate); + edDate = new Date(edDate); + + if(stDate.getFullYear() != edDate.getFullYear()){ + alert('같은 년도의 데이터만 조회가능합니다. ex)2021-01-01 ~ 2021-12-31'); + return; + } + + + + //location.href="/budget/stats/detail?year="+$("#year").val() + "&stDate=" + $("#stDate").val() + "&edDate=" + $("#edDate").val() + "&code=" +$("#code").val() + "&won="+$("#won").val(); + location.href="/budget/stats/detail?year="+$("#year").val() + "&stDate=" + $("#stDate").val() + "&edDate=" + $("#edDate").val() + "&code=본청&won="+$("#won").val()+"&item="+$("#item").val(); + +}) +$(document).on('click', '#deleteBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('삭제할 항목을 선택해주세요'); + return; + } + console.dir($("input[name='budget']:checked")[0].dataset.name1); + console.dir($("input[name='budget']:checked")[0].dataset.name2); + console.dir($("input[name='budget']:checked")[0].dataset.name3); + if(confirm('삭제하시겠습니까?')){ + var params = {}; + params.year = $("#searchYear").val(); + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + console.dir(params); + $.ajax({ + type : 'DELETE', + data : params, + + url : "/budget/budgeting/code", + + + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(data) { + if(data.code == "200"){ + alert("삭제되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("삭제에 실패하였습니다."); + } + }) + } + +}) + +function changeYear(){ + location.href="/budget/stats/detail?year="+$("#year").val(); +} + +$(document).on('click', '#updateBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('수정할 항목을 선택해주세요'); + return; + } + params = {} + params.year = $("#searchYear").val() + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); +}) + +function goAll() { + location.href="/budget/stats/all" +} + +function goOrg(){ + location.href="/budget/stats/org" +} + +function goDetail() { + location.href="/budget/stats/detail" +} + +function getViewModal(no){ + params = {} + params.no = no; + $.ajax({ + url: '/pds/ship/modal/view', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + }, + error:function(){ + + } + }); +} + +$(document).on('click', '.grid', function(event) { + const target = event.target; + const no = (Number($(this).find(".key").val())); + +}) + +function getEditModal(no){ + + params = {} + params.no = no; + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); + + +} + + +$(document).on('click', '#saveBtn', function (){ + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + + if(confirm("저장하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + + +$(document).on('click', '#modifyBtn', function (){ + + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + if(confirm("수정하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'PUT', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } + + +}); + +$(document).on('click', '#tempBtn', function (){ + if(confirm("임시 저장하시겠습니까?")){ + $("#status").val("TEMP"); + const formData = new FormData($("#investigationEditForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/pds/ship", + processData: false, + contentType: false, + success : function(data) { + alert("저장되었습니다."); + location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); diff --git a/src/main/resources/static/js/budget/statsOrg.js b/src/main/resources/static/js/budget/statsOrg.js new file mode 100644 index 00000000..839663af --- /dev/null +++ b/src/main/resources/static/js/budget/statsOrg.js @@ -0,0 +1,316 @@ +$(function(){ + $("#dateSelectorDiv").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); +}) + +$(document).on('click', '#addBtn', function (){ + getEditModal(0) +}) + +$(document).on('click', '#searchBtn', function (){ + var stDate = $("#stDate").val() + var edDate = $("#edDate").val() + if($("#stDate").val() ==""){ + alert('시작일을 선택해주세요'); + return; + } + + if($("#edDate").val() ==""){ + alert('종료일을 선택해주세요'); + return; + } + + stDate = new Date(stDate); + edDate = new Date(edDate); + + if(stDate.getFullYear() != edDate.getFullYear()){ + alert('같은 년도의 데이터만 조회가능합니다. ex)2021-01-01 ~ 2021-12-31'); + return; + } + + $("#year").val(stDate.getFullYear()); + + location.href="/budget/stats/org?year="+$("#year").val() + "&stDate=" + $("#stDate").val() + "&edDate=" + $("#edDate").val() + "&code=" +$("#code").val() + "&won="+$("#won").val(); + +}) +$(document).on('click', '#deleteBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('삭제할 항목을 선택해주세요'); + return; + } + console.dir($("input[name='budget']:checked")[0].dataset.name1); + console.dir($("input[name='budget']:checked")[0].dataset.name2); + console.dir($("input[name='budget']:checked")[0].dataset.name3); + if(confirm('삭제하시겠습니까?')){ + var params = {}; + params.year = $("#searchYear").val(); + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + console.dir(params); + $.ajax({ + type : 'DELETE', + data : params, + + url : "/budget/budgeting/code", + + + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(data) { + if(data.code == "200"){ + alert("삭제되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("삭제에 실패하였습니다."); + } + }) + } + +}) + +$(document).on('click', '#updateBtn', function (){ + if($("input[name='budget']:checked").val() == undefined || $("input[name='budget']:checked").val()==null){ + alert('수정할 항목을 선택해주세요'); + return; + } + params = {} + params.year = $("#searchYear").val() + params.nameL1 = $("input[name='budget']:checked")[0].dataset.name1; + params.nameL2 = $("input[name='budget']:checked")[0].dataset.name2; + params.nameL3 = $("input[name='budget']:checked")[0].dataset.name3; + + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); +}) + + + +function getList(){ + $.ajax({ + type : 'GET', + data : {}, + url : "/pds/ship/list", + processData: false, + contentType: false, + beforeSend: function (xhr){ + xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); + }, + success : function(response) { + console.dir(response) + + }, + error : function() { + alert("저장에 실패하였습니다."); + }, + complete : function () { + loaddingOff(); + } + }) +} + +function goAll() { + location.href="/budget/stats/all" +} + +function goOrg() { + location.href="/budget/stats/org" +} + +function goDetail(){ + location.href="/budget/stats/detail" +} +function getViewModal(no){ + params = {} + params.no = no; + $.ajax({ + url: '/pds/ship/modal/view', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + $("#editModalContent").empty().append(html); + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + $("#editModal").modal('show'); + }, + error:function(){ + + } + }); +} + +$(document).on('click', '.grid', function(event) { + const target = event.target; + const no = (Number($(this).find(".key").val())); + +}) + +function getEditModal(no){ + + params = {} + params.no = no; + $.ajax({ + url: '/budget/budgeting/modal/edit', + data: params, + type: 'GET', + dataType:"html", + success: function(html){ + + $("#editModalContent").empty().append(html); + $("#year").val($("#searchYear").val()) + $(".dateSelector").datepicker({ + format: "yyyy-mm-dd", + language: "ko", + autoclose: true + }); + + $("#editModal").modal('show'); + + }, + error:function(){ + + } + }); + + +} + + +$(document).on('click', '#saveBtn', function (){ + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + + if(confirm("저장하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); + + +$(document).on('click', '#modifyBtn', function (){ + + if($("#nameL1").val() == ""){ + alert('사업명을 입력해주세요.'); + $("#position").focus(); + return; + } + if($("#nameL2").val() == ""){ + alert('구분을 입력해주세요.'); + $("#name").focus(); + return; + } + if($("#nameL3").val() == ""){ + alert('세부내역을 입력해주세요.'); + $("#name").focus(); + return; + } + + if(confirm("수정하시겠습니까?")){ + const formData = new FormData($("#budgetForm")[0]); + $.ajax({ + type : 'PUT', + data : formData, + url : "/budget/budgeting/code", + processData: false, + contentType: false, + success : function(data) { + if(data.code == "200"){ + alert("저장되었습니다."); + location.reload(); + }else{ + alert(data.message); + } + //location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } + + +}); + +$(document).on('click', '#tempBtn', function (){ + if(confirm("임시 저장하시겠습니까?")){ + $("#status").val("TEMP"); + const formData = new FormData($("#investigationEditForm")[0]); + $.ajax({ + type : 'POST', + data : formData, + url : "/pds/ship", + processData: false, + contentType: false, + success : function(data) { + alert("저장되었습니다."); + location.reload(); + }, + error : function(xhr) { + alert("저장에 실패하였습니다."); + } + }) + } +}); From 9d03dcf48221a3d5b95d1793f1db6a6256f39704 Mon Sep 17 00:00:00 2001 From: "Lim\\jun" Date: Tue, 9 May 2023 16:33:21 +0900 Subject: [PATCH 3/5] =?UTF-8?q?=EC=98=88=EC=82=B0=20=EC=97=85=EB=8E=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../faisp/main/budget/BudgetController.java | 372 +++++++++++++++++- .../main/budget/common/BaseException.java | 18 + .../budget/common/ResultResponseCode.java | 53 +++ .../faisp/main/budget/model/BudgetDto.java | 158 ++++++++ .../main/budget/model/ResultResponse.java | 37 ++ .../budget/repository/BudgetRepository.java | 346 ++++++++++++++++ .../main/budget/service/BudgetService.java | 299 ++++++++++++++ 7 files changed, 1278 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/dbnt/faisp/main/budget/common/BaseException.java create mode 100644 src/main/java/com/dbnt/faisp/main/budget/common/ResultResponseCode.java create mode 100644 src/main/java/com/dbnt/faisp/main/budget/model/BudgetDto.java create mode 100644 src/main/java/com/dbnt/faisp/main/budget/model/ResultResponse.java create mode 100644 src/main/java/com/dbnt/faisp/main/budget/repository/BudgetRepository.java create mode 100644 src/main/java/com/dbnt/faisp/main/budget/service/BudgetService.java diff --git a/src/main/java/com/dbnt/faisp/main/budget/BudgetController.java b/src/main/java/com/dbnt/faisp/main/budget/BudgetController.java index 13e30683..044999e1 100644 --- a/src/main/java/com/dbnt/faisp/main/budget/BudgetController.java +++ b/src/main/java/com/dbnt/faisp/main/budget/BudgetController.java @@ -1,38 +1,400 @@ package com.dbnt.faisp.main.budget; +import com.dbnt.faisp.main.budget.common.ResultResponseCode; +import com.dbnt.faisp.main.budget.model.ResultResponse; +import com.dbnt.faisp.main.budget.model.BudgetDto; +import com.dbnt.faisp.main.budget.repository.BudgetRepository.*; +import com.dbnt.faisp.main.budget.service.BudgetService; import com.dbnt.faisp.main.userInfo.model.UserInfo; +import com.dbnt.faisp.main.userInfo.service.UserInfoService; + import lombok.RequiredArgsConstructor; + +import org.springframework.data.domain.Pageable; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import org.springframework.web.servlet.ModelAndView; -@RestController +import java.time.LocalDate; +import java.util.List; + + +@SuppressWarnings("unchecked") @RequiredArgsConstructor +@RestController @RequestMapping("/budget") public class BudgetController { + private final UserInfoService userInfoService; + private final BudgetService budgetService; + /* 예산편성 - 화면 */ @GetMapping("/budgeting") - public ModelAndView budgetingPage(@AuthenticationPrincipal UserInfo loginUser){ + public ModelAndView viewShipList(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingSearchReqeust requestDto, Pageable pageable) { ModelAndView mav = new ModelAndView("budget/budgeting"); + if (requestDto.getYear() == null || requestDto.getYear().equals("")) { + LocalDate date = LocalDate.now(); + requestDto.setYear(String.valueOf(date.getYear())); + } + System.out.println(requestDto.getYear()); + List list = budgetService.selectBudgetingList(loginUser, requestDto); + List yearList = budgetService.selectBudgetingYearList(loginUser); + long sum = 0; + for (int i = 0; i < list.size(); i++) { + sum += list.get(i).getAmount(); + } + requestDto.setSum(sum); +// System.out.println(yearList.get(1).getYear()); +// System.out.println(yearList.size()); + mav.addObject("list", list); + mav.addObject("yearList", yearList); + mav.addObject("searchParams", requestDto); return mav; } + + // 예산편성 - 연도 추가 + @PostMapping("/budgeting/year") + public ResultResponse copyBudgeting(@AuthenticationPrincipal UserInfo loginUser, @RequestBody BudgetDto.BudgetingCopyReqeust requestDto) { + budgetService.copyYearBudgeting(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + // 예산편성 - 연도 삭제 + @DeleteMapping("/budgeting/year") + public ResultResponse deleteYearBudgeting(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingCopyReqeust requestDto) { + budgetService.deleteBudgetingYear(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + //예산편성 - 항목추가/변경 모달(버튼) + @GetMapping("/budgeting/modal/edit") + public ModelAndView editModal(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingInsertReqeust requestDto) { + ModelAndView mav = new ModelAndView("budget/budgetingEditModal"); + +// System.out.println(requestDto.getNameL1()); + if (requestDto.getNameL1() != null) { + mav.addObject("info", requestDto); + mav.addObject("cmd", "update"); + } else { + mav.addObject("info"); + mav.addObject("cmd", "insert"); + } + return mav; + } + + //예산편성 - 항목추가 + @PostMapping("/budgeting/code") + public ResultResponse insertBudgeting(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingInsertReqeust requestDto) { + budgetService.insertBudgetingList(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + //예산편성 - 항목변경 + @PutMapping("/budgeting/code") + public ResultResponse updateBudgeting(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingUpdateReqeust requestDto) { + budgetService.updateBudgetingList(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + //예산편성 - 항목삭제 + @DeleteMapping("/budgeting/code") + public ResultResponse deleteBudgeting(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingInsertReqeust requestDto) { + budgetService.deleteBudgetingList(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + // 예산편성 - 예산편성 버튼(modal) + @GetMapping("/budgeting/modal/org") + public ModelAndView orgModal(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.BudgetingSearchReqeust requestDto) { + ModelAndView mav = new ModelAndView("budget/budgetingOrgModal"); + List list = budgetService.selectBudgetingList(loginUser, requestDto); + mav.addObject("list", list); + mav.addObject("searchParams", requestDto); + return mav; + } + + // 예산편성 - 예산편성(저장) + @PostMapping("/budgeting/save") + public ResultResponse saveBudgeting(@AuthenticationPrincipal UserInfo loginUser, @RequestBody BudgetDto.BudgetingSaveReqeust requestDto) { + budgetService.saveBudgetingList(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + // 예산편성 - 예산삭제 (0원 세팅) + @DeleteMapping("/budgeting") //@AuthenticationPrincipal + public ResultResponse deleteBudgeting(UserInfo loginUser, BudgetDto.BudgetingSaveReqeust requestDto) { + budgetService.deleteBudgeting(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + // 예산배정 @GetMapping("/assign") - public ModelAndView assignPage(@AuthenticationPrincipal UserInfo loginUser){ + public ModelAndView viewAssignList(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.AssignSearchReqeust requestDto, Pageable pageable) { ModelAndView mav = new ModelAndView("budget/assign"); + String userOrgCode; + if (requestDto.getYear() != null) { + userOrgCode = requestDto.getCode(); + + List list = budgetService.selectBudgetAssignInfo(loginUser, requestDto); + mav.addObject("list", list); + } else { + // 로그인된 해당청 기본선택 + userOrgCode = userInfoService.selectUserInfo(loginUser.getUserSeq()).getOgCd(); + String HighOrgCode = budgetService.selectGetHighOrgCode(userOrgCode); + if (HighOrgCode == null) { // 1, 2단계시 + requestDto.setCode(userOrgCode); + } else { // 3단계 이하 관서시 + requestDto.setCode(HighOrgCode); + userOrgCode = HighOrgCode; + } + + mav.addObject("list"); + + // 첫해 첫날 ~ 오늘날짜 기본세팅 + LocalDate date = LocalDate.now(); + String CurrentYear = String.valueOf(date.getYear()) + "-01-01"; + requestDto.setStDate(LocalDate.parse(CurrentYear)); + requestDto.setEdDate(date); + } + //하위청 리스트 + List downOrgList = budgetService.selectDownOrg(userOrgCode); + mav.addObject("downOrgList", downOrgList); + + //Select box 관서 리스트 + List codeList = budgetService.selectGetLowerOrgCodeByName(loginUser); + mav.addObject("codeList", codeList); + + mav.addObject("searchParams", requestDto); return mav; } + + + // 예산배정 - 리스트 수정 + @GetMapping("/assign/modal/edit") + public ModelAndView viewAssignModal(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.AssignSearchReqeust requestDto, Pageable pageable) { + ModelAndView mav = new ModelAndView("budget/assignEditModal"); + String userOrgCode; + LocalDate date = LocalDate.now(); + requestDto.setModalDate(date); + if (requestDto.getYear() != null) { + userOrgCode = requestDto.getCode(); + + List list = budgetService.selectBudgetAssignInfo(loginUser, requestDto); + mav.addObject("list", list); + } else { + // 로그인된 해당청 기본선택 + userOrgCode = userInfoService.selectUserInfo(loginUser.getUserSeq()).getOgCd(); + String HighOrgCode = budgetService.selectGetHighOrgCode(userOrgCode); + if (HighOrgCode == null) { // 1, 2단계시 + requestDto.setCode(userOrgCode); + } else { // 3단계 이하 관서시 + requestDto.setCode(HighOrgCode); + userOrgCode = HighOrgCode; + } + + mav.addObject("list"); + } + //하위청 리스트 + List downOrgList = budgetService.selectDownOrg(userOrgCode); + mav.addObject("downOrgList", downOrgList); + + List codeList = budgetService.selectGetLowerOrgCodeByName(loginUser); + mav.addObject("codeList", codeList); + + mav.addObject("searchParams", requestDto); + + return mav; + } + + // 예산배정 - 등록(저장버튼) + @PostMapping("/assign/save") + public ResultResponse saveAssign(@AuthenticationPrincipal UserInfo loginUser, @RequestBody BudgetDto.AssignSaveReqeust requestDto) { + budgetService.updateAssignList(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + // 집행관리 @GetMapping("/expense") - public ModelAndView expensePage(@AuthenticationPrincipal UserInfo loginUser){ + public ModelAndView viewExpenseList(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.AssignSearchReqeust requestDto, Pageable pageable) { ModelAndView mav = new ModelAndView("budget/expense"); + String userOrgCode; + if (requestDto.getYear() != null) { + userOrgCode = requestDto.getCode(); + + List list = budgetService.selectBudgetExpenseInfo(loginUser, requestDto); + mav.addObject("list", list); + } else { + // 로그인된 해당청 기본선택 + userOrgCode = userInfoService.selectUserInfo(loginUser.getUserSeq()).getOgCd(); + String HighOrgCode = budgetService.selectGetHighOrgCode(userOrgCode); + if (HighOrgCode == null) { // 1, 2단계시 + requestDto.setCode(userOrgCode); + } else { // 3단계 이하 관서시 + requestDto.setCode(HighOrgCode); + userOrgCode = HighOrgCode; + } + + mav.addObject("list"); + + // 첫해 첫날 ~ 오늘날짜 기본세팅 + LocalDate date = LocalDate.now(); + String CurrentYear = String.valueOf(date.getYear()) + "-01-01"; + requestDto.setStDate(LocalDate.parse(CurrentYear)); + requestDto.setEdDate(date); + } + //하위청 리스트 + List downOrgList = budgetService.selectDownOrg(userOrgCode); + mav.addObject("downOrgList", downOrgList); + + List codeList = budgetService.selectGetLowerOrgCodeByName(loginUser); + mav.addObject("codeList", codeList); + + mav.addObject("searchParams", requestDto); return mav; } + + @PostMapping("/expense") + public ResultResponse saveExpense(@AuthenticationPrincipal UserInfo loginUser, @RequestBody BudgetDto.ExpenseSaveReqeust requestDto) { + budgetService.insertExpense(loginUser, requestDto); + return new ResultResponse().successResponse(ResultResponseCode.SUCCESS); + } + + /* 예산편성 - 팝업화면 */ + @GetMapping("/expense/modal/view") + public ModelAndView viewExpenseModal(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.ExpenseSearchReqeust requestDto, Pageable pageable) { + ModelAndView mav = new ModelAndView("budget/expenseEditModal"); + List list = budgetService.selectBudgetExpense(loginUser, requestDto); + + mav.addObject("list", list); + mav.addObject("searchParams", requestDto); + + return mav; + } + + /* 집행표 - 화면 */ @GetMapping("/stats") - public ModelAndView statsPage(@AuthenticationPrincipal UserInfo loginUser){ + public ModelAndView viewStatsAllList(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.StatsSearchReqeust requestDto, Pageable pageable) { ModelAndView mav = new ModelAndView("budget/stats"); + String userOrgCode; + if (requestDto.getYear() != null) { + userOrgCode = requestDto.getCode(); + + List list = budgetService.selectSpGetbudgetStatOrg(loginUser, requestDto); + + mav.addObject("list", list); + } else { + // 로그인된 해당청 기본선택 + userOrgCode = userInfoService.selectUserInfo(loginUser.getUserSeq()).getOgCd(); + String HighOrgCode = budgetService.selectGetHighOrgCode(userOrgCode); + if (HighOrgCode == null) { // 1, 2단계시 + requestDto.setCode(userOrgCode); + } else { // 3단계 이하 관서시 + requestDto.setCode(HighOrgCode); + userOrgCode = HighOrgCode; + } + + mav.addObject("list"); + + // 첫해 첫날 ~ 오늘날짜 기본세팅 + LocalDate date = LocalDate.now(); + String CurrentYear = String.valueOf(date.getYear()) + "-01-01"; + requestDto.setStDate(LocalDate.parse(CurrentYear)); + requestDto.setEdDate(date); + } + //하위청 리스트 + List downOrgList = budgetService.selectDownOrg(userOrgCode); + mav.addObject("downOrgList", downOrgList); + + List codeList = budgetService.selectGetLowerOrgCodeByName(loginUser); + mav.addObject("codeList", codeList); + + mav.addObject("searchParams", requestDto); return mav; } + + /* 집행표 - 화면 */ + @GetMapping("/stats/org") + public ModelAndView viewExpenseList(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.StatsSearchReqeust requestDto, Pageable pageable) { + ModelAndView mav = new ModelAndView("budget/statsOrg"); + String userOrgCode; + if (requestDto.getYear() != null) { + userOrgCode = requestDto.getCode(); + + List list = budgetService.selectSpGetbudgetStatOrg(loginUser, requestDto); + mav.addObject("list", list); + } else { + // 로그인된 해당청 기본선택 + userOrgCode = userInfoService.selectUserInfo(loginUser.getUserSeq()).getOgCd(); + String HighOrgCode = budgetService.selectGetHighOrgCode(userOrgCode); + if (HighOrgCode == null) { // 1, 2단계시 + requestDto.setCode(userOrgCode); + } else { // 3단계 이하 관서시 + requestDto.setCode(HighOrgCode); + userOrgCode = HighOrgCode; + } + + mav.addObject("list"); + + // 첫해 첫날 ~ 오늘날짜 기본세팅 + LocalDate date = LocalDate.now(); + String CurrentYear = String.valueOf(date.getYear()) + "-01-01"; + requestDto.setStDate(LocalDate.parse(CurrentYear)); + requestDto.setEdDate(date); + } + //하위청 리스트 + List downOrgList = budgetService.selectDownOrg(userOrgCode); + mav.addObject("downOrgList", downOrgList); + + List codeList = budgetService.selectGetLowerOrgCodeByName(loginUser); + mav.addObject("codeList", codeList); + + mav.addObject("searchParams", requestDto); + + return mav; + } + + /* 세부내역별현황 - 화면 */ + @GetMapping("/stats/detail") + public ModelAndView viewStatsDetailList(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.StatsSearchReqeust requestDto, Pageable pageable) { + ModelAndView mav = new ModelAndView("budget/statsDetail"); + + List yearList = budgetService.selectBudgetingYearList(loginUser); + if (requestDto.getStDate() != null) { + List list = budgetService.selectSpGetbudgetStatDetail(loginUser, requestDto); + List codeList = budgetService.selectSpGetL3Code(loginUser, requestDto.getYear()); + mav.addObject("list", list); + mav.addObject("codeList", codeList); + } else { + + LocalDate date = LocalDate.now(); + List codeList = budgetService.selectSpGetL3Code(loginUser, String.valueOf(date.getYear())); + requestDto.setYear(String.valueOf(date.getYear())); + mav.addObject("list"); + mav.addObject("codeList", codeList); + + // 첫해 첫날 ~ 오늘날짜 기본세팅 + String CurrentYear = String.valueOf(date.getYear()) + "-01-01"; + requestDto.setStDate(LocalDate.parse(CurrentYear)); + requestDto.setEdDate(date); + } + List codeList = budgetService.selectGetLowerOrgCodeByName(loginUser); + + mav.addObject("yearList", yearList); + mav.addObject("searchParams", requestDto); + + return mav; + } + + @GetMapping("/stats/code") + @ResponseBody + public List selectCodeL3(@AuthenticationPrincipal UserInfo loginUser, BudgetDto.L3CodeRequest requestDto) { + + List list = budgetService.selectSpGetL3Code(loginUser, requestDto.getYear()); + return list; + } + + } diff --git a/src/main/java/com/dbnt/faisp/main/budget/common/BaseException.java b/src/main/java/com/dbnt/faisp/main/budget/common/BaseException.java new file mode 100644 index 00000000..f8e58f00 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/budget/common/BaseException.java @@ -0,0 +1,18 @@ +package com.dbnt.faisp.main.budget.common; + +import com.dbnt.faisp.main.budget.common.ResultResponseCode; + +public class BaseException extends RuntimeException { + + private static final long serialVersionUID = 163922632784183581L; + private ResultResponseCode code; + + public BaseException(ResultResponseCode code) { + this.code = code; + } + + public ResultResponseCode getCode(){ + return code; + } + +} diff --git a/src/main/java/com/dbnt/faisp/main/budget/common/ResultResponseCode.java b/src/main/java/com/dbnt/faisp/main/budget/common/ResultResponseCode.java new file mode 100644 index 00000000..7d21e8d8 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/budget/common/ResultResponseCode.java @@ -0,0 +1,53 @@ +package com.dbnt.faisp.main.budget.common; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Collections; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +@AllArgsConstructor +@Getter +public enum ResultResponseCode { + + SUCCESS(200, "정상처리되었습니다.","Success"), + DATA_NOT_FOUND(604, "존재하지 않는 데이터입니다.","InternalNotFound"), + FORBIDDEN(403,"해당요청에 대한 권한이 없습니다.","Forbidden"), + PARAM_NOT_NULL(900, " - 필수 입력 사항입니다.", "NotNull"), + PARAM_NOT_EMPTY(900, " - 필수 입력 사항입니다.", "NotEmpty"), + INTERNAL_PARAM_EMPTY(900, "필수 항목이 누락되었습니다.", "InternalParamEmpty"), + FILE_EMPTY(900, "필수 파일이 존재하지 않습니다.", "FileEmpty"), + PARAM_PERMIT_TYPE(901, "잘못된 형식의 데이터입니다.", "ParamType"), + NOT_FOUND_SENDER(903, "발송대상이 없습니다.","NotFoundSender"), + TYPE_MISMATCH(905, "잘못된 형식의 데이터입니다..", "typeMismatch"), + DUPLICATE_CODE(906, "이미 등록된 코드명칭입니다.", "DuplicateCode"), + DELETE_FOUND_VALUE(907, "예산표에 값이 있습니다. 예산삭제 후 해당 코드를 삭제하십시요.", "DELETE_FOUND_VALUE"), + + + NOT_FOUND_CODE(908, "없는 코드 또는 명칭입니다." ,"NotFoundCodE"), + NOT_FOUND_YEAR(909 , " 없는 연도의 코드입니다.", "NotFoundYear"), + FOUND_YEAR(910, "이미 등록되어 있는 연도의 코드입니다.", "FoundYear"), + EXPENSE_OVER_VALUE(911, "총 지출금액이 배정된 예산보다 큽니다.", "ExepenseOverValue"), + ERROR(999, "오류가 발생하였습니다.","ERROR"); + + + + private static final Map CODE_MAP = Collections.unmodifiableMap(Stream.of(values()).collect(Collectors.toMap(ResultResponseCode::getType, ResultResponseCode::name))); + + private int code; + private String message; + private String type; + + public static ResultResponseCode of(final String code) { + try { + return ResultResponseCode.valueOf(CODE_MAP.get(code)); + }catch(NullPointerException NPE) { + return ResultResponseCode.valueOf("ERROR"); + } + } + +} + + diff --git a/src/main/java/com/dbnt/faisp/main/budget/model/BudgetDto.java b/src/main/java/com/dbnt/faisp/main/budget/model/BudgetDto.java new file mode 100644 index 00000000..5684b825 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/budget/model/BudgetDto.java @@ -0,0 +1,158 @@ +package com.dbnt.faisp.main.budget.model; + +import com.dbnt.faisp.config.BaseModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; + +public class BudgetDto { + + @Data + @AllArgsConstructor + @ToString + public static class BudgetingListResponse { + + private String budget_name_l1; + private String budget_name_l2; + private String budget_name_l3; + } + + @Data + @AllArgsConstructor + @ToString + public static class BudgetingSearchReqeust { + private String year; + private Long sum; + } + + @Data + @AllArgsConstructor + @ToString + public static class BudgetingInsertReqeust { + private String year; + private String nameL1; + private String nameL2; + private String nameL3; + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @ToString + public static class BudgetingSaveReqeust { + private String year; + private String nameL1; + private String nameL2; + private String nameL3; + private Integer amount; + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @ToString + public static class AssignSaveReqeust { + private String year; + private String code; + private Integer amount; + private String org; + private String org1; + + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @ToString + public static class BudgetingCopyReqeust { + private String year; + private String copyYear; + } + + @Data + @AllArgsConstructor + @ToString + public static class BudgetingUpdateReqeust { + private String year; + private String nameL1; + private String nameL2; + private String nameL3; + private String prevNameL1; + private String prevNameL2; + private String prevNameL3; + + } + + @Data + @AllArgsConstructor + @ToString + public static class AssignSearchReqeust { + private String year; + private String code; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate stDate; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate edDate; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate modalDate; + + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @ToString + public static class ExpenseSaveReqeust { + private String year; + private String nameL1; + private String nameL2; + private String nameL3; + private String item; + private Integer amount; + private String org; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate expenseDate; + + + } + + @Data + @AllArgsConstructor + @ToString + public static class StatsSearchReqeust { + private String year; + private String code; + private String item; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate stDate; + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate edDate; + private Integer won; + + + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @ToString + public static class ExpenseSearchReqeust { + private String year; + private String nameL1; + private String nameL2; + private String nameL3; + private Integer amount; + } + + @Data + @AllArgsConstructor + @ToString + public static class L3CodeRequest { + private String year; + + } +} diff --git a/src/main/java/com/dbnt/faisp/main/budget/model/ResultResponse.java b/src/main/java/com/dbnt/faisp/main/budget/model/ResultResponse.java new file mode 100644 index 00000000..1d2a2e6c --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/budget/model/ResultResponse.java @@ -0,0 +1,37 @@ +package com.dbnt.faisp.main.budget.model; + +import com.dbnt.faisp.main.budget.common.ResultResponseCode; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +@AllArgsConstructor +public class ResultResponse { + + private int code; + private String message; + private T data; + + public ResultResponse(int code, String message) { + this.code = code; + this.message = message; + } + + public ResultResponse(ResultResponseCode responseCode) { + this.code = responseCode.getCode(); + this.message = responseCode.getMessage(); + } + + public ResultResponse successResponse(T data) { + this.code = ResultResponseCode.SUCCESS.getCode(); + this.message = ResultResponseCode.SUCCESS.getMessage(); + this.data = data; + return new ResultResponse<>(this.code, this.message, this.data); + } + +} + diff --git a/src/main/java/com/dbnt/faisp/main/budget/repository/BudgetRepository.java b/src/main/java/com/dbnt/faisp/main/budget/repository/BudgetRepository.java new file mode 100644 index 00000000..cbc3b0e9 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/budget/repository/BudgetRepository.java @@ -0,0 +1,346 @@ +package com.dbnt.faisp.main.budget.repository; + +import com.dbnt.faisp.main.codeMgt.model.CodeCatg; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.sql.Date; +import java.util.List; + +@Repository +public interface BudgetRepository extends JpaRepository { + + @Query(value = " select " + + "budget_name_l1 as budgetNameL1," + + "budget_name_l2 as budgetNameL2," + + "budget_name_l3 as budgetNameL3," + + "budget_code_l3 as budgetCodeL3," + + "amount," + + "remark," + + "modi_id as modiId," + + "modi_date as modiDate " + + " from public.sp_get_budget_plan_info(:code1, :code2, :code3) ", nativeQuery = true) + List callSpGetBudgetPlanInfo( + @Param("code1") String code1, + @Param("code2") String code2, + @Param("code3") String code3); + + //(공통) - 생선된 년도 (셀렉트박스) + @Query(value ="select l1_year as year from public.sp_get_budget_code_year_list( );", nativeQuery = true) + List callSpGetBudgetCodeYearList(); + + //예산편성 - 연도추가 + @Query(value ="call public.sp_copy_budget_item (:year,:copyYear,:id,NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callSpCopyBudgetItem( + @Param("year") String year, + @Param("copyYear") String org, + @Param("id") String id); + + //예산편성 - 연도삭제 + @Query(value ="call public.sp_brute_force_delete_budget_item(:year, :id,NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callBruteForceDeleteBudgetItem( + @Param("year") String year, + @Param("id") String id); + + //예산편성 - 항목추가 + @Query(value ="call public.sp_add_budget_plan_codename (:year, :code1, :code2, :code3, :org, :id ,NULL, NULL, NULL);", nativeQuery = true) + UpdateResult callSpAddBudgetPlanCodeName( + @Param("year") String year, + @Param("code1") String nameL1, + @Param("code2") String nameL2, + @Param("code3") String nameL3, + @Param("org") String org, + @Param("id") String id); + + //예산편성 - 항목변경 + @Query(value ="call public.sp_update_budget_plan_codename(:year, :code1, :code2, :code3, :newCode1, :newCode2, :newCode3, :org,:id,NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callSpUpdateBudgetPlanCodeName( + @Param("year") String year, + @Param("code1") String prevNameL1, + @Param("code2") String prevNameL2, + @Param("code3") String prevNameL3, + @Param("newCode1") String nameL1, + @Param("newCode2") String nameL2, + @Param("newCode3") String nameL3, + @Param("org") String org, + @Param("id") String id); + + //예산편성 - 항목삭제 + @Query(value ="call public.sp_delete_budget_plan_codename(:year, :code1, :code2, :code3, :org,:id,NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callSpDeleteBudgetPlanCodeName( + @Param("year") String year, + @Param("code1") String nameL1, + @Param("code2") String nameL2, + @Param("code3") String nameL3, + @Param("org") String org, + @Param("id") String id); + + //예산편성 - 예산저장 + @Query(value ="call public.sp_update_budget_plan_item (:year, :code1, :code2, :code3, :amount, :org, :id,NULL, NULL, NULL);", nativeQuery = true) + UpdateResult callSpUpdateBudgetPlanCodeItem( + @Param("year") String year, + @Param("code1") String nameL1, + @Param("code2") String nameL2, + @Param("code3") String nameL3, + @Param("amount") Integer amount, + @Param("org") String org, + @Param("id") String id); + + //예산편성 - 예산삭제 + @Query(value ="call public.sp_clear_budget_plan(:year, :org, :id,NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callSpDeleteBudgetPlan( + @Param("year") String year, + @Param("org") String org, + @Param("id") String id); + + // 예산배정 + @Query(value ="select * from public.sp_get_budget_assign_info(:year, :code, :user ,:stDate, :edDate)", nativeQuery = true) + List callSpGetBudgetAssignInfo( + @Param("year") String year, + @Param("code") String code, + @Param("user") String user, + @Param("stDate") Date stDate, + @Param("edDate") Date edDate + ); + + //(공통) 2단계로 하위청 뿌려주기 + @Query(value ="select org_code as orgCode, org_name as orgName from public.sp_get_down_org(:org);", nativeQuery = true) + List callSpGetDownOrg( + @Param("org") String org + ); + + // + @Query(value ="select org_code as orgCode, org_name as orgName from public.sp_get_lower_org_code_by_name('본청');", nativeQuery = true) + List callSpGetLowerOrgCodeByName( + + ); + + //상위 기관 코드 가져오기 (3단계인경우만) + @Query(value ="select * from public.sp_get_high_org_code(:org);", nativeQuery = true) + String callSpGetHighOrgCode( + @Param("org") String org + ); + + // 예산배정 - 등록(저장버튼) + @Query(value ="call public.sp_add_budget_assign(:code, :org, :org1, cast (:amount as bigint), to_date(:dt,'YYYY-MM-DD'), 'admin', NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callSpAddBudgetAssign( + @Param("code") String year, + @Param("org") String org, + @Param("org1") String org1, + @Param("amount") Integer amount, + @Param("dt") String dt); + + // 집행관리 + @Query(value ="select * from public.sp_get_budget_expense_info(:year,:code,:user,:stDate,:edDate);", nativeQuery = true) + List callSpGetBudgetExpenseInfo( + @Param("year") String year, + @Param("code") String code, + @Param("user") String user, + @Param("stDate") Date stDate, + @Param("edDate") Date edDate + ); + + @Query(value ="select * from public.sp_get_budget_expense(:year,:code1,:code2,:code3,:org,1,2,20,1);", nativeQuery = true) + List callSpGetBudgetExpense( + @Param("year") String year, + @Param("code1") String code1, + @Param("code2") String code2, + @Param("code3") String code3, + @Param("org") String org + ); + + @Query(value ="call public.sp_add_budget_EXPENSE(:year,:code1,:code2,:code3, :org, :item ,cast (:amount as bigint), to_date(:dt,'YYYY-MM-DD'),'admin',NULL,NULL,NULL);", nativeQuery = true) + UpdateResult callSpAddBudgetExpense( + @Param("year") String year, + @Param("code1") String code1, + @Param("code2") String code2, + @Param("code3") String code3, + @Param("org") String org, + @Param("item") String item, + @Param("amount") Integer amount, + @Param("dt") Date dt + + ); + + @Query(value ="call public.sp_update_budget_expense(:seq,:item ,cast (:amount as bigint),NULL,NULL,NULL,NULL,NULL);;", nativeQuery = true) + List callSpUpdateBudgetExpense( + @Param("seq") Integer seq, + @Param("item") String item, + @Param("amount") Integer amount + ); + + @Query(value ="select * from public.sp_get_budget_statistics_by_org(:year,:code,:user,:stDate,:edDate,:won);", nativeQuery = true) + List callSpGetbudgetStatOrg( + @Param("year") String year, + @Param("code") String code, + @Param("user") String user, + @Param("stDate") Date stDate, + @Param("edDate") Date edDate, + @Param("won") int won + ); + + @Query(value ="select * from public.sp_get_budget_statistics_by_item(:year,:code,:item, :user,:stDate,:edDate,:won);", nativeQuery = true) + List callSpGetbudgetStatDetail( + @Param("year") String year, + @Param("code") String code, + @Param("item") String item, + @Param("user") String user, + @Param("stDate") Date stDate, + @Param("edDate") Date edDate, + @Param("won") int won + ); + + @Query(value ="select * from public.sp_get_budget_code_l3(:year,null,null,null);", nativeQuery = true) + List callSpGetBudgetCodeL3( + @Param("year") String year + ); + + public static interface BudgetingList { + String getBudgetNameL1(); + String getBudgetNameL2(); + String getBudgetNameL3(); + String getBudgetCodeL3(); + Integer getAmount(); + String getRemark(); + String getModiId(); + String getModiDate(); + } + + public static interface UpdateResult { + Integer get_result_count(); + String get_result_code(); + String get_error_message(); + + } + + public static interface YearResult { + String getYear(); + } + + public static interface AssignResult { + String getorg_count(); + String getbudget_name_l1(); + String getbudget_name_l2(); + String getbudget_name_l3(); + String getbudget_code_l3(); + String getplan_amount(); + String gettotal_assign_amount(); + String getperiod_assign_amount1(); + String getsum_assign_amount1(); + String getperiod_assign_amount2(); + String getsum_assign_amount2(); + String getperiod_assign_amount3(); + String getsum_assign_amount3(); + String getperiod_assign_amount4(); + String getsum_assign_amount4(); + String getperiod_assign_amount5(); + String getsum_assign_amount5(); + String getperiod_assign_amount6(); + String getsum_assign_amount6(); + String getperiod_assign_amount7(); + String getsum_assign_amount7(); + String getperiod_assign_amount8(); + String getsum_assign_amount8(); + String getperiod_assign_amount9(); + String getsum_assign_amount9(); + + } + + public static interface L3CodeResult { + + String getl3_name(); + String getl3_code(); + + } + + public static interface StatsItemResult { + String getorg_name(); + String getplan_amount(); + String gettotal_assign_amount(); + String getexpense_t_amount(); + String getbalance_t_amount(); + String getexpense_total_rate(); + } + + public static interface ExpenseResult { + String getorg_count(); + String getbudget_name_l1(); + String getbudget_name_l2(); + String getbudget_name_l3(); + String getbudget_code_l3(); + String getplan_amount(); + String gettotal_assign_amount(); + String getexpense_t_amount(); + String getbalance_t_amount(); + Integer getperiod_assign_amount1(); + Integer getexpense_p_amount1(); + Integer getblance_amount1(); + Integer getexpense_rate1(); + + String getperiod_assign_amount2(); + String getexpense_p_amount2(); + String getblance_amount2(); + String getexpense_rate2(); + + String getperiod_assign_amount3(); + String getexpense_p_amount3(); + String getblance_amount3(); + String getexpense_rate3(); + + + String getperiod_assign_amount4(); + String getexpense_p_amount4(); + String getblance_amount4(); + String getexpense_rate4(); + + + String getperiod_assign_amount5(); + String getexpense_p_amount5(); + String getblance_amount5(); + String getexpense_rate5(); + + + String getperiod_assign_amount6(); + String getexpense_p_amount6(); + String getblance_amount6(); + String getexpense_rate6(); + + String getperiod_assign_amount7(); + String getexpense_p_amount7(); + String getblance_amount7(); + String getexpense_rate7(); + + String getperiod_assign_amount8(); + String getexpense_p_amount8(); + String getblance_amount8(); + String getexpense_rate8(); + + String getperiod_assign_amount9(); + String getexpense_p_amount9(); + String getblance_amount9(); + String getexpense_rate9(); + + + } + + public static interface ExpenseInfoResult { + String getseq(); + String getexpense_date(); + String getexpense_item(); + String getamount(); + String getmodi_id(); + String getmodi_date(); + } + + + public static interface CodeResult { + String getOrgName(); + String getOrgCode(); + + + } + + +} diff --git a/src/main/java/com/dbnt/faisp/main/budget/service/BudgetService.java b/src/main/java/com/dbnt/faisp/main/budget/service/BudgetService.java new file mode 100644 index 00000000..166eb599 --- /dev/null +++ b/src/main/java/com/dbnt/faisp/main/budget/service/BudgetService.java @@ -0,0 +1,299 @@ +package com.dbnt.faisp.main.budget.service; + + +import com.dbnt.faisp.main.budget.common.BaseException; +import com.dbnt.faisp.main.budget.common.ResultResponseCode; +import com.dbnt.faisp.main.budget.model.BudgetDto; +import com.dbnt.faisp.main.budget.repository.BudgetRepository; +import com.dbnt.faisp.main.budget.repository.BudgetRepository.*; +import com.dbnt.faisp.main.equip.model.Equip; +import com.dbnt.faisp.main.userInfo.model.UserInfo; + +import lombok.RequiredArgsConstructor; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + + +@Service +@Transactional +@RequiredArgsConstructor +public class BudgetService { + + private final BudgetRepository budgetRepository; + + public List selectBudgetingList(UserInfo loginUser, BudgetDto.BudgetingSearchReqeust requestDto){ + return budgetRepository.callSpGetBudgetPlanInfo(requestDto.getYear(), "OG001", "admin"); + } + + public List selectBudgetingYearList(UserInfo loginUser){ + return budgetRepository.callSpGetBudgetCodeYearList(); + } + + // 예산편성 - 연도추가(버튼) + @Transactional + public void copyYearBudgeting(UserInfo loginUser, BudgetDto.BudgetingCopyReqeust requestDto){ +// System.out.println(requestDto.getYear()); +// System.out.println(requestDto.getCopyYear()); + UpdateResult result = budgetRepository.callSpCopyBudgetItem(requestDto.getYear(), requestDto.getCopyYear(), loginUser.getUserId()); + + if(result.get_result_code().equals("100")) { + return; + } else { + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.FOUND_YEAR); + } + + } + + //예산편성 - 연도삭제(버튼) + @Transactional + public void deleteBudgetingYear(UserInfo loginUser, BudgetDto.BudgetingCopyReqeust requestDto){ +// System.out.println(requestDto.getYear()); +// System.out.println(requestDto.getCopyYear()); + UpdateResult result = budgetRepository.callBruteForceDeleteBudgetItem(requestDto.getYear(), "admin"); + + if(result.get_result_code().equals("100")) { + return; + }else if( result.get_result_code().equals("93")){ + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.NOT_FOUND_YEAR); + } else { + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.DELETE_FOUND_VALUE); + } + } + + //예산편성 - 항목추가 + @Transactional + public void insertBudgetingList(UserInfo loginUser, BudgetDto.BudgetingInsertReqeust requestDto){ + System.out.println(requestDto.getYear()); + System.out.println(requestDto.getNameL1()); + System.out.println(requestDto.getNameL2()); + System.out.println(requestDto.getNameL3()); + UpdateResult result = budgetRepository.callSpAddBudgetPlanCodeName(requestDto.getYear(),requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), "OG001", "admin"); + + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + if(result.get_result_code().equals("100")) { + return; + } else { + throw new BaseException(ResultResponseCode.DUPLICATE_CODE); + } + + } + + //예산편성 - 항목변경 + public void updateBudgetingList(UserInfo loginUser, BudgetDto.BudgetingUpdateReqeust requestDto){ + System.out.println(requestDto.getYear()+","+ requestDto.getPrevNameL1()+","+requestDto.getPrevNameL2()+","+requestDto.getPrevNameL3()+","+requestDto.getNameL1()+","+requestDto.getNameL2()+","+requestDto.getNameL3()); + UpdateResult result = budgetRepository.callSpUpdateBudgetPlanCodeName( requestDto.getYear(), requestDto.getPrevNameL1(), requestDto.getPrevNameL2(), requestDto.getPrevNameL3(),requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), "OG001", "admin"); + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + System.out.println(result); + if(result.get_result_code().equals("100")) { + return; + } else if (result.get_result_code().equals("91")) { + throw new BaseException(ResultResponseCode.DUPLICATE_CODE); + } + } + + //예산편성 - 항목삭제 + public void deleteBudgetingList(UserInfo loginUser, BudgetDto.BudgetingInsertReqeust requestDto){ + System.out.println(requestDto.getYear()); + System.out.println(requestDto.getNameL1()); + System.out.println(requestDto.getNameL2()); + System.out.println(requestDto.getNameL3()); + UpdateResult result = budgetRepository.callSpDeleteBudgetPlanCodeName(requestDto.getYear(),requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), "OG001", "admin"); + + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + if(result.get_result_code().equals("100")) { + return; + } else { + throw new BaseException(ResultResponseCode.DELETE_FOUND_VALUE); + } + } + + // 예산편성 - 예산편성 저장(modal) + @Transactional + public void saveBudgetingList(UserInfo loginUser, BudgetDto.BudgetingSaveReqeust requestDto){ +// System.out.println(requestDto.getAmount()); +// System.out.println(requestDto.getNameL1()); +// System.out.println(requestDto.getNameL2()); +// System.out.println(requestDto.getNameL3()); + UpdateResult result = budgetRepository.callSpUpdateBudgetPlanCodeItem(requestDto.getYear(), requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), requestDto.getAmount(),"OG001", "admin"); + +// System.out.println(result.get_error_message()); +// System.out.println(result.get_result_code()); +// System.out.println(result.get_result_count()); + if(result.get_result_code().equals("100")) { + return; + } else { + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.DUPLICATE_CODE); + } + + } + + //예산편성 - 예산삭제(버튼) + @Transactional + public void deleteBudgeting(UserInfo loginUser, BudgetDto.BudgetingSaveReqeust requestDto){ +// System.out.println(requestDto.getYear()); +// System.out.println(requestDto.getNameL1()); +// System.out.println(requestDto.getNameL2()); +// System.out.println(requestDto.getNameL3()); + UpdateResult result = budgetRepository.callSpDeleteBudgetPlan(requestDto.getYear(), "OG001", "admin"); + + + if(result.get_result_code().equals("100")) { + return; + } else { + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.NOT_FOUND_CODE); + } + + } + + // 예산배정 + public List selectBudgetAssignInfo(UserInfo loginUser, BudgetDto.AssignSearchReqeust requestDto){ +// System.out.println(requestDto.getCode()); +// System.out.println(requestDto.getYear()); +// System.out.println(requestDto.getStDate()); +// System.out.println(requestDto.getEdDate()); + return budgetRepository.callSpGetBudgetAssignInfo(requestDto.getYear(), requestDto.getCode(), "admin", java.sql.Date.valueOf(requestDto.getStDate()),java.sql.Date.valueOf(requestDto.getEdDate())); + } + + //(공통) 2단계로 하위청 뿌려주기 + public List selectDownOrg(String userOrgCode){ + return budgetRepository.callSpGetDownOrg(userOrgCode); + } + + // + public List selectGetLowerOrgCodeByName(UserInfo loginUser){ + return budgetRepository.callSpGetLowerOrgCodeByName(); + } + + //상위 기관 코드 가져오기 (3단계인경우만) + public String selectGetHighOrgCode(String userOrgCode){ + return budgetRepository.callSpGetHighOrgCode(userOrgCode); + } + + // 예산배정 - 등록(저장버튼) + @Transactional + public void updateAssignList(UserInfo loginUser, BudgetDto.AssignSaveReqeust requestDto){ + + System.out.println(requestDto.getCode()); + System.out.println(requestDto.getOrg()); + System.out.println(requestDto.getYear()); +// System.out.println(requestDto.getAmount()); + UpdateResult result = budgetRepository.callSpAddBudgetAssign(requestDto.getCode(),requestDto.getOrg(),requestDto.getOrg1(), requestDto.getAmount(), "2023-03-15"); + + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + if(result.get_result_code().equals("100")) { + return; + }else if(result.get_result_code().equals("72")) { + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.EXPENSE_OVER_VALUE); + } else { + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + throw new BaseException(ResultResponseCode.DUPLICATE_CODE); + } + + } + + //집행관리 + public List selectBudgetExpenseInfo(UserInfo loginUser, BudgetDto.AssignSearchReqeust requestDto){ + System.out.println(requestDto.getYear()); + System.out.println(requestDto.getCode()); + System.out.println(java.sql.Date.valueOf(requestDto.getStDate())); + System.out.println(requestDto.getEdDate()); + return budgetRepository.callSpGetBudgetExpenseInfo(requestDto.getYear(), requestDto.getCode(), "admin", java.sql.Date.valueOf(requestDto.getStDate()),java.sql.Date.valueOf(requestDto.getEdDate())); + } + + public List selectBudgetExpense(UserInfo loginUser, BudgetDto.ExpenseSearchReqeust requestDto){ + System.out.println(requestDto.getYear()); + System.out.println(requestDto.getNameL1()); + System.out.println(requestDto.getNameL2()); + System.out.println(requestDto.getNameL3()); + return budgetRepository.callSpGetBudgetExpense(requestDto.getYear(), requestDto.getNameL1(), requestDto.getNameL2(), requestDto.getNameL3(), "본청"); + } + + @Transactional + public void insertExpense(UserInfo loginUser, BudgetDto.ExpenseSaveReqeust requestDto){ +// System.out.println(requestDto.getYear()); +// System.out.println(requestDto.getNameL1()); +// System.out.println(requestDto.getNameL2()); +// System.out.println(requestDto.getNameL3()); + UpdateResult result = budgetRepository.callSpAddBudgetExpense(requestDto.getYear(),requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), "본청", requestDto.getItem(), requestDto.getAmount(), java.sql.Date.valueOf(requestDto.getExpenseDate())); + + System.out.println(result.get_error_message()); + System.out.println(result.get_result_code()); + System.out.println(result.get_result_count()); + if(result.get_result_code().equals("100")) { + return; + }else if(result.get_result_code().equals("71")) { + throw new BaseException(ResultResponseCode.EXPENSE_OVER_VALUE); + } else { + throw new BaseException(ResultResponseCode.ERROR); + } + + } + + public List selectSpGetbudgetStatOrg(UserInfo loginUser,BudgetDto.StatsSearchReqeust requestDto){ + System.out.println(requestDto.getYear()); + System.out.println(requestDto.getCode()); + System.out.println(java.sql.Date.valueOf(requestDto.getStDate())); + System.out.println(requestDto.getEdDate()); + System.out.println(requestDto.getWon()); + return budgetRepository.callSpGetbudgetStatOrg(requestDto.getYear(), requestDto.getCode(), "admin", java.sql.Date.valueOf(requestDto.getStDate()), java.sql.Date.valueOf(requestDto.getEdDate()), requestDto.getWon()); + } + + public List selectSpGetbudgetStatDetail(UserInfo loginUser,BudgetDto.StatsSearchReqeust requestDto){ + System.out.println(requestDto.getYear()); + System.out.println(requestDto.getCode()); + System.out.println(java.sql.Date.valueOf(requestDto.getStDate())); + System.out.println(requestDto.getEdDate()); + System.out.println(requestDto.getWon()); + return budgetRepository.callSpGetbudgetStatDetail(requestDto.getYear(), requestDto.getCode(), requestDto.getItem(), "admin", java.sql.Date.valueOf(requestDto.getStDate()), java.sql.Date.valueOf(requestDto.getEdDate()), requestDto.getWon()); + } + + public List selectSpGetL3Code(UserInfo loginUser,String year){ + + return budgetRepository.callSpGetBudgetCodeL3(year); + } + + +// public void insertBudgetingYear(UserInfo loginUser, BudgetDto.BudgetingUpdateReqeust requestDto){ +// UpdateResult result = budgetRepository.callSpUpdateBudgetPlanCodeName( requestDto.getPrevNameL1(), requestDto.getPrevNameL2(), requestDto.getPrevNameL3(),requestDto.getYear(),requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), "OG001", "admin"); +// System.out.println(result); +// } +// +// public void deleteBudgetingYear(UserInfo loginUser, BudgetDto.BudgetingUpdateReqeust requestDto){ +// UpdateResult result = budgetRepository.callSpUpdateBudgetPlanCodeName( requestDto.getPrevNameL1(), requestDto.getPrevNameL2(), requestDto.getPrevNameL3(),requestDto.getYear(),requestDto.getNameL1(),requestDto.getNameL2(),requestDto.getNameL3(), "OG001", "admin"); +// System.out.println(result); +// } + + + +} From 0e4fbfe6718347060c0e2e117d31774249c62236 Mon Sep 17 00:00:00 2001 From: "Lim\\jun" Date: Tue, 9 May 2023 16:35:19 +0900 Subject: [PATCH 4/5] =?UTF-8?q?=EC=98=88=EC=82=B0=20=EC=97=85=EB=8E=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/budget/assign.js | 2 +- src/main/resources/templates/budget/assign.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/static/js/budget/assign.js b/src/main/resources/static/js/budget/assign.js index db3ff932..f46d1a9c 100644 --- a/src/main/resources/static/js/budget/assign.js +++ b/src/main/resources/static/js/budget/assign.js @@ -22,7 +22,7 @@ $(document).ready(function(){ } }); -$(document).on('click', '#searchBtn', function () { +$(document).on('click', '#assignsearchBtn', function () { assignSearch(); }) diff --git a/src/main/resources/templates/budget/assign.html b/src/main/resources/templates/budget/assign.html index dd9cb767..c2c122d9 100644 --- a/src/main/resources/templates/budget/assign.html +++ b/src/main/resources/templates/budget/assign.html @@ -49,7 +49,7 @@
- +
From 7e63d354c80ac29d2d71f8fab35367d69bfbbb76 Mon Sep 17 00:00:00 2001 From: "Lim\\jun" Date: Tue, 9 May 2023 16:36:18 +0900 Subject: [PATCH 5/5] =?UTF-8?q?=EC=98=88=EC=82=B0=20loading=20js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/js/common.js | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index 759b677d..000ecf11 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -356,4 +356,38 @@ function ajaxErrorAction(e){ location.href="/"; } } +} + +function LoadingWithMask() { + //화면의 높이와 너비를 구합니다. + let maskHeight = $(document).height(); + let maskWidth = window.document.body.clientWidth; + + //화면에 출력할 마스크를 설정해줍니다. + let mask = ""; + + //화면에 레이어 추가 + $("body") + .append(mask) + + //마스크의 높이와 너비를 화면 것으로 만들어 전체 화면을 채웁니다. + $("#mask").css({ + 'width' : maskWidth, + 'height': maskHeight, + 'opacity' : '0.7' + }); + $("#loadingImg").css({ + 'position' : 'absolute', + 'z-index' : '100', + 'top' : '50%', //parseInt(maskHeight)/2-20 + 'left' : '50%', //parseInt(maskWidth)/2-20, + }); + + //마스크 표시 + $("#mask").show(); +} + +function WithoutMask() { + $("#mask, #loadingImg").hide(); + $("#mask, #loadingImg").remove(); } \ No newline at end of file