임대기업 차량 등록 메뉴 추가

main
이범준 9 months ago
parent c32dcefca2
commit 17aa53d573

@ -0,0 +1,39 @@
package cokr.xit.fims.rent;
import cokr.xit.foundation.AbstractEntity;
import lombok.Getter;
import lombok.Setter;
/**
*
* @author leebj
*/
@Getter
@Setter
public class RentEntVhclMpng extends AbstractEntity {
/**
* ID
*/
private String mpngId;
/**
* IDs
*/
private String[] mpngIds;
/**
* ID
*/
private String entId;
/**
*
*/
private String vhrno;
/**
*
*/
private String delYn;
}

@ -4,6 +4,7 @@ import java.util.List;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.fims.rent.RentEntVhclMpng;
import cokr.xit.fims.rent.RentQuery;
import cokr.xit.fims.rent.UserRentEntMpng;
import cokr.xit.foundation.component.AbstractMapper;
@ -81,4 +82,34 @@ public interface UserRentEntMpngMapper extends AbstractMapper {
*/
int deleteUserRentEntMpng(UserRentEntMpng userRentEntMpng);
List<DataObject> selectEnterpriseCarMappingList(RentQuery req);
/** .
* @param params
* <ul><li>"rentEntVhclMpng" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
int deleteRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng);
/** .
* @param params
* <ul><li>"rentEntVhclMpng" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
int countRentEntVhclMpngInfo(RentEntVhclMpng rentEntVhclMpng);
/** .
* @param params
* <ul><li>"rentEntVhclMpng" - </li>
* <li>"currentUser" - </li>
* </ul>
* @return
*/
int createRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng);
}

@ -3,6 +3,7 @@ package cokr.xit.fims.rent.service;
import java.util.List;
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.foundation.data.DataObject;
@ -100,4 +101,28 @@ public interface RentEntService {
*/
String removeRentEnt(RentEnt rentEnt);
/** .
* @param req
* @return
*/
List<DataObject> getEnterpriseCarMappingList(RentQuery req);
/** .
* @param rentEntMpng
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
String removeRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng);
/** .
* @param rentEntVhclMpng
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
String createRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng);
}

@ -8,6 +8,7 @@ import org.springframework.stereotype.Component;
import cokr.xit.fims.cmmn.CmmnUtil;
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.dao.RentEntMapper;
@ -274,4 +275,71 @@ public class RentEntBean extends AbstractBean {
return "[S] 삭제 작업이 정상 처리 되었습니다.";
}
/** .
* @param req
* @return
*/
public List<DataObject> getEnterpriseCarMappingList(RentQuery req) {
// 삭제 여부 확인
if (req.getDelYn() == null) {
req.setDelYn("N");
}
// 정렬 확인
if (req.getOrderBy() == null) {
if (req.getBy() == null) {
req.setOrderBy("VHRNO");
} else {
req.setOrderBy(CmmnUtil.convertCamelCaseToSnakeCase(req.getBy()));
}
}
return userRentEntMpngMapper.selectEnterpriseCarMappingList(req);
}
/** .
* @param rentEntVhclMpng
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public String removeRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng) {
// 임대 기업 차량 매핑(TB_RENT_ENT_VHCL_MPNG) 대장을 삭제한다.
int rtnNocs = userRentEntMpngMapper.deleteRentEntVhclMpng(rentEntVhclMpng);
if (rtnNocs < 1) {
throw new RuntimeException("[F] 삭제 작업에 실패하였습니다."); // 예외를 발생시켜서 DB Rollback
}
return "[S] 삭제 작업이 정상 처리 되었습니다.";
}
/** .
* @param rentEntVhclMpng
* @return
* <ul><li> true</li>
* <li> false</li>
* </ul>
*/
public String createRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng) {
RentQuery req = new RentQuery();
req.setUserId(rentEntVhclMpng.getCreatedBy());
req.setEntId(rentEntVhclMpng.getEntId());
DataObject userEntInfo = userRentEntMpngMapper.selectUserRentEntMpngInfo(req);
if(userEntInfo == null || userEntInfo.isEmpty()) {
return "[F] 차량 등록 권한이 없습니다.";
}
int vhclCnt = userRentEntMpngMapper.countRentEntVhclMpngInfo(rentEntVhclMpng);
if(vhclCnt > 0) {
return "[S] 등록된 차량입니다.";
}
int result = userRentEntMpngMapper.createRentEntVhclMpng(rentEntVhclMpng);
if(result < 1) {
return "[F] 차량 등록 작업에 실패하였습니다.";
}
return "[S] 차량 등록 작업이 정상 처리 되었습니다.";
}
}

