Merge branch 'main' of https://g.wace.me/chpark/wace_plm into V2025111104

This commit is contained in:
leeheejin
2025-11-14 09:16:24 +09:00
15 changed files with 767 additions and 192 deletions

View File

@@ -6038,7 +6038,7 @@ SELECT T1.LEV, T1.BOM_REPORT_OBJID, T1.ROOT_PART_NO, T1.PATH, T1.LEAF, T2.*
BT.ITEM_QTY,
BT.QTY AS QTY_TEMP,
BT.SEQ,
BT.LEAF,
-- BT.LEAF, -- 재귀 CTE의 LEAF는 항상 0이므로 제거 (아래에서 재계산)
-- PART 정보
PM.OBJID AS PART_OBJID,
PM.PART_NO,
@@ -6424,12 +6424,21 @@ SELECT T1.LEV, T1.BOM_REPORT_OBJID, T1.ROOT_PART_NO, T1.PATH, T1.LEAF, T2.*
)
SELECT
BT.BOM_REPORT_OBJID,
BT.LEV,
BT.LEV AS LEVEL,
-- 역전개는 레벨을 거꾸로 표시 (최상위가 1레벨)
(ML.MAX_LEVEL - BT.LEV + 1) AS LEV,
(ML.MAX_LEVEL - BT.LEV + 1) AS LEVEL,
BT.QTY,
BT.ITEM_QTY,
BT.QTY AS P_QTY,
BT.SEQ,
-- LEAF 계산 (역전개: 하위 항목이 있는지 체크 - 정전개와 동일)
(
SELECT CASE WHEN COUNT(*) > 0 THEN 0 ELSE 1 END
FROM BOM_PART_QTY BPQ2
WHERE BPQ2.PARENT_OBJID = BT.CHILD_OBJID
AND BPQ2.BOM_REPORT_OBJID = BT.BOM_REPORT_OBJID
AND COALESCE(BPQ2.STATUS, '') NOT IN ('deleting', 'deleted')
) AS LEAF,
-- PART 정보
PM.OBJID AS PART_OBJID,
PM.PART_NO,
@@ -6472,7 +6481,7 @@ SELECT T1.LEV, T1.BOM_REPORT_OBJID, T1.ROOT_PART_NO, T1.PATH, T1.LEAF, T2.*
ORDER BY
PBR.REGDATE DESC,
BT.LEV,
(ML.MAX_LEVEL - BT.LEV + 1), -- 역전개: 레벨 역순
BT.PATH
</select>

View File

@@ -7627,29 +7627,65 @@ SELECT
<!-- //영업정보 수정시 프로젝트 정보 업데이트 -->
<update id="ModifyProjectByContract" parameterType="map">
UPDATE PROJECT_MGMT
SET
DUE_DATE = #{due_date}
,CUSTOMER_PROJECT_NAME = #{customer_project_name}
,LOCATION = #{location}
,SETUP = #{setup}
,FACILITY = #{facility}
,FACILITY_TYPE = #{facility_type}
,FACILITY_DEPTH = #{facility_depth}
,CONTRACT_DATE = #{contract_date}
,PO_NO = #{po_no}
,PM_USER_ID = #{pm_user_id}
,CONTRACT_CURRENCY = #{contract_currency}
,CONTRACT_PRICE_CURRENCY = #{contract_price_currency}
,CONTRACT_PRICE = #{contract_price}
,PROJECT_NAME = #{project_name}
,CONTRACT_DEL_DATE = #{contract_del_date}
,REQ_DEL_DATE = #{req_del_date}
,CONTRACT_COMPANY = #{contract_company}
,MANUFACTURE_PLANT = #{manufacture_plant}
,PART_OBJID = #{part_objid}
,PART_NO = #{part_no}
,PART_NAME = #{part_name}
,QUANTITY = #{quantity}
<set>
<if test="due_date != null and due_date != ''">
DUE_DATE = #{due_date},
</if>
<if test="customer_project_name != null and customer_project_name != ''">
CUSTOMER_PROJECT_NAME = #{customer_project_name},
</if>
<if test="location != null and location != ''">
LOCATION = #{location},
</if>
<if test="setup != null and setup != ''">
SETUP = #{setup},
</if>
<if test="facility != null and facility != ''">
FACILITY = #{facility},
</if>
<if test="facility_type != null and facility_type != ''">
FACILITY_TYPE = #{facility_type},
</if>
<if test="facility_depth != null and facility_depth != ''">
FACILITY_DEPTH = #{facility_depth},
</if>
<if test="contract_date != null and contract_date != ''">
CONTRACT_DATE = #{contract_date},
</if>
<if test="po_no != null and po_no != ''">
PO_NO = #{po_no},
</if>
<if test="pm_user_id != null and pm_user_id != ''">
PM_USER_ID = #{pm_user_id},
</if>
<if test="contract_currency != null and contract_currency != ''">
CONTRACT_CURRENCY = #{contract_currency},
</if>
<if test="contract_price_currency != null and contract_price_currency != ''">
CONTRACT_PRICE_CURRENCY = #{contract_price_currency},
</if>
<if test="contract_price != null and contract_price != ''">
CONTRACT_PRICE = #{contract_price},
</if>
<if test="project_name != null and project_name != ''">
PROJECT_NAME = #{project_name},
</if>
<if test="contract_del_date != null and contract_del_date != ''">
CONTRACT_DEL_DATE = #{contract_del_date},
</if>
<if test="req_del_date != null and req_del_date != ''">
REQ_DEL_DATE = #{req_del_date},
</if>
<if test="contract_company != null and contract_company != ''">
CONTRACT_COMPANY = #{contract_company},
</if>
<if test="manufacture_plant != null and manufacture_plant != ''">
MANUFACTURE_PLANT = #{manufacture_plant},
</if>
<if test="quantity != null and quantity != ''">
QUANTITY = #{quantity}
</if>
</set>
WHERE CONTRACT_OBJID = #{objId}
AND PART_OBJID = #{part_objid}
</update>

