fix:외사장비현황 중간저장

TaehunPark 2022-09-26 09:38:58 +09:00
parent 3eb76f75df
commit e18677a5c0
12 changed files with 386 additions and 25 deletions

View File

@ -13,7 +13,11 @@ import com.dbnt.faisp.util.Utils;
import lombok.RequiredArgsConstructor;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
@ -106,6 +110,60 @@ public class EquipController {
return result;
}
@GetMapping("/historyView")
public ModelAndView historyView(Equip equip) {
ModelAndView mav = new ModelAndView("equip/equipHistory");
mav.addObject("equList", equipService.selectHistoryView(equip));
return mav;
}
@GetMapping("/HistoryDetail")
@ResponseBody
public Equip HistoryDetail(Equip equip){
return equipService.selectHistoryDetail(equip);
}
@PostMapping("/epuipDelete")
public void epuipDelete(@RequestBody List<Equip> equip){
equipService.equipDelete(equip);
}
@GetMapping("/getEquipImg")
public void getThumbImage(Equip equip , HttpServletResponse response) throws Exception {
Equip dbImg = equipService.selectEquipInfo(equip);
String realFile = dbImg.getFilePath()+"/"+ dbImg.getConvNm();
String fileNm = dbImg.getConvNm();
BufferedOutputStream out = null;
InputStream in = null;
try {
response.setContentType("image/jpeg;charset=UTF-8");
response.setHeader("Content-Disposition", "inline;filename=" + fileNm);
File file = new File(realFile);
// File file = new File(realFile + "/" + fileNm);
if(file.exists()){
in = new FileInputStream(file);
out = new BufferedOutputStream(response.getOutputStream());
int len;
byte[] buf = new byte[1024];
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
}
} catch (Exception e) {
} finally {
if(out != null){ out.flush(); }
if(out != null){ out.close(); }
if(in != null){ in.close(); }
}
}

View File

@ -23,6 +23,8 @@ public interface EquipMapper {
ParamMap selectEduType(Equip equip);
Equip selectHistoryDetail(Equip equip);
}

View File

