فهرست منبع

생활치료센터 엑셀다운로드 추가
환자용 로그인시 생치 선택 화면 변경

junekeunsong 4 سال پیش
والد
کامیت
aa55300f77

+ 210 - 0
src/main/java/com/lemon/lifecenter/controller/CenterController.java

@@ -1,11 +1,25 @@
 package com.lemon.lifecenter.controller;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.List;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+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.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,17 +28,20 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.servlet.ModelAndView;
 
 import com.lemon.lifecenter.common.LifeCenterConfigVO;
 import com.lemon.lifecenter.common.LifeCenterController;
+import com.lemon.lifecenter.common.LifeCenterFileDownload;
 import com.lemon.lifecenter.common.LifeCenterFunction;
 import com.lemon.lifecenter.common.LifeCenterPaging;
 import com.lemon.lifecenter.common.LifeCenterSessionController;
 import com.lemon.lifecenter.dto.CenterInfoDTO;
 import com.lemon.lifecenter.dto.LocationDTO;
 import com.lemon.lifecenter.dto.LoginDTO;
+import com.lemon.lifecenter.dto.PatientDTO;
 import com.lemon.lifecenter.dto.StaffDTO;
 import com.lemon.lifecenter.service.CenterService;
 import com.lemon.lifecenter.service.LoginService;
@@ -234,4 +251,197 @@ public class CenterController extends LifeCenterController {
         
         return mv;
     }
