zioinfo-esn/backend/src/main/resources/mapper/WorkMapper.xml
DESKTOP-TKLFCPR\ython 969fcd7284 feat(esn): zioinfo ESN ESL 통합 플랫폼 초기 구현
Spring Boot 3.5 / Java 17 + React 19 + PostgreSQL 단일 JAR.
멀티테넌트(LGINNOTEK/LGIT/EMART/ZIOINFO), HCore 게이트웨이 관제,
POS 연동 가격 자동 업데이트, Ollama 온프레미스 AI 알람 분석·POS 분류.
레거시 ESN 6개 프로젝트(Spring Boot 1.5/Java 8) 현대화 통합.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-16 01:07:05 +09:00

76 lines
3.2 KiB
XML

<?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.zioinfo.esn.mapper.WorkMapper">
<resultMap id="workMap" type="com.zioinfo.esn.domain.WorkHistoryVo">
<id property="id" column="id"/>
<result property="tenantCode" column="tenant_code"/>
<result property="storeId" column="store_id"/>
<result property="storeName" column="store_name"/>
<result property="workType" column="work_type"/>
<result property="workContent" column="work_content"/>
<result property="workerName" column="worker_name"/>
<result property="status" column="status"/>
<result property="remarks" column="remarks"/>
<result property="startedAt" column="started_at"/>
<result property="completedAt" column="completed_at"/>
<result property="createdAt" column="created_at"/>
</resultMap>
<select id="findAll" resultMap="workMap">
SELECT w.id, w.tenant_code, w.store_id, s.store_name, w.work_type, w.work_content,
w.worker_name, w.status, w.remarks, w.started_at, w.completed_at, w.created_at
FROM esn_work_history w
LEFT JOIN esn_store s ON w.store_id = s.id
<where>
<if test="tenantCode != null and tenantCode != ''">AND w.tenant_code = #{tenantCode}</if>
<if test="storeId != null">AND w.store_id = #{storeId}</if>
<if test="status != null and status != ''">AND w.status = #{status}</if>
<if test="workType != null and workType != ''">AND w.work_type = #{workType}</if>
</where>
ORDER BY w.created_at DESC LIMIT 200
</select>
<select id="findById" resultMap="workMap">
SELECT w.id, w.tenant_code, w.store_id, s.store_name, w.work_type, w.work_content,
w.worker_name, w.status, w.remarks, w.started_at, w.completed_at, w.created_at
FROM esn_work_history w
LEFT JOIN esn_store s ON w.store_id = s.id
WHERE w.id = #{id}
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
INSERT INTO esn_work_history (tenant_code, store_id, work_type, work_content,
worker_name, status, remarks, started_at)
VALUES (#{tenantCode}, #{storeId}, #{workType}, #{workContent},
#{workerName}, #{status}, #{remarks}, #{startedAt})
</insert>
<update id="update">
UPDATE esn_work_history SET
work_type = #{workType},
work_content = #{workContent},
worker_name = #{workerName},
status = #{status},
remarks = #{remarks},
started_at = #{startedAt},
completed_at = #{completedAt}
WHERE id = #{id}
</update>
<delete id="delete">DELETE FROM esn_work_history WHERE id = #{id}</delete>
<select id="countToday" resultType="long">
SELECT COUNT(*) FROM esn_work_history WHERE created_at::date = CURRENT_DATE
<if test="tenantCode != null and tenantCode != ''">AND tenant_code = #{tenantCode}</if>
</select>
<select id="countCompletedToday" resultType="long">
SELECT COUNT(*) FROM esn_work_history
WHERE status = 'COMPLETED' AND completed_at::date = CURRENT_DATE
<if test="tenantCode != null and tenantCode != ''">AND tenant_code = #{tenantCode}</if>
</select>
</mapper>