|
|
|
|
@ -1,6 +1,10 @@
|
|
|
|
|
package cokr.xit.fims.rent.web;
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
@ -9,10 +13,17 @@ import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellStyle;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
|
import cokr.xit.applib.AppCmmnUtil;
|
|
|
|
|
import cokr.xit.base.code.CommonCode;
|
|
|
|
|
import cokr.xit.base.docs.xls.CellDef;
|
|
|
|
|
import cokr.xit.base.docs.xls.Format;
|
|
|
|
|
@ -24,6 +35,7 @@ import cokr.xit.fims.cmmn.service.bean.StngBean;
|
|
|
|
|
import cokr.xit.fims.cmmn.xls.FormatMaker;
|
|
|
|
|
import cokr.xit.fims.cmmn.xls.StyleMaker;
|
|
|
|
|
import cokr.xit.fims.rent.RentEnt;
|
|
|
|
|
import cokr.xit.fims.rent.RentEntVhclMpng;
|
|
|
|
|
import cokr.xit.fims.rent.RentQuery;
|
|
|
|
|
import cokr.xit.fims.rent.UserRentEntMpng;
|
|
|
|
|
import cokr.xit.fims.rent.service.RentEntService;
|
|
|
|
|
@ -61,6 +73,10 @@ public class Rent01Controller extends ApplicationController {
|
|
|
|
|
, getRentEnterprise = "/040/list.do" // 임대 기업 대장 상세 정보 조회
|
|
|
|
|
, createRentEnterprise = "/040/createEnt.do" // 임대 기업 대장 등록
|
|
|
|
|
, updateRentEnterprise = "/040/updateEnt.do" // 임대 기업 대장 수정
|
|
|
|
|
, enterpriseCarMappingMain = "/050/main.do"
|
|
|
|
|
, getEnterpriseCarMappingList = "/050/list.do"
|
|
|
|
|
, removeRentEnterpriseCarMapping = "/050/removeMpng.do"
|
|
|
|
|
, createRentEnterpriseCarMapping = "/050/create.do"
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -430,4 +446,203 @@ public class Rent01Controller extends ApplicationController {
|
|
|
|
|
.addObject("rtnMsg", rtnMsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**임대기업 차량 매핑 메인화면(fims/rent/rent01050-main)을 연다.
|
|
|
|
|
* @return fims/rent/rent01050-main
|
|
|
|
|
*/
|
|
|
|
|
@RequestMapping(name = "임대기업 차량 매핑 메인", value=METHOD_URL.enterpriseCarMappingMain)
|
|
|
|
|
public ModelAndView enterpriseCarMappingMain() {
|
|
|
|
|
ModelAndView mav = new ModelAndView("fims/rent/rent01050-main");
|
|
|
|
|
|
|
|
|
|
// 사용자 정보
|
|
|
|
|
FimsUser fimsUser = (FimsUser)currentUser().getUser();
|
|
|
|
|
|
|
|
|
|
// 사용자와 매핑되어있는 임대업체 정보 조회
|
|
|
|
|
RentQuery req = new RentQuery();
|
|
|
|
|
req.setUserId(fimsUser.getId());
|
|
|
|
|
|
|
|
|
|
List<DataObject> entRegNoList = rentEntService.getUserRentEntMpngs(req);
|
|
|
|
|
|
|
|
|
|
return mav
|
|
|
|
|
.addObject("pageName", "rent01050") // jsp pageName
|
|
|
|
|
.addObject("prefixUrl", CLASS_URL) // prefixUrl
|
|
|
|
|
.addObject("userId", req.getUserId()) // 사용자 ID
|
|
|
|
|
.addObject("userAcnt", fimsUser.getAccount()) // 사용자 계정(USER_ACNT)
|
|
|
|
|
.addObject("entRegNoList", entRegNoList) // 임대업체 목록
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**임대기업 차량 목록을 조회하여 반환한다.<br />
|
|
|
|
|
* {@link RentEntService#getEnterpriseCarMappingList(RentEntQuery)} 참고
|
|
|
|
|
* @param req 임대 기업 차량 조회 조건
|
|
|
|
|
* @return jsonView
|
|
|
|
|
* <pre><code> {
|
|
|
|
|
* "rentEntList": [임대 기업 매핑 차량 목록]
|
|
|
|
|
* "rentEntStart": 임대 기업 매핑 차량 목록 시작 인덱스
|
|
|
|
|
* "rentEntFetch": 한 번에 가져오는 임대 기업 매핑 차량 목록 수
|
|
|
|
|
* "rentEntTotal": 조회 결과 찾은 전체 임대 기업 매핑 차량 수
|
|
|
|
|
* }</code></pre>
|
|
|
|
|
*/
|
|
|
|
|
@Task("CMN")
|
|
|
|
|
@RequestMapping(name = "임대기업 차량 조회", value=METHOD_URL.getEnterpriseCarMappingList)
|
|
|
|
|
public ModelAndView getEnterpriseCarMappingList(RentQuery req) {
|
|
|
|
|
// 사용자 정보
|
|
|
|
|
FimsUser fimsUser = (FimsUser)currentUser().getUser();
|
|
|
|
|
|
|
|
|
|
// 사용자와 매핑되어있는 임대업체 정보 조회
|
|
|
|
|
req.setUserId(fimsUser.getId());
|
|
|
|
|
|
|
|
|
|
if (!"xls".equals(req.getDownload())) {
|
|
|
|
|
List<?> result = rentEntService.getEnterpriseCarMappingList(setFetchSize(req));
|
|
|
|
|
return setPagingInfo(new ModelAndView("jsonView"), result, "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 현재 날짜 구하기
|
|
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
|
|
String dateTime = dateFormat.format(System.currentTimeMillis());
|
|
|
|
|
|
|
|
|
|
List<CellDef> cellDefs = fromJson(req.getCellDefs(), CellDef.listType());
|
|
|
|
|
|
|
|
|
|
XLSWriter xlsx = new XLSWriter().worksheet(0);
|
|
|
|
|
Format format = new Format(xlsx);
|
|
|
|
|
CellStyle center = format.cellStyle(Style.CENTER);
|
|
|
|
|
CellStyle dateDT = format.yyyy_mm_dd_hh_mm_ss();
|
|
|
|
|
|
|
|
|
|
List<DataObject> list = rentEntService.getEnterpriseCarMappingList(req.setFetchSize(0));
|
|
|
|
|
|
|
|
|
|
Map<String,Object> valueMap = new HashMap<String,Object>();
|
|
|
|
|
valueMap.put("사용자계정", format.of("USER_ACNT"));
|
|
|
|
|
valueMap.put("사용자명", format.of("USER_NM").style(center));
|
|
|
|
|
valueMap.put("기업구분", format.of("ENT_SE_NM").style(center));
|
|
|
|
|
valueMap.put("기업명", format.of("ENT_NM"));
|
|
|
|
|
valueMap.put("법인(사업자)번호", format.of("ENT_REG_NO").style(center));
|
|
|
|
|
valueMap.put("차량번호", format.of("VHRNO").style(center));
|
|
|
|
|
valueMap.put("등록일시", FormatMaker.yyyy_mm_dd_hh_mm_ss(format, "REG_DT").style(dateDT));
|
|
|
|
|
valueMap.put("등록사용자", format.of("RGTR_NM").style(center));
|
|
|
|
|
|
|
|
|
|
CellDef.setValues(cellDefs, valueMap);
|
|
|
|
|
|
|
|
|
|
xlsx.cell(0, 0).value("임대기업차량").value(center).merge(0, cellDefs.size() - 1)
|
|
|
|
|
.cell(3, 0).rowValues(CellDef.header(cellDefs, () -> StyleMaker.headerStyle(xlsx)))
|
|
|
|
|
.cell(4, 0).values(list, CellDef.values(cellDefs.stream().map(i -> { if(i.getValue() instanceof Format) { i.setField(null); }; return i; }).toList()));
|
|
|
|
|
|
|
|
|
|
return new ModelAndView("downloadView")
|
|
|
|
|
.addObject("download", xlsx.getDownloadable().setFilename("임대기업차량" + "_목록_" + dateTime + ".xlsx"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**지정한 임대 기업 차량 매핑 대장을 제거한다.
|
|
|
|
|
* @param userRentEntMpngIDs 임대 기업 차량 매핑 아이디
|
|
|
|
|
* @return jsonView
|
|
|
|
|
* <pre><code> {
|
|
|
|
|
* "affected": 저장된 정보수
|
|
|
|
|
* "saved": 저장되었으면 true, 그렇지 않으면 false
|
|
|
|
|
* }</code></pre>
|
|
|
|
|
*/
|
|
|
|
|
@Task("CMN")
|
|
|
|
|
@RequestMapping(name = "임대 기업 차량 매핑 대장 제거", value = METHOD_URL.removeRentEnterpriseCarMapping)
|
|
|
|
|
public ModelAndView removeRentEnterpriseCarMapping(RentEntVhclMpng rentEntVhclMpng) {
|
|
|
|
|
|
|
|
|
|
boolean saved = false;
|
|
|
|
|
|
|
|
|
|
String rtnMsg = rentEntService.removeRentEntVhclMpng(rentEntVhclMpng);
|
|
|
|
|
|
|
|
|
|
if (rtnMsg.contains("[S]")) {
|
|
|
|
|
saved = true;
|
|
|
|
|
} else {
|
|
|
|
|
saved = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ModelAndView("jsonView")
|
|
|
|
|
.addObject("saved", saved)
|
|
|
|
|
.addObject("rtnMsg", rtnMsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**임대 기업 차량 매핑 대장을 등록한다.
|
|
|
|
|
* @param
|
|
|
|
|
* @return jsonView
|
|
|
|
|
* <pre><code> {
|
|
|
|
|
* "saved": 등록되었으면 true, 그렇지 않으면 false
|
|
|
|
|
* }</code></pre>
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping(name = "임대 기업 차량 매핑 대장 등록", value = METHOD_URL.createRentEnterpriseCarMapping)
|
|
|
|
|
public ModelAndView createRentEnterpriseCarMapping(String excelUploadEntId, MultipartFile excelUploadFile) throws InterruptedException, IOException {
|
|
|
|
|
boolean saved = false;
|
|
|
|
|
String rtnMsg = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] bytesOfFile = excelUploadFile.getBytes();
|
|
|
|
|
InputStream in = new ByteArrayInputStream(bytesOfFile);
|
|
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(in);
|
|
|
|
|
|
|
|
|
|
List<String> vhrnoList = new ArrayList<>();
|
|
|
|
|
int successCnt = 0;
|
|
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
|
|
int rowNo = 0;
|
|
|
|
|
|
|
|
|
|
XSSFSheet sheet = workbook.getSheetAt(0); // 0 번째 시트를 가져온다
|
|
|
|
|
|
|
|
|
|
int rows = sheet.getPhysicalNumberOfRows(); // 사용자가 입력한 엑셀 Row수를 가져온다
|
|
|
|
|
for(rowNo = 0; rowNo < rows; rowNo++){
|
|
|
|
|
|
|
|
|
|
XSSFRow row = sheet.getRow(rowNo);
|
|
|
|
|
if(row == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
XSSFCell cell = row.getCell(0); // 0번째 셀의 값을 가져온다
|
|
|
|
|
if(cell == null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String vhrno = cell.getStringCellValue() + "";
|
|
|
|
|
|
|
|
|
|
if(vhrno.equals("")) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!AppCmmnUtil.isValidCarNumber(vhrno)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vhrnoList.add(vhrno);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workbook.close();
|
|
|
|
|
|
|
|
|
|
String userId = currentUser().getId();
|
|
|
|
|
|
|
|
|
|
for (String vhrno : vhrnoList) {
|
|
|
|
|
RentEntVhclMpng rentEntVhclMpng = new RentEntVhclMpng();
|
|
|
|
|
rentEntVhclMpng.setVhrno(vhrno);
|
|
|
|
|
rentEntVhclMpng.setEntId(excelUploadEntId);
|
|
|
|
|
rentEntVhclMpng.setCreatedBy(userId);
|
|
|
|
|
|
|
|
|
|
// 등록 호출
|
|
|
|
|
String ret = rentEntService.createRentEntVhclMpng(rentEntVhclMpng);
|
|
|
|
|
if(ret.contains("[S]")) {
|
|
|
|
|
successCnt++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(vhrnoList.size() == 0) {
|
|
|
|
|
rtnMsg = "[F] 파일에 유효한 차량번호가 없습니다.";
|
|
|
|
|
} else if(successCnt == 0){
|
|
|
|
|
rtnMsg = "[F] 차량 등록 작업에 실패하였습니다.";
|
|
|
|
|
} else {
|
|
|
|
|
rtnMsg = "[S] 차량 등록 작업이 정상 처리 되었습니다.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (rtnMsg.contains("[S]")) {
|
|
|
|
|
saved = true;
|
|
|
|
|
} else {
|
|
|
|
|
saved = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new ModelAndView("jsonView")
|
|
|
|
|
.addObject("saved", saved)
|
|
|
|
|
.addObject("rtnMsg", rtnMsg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|