+    
+    @RequestMapping( value="/excel", method=RequestMethod.POST )
+    public void getCenterList(HttpServletRequest request,HttpServletResponse response) {
+        CenterInfoDTO dto = new CenterInfoDTO();
+        int total = centerService.selectCenterCount(dto);
+        List<CenterInfoDTO> result = new ArrayList<CenterInfoDTO>();
+        if (total > 0) {
+            dto.setLimit(0);
+            dto.setLimitMax(total);
+            result = centerService.selectCenterList(dto);
+            
+            for( CenterInfoDTO temp : result ) {
+                result.get( result.indexOf( temp ) ).setStaffPhoneNumber( LifeCenterFunction.phone( temp.getStaffPhoneNumber() ) );
+            }
+        }
+        
+        getCenterListExcel(request, response, result);
+    }
+    
+    private void getCenterListExcel(HttpServletRequest request, HttpServletResponse response, List<CenterInfoDTO> data ) {
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet1 = workbook.createSheet("firstSheet");
+        DecimalFormat df = new DecimalFormat("#,###");
+        
+        //1.셀 스타일 및 폰트 설정
+        CellStyle styleOfBoardFillFontBlackBold16 = workbook.createCellStyle();
+        //정렬
+        styleOfBoardFillFontBlackBold16.setAlignment(CellStyle.ALIGN_CENTER); //가운데 정렬
+        styleOfBoardFillFontBlackBold16.setVerticalAlignment(CellStyle.VERTICAL_CENTER); //높이 가운데 정렬
+        //배경색
+        styleOfBoardFillFontBlackBold16.setFillForegroundColor(IndexedColors.LIGHT_YELLOW.getIndex());
+        styleOfBoardFillFontBlackBold16.setFillPattern(CellStyle.SOLID_FOREGROUND);
+        //테두리 선 (우,좌,위,아래)
+        styleOfBoardFillFontBlackBold16.setBorderRight(HSSFCellStyle.BORDER_THIN);
+        styleOfBoardFillFontBlackBold16.setBorderLeft(HSSFCellStyle.BORDER_THIN);
+        styleOfBoardFillFontBlackBold16.setBorderTop(HSSFCellStyle.BORDER_THIN);
+        styleOfBoardFillFontBlackBold16.setBorderBottom(HSSFCellStyle.BORDER_THIN);
+        //폰트 설정
+        Font fontOfGothicBlackBold16 = workbook.createFont();
+//        fontOfGothicBlackBold16.setFontName("나눔고딕"); //글씨체
+        fontOfGothicBlackBold16.setFontHeight((short)(10*20)); //사이즈
+        fontOfGothicBlackBold16.setBoldweight(Font.BOLDWEIGHT_BOLD); //볼드 (굵게)
+        styleOfBoardFillFontBlackBold16.setFont(fontOfGothicBlackBold16);
+        
+        int i = 1;
+        Row row = sheet1.createRow(0);
+        Cell cell1 = row.createCell(0);
+        Cell cell2 = row.createCell(1);
+        Cell cell3 = row.createCell(2);
+        Cell cell4 = row.createCell(3);
+        Cell cell5 = row.createCell(4);
+        Cell cell6 = row.createCell(5);
+        Cell cell7 = row.createCell(6);
+        Cell cell8 = row.createCell(7);
+        Cell cell9 = row.createCell(8);
+        Cell cell10 = row.createCell(9);
+        Cell cell11 = row.createCell(10);
+        Cell cell12 = row.createCell(11);
+        Cell cell13 = row.createCell(12);
+        Cell cell14 = row.createCell(13);
+        
+        cell1.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell2.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell3.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell4.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell5.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell6.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell7.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell8.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell9.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell10.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell11.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell12.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell13.setCellStyle(styleOfBoardFillFontBlackBold16);
+        cell14.setCellStyle(styleOfBoardFillFontBlackBold16);
+        
+        sheet1.setColumnWidth( 0, 10000); //생활치료센터명
+        sheet1.setColumnWidth( 1, 5000); //지역
+        sheet1.setColumnWidth( 2, 5000); //소관
+        sheet1.setColumnWidth( 3, 8000); //협력병원
+        sheet1.setColumnWidth( 4, 6000); //담당자 이름
+        sheet1.setColumnWidth( 5, 4000); //담당자 아이디
+        sheet1.setColumnWidth( 6, 4000); //담당자 전화번호
+        sheet1.setColumnWidth( 7, 4000); //전화번호
+        sheet1.setColumnWidth( 8, 2500); //의료진수
+        sheet1.setColumnWidth( 9, 2500); //환자 총 수용인원
+        sheet1.setColumnWidth( 10, 2500); //입소자수
+        sheet1.setColumnWidth( 11, 2500); //퇴소자수
+        sheet1.setColumnWidth( 12, 2500); //지정병원이송
+        sheet1.setColumnWidth( 13, 2500); //기타
+        
+        cell1.setCellValue("생활치료센터명");
+        cell2.setCellValue("지역");
+        cell3.setCellValue("소관");
+        cell4.setCellValue("협력병원");
+        cell5.setCellValue("담당자 이름");
+        cell6.setCellValue("담당자 아이디");
+        cell7.setCellValue("담당자 전화번호");
+        cell8.setCellValue("전화번호");
+        cell9.setCellValue("의료진수");
+        cell10.setCellValue("환자 총 수용인원");
+        cell11.setCellValue("입소자수");
+        cell12.setCellValue("퇴소자수");
+        cell13.setCellValue("지정병원이송");
+        cell14.setCellValue("기타");
+        
+        for (CenterInfoDTO dto : data) {
+            row = sheet1.createRow(i);
+            cell1 = row.createCell(0);
+            cell2 = row.createCell(1);
+            cell3 = row.createCell(2);
+            cell4 = row.createCell(3);
+            cell5 = row.createCell(4);
+            cell6 = row.createCell(5);
+            cell7 = row.createCell(6);
+            cell8 = row.createCell(7);
+            cell9 = row.createCell(8);
+            cell10 = row.createCell(9);
+            cell11 = row.createCell(10);
+            cell12 = row.createCell(11);
+            cell13 = row.createCell(12);
+            cell14 = row.createCell(13);
+            
+            String centerName = dto.getCenterName();
+            String locationName = dto.getLocationName();
+            String jurisdictionName = dto.getJurisdictionName();
+            String cooperativeName = dto.getCooperativeName();
+            String staffName = dto.getStaffName();
+            String staffId = dto.getStaffId();
+            String staffPhoneNumber = dto.getStaffPhoneNumber();
+            String centerNumber = dto.getCenterNumber();
+            int medicalTotal = dto.getTotalStaff();
+            int patientTotal = dto.getTotalPatient();
+            int patientTotalH = dto.getTotalPatientH();
+            int patientTotalD = dto.getTotalPatientD();
+            int patientTotalT = dto.getTotalPatientT();
+            int patientTotalE = dto.getTotalPatientE();
+            
+            cell1.setCellValue(centerName);
+            cell2.setCellValue(locationName);
+            cell3.setCellValue(jurisdictionName);
+            cell4.setCellValue(cooperativeName);
+            cell5.setCellValue(staffName);
+            cell6.setCellValue(staffId);
+            cell7.setCellValue(staffPhoneNumber);
+            cell8.setCellValue(centerNumber);
+            cell9.setCellValue(medicalTotal);
+            cell10.setCellValue(patientTotal);
+            cell11.setCellValue(patientTotalH);
+            cell12.setCellValue(patientTotalD);
+            cell13.setCellValue(patientTotalT);
+            cell14.setCellValue(patientTotalE);
+            
+            i++;
+        }
+        
+        row = sheet1.createRow(i);
+        cell1 = row.createCell(2);
+        cell2 = row.createCell(3);
+        cell3 = row.createCell(4);
+        cell4 = row.createCell(5);
+        cell5 = row.createCell(6);
+        cell6 = row.createCell(7);
+        cell7 = row.createCell(8);
+        cell8 = row.createCell(9);
+        cell9 = row.createCell(10);
+        cell10 = row.createCell(11);
+        cell11 = row.createCell(12);
+        cell12 = row.createCell(13);
+        cell13 = row.createCell(14);
+        cell14 = row.createCell(15);
+        
+        try {
+//          File file = new File(".");
+//          String rootPath = file.getAbsolutePath();
+//          System.out.println("현재 프로젝트의 경로 : "+rootPath );
+          
+          // JBOSS에서 구동시 /home1/jboss/jboss-eap-7.3/domain/test/excel-temp 경로에 저장이됨
+          String tempPath = "../excel-temp/testCenterListExcel.xlsx";
+          String downName = LifeCenterFunction.getNow() + " 생활치료센터.xlsx";
+          File xlsFile = new File(tempPath);
+          FileOutputStream fileOut = new FileOutputStream(xlsFile);
+          workbook.write(fileOut);
+
+          LifeCenterFileDownload.download(request, response, tempPath, downName);
+
+          xlsFile.delete();
+      } catch (FileNotFoundException e) {
+          e.printStackTrace();
+      } catch (IOException e) {
+          e.printStackTrace();
+      }
+    }
 }

