728x90
jsp
<form name="propertyFrm" id="propertyFrm" action="/property/regProc.do" method="post">
<input type="hidden" name="depth1" id="depth1" value="0"/>
<input type="hidden" name="depth2" id="depth2" value="0"/>
<input type="hidden" name="depth3" id="depth3" value="0"/>
<div class="wTableFrm">
<h2>자산 등록</h2>
<table class="wTable">
<colgroup>
<col style="width: 20%;">
<col style="width: ;">
</colgroup>
<tbody>
<tr>
<th>
<label for="pNm">자산 명 <span class="pilsu">*</span></label>
</th>
<td class="left">
<input type="text" id="pNm" name="pNm" placeholder="자산 명을 입력하세요. 자산 명은 필수입니다." title="자산명" required />
</td>
</tr>
<tr>
<th>
<label for="itemCode">품목 선택 <span class="pilsu">*</span></label>
</th>
<td class="left">
<select id="itemCode" name="itemCode" title="품목" required>
<c:forEach var="item" items="${pummogItemList }">
<option value="${item.code }"><c:out value="${item.codeNm }"/></option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<th><label for="pModel">모델 명</label></th>
<td class="left">
<input type="text" id="pModel" name="pModel" placeholder="모델 명을 입력하세요." />
</td>
</tr>
<tr>
<th>
<label for="pModel">바코드 번호</label>
</th>
<td class="left">
<input type="text" id="pBarcode" name="pBarcode" placeholder="바코드 양식을 참고하여 입력해 주세요." required maxlength="10" />
<a href="/property/barcodeInfo.do" target="blank"><span class="noti"><i class="xi-info-o"></i> 바코드 양식을 참고하여 입력해 주세요.</span></a>
</td>
</tr>
<tr>
<th>
<label for="getDate">취득일자 <span class="pilsu">*</span></label>
</th>
<td class="left">
<input class="datepicker" type="text" id="getDate" name="getDate" title="취득일자" required/>
</td>
</tr>
<tr>
<th>
<label for="getPrice">취득가액 <span class="pilsu">*</span></label>
</th>
<td class="left">
<input type="number" id="getPrice" name="getPrice" value="0" title="취득가액" required /> 원
<span class="noti">* 숫자만 입력 가능합니다.</span>
</td>
</tr>
<tr>
<th>
<label for="">자산구분 <span class="pilsu">*</span></label>
</th>
<td class="left">
<select id="pDiv1" name="pDiv1" onChange="fn_selectTopProperty(this.value);" title="자산구분 상위그룹" required>
<option value="">자산 구분값을 선택하세요.</option>
<c:forEach var="property" items="${propertyList }">
<option value="${property.code }"><c:out value="${property.codeNm }"/></option>
</c:forEach>
</select>
<select name="pDiv2" id="pDiv2" title="자산구분" onChange="fn_selectProInfo(this);" required>
<option value="">상위 구분값을 선택하세요.</option>
</select>
<select name="pCalYear" id="pCalYear" title="내용연수" required style="display: none;">
<option value="">자산구분을 선택하세요.</option>
</select>
</td>
</tr>
<tr>
<th>
<label for="tId">부서 <span class="pilsu">*</span></label>
</th>
<td class="left">
<select id="tId" name="tId" title="부서" required>
<c:forEach var="team" items="${teamList }">
<option value="${team.tId }"><c:out value="${team.tNm }"/></option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<th>
<label for="tId">위치 <span class="pilsu">*</span></label>
</th>
<td class="left">
<select name="gDepth_01" id="gDepth_01" onChange="fn_selectByGseq1(this.value);" title="위치" required>
<option value="">그룹을 선택하세요.</option>
<c:forEach var="group" items="${groupsList }">
<option value="${group.gSeq }"><c:out value="${group.gNm }"/></option>
</c:forEach>
</select>
<select name="gDepth_02" id="gDepth_02" onChange="fn_selectByGseq2(this.value);">
<option value="">상위 그룹을 선택하세요.</option>
</select>
<select name="gDepth_03" id="gDepth_03" onChange="fn_setDepth(this.value);">
<option value="">상위 그룹을 선택하세요.</option>
</select>
</td>
</tr>
<tr>
<th>
<label for="manager">담당자 <span class="pilsu">*</span></label>
</th>
<td class="left">
<input type="text" id="manager" name="manager" title="담당자" required />
</td>
</tr>
<tr>
<th>
<label for="manager">자산 이미지 <span class="pilsu">*</span></label>
</th>
<td class="left">
<input type="text" id="atchFileId" name="atchFileId" title="자산 이미지" required />
</td>
</tr>
<tr>
<th>
<label for="getFrom">구매처</label>
</th>
<td class="left">
<input type="text" id="getFrom" name="getFrom" />
</td>
</tr>
<tr>
<th>
<label for="memo">비고 </label>
</th>
<td class="left">
<input type="text" id="memo" name="memo" />
</td>
</tr>
</tbody>
</table>
<div class="btns">
<a class="btn_s" href="javascript:fn_insert();" >자산 등록</a>
<a class="btn_s" href="javascript:fn_list()" >목록</a>
</div>
</div>
</form>
Controller
@Controller
@RequestMapping("/property")
public class PropertyController {
static public final Logger logger = LogManager.getLogger(PropertyController.class);
@Resource(name = "propertiesService")
private EgovPropertyService propertiesService;
@Autowired
private CodeManageService codeManageService;
@Autowired
private TeamsService teamsService;
@Autowired
private GroupsService groupsService;
@Autowired
private PropertyService propertyService;
@RequestMapping("/regProc.do")
public String regProc(PropertyVO vo, ModelMap model) {
logger.info("CALL /property/regProc.do");
// 값을 설정하기 전에 로그
logger.info("자산명 :{} ", vo.getpNm());
logger.info("품목명 :{} ", vo.getpModel());
logger.info("바코드 :{} ", vo.getpBarcode());
logger.info("pid :{} ", vo.getpId());
Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated();
if (!isAuthenticated) {
return "index";
}
String message = "";
String returnUrl = "/property/list.do";
try {
LoginVO user = (LoginVO) EgovUserDetailsHelper.getAuthenticatedUser();
vo.setRegId(user.getUniqId());
int resultCnt = propertyService.regProc(vo);
if (resultCnt == 1) {
message = "자산을 등록하였습니다.";
} else {
message = "자산 등록 중 오류가 발생하였습니다.";
}
model.addAttribute("message", message);
model.addAttribute("returnUrl", returnUrl);
} catch (DataIntegrityViolationException e) {
// 중복 등 데이터 무결성 관련 예외 처리
logger.error("Data integrity violation: {}", e.getMessage(), e);
message = "자산 등록 중 중복된 데이터가 발생하였습니다.";
} catch (Exception | Error e) {
// 그 외 예외 처리
logger.error(e.getMessage(), e);
message = "자산 등록 중 오류가 발생하였습니다.";
}
return "egovframework/com/property/result";
}
}
service
package egovframework.com.property.service;
import java.util.List;
import java.util.Map;
import egovframework.com.property.model.PropertyVO;
public interface PropertyService {
List<PropertyVO> selectList(PropertyVO vo) throws Exception;
int selectListCnt(PropertyVO vo) throws Exception;
PropertyVO selectDetail(PropertyVO vo) throws Exception;
int regProc(PropertyVO vo) throws Exception;
int updProc(PropertyVO vo) throws Exception;
int delProc(PropertyVO vo) throws Exception;
PropertyVO selectByQrNm(String qrNm) throws Exception;
List<Map> statisList() throws Exception;
void selectFirstList(PropertyVO vo) throws Exception;
}
serviceImpl
@Service("propertyService")
public class PropertyServiceImpl implements PropertyService {
static public final Logger logger = LogManager.getLogger(PropertyServiceImpl.class);
@Resource(name = "propertyDAO")
private PropertyDAO propertyDAO;
@Resource(name = "propertyIdGnrService")
private EgovIdGnrService idgenService;
@Override
public List<PropertyVO> selectList(PropertyVO vo) throws Exception {
return propertyDAO.selectList(vo);
}
@Override
public int selectListCnt(PropertyVO vo) throws Exception {
return propertyDAO.selectListCnt(vo);
}
@Override
public PropertyVO selectDetail(PropertyVO vo) throws Exception {
return propertyDAO.selectDetail(vo);
}
@Override
public int regProc(PropertyVO vo) throws Exception {
logger.info("서비스호출 PropertyServiceImpl 자산명: " + vo.getpNm());
// 자산 ID 채번
String propertyId = idgenService.getNextStringId();
vo.setpId(propertyId);
Map qrInfos = createQrCode(propertyId);
vo.setQrCode(String.valueOf(qrInfos.get("qrCodeStr")));
vo.setQrPath(String.valueOf(qrInfos.get("qrCodePath")));
vo.setQrNm(String.valueOf(qrInfos.get("qrCodeName")));
return propertyDAO.regProc(vo);
}
}
DAO
@Repository("propertyDAO")
public class PropertyDAO extends EgovComAbstractDAO {
static public final Logger logger = LogManager.getLogger(PropertyServiceImpl.class);
public int regProc(PropertyVO vo) throws Exception {
logger.info("propertyDAO.regProc 메서드 호출");
logger.info("propertyDAO.regProc 자산명 :" + vo.getpNm());
logger.info("propertyDAO.regProc 자산명 바코드번호: " + vo.getpBarcode());
return insert("propertyDAO.regProc", vo);
}
}
PropertyMapper.xml
<insert id="regProc" parameterType="egovframework.com.property.model.PropertyVO">
INSERT INTO property (
p_id,
item_code,
p_nm,
p_model,
p_barcode,
qr_code,
qr_path,
qr_nm,
get_date,
get_price,
whd,
t_id,
g_id,
depth1,
depth2,
depth3,
p_div1,
p_div2,
p_cal_year,
manager,
user_group,
get_from,
reg_id,
reg_date,
del_yn,
memo,
atch_file_id
) VALUES (
#{pId},
#{itemCode},
#{pNm},
#{pModel},
#{pBarcode},
#{qrCode},
#{qrPath},
#{qrNm},
#{getDate},
#{getPrice},
#{whd},
#{tId},
#{gId},
#{depth1},
#{depth2},
#{depth3},
#{pDiv1},
#{pDiv2},
#{pCalYear},
#{manager},
#{userGroup},
#{getFrom},
#{regId},
SYSDATETIME,
'N',
#{memo},
#{atchFileId}
)
</insert>
PropertyVO
package egovframework.com.property.model;
import egovframework.com.groups.model.GroupsVO;
public class PropertyVO extends GroupsVO {
private static final long serialVersionUID = -594111053602458691L;
private String pId;
private String itemCode = "";
private String itemCodeNm = "";
private String pNm = "";
private String pModel = "";
private String pBarcode = ""; // 10자리 생성규칙 있음
private String qrCode = "";
private String qrPath = "";
private String qrNm = "";
private String getDate;
private long getPrice = 0;
private String getFrom = "";
private String whd = "";
private String tId = "";
private String tNm = "";
private String manager = "";
private String userGroup = "";
private String memo = "";
private String getDepYn = ""; // (올해기준) 감가상각 계산 존재 유무
/** 위치 정보 저장&조회용 */
private int depth1 = 0;
private int depth2 = 0;
private int depth3 = 0;
private String gNm1 = "";
private String gNm2 = "";
private String gNm3 = "";
/** 자산구분 depth1, 2 (property division) **/
private String pDiv1 = "";
private String pDiv2 = "";
private String pCalYear = "";
private String searchUseAt = "";
private String searchPummog = "";
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getpNm() {
return pNm;
}
public void setpNm(String pNm) {
this.pNm = pNm;
}
public String getpModel() {
return pModel;
}
public void setpModel(String pModel) {
this.pModel = pModel;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getQrPath() {
return qrPath;
}
public void setQrPath(String qrPath) {
this.qrPath = qrPath;
}
public String getQrNm() {
return qrNm;
}
public void setQrNm(String qrNm) {
this.qrNm = qrNm;
}
public String getGetDate() {
return getDate;
}
public void setGetDate(String getDate) {
this.getDate = getDate;
}
public long getGetPrice() {
return getPrice;
}
public void setGetPrice(long getPrice) {
this.getPrice = getPrice;
}
public String getGetFrom() {
return getFrom;
}
public void setGetFrom(String getFrom) {
this.getFrom = getFrom;
}
public String getWhd() {
return whd;
}
public void setWhd(String whd) {
this.whd = whd;
}
public String gettId() {
return tId;
}
public void settId(String tId) {
this.tId = tId;
}
public String getManager() {
return manager;
}
public void setManager(String manager) {
this.manager = manager;
}
public String getUserGroup() {
return userGroup;
}
public void setUserGroup(String userGroup) {
this.userGroup = userGroup;
}
public String getMemo() {
return memo;
}
public void setMemo(String memo) {
this.memo = memo;
}
public String getpId() {
return pId;
}
public void setpId(String pId) {
this.pId = pId;
}
public String gettNm() {
return tNm;
}
public void settNm(String tNm) {
this.tNm = tNm;
}
public String getItemCodeNm() {
return itemCodeNm;
}
public void setItemCodeNm(String itemCodeNm) {
this.itemCodeNm = itemCodeNm;
}
public int getDepth1() {
return depth1;
}
public void setDepth1(int depth1) {
this.depth1 = depth1;
}
public int getDepth2() {
return depth2;
}
public void setDepth2(int depth2) {
this.depth2 = depth2;
}
public int getDepth3() {
return depth3;
}
public void setDepth3(int depth3) {
this.depth3 = depth3;
}
public String getgNm1() {
return gNm1;
}
public void setgNm1(String gNm1) {
this.gNm1 = gNm1;
}
public String getgNm2() {
return gNm2;
}
public void setgNm2(String gNm2) {
this.gNm2 = gNm2;
}
public String getgNm3() {
return gNm3;
}
public void setgNm3(String gNm3) {
this.gNm3 = gNm3;
}
public String getpDiv1() {
return pDiv1;
}
public void setpDiv1(String pDiv1) {
this.pDiv1 = pDiv1;
}
public String getpDiv2() {
return pDiv2;
}
public void setpDiv2(String pDiv2) {
this.pDiv2 = pDiv2;
}
public String getpCalYear() {
return pCalYear;
}
public void setpCalYear(String pCalYear) {
this.pCalYear = pCalYear;
}
public String getGetDepYn() {
return getDepYn;
}
public void setGetDepYn(String getDepYn) {
this.getDepYn = getDepYn;
}
@Override
public String getSearchUseAt() {
return searchUseAt;
}
@Override
public void setSearchUseAt(String searchUseAt) {
this.searchUseAt = searchUseAt;
}
public String getSearchPummog() {
return searchPummog;
}
public void setSearchPummog(String searchPummog) {
this.searchPummog = searchPummog;
}
@Override
public String toString() {
return "{pId=" + pId + ", itemCode=" + itemCode + ", itemCodeNm=" + itemCodeNm + ", pNm=" + pNm + ", pModel="
+ pModel + ", qrCode=" + qrCode + ", qrPath=" + qrPath + ", qrNm=" + qrNm + ", getDate=" + getDate
+ ", getPrice=" + getPrice + ", getFrom=" + getFrom + ", whd=" + whd + ", tId=" + tId + ", tNm=" + tNm
+ ", manager=" + manager + ", userGroup=" + userGroup + ", memo=" + memo + ", getDepYn=" + getDepYn
+ ", depth1=" + depth1 + ", depth2=" + depth2 + ", depth3=" + depth3 + ", gNm1=" + gNm1 + ", gNm2="
+ gNm2 + ", gNm3=" + gNm3 + ", pDiv1=" + pDiv1 + ", pDiv2=" + pDiv2 + ", pCalYear=" + pCalYear + "}";
}
public String getpBarcode() {
return pBarcode;
}
public void setpBarcode(String pBarcode) {
this.pBarcode = pBarcode;
}
}
728x90
'SpringBoot' 카테고리의 다른 글
[HttpServletRequest] request 출력 (0) | 2024.07.25 |
---|---|
[Spring Boot] 엑셀 다운로드 (1) | 2024.02.29 |
[JSTL] 날짜사용 (0) | 2023.11.09 |
[Spring Boot] select 검색조건유지 jstl (0) | 2023.11.06 |
[Spring Boot] DAO 검색 (0) | 2023.11.06 |