feat:사용대장 임시저장

TaehunPark 2022-10-14 17:21:41 +09:00
parent 4c99d4b06c
commit 7ea38dff89
9 changed files with 555 additions and 1 deletions

View File

@ -5,8 +5,10 @@ import com.dbnt.faisp.authMgt.service.AuthMgtService;
import com.dbnt.faisp.equip.model.CellPhone; import com.dbnt.faisp.equip.model.CellPhone;
import com.dbnt.faisp.equip.model.Equip; import com.dbnt.faisp.equip.model.Equip;
import com.dbnt.faisp.equip.model.EquipLog; import com.dbnt.faisp.equip.model.EquipLog;
import com.dbnt.faisp.equip.model.UseList;
import com.dbnt.faisp.equip.service.EquipService; import com.dbnt.faisp.equip.service.EquipService;
import com.dbnt.faisp.fipTarget.model.PartInfo; import com.dbnt.faisp.fipTarget.model.PartInfo;
import com.dbnt.faisp.fipTarget.service.FipTargetService;
import com.dbnt.faisp.organMgt.service.OrganConfigService; import com.dbnt.faisp.organMgt.service.OrganConfigService;
import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.userInfo.model.UserInfo;
import com.dbnt.faisp.userInfo.service.UserInfoService; import com.dbnt.faisp.userInfo.service.UserInfoService;
@ -40,6 +42,7 @@ public class EquipController {
private final EquipService equipService; private final EquipService equipService;
private final AuthMgtService authMgtService; private final AuthMgtService authMgtService;
private final OrganConfigService organConfigService; private final OrganConfigService organConfigService;
private final FipTargetService fipTargetService;
private final UserInfoService userInfoService; private final UserInfoService userInfoService;
@GetMapping("/equipStatus") @GetMapping("/equipStatus")
@ -288,6 +291,47 @@ public class EquipController {
} }
@GetMapping("/pvreUseList")
public ModelAndView pvreUseList(@AuthenticationPrincipal UserInfo loginUser,UseList useList,HttpServletResponse response) {
ModelAndView mav = new ModelAndView("equip/pvreUseList");
useList.setDownOrganCdList(loginUser.getDownOrganCdList());
useList.setUseType("PVRE");
//메뉴권한 확인
String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth();
mav.addObject("accessAuth", accessAuth);
useList.setQueryInfo();
mav.addObject("useList", equipService.selectUseList(useList));
useList.setContentCnt(equipService.selectUseListCnt(useList));
useList.setPaginationInfo();
mav.addObject("searchParams", useList);
return mav;
}
@GetMapping("/pvreEditModal")
public ModelAndView pvreEditModal(@AuthenticationPrincipal UserInfo loginUser,UseList useList) {
ModelAndView mav = new ModelAndView("equip/pvreEditModal");
useList.setDownOrganCdList(loginUser.getDownOrganCdList());
mav.addObject("organList", equipService.selectOrganList(useList));
mav.addObject("userOrgan", loginUser.getOgCd());
mav.addObject("useType", "PVRE");
//메뉴권한 확인
String accessAuth = authMgtService.selectAccessConfigList(loginUser.getUserSeq(), "/equip/pvreUseList").get(0).getAccessAuth();
mav.addObject("accessAuth", accessAuth);
return mav;
}
@PostMapping("/saveUse")
public void saveUse(@AuthenticationPrincipal UserInfo loginUser,UseList useList){
useList.setWrtOrgan(loginUser.getOgCd());
useList.setWrtPart(loginUser.getOfcCd());
useList.setWrtUserSeq(loginUser.getUserSeq());
useList.setWrtNm(loginUser.getUserId());
useList.setWrtDt(LocalDateTime.now());
equipService.saveUse(useList);
}

View File

@ -3,6 +3,7 @@ package com.dbnt.faisp.equip.mapper;
import com.dbnt.faisp.equip.model.CellPhone; import com.dbnt.faisp.equip.model.CellPhone;
import com.dbnt.faisp.equip.model.Equip; import com.dbnt.faisp.equip.model.Equip;
import com.dbnt.faisp.equip.model.EquipLog; import com.dbnt.faisp.equip.model.EquipLog;
import com.dbnt.faisp.equip.model.UseList;
import com.dbnt.faisp.util.ParamMap; import com.dbnt.faisp.util.ParamMap;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -34,6 +35,16 @@ public interface EquipMapper {
Integer selectCellPhoneListCnt(CellPhone cellPhone); Integer selectCellPhoneListCnt(CellPhone cellPhone);
List<ParamMap> selectOrganList(UseList useList);
UseList selectUseNoCnt(UseList useList);
Integer selectLastUseNo(UseList useList);
List<UseList> selectUseList(UseList useList);
Integer selectUseListCnt(UseList useList);
} }