@ -8,6 +8,8 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface EquipFileRepository extends JpaRepository<EquipFile, EquipFile.EquipFileId> {
void deleteByEquKey(Integer equKey);

View File

@ -2,6 +2,7 @@ package com.dbnt.faisp.equip.repository;
import com.dbnt.faisp.equip.model.Equip;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
@ -12,6 +13,10 @@ public interface EquipRepository extends JpaRepository<Equip, Equip.EquipId> {
Equip findFirstByOrderByEquKeyDesc();
List<Equip> findByEquKeyOrderByWrtDtDesc(Integer equKey);
void deleteByEquKey(Integer equKey);

View File

@ -10,6 +10,7 @@ import com.dbnt.faisp.equip.repository.EquipFileRepository;
import com.dbnt.faisp.equip.repository.EquipRepository;
import com.dbnt.faisp.translator.model.Translator;
import com.dbnt.faisp.translator.model.Translator.TranslatorId;
import com.dbnt.faisp.userInfo.model.UserInfo;
import com.dbnt.faisp.util.ParamMap;
import com.dbnt.faisp.util.Utils;
@ -216,5 +217,33 @@ public class EquipService {
return equipMapper.selectEduType(equip);
}
public List<Equip> selectHistoryView(Equip equip) {
return equipRepository.findByEquKeyOrderByWrtDtDesc(equip.getEquKey());
}
public Equip selectHistoryDetail(Equip equip) {
return equipMapper.selectHistoryDetail(equip);
}
@Transactional
public void equipDelete(List<Equip> equip) {
for(Equip equ: equip) {
//파일삭제
Equip dbEquip = equipMapper.selectEquipInfo(equ);
if(dbEquip.getOrigNm() != null) {
File file = new File(dbEquip.getFilePath(), dbEquip.getConvNm());
if(file.exists()) {
file.delete();
}
}
equipRepository.deleteByEquKey(equ.getEquKey());
equipFileRepository.deleteByEquKey(equ.getEquKey());
}
}
}

View File

@ -233,7 +233,8 @@
<foreach collection="downOrganCdList" item="item" index="index" separator="," open="(" close=")">
#{item}
</foreach>
order by equ_key asc
order by equ_key desc
limit #{rowCnt} offset #{firstIndex}
</select>
<select id="selectEquipListCnt" resultType="int" parameterType="Equip">
@ -312,5 +313,33 @@
</select>
<select id="selectHistoryDetail" resultType="Equip" parameterType="Equip">
select em.equ_key,
em.version_no,
mgt_organ,
case
when oc.organ_type = 'OGC001' then (select item_value from code_mgt cm where cm.item_cd = oc.organ_cd )
when oc.organ_type = 'OGC002' then (select item_value from code_mgt cm where cm.item_cd = oc.organ_cd )
else CONCAT((select item_value from code_mgt cm where cm.item_cd = oc.parent_organ ),'-',(select item_value from code_mgt cm where cm.item_cd = oc.organ_cd ))
end as sosok,
(select item_value from code_mgt cm where cm.item_cd = equ_type ) as equ_type,
(select item_value from code_mgt cm where cm.item_cd = detail_type ) as detail_type,
stored_year,
item_qty,
(select item_value from code_mgt cm where cm.item_cd = item_condition ) as item_condition,
note,
ef.orig_nm,
ef.conv_nm,
ef.file_path
from equ_mgt em,
equ_file ef,
organ_config oc
where em.equ_key = ef.equ_key
and em.version_no = ef.version_no
and em.mgt_organ = oc.organ_cd
and em.equ_key = #{equKey}
and em.version_no = #{versionNo}
</select>
</mapper>

View File

@ -1,3 +1,5 @@
$(document).ready(function(){
$(".table_id").each(function(){
var rows = $(".table_id:contains('"+$(this).text()+"')");
@ -18,8 +20,13 @@ $(document).on('click', '#addEquip', function (){
type: 'GET',
dataType:"html",
success: function(html){
$("#equipEditModalContent").empty().append(html)
$("#equipEditModal").modal('show')
$("#equipEditModalContent").empty().append(html);
$("#equipEditModal").modal('show');
$(".storedYear").datepicker({
minViewMode: 'years',
format: "yyyy",
language: "ko"
})
},
error:function(){
@ -38,7 +45,6 @@ $(document).on('change', '#equType', function (){
type: 'GET',
dataType:"html",
success: function(html){
console.log(html);
$("#detailType").empty().append(html)
},
error:function(){
@ -48,6 +54,21 @@ $(document).on('change', '#equType', function (){
});
$(document).on('click', '#saveEquip', function (){
if($('#equType').val() == ''){
alert("분류를 선택해주세요.");
$('#equType').focus();
return false;
}
if($('#detailType').val() == ''){
alert("세부분류를 선택해주세요.");
$('#detailType').focus();
return false;
}
if($('#itemQty').val() == ''){
alert("수량을 입력해주세요.");
$('#itemQty').focus();
return false;
}
if(confirm("저장하시겠습니까?")){
let ajaxUrl = "/equip/saveEquip";
const formData = new FormData($("#equipEditForm")[0]);
@ -91,6 +112,11 @@ function showUpdateModal(equKey){
success: function(html){
$("#configEqu").empty().append(html)
$("#equipModifyModal").modal('show');
$(".mStoredYear").datepicker({
minViewMode: 'years',
format: "yyyy",
language: "ko"
})
},
error:function(){
@ -112,6 +138,11 @@ function deleteImg(equKey,versionNo){
}
$(document).on('click', '#updateEquip', function (){
if($('#mItemQty').val() == ''){
alert("수량을 입력해주세요.");
$('#mItemQty').focus();
return false;
}
if(confirm("수정하시겠습니까?")){
let ajaxUrl = "/equip/updateEquip";
const formData = new FormData($("#equipModifyForm")[0]);
@ -135,3 +166,91 @@ $(document).on('click', '#updateEquip', function (){
}
});
$(document).on('click', '#historyBtn', function (){
if($('input:checkbox[name=equChk]:checked').length > 1){
alert("한개만 선택해주세요")
return false;
}
const target = $('input:checkbox[name=equChk]:checked');
const equKey = Number(target.parents('tr').find('.equKey').val());
$.ajax({
url: '/equip/historyView',
data: {equKey: equKey},
type: 'GET',
dataType:"html",
success: function(html){
$("#configEqu").empty().append(html)
$("#equipModifyModal").modal('show');
},
error:function(){
}
});
})
$(document).on('click', '.historyInfoTr', function (){
$(this).find('.hisChk').prop('checked',true)
if($(this).find('.hisChk').prop('checked')){
$('.hisChk').prop('checked',false);
$(this).find('.hisChk').prop('checked',true)
}
$.ajax({
url: '/equip/HistoryDetail',
data: {
equKey : Number($(this).find(".equKey").val()),
versionNo : Number($(this).find(".verNo").val())
},
type: 'GET',
dataType:"json",
success: function(data){
$('#vSosok').val(data.sosok);
$('#vEquType').val(data.equType);
$('#vDetailType').val(data.detailType);
$('#vStoredYear').val(data.storedYear);
$('#vItemQty').val(data.itemQty);
$('#vItemCondition').val(data.itemCondition);
$('#vNote').val(data.note);
$('#vImgName').val(data.origNm);
},
error:function(){
}
});
})
$(document).on('click', '#equDeleteBtn', function (){
if(confirm("선택한 대상을 삭제처리 하시겠습니까?")){
const checkArr = [];
$('input:checkbox[name=equChk]:checked').each(function (idx, el){
checkArr.push({});
const target = $(el);
checkArr[idx].equKey = Number(target.parents('tr').find('.equKey').val());
})
$.ajax({
type : 'POST',
url : "/equip/epuipDelete",
data : JSON.stringify(checkArr),
contentType: 'application/json',
beforeSend: function (xhr){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
},
success : function() {
alert("삭제처리 되었습니다.");
location.reload();
},
error : function(xhr, status) {
alert("삭제처리에 실패하였습니다");
}
})
}
})
$(document).ready( function() {
$('#chk-all').click( function() {
$('.equInfoCheckBox').prop('checked',this.checked);
});
});

View File

@ -9,6 +9,12 @@
<form id="equipEditForm" th:action="@{/equip/saveEquip}" method="post" enctype="multipart/form-data">
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="row mb-3">
<label for="cat1Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">관리처</label>
<div class="col-sm-6">
<input type="text" class="form-control" value="사용자 소속처 자동입력" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat1Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">분류</label>
<div class="col-sm-6">
@ -31,13 +37,13 @@
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">취득연도</label>
<div class="col-sm-6">
<input type="text" name="storedYear">
<input type="text" class="form-control storedYear" name="storedYear">
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">보유량</label>
<div class="col-sm-6">
<input type="number" name="itemQty" placeholder="수량 직접입력">
<input type="number" class="form-control" id="itemQty" name="itemQty" placeholder="수량 직접입력">
</div>
</div>
<div class="row mb-3">
@ -54,13 +60,13 @@
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">비고</label>
<div class="col-sm-6">
<input type="text" name="note">
<input type="text" class="form-control" name="note">
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">장비사진</label>
<div class="col-sm-6">
<input type="file" name="file">
<input type="file" class="form-control" name="file" accept="image/gif,image/jpeg,image/png">
</div>
</div>
</form>

View File

@ -0,0 +1,103 @@
<!DOCTYPE html>
<html lang="ko" xmlns:th="http://www.thymeleaf.org">
<main class="pt-3">
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<div class="modal-header">
<h5 class="modal-title">수정이력</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="row mx-0">
<div class="col-100 card text-center">
<div class="card-body">
<div class="row">
</div>
<div class="row justify-content-start">
<div class="col-4">
<div class="card">
<div class="card-body">
<div class="row">
<table class="table table-striped" id="categoryTable">
<thead>
<tr>
<th></th>
<th>작성자</th>
<th>등록일</th>
</tr>
</thead>
<tbody class="overflow-scroll">
<tr class="historyInfoTr" th:each="equInfo:${equList}">
<td><input type="checkbox" class="hisChk">
<input type="hidden" class="equKey" th:value="${equInfo.equKey}">
<input type="hidden" class="verNo" th:value="${equInfo.versionNo}" >
</td>
<td th:text="${equInfo.wrtNm}"></td>
<td th:text="${#temporals.format(equInfo.wrtDt, 'yyyy-MM-dd')}"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-8" id="valueDiv">
<div class="row mb-3">
<label for="cat1Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">관리처</label>
<div class="col-sm-6">
<input type="text" id="vSosok" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat1Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">분류</label>
<div class="col-sm-6">
<input type="text" id="vEquType" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat2Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">세부분류</label>
<div class="col-sm-6">
<input type="text" id="vDetailType" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">취득연도</label>
<div class="col-sm-6">
<input type="text" id="vStoredYear" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">보유량</label>
<div class="col-sm-6">
<input type="text" id="vItemQty" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat2Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">상태</label>
<div class="col-sm-6">
<input type="text" id="vItemCondition" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">비고</label>
<div class="col-sm-6">
<input type="text" id="vNote" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">장비사진</label>
<div class="col-sm-6">
<input type="text" id="vImgName" readonly>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer justify-content-between">
<div class="col-auto">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
</div>
</div>
</div>
</div>
</main>
</html>

View File

@ -14,9 +14,9 @@
<div class="row mx-0">
<div class="col-12 card text-center">
<div class="card-body">
<form method="get" th:action="@{/userMgt/userMgtPage}">
<input type="hidden" name="userStatus" id="userStatus" >
<input type="hidden" name="pageIndex" id="pageIndex" >
<form method="get" th:action="@{/equip/List}">
<input type="hidden" name="pageIndex" id="pageIndex" th:value="${searchParams.pageIndex}">
<input type="hidden" name="detailType" th:value="${searchParams.detailType}">
<div class="row justify-content-between pe-3 py-1">
<div class="col-auto">
<select class="form-select" name="rowCnt" id="rowCnt">
@ -62,7 +62,7 @@
<table class="table table-striped">
<thead>
<tr>
<th> <input type="checkbox" id="chk-all" class="userInfoCheckBox"></th>
<th> <input type="checkbox" id="chk-all" class="equInfoCheckBox"></th>
<th>소속</th>
<th>세부소속</th>
<th>장비사진</th>
@ -75,13 +75,15 @@
<tbody>
<tr th:each="equ:${equipList}">
<td>
<input type="checkbox" name="equChk">
<input type="checkbox" name="equChk" class="equInfoCheckBox">
<input type="hidden" class="equKey" th:value="${equ.equKey}">
<input type="hidden" class="verNo" th:value="${equ.versionNo}">
</td>
<td th:text="${equ.sosok}"></td>
<td th:text="${equ.detailSosok}"></td>
<td th:text="${equ.origNm}"></td>
<td>
<img id="imgId" th:src="|@{/equip/getEquipImg(equKey=${equ.equKey},versionNo=${equ.versionNo})}|" alt="첨부이미지" style="width: 100px; height: 50px;" onclick="window.open(this.src)" th:if="${equ.origNm != null}" />
</td>
<td th:text="${equ.storedYear}"></td>
<td th:text="${equ.itemQty}"></td>
<td th:text="${equ.itemCondition}"></td>
@ -92,9 +94,9 @@
</table>
</div>
<div class="col-auto">
<input type="button" class="btn btn-success" value="삭제" id="">
<input type="button" class="btn btn-success" value="삭제" id="equDeleteBtn">
<input type="button" class="btn btn-success" value="수정" id="equUpdateBtn">
<input type="button" class="btn btn-success" value="수정이력" id="">
<input type="button" class="btn btn-success" value="수정이력" id="historyBtn">
</div>
<div class="row justify-content-center">
<div class="col-auto">

View File

@ -11,6 +11,12 @@
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<input type="hidden" name="equKey" th:value="${equInfo.equKey}">
<input type="hidden" name="versionNo" th:value="${equInfo.versionNo}">
<div class="row mb-3">
<label for="cat1Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">관리처</label>
<div class="col-sm-6">
<input type="text" class="form-control" value="사용자 소속처 자동입력" readonly>
</div>
</div>
<div class="row mb-3">
<label for="cat1Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">분류</label>
<div class="col-sm-6">
@ -36,13 +42,13 @@
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">취득연도</label>
<div class="col-sm-6">
<input type="text" name="storedYear" th:value="${equInfo.storedYear}">
<input type="text" class="form-control mStoredYear" name="storedYear" th:value="${equInfo.storedYear}">
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">보유량</label>
<div class="col-sm-6">
<input type="number" name="itemQty" th:value="${equInfo.itemQty}" placeholder="수량 직접입력">
<input type="number" class="form-control" id="mItemQty" name="itemQty" th:value="${equInfo.itemQty}" placeholder="수량 직접입력">
</div>
</div>
<div class="row mb-3">
@ -59,20 +65,20 @@
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">비고</label>
<div class="col-sm-6">
<input type="text" name="note" th:value="${equInfo.note}">
<input type="text" class="form-control" name="note" th:value="${equInfo.note}">
</div>
</div>
<div class="row mb-3">
<label for="cat3Cd" class="col-sm-4 col-form-label col-form-label-sm text-center">장비사진</label>
<div class="col-sm-6">
<div id="imgUpload">
<input type="text" th:value="${equInfo.origNm}" readonly th:if="${not #strings.isEmpty(equInfo.origNm)}">
<input type="text" class="form-control" th:value="${equInfo.origNm}" readonly th:if="${not #strings.isEmpty(equInfo.origNm)}">
<input type="button" id="deleteImgBtn" value="삭제" th:if="${not #strings.isEmpty(equInfo.origNm)}" th:attr="onclick=|deleteImg('${equInfo.equKey}','${equInfo.versionNo}')|">
<input type="text" value="등록된 사진이 없습니다." readonly th:if="${#strings.isEmpty(equInfo.origNm)}">
<input type="text" class="form-control" value="등록된 사진이 없습니다." readonly th:if="${#strings.isEmpty(equInfo.origNm)}">
<input type="button" id="addImgBtn" value="추가" th:if="${#strings.isEmpty(equInfo.origNm)}">
</div>
<div id="imgUpdate" style="display:none">
<input type="file" name="file">
<input type="file" class="form-control" name="file" accept="image/gif,image/jpeg,image/png">
</div>
</div>
</div>

View File

@ -105,7 +105,7 @@
<tr class="" th:each="equip,index:${equipList}">
<td th:text="${index.index+1}"></td>
<td class="table_id" th:text="${equip.equ_type}"></td>
<td th:text="${equip.item_value}" th:onclick="|location.href='@{/equip/List(detailType=${equip.item_cd})}'|"></td>
<td th:text="${equip.item_value}" style="color: blue; cursor:pointer;" th:onclick="|location.href='@{/equip/List(detailType=${equip.item_cd})}'|"></td>
<td th:text="${equip.total}"></td>
<td th:text="${equip.cnt_bon}"></td>
<td th:text="${equip.cnt_center}"></td>