+ 6 - 2
src/main/java/com/lemon/lifecenter/controller/MobileLoginController.java

@@ -22,7 +22,9 @@ import com.lemon.lifecenter.common.LifeCenterController;
 import com.lemon.lifecenter.common.LifeCenterFunction;
 import com.lemon.lifecenter.common.LifeCenterSessionController;
 import com.lemon.lifecenter.dto.CenterInfoDTO;
+import com.lemon.lifecenter.dto.LocationDTO;
 import com.lemon.lifecenter.dto.PatientDTO;
+import com.lemon.lifecenter.service.CenterService;
 import com.lemon.lifecenter.service.MobilePatientService;
 import com.lemon.lifecenter.service.RestApiService;
 import com.lemon.lifecenter.service.StaffService;
@@ -37,19 +39,21 @@ public class MobileLoginController extends LifeCenterController {
     private StaffService memberService;
     
     @Autowired
-    private MobilePatientService patientService;
+    private CenterService centerService;
     
     @Autowired
-    private RestApiService restApiService;
+    private MobilePatientService patientService;
     
     @Autowired
     private LifeCenterConfigVO config;
     
     @RequestMapping("/login")
     public ModelAndView login() {
+        List<LocationDTO> locationList = centerService.selectLocation();
         List<CenterInfoDTO> centerList = memberService.selectCenterList();
         
         ModelAndView mv = setMobileMV("login/login");
+        mv.addObject("locationList", locationList);
         mv.addObject("centerList", centerList);
         return mv;
     }

+ 6 - 3
src/main/resources/mybatis/mapper/center/center.xml

@@ -104,18 +104,21 @@
                    (SELECT LOCATION_NAME
                       FROM LOCATION_INFO LI
                      WHERE LI.LOCATION_CODE = CI.LOCATION_CODE)  AS locationName,
+                   (SELECT LOCATION_NAME
+                      FROM LOCATION_INFO LI
+                     WHERE LI.LOCATION_CODE = CI.jurisdiction)  AS jurisdictionName,
+                   ( SELECT cooperative_name FROM cooperative_hospital WHERE cooperative_code = CI.cooperative_code ) AS cooperativeName,
                    M.NAME                                        AS staffName,
                    M.ID                                          AS staffId,
                    M.PHONE_NUMBER                                AS staffPhoneNumber,
                    CI.CENTER_NUMBER                              AS centerNumber,
                    CI.TOTAL_PATIENT                              AS totalPatient,
+                   (SELECT COUNT(*) FROM member WHERE center_code = CI.center_code) AS totalStaff,
+                   CI.TOTAL_CAPACITY                             AS totalCapacity,
                    ( SELECT COUNT(*) FROM patient_care WHERE center_code = CI.center_code AND state = 'H' ) AS totalPatientH,
                    ( SELECT COUNT(*) FROM patient_care WHERE center_code = CI.center_code AND state = 'D' ) AS totalPatientD,
                    ( SELECT COUNT(*) FROM patient_care WHERE center_code = CI.center_code AND state = 'T' ) AS totalPatientT,
                    ( SELECT COUNT(*) FROM patient_care WHERE center_code = CI.center_code AND state = 'E' ) AS totalPatientE,
-                   ( SELECT cooperative_name FROM cooperative_hospital WHERE cooperative_code = CI.cooperative_code ) AS cooperativeName,
-                   CI.TOTAL_CAPACITY                             AS totalCapacity,
-                   CI.TOTAL_STAFF                                AS totalStaff,
                    DATE_FORMAT(CI.CREATE_DATE, '%Y-%m-%d %H:%i') AS createDate
               FROM CENTER_INFO CI
               LEFT OUTER JOIN MEMBER M

+ 3 - 2
src/main/resources/mybatis/mapper/staff/staff.xml

@@ -220,8 +220,9 @@
     
     <select id="selectCenterList" resultType="CenterInfoDTO">
         <![CDATA[
-            SELECT CENTER_CODE AS centerCode,
-                   CENTER_NAME AS centerName
+            SELECT CENTER_CODE   AS centerCode,
+                   CENTER_NAME   AS centerName,
+                   LOCATION_CODE AS locationCode
               FROM CENTER_INFO
              WHERE 1 = 1
              ORDER BY CENTER_NAME

+ 16 - 1
src/main/webapp/WEB-INF/jsp/center/list.jsp

@@ -31,6 +31,20 @@ var endDate   = "<c:out value='${endDate}'/>";
         $("input[name=\"startDate\"]").val( startDate );
         $("input[name=\"endDate\"]").val( endDate );
     });
+
+function getExcel(){
+    var newForm = $( "#searchForm" ).clone();
+    
+    newForm.attr( "id", "excelForm" );
+    newForm.attr( "method", "post" );
+    newForm.attr( "action", "./excel" );
+    newForm.attr( "target", "_blank" );
+    newForm.hide();
+    
+    $( document.body ).append( newForm );
+    newForm.submit();
+    $( "#excelForm" ).remove();
+}
 </script>
 </head>
 <body>
@@ -59,7 +73,7 @@ var endDate   = "<c:out value='${endDate}'/>";
                     <div class="row">
                         <div class="col-12">
                             <div class="card">
-                                <form action="?" method="get">
+                                <form action="?" method="get" id="searchForm">
                                     <div class="card-body">
                                         <table class="table mobile-table">
                                             <colgroup>
@@ -126,6 +140,7 @@ var endDate   = "<c:out value='${endDate}'/>";
                                             <fmt:formatNumber value="${total}" pattern="#,###" />
                                         </div>
                                         <div class="col-6 text-right">
+                                            <button class="btn btn-success" onclick="getExcel();">Excel 다운로드</button>
                                             <button class="btn btn-primary" onclick="location.href='./new';">생활치료센터 신규 등록</button>
                                         </div>
                                     </div>

+ 41 - 4
src/main/webapp/WEB-INF/jsp/mobile/login/login.jsp

@@ -19,12 +19,17 @@ $( function(){
             pw : {
                 required: true
             },
+            locationCode : {
+                selectcheck : true
+            },
             centerCode : {
                 selectcheck : true
             }
         },
         errorPlacement: function( error, element ){
-            if( element.attr( "name" ) == "centerCode" ) {
+            if (element.attr("name") == "locationCode") {
+                $( "#errMsg" ).text( "지역을 선택해주세요" );
+            } else if( element.attr( "name" ) == "centerCode" ) {
                 $( "#errMsg" ).text( "생활센터를 선택해주세요" );
             } else if( element.attr( "name" ) == "id"  ||  element.attr( "name" ) == "pw" ) {
                 if( $( "#id" ).val().length == 0 ) { 
@@ -65,6 +70,28 @@ $( function(){
     if (localStorage.getItem( "id" ) != null) {
         autoLogin();
     }
+
+
+
+    $( "#locationList" ).on( "change", function(){
+        if($('#locationList > option:selected').val() != "0") {
+            console.log($('#locationList').val());
+//             $('#centerDiv').css("display", "block");
+
+            $( "#centerList option" ).hide();
+            if ($( "#centerList option[accessKey='"+$('#locationList').val()+"']" ).length == 0) {
+                $("#centerLabel").text("등록된 생활치료센터가 없습니다.");
+//               var option = "<option value='99' selected>등록된 생활치료센터가 없습니다.</option>";
+//               $('#centerList').append(option);
+            } else {
+                $("#centerLabel").text("치료센터 선택");
+                $( "#centerList option[accessKey='"+$('#locationList').val()+"']" ).show();
+            }
+        } else {
+            $( "#centerList option" ).show();
+            $("#centerLabel").text("치료센터 선택");
+        }
+    });
 });
 
 
@@ -81,7 +108,6 @@ function autoLogin(){
     }
 }
 
-
 </script>
 </head>
 <body>
@@ -96,11 +122,22 @@ function autoLogin(){
                     <div class="form">
                         <div class="part">
                             <div class="selectbox">
-                                <label for="centerList">치료센터 선택</label>
+                                <label for="locationList">전체</label>
+                                <select id="locationList" name="locationCode">
+                                    <option value="0" selected>전체</option>
+                                    <c:forEach var="i" items="${locationList}">
+                                        <option value="${i.locationCode}"> · <c:out value="${i.locationName}" /></option> 
+                                    </c:forEach>
+                                </select>
+                            </div>
+                        </div>
+                        <div class="part" id="centerDiv">
+                            <div class="selectbox">
+                                <label for="centerList" id="centerLabel">치료센터 선택</label>
                                 <select id="centerList" name="centerCode">
                                     <option value="0" selected>치료센터 선택</option>
                                     <c:forEach var="i" items="${centerList}">
-                                        <option value="${i.centerCode}"> · <c:out value="${i.centerName}" /></option> 
+                                        <option value="${i.centerCode}" accessKey="${i.locationCode}"> · <c:out value="${i.centerName}" /></option> 
                                     </c:forEach>
                                 </select>
                             </div>

+ 2 - 2
src/main/webapp/WEB-INF/jsp/patient/list.jsp

@@ -218,8 +218,8 @@ tr.phr-info td span.no-data{color:#999999;}
                                                         <div class="col-5">
                                                             <div class="form-group mb-xl-0">
                                                                 <select class="custom-select form-control" id="sort" name="sort">
-                                                                    <option value="desc" <c:if test="${sort eq 'desc'}">selected="selected"</c:if>>내림차순</option>
-                                                                    <option value="asc" <c:if test="${sort eq 'asc'}">selected="selected"</c:if>>오름차순</option>
+                                                                    <option value="desc" <c:if test="${sort eq 'asc'}">selected="selected"</c:if>>내림차순</option>
+                                                                    <option value="asc" <c:if test="${sort eq 'desc'}">selected="selected"</c:if>>오름차순</option>
                                                                 </select>
                                                             </div>
                                                         </div>