View File

@ -0,0 +1,110 @@
package com.dbnt.faisp.equip.model;
import com.dbnt.faisp.config.BaseModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
@Getter
@Setter
@Entity
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@IdClass(UseList.UseListId.class)
@Table(name = "use_list")
public class UseList extends BaseModel implements Serializable{
@Id
@Column(name = "mgt_organ")
private String mgtOrgan;
@Id
@Column(name = "use_no")
private String useNo;
@Id
@Column(name = "version_no")
private Integer versionNo;
@Id
@Column(name = "use_type")
private String useType;
@Column(name = "use_dt")
private String useDt;
@Column(name = "detail_type")
private String detailType;
@Column(name = "detail_self")
private String detailSelf;
@Column(name = "people_cnt")
private Integer peopleCnt;
@Column(name = "description")
private String description;
@Column(name = "wrt_organ")
private String wrtOrgan;
@Column(name = "wrt_part")
private String wrtPart;
@Column(name = "wrt_user_grd")
private String wrtUserGrd;
@Column(name = "wrt_user_seq")
private Integer wrtUserSeq;
@Column(name = "wrt_nm")
private String wrtNm;
@Column(name = "wrt_dt")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
private LocalDateTime wrtDt;
@Transient
private String excel;
@Transient
private String year;
@Transient
private String detailTypeName;
@Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
public static class UseListId implements Serializable {
private String mgtOrgan;
private String useNo;
private Integer versionNo;
private String useType;
}
}

View File

@ -0,0 +1,14 @@
package com.dbnt.faisp.equip.repository;
import com.dbnt.faisp.equip.model.UseList;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UseListRepository extends JpaRepository<UseList, UseList.UseListId> {
}

View File

@ -8,10 +8,12 @@ import com.dbnt.faisp.equip.model.Equip.EquipId;
import com.dbnt.faisp.equip.model.EquipFile; import com.dbnt.faisp.equip.model.EquipFile;
import com.dbnt.faisp.equip.model.EquipFile.EquipFileId; import com.dbnt.faisp.equip.model.EquipFile.EquipFileId;
import com.dbnt.faisp.equip.model.EquipLog; import com.dbnt.faisp.equip.model.EquipLog;
import com.dbnt.faisp.equip.model.UseList;
import com.dbnt.faisp.equip.repository.CellPhoneRepository; import com.dbnt.faisp.equip.repository.CellPhoneRepository;
import com.dbnt.faisp.equip.repository.EquipFileRepository; import com.dbnt.faisp.equip.repository.EquipFileRepository;
import com.dbnt.faisp.equip.repository.EquipLogRepository; import com.dbnt.faisp.equip.repository.EquipLogRepository;
import com.dbnt.faisp.equip.repository.EquipRepository; import com.dbnt.faisp.equip.repository.EquipRepository;
import com.dbnt.faisp.equip.repository.UseListRepository;
import com.dbnt.faisp.userInfo.model.UserInfo; import com.dbnt.faisp.userInfo.model.UserInfo;
import com.dbnt.faisp.util.ParamMap; import com.dbnt.faisp.util.ParamMap;
import com.dbnt.faisp.util.Utils; import com.dbnt.faisp.util.Utils;
@ -26,6 +28,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.*; import java.util.*;
@ -39,8 +42,12 @@ public class EquipService {
private final EquipFileRepository equipFileRepository; private final EquipFileRepository equipFileRepository;
private final EquipLogRepository equipLogRepository; private final EquipLogRepository equipLogRepository;
private final CellPhoneRepository cellPhoneRepository; private final CellPhoneRepository cellPhoneRepository;
private final UseListRepository useListRepository;
private final EquipMapper equipMapper; private final EquipMapper equipMapper;
SimpleDateFormat Date = new SimpleDateFormat("yyyy");
String year = Date.format(new Date());
@Transactional @Transactional
public void saveEquip(Equip equip, MultipartHttpServletRequest request) { public void saveEquip(Equip equip, MultipartHttpServletRequest request) {
@ -318,6 +325,33 @@ public class EquipService {
cellPhoneRepository.deleteAll(cellPhone); cellPhoneRepository.deleteAll(cellPhone);
} }
public List<ParamMap> selectOrganList(UseList useList) {
return equipMapper.selectOrganList(useList);
}
@Transactional
public void saveUse(UseList useList) {
useList.setYear(year);
Integer useNo = equipMapper.selectLastUseNo(useList);
if(useNo == null) {
useList.setUseNo(year+"-001");
useList.setVersionNo(1);
} else {
useList.setUseNo(year+"-"+String.format("%03d", useNo+1));
useList.setVersionNo(1);
}
useListRepository.save(useList);
}
public List<UseList> selectUseList(UseList useList) {
return equipMapper.selectUseList(useList);
}
public Integer selectUseListCnt(UseList useList) {
return equipMapper.selectUseListCnt(useList);
}
} }

