품목 정보 API 연계계
This commit is contained in:
@@ -2689,7 +2689,7 @@ INSERT INTO OEM_MNG
|
||||
VALUES
|
||||
(
|
||||
#{objid}::numeric,
|
||||
LPAD(nextval('seq_comm_code')::varchar,7,'0'),
|
||||
LPAD((COALESCE((SELECT MAX(CODE_ID::numeric) FROM COMM_CODE WHERE CODE_ID ~ '^[0-9]+$'), 0) + 1)::varchar, 7, '0'),
|
||||
#{parentCodeId},
|
||||
#{codeName},
|
||||
#{id},
|
||||
|
||||
@@ -3394,6 +3394,4 @@ ORDER BY PATH,
|
||||
AND PART_NO = #{OBJID}
|
||||
) T
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -926,7 +926,17 @@
|
||||
(SELECT USER_NAME FROM USER_INFO WHERE USER_ID = T.PM_USER_ID)
|
||||
) AS MANAGER,
|
||||
COALESCE(SR.incoterms, '') AS INCOTERMS,
|
||||
T.SALES_STATUS,
|
||||
-- 판매상태: 수주수량과 판매수량 비교하여 동적 계산
|
||||
CASE
|
||||
WHEN COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) = 0
|
||||
THEN '미판매'
|
||||
WHEN COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) >= COALESCE(T.QUANTITY::numeric, 0)
|
||||
THEN '완판'
|
||||
WHEN COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) > 0
|
||||
AND COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) <![CDATA[<]]> COALESCE(T.QUANTITY::numeric, 0)
|
||||
THEN '분할판매'
|
||||
ELSE ''
|
||||
END AS SALES_STATUS,
|
||||
T.OBJID::VARCHAR AS SALE_NO,
|
||||
'ORIGINAL' AS RECORD_TYPE,
|
||||
'' AS SPLIT_LOG_ID,
|
||||
@@ -1069,15 +1079,27 @@
|
||||
AND SR.project_no IS NOT NULL
|
||||
AND SR.incoterms = #{incoterms}
|
||||
</if>
|
||||
<if test="salesStatus != null and salesStatus != ''">
|
||||
<choose>
|
||||
<when test="salesStatus == 'NOT_CLOSED'">
|
||||
AND (T.SALES_STATUS IS NULL OR T.SALES_STATUS = '' OR T.SALES_STATUS != '완료')
|
||||
</when>
|
||||
<otherwise>
|
||||
AND T.SALES_STATUS = #{salesStatus}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<!-- 판매상태 검색 (멀티 선택 지원) - 동적 계산 기준 -->
|
||||
<if test="salesStatus != null and salesStatus.size() > 0">
|
||||
AND (
|
||||
1=0
|
||||
<foreach item="item" collection="salesStatus">
|
||||
<!-- 완판: 0900208 -->
|
||||
<if test="'0900208'.equals(item)">
|
||||
OR (COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) >= COALESCE(T.QUANTITY::numeric, 0)
|
||||
AND COALESCE(T.QUANTITY::numeric, 0) > 0)
|
||||
</if>
|
||||
<!-- 분할판매: 0900209 -->
|
||||
<if test="'0900209'.equals(item)">
|
||||
OR (COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) > 0
|
||||
AND COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) <![CDATA[<]]> COALESCE(T.QUANTITY::numeric, 0))
|
||||
</if>
|
||||
<!-- 미판매: 0900210 -->
|
||||
<if test="'0900210'.equals(item)">
|
||||
OR COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) = 0
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 매출마감 기간 검색 -->
|
||||
<if test="salesDeadlineFrom != null and salesDeadlineFrom != ''">
|
||||
@@ -1248,15 +1270,27 @@ ORDER BY T.REGDATE DESC, T.PROJECT_NO DESC
|
||||
AND SR.incoterms = #{incoterms}
|
||||
)
|
||||
</if>
|
||||
<if test="salesStatus != null and salesStatus != ''">
|
||||
<choose>
|
||||
<when test="salesStatus == 'NOT_CLOSED'">
|
||||
AND (T.SALES_STATUS IS NULL OR T.SALES_STATUS = '' OR T.SALES_STATUS != '완료')
|
||||
</when>
|
||||
<otherwise>
|
||||
AND T.SALES_STATUS = #{salesStatus}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<!-- 판매상태 검색 (멀티 선택 지원) - 동적 계산 기준 -->
|
||||
<if test="salesStatus != null and salesStatus.size() > 0">
|
||||
AND (
|
||||
1=0
|
||||
<foreach item="item" collection="salesStatus">
|
||||
<!-- 완판: 0900208 -->
|
||||
<if test="'0900208'.equals(item)">
|
||||
OR (COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) >= COALESCE(T.QUANTITY::numeric, 0)
|
||||
AND COALESCE(T.QUANTITY::numeric, 0) > 0)
|
||||
</if>
|
||||
<!-- 분할판매: 0900209 -->
|
||||
<if test="'0900209'.equals(item)">
|
||||
OR (COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) > 0
|
||||
AND COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) <![CDATA[<]]> COALESCE(T.QUANTITY::numeric, 0))
|
||||
</if>
|
||||
<!-- 미판매: 0900210 -->
|
||||
<if test="'0900210'.equals(item)">
|
||||
OR COALESCE((SELECT SUM(sales_quantity) FROM sales_registration WHERE project_no LIKE T.PROJECT_NO || '%'), 0) = 0
|
||||
</if>
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<!-- 매출마감 기간 검색 -->
|
||||
<if test="salesDeadlineFrom != null and salesDeadlineFrom != ''">
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
fn_delete();
|
||||
});
|
||||
|
||||
//ERP 창고 동기화
|
||||
$("#btnSyncErp").click(function(){
|
||||
fn_syncErp();
|
||||
});
|
||||
|
||||
fn_search();
|
||||
});
|
||||
</script>
|
||||
@@ -124,6 +129,52 @@ function openwarehouseListInfoPopUp(objid){
|
||||
hiddenForm.action = "/admin/warehouseListFormPopUp.do";
|
||||
hiddenForm.submit();
|
||||
}
|
||||
|
||||
function fn_syncErp(){
|
||||
if(confirm("ERP 시스템의 창고 정보를 동기화하시겠습니까?")){
|
||||
// 로딩 표시
|
||||
Swal.fire({
|
||||
title: '동기화 중...',
|
||||
text: 'ERP 창고 데이터를 가져오는 중입니다. 잠시만 기다려주세요.',
|
||||
allowOutsideClick: false,
|
||||
didOpen: () => {
|
||||
Swal.showLoading();
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/admin/syncWarehouseDataManual.do",
|
||||
dataType:"json",
|
||||
success:function(data){
|
||||
Swal.close();
|
||||
if(data.success){
|
||||
Swal.fire({
|
||||
icon: 'success',
|
||||
title: '동기화 완료',
|
||||
text: data.message
|
||||
}).then(function(){
|
||||
fn_search(); // 목록 새로고침
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: '동기화 실패',
|
||||
text: data.message
|
||||
});
|
||||
}
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
Swal.close();
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: '오류 발생',
|
||||
text: '배치 실행 중 오류가 발생했습니다.'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body style="overflow-y: hidden;">
|
||||
@@ -140,8 +191,9 @@ function openwarehouseListInfoPopUp(objid){
|
||||
</h2>
|
||||
<div class="btnArea">
|
||||
<input type="button" value="조회" class="plm_btns" id="btnSearch">
|
||||
<input type="button" value="창고등록" class="plm_btns" onclick="javascript:openwarehouseListInfoPopUp('');">
|
||||
<!-- <input type="button" value="창고등록" class="plm_btns" onclick="javascript:openwarehouseListInfoPopUp('');"> -->
|
||||
<input type="button" value="삭제" class="plm_btns" id="btnDelete">
|
||||
<input type="button" value="ERP 창고 동기화" class="plm_btns" id="btnSyncErp" style="background-color:#4CAF50;color:white;">
|
||||
</div>
|
||||
</div>
|
||||
<div id="plmSearchZon">
|
||||
|
||||
@@ -292,18 +292,9 @@ ui-jqgrid tr.jqgrow td {
|
||||
//data:{"OBJID":OBJID},
|
||||
dataType:"json",
|
||||
success:function(data){
|
||||
Swal.fire(data.msg);
|
||||
fn_search();
|
||||
|
||||
// 확정 성공 시 ERP로 전송
|
||||
if(data.result == true || data.result == 'true'){
|
||||
var selectedData = _tabulGrid.getSelectedData();
|
||||
if(selectedData && selectedData.length > 0){
|
||||
var partObjid = selectedData[0].OBJID;
|
||||
fn_sendSinglePartToErp(partObjid);
|
||||
}
|
||||
}
|
||||
},
|
||||
Swal.fire(data.msg);
|
||||
fn_search();
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
}
|
||||
});
|
||||
@@ -586,25 +577,6 @@ ui-jqgrid tr.jqgrow td {
|
||||
window.open(url, target,"width=1520, height=860, menubars=no, scrollbars=yes, resizable=yes");
|
||||
}
|
||||
|
||||
// 단일 PART ERP 전송
|
||||
function fn_sendSinglePartToErp(partObjid){
|
||||
$.ajax({
|
||||
type : "POST",
|
||||
url : "/admin/sendSinglePartToErp.do",
|
||||
data : {partObjid: partObjid},
|
||||
dataType:"json",
|
||||
success:function(data){
|
||||
if(data.success){
|
||||
console.log("ERP 전송 성공: " + data.message);
|
||||
} else {
|
||||
console.log("ERP 전송 실패: " + data.message);
|
||||
}
|
||||
},
|
||||
error: function(jqxhr, status, error){
|
||||
console.log("ERP 전송 오류");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@@ -3394,35 +3394,4 @@ ORDER BY PATH,
|
||||
AND PART_NO = #{OBJID}
|
||||
) T
|
||||
</select>
|
||||
|
||||
<!-- ERP 전송을 위한 전체 PART 목록 조회 -->
|
||||
<select id="selectAllPartListForErp" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
SPEC,
|
||||
acctfg,
|
||||
odrfg
|
||||
FROM PART_MNG
|
||||
WHERE STATUS = 'release'
|
||||
AND PART_NO IS NOT NULL
|
||||
AND PART_NAME IS NOT NULL
|
||||
ORDER BY PART_NO
|
||||
</select>
|
||||
|
||||
<!-- OBJID로 단일 PART 조회 -->
|
||||
<select id="selectPartByObjid" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
SPEC,
|
||||
acctfg,
|
||||
odrfg
|
||||
FROM PART_MNG
|
||||
WHERE OBJID = #{objid}::NUMERIC
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -8131,5 +8131,34 @@ SELECT PM.OBJID
|
||||
WHERE OBJID::VARCHAR = #{partObjId}
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- ERP 전송을 위한 전체 PART 목록 조회 -->
|
||||
<select id="selectAllPartListForErp" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
SPEC,
|
||||
acctfg,
|
||||
odrfg
|
||||
FROM PART_MNG
|
||||
WHERE STATUS = 'release'
|
||||
AND PART_NO IS NOT NULL
|
||||
AND PART_NAME IS NOT NULL
|
||||
ORDER BY PART_NO
|
||||
</select>
|
||||
|
||||
<!-- OBJID로 단일 PART 조회 -->
|
||||
<select id="selectPartByObjid" parameterType="map" resultType="map">
|
||||
SELECT
|
||||
OBJID,
|
||||
PART_NO,
|
||||
PART_NAME,
|
||||
SPEC,
|
||||
acctfg,
|
||||
odrfg
|
||||
FROM PART_MNG
|
||||
WHERE OBJID = #{objid}::NUMERIC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -998,7 +998,7 @@ public class BatchService extends BaseService {
|
||||
String baseUrl = "https://erp.rps-korea.com";
|
||||
|
||||
// DB에서 전체 PART 목록 조회
|
||||
List<Map<String, Object>> partList = sqlSession.selectList("part.selectAllPartListForErp");
|
||||
List<Map<String, Object>> partList = sqlSession.selectList("partMng.selectAllPartListForErp");
|
||||
|
||||
if (partList == null || partList.isEmpty()) {
|
||||
result.put("success", false);
|
||||
@@ -1104,7 +1104,7 @@ public class BatchService extends BaseService {
|
||||
// DB에서 PART 정보 조회
|
||||
Map<String, Object> paramMap = new HashMap<String, Object>();
|
||||
paramMap.put("objid", partObjid);
|
||||
Map<String, Object> part = sqlSession.selectOne("part.selectPartByObjid", paramMap);
|
||||
Map<String, Object> part = sqlSession.selectOne("partMng.selectPartByObjid", paramMap);
|
||||
|
||||
if (part == null) {
|
||||
result.put("success", false);
|
||||
|
||||
@@ -48,6 +48,9 @@ public class PartMngService extends BaseService {
|
||||
|
||||
CommonService commonService = null;
|
||||
|
||||
@Autowired
|
||||
private BatchService batchService;
|
||||
|
||||
@Autowired
|
||||
ProjectService projectService;
|
||||
|
||||
@@ -793,6 +796,25 @@ public class PartMngService extends BaseService {
|
||||
|
||||
}
|
||||
sqlSession.commit();
|
||||
|
||||
// 배포 성공 후 ERP로 전송
|
||||
for (Map<String, Object> data : dataList) {
|
||||
String partObjid = CommonUtils.checkNull(data.get("OBJID"));
|
||||
if (!partObjid.isEmpty()) {
|
||||
try {
|
||||
Map<String, Object> erpResult = batchService.sendSinglePartToErp(partObjid);
|
||||
if (erpResult != null && Boolean.TRUE.equals(erpResult.get("success"))) {
|
||||
System.out.println("PART 배포 후 ERP 전송 성공: " + partObjid);
|
||||
} else {
|
||||
System.err.println("PART 배포 후 ERP 전송 실패: " + partObjid + " - " + erpResult.get("message"));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("PART 배포 후 ERP 전송 중 오류: " + partObjid + " - " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resultMap.put("result", true);
|
||||
resultMap.put("msg", Message.SAVE_SUCCESS);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user