Explorar el Código

컨트롤러 의료, 행정 분리

databank102 hace 4 años
padre
commit
7b7cf412bb

+ 597 - 0
src/main/java/com/lemon/lifecenter/controller/StaffGovManagerController.java

@@ -0,0 +1,597 @@
+package com.lemon.lifecenter.controller;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+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.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.poifs.crypt.EncryptionInfo;
+import org.apache.poi.poifs.crypt.EncryptionMode;
+import org.apache.poi.poifs.crypt.Encryptor;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+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.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+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.FileDownloadDTO;
+import com.lemon.lifecenter.dto.LocationDTO;
+import com.lemon.lifecenter.dto.StaffManagerDTO;
+import com.lemon.lifecenter.service.CenterService;
+import com.lemon.lifecenter.service.FileDownloadService;
+import com.lemon.lifecenter.service.StaffManagerService;
+
+@Controller
+@RequestMapping("/staffGovManager")
+public class StaffGovManagerController extends LifeCenterController {
+    private final Logger logger = LoggerFactory.getLogger(this.getClass());
+
+    @Autowired
+    private StaffManagerService service;
+    
+    @Autowired
+    private CenterService centerService;
+    
+    @Autowired
+    private LifeCenterConfigVO config;
+    
+    private LifeCenterPaging paging;
+    
+    @Autowired
+    private FileDownloadService fileDownloadService;
+    
+    @RequestMapping("/info")
+    public ModelAndView staffManagerInfo(
+            @ModelAttribute("dto") StaffManagerDTO dto,
+            @RequestParam(value="gubun", required=false, defaultValue="G") String inputgubun,
+            HttpServletRequest request,HttpServletResponse response) {
+        
+        String sesCenterCode  = LifeCenterSessionController.getSession( request, "sesCenterCode" );
+        dto.setCenterCode(Integer.valueOf(sesCenterCode));
+        dto.setGubun(inputgubun);
+        
+        ModelAndView mv = setMV("staff/manager/info");
+        
+        int total = service.selectStaffManagerCount(dto);
+        
+        StaffManagerDTO ndto = new StaffManagerDTO();
+        if (total > 0) {
+            ndto = service.selectStaffManagerInfo(dto);
+        } else {
+            ndto.setCenterCode(Integer.valueOf(sesCenterCode));
+            ndto.setGubun(inputgubun);
+            
+        }
+        
+        mv.addObject("list", ndto);
+        
+        return mv;
+    }
+    
+    
+      @RequestMapping("/edit")
+      public ModelAndView staffManagerEdit(
+              @ModelAttribute("dto") StaffManagerDTO dto,
+              @RequestParam(value="gubun", required=false, defaultValue="G") String inputgubun,
+              HttpServletRequest request,HttpServletResponse response) {
+          
+          String sesCenterCode  = LifeCenterSessionController.getSession( request, "sesCenterCode" );
+          dto.setCenterCode(Integer.valueOf(sesCenterCode));
+          dto.setGubun(inputgubun);
+          
+          int total = service.selectStaffManagerCount(dto);
+          StaffManagerDTO ndto = new StaffManagerDTO();
+          if (total > 0) {
+              ndto = service.selectStaffManagerInfo(dto);
+          } else {
+              ndto.setCenterCode(Integer.valueOf(sesCenterCode));
+              ndto.setGubun(inputgubun);
+          }
+          
+          ModelAndView mv = setMV("staff/manager/edit");
+          
+          mv.addObject("list", ndto);
+          
+          return mv;
+      }
+      
+      @RequestMapping( value = "/staffupdate", method = RequestMethod.POST)
+      public String staffManagerUpdate(
+              @ModelAttribute("dto") final StaffManagerDTO dto,
+              HttpServletRequest request,HttpServletResponse response) {
+          String sesId  = LifeCenterSessionController.getSession( request, "sesId" );
+          String sesCenterCode  = LifeCenterSessionController.getSession( request, "sesCenterCode" );
+          String sesCenterName  = LifeCenterSessionController.getSession( request, "sesCenterName" );
+          
+          dto.setCenterCode(Integer.valueOf(sesCenterCode));
+          
+          int total = service.selectStaffManagerCount(dto);
+          
+          if (total > 0) {
+              dto.setUpdateById(sesId);
+              service.updateStaffManager(dto);
+          } else {
+              dto.setCreateById(sesId);
+              
+              CenterInfoDTO cdto = new CenterInfoDTO();
+              cdto.setCenterCode(Integer.valueOf(sesCenterCode));
+              cdto = centerService.selectCenterInfo(cdto);
+               
+              //검색용으로 저장
+              dto.setLocationCode(cdto.getLocationCode());
+              dto.setCenterName(sesCenterName);
+              dto.setCooperativeCode(cdto.getCooperativeCode());
+              dto.setCooperativeName(cdto.getCooperativeName());
+              
+              service.insertStaffManager(dto);
+          }
+          
+          LifeCenterFunction.scriptMessage( response, "alertBox({ txt: '저장을 완료하였습니다.', callBack : function(){ location.href='/staffManager/info?gubun="+ dto.getGubun() +"'; } });" );
+          return "/common/blank";
+          
+      }    
+      
+      @RequestMapping("/list")
+      public ModelAndView staffManagerList(
+              @ModelAttribute("dto") StaffManagerDTO dto,
+              @RequestParam(value="gubun", required=false, defaultValue="G") String inputgubun,
+              @RequestParam(value="locationCode", required=false, defaultValue="") String inputlocationCode,
+              @RequestParam(value="centerName", required=false, defaultValue="") String inputCenterName,
+              @RequestParam(value="page", required=false, defaultValue="1") int page,
+              
+              HttpServletRequest request,HttpServletResponse response) {
+          
+          List<LocationDTO> locationCodeList = centerService.selectLocation();
+          
+          dto.setLimit( ( Integer.valueOf( page ) - 1 ) * config.pageDataSize );
+          dto.setLimitMax( config.pageDataSize );
+          dto.setGubun(inputgubun);
+          
+          int total = service.selectStaffManagerCount(dto);
+          List<StaffManagerDTO> list = new ArrayList<StaffManagerDTO>();
+          if (total > 0) {
+              list = service.selectStaffManagerList(dto);
+          }
+          
+          String param = "locationCode="+inputlocationCode+"&centerlName="+inputCenterName+"&gubun="+inputgubun;
+          paging = LifeCenterPaging.getInstance();
+          paging.paging(config, total, page, param);
+              
+          ModelAndView mv = setMV("staff/manager/list");
+          
+          mv.addObject("total", total);
+          
+          mv.addObject("list", list);
+          mv.addObject("locationList", locationCodeList);
+          
+          mv.addObject("gubun", inputgubun);
+          mv.addObject("locationCode", inputlocationCode);
+          mv.addObject("centerName", inputCenterName);
+          
+          mv.addObject("paging", paging);
+          mv.addObject("page", page);
+          mv.addObject("pageSize", dto.getLimitMax());
+          
+          return mv;
+      }
+      
+      @RequestMapping( value="/excel", method=RequestMethod.POST )
+      public void staffManagerExcelList(
+              @RequestParam(value="downMemo", required=false, defaultValue="") String downMemo,
+              @RequestParam(value="locationCode", required=false, defaultValue="") String inputlocationCode,
+              @RequestParam(value="centerlName", required=false, defaultValue="") String inputcenterlName,
+              @RequestParam(value="gubun", required=false, defaultValue="G") String inputgubun,
+              HttpServletRequest request,HttpServletResponse response ) {
+          String userId = LifeCenterSessionController.getSession(request, "sesId");
+
+          //excel 다운로드 로그 남기기
+          FileDownloadDTO fileDTO = new FileDownloadDTO();
+          fileDTO.setId( userId );
+          fileDTO.setIp( LifeCenterFunction.getRemoteAddr( request ) );
+          fileDTO.setUrl( request.getRequestURI().toString() );
+          fileDTO.setMemo( downMemo );
+          fileDTO.setEtc( "" );
+          fileDownloadService.insertExcelDownloadLog( fileDTO );
+          
+          StaffManagerDTO dto = new StaffManagerDTO();
+          dto.setGubun(inputgubun);
+          dto.setLocationCode(inputlocationCode);
+          dto.setCenterName(inputcenterlName);
+          
+          int total = service.selectStaffManagerCount(dto);
+          List<StaffManagerDTO> result = new ArrayList<StaffManagerDTO>();
+          if (total > 0) {
+              dto.setLimit(0);
+              dto.setLimitMax(total + 1);
+              result = service.selectStaffManagerList(dto);
+              
+//              for( StaffManagerDTO temp : result ) {
+//                  result.get( result.indexOf( temp ) ).setStaffPhoneNumber( LifeCenterFunction.phone( temp.getStaffPhoneNumber() ) );
+//              }
+             
+          }
+          getstaffManagerListExcel(request, response, result, inputgubun);
+          
+      }
+      
+      private void getstaffManagerListExcel(HttpServletRequest request, HttpServletResponse response, List<StaffManagerDTO> data,String inputgubun ) {
+          String password = LifeCenterSessionController.getSession(request, "sesPhoneNumber");
+          password = password.toLowerCase();
+          if (!password.equals("null") && !password.equals( "" )) {
+              password = password.replace("-", "");
+              password = password.substring(3).trim();
+          } else {
+              password = "";
+          }
+          
+          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 = 2;
+          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);
+          Cell cell15 = row.createCell(14);
+          Cell cell16 = row.createCell(15);
+          Cell cell17 = row.createCell(16);
+          Cell cell18 = row.createCell(17);
+          Cell cell19 = row.createCell(18);
+          
+          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);
+          cell15.setCellStyle(styleOfBoardFillFontBlackBold16);
+          
+          if(inputgubun.equals("M")) {
+              cell16.setCellStyle(styleOfBoardFillFontBlackBold16);
+              cell17.setCellStyle(styleOfBoardFillFontBlackBold16);
+              cell18.setCellStyle(styleOfBoardFillFontBlackBold16);
+              cell19.setCellStyle(styleOfBoardFillFontBlackBold16);
+          }
+          
+          cell1.setCellValue("생활치료센터명");
+          sheet1.addMergedRegion(new CellRangeAddress(0,1,0,0));
+          
+          cell2.setCellValue("지역");
+          sheet1.addMergedRegion(new CellRangeAddress(0,1,1,1));
+          cell3.setCellValue("협력병원명");
+          sheet1.addMergedRegion(new CellRangeAddress(0,1,2,2));
+          cell4.setCellValue("인력총계(단위:명)");
+          sheet1.addMergedRegion(new CellRangeAddress(0,1,3,3));
+          
+          cell5.setCellValue((inputgubun.equals("M") ? "협력병원" : "행정") + " 인력 현황 (단위 :명)");
+          sheet1.addMergedRegion(new CellRangeAddress(0,0,4,inputgubun.equals("M") ? 9 : 8));
+          
+          if (inputgubun.equals("M")) {
+              cell11.setCellValue("공공 인력 현황 (단위 :명)");
+              sheet1.addMergedRegion(new CellRangeAddress(0,0,10,12));
+              cell14.setCellValue("민간 인력 현황 (단위 :명)");
+              sheet1.addMergedRegion(new CellRangeAddress(0,0,13, 18));
+          } else {
+              cell10.setCellValue("서비스 인력 현황 (단위 :명)");
+              sheet1.addMergedRegion(new CellRangeAddress(0,0,9,11));
+              cell13.setCellValue("민간 인력 현황 (단위 :명)");
+              sheet1.addMergedRegion(new CellRangeAddress(0,0,12, 14));
+          }
+          
+          row = sheet1.createRow(1);
+          
+          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);    
+          cell15 = row.createCell(14);    
+          cell16 = row.createCell(15);    
+          cell17 = row.createCell(16);    
+          cell18 = row.createCell(17);    
+          cell19 = row.createCell(18);    
+                                          
+          
+          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);
+          cell15.setCellStyle(styleOfBoardFillFontBlackBold16);
+          
+          if(inputgubun.equals("M")) {
+              cell16.setCellStyle(styleOfBoardFillFontBlackBold16);
+              cell17.setCellStyle(styleOfBoardFillFontBlackBold16);
+              cell18.setCellStyle(styleOfBoardFillFontBlackBold16);
+              cell19.setCellStyle(styleOfBoardFillFontBlackBold16);
+          }
+          
+          sheet1.setColumnWidth( 0, 10000); //생활치료센터명
+          sheet1.setColumnWidth( 1, 5000); //지역
+          sheet1.setColumnWidth( 2, 5000); //협력병원명
+          sheet1.setColumnWidth( 3, 5000); //인력총계(단위:명)
+          sheet1.setColumnWidth( 4, 4000); //의사 , 복지부
+          sheet1.setColumnWidth( 5, 4000); //간호사, 지자체
+          sheet1.setColumnWidth( 6, 4000); //간호조무사, 환경부
+          sheet1.setColumnWidth( 7, 4000); //임상병리사, 소방청
+          sheet1.setColumnWidth( 8, 4000); //방사선사, 기타
+          sheet1.setColumnWidth( 9, 4000); //행정인력, 국방부
+          sheet1.setColumnWidth( 10, 4000); //공보의, 경찰청
+          sheet1.setColumnWidth( 11, 4000); //군의관, 기타
+          sheet1.setColumnWidth( 12, 4000); //간호사관생도, 방역
+          sheet1.setColumnWidth( 13, 4000); //민가모집의사, 청소
+          sheet1.setColumnWidth( 14, 4000); //민간모집간호사, 기타
+          
+          if(inputgubun.equals("M")) {
+              sheet1.setColumnWidth( 15, 6000); //민간모집간호조무사
+              sheet1.setColumnWidth( 16, 6000); //민간모잡방사선사
+              sheet1.setColumnWidth( 17, 6000); //민간모집임상병리사
+              sheet1.setColumnWidth( 18, 6000); //민간모집기타인력
+          }
+          
+          //cell1.setCellValue("생활치료센터명");
+          //cell2.setCellValue("지역");
+          //cell3.setCellValue("협력병원명");
+          //cell4.setCellValue("인력총계(단위:명)");
+          cell5.setCellValue(inputgubun.equals("M") ? "의사" : "복지부");
+          cell6.setCellValue(inputgubun.equals("M") ?"간호사" : "지자체");
+          cell7.setCellValue(inputgubun.equals("M") ?"간호조무사" : "환경부");
+          cell8.setCellValue(inputgubun.equals("M") ?"임상병리사" : "소방청");
+          cell9.setCellValue(inputgubun.equals("M") ?"방사선사" : "기타");
+          cell10.setCellValue(inputgubun.equals("M") ?"행정인력" : "국방부");
+          cell11.setCellValue(inputgubun.equals("M") ?"공보의" : "경찰청");
+          cell12.setCellValue(inputgubun.equals("M") ?"군의관" : "기타");
+          cell13.setCellValue(inputgubun.equals("M") ?"간호사관생도" : "방역");
+          cell14.setCellValue(inputgubun.equals("M") ?"민가모집의사" : "청소");
+          cell15.setCellValue(inputgubun.equals("M") ?"민간모집간호사" : "기타");
+          
+          if(inputgubun.equals("M")) {
+              cell16.setCellValue("민간모집간호조무사");
+              cell17.setCellValue("민간모잡방사선사");
+              cell18.setCellValue("민간모집임상병리사");
+              cell19.setCellValue("민간모집기타인력");
+          }
+          
+          for (StaffManagerDTO dto : data) {
+              row = sheet1.createRow(i);
+              String gubun = dto.getGubun();
+              
+              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);
+              cell15 = row.createCell(14);
+              
+              if(gubun.equals("M")) {
+                  cell16 = row.createCell(15);
+                  cell17 = row.createCell(16);
+                  cell18 = row.createCell(17);
+                  cell19 = row.createCell(18);
+              }
+
+              String centerName = dto.getCenterName();
+              String locationName = dto.getLocationName();
+              String cooperativeName = dto.getCooperativeName();
+              int staffTotal = dto.getStaffTotal();
+              int staff1 = dto.getStaff1();
+              int staff2 = dto.getStaff2();
+              int staff3 = dto.getStaff3();
+              int staff4 = dto.getStaff4();
+              int staff5 = dto.getStaff5();
+              int staff6 = dto.getStaff6();
+              int staff7 = dto.getStaff7();
+              int staff8 = dto.getStaff8();
+              int staff9 = dto.getStaff9();
+              int staff10 = dto.getStaff10();
+              int staff11 = dto.getStaff11();
+              int staff12 = dto.getStaff12();
+              int staff13 = dto.getStaff13();
+              int staff14 = dto.getStaff14();
+              int staff15 = dto.getStaff15();
+             
+              
+              cell1.setCellValue(centerName);
+              cell2.setCellValue(locationName);
+              cell3.setCellValue(cooperativeName);
+              cell4.setCellValue(staffTotal);
+              cell5.setCellValue(staff1);
+              cell6.setCellValue(staff2);
+              cell7.setCellValue(staff3);
+              cell8.setCellValue(staff4);
+              cell9.setCellValue(staff5);
+              cell10.setCellValue(staff6);
+              cell11.setCellValue(staff7);
+              cell12.setCellValue(staff8);
+              cell13.setCellValue(staff9);
+              cell14.setCellValue(staff10);
+              cell15.setCellValue(staff11);
+             
+              if(gubun.equals("M")) {
+                  cell16.setCellValue(staff12);
+                  cell17.setCellValue(staff13);
+                  cell18.setCellValue(staff14);
+                  cell19.setCellValue(staff15);
+              }
+              
+              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);
+          cell15 = row.createCell(16);
+          
+          if(inputgubun.equals("M")) {
+              cell16 = row.createCell(17);
+              cell17 = row.createCell(18);
+              cell18 = row.createCell(19);
+              cell19 = row.createCell(20);
+          }
+          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/testExcel.xlsx";
+            String downName = LifeCenterFunction.getNow() + "_" + (inputgubun.equals("M") ? "의료" : "행정") +"인력 현황리스트.xlsx";
+            File xlsFile = new File(tempPath);
+//            FileOutputStream fileOut = new FileOutputStream(tempPath);
+//            workbook.write(fileOut);
+//            fileOut.close();
+            
+            ByteArrayOutputStream fileOut = new ByteArrayOutputStream();
+            FileOutputStream fos = new FileOutputStream(tempPath);
+            workbook.write(fileOut);
+            
+            InputStream filein = new ByteArrayInputStream(fileOut.toByteArray());
+            OPCPackage opc = OPCPackage.open(filein);
+
+            POIFSFileSystem fileSystem = new POIFSFileSystem();
+
+            EncryptionInfo encryptionInfo = new EncryptionInfo(EncryptionMode.agile);
+            Encryptor encryptor = encryptionInfo.getEncryptor();
+            encryptor.confirmPassword(password);
+
+            opc.save(encryptor.getDataStream(fileSystem));
+            opc.flush();
+            
+            fileSystem.writeFilesystem(fos);
+            
+            fileOut.close();
+            opc.close();
+            
+            filein.close();
+            fileSystem.close();
+            
+            LifeCenterFileDownload.download(request, response, tempPath, downName);
+
+            xlsFile.delete();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } catch (InvalidFormatException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+      } catch (GeneralSecurityException e) {
+          // TODO Auto-generated catch block
+          e.printStackTrace();
+      }
+      }
+      
+}