View File

@ -441,7 +441,96 @@
</foreach> </foreach>
order by cm.wrt_dt desc order by cm.wrt_dt desc
) a ) a
</select>
<select id="selectOrganList" resultType="com.dbnt.faisp.util.ParamMap" parameterType="UseList">
select item_cd,
item_value
from code_mgt cm,
organ_config oc
where cm.item_cd = oc.organ_cd
and oc.organ_type = 'OGC003'
and cm.use_chk = 'T'
and item_cd in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by item_cd asc
</select>
<select id="selectLastUseNo" resultType="Integer" parameterType="UseList">
select a.useNo
from(
select substring(use_no, 6, 3)::int as useNo
from use_list
where mgt_organ = #{mgtOrgan}
and use_no like #{year}||'%'
and use_type = #{useType}
group by use_no
) a
order by useNo desc
limit 1
</select>
<select id="selectUseList" resultType="UseList" parameterType="UseList">
select (select item_value from code_mgt where item_cd = mgt_organ) as mgt_organ,
ul.use_no,
ul.version_no,
use_dt,
(select item_value from code_mgt where item_cd = detail_type) as detail_type_name,
detail_type,
detail_self,
people_cnt,
description,
wrt_dt
from use_list ul,
(select use_no,max(version_no) as lastVer from use_list
where use_type = #{useType}
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
group by use_no) b
where ul.use_no = b.use_no
and ul.version_no = b.lastVer
and use_type = #{useType}
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by ul.use_no desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectUseListCnt" resultType="Integer" parameterType="UseList">
select count(*)
from(
select mgt_organ,
ul.use_no,
ul.version_no,
use_dt,
(select item_value from code_mgt where item_cd = detail_type) as detail_type,
detail_self,
people_cnt,
description,
wrt_dt
from use_list ul,
(select use_no,max(version_no) as lastVer from use_list
where use_type = #{useType}
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
group by use_no) b
where ul.use_no = b.use_no
and ul.version_no = b.lastVer
and use_type = #{useType}
and mgt_organ in
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by ul.use_no desc
) a
</select> </select>

View File

