예산통계 총괄 표 작업완료.

master
강석 최 2023-07-31 18:52:19 +09:00
parent 5b6a21eb60
commit 128478e477
8 changed files with 190 additions and 16 deletions

View File

@ -279,8 +279,15 @@ public class BudgetController {
requestDto.setEdDate(date);
}
mav.addObject("budgetCode", budgetService.selectBudgetCodeToYear(requestDto.getStDate().getYear()));
BudgetParams params = new BudgetParams();
params.setCode(requestDto.getCode());
params.setWon(requestDto.getWon());
params.setYear(((Integer)requestDto.getStDate().getYear()).toString());
params.setStDate(requestDto.getStDate());
params.setEdDate(requestDto.getEdDate());
mav.addObject("totalList", budgetService.selectStatsTotal(params));
mav.addObject("statsList", budgetService.selectStatsList(params, loginUser.getDownOrganCdList()));
mav.addObject("loginOrgan", loginUser.getOgCd());
if(loginUser.getOgCd().equals("OG001")){
//하위청 리스트

View File

@ -35,4 +35,7 @@ public interface BudgetMapper {
List<TblBudgetCodeL1> selectBudgetCodeL1List(String year);
List<TblBudgetCodeL2> selectBudgetCodeL2List(String l1Code);
List<StatsDetailResult> selectStatsTotal(BudgetParams params);
List<StatsDetailResult> selectStats(BudgetParams params);
}

View File

@ -0,0 +1,14 @@
package com.dbnt.faisp.main.budget.model;
import com.dbnt.faisp.main.budget.model.result.StatsDetailResult;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class BudgetStat {
String organ;
List<StatsDetailResult> amountList;
}

View File

@ -8,6 +8,7 @@ import lombok.Setter;
public class StatsDetailResult {
String parentOrgan;
String organCd;
String budgetCode;
Double planAmount = 0d;
Double assignAmount = 0d;
Double expenseAmount = 0d;

View File

@ -650,17 +650,29 @@ public class BudgetService {
return budgetCode;
}
public List<StatsDetailResult> selectStatsTotal(BudgetParams params){
List<StatsDetailResult> statsTotalList = budgetMapper.selectStatsTotal(params);
int wonUnit = params.getWon();
for(StatsDetailResult total: statsTotalList){
total.setPlanAmount(total.getPlanAmount()/wonUnit);
total.setAssignAmount(total.getAssignAmount()/wonUnit);
total.setExpenseAmount(total.getExpenseAmount()/wonUnit);
total.setBalanceAmount(total.getAssignAmount()-total.getExpenseAmount());
total.setRate(Math.round((total.getExpenseAmount()/total.getAssignAmount())*10000)/100d);
}
return statsTotalList;
}
// 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);
// }
public List<BudgetStat> selectStatsList(BudgetParams params, List<String> downOrganList){
List<BudgetStat> statList = new ArrayList<>();
for(String organ: downOrganList){
BudgetStat stat = new BudgetStat();
stat.setOrgan(organ);
params.setCode(organ);
stat.setAmountList(budgetMapper.selectStats(params));
statList.add(stat);
}
return statList;
}
}

View File

@ -249,4 +249,64 @@
and c2.l1_code = #{l1Code}
order by c2.l2_code
</select>
<select id="selectStatsTotal" resultType="StatsDetailResult" parameterType="BudgetParams">
select bp.budget_code,
bp.amount as plan_amount,
ba.amount as assign_amount,
be.amount as expense_amount
from tbl_budget_code_l1 l1
inner join tbl_budget_code_l2 l2 on l1.l1_code = l2.l1_code
inner join tbl_budget_code_l3 l3 on l2.l2_code = l3.l2_code and l3.use_tag = 'Y'
left outer join tbl_budget_plan bp on l3.l3_code = bp.budget_code and bp.org_code = #{code}
left outer join (
select budget_code, sum(amount) as amount
from tbl_budget_assign
where h_org_code = #{code}
and assign_date >= #{stDate}::date
and assign_date &lt;= #{edDate}::date+1
group by budget_code
) ba on l3.l3_code = ba.budget_code
left outer join (
select budget_code, sum(amount) as amount
from tbl_budget_expense
where expense_date >= #{stDate}::date
and expense_date &lt;= #{edDate}::date+1
group by budget_code
) be on l3.l3_code = be.budget_code
where l1.l1_year = #{year}
order by l3.l3_code
</select>
<select id="selectStats" resultType="StatsDetailResult" parameterType="BudgetParams">
select l3.l3_code as budgetCode,
ba.amount as assign_amount,
be.amount as expense_amount,
ba.amount-be.amount as balance_amount
--round(be.amount/ba.amount*100, 2) as rate
from tbl_budget_code_l1 l1
inner join tbl_budget_code_l2 l2 on l1.l1_code = l2.l1_code
inner join tbl_budget_code_l3 l3 on l2.l2_code = l3.l2_code and l3.use_tag = 'Y'
left outer join (
select budget_code, sum(amount) as amount
from tbl_budget_assign
where l_org_code = #{code}
<if test='code != "OG001"'>
and h_org_code &lt;> 'OG001'
</if>
and assign_date >= #{stDate}::date
and assign_date &lt;= #{edDate}::date+1
group by budget_code
) ba on l3.l3_code = ba.budget_code
left outer join (
select budget_code, sum(amount) as amount
from tbl_budget_expense
where org_code = #{code}
and expense_date >= #{stDate}::date
and expense_date &lt;= #{edDate}::date+1
group by budget_code
) be on l3.l3_code = be.budget_code
where l1.l1_year = #{year}
order by l3.l3_code
</select>
</mapper>

View File

@ -0,0 +1,20 @@
$(document).on('change', '#stDate,#edDate', function (){
const stInput = $("#stDate")
const edInput = $("#edDate")
const stDate = new Date(stInput.val());
const edDate = new Date(edInput.val());
if (stDate.getFullYear() != edDate.getFullYear()) {
alert('같은 년도의 데이터만 조회가능합니다. ex)2021-01-01 ~ 2021-12-31');
const nowDate = new Date();
stInput.val(nowDate.getFullYear()+"-01-01");
edInput.val(nowDate);
this.focus();
}
})
$(document).on('click', '#orgTab', function (){
location.href = "/budget/stats/org";
})
$(document).on('click', '#detailTab', function (){
location.href = "/budget/stats/detail";
})

View File

@ -3,6 +3,7 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}">
<th:block layout:fragment="script">
<script type="text/javascript" th:src="@{/js/budget/stats.js}"></script>
<script type="text/javascript" th:src="@{/js/budget/statsCommon.js}"></script>
</th:block>
<div layout:fragment="content">
@ -43,10 +44,10 @@
<div class="row justify-content-end">
<div class="col-auto">
<select class="form-select form-select-sm" name="won" id="won">
<option value="1" th:selected="${searchParams.won eq '1'}"></option>
<option value="2" th:selected="${searchParams.won eq '2'}">백원</option>
<option value="3" th:selected="${searchParams.won eq '3'}">천원</option>
<option value="4" th:selected="${searchParams.won eq '4'}">만원</option>
<option value="1" th:selected="${searchParams.won eq 1}"></option>
<option value="100" th:selected="${searchParams.won eq 100}">백원</option>
<option value="1000" th:selected="${searchParams.won eq 1000}">천원</option>
<option value="10000" th:selected="${searchParams.won eq 10000}">만원</option>
</select>
</div>
<div class="col-auto">
@ -97,6 +98,62 @@
</tr>
</thead>
<tbody class="table-group-divider">
<tr>
<td colspan="2">편성액</td>
<th:block th:each="total:${totalList}">
<td th:text="${#numbers.formatInteger(total.planAmount,1,'COMMA')}"></td>
</th:block>
</tr>
<tr>
<td colspan="2">배정액</td>
<th:block th:each="total:${totalList}">
<td th:text="${#numbers.formatInteger(total.assignAmount,1,'COMMA')}"></td>
</th:block>
</tr>
<tr>
<td colspan="2">집행액</td>
<th:block th:each="total:${totalList}">
<td th:text="${#numbers.formatInteger(total.expenseAmount,1,'COMMA')}"></td>
</th:block>
</tr>
<th:block th:each="stat, row:${statsList}">
<tr>
<td rowspan="3">
<th:block th:each="code:${session.commonCode.get('OG')}">
<th:block th:if="${stat.organ eq code.itemCd}" th:text="${code.itemValue}"></th:block>
</th:block>
</td>
<td>배정</td>
<th:block th:each="amount:${stat.amountList}">
<td th:text="${#numbers.formatInteger(amount.assignAmount,1,'COMMA')}"></td>
</th:block>
</tr>
<tr>
<td>집행</td>
<th:block th:each="amount:${stat.amountList}">
<td th:text="${#numbers.formatInteger(amount.expenseAmount,1,'COMMA')}"></td>
</th:block>
</tr>
<tr>
<td>잔액</td>
<th:block th:each="amount:${stat.amountList}">
<td th:text="${#numbers.formatInteger(amount.balanceAmount,1,'COMMA')}"></td>
</th:block>
</tr>
</th:block>
<tr>
<td colspan="2">사업별 잔액</td>
<th:block th:each="total:${totalList}">
<td th:text="${#numbers.formatInteger(total.balanceAmount,1,'COMMA')}"></td>
</th:block>
</tr>
<tr>
<td colspan="2">사업별집행률</td>
<th:block th:each="total:${totalList}">
<td th:text="${#strings.concat(total.rate, '%')}"></td>
</th:block>
</tr>
<!--<tr class="faRptTr" th:each="info, i : ${list}">
</tr>-->
</tbody>