@ -7,6 +7,7 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Service;
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;
@ -85,4 +86,19 @@ public class RentEntServiceBean extends AbstractServiceBean implements RentEntSe
return rentEntBean.removeRentEnt(rentEnt);
}
@Override
public List<DataObject> getEnterpriseCarMappingList(RentQuery req) {
return rentEntBean.getEnterpriseCarMappingList(req);
}
@Override
public String removeRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng) {
return rentEntBean.removeRentEntVhclMpng(rentEntVhclMpng);
}
@Override
public String createRentEntVhclMpng(RentEntVhclMpng rentEntVhclMpng) {
return rentEntBean.createRentEntVhclMpng(rentEntVhclMpng);
}
}

@ -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);
}
}

@ -141,4 +141,131 @@
</choose>
</update>
<select id="selectEnterpriseCarMappingList" parameterType="map" resultType="dataobject">
/* 사용자 임대 기업 차량 매핑 목록 조회(userRentEntMpngMapper.selectEnterpriseCarMappingList) */
<include refid="utility.paging-prefix" />
SELECT REVM.MPNG_ID <!-- 매핑 ID -->
, UREM.USER_ID <!-- 사용자 ID -->
, UREM.ENT_ID <!-- 기업 ID -->
, REVM.DEL_YN <!-- 삭제 여부 -->
, (GET_CODE_NM('CMN007', REVM.DEL_YN)) AS DEL_YN_NM <!-- 삭제 여부 -->
, U.USER_ACNT <!-- 사용자 계정 -->
, U.USER_NM <!-- 사용자 이름 -->
, RE.ENT_SE_CD <!-- 기업 구분 코드 -->
, (GET_CODE_NM('FIM088', RE.ENT_SE_CD)) AS ENT_SE_NM <!-- 기업 구분 -->
, RE.ENT_NM <!-- 기업 명 -->
, RE.ENT_REG_NO <!-- 기업 등록 번호 -->
, RE.RPRSV_NM <!-- 대표자 명 -->
, RE.ENT_TELNO <!-- 기업 전화번호 -->
, RE.ENT_MBL_TELNO <!-- 기업 휴대 전화번호 -->
, RE.ENT_FXNO <!-- 기업 팩스번호 -->
, RE.ENT_EML_ADDR <!-- 기업 이메일 주소 -->
, RE.ENT_ZIP <!-- 기업 우편번호 -->
, RE.ENT_ADDR <!-- 기업 주소 -->
, RE.ENT_DTL_ADDR <!-- 기업 상세 주소 -->
, REVM.VHRNO <!-- 차량번호 -->
, REVM.REG_DT <!-- 등록 일시 -->
, REVM.RGTR <!-- 등록자 -->
, (SELECT USER_NM FROM TB_USER X WHERE X.USER_ID = REVM.RGTR) AS RGTR_NM <!-- 등록자 명 -->
FROM TB_USER_RENT_ENT_MPNG UREM
INNER JOIN TB_USER U ON (UREM.USER_ID = U.USER_ID)
INNER JOIN TB_RENT_ENT RE ON (UREM.ENT_ID = RE.ENT_ID)
INNER JOIN TB_RENT_ENT_VHCL_MPNG REVM ON (RE.ENT_ID = REVM.ENT_ID)
<where>
AND UREM.DEL_YN = 'N' <!-- 삭제 여부 -->
AND REVM.DEL_YN = 'N'
<if test="userId != null">
AND UREM.USER_ID = #{userId} <!-- 사용자 ID -->
</if>
<if test="entId != null">
AND UREM.ENT_ID = #{entId} <!-- 기업 ID -->
</if>
<if test="schEntRegNo != null">
AND RE.ENT_REG_NO = #{schEntRegNo} <!-- 기업 ID -->
</if>
<if test="schVhrno != null">
AND REVM.VHRNO = #{schVhrno} <!-- 기업 ID -->
</if>
<if test="@org.egovframe.rte.fdl.string.EgovStringUtil@isNotEmpty(by) and @org.egovframe.rte.fdl.string.EgovStringUtil@isNotEmpty(term)">
<choose>
<when test="mainOption == 'codeValue' or mainOption == 'match' or mainOption == 'ymd'">
<include refid="dynamicSearch.start" />
<choose>
<when test="by == 'userAcnt'">U.USER_ACNT</when>
<when test="by == 'userNm'">U.USER_NM</when>
<when test="by == 'entSeCd'">RE.ENT_SE_CD</when>
<when test="by == 'entNm'">RE.ENT_NM</when>
<when test="by == 'vhrno'">REVM.VHRNO</when>
</choose>
<include refid="dynamicSearch.center" />#{term}<include refid="dynamicSearch.end" />
</when>
<otherwise>
</otherwise>
</choose>
</if>
</where>
<include refid="utility.orderBy" />
<include refid="utility.paging-suffix" />
</select>
<update id="deleteRentEntVhclMpng" parameterType="cokr.xit.fims.rent.RentEntVhclMpng">
/* 임대 기업 차량 매핑 삭제(userRentEntMpngMapper.deleteRentEntVhclMpng) */
UPDATE TB_RENT_ENT_VHCL_MPNG
SET DEL_YN = 'Y'
, DEL_DT = <include refid="utility.now" /> <!-- 삭제 일시 -->
, DLTR = #{modifiedBy} <!-- 삭제자 -->
<choose>
<when test="mpngIds != null">
WHERE MPNG_ID IN ( <!-- 매핑 IDs -->
<foreach collection="mpngIds" item="mpngId" separator=","> #{mpngId} </foreach>
)
</when>
<otherwise>
WHERE MPNG_ID = #{mpngId} <!-- 매핑 ID -->
</otherwise>
</choose>
</update>
<select id="countRentEntVhclMpngInfo" parameterType="cokr.xit.fims.rent.RentEntVhclMpng" resultType="int">
/* 임대 기업 차량 매핑 중복 확인(userRentEntMpngMapper.countRentEntVhclMpngInfo) */
SELECT COUNT(*)
FROM TB_RENT_ENT_VHCL_MPNG
WHERE ENT_ID = #{entId}
AND VHRNO = #{vhrno}
AND DEL_YN = 'N'
</select>
<insert id="createRentEntVhclMpng" parameterType="cokr.xit.fims.rent.RentEntVhclMpng">
/* 임대 기업 차량 매핑 등록(userRentEntMpngMapper.createRentEntVhclMpng) */
<selectKey resultType="string" keyProperty="mpngId" keyColumn="NEW_ID" order="BEFORE">
<include refid="numbering.key">
<property name="TABLE_NAME" value="TB_RENT_ENT_VHCL_MPNG" />
<property name="TABLE_KEY" value="MPNG_ID" />
<property name="pad" value="10" />
</include>
</selectKey>
INSERT
INTO TB_RENT_ENT_VHCL_MPNG (
MPNG_ID <!-- 매핑 ID -->
, ENT_ID <!-- 기업 ID -->
, VHRNO <!-- 차량번호 -->
, DEL_YN <!-- 삭제 여부 -->
, REG_DT <!-- 등록 일시 -->
, RGTR <!-- 등록자 -->
, MDFCN_DT <!-- 수정 일시 -->
, MDFR <!-- 수정자 -->
)
VALUES (
#{mpngId} <!-- 매핑 ID -->
, #{entId} <!-- 기업 ID -->
, #{vhrno} <!-- 차량번호 -->
, 'N' <!-- 삭제 여부 -->
, <include refid="utility.now" /> <!-- 등록 일시 -->
, #{createdBy} <!-- 등록자 -->
, <include refid="utility.now" /> <!-- 수정 일시 -->
, #{createdBy} <!-- 수정자 -->
)
</insert>
</mapper>

Loading…
Cancel
Save