@ -0,0 +1,56 @@
$(document).on('click', '#addPvre', function (){
$.ajax({
url: '/equip/pvreEditModal',
type: 'GET',
dataType:"html",
success: function(html){
$("#pvreEditModalContent").empty().append(html);
$("#pvreEditModal").modal('show');
$("#useDt").datepicker({
format: "mm-dd",
language: "ko"
});
$('#detailSelf').hide();
},
error:function(){
}
});
})
$(document).on('click', '#saveUse', function (){
if(confirm("저장하시겠습니까?")){
document.getElementById("mgtOrgan").disabled = false;
contentFade("in");
const formData = new FormData($("#useFm")[0]);
$.ajax({
type : 'POST',
data : formData,
url : "/equip/saveUse",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
location.reload();
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
})
$(document).on('change', '#detailType', function (){
if($(this).val() == 'USE007'){
$('#detailSelf').show();
}else{
$('#detailSelf').hide();
$('#detailSelf').val('');
}
});

View File

@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<div class="modal-header">
<th:block th:if="${useType eq 'PVRE'}">
<h5 class="modal-title" id="menuEditModalLabel" th:if="${useType eq 'PVRE'}">휴대용 녹화장비 사용대장 등록</h5>
</th:block>
<th:block th:if="${useType eq 'QIR'}">
<h5 class="modal-title" id="menuEditModalLabel" th:if="${useType eq 'PVRE'}">방역조사실 사용대장 등록</h5>
</th:block>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<form id="useFm" method="post">
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<input type="hidden" name="useType" th:value="${useType}">
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">사용관서</label>
<div class="col-sm-3">
<select class="form-select form-select-sm" id="mgtOrgan" name="mgtOrgan" th:disabled="${accessAuth ne 'ACC003'}">
<option value="">선택</option>
<th:block th:each="organList:${organList}">
<option th:value="${organList.item_cd}" th:text="${organList.item_value}" th:selected="${organList.item_cd eq userOrgan}"></option>
</th:block>
</select>
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">사용일시</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="useDt" name="useDt">
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">사용사유</label>
<div class="col-sm-3">
<select class="form-select form-select-sm" id="detailType" name="detailType">
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('USE')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"></option>
</th:block>
</select>
<input type="text" class="form-control" id="detailSelf" name="detailSelf">
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">사용인원</label>
<div class="col-sm-4">
<input type="number" class="form-control" id="peopleCnt" name="peopleCnt">
</div>
</div>
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">비고</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="description" name="description">
</div>
</div>
</form>
</div>
<div class="modal-footer justify-content-between">
<div class="col-auto">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
<button type="button" class="btn btn-primary" id="saveUse">저장</button>
</div>
</div>
</html>

View File

@ -0,0 +1,127 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org"
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/equip/pvre.js}"></script>
</th:block>
<div layout:fragment="content">
<main class="pt-3">
<h4>휴대용 녹화장비 사용대장</h4>
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="row mx-0">
<div class="col-12 card text-center">
<div class="card-body">
<form id="searchFm" method="get" th:action="@{/equip/cellPhoneList}">
<input type="hidden" name="excel">
<input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
<div class="row justify-content-between pe-3 py-1">
<div class="col-auto">
<select class="form-select" name="rowCnt" id="rowCnt">
<th:block th:each="num : ${#numbers.sequence(1,5)}">
<option th:value="${num*10}" th:text="${num*10}" th:selected="${searchParams.rowCnt==num*10}"></option>
</th:block>
</select>
</div>
<div class="col-auto">
<div class="row justify-content-end">
<div class="col-auto">
<input type="text" class="form-control form-control-sm">
</div>
<input type="submit" class="btn btn-sm btn-primary col-auto" id="searchBtn" value="검색">
</div>
</div>
</div>
</form>
<button id="goExcel">엑셀다운</button>
<div class="row justify-content-start">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<table class="table table-striped">
<thead>
<tr>
<th> <input type="checkbox" id="chk-all" class="equInfoCheckBox"></th>
<th>연번</th>
<th>경찰서</th>
<th>사용일시</th>
<th>사용사유</th>
<th>사용인원</th>
<th>비고</th>
<th>최종수정일</th>
</tr>
</thead>
<tbody>
<tr class="cellPhoneTr" th:each="list:${useList}">
<td><input type="checkbox" name="cpChk" class="cellPhoneCheckBox"></td>
<td th:text="${list.useNo}"></td>
<td th:text="${list.mgtOrgan}"></td>
<td th:text="${list.useDt}"></td>
<td th:text="${list.detailTypeName}" th:if="${list.detailType != 'USE007'}"></td>
<td th:text="${list.detailSelf}" th:unless="${list.detailType != 'USE007'}"></td>
<td th:text="${list.peopleCnt}"></td>
<td th:text="${list.description}"></td>
<td th:text="${#temporals.format(list.wrtDt, 'yyyy-MM-dd HH:mm')}"></td>
</tr>
</tbody>
</table>
</div>
<div class="row justify-content-center">
<div class="col-auto">
<nav aria-label="Page navigation">
<ul class="pagination">
<th:block th:if="${searchParams.pageIndex>3}">
<li class="page-item" th:data-pageindex="${(searchParams.pageIndex)-3}">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
</th:block>
<th:block th:each="num : ${#numbers.sequence(searchParams.startNum, searchParams.endNum)}">
<li class="page-item" th:data-pageindex="${num}" th:classappend="${searchParams.pageIndex==num?'active':''}">
<a class="page-link" href="#" th:text="${num}"></a>
</li>
</th:block>
<th:block th:if="${searchParams.maxNum>searchParams.endNum+2}">
<li class="page-item" th:data-pageindex="${(searchParams.pageIndex)+3}">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
</th:block>
</ul>
</nav>
</div>
</div>
<div class="col-auto">
<button type="button" class="btn btn-danger"id="deleteCellPhone" th:if="${accessAuth eq 'ACC003'}">삭제</button>
<button type="button" class="btn btn-success"id="addPvre" th:unless="${accessAuth eq 'ACC001'}">등록</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<div class="modal fade" id="pvreEditModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="userEditModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-scrollable">
<div class="modal-content" id="pvreEditModalContent">
<div class="modal-header">
</div>
<div class="modal-body">
<div class="tab-content border border-top-0" id="configCellPhone">
</div>
</div>
</div>
</div>
</div>
</div>
</html>