View File

@@ -1830,6 +1830,40 @@ public class ContractMgmtController {
return "/contractMgmt/estimateRegistFormPopup";
}
/**
* 견적요청 조회 전용 팝업 (View Only)
* @param request
* @param paramMap
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@RequestMapping("/contractMgmt/estimateViewPopup.do")
public String estimateViewPopup(HttpSession session, HttpServletRequest request, @RequestParam Map<String, Object> paramMap){
String objId = CommonUtils.checkNull(paramMap.get("objId"));
try{
Map info = null;
List<Map<String, Object>> itemList = new ArrayList<Map<String, Object>>();
if(paramMap.get("objId")!=null){
paramMap.put("objId",objId);
info = CommonUtils.keyChangeUpperMap(contractMgmtService.getContractMgmtInfo(paramMap));
// 품목 목록 조회
itemList = contractMgmtService.getContractItemList(objId);
}
request.setAttribute("info", info);
request.setAttribute("objId", objId);
request.setAttribute("itemList", itemList);
}catch(Exception e){
e.printStackTrace();
}
return "/contractMgmt/estimateViewPopup";
}
/**
* 품번 검색 (AJAX용)
*/
@@ -2623,4 +2657,43 @@ public class ContractMgmtController {
return resultMap;
}
/**
* 프로젝트 존재 여부 확인 (AJAX)
* @param request
* @param paramMap - contractObjId
* @return
*/
@ResponseBody
@RequestMapping(value="/contractMgmt/checkProjectExists.do", method=RequestMethod.POST)
public Map checkProjectExists(HttpServletRequest request, @RequestParam Map<String, Object> paramMap){
Map resultMap = new HashMap();
try {
String contractObjId = CommonUtils.checkNull(paramMap.get("contractObjId"));
if(StringUtils.isBlank(contractObjId)) {
System.out.println("contractObjId가 비어있음 - exists: false");
resultMap.put("exists", false);
return resultMap;
}
paramMap.put("objId", contractObjId);
Map projectInfo = contractMgmtService.checkProjectExists(paramMap);
if(projectInfo != null) {
resultMap.put("exists", true);
resultMap.put("projectInfo", projectInfo);
} else {
resultMap.put("exists", false);
}
} catch (Exception e) {
e.printStackTrace();
resultMap.put("exists", false);
resultMap.put("error", e.getMessage());
}
return resultMap;
}
}

View File

@@ -1514,8 +1514,11 @@
SELECT
A.OBJID
,A.CATEGORY_CD
,CODE_NAME(A.CATEGORY_CD) AS CATEGORY_NAME
,A.CUSTOMER_OBJID
,(SELECT SUPPLY_NAME FROM SUPPLY_MNG AS O WHERE O.OBJID = A.CUSTOMER_OBJID::NUMERIC) AS CUSTOMER_NAME
,A.PRODUCT
,CODE_NAME(A.PRODUCT) AS PRODUCT_NAME
,A.CUSTOMER_PROJECT_NAME
,A.STATUS_CD
,A.DUE_DATE
@@ -1558,12 +1561,14 @@
,A.EST_COMP_DATE
,A.EST_RESULT_CD
,A.AREA_CD
,CODE_NAME(A.AREA_CD) AS AREA_NAME
,A.TARGET_PROJECT_NO
,A.TARGET_PROJECT_NO_DIRECT
,A.CUSTOMER_PRODUCTION_NO
,A.MECHANICAL_TYPE
,A.OVERHAUL_ORDER
,A.PAID_TYPE
,(case when A.PAID_TYPE = 'paid' then '유상' when A.PAID_TYPE = 'free' then '무상' else A.PAID_TYPE end) AS PAID_TYPE_NAME
,A.RECEIPT_DATE
,A.PART_NO
,A.PART_NAME
@@ -3614,7 +3619,9 @@ ORDER BY ASM.SUPPLY_NAME
<select id="getProjectListBycontractObjid" parameterType="map" resultType="map">
SELECT
PROJECT_NAME
OBJID,
PROJECT_NAME,
PROJECT_NO
FROM
PROJECT_MGMT
WHERE CONTRACT_OBJID = #{objId}

View File

@@ -512,6 +512,35 @@ public class ContractMgmtService {
paramMap.put("writer", person.getUserId());
int cnt = sqlSession.update("contractMgmt.saveContractMgmtInfo", paramMap);
// 프로젝트가 존재하는 경우 프로젝트 정보도 업데이트 (수량 제외)
String contract_objid = CommonUtils.checkNull(paramMap.get("objId"));
if(!"".equals(contract_objid)) {
// CONTRACT_OBJID로 프로젝트 존재 여부 확인
resultList = sqlSession.selectOne("contractMgmt.getProjectListBycontractObjid", paramMap);
if(resultList != null) {
System.out.println("=== 견적요청 수정 시 프로젝트 업데이트 (수량 제외) ===");
System.out.println("CONTRACT_OBJID: " + contract_objid);
// 품목별로 프로젝트 업데이트 (수량은 제외)
List<Map> contractItems = getContractItems(paramMap);
if(contractItems != null && !contractItems.isEmpty()) {
for(Map item : contractItems) {
Map<String, Object> updateParam = new HashMap<String, Object>();
updateParam.putAll(paramMap);
updateParam.put("part_objid", item.get("PART_OBJID"));
updateParam.put("due_date", item.get("DUE_DATE"));
// quantity는 paramMap에서 제거하여 업데이트되지 않도록 함
updateParam.remove("quantity");
System.out.println("프로젝트 업데이트 - PART_OBJID: " + item.get("PART_OBJID") + ", 납기일: " + updateParam.get("due_date"));
sqlSession.update("project.ModifyProjectByContract", updateParam);
}
}
}
}
resultMap.put("result", true);
resultMap.put("msg", Message.SAVE_SUCCESS);
sqlSession.commit();
@@ -2626,39 +2655,36 @@ private String encodeImageToBase64(String imagePath) {
//paramMap.put("contract_price", contract_price/project_cnt + "");
if("0000964".equals(result_cd) || "0000968".equals(result_cd)){
// 품목별로 프로젝트 생성
// CONTRACT_OBJID로 프로젝트 존재 여부 확인 (한 번만 체크)
resultList = sqlSession.selectOne("contractMgmt.getProjectListBycontractObjid", paramMap);
boolean hasProject = (resultList != null);
// 품목별로 프로젝트 생성 또는 업데이트
List<Map> contractItems = getContractItems(paramMap);
if(contractItems != null && !contractItems.isEmpty()) {
System.out.println("품목 개수: " + contractItems.size() + "개 - 품목별 프로젝트 생성 시작");
System.out.println("품목 개수: " + contractItems.size() + "개 - 프로젝트 " + (hasProject ? "업데이트" : "생성") + " 시작");
for(Map item : contractItems) {
// 품목별 프로젝트 존재 여부 확인
Map<String, Object> projectCheckParam = new HashMap<String, Object>();
projectCheckParam.put("contractObjId", contract_objid);
projectCheckParam.put("part_objid", item.get("PART_OBJID"));
resultList = sqlSession.selectOne("contractMgmt.getProjectListByContractAndPartObjid", projectCheckParam);
if(null == resultList) {
// 새 프로젝트 생성
Map<String, Object> projectParam = new HashMap<String, Object>();
projectParam.putAll(paramMap); // 기본 정보 복사
// 품목별 정보 설정
projectParam.put("OBJID", CommonUtils.createObjId());
projectParam.put("is_temp", '1');
projectParam.put("part_objid", item.get("PART_OBJID"));
projectParam.put("part_no", item.get("PART_NO"));
projectParam.put("part_name", item.get("PART_NAME"));
projectParam.put("quantity", item.get("ORDER_QUANTITY") != null ? item.get("ORDER_QUANTITY") : item.get("QUANTITY"));
projectParam.put("due_date", item.get("DUE_DATE"));
if("0000170".equals(category_cd) || "0000171".equals(category_cd)){
projectParam.put("overhaul_project_no", target_project_no);
}
System.out.println("프로젝트 생성 - PART_OBJID: " + item.get("PART_OBJID") + ", 품번: " + item.get("PART_NO") + ", 품명: " + item.get("PART_NAME"));
for(Map item : contractItems) {
if(!hasProject) {
// 프로젝트가 없으면 모든 품목에 대해 생성
Map<String, Object> projectParam = new HashMap<String, Object>();
projectParam.putAll(paramMap); // 기본 정보 복사
// 품목별 정보 설정
projectParam.put("OBJID", CommonUtils.createObjId());
projectParam.put("is_temp", '1');
projectParam.put("part_objid", item.get("PART_OBJID"));
projectParam.put("part_no", item.get("PART_NO"));
projectParam.put("part_name", item.get("PART_NAME"));
projectParam.put("quantity", item.get("ORDER_QUANTITY") != null ? item.get("ORDER_QUANTITY") : item.get("QUANTITY"));
projectParam.put("due_date", item.get("DUE_DATE"));
if("0000170".equals(category_cd) || "0000171".equals(category_cd)){
projectParam.put("overhaul_project_no", target_project_no);
}
System.out.println("프로젝트 생성 - PART_OBJID: " + item.get("PART_OBJID") + ", 품번: " + item.get("PART_NO") + ", 품명: " + item.get("PART_NAME"));
// 프로젝트 등록
cnt = sqlSession.update("project.createProject", projectParam);
@@ -2683,25 +2709,22 @@ private String encodeImageToBase64(String imagePath) {
}
}
}
} else {
// 기존 프로젝트 업데이트
Map<String, Object> updateParam = new HashMap<String, Object>();
updateParam.putAll(paramMap);
updateParam.put("part_objid", item.get("PART_OBJID"));
updateParam.put("part_no", item.get("PART_NO"));
updateParam.put("part_name", item.get("PART_NAME"));
updateParam.put("quantity", item.get("ORDER_QUANTITY") != null ? item.get("ORDER_QUANTITY") : item.get("QUANTITY"));
updateParam.put("due_date", item.get("DUE_DATE"));
System.out.println("프로젝트 업데이트 - PART_OBJID: " + item.get("PART_OBJID") + ", 품번: " + item.get("PART_NO"));
sqlSession.update("project.ModifyProjectByContract", updateParam);
}
} else {
// 프로젝트가 있으면 모든 품목 업데이트 (수량, 금액 등만)
Map<String, Object> updateParam = new HashMap<String, Object>();
updateParam.putAll(paramMap);
updateParam.put("part_objid", item.get("PART_OBJID"));
updateParam.put("quantity", item.get("ORDER_QUANTITY") != null ? item.get("ORDER_QUANTITY") : item.get("QUANTITY"));
updateParam.put("due_date", item.get("DUE_DATE"));
System.out.println("프로젝트 업데이트 - PART_OBJID: " + item.get("PART_OBJID") + ", 수량: " + updateParam.get("quantity"));
sqlSession.update("project.ModifyProjectByContract", updateParam);
}
}
} else {
System.out.println("품목이 없습니다 - 기존 방식으로 프로젝트 생성");
// 품목이 없는 경우 기존 방식대로 처리
resultList = sqlSession.selectOne("contractMgmt.getProjectListBycontractObjid", paramMap);
if(null==resultList){
if(!hasProject){
paramMap.put("OBJID", CommonUtils.createObjId());
paramMap.put("is_temp", '1');
if("0000170".equals(category_cd) || "0000171".equals(category_cd)){
@@ -3270,4 +3293,35 @@ private String encodeImageToBase64(String imagePath) {
return resultMap;
}
/**
* 프로젝트 존재 여부 확인
* @param paramMap - objId (contractObjId)
* @return 프로젝트 정보 (없으면 null)
*/
@SuppressWarnings("rawtypes")
public Map checkProjectExists(Map paramMap) {
SqlSession sqlSession = null;
Map projectInfo = null;
try {
// autoCommit = true로 세션 생성
sqlSession = SqlMapConfig.getInstance().getSqlSession(true);
projectInfo = sqlSession.selectOne("contractMgmt.getProjectListBycontractObjid", paramMap);
if(projectInfo != null) {
projectInfo = CommonUtils.keyChangeUpperMap(projectInfo);
}
} catch(Exception e) {
System.out.println("❌ Service 오류: " + e.getMessage());
e.printStackTrace();
} finally {
if(sqlSession != null) sqlSession.close();
}
System.out.println("Service 최종 반환값: " + projectInfo);
return projectInfo;
}
}