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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3007,8 +3007,11 @@ SELECT T1.LEV, T1.BOM_REPORT_OBJID, T1.ROOT_PART_NO, T1.PATH, T1.LEAF, T2.*
|
||||
PART_NAME
|
||||
FROM PART_BOM_REPORT
|
||||
WHERE PART_NO = #{partNo}
|
||||
AND (STATUS IS NULL OR STATUS != 'deleted')
|
||||
ORDER BY CREATE_DATE DESC
|
||||
AND PART_NO IS NOT NULL
|
||||
AND TRIM(PART_NO) != ''
|
||||
AND PART_NAME IS NOT NULL
|
||||
AND TRIM(PART_NAME) != ''
|
||||
ORDER BY REGDATE DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
|
||||
@@ -2999,4 +2999,299 @@
|
||||
LEFT JOIN USER_INFO UI ON UI.USER_ID = T.WRITER
|
||||
WHERE T.OBJID::VARCHAR = #{objid}
|
||||
</select>
|
||||
|
||||
<!-- M-BOM 상세 조회 (PROJECT_MGMT + CONTRACT_MGMT 정보) -->
|
||||
<select id="getProjectMgmtDetail" parameterType="map" resultType="com.pms.common.UpperKeyMap">
|
||||
SELECT
|
||||
PM.OBJID,
|
||||
PM.CONTRACT_OBJID,
|
||||
PM.PROJECT_NO,
|
||||
PM.BOM_REPORT_OBJID,
|
||||
PM.PART_NO,
|
||||
PM.PART_NAME,
|
||||
CM.CATEGORY_CD,
|
||||
COALESCE(
|
||||
(SELECT CODE_NAME FROM COMM_CODE WHERE CODE_ID = CM.CATEGORY_CD LIMIT 1),
|
||||
''
|
||||
) AS CATEGORY_NAME,
|
||||
CM.PRODUCT,
|
||||
COALESCE(
|
||||
(SELECT CODE_NAME FROM COMM_CODE WHERE CODE_ID = CM.PRODUCT LIMIT 1),
|
||||
''
|
||||
) AS PRODUCT_NAME,
|
||||
CM.AREA_CD,
|
||||
COALESCE(
|
||||
(SELECT CODE_NAME FROM COMM_CODE WHERE CODE_ID = CM.AREA_CD LIMIT 1),
|
||||
''
|
||||
) AS AREA_NAME,
|
||||
CM.CUSTOMER_OBJID,
|
||||
COALESCE(
|
||||
(SELECT SUPPLY_NAME FROM SUPPLY_MNG WHERE OBJID = CM.CUSTOMER_OBJID::NUMERIC LIMIT 1),
|
||||
''
|
||||
) AS CUSTOMER_NAME,
|
||||
CM.PAID_TYPE,
|
||||
CM.REQ_DEL_DATE,
|
||||
TO_CHAR(PM.REGDATE, 'YYYY-MM-DD') AS RECEIPT_DATE,
|
||||
TO_CHAR(PM.REGDATE, 'YYYY-MM-DD') AS MBOM_REGDATE
|
||||
FROM
|
||||
PROJECT_MGMT PM
|
||||
INNER JOIN CONTRACT_MGMT CM ON PM.CONTRACT_OBJID = CM.OBJID
|
||||
WHERE
|
||||
PM.OBJID::VARCHAR = #{objId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- E-BOM 목록 조회 -->
|
||||
<select id="getEbomList" parameterType="map" resultType="com.pms.common.UpperKeyMap">
|
||||
SELECT
|
||||
T.OBJID,
|
||||
T.PRODUCT_CD,
|
||||
COALESCE(
|
||||
(SELECT CODE_NAME FROM COMM_CODE WHERE CODE_ID = T.PRODUCT_CD LIMIT 1),
|
||||
''
|
||||
) AS PRODUCT_NAME,
|
||||
T.PART_NO,
|
||||
T.PART_NAME,
|
||||
T.STATUS,
|
||||
T.REVISION,
|
||||
TO_CHAR(T.REGDATE, 'YYYY-MM-DD') AS REG_DATE,
|
||||
UI.USER_NAME AS WRITER_NAME,
|
||||
UI.DEPT_NAME,
|
||||
COALESCE(PM.MATERIAL, '') AS MATERIAL,
|
||||
COALESCE(PM.MAKER, '') AS SUPPLIER
|
||||
FROM
|
||||
PART_BOM_REPORT T
|
||||
LEFT JOIN USER_INFO UI ON UI.USER_ID = T.WRITER
|
||||
LEFT JOIN PART_MNG PM ON PM.PART_NO = T.PART_NO AND PM.STATUS = 'release'
|
||||
WHERE 1=1
|
||||
<!-- 품번, 품명이 비어있지 않은 것만 조회 -->
|
||||
AND T.PART_NO IS NOT NULL
|
||||
AND TRIM(T.PART_NO) != ''
|
||||
AND T.PART_NAME IS NOT NULL
|
||||
AND TRIM(T.PART_NAME) != ''
|
||||
<!-- 품번 검색 -->
|
||||
<if test="search_part_no != null and search_part_no != ''">
|
||||
AND UPPER(T.PART_NO) LIKE '%' || UPPER(#{search_part_no}) || '%'
|
||||
</if>
|
||||
<!-- 품명 검색 -->
|
||||
<if test="search_part_name != null and search_part_name != ''">
|
||||
AND UPPER(T.PART_NAME) LIKE '%' || UPPER(#{search_part_name}) || '%'
|
||||
</if>
|
||||
<!-- 재료 검색 -->
|
||||
<if test="search_material != null and search_material != ''">
|
||||
AND UPPER(PM.MATERIAL) LIKE '%' || UPPER(#{search_material}) || '%'
|
||||
</if>
|
||||
<!-- 공급업체 검색 -->
|
||||
<if test="search_supplier != null and search_supplier != ''">
|
||||
AND UPPER(PM.MAKER) LIKE '%' || UPPER(#{search_supplier}) || '%'
|
||||
</if>
|
||||
ORDER BY T.REGDATE DESC
|
||||
LIMIT 100
|
||||
</select>
|
||||
|
||||
<!-- M-BOM 목록 조회 -->
|
||||
<select id="getMbomList" resultType="map" parameterType="map">
|
||||
SELECT
|
||||
MH.OBJID,
|
||||
MH.MBOM_NO,
|
||||
MH.PART_NO,
|
||||
MH.PART_NAME,
|
||||
MH.SAVE_DATE,
|
||||
MH.CREATE_USER,
|
||||
MH.CREATE_DATE,
|
||||
MH.UPDATE_USER,
|
||||
MH.UPDATE_DATE
|
||||
FROM
|
||||
MBOM_HEADER MH
|
||||
WHERE 1=1
|
||||
<!-- 품번 검색 -->
|
||||
<if test="partNo != null and partNo != ''">
|
||||
AND UPPER(MH.PART_NO) LIKE '%' || UPPER(#{partNo}) || '%'
|
||||
</if>
|
||||
<!-- 품명 검색 -->
|
||||
<if test="partName != null and partName != ''">
|
||||
AND UPPER(MH.PART_NAME) LIKE '%' || UPPER(#{partName}) || '%'
|
||||
</if>
|
||||
<!-- M-BOM 품번 검색 -->
|
||||
<if test="mbomPartNo != null and mbomPartNo != ''">
|
||||
AND UPPER(MH.MBOM_NO) LIKE '%' || UPPER(#{mbomPartNo}) || '%'
|
||||
</if>
|
||||
<!-- 저장일 검색 -->
|
||||
<if test="saveDate != null and saveDate != ''">
|
||||
AND DATE(MH.SAVE_DATE) = #{saveDate}
|
||||
</if>
|
||||
ORDER BY MH.SAVE_DATE DESC
|
||||
LIMIT 100
|
||||
</select>
|
||||
|
||||
<!-- M-BOM 상세 데이터 조회 (프로젝트별) -->
|
||||
<select id="getMbomDetailByProject" resultType="map" parameterType="map">
|
||||
SELECT
|
||||
MD.OBJID,
|
||||
MD.MBOM_HEADER_OBJID,
|
||||
MD.PART_NO,
|
||||
MD.PART_NAME,
|
||||
MD.QTY,
|
||||
MD.QTY_TEMP,
|
||||
MD.ITEM_QTY,
|
||||
MD.LEVEL,
|
||||
MD.REVISION,
|
||||
MD.SPEC,
|
||||
MD.PRODUCT_NAME,
|
||||
MD.STATUS_NAME,
|
||||
MD.LEVEL_1,
|
||||
MD.LEVEL_2,
|
||||
MD.LEVEL_3,
|
||||
MD.LEVEL_4,
|
||||
MD.LEVEL_5,
|
||||
MD.LEVEL_6,
|
||||
MD.LEVEL_7,
|
||||
MD.LEVEL_8,
|
||||
MD.LEVEL_9,
|
||||
MD.LEVEL_10
|
||||
FROM
|
||||
MBOM_DETAIL MD
|
||||
INNER JOIN
|
||||
MBOM_HEADER MH ON MD.MBOM_HEADER_OBJID = MH.OBJID
|
||||
WHERE
|
||||
MH.PROJECT_MGMT_OBJID = #{objId}
|
||||
ORDER BY
|
||||
MD.LEVEL, MD.PART_NO
|
||||
</select>
|
||||
|
||||
<!-- M-BOM 헤더 저장 -->
|
||||
<insert id="insertMbomHeader" parameterType="map">
|
||||
<selectKey keyProperty="OBJID" resultType="string" order="BEFORE">
|
||||
SELECT REPLACE(UUID(),'-','') FROM DUAL
|
||||
</selectKey>
|
||||
INSERT INTO MBOM_HEADER (
|
||||
OBJID,
|
||||
MBOM_NO,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
SAVE_DATE,
|
||||
CREATE_USER,
|
||||
CREATE_DATE,
|
||||
UPDATE_USER,
|
||||
UPDATE_DATE
|
||||
) VALUES (
|
||||
#{OBJID},
|
||||
CONCAT('MBOM-', DATE_FORMAT(NOW(), '%Y%m%d%H%i%s')),
|
||||
#{PART_NO},
|
||||
#{PART_NAME},
|
||||
NOW(),
|
||||
#{CREATE_USER},
|
||||
NOW(),
|
||||
#{UPDATE_USER},
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- M-BOM 상세 저장 -->
|
||||
<insert id="insertMbomDetail" parameterType="map">
|
||||
<selectKey keyProperty="OBJID" resultType="string" order="BEFORE">
|
||||
SELECT REPLACE(UUID(),'-','') FROM DUAL
|
||||
</selectKey>
|
||||
INSERT INTO MBOM_DETAIL (
|
||||
OBJID,
|
||||
MBOM_HEADER_OBJID,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
QTY,
|
||||
LEVEL,
|
||||
REVISION,
|
||||
SPEC,
|
||||
PRODUCT_NAME,
|
||||
STATUS_NAME,
|
||||
CREATE_USER,
|
||||
CREATE_DATE,
|
||||
UPDATE_USER,
|
||||
UPDATE_DATE
|
||||
) VALUES (
|
||||
#{OBJID},
|
||||
#{MBOM_HEADER_OBJID},
|
||||
#{PART_NO},
|
||||
#{PART_NAME},
|
||||
#{QTY},
|
||||
#{LEVEL},
|
||||
#{REVISION},
|
||||
#{SPEC},
|
||||
#{PRODUCT_NAME},
|
||||
#{STATUS_NAME},
|
||||
#{CREATE_USER},
|
||||
NOW(),
|
||||
#{UPDATE_USER},
|
||||
NOW()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- E-BOM을 M-BOM으로 복사 -->
|
||||
<insert id="saveMbomFromEbom" parameterType="map">
|
||||
/* productionplanning.saveMbomFromEbom - E-BOM을 M-BOM으로 복사 */
|
||||
/* 1. 새로운 PART_BOM_REPORT 생성 (M-BOM용) */
|
||||
WITH new_bom_report AS (
|
||||
INSERT INTO PART_BOM_REPORT (
|
||||
OBJID,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
WRITER,
|
||||
REGDATE,
|
||||
STATUS
|
||||
) VALUES (
|
||||
(SELECT (FLOOR(RANDOM() * 1000000000) + 1000000000)::INTEGER),
|
||||
#{PART_NO},
|
||||
#{PART_NAME},
|
||||
#{USER_ID},
|
||||
NOW(),
|
||||
'Y'
|
||||
)
|
||||
RETURNING OBJID
|
||||
),
|
||||
/* 2. E-BOM의 BOM_PART_QTY 데이터를 새 M-BOM으로 복사 */
|
||||
copied_bom_data AS (
|
||||
INSERT INTO BOM_PART_QTY (
|
||||
BOM_REPORT_OBJID,
|
||||
OBJID,
|
||||
PARENT_OBJID,
|
||||
CHILD_OBJID,
|
||||
PARENT_PART_NO,
|
||||
PART_NO,
|
||||
QTY,
|
||||
ITEM_QTY,
|
||||
QTY_TEMP,
|
||||
REGDATE,
|
||||
WRITER,
|
||||
SEQ,
|
||||
STATUS,
|
||||
LAST_PART_OBJID
|
||||
)
|
||||
SELECT
|
||||
(SELECT OBJID FROM new_bom_report),
|
||||
(SELECT (FLOOR(RANDOM() * 1000000000) + 1000000000 + ROW_NUMBER() OVER (ORDER BY OBJID))::INTEGER),
|
||||
PARENT_OBJID,
|
||||
CHILD_OBJID,
|
||||
PARENT_PART_NO,
|
||||
PART_NO,
|
||||
QTY,
|
||||
ITEM_QTY,
|
||||
QTY_TEMP,
|
||||
NOW(),
|
||||
#{USER_ID},
|
||||
ROW_NUMBER() OVER (ORDER BY OBJID),
|
||||
'adding',
|
||||
LAST_PART_OBJID
|
||||
FROM BOM_PART_QTY
|
||||
WHERE BOM_REPORT_OBJID::VARCHAR = #{SOURCE_BOM_OBJID}
|
||||
AND COALESCE(STATUS, '') NOT IN ('deleting', 'deleted')
|
||||
RETURNING 1
|
||||
)
|
||||
/* 3. PROJECT_MGMT 업데이트 */
|
||||
UPDATE PROJECT_MGMT
|
||||
SET
|
||||
BOM_REPORT_OBJID = (SELECT OBJID FROM new_bom_report),
|
||||
MBOM_STATUS = 'Y',
|
||||
PART_NO = #{PART_NO},
|
||||
PART_NAME = #{PART_NAME}
|
||||
WHERE OBJID::VARCHAR = #{PROJECT_OBJID}
|
||||
</insert>
|
||||
</mapper>
|
||||
|
||||
@@ -749,4 +749,57 @@ public class ProductionPlanningService {
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* M-BOM 저장
|
||||
* @param request
|
||||
* @param mbomData
|
||||
* @param partNo
|
||||
* @param partName
|
||||
* @return
|
||||
*/
|
||||
public int saveMbom(HttpServletRequest request, List<Map<String, Object>> mbomData, String partNo, String partName) {
|
||||
SqlSession sqlSession = null;
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
sqlSession = SqlMapConfig.getInstance().getSqlSession(false);
|
||||
HttpSession session = request.getSession();
|
||||
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);
|
||||
}
|
||||
|
||||
sqlSession.commit();
|
||||
result = 1;
|
||||
} 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