260506_01_fst: First Commit

This commit is contained in:
2026-05-06 13:54:16 +09:00
commit 90a17bd8af
34 changed files with 1430 additions and 0 deletions

View File

@@ -0,0 +1,155 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kri.kfpa.dash.mapper.DataMapper">
<resultMap id="DivCsiDataResultMap" type="com.kri.kfpa.dash.entity.CsiDataEntity">
<result property="div" column="div"/>
<result property="csi" column="csi"/>
<result property="safeHelp" column="safe_help"/>
<result property="recHelp" column="rec_help"/>
<result property="staffProf" column="staff_prof"/>
<result property="staffAtt" column="staff_att"/>
</resultMap>
<resultMap id="DivObjectTypeCsiRankResultMap" type="com.kri.kfpa.dash.entity.ObjectTypeCsiRankEntity">
<result property="div" column="div"/>
<result property="objectType" column="object_type"/>
<result property="csi" column="csi"/>
<result property="divRank" column="div_rank"/>
</resultMap>
<resultMap id="DivCommentResultMap" type="com.kri.kfpa.dash.entity.DivCommentEntity">
<result property="performance25DirectExperience" column="performance25_direct_experience"/>
<result property="performance25IndirectExperience" column="performance25_indirect_experience"/>
<result property="performance25Capability" column="performance25_capability"/>
<result property="plan26DirectExperience" column="plan26_direct_experience"/>
<result property="plan26IndirectExperience" column="plan26_indirect_experience"/>
<result property="plan26Capability" column="plan26_capability"/>
<result property="performance26DirectExperience" column="performance26_direct_experience"/>
<result property="performance26IndirectExperience" column="performance26_indirect_experience"/>
<result property="performance26Capability" column="performance26_capability"/>
</resultMap>
<sql id="BaseDataSelect">
SELECT
IDKEY
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q1.Q1') AS DECIMAL(18, 4)) AS q1
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q2.Q2') AS DECIMAL(18, 4)) AS q2
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q7.Q7') AS DECIMAL(18, 4)) AS q4
, TRY_CAST(JSON_VALUE(DATJSON, '$.Q10.Q10') AS DECIMAL(18, 4)) AS q5
, CASE
WHEN JSON_VALUE(DATJSON, '$.Q16.Q14') IS NOT NULL
THEN JSON_VALUE(DATJSON, '$.Q16.Q14')
ELSE JSON_VALUE(DATJSON, '$.Q14.Q14')
END AS object_type_raw
, CASE
WHEN JSON_VALUE(DATJSON, '$.Q16.Q15') IS NOT NULL
THEN JSON_VALUE(DATJSON, '$.Q16.Q15')
ELSE JSON_VALUE(DATJSON, '$.Q15.Q15')
END AS div
FROM Kon.dbo.DATA
WHERE SURVEY_TYPE != 'TEST'
AND Status = 10
AND PKEY = #{pkey}
</sql>
<select id="selectDivCsiData" resultMap="DivCsiDataResultMap">
WITH Base AS (
<include refid="BaseDataSelect"/>
)
SELECT
div
, AVG(q1 * 0.4 + q2 * 0.4 + q4 * 0.1 + q5 * 0.1) AS csi
, AVG(q1) AS safe_help
, AVG(q2) AS rec_help
, AVG(q4) AS staff_prof
, AVG(q5) AS staff_att
FROM Base
WHERE object_type_raw IS NOT NULL
AND div IS NOT NULL
AND object_type_raw != '99'
AND div != '99'
GROUP BY div
ORDER BY div
</select>
<select id="selectDivObjectTypeCsiRank" resultMap="DivObjectTypeCsiRankResultMap">
WITH Base AS (
<include refid="BaseDataSelect"/>
),
Recode AS (
SELECT
IDKEY
, q1
, q2
, q4
, q5
, div
, CASE
WHEN object_type_raw IN ('4', '12') THEN object_type_raw
ELSE '90'
END AS object_type
FROM Base
),
CsiAgg AS (
SELECT
div
, object_type
, AVG(q1 * 0.4 + q2 * 0.4 + q4 * 0.1 + q5 * 0.1) AS csi
FROM Recode
WHERE div IS NOT NULL
AND div = #{div}
GROUP BY div, object_type
)
SELECT
div
, object_type
, CSI
, DENSE_RANK() OVER (
PARTITION BY object_type
ORDER BY CSI DESC
) AS div_rank
FROM CsiAgg
ORDER BY div, object_type, div_rank
</select>
<select id="selectDivComment" resultMap="DivCommentResultMap">
SELECT
ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_1'), '') AS performance25_direct_experience
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_1'), '') AS performance25_indirect_experience
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_1'), '') AS performance25_capability
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_2'), '') AS plan26_direct_experience
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_2'), '') AS plan26_indirect_experience
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_2'), '') AS plan26_capability
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_1_3'), '') AS performance26_direct_experience
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_2_3'), '') AS performance26_indirect_experience
, ISNULL(JSON_VALUE(DATJSON, '$.Q1.Q1_3_3'), '') AS performance26_capability
FROM Kon.dbo.DATA
WHERE PKEY = #{pkey}
AND IDKEY = #{idkey}
</select>
<update id="updateDivComment">
UPDATE A
SET DATJSON = JSON_MODIFY(
DATJSON,
'$.Q1',
JSON_QUERY((
SELECT
#{commentValues.performance25.directExperience} AS [Q1_1_1]
, #{commentValues.performance25.indirectExperience} AS [Q1_2_1]
, #{commentValues.performance25.capability} AS [Q1_3_1]
, #{commentValues.plan26.directExperience} AS [Q1_1_2]
, #{commentValues.plan26.indirectExperience} AS [Q1_2_2]
, #{commentValues.plan26.capability} AS [Q1_3_2]
, #{commentValues.performance26.directExperience} AS [Q1_1_3]
, #{commentValues.performance26.indirectExperience} AS [Q1_2_3]
, #{commentValues.performance26.capability} AS [Q1_3_3]
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
))
)
FROM Kon.dbo.DATA A
WHERE PKEY = #{pkey}
AND IDKEY = #{idkey}
</update>
</mapper>