통계 수정
parent
d0eaac9d9f
commit
58b70d3663
@ -0,0 +1,219 @@
|
||||
package cokr.xit.fims.cmmn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cokr.xit.base.code.CommonCode;
|
||||
import cokr.xit.fims.stat.dao.StatMapper;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
|
||||
public class CodeConverter {
|
||||
|
||||
Map<String, List<CommonCode>> commonCodes = new HashMap<String, List<CommonCode>>();
|
||||
|
||||
List<DataObject> sggList = new ArrayList<DataObject>();
|
||||
List<DataObject> deptList = new ArrayList<DataObject>();
|
||||
List<DataObject> vltnList = new ArrayList<DataObject>();
|
||||
List<DataObject> userList = new ArrayList<DataObject>();
|
||||
|
||||
@Resource(name = "statMapper")
|
||||
private StatMapper statMapper;
|
||||
|
||||
public CodeConverter(Map<String, List<CommonCode>> commonCodes){
|
||||
this.commonCodes = commonCodes;
|
||||
}
|
||||
|
||||
/** 코드값으로 코드를 반환한다.
|
||||
* @param codeGroupName 코드그룹명, value 코드값
|
||||
* @return 코드
|
||||
*/
|
||||
public String valueToCode(String codeGroupName, String value){
|
||||
String result = "";
|
||||
|
||||
List<CommonCode> commonCodeList = commonCodes.get(codeGroupName);
|
||||
|
||||
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||
if(value.replaceAll(Matcher.quoteReplacement(" "), "").equals(commonCodeList.get(i).getValue().replaceAll(Matcher.quoteReplacement(" "), ""))) {
|
||||
result = commonCodeList.get(i).getCode();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 코드로 코드값을 반환한다.
|
||||
* @param codeGroupName 코드그룹명, code 코드
|
||||
* @return 코드값
|
||||
*/
|
||||
public String codeToValue(String codeGroupName, String code){
|
||||
String result = "";
|
||||
|
||||
List<CommonCode> commonCodeList = commonCodes.get(codeGroupName);
|
||||
|
||||
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||
if(code.equals(commonCodeList.get(i).getCode())) {
|
||||
result = commonCodeList.get(i).getValue();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 코드나 코드명이 비어있을 경우 변환하여 값을 채운다.
|
||||
* @param dataObject 맵 데이터, codeGroupName 코드그룹명, codeName 코드가 저장된 키 이름, valueName 코드값이 저장된 키 이름
|
||||
* @return
|
||||
*/
|
||||
public void fillIfEmpty(DataObject dataObject, String codeGroupName, String codeName, String valueName) {
|
||||
if(!dataObject.string(valueName).equals("") && dataObject.string(codeName).equals("")) {
|
||||
dataObject.put(codeName, this.valueToCode(codeGroupName, dataObject.string(valueName)));
|
||||
} else if(dataObject.string(valueName).equals("") && !dataObject.string(codeName).equals("")) {
|
||||
dataObject.put(valueName, this.codeToValue(codeGroupName, dataObject.string(codeName)));
|
||||
}
|
||||
}
|
||||
|
||||
/** 위반코드로 위반항목명을 반환한다.
|
||||
* @param taskSeCd 업무구분코드, vltnCd 위반항목코드
|
||||
* @return 위반항목명
|
||||
*/
|
||||
public String vltnCdToValue(String taskSeCd, String vltnCd) {
|
||||
String result = "";
|
||||
String codeGroup = "";
|
||||
|
||||
switch(taskSeCd){
|
||||
case "PVS" :
|
||||
codeGroup = "FIM004";
|
||||
break;
|
||||
case "BPV" :
|
||||
codeGroup = "FIM005";
|
||||
break;
|
||||
case "DPV" :
|
||||
codeGroup = "FIM006";
|
||||
break;
|
||||
case "ECA" :
|
||||
codeGroup = "FIM061";
|
||||
break;
|
||||
case "TPV" :
|
||||
codeGroup = "FIM064";
|
||||
break;
|
||||
default :
|
||||
throw new RuntimeException("위반코드 변환 오류");
|
||||
}
|
||||
|
||||
List<CommonCode> commonCodeList = commonCodes.get(codeGroup);
|
||||
|
||||
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||
if(vltnCd.equals(commonCodeList.get(i).getCode())) {
|
||||
result = commonCodeList.get(i).getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 위반ID로 위반항목명을 반환한다.
|
||||
* @param vltnId 위반ID
|
||||
* @return 위반항목명
|
||||
*/
|
||||
public String vltnIdToValue(String vltnId){
|
||||
String result = "";
|
||||
|
||||
for(int i = 0; i < vltnList.size(); i++) {
|
||||
if(vltnId.equals(vltnList.get(i).string("VLTN_ID"))) {
|
||||
result = vltnList.get(i).string("VLTN_NM");
|
||||
}
|
||||
}
|
||||
|
||||
if(result.equals("")) {
|
||||
DataObject findRow = statMapper.selectVltnById(vltnId);
|
||||
|
||||
if(findRow != null){
|
||||
vltnList.add(findRow);
|
||||
result = findRow.string("VLTN_NM");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 시군구코드로 시군구명을 반환한다.
|
||||
* @param sggCd 시군구코드
|
||||
* @return 시군구명
|
||||
*/
|
||||
public String sggCodeToValue(String sggCd){
|
||||
String result = "";
|
||||
|
||||
for(int i = 0; i < sggList.size(); i++) {
|
||||
if(sggCd.equals(sggList.get(i).string("SGG_CD"))) {
|
||||
result = sggList.get(i).string("SGG_NM");
|
||||
}
|
||||
}
|
||||
|
||||
if(result.equals("")) {
|
||||
DataObject findRow = statMapper.selectSggByCode(sggCd);
|
||||
|
||||
if(findRow != null){
|
||||
vltnList.add(findRow);
|
||||
result = findRow.string("SGG_NM");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 부서코드로 부서명을 반환한다.
|
||||
* @param deptCd 부서코드
|
||||
* @return 부서명
|
||||
*/
|
||||
public String deptCodeToValue(String deptCd){
|
||||
String result = "";
|
||||
|
||||
for(int i = 0; i < deptList.size(); i++) {
|
||||
if(deptCd.equals(deptList.get(i).string("DEPT_CD"))) {
|
||||
result = deptList.get(i).string("DEPT_NM");
|
||||
}
|
||||
}
|
||||
|
||||
if(result.equals("")) {
|
||||
DataObject findRow = statMapper.selectDeptByCode(deptCd);
|
||||
|
||||
if(findRow != null){
|
||||
vltnList.add(findRow);
|
||||
result = findRow.string("DEPT_NM");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** 유저ID로 유저이름을 반환한다.
|
||||
* @param userId 유저ID
|
||||
* @return 유저이름
|
||||
*/
|
||||
public String userIdToUserName(String userId){
|
||||
String result = "";
|
||||
|
||||
for(int i = 0; i < userList.size(); i++) {
|
||||
if(userId.equals(userList.get(i).string("USER_ID"))) {
|
||||
result = userList.get(i).string("USER_NM");
|
||||
}
|
||||
}
|
||||
|
||||
if(result.equals("")) {
|
||||
DataObject findRow = statMapper.selectUserById(userId);
|
||||
|
||||
if(findRow != null){
|
||||
vltnList.add(findRow);
|
||||
result = findRow.string("USER_NM");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package cokr.xit.fims.crdn.parsing;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import cokr.xit.base.code.CommonCode;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
|
||||
public class CodeConverter {
|
||||
|
||||
Map<String, List<CommonCode>> commonCodes = new HashMap<String, List<CommonCode>>();
|
||||
|
||||
public CodeConverter(Map<String, List<CommonCode>> commonCodes){
|
||||
this.commonCodes = commonCodes;
|
||||
}
|
||||
|
||||
public String valueToCode(String codeGroupName, String value){
|
||||
String result = "";
|
||||
|
||||
List<CommonCode> commonCodeList = commonCodes.get(codeGroupName);
|
||||
|
||||
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||
if(value.replaceAll(Matcher.quoteReplacement(" "), "").equals(commonCodeList.get(i).getValue().replaceAll(Matcher.quoteReplacement(" "), ""))) {
|
||||
result = commonCodeList.get(i).getCode();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String codeToValue(String codeGroupName, String code){
|
||||
String result = "";
|
||||
|
||||
List<CommonCode> commonCodeList = commonCodes.get(codeGroupName);
|
||||
|
||||
for(int i = 0; i < commonCodeList.size(); i++) {
|
||||
if(code.equals(commonCodeList.get(i).getCode())) {
|
||||
result = commonCodeList.get(i).getValue();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void fillIfEmpty(DataObject dataObject, String codeGroupName, String codeName, String valueName) {
|
||||
if(!dataObject.string(valueName).equals("") && dataObject.string(codeName).equals("")) {
|
||||
dataObject.put(codeName, this.valueToCode(codeGroupName, dataObject.string(valueName)));
|
||||
} else if(dataObject.string(valueName).equals("") && !dataObject.string(codeName).equals("")) {
|
||||
dataObject.put(valueName, this.codeToValue(codeGroupName, dataObject.string(codeName)));
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cokr.xit.fims.stat.dao;
|
||||
|
||||
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
|
||||
|
||||
import cokr.xit.foundation.component.AbstractMapper;
|
||||
import cokr.xit.foundation.data.DataObject;
|
||||
|
||||
@Mapper("statMapper")
|
||||
public interface StatMapper extends AbstractMapper {
|
||||
|
||||
DataObject selectVltnById(String vltnId);
|
||||
|
||||
DataObject selectSggByCode(String sggCd);
|
||||
|
||||
DataObject selectDeptByCode(String deptCd);
|
||||
|
||||
DataObject selectUserById(String userId);
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cokr.xit.fims.stat.dao.StatMapper">
|
||||
|
||||
<select id="selectVltnById" parameterType="string" resultType="dataobject">
|
||||
SELECT VLTN_ID
|
||||
, VLTN_NM
|
||||
FROM TB_VLTN_INFO
|
||||
WHERE VLTN_ID = #{vltnId}
|
||||
</select>
|
||||
|
||||
<select id="selectSggByCode" parameterType="string" resultType="dataobject">
|
||||
SELECT SGG_CD
|
||||
, SGG_NM
|
||||
FROM TB_SGG_INFO
|
||||
WHERE SGG_CD = #{sggCd}
|
||||
</select>
|
||||
|
||||
<select id="selectDeptByCode" parameterType="string" resultType="dataobject">
|
||||
SELECT DEPT_CD
|
||||
, DEPT_NM
|
||||
FROM TB_DEPT_INFO
|
||||
WHERE DEPT_CD = #{deptCd}
|
||||
</select>
|
||||
|
||||
<select id="selectUserById" parameterType="string" resultType="dataobject">
|
||||
SELECT USER_ID
|
||||
, USER_NM
|
||||
FROM TB_USER
|
||||
WHERE USER_ID = #{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue