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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user