@@ -725,36 +725,6 @@ public class ProductionPlanningService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PROJECT_MGMT에서 E-BOM 제거 (PART_OBJID를 null로 설정)
|
||||
* @param projectMgmtObjid
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int removeEbomFromProject(String projectMgmtObjid) throws Exception {
|
||||
SqlSession sqlSession = null;
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("projectMgmtObjid", projectMgmtObjid);
|
||||
|
||||
int result = sqlSession.update("productionplanning.removeEbomFromProject", paramMap);
|
||||
sqlSession.commit();
|
||||
|
||||
return result;
|
||||
} catch(Exception e) {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* E-BOM 정보 조회
|
||||
* @param bomReportObjid
|
||||
@@ -779,201 +749,4 @@ public class ProductionPlanningService {
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* PROJECT_MGMT 정보 조회
|
||||
* @param projectMgmtObjid
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Object> getProjectMgmtInfo(String projectMgmtObjid) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("objid", projectMgmtObjid);
|
||||
resultMap = sqlSession.selectOne("productionplanning.getProjectMgmtInfo", paramMap);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장된 M-BOM 데이터 조회 (없으면 빈 리스트 반환)
|
||||
* @param projectMgmtObjid
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<Map<String, Object>> getSavedMBomData(String projectMgmtObjid) throws Exception {
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("projectMgmtObjid", projectMgmtObjid);
|
||||
|
||||
// 저장된 M-BOM 데이터 조회
|
||||
resultList = sqlSession.selectList("productionplanning.getSavedMBomData", paramMap);
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* E-BOM 데이터를 기반으로 M-BOM 데이터 조회/생성
|
||||
* @param projectMgmtObjid
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<Map<String, Object>> getMBomDataFromEbom(String projectMgmtObjid) throws Exception {
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
|
||||
// PROJECT_MGMT 정보 조회
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("objid", projectMgmtObjid);
|
||||
|
||||
Map<String, Object> projectInfo = sqlSession.selectOne("productionplanning.getProjectMgmtInfo", paramMap);
|
||||
|
||||
if(projectInfo != null) {
|
||||
// PART_OBJID 사용 (E-BOM의 OBJID)
|
||||
String partObjid = CommonUtils.checkNull(projectInfo.get("PART_OBJID"));
|
||||
|
||||
if(!partObjid.isEmpty()) {
|
||||
// E-BOM이 할당되어 있으면 E-BOM 데이터를 복사하여 M-BOM으로 반환
|
||||
paramMap.put("bomReportObjid", partObjid);
|
||||
resultList = sqlSession.selectList("productionplanning.getMBomDataFromEbom", paramMap);
|
||||
}
|
||||
}
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 데이터 저장
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @throws Exception
|
||||
*/
|
||||
public void saveMBomData(HttpServletRequest request, Map<String, Object> paramMap) throws Exception {
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||||
HttpSession session = request.getSession();
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
String userId = person.getUserId();
|
||||
|
||||
// M-BOM 그리드 데이터 파싱
|
||||
List<Map<String, Object>> gridDataList = JsonUtil.JsonToList(CommonUtils.checkNull(paramMap.get("gridData")));
|
||||
|
||||
String projectMgmtObjid = CommonUtils.checkNull(paramMap.get("projectMgmtObjid"));
|
||||
|
||||
// 기존 M-BOM 데이터 삭제 (필요한 경우)
|
||||
if(!projectMgmtObjid.isEmpty()) {
|
||||
sqlSession.delete("productionplanning.deleteMBomData", paramMap);
|
||||
}
|
||||
|
||||
// M-BOM 데이터 저장
|
||||
for(Map<String, Object> data : gridDataList) {
|
||||
data.put("projectMgmtObjid", projectMgmtObjid);
|
||||
data.put("writer", userId);
|
||||
|
||||
// 항상 새로운 OBJID 생성 (E-BOM의 OBJID와 충돌 방지)
|
||||
data.put("OBJID", CommonUtils.createObjId());
|
||||
|
||||
// 빈 문자열을 null로 변환 (NUMERIC 타입 컬럼들)
|
||||
if(CommonUtils.checkNull(data.get("PARENT_OBJID")).isEmpty()) {
|
||||
data.put("PARENT_OBJID", null);
|
||||
}
|
||||
if(CommonUtils.checkNull(data.get("CHILD_OBJID")).isEmpty()) {
|
||||
data.put("CHILD_OBJID", null);
|
||||
}
|
||||
|
||||
sqlSession.insert("productionplanning.insertMBomData", data);
|
||||
}
|
||||
|
||||
// PROJECT_MGMT의 M-BOM 버전 업데이트
|
||||
Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("projectMgmtObjid", projectMgmtObjid);
|
||||
updateMap.put("writer", userId);
|
||||
sqlSession.update("productionplanning.updateMBomVersion", updateMap);
|
||||
|
||||
sqlSession.commit();
|
||||
|
||||
} catch(Exception e) {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 데이터 삭제
|
||||
* @param projectMgmtObjid
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteMBomData(String projectMgmtObjid) throws Exception {
|
||||
SqlSession sqlSession = null;
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||||
|
||||
Map<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("projectMgmtObjid", projectMgmtObjid);
|
||||
|
||||
// M-BOM 데이터 삭제
|
||||
sqlSession.delete("productionplanning.deleteMBomData", paramMap);
|
||||
|
||||
// PROJECT_MGMT의 MBOM_STATUS를 NULL로 업데이트
|
||||
sqlSession.update("productionplanning.resetMBomStatus", paramMap);
|
||||
|
||||
sqlSession.commit();
|
||||
|
||||
} catch(Exception e) {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user