+ 3 - 3
src/main/java/com/lemon/lifecenter/controller/StaffManagerController.java

@@ -56,8 +56,8 @@ import com.lemon.lifecenter.service.FileDownloadService;
 import com.lemon.lifecenter.service.StaffManagerService;
 
 @Controller
-@RequestMapping("/staffManager")
-public class StaffManagerController extends LifeCenterController {
+@RequestMapping("/staffMediManager")
+public class StaffMediManagerController extends LifeCenterController {
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @Autowired
@@ -214,7 +214,7 @@ public class StaffManagerController extends LifeCenterController {
               @RequestParam(value="downMemo", required=false, defaultValue="") String downMemo,
               @RequestParam(value="locationCode", required=false, defaultValue="") String inputlocationCode,
               @RequestParam(value="centerlName", required=false, defaultValue="") String inputcenterlName,
-              @RequestParam(value="gubun", required=false, defaultValue="") String inputgubun,
+              @RequestParam(value="gubun", required=false, defaultValue="M") String inputgubun,
               HttpServletRequest request,HttpServletResponse response ) {
           String userId = LifeCenterSessionController.getSession(request, "sesId");
 

+ 36 - 41
src/main/resources/mybatis/mapper/staff/staffManager.xml

@@ -82,10 +82,7 @@
                     STAFF14,
                     STAFF15,
                     CREATE_DATE,
-                    CREATE_BY_ID,
-                    LOCATION_CODE,
-                    CENTER_NAME,
-                    COOPERATIVE_CODE
+                    CREATE_BY_ID
                 )
             values
                 (
@@ -107,10 +104,7 @@
                     #{staff14},
                     #{staff15},
                     NOW(),
-                    #{createById},
-                    #{locationCode},
-                    #{centerName},
-                    #{cooperativeCode}
+                    #{createById}
                 )
         ]]>
     </insert>
