생산관리
This commit is contained in:
@@ -759,6 +759,10 @@ public class ProductionPlanningService {
|
||||
* @return
|
||||
*/
|
||||
public int saveMbom(HttpServletRequest request, List<Map<String, Object>> mbomData, String partNo, String partName) {
|
||||
return saveMbom(request, mbomData, partNo, partName, "", false);
|
||||
}
|
||||
|
||||
public int saveMbom(HttpServletRequest request, List<Map<String, Object>> mbomData, String partNo, String partName, String mbomPartNo, boolean isUpdate) {
|
||||
SqlSession sqlSession = null;
|
||||
int result = 0;
|
||||
|
||||
@@ -768,23 +772,48 @@ public class ProductionPlanningService {
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
String userId = CommonUtils.checkNull(person.getUserId());
|
||||
|
||||
// M-BOM 헤더 정보 생성
|
||||
Map<String, Object> headerMap = new HashMap<>();
|
||||
headerMap.put("PART_NO", partNo);
|
||||
headerMap.put("PART_NAME", partName);
|
||||
headerMap.put("CREATE_USER", userId);
|
||||
headerMap.put("UPDATE_USER", userId);
|
||||
|
||||
// M-BOM 헤더 저장
|
||||
sqlSession.insert("productionplanning.insertMbomHeader", headerMap);
|
||||
String mbomHeaderObjid = (String) headerMap.get("OBJID");
|
||||
|
||||
// M-BOM 상세 데이터 저장
|
||||
for(Map<String, Object> item : mbomData) {
|
||||
item.put("MBOM_HEADER_OBJID", mbomHeaderObjid);
|
||||
item.put("CREATE_USER", userId);
|
||||
item.put("UPDATE_USER", userId);
|
||||
sqlSession.insert("productionplanning.insertMbomDetail", item);
|
||||
if(isUpdate && !"".equals(mbomPartNo)) {
|
||||
// M-BOM 수정: 기존 데이터 삭제 후 재저장 (동일 품번 유지)
|
||||
// 기존 M-BOM 상세 데이터 삭제
|
||||
Map<String, Object> deleteParam = new HashMap<>();
|
||||
deleteParam.put("MBOM_PART_NO", mbomPartNo);
|
||||
sqlSession.delete("productionplanning.deleteMbomDetailByPartNo", deleteParam);
|
||||
|
||||
// M-BOM 헤더 업데이트
|
||||
Map<String, Object> headerMap = new HashMap<>();
|
||||
headerMap.put("MBOM_PART_NO", mbomPartNo);
|
||||
headerMap.put("PART_NO", partNo);
|
||||
headerMap.put("PART_NAME", partName);
|
||||
headerMap.put("UPDATE_USER", userId);
|
||||
sqlSession.update("productionplanning.updateMbomHeader", headerMap);
|
||||
|
||||
// M-BOM 상세 데이터 재저장
|
||||
for(Map<String, Object> item : mbomData) {
|
||||
item.put("MBOM_PART_NO", mbomPartNo);
|
||||
item.put("CREATE_USER", userId);
|
||||
item.put("UPDATE_USER", userId);
|
||||
sqlSession.insert("productionplanning.insertMbomDetail", item);
|
||||
}
|
||||
} else {
|
||||
// M-BOM 신규 저장
|
||||
// M-BOM 헤더 정보 생성
|
||||
Map<String, Object> headerMap = new HashMap<>();
|
||||
headerMap.put("PART_NO", partNo);
|
||||
headerMap.put("PART_NAME", partName);
|
||||
headerMap.put("CREATE_USER", userId);
|
||||
headerMap.put("UPDATE_USER", userId);
|
||||
|
||||
// M-BOM 헤더 저장
|
||||
sqlSession.insert("productionplanning.insertMbomHeader", headerMap);
|
||||
String mbomHeaderObjid = (String) headerMap.get("OBJID");
|
||||
|
||||
// M-BOM 상세 데이터 저장
|
||||
for(Map<String, Object> item : mbomData) {
|
||||
item.put("MBOM_HEADER_OBJID", mbomHeaderObjid);
|
||||
item.put("CREATE_USER", userId);
|
||||
item.put("UPDATE_USER", userId);
|
||||
sqlSession.insert("productionplanning.insertMbomDetail", item);
|
||||
}
|
||||
}
|
||||
|
||||
sqlSession.commit();
|
||||
@@ -802,4 +831,180 @@ public class ProductionPlanningService {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM Part 연결 (E-BOM의 relatePartInfo와 동일한 로직)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @param partList
|
||||
* @return
|
||||
*/
|
||||
public boolean relateMbomPartInfo(HttpServletRequest request, Map paramMap, List<String> partList){
|
||||
boolean result = false;
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try{
|
||||
HttpSession session = request.getSession();
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
Map info = person.getLoginInfo();
|
||||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||||
|
||||
Map sqlParamMap = new HashMap();
|
||||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(paramMap.get("BOM_REPORT_OBJID")));
|
||||
sqlParamMap.put("PARENT_OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||||
sqlParamMap.put("PARENT_PART_OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||||
sqlParamMap.put("PARENT_PART_NO", CommonUtils.checkNull(paramMap.get("leftPartNoQty")));
|
||||
sqlParamMap.put("PARENT_QTY_CHILD_OBJID", CommonUtils.checkNull(paramMap.get("leftPartChildObjId")));
|
||||
sqlParamMap.put("QTY", 1);
|
||||
sqlParamMap.put("QTY_TEMP", 1);
|
||||
sqlParamMap.put("STATUS", "adding");
|
||||
sqlParamMap.put("WRITER", userId);
|
||||
|
||||
// 각 Part를 BOM_PART_QTY 테이블에 삽입
|
||||
for(String partObjId : partList){
|
||||
sqlParamMap.put("OBJID", CommonUtils.createObjId());
|
||||
sqlParamMap.put("CHILD_OBJID", CommonUtils.createObjId());
|
||||
sqlParamMap.put("PART_NO", partObjId);
|
||||
|
||||
sqlSession.insert("partMng.relatePartInfo", sqlParamMap);
|
||||
|
||||
// 히스토리 저장
|
||||
sqlParamMap.put("OBJID", CommonUtils.checkNull(partObjId));
|
||||
sqlParamMap.put("OBJID_LEFT", CommonUtils.checkNull(paramMap.get("partObjId")));
|
||||
sqlParamMap.put("CHANGE_TYPE", CommonUtils.checkNull(paramMap.get("CHANGE_TYPE")));
|
||||
sqlParamMap.put("HIS_STATUS", "ADD");
|
||||
sqlParamMap.put("CHANGE_OPTION", CommonUtils.checkNull(paramMap.get("CHANGE_OPTION")));
|
||||
sqlSession.update("partMng.insertPartMngHistory",sqlParamMap);
|
||||
}
|
||||
|
||||
// BOM 상태 변경
|
||||
sqlSession.insert("partMng.changeStatusBomReport", sqlParamMap);
|
||||
|
||||
sqlSession.commit();
|
||||
result = true;
|
||||
|
||||
}catch(Exception e){
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM Part 연결 해제 (E-BOM의 deleteStatusPartRelateInfo와 동일한 로직)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteMbomPartRelateInfo(HttpServletRequest request, Map paramMap){
|
||||
boolean result = false;
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try{
|
||||
HttpSession session = request.getSession();
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
Map info = person.getLoginInfo();
|
||||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||||
|
||||
Map sqlParamMap = new HashMap();
|
||||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(paramMap.get("BOM_REPORT_OBJID")));
|
||||
sqlParamMap.put("OBJID", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||||
sqlParamMap.put("PART_OBJID", CommonUtils.checkNull(paramMap.get("partObjId")));
|
||||
sqlParamMap.put("leftPartChildObjId", CommonUtils.checkNull(paramMap.get("leftPartChildObjId")));
|
||||
sqlParamMap.put("leftParentPartNo", CommonUtils.checkNull(paramMap.get("leftParentPartNo")));
|
||||
sqlParamMap.put("leftParentObjId", CommonUtils.checkNull(paramMap.get("leftParentObjId")));
|
||||
sqlParamMap.put("STATUS", "deleting");
|
||||
sqlParamMap.put("WRITER", userId);
|
||||
|
||||
// BOM_PART_QTY 테이블에서 상태를 'deleting'으로 변경
|
||||
sqlSession.update("partMng.deleteStatusPartRelateInfo", sqlParamMap);
|
||||
|
||||
// 히스토리 저장
|
||||
sqlParamMap.put("HIS_STATUS", "DELETE");
|
||||
sqlSession.update("partMng.insertPartMngHistory", sqlParamMap);
|
||||
|
||||
// BOM 상태 변경
|
||||
sqlSession.insert("partMng.changeStatusBomReport", sqlParamMap);
|
||||
|
||||
sqlSession.commit();
|
||||
result = true;
|
||||
|
||||
}catch(Exception e){
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM Part 변경 (E-BOM의 changeRelatePartInfo와 동일한 로직)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
public boolean changeMbomPartInfo(HttpServletRequest request, Map paramMap){
|
||||
boolean result = false;
|
||||
SqlSession sqlSession = null;
|
||||
|
||||
try{
|
||||
HttpSession session = request.getSession();
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
Map info = person.getLoginInfo();
|
||||
String userId = CommonUtils.checkNull(info.get("userId"));
|
||||
|
||||
Map sqlParamMap = new HashMap();
|
||||
sqlParamMap.put("BOM_REPORT_OBJID", CommonUtils.checkNull(paramMap.get("BOM_REPORT_OBJID")));
|
||||
sqlParamMap.put("OBJID", CommonUtils.checkNull(paramMap.get("OBJID")));
|
||||
sqlParamMap.put("rightObjId", CommonUtils.checkNull(paramMap.get("rightObjId")));
|
||||
sqlParamMap.put("leftObjId", CommonUtils.checkNull(paramMap.get("leftObjId")));
|
||||
sqlParamMap.put("leftPartNoQty", CommonUtils.checkNull(paramMap.get("leftPartNoQty")));
|
||||
sqlParamMap.put("leftPartChildObjId", CommonUtils.checkNull(paramMap.get("leftPartChildObjId")));
|
||||
sqlParamMap.put("leftPartObjid", CommonUtils.checkNull(paramMap.get("leftPartObjid")));
|
||||
sqlParamMap.put("rightPartNo", CommonUtils.checkNull(paramMap.get("rightPartNo")));
|
||||
sqlParamMap.put("rightPartRev", CommonUtils.checkNull(paramMap.get("rightPartRev")));
|
||||
sqlParamMap.put("WRITER", userId);
|
||||
|
||||
// BOM_PART_QTY 테이블에서 Part 변경
|
||||
sqlSession.update("partMng.changeRelatePartInfo", sqlParamMap);
|
||||
|
||||
// 히스토리 저장
|
||||
sqlParamMap.put("HIS_STATUS", "CHANGE");
|
||||
sqlSession.update("partMng.insertPartMngHistory", sqlParamMap);
|
||||
|
||||
// BOM 상태 변경
|
||||
sqlSession.insert("partMng.changeStatusBomReport", sqlParamMap);
|
||||
|
||||
sqlSession.commit();
|
||||
result = true;
|
||||
|
||||
}catch(Exception e){
|
||||
if(sqlSession != null) {
|
||||
sqlSession.rollback();
|
||||
}
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user