auto commit
This commit is contained in:
@@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -888,23 +889,110 @@ public class PartMngController {
|
||||
}
|
||||
|
||||
/**
|
||||
* bom copy 저장
|
||||
* BOM COPY (M-BOM 관리에서 호출)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/partMng/structureBomCopyFormPopup.do")
|
||||
public String structureBomCopyFormPopup(HttpServletRequest request, @RequestParam Map<String, Object> paramMap){
|
||||
try {
|
||||
String objId = CommonUtils.checkNull((String)paramMap.get("objId"));
|
||||
System.out.println("========== structureBomCopyFormPopup ==========");
|
||||
System.out.println("objId: " + objId);
|
||||
|
||||
// objId를 항상 설정 (음수 포함)
|
||||
request.setAttribute("TARGET_OBJID", objId);
|
||||
|
||||
// objId가 유효한 경우 프로젝트 정보 조회 (음수도 유효한 OBJID임)
|
||||
if(!"".equals(objId) && !"-1".equals(objId)) {
|
||||
try {
|
||||
long objIdLong = Long.parseLong(objId);
|
||||
System.out.println("objIdLong: " + objIdLong);
|
||||
|
||||
// PROJECT_MGMT 테이블에서 품번/품명 조회 (M-BOM 관리 리스트의 OBJID는 PROJECT_MGMT의 OBJID)
|
||||
Map<String, Object> projectInfo = commonService.selectOne("productionplanning.getProjectMgmtDetail", request, paramMap);
|
||||
System.out.println("projectInfo: " + projectInfo);
|
||||
|
||||
if(projectInfo != null) {
|
||||
System.out.println("PART_NO: " + projectInfo.get("PART_NO"));
|
||||
System.out.println("PART_NAME: " + projectInfo.get("PART_NAME"));
|
||||
request.setAttribute("projectInfo", projectInfo);
|
||||
} else {
|
||||
System.out.println("projectInfo is null!");
|
||||
}
|
||||
} catch(NumberFormatException nfe) {
|
||||
System.out.println("NumberFormatException: " + nfe.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
Map code_map = new HashMap();
|
||||
code_map.put("rev", commonService.bizMakeOptionList("", "", "common.getRevNoselect"));
|
||||
code_map.put("product_code", commonService.bizMakeOptionList("", "", "common.getProductNoselect"));
|
||||
request.setAttribute("code_map", code_map);
|
||||
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "/partMng/structureBomCopyFormPopup";
|
||||
}
|
||||
|
||||
/**
|
||||
* bom copy 저장 (E-BOM을 M-BOM으로 복사)
|
||||
*/
|
||||
@RequestMapping("/partMng/saveBomCopy.do")
|
||||
@ResponseBody
|
||||
public String saveBomCopySave(HttpSession session, HttpServletRequest request, @RequestParam Map paramMap){
|
||||
String result = "";
|
||||
public Map<String, Object> saveBomCopySave(HttpSession session, HttpServletRequest request, @RequestBody Map<String, Object> paramMap){
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
try{
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
paramMap.put("CONNECTUSERID", CommonUtils.checkNull(person.getUserId()));
|
||||
System.out.println("========== saveBomCopy ==========");
|
||||
System.out.println("paramMap: " + paramMap);
|
||||
|
||||
partMngService.saveBomCopySave(request, paramMap);
|
||||
result = "SUCCESS";
|
||||
PersonBean person = (PersonBean)session.getAttribute(Constants.PERSON_BEAN);
|
||||
String userId = person.getUserId();
|
||||
|
||||
// targetObjId: PROJECT_MGMT의 OBJID
|
||||
String targetObjId = CommonUtils.checkNull((String)paramMap.get("targetObjId"));
|
||||
String sourceBomObjId = CommonUtils.checkNull((String)paramMap.get("sourceBomObjId"));
|
||||
String targetPartNo = CommonUtils.checkNull((String)paramMap.get("targetPartNo"));
|
||||
String targetPartName = CommonUtils.checkNull((String)paramMap.get("targetPartName"));
|
||||
List<Map<String, Object>> bomData = (List<Map<String, Object>>)paramMap.get("bomData");
|
||||
|
||||
if(bomData == null || bomData.isEmpty()) {
|
||||
resultMap.put("result", "fail");
|
||||
resultMap.put("message", "복사할 BOM 데이터가 없습니다.");
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
// M-BOM 저장
|
||||
Map<String, Object> saveParam = new HashMap<String, Object>();
|
||||
saveParam.put("PROJECT_OBJID", targetObjId);
|
||||
saveParam.put("SOURCE_BOM_OBJID", sourceBomObjId);
|
||||
saveParam.put("PART_NO", targetPartNo);
|
||||
saveParam.put("PART_NAME", targetPartName);
|
||||
saveParam.put("BOM_DATA", bomData);
|
||||
saveParam.put("USER_ID", userId);
|
||||
|
||||
// SqlSession을 통해 직접 실행
|
||||
SqlSession sqlSession = SqlMapConfig.getInstance().getSqlSession();
|
||||
try {
|
||||
sqlSession.insert("productionplanning.saveMbomFromEbom", saveParam);
|
||||
sqlSession.commit();
|
||||
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("message", "M-BOM이 성공적으로 생성되었습니다.");
|
||||
} finally {
|
||||
if(sqlSession != null) {
|
||||
sqlSession.close();
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
result = "FAIL";
|
||||
resultMap.put("result", "fail");
|
||||
resultMap.put("message", "BOM 복사 중 오류가 발생했습니다: " + e.getMessage());
|
||||
}
|
||||
return result;
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,10 +9,12 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.pms.common.service.BaseService;
|
||||
import com.pms.common.utils.CommonUtils;
|
||||
import com.pms.common.utils.Constants;
|
||||
@@ -934,13 +936,140 @@ public class ProductionPlanningController extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 팝업
|
||||
* M-BOM 조회 팝업 (읽기 전용)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomViewPopup.do")
|
||||
public String mBomViewPopup(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
return "/productionplanning/mBomViewPopup";
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 복사 팝업 메인 (frameset)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomFormPopup.do")
|
||||
public String mBomFormPopup(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
try {
|
||||
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||||
System.out.println("========== mBomFormPopup ==========");
|
||||
System.out.println("objId: " + objId);
|
||||
|
||||
// PROJECT_MGMT 정보 조회
|
||||
if(!"".equals(objId)) {
|
||||
paramMap.put("objId", objId);
|
||||
Map<String, Object> projectInfo = commonService.selectOne("productionplanning.getProjectMgmtDetail", request, paramMap);
|
||||
System.out.println("projectInfo: " + projectInfo);
|
||||
|
||||
if(projectInfo != null && !projectInfo.isEmpty()) {
|
||||
request.setAttribute("info", projectInfo);
|
||||
} else {
|
||||
System.out.println("projectInfo is null or empty!");
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "/productionplanning/mBomPopupHeaderFs";
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 조회 팝업 상단 헤더
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomHeaderPopup.do")
|
||||
public String mBomHeaderPopup(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
try {
|
||||
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||||
if(!"".equals(objId)) {
|
||||
paramMap.put("objId", objId);
|
||||
Map<String, Object> projectInfo = commonService.selectOne("productionplanning.getProjectMgmtDetail", request, paramMap);
|
||||
request.setAttribute("info", projectInfo);
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "/productionplanning/mBomHeaderPopup";
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 조회 팝업 중앙 버튼 영역
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomCenterBtnPopup.do")
|
||||
public String mBomCenterBtnPopup(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
return "/productionplanning/mBomCenterBtnPopup";
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 조회 팝업 중앙 버튼 영역
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomPopupCenter.do")
|
||||
public String mBomPopupCenter(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
return "/productionplanning/mBomPopupCenter";
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 조회 팝업 오른쪽 E-BOM 목록
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomPopupRight.do")
|
||||
public String mBomPopupRight(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
return "/productionplanning/mBomPopupRight";
|
||||
}
|
||||
|
||||
/**
|
||||
* E-BOM 목록 조회 (AJAX)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/getEbomList.do")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getEbomList(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
List<Map<String, Object>> list = commonService.selectList("productionplanning.getEbomList", request, paramMap);
|
||||
result.put("list", list);
|
||||
result.put("result", true);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
result.put("result", false);
|
||||
result.put("list", new ArrayList<>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 조회 팝업 하단 frameset
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomBottomPopupFS.do")
|
||||
public String mBomBottomPopupFS(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
return "/productionplanning/mBomPopupFs";
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 조회 팝업 왼쪽 트리
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/productionplanning/mBomPopupLeft.do")
|
||||
public String mBomPopupLeft(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
String objId = CommonUtils.checkNull(paramMap.get("objId"));
|
||||
|
||||
@@ -948,10 +1077,27 @@ public class ProductionPlanningController extends BaseService {
|
||||
if(!"".equals(objId)) {
|
||||
paramMap.put("objId", objId);
|
||||
Map<String, Object> projectInfo = commonService.selectOne("productionplanning.getProjectMgmtDetail", request, paramMap);
|
||||
request.setAttribute("info", projectInfo);
|
||||
|
||||
// 할당된 E-BOM 정보 조회
|
||||
if(projectInfo != null) {
|
||||
// 1. 먼저 저장된 M-BOM 데이터가 있는지 확인
|
||||
List<Map<String, Object>> mbomDetailList = commonService.selectList("productionplanning.getMbomDetailByProject", request, paramMap);
|
||||
|
||||
if(mbomDetailList != null && !mbomDetailList.isEmpty()) {
|
||||
// 저장된 M-BOM 데이터가 있으면 이를 표시
|
||||
int maxLevel = 1;
|
||||
for(Map<String, Object> item : mbomDetailList) {
|
||||
Integer level = (Integer) item.get("LEVEL");
|
||||
if(level != null && level > maxLevel) {
|
||||
maxLevel = level;
|
||||
}
|
||||
}
|
||||
|
||||
request.setAttribute("MAXLEV", maxLevel);
|
||||
request.setAttribute("bomTreeListJson", gson.toJson(mbomDetailList));
|
||||
return "/productionplanning/mBomPopupLeft";
|
||||
}
|
||||
|
||||
// 저장된 M-BOM이 없으면 할당된 E-BOM 정보 조회
|
||||
String bomReportObjid = CommonUtils.checkNull(projectInfo.get("BOM_REPORT_OBJID"));
|
||||
if(!"".equals(bomReportObjid)) {
|
||||
Map<String, Object> ebomParam = new HashMap<>();
|
||||
@@ -964,14 +1110,31 @@ public class ProductionPlanningController extends BaseService {
|
||||
|
||||
// BOM 트리 데이터 조회 (레벨 정보 포함)
|
||||
List<Map<String, Object>> bomTreeList = commonService.selectList("partMng.getBOMTreeList", request, ebomParam);
|
||||
request.setAttribute("bomTreeList", bomTreeList);
|
||||
|
||||
if(bomTreeList != null && !bomTreeList.isEmpty()) {
|
||||
// MAX LEVEL 계산
|
||||
int maxLevel = 1;
|
||||
for(Map<String, Object> item : bomTreeList) {
|
||||
Integer level = (Integer) item.get("LEVEL");
|
||||
if(level != null && level > maxLevel) {
|
||||
maxLevel = level;
|
||||
}
|
||||
}
|
||||
request.setAttribute("MAXLEV", maxLevel);
|
||||
request.setAttribute("bomTreeListJson", gson.toJson(bomTreeList));
|
||||
return "/productionplanning/mBomPopupLeft";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "/productionplanning/mBomFormPopup";
|
||||
|
||||
// 데이터가 없을 때 빈 배열 설정
|
||||
request.setAttribute("MAXLEV", 1);
|
||||
request.setAttribute("bomTreeListJson", "[]");
|
||||
return "/productionplanning/mBomPopupLeft";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1011,4 +1174,67 @@ public class ProductionPlanningController extends BaseService {
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 목록 조회 (검색 조건 포함)
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping("/productionplanning/getMbomList.do")
|
||||
public Map<String, Object> getMbomList(HttpServletRequest request, @RequestParam Map<String, Object> paramMap) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
try {
|
||||
// 검색 조건에 맞는 M-BOM 목록 조회
|
||||
List<Map<String, Object>> list = commonService.selectList("productionplanning.getMbomList", request, paramMap);
|
||||
result.put("list", list);
|
||||
result.put("result", true);
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
result.put("result", false);
|
||||
result.put("list", new ArrayList<>());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 저장
|
||||
* @param request
|
||||
* @param paramMap
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@RequestMapping("/productionplanning/saveMbom.do")
|
||||
public Map<String, Object> saveMbom(HttpServletRequest request, @RequestBody Map<String, Object> paramMap) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
try {
|
||||
// M-BOM 데이터 저장 로직
|
||||
List<Map<String, Object>> mbomData = (List<Map<String, Object>>) paramMap.get("mbomData");
|
||||
String partNo = CommonUtils.checkNull(paramMap.get("partNo"));
|
||||
String partName = CommonUtils.checkNull(paramMap.get("partName"));
|
||||
|
||||
if(mbomData == null || mbomData.isEmpty()) {
|
||||
resultMap.put("result", "fail");
|
||||
resultMap.put("message", "저장할 데이터가 없습니다.");
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
// M-BOM 저장 서비스 호출
|
||||
int saveResult = productionPlanningService.saveMbom(request, mbomData, partNo, partName);
|
||||
|
||||
if(saveResult > 0) {
|
||||
resultMap.put("result", "success");
|
||||
resultMap.put("message", "M-BOM이 저장되었습니다.");
|
||||
} else {
|
||||
resultMap.put("result", "fail");
|
||||
resultMap.put("message", "저장에 실패했습니다.");
|
||||
}
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
resultMap.put("result", "fail");
|
||||
resultMap.put("message", "오류가 발생했습니다: " + e.getMessage());
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user