@@ -145,59 +139,60 @@
     <select id="selectStaffManagerList" parameterType="StaffManagerDTO" resultType="StaffManagerDTO">
         <![CDATA[
             SELECT
-                CENTER_CODE                                             AS centerCode,
-                NVL(GUBUN, #{gubun})                                    AS gubun,       --M:의료,     G:행정
-                SUM(STAFF1 )                                            AS staff1,      --의사,       복지부
-                SUM(STAFF2 )                                            AS staff2,      --간호사,      지자체
-                SUM(STAFF3 )                                            AS staff3,      --간호조무사,   환경부
-                SUM(STAFF4 )                                            AS staff4,      --임상병리사,   소방청
-                SUM(STAFF5 )                                            AS staff5,      --방사선사,     기타
-                SUM(STAFF6 )                                            AS staff6,      --행정인력,     국방부
-                SUM(STAFF7 )                                            AS staff7,      --공보의,      경찰청
-                SUM(STAFF8 )                                            AS staff8,      --군의관,      소방청
-                SUM(STAFF9 )                                            AS staff9,      --간호사관생도,  방역
-                SUM(STAFF10)                                            AS staff10,     --민간모집의사,  청소
-                SUM(STAFF11)                                            AS staff11,     --민간모집간호사, 기타
-                SUM(STAFF12)                                            AS staff12,     --민간모집간호조무사
-                SUM(STAFF13)                                            AS staff13,     --민간모집임상병리사
-                SUM(STAFF14)                                            AS staff14,     --민간모집방사선사
-                SUM(STAFF15)                                            AS staff15,     --민간모집기타인력
-                CREATE_DATE                                             AS createDate,
-                UPDATE_DATE                                             AS updateDate,
-                CREATE_BY_ID                                            AS createById,
-                UPDATE_BY_ID                                            AS updateById,
-                LOCATION_CODE                                           AS locationCode,
-                DECODE(CENTER_CODE, NULL , TO_CHAR(SUM(1)), CENTER_NAME)                                             AS centerName,
-                DECODE(CENTER_CODE, NULL , TO_CHAR(SUM(1)), (SELECT CH.COOPERATIVE_NAME 
+                SM.CENTER_CODE                                             AS centerCode,
+                NVL(SM.GUBUN, #{gubun})                                    AS gubun,       --M:의료,     G:행정
+                SUM(SM.STAFF1 )                                            AS staff1,      --의사,       복지부
+                SUM(SM.STAFF2 )                                            AS staff2,      --간호사,      지자체
+                SUM(SM.STAFF3 )                                            AS staff3,      --간호조무사,   환경부
+                SUM(SM.STAFF4 )                                            AS staff4,      --임상병리사,   소방청
+                SUM(SM.STAFF5 )                                            AS staff5,      --방사선사,     기타
+                SUM(SM.STAFF6 )                                            AS staff6,      --행정인력,     국방부
+                SUM(SM.STAFF7 )                                            AS staff7,      --공보의,      경찰청
+                SUM(SM.STAFF8 )                                            AS staff8,      --군의관,      소방청
+                SUM(SM.STAFF9 )                                            AS staff9,      --간호사관생도,  방역
+                SUM(SM.STAFF10)                                            AS staff10,     --민간모집의사,  청소
+                SUM(SM.STAFF11)                                            AS staff11,     --민간모집간호사, 기타
+                SUM(SM.STAFF12)                                            AS staff12,     --민간모집간호조무사
+                SUM(SM.STAFF13)                                            AS staff13,     --민간모집임상병리사
+                SUM(SM.STAFF14)                                            AS staff14,     --민간모집방사선사
+                SUM(SM.STAFF15)                                            AS staff15,     --민간모집기타인력
+                SM.CREATE_DATE                                             AS createDate,
+                SM.UPDATE_DATE                                             AS updateDate,
+                SM.CREATE_BY_ID                                            AS createById,
+                SM.UPDATE_BY_ID                                            AS updateById,
+                CI.LOCATION_CODE                                           AS locationCode,
+                DECODE(SM.CENTER_CODE, NULL , TO_CHAR(SUM(1)), CI.CENTER_NAME)                                             AS centerName,
+                DECODE(SM.CENTER_CODE, NULL , TO_CHAR(SUM(1)), (SELECT CH.COOPERATIVE_NAME 
                                                                 FROM COOPERATIVE_HOSPITAL CH
-                                                                WHERE SM.COOPERATIVE_CODE = CH.COOPERATIVE_CODE
-                                                            )
+                                                                WHERE CI.COOPERATIVE_CODE = CH.COOPERATIVE_CODE
+                                                                )
                 )                                                       AS cooperativeName,
                 (SELECT LI.LOCATION_NAME
                       FROM LOCATION_INFO LI
-                     WHERE SM.LOCATION_CODE = LI.LOCATION_CODE)         AS locationName,
+                     WHERE CI.LOCATION_CODE = LI.LOCATION_CODE)         AS locationName,
                 SUM(STAFF1 + STAFF2 + STAFF3 + STAFF4 + STAFF5 +
                  STAFF6 + STAFF7 + STAFF8 + STAFF9 + STAFF10 +
                  STAFF11 + STAFF12 + STAFF13 + STAFF14 + STAFF15)       AS staffTotal
             FROM
-                STAFF_MANAGER SM
+                STAFF_MANAGER SM, CENTER_INFO CI
             WHERE 1 = 1
-            AND GUBUN = #{gubun}
+            AND SM.CENTER_CODE = CI.CENTER_CODE(+)
+            AND SM.GUBUN = #{gubun}
         ]]>
         
         <if test='centerName != null and centerName != ""'>
             <![CDATA[
-                AND CENTER_NAME LIKE CONCAT('%', #{centerName}, '%')
+                AND CI.CENTER_NAME LIKE CONCAT('%', #{centerName}, '%')
             ]]>
         </if>
         <if test='locationCode != null and locationCode != ""'>
             <![CDATA[
-                AND LOCATION_CODE = #{locationCode}
+                AND CI.LOCATION_CODE = #{locationCode}
             ]]>
         </if>
         <![CDATA[
-            GROUP BY CENTER_CODE WITH ROLLUP HAVING 1 = 1
-            ORDER BY NVL(CENTER_CODE, 99999) DESC
+            GROUP BY SM.CENTER_CODE WITH ROLLUP HAVING 1 = 1
+            ORDER BY NVL(SM.CENTER_CODE, 99999) DESC
             LIMIT #{limit}, #{limitMax}
         ]]>
     </select>