강석 최 2022-09-19 18:20:52 +09:00
commit debc9b46c1
7 changed files with 207 additions and 109 deletions

View File

@ -31,8 +31,8 @@ public class TranslatorController {
private final AuthMgtService authMgtService;
private final TranslatorService translatorSevice;
private final OrganConfigService organConfigService;
@GetMapping("/info")
public ModelAndView translatorInfo(@AuthenticationPrincipal UserInfo loginUser,Translator translator,HttpServletResponse response) {
ModelAndView mav = new ModelAndView("translator/translator");
@ -42,23 +42,23 @@ public class TranslatorController {
translator.setOrganCdList(organConfigService.selectOrganListWhereUserOgCd(loginUser.getOgCd()));
//엑셀다운
if(translator.getExcel() != null && translator.getExcel().equals("Y")){
String[] headers = { "translator_key", "ogdp1", "tr_lang", "tr_career", "tr_name", "tr_age", "tr_nny", "tr_edu", "tr_cft", "dml_yn", "apt_dt", "tr_phone"};
String[] headerNames = { "연번", "관서명", "언어", "경력", "성명", "나이", "국적", "학력", "자격증", "해촉", "위촉일", "연락처" };
String[] columnType = { "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String"};
String sheetName = "민간 통역인 현황";
String excelFileName = "민간 통역인 현황";
List<ParamMap> translatorInfoList= translatorSevice.selectTranslatorListEx(translator);
String[] headers = { "translator_key", "ogdp1", "tr_lang", "tr_career", "tr_name", "tr_age", "tr_nny", "tr_edu", "tr_cft", "dml_yn", "apt_dt", "tr_phone"};
String[] headerNames = { "연번", "관서명", "언어", "경력", "성명", "나이", "국적", "학력", "자격증", "해촉", "위촉일", "연락처" };
String[] columnType = { "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String", "String"};
String sheetName = "민간 통역인 현황";
String excelFileName = "민간 통역인 현황";
List<ParamMap> translatorInfoList= translatorSevice.selectTranslatorListEx(translator);
try {
Utils.listToExcel(translatorInfoList, response, headers, headerNames, columnType, sheetName, excelFileName);
} catch (IOException e) {
}
return null;
try {
Utils.listToExcel(translatorInfoList, response, headers, headerNames, columnType, sheetName, excelFileName);
} catch (IOException e) {
}
return null;
}
//메뉴권한 확인
String accessAuth = authMgtService.selectAccessConfigList(params).get(0).getAccessAuth();
mav.addObject("mgtOrganList", loginUser.getOrganCdList());
mav.addObject("accessAuth", accessAuth);
translator.setQueryInfo();
@ -68,14 +68,14 @@ public class TranslatorController {
mav.addObject("searchParams", translator);
return mav;
}
@PostMapping("/insertTranslatorInfo")
public String insertTranslatorInfo(@AuthenticationPrincipal UserInfo loginUser,Translator translator) {
translator.setWrtNm(loginUser.getUserId());
translator.setWrtOrgan(loginUser.getOgCd());
translator.setWrtNm(loginUser.getUserId());
translator.setWrtOrgan(loginUser.getOgCd());
return translatorSevice.insertTranslatorInfo(translator);
}
@GetMapping("/translatorEditModal")
public ModelAndView translatorEditModal(@AuthenticationPrincipal UserInfo loginUser,Translator translator){
ModelAndView mav = new ModelAndView("translator/translatorEditModal");
@ -88,28 +88,28 @@ public class TranslatorController {
mav.addObject("accessAuth", accessAuth);
return mav;
}
@PostMapping("/updateTranslatorInfo")
public void updatetranslatorInfo(@AuthenticationPrincipal UserInfo loginUser,Translator translator) {
translator.setWrtNm(loginUser.getUserId());
translator.setWrtOrgan(loginUser.getOgCd());
translatorSevice.updatetranslatorInfo(translator);
translator.setWrtNm(loginUser.getUserId());
translator.setWrtOrgan(loginUser.getOgCd());
translatorSevice.updatetranslatorInfo(translator);
}
@GetMapping("/revisionHistory")
public ModelAndView revisionHistory(Translator translator){
ModelAndView mav = new ModelAndView("translator/translatorHistory");
mav.addObject("HistoryList", translatorSevice.selectHistoryList(translator));
return mav;
}
@GetMapping("/HistoryView")
@ResponseBody
public Translator HistoryView(Translator translator){
return translatorSevice.HistoryView(translator);
}
@GetMapping("/careerView")
public ModelAndView careerView(@AuthenticationPrincipal UserInfo loginUser,TranslatorCrr translatorCrr){
ModelAndView mav = new ModelAndView("translator/translatorCareerModal");
@ -124,34 +124,34 @@ public class TranslatorController {
mav.addObject("accessAuth", accessAuth);
return mav;
}
@GetMapping("/careerInsertPage")
public ModelAndView careerInsertPage(TranslatorCrr translatorCrr){
ModelAndView mav = new ModelAndView("translator/translatorCareerInsert");
mav.addObject("trKey", translatorCrr.getTranslatorKey());
return mav;
}
@PostMapping("/insertTranslatorCareer")
@ResponseBody
public int insertTranslatorCareer(@RequestBody List<TranslatorCrr> translatorCrr){
int trKey = translatorSevice.insertTranslatorCareer(translatorCrr);
int trKey = translatorSevice.insertTranslatorCareer(translatorCrr);
return trKey;
}
@PostMapping("/deleteCareer")
@ResponseBody
public int deleteCareer(@RequestBody TranslatorCrr translatorCrr) {
int trKey = translatorSevice.deleteCareer(translatorCrr);
int trKey = translatorSevice.deleteCareer(translatorCrr);
return trKey;
}
@PostMapping("/deleteTranslatorInfo")
@ResponseBody
public void deleteTranslatorInfo(@RequestBody int trKey) {
translatorSevice.deleteTranslatorInfo(trKey);
translatorSevice.deleteTranslatorInfo(trKey);
}
@GetMapping("/statisticsLang")
public ModelAndView statisticsLang() {
ModelAndView mav = new ModelAndView("translator/translatorStatisticsLang");
@ -159,8 +159,26 @@ public class TranslatorController {
mav.addObject("total", translatorSevice.selectStatisticsLangTotal());
return mav;
}
@GetMapping("/statisticsExcelDown")
public void statisticsExcelDown(HttpServletResponse response) {
ParamMap total =translatorSevice.selectStatisticsLangTotal();
String[] headers = { "rownum", "lang", "cnt_total", "cnt_center", "cnt_west", "cnt_south", "cnt_east", "cnt_jeju"};
String[] headerNames = { "어권별 구분", "", "총계", "중부청", "서해청", "남해청", "동해청", "제주청"};
String[] headerNames2 = { "연번", "계", ""+total.getInt("total_total")+"", ""+total.getInt("total_center")+"", ""+total.getInt("total_west")+"", ""+total.getInt("total_south")+"", ""+total.getInt("total_east")+"", ""+total.getInt("total_jeju")+""};
String[] columnType = { "int", "String", "int", "int", "int", "int", "int", "int"};
String sheetName = "어권별 현황 통계";
String excelFileName = "어권별 현황 통계";
List<ParamMap> translatorInfoList= translatorSevice.selectStatisticsLangCnt();
try {
Utils.downExcel(translatorInfoList, response, headers, headerNames,headerNames2, columnType, sheetName, excelFileName);
} catch (IOException e) {
}
}
}

View File

@ -37,6 +37,7 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFDataFormat;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@ -186,6 +187,92 @@ public class Utils {
}
public static void downExcel(List<ParamMap> list, HttpServletResponse response, String[] headers, String[] headerNames,String[] headerNames2, String[] columnType, String sheetName, String excelFileName) throws IOException {
if(Utils.isNotEmpty(list)) {
// 메모리에 100개의 행을 유지합니다. 행의 수가 넘으면 디스크에 적습니다.
XSSFWorkbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(sheetName);
Row headerRow = sheet.createRow(0);
Row headerRow2 = sheet.createRow(1);
CellStyle cellStyle1 = wb.createCellStyle(); //쉼표들어간 숫자 양식
CellStyle cellStyle2 = wb.createCellStyle(); //숫자양식
CellStyle headerStyle = wb.createCellStyle(); //숫자양식
CellStyle headerStyle2 = wb.createCellStyle();
XSSFDataFormat format = wb.createDataFormat();
cellStyle1.setDataFormat(format.getFormat("#,##0"));
cellStyle2.setDataFormat(format.getFormat("#,##0"));
cellStyle2.setAlignment(HorizontalAlignment.CENTER);
headerStyle2.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setAlignment(HorizontalAlignment.CENTER);
headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
headerStyle.setFillForegroundColor((short)3);
headerStyle.setFillForegroundColor(IndexedColors.LIME.getIndex());
//로우그리기
for(int i=0; i<list.size(); i++) {
ParamMap rowData = list.get(i);
Row row = sheet.createRow(i+2);
for(int j=0; j<headers.length; j++) {
Cell cell = row.createCell(j);
if(columnType[j].equalsIgnoreCase("Int")) {
cell.setCellValue(rowData.getInt(headers[j]));
cell.setCellStyle(cellStyle2);
} else if(columnType[j].equalsIgnoreCase("String")) {
cell.setCellValue(rowData.getString(headers[j]));
} else {
cell.setCellValue(rowData.getString(headers[j]));
}
}
}
//헤더
for(int j=0; j<headerNames.length; j++) {
Cell cell = headerRow.createCell(j);
cell.setCellValue(headerNames[j]);
cell.setCellStyle(headerStyle);
sheet.autoSizeColumn(j);
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1000);
}
sheet.addMergedRegion(new CellRangeAddress(0,0,0,1));
for(int j=0; j<headerNames2.length; j++) {
Cell cell = headerRow2.createCell(j);
cell.setCellValue(headerNames2[j]);
cell.setCellStyle(headerStyle2);
sheet.autoSizeColumn(j);
sheet.setColumnWidth(j, (sheet.getColumnWidth(j)) + 1000);
}
//엑셀이름 한글깨짐방지
String outputFileName = new String(excelFileName.getBytes("KSC5601"), "8859_1");
response.setHeader("Set-Cookie", "fileDownload=true; path=/");
response.setHeader("Content-Disposition", String.format("attachment; filename=\""+outputFileName+"_"+Utils.getTimeStampString("yyyyMMdd_HHmm")+".xlsx\""));
wb.write(response.getOutputStream());
wb.close();
} else {
response.setHeader("Content-Type", "text/html; charset=UTF-8");
PrintWriter out = response.getWriter();
out.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
out.write("<html lang=\"ko\">");
out.write("<head>");
out.write("<script type=\"text/javascript\">");
out.write("alert('데이터가 없습니다.');");
out.write("history.back(-1);");
out.write("</script>");
out.write("</head>");
out.write("</html>");
out.flush();
out.close();
}
}

View File

@ -170,7 +170,8 @@
</select>
<select id="selectStatisticsLangCnt" resultType="com.dbnt.faisp.util.ParamMap">
select cm.item_value as lang ,
select (ROW_NUMBER() OVER()) AS rownum,
cm.item_value as lang ,
sum(center+west+south+east+jeju) as cnt_total,
sum(center) as cnt_center,
sum(west) as cnt_west,

View File

@ -39,6 +39,24 @@ $(document).on('click', '#trView', function (){
})
$(document).on('click', '#updateBtn', function (){
if($('#eOgdp1').val() == ''){
alert("관서를 선택해주세요.");
$('#eOgdp1').focus();
return false;
}
if($('#trLang').val() == ''){
alert("언어를 선택해주세요.");
$('#trLang').focus();
return false;
}
if($('#trEname').val() == ''){
alert("성명을 입력해주세요.");
$('#trEname').focus();
return false;
}
if(confirm("수정하시겠습니까?")){
contentFade("in");
const formData = new FormData($("#trInfoUpdate")[0]);
@ -62,6 +80,30 @@ $(document).on('click', '#updateBtn', function (){
})
$(document).on('click', '#saveBtn', function (){
if($('#ogdp1').val() == ''){
alert("관서를 선택해주세요.");
$('#ogdp1').focus();
return false;
}
if($('#lang').val() == ''){
alert("언어를 선택해주세요.");
$('#lang').focus();
return false;
}
if($('#trName').val() == ''){
alert("성명을 입력해주세요.");
$('#trName').focus();
return false;
}
if($('#dmlYn').val() == ''){
alert("해촉여부를 선택해주세요.");
$('#dmlYn').focus();
return false;
}
if(confirm("저장하시겠습니까?")){
contentFade("in");
const formData = new FormData($("#translatorInsert")[0]);
@ -84,63 +126,6 @@ $(document).on('click', '#saveBtn', function (){
}
})
function valueCheck(form){
const targetForm = $("#"+form);
const userId = targetForm.find("#userId").val();
const password = targetForm.find("#modalPassword");
const passwordConfirm = targetForm.find("#passwordConfirm");
const userNm = targetForm.find("#userNm").val();
const ogCd = targetForm.find("#ogCd").val();
const ofcCd = targetForm.find("#ofcCd").val();
let returnFlag = true;
if(!userId){
alert("아이디를 입력해주세요.");
returnFlag = false;
}else{
const idReg = /^[a-z]+[a-z0-9]{5,19}$/g;
if(!idReg.test(userId)){
returnFlag = false;
alert("아이디 조건이 맞지 않습니다.")
}
}
if(!password[0].disabled && !password.val()){
alert("비밀번호를 입력해주세요.");
returnFlag = false;
}
if(!password[0].disabled && !passwordConfirm.val()){
alert("비밀번호 확인을 입력해주세요.");
returnFlag = false;
}
if(!userNm){
alert("이름 입력해주세요.");
returnFlag = false;
}
if(returnFlag){
const passwordReg = /^(?=.*[a-zA-z])(?=.*[0-9])(?=.*[$`~!@$!%*#^?&\\(\\)\-_=+]).{8,16}$/;
if(!password[0].disabled){
if(!passwordReg.test(password.val())){
alert("비밀번호 조건이 맞지 않습니다.")
returnFlag = false;
}else{
if(password.val() !== passwordConfirm.val()){
alert("비밀번호가 같지 않습니다.");
returnFlag = false;
}
}
}
}
if(!ogCd){
alert("관서를 선택해주세요.");
returnFlag = false;
}
if(!ofcCd){
alert("부서를 선택해주세요.");
returnFlag = false;
}
return returnFlag;
}
$(document).on('click', '.historyInfoTr', function (){
$(this).find('.hisChk').prop('checked',true)
if($(this).find('.hisChk').prop('checked')){
@ -389,6 +374,11 @@ function deleteCareerBtn(crrSeq,trKey){
$(document).on('click', '.btn-close', function (){
trCarrerList.length = 0;
location.reload();
})
$(document).on('click', '#closeModalBtn', function (){
location.reload();
})
$(document).on('click', '#trDeleteBtn', function (){
@ -426,6 +416,14 @@ $(document).on('click', '#goExcel', function (){
}
})
$(document).on('click', '#excelDown', function (){
if(confirm("엑셀로 다운로드 하시겠습니까?")){
location.href='/translator/statisticsExcelDown';
}else{
false;
}
})

View File

@ -198,7 +198,7 @@
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">관서</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="ogdp1">
<select class="form-select form-select-sm" id="ogdp1" name="ogdp1">
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<th:block th:if="${#lists.contains(mgtOrganList, commonCode.itemCd)}">
@ -209,7 +209,7 @@
</div>
<label for="ofcCd" class="col-sm-1 col-form-label text-center">언어</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="trLang">
<select class="form-select form-select-sm" id="lang" name="trLang">
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('LGG')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}"></option>
@ -286,7 +286,7 @@
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">해촉</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="dmlYn">
<select class="form-select form-select-sm" id="dmlYn" name="dmlYn">
<option value="">선택</option>
<option value="O">O</option>
<option value="X">X</option>
@ -299,13 +299,7 @@
<textarea class="form-control" id="remark" name="remark"></textarea>
</div>
</div>
</form>
<h4>경력사항</h4>
<div id="crr">
<div class="row justify-content-center">
<button type="button" class="btn btn-sm btn-outline-primary col-auto" id="crrAddBtn"><i class="bi bi-plus-lg"></i></button>
</div>
</div>
</form>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="closeModalBtn">닫기</button>
<button type="button" class="btn btn-primary" id="saveBtn">등록</button>

View File

@ -11,7 +11,7 @@
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">관서</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="ogdp1">
<select class="form-select form-select-sm" id="eOgdp1" name="ogdp1">
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('OG')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd} == ${trInfo.ogdp1}"></option>
@ -20,7 +20,7 @@
</div>
<label for="ofcCd" class="col-sm-1 col-form-label text-center">언어</label>
<div class="col-sm-2">
<select class="form-select form-select-sm" name="trLang">
<select class="form-select form-select-sm" id="trLang" name="trLang">
<option value="">선택</option>
<th:block th:each="commonCode:${session.commonCode.get('LGG')}">
<option th:value="${commonCode.itemCd}" th:text="${commonCode.itemValue}" th:selected="${commonCode.itemCd} == ${trInfo.trLang}"></option>
@ -35,7 +35,7 @@
<div class="mb-3 row">
<label for="ogCd" class="col-sm-2 col-form-label text-center">성명</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="trName" name="trName" th:value="${trInfo.trName}">
<input type="text" class="form-control" id="trEname" name="trName" th:value="${trInfo.trName}">
</div>
<label for="ofcCd" class="col-sm-1 col-form-label text-center">성별</label>
<div class="col-sm-2">

View File

@ -42,7 +42,7 @@
</thead>
<tbody>
<tr class="" th:each="cnt,index:${cntList}">
<td th:text="${index.index}"></td>
<td th:text="${index.index+1}"></td>
<td th:text="${cnt.lang}"></td>
<td th:text="${cnt.cnt_total}"></td>
<td th:text="${cnt.cnt_center}"></td>
@ -57,7 +57,7 @@
<div class="row justify-content-center">
<div class="col-auto">
<div class="col-auto">
<button>엑셀다운</button>
<button id="excelDown">엑셀다운</button>
</div>
</div>
</div>