Pārlūkot izejas kodu

배치로그 생성 및 종료처리 추가

gagamel 5 gadi atpakaļ
vecāks
revīzija
0c3b189b5e

+ 40 - 0
style24.batch/src/main/java/com/style24/batch/biz/dao/TsbBatchDao.java

@@ -0,0 +1,40 @@
+package com.style24.batch.biz.dao;
+
+import com.style24.core.support.annotation.ShopDs;
+import com.style24.persistence.domain.BatchLog;
+
+/**
+ * 배치 Dao
+ *
+ * @author gagamel
+ * @since 2020. 12. 2
+ */
+@ShopDs
+public interface TsbBatchDao {
+
+	/**
+	 * 배치ID로 배치명 조회
+	 * @param batchId - 배치ID
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 12. 2
+	 */
+	String getBatchName(String batchId);
+
+	/**
+	 * 배치로그 생성
+	 * @param batchLog - 배치로그 정보
+	 * @author gagamel
+	 * @since 2020. 12. 2
+	 */
+	void createBatchLog(BatchLog batchLog);
+
+	/**
+	 * 배치로그 종료 처리
+	 * @param batchLogSq - 배치로그일련번호
+	 * @author gagamel
+	 * @since 2020. 12. 2
+	 */
+	void updateBatchLog(Integer batchLogSq);
+
+}

+ 65 - 0
style24.batch/src/main/java/com/style24/batch/biz/service/TsbBatchService.java

@@ -0,0 +1,65 @@
+package com.style24.batch.biz.service;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.style24.batch.biz.dao.TsbBatchDao;
+import com.style24.batch.support.env.TsbConstants;
+import com.style24.persistence.domain.BatchLog;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 배치 Service
+ *
+ * @author gagamel
+ * @since 2020. 12. 2
+ */
+@Service
+@Slf4j
+public class TsbBatchService {
+
+	@Autowired
+	private TsbBatchDao batchDao;
+
+	/**
+	 * 배치ID로 배치명 조회
+	 * @param batchId - 배치ID
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 12. 2
+	 */
+	public String getBatchName(String batchId) {
+		return batchDao.getBatchName(batchId);
+	}
+
+	/**
+	 * 배치로그 생성
+	 * @param batchId - 배치ID
+	 * @return 배치로그일련번호
+	 * @author gagamel
+	 * @since 2020. 12. 2
+	 */
+	@Transactional("shopTxnManager")
+	public Integer createBatchLog(String batchId) {
+		BatchLog batchLog = new BatchLog();
+		batchLog.setBatchId(batchId);
+		batchLog.setRegNo(TsbConstants.REG_NO);
+		batchDao.createBatchLog(batchLog);
+
+		return batchLog.getBatchLogSq();
+	}
+
+	/**
+	 * 배치로그 종료 처리
+	 * @param batchLogSq - 배치로그일련번호
+	 * @return
+	 * @author gagamel
+	 * @since 2020. 12. 2
+	 */
+	public void updateBatchLog(Integer batchLogSq) {
+		batchDao.updateBatchLog(batchLogSq);
+	}
+
+}

+ 45 - 0
style24.batch/src/main/java/com/style24/persistence/mybatis/shop/TsbBatch.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.style24.batch.biz.dao.TsbBatchDao">
+	
+	<!-- 배치명 조회 -->
+	<select id="getBatchName" parameterType="String" resultType="String">
+		/* TsbBatch.createGoodsHst */
+		SELECT BATCH_NM
+		FROM   TB_BATCH
+		WHERE  BATCH_ID = #{batchId}
+		AND    USE_YN = 'Y' /*사용하는넘만*/
+	</select>
+	
+	<!-- 배치로그 생성 -->
+	<insert id="createBatchLog" parameterType="BatchLog" keyProperty="batchLogSq">
+		/* TsbBatch.createBatchLog */
+		INSERT INTO TB_BATCH (
+		       BATCH_LOG_SQ
+		     , BATCH_ID
+		     , BATCH_STDT
+		     , BATCH_STAT
+		     , REG_NO
+		     , REG_DT
+		)
+		VALUES (
+		       #{batchLogSq}
+		     , #{batchId}
+		     , NOW()
+		     , 'I'
+		     , #{regNo}
+		     , NOW()
+		)
+	</insert>
+	
+	<!-- 배치로그 종료 처리 -->
+	<update id="updateBatchLog" parameterType="Integer">
+		/* TsbBatch.updateBatchLog */
+		UPDATE TB_BATCH
+		SET    BATCH_EDDT = NOW()
+		     , BATCH_STAT = 'F'
+		WHERE  BATCH_LOG_SQ = #{batchLogSq}
+		AND    BATCH_STAT = 'I'
+	</update>
+	
+</mapper>