503 lines
22 KiB
XML
503 lines
22 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.roomroot.jwgl.mapper.SystemInitializationMapper">
|
|
|
|
<!-- 将系统版本表的中英文字段显式映射为系统初始化专用 VO。 -->
|
|
<resultMap id="SystemInitializationConfigurationResultMap"
|
|
type="com.roomroot.jwgl.vo.systeminitialization.SystemInitializationConfigurationVO">
|
|
<id column="versionId" property="versionId"/>
|
|
<result column="versionDate" property="versionDate"/>
|
|
<result column="versionValue" property="versionValue"/>
|
|
<result column="universityName" property="universityName"/>
|
|
<result column="universityCode" property="universityCode"/>
|
|
<result column="defaultSystemName" property="defaultSystemName"/>
|
|
<result column="systemMode" property="systemMode"/>
|
|
<result column="semesterNameStyle" property="semesterNameStyle"/>
|
|
<result column="periodCategory" property="periodCategory"/>
|
|
<result column="studentTeamFullNameIncludesGrade"
|
|
property="studentTeamFullNameIncludesGrade"/>
|
|
<result column="externalFileStorageRootPath"
|
|
property="externalFileStorageRootPath"/>
|
|
<result column="localFileAccessPath"
|
|
property="localFileAccessPath"/>
|
|
</resultMap>
|
|
|
|
<!-- 将“学期”表字段显式映射为系统初始化学期 VO。 -->
|
|
<resultMap id="SemesterInitializationResultMap"
|
|
type="com.roomroot.jwgl.vo.systeminitialization.SemesterInitializationVO">
|
|
<id column="year" property="year"/>
|
|
<id column="sequenceNumber" property="sequenceNumber"/>
|
|
<result column="currentSemester" property="currentSemester"/>
|
|
<result column="startAt" property="startAt"/>
|
|
<result column="endAt" property="endAt"/>
|
|
<result column="adjustmentWithoutApproval"
|
|
property="adjustmentWithoutApproval"/>
|
|
<result column="hourCoefficientSchemeId"
|
|
property="hourCoefficientSchemeId"/>
|
|
<result column="adjustmentForbidden"
|
|
property="adjustmentForbidden"/>
|
|
<result column="finalGradeAsPass"
|
|
property="finalGradeAsPass"/>
|
|
<result column="leadershipReviewRequired"
|
|
property="leadershipReviewRequired"/>
|
|
<result column="teacherAdjustmentWithoutApproval"
|
|
property="teacherAdjustmentWithoutApproval"/>
|
|
<result column="timeAdjustmentWithoutApproval"
|
|
property="timeAdjustmentWithoutApproval"/>
|
|
<result column="supportAdjustmentWithoutApproval"
|
|
property="supportAdjustmentWithoutApproval"/>
|
|
<result column="venueAdjustmentWithoutApproval"
|
|
property="venueAdjustmentWithoutApproval"/>
|
|
<result column="lockedWeeks" property="lockedWeeks"/>
|
|
<result column="lockMeasurementUnit"
|
|
property="lockMeasurementUnit"/>
|
|
<result column="teachingHourStatisticsAt"
|
|
property="teachingHourStatisticsAt"/>
|
|
</resultMap>
|
|
|
|
<!-- 系统基础参数查询统一字段,避免查询和保存后的返回字段不一致。 -->
|
|
<sql id="ConfigurationColumns">
|
|
currentVersion."ID" AS "versionId",
|
|
currentVersion."VersionDate" AS "versionDate",
|
|
currentVersion."VersionValue" AS "versionValue",
|
|
currentVersion."UniversityName" AS "universityName",
|
|
currentVersion."UniversityCode" AS "universityCode",
|
|
currentVersion."缺省系统名称" AS "defaultSystemName",
|
|
currentVersion."系统模式" AS "systemMode",
|
|
currentVersion."学期名称样式" AS "semesterNameStyle",
|
|
currentVersion."节次类别" AS "periodCategory",
|
|
currentVersion."学员队全名称含年级"
|
|
AS "studentTeamFullNameIncludesGrade",
|
|
currentVersion."外部文件存储根路径"
|
|
AS "externalFileStorageRootPath",
|
|
currentVersion."本站文件访问路径"
|
|
AS "localFileAccessPath"
|
|
</sql>
|
|
|
|
<!-- 学期查询统一字段,避免新增、修改和当前学期查询使用不同映射。 -->
|
|
<sql id="SemesterColumns">
|
|
semester."年度" AS "year",
|
|
semester."序号" AS "sequenceNumber",
|
|
semester."当前学期" AS "currentSemester",
|
|
semester."开学日期" AS "startAt",
|
|
semester."结束日期" AS "endAt",
|
|
semester."调课不审批" AS "adjustmentWithoutApproval",
|
|
semester."课时系数方案编号"
|
|
AS "hourCoefficientSchemeId",
|
|
semester."禁止调课" AS "adjustmentForbidden",
|
|
semester."终结成绩定及格" AS "finalGradeAsPass",
|
|
semester."教务领导审核调课"
|
|
AS "leadershipReviewRequired",
|
|
semester."调课不审批_教员"
|
|
AS "teacherAdjustmentWithoutApproval",
|
|
semester."调课不审批_时间"
|
|
AS "timeAdjustmentWithoutApproval",
|
|
semester."调课不审批_保障"
|
|
AS "supportAdjustmentWithoutApproval",
|
|
semester."调课不审批_场地"
|
|
AS "venueAdjustmentWithoutApproval",
|
|
semester."锁定周数" AS "lockedWeeks",
|
|
semester."锁定计量单位" AS "lockMeasurementUnit",
|
|
semester."课时统计时间" AS "teachingHourStatisticsAt"
|
|
</sql>
|
|
|
|
<!--
|
|
第一步:读取系统初始化页面允许展示的系统基础参数。
|
|
第二步:通过固定英文别名隔离数据库中文字段和 Java 属性命名。
|
|
第三步:使用最大 ID 取得当前生效配置,保留历史版本机制。
|
|
第四步:不查询 UniversityValidCode,避免业务接口暴露校验信息。
|
|
-->
|
|
<select id="selectCurrentConfiguration"
|
|
resultMap="SystemInitializationConfigurationResultMap">
|
|
SELECT
|
|
<include refid="ConfigurationColumns"/>
|
|
FROM "DBVersion" currentVersion
|
|
WHERE currentVersion."ID" = (
|
|
SELECT MAX(historyVersion."ID")
|
|
FROM "DBVersion" historyVersion
|
|
)
|
|
</select>
|
|
|
|
<!--
|
|
系统版本表为空时写入第一条配置。
|
|
未由初始化页面维护的列不在 INSERT 字段中,继续使用数据库默认值或空值。
|
|
-->
|
|
<insert id="insertInitialConfiguration">
|
|
INSERT INTO "DBVersion" (
|
|
"ID", "VersionDate", "VersionValue",
|
|
"UniversityName", "UniversityCode",
|
|
"缺省系统名称", "系统模式", "学期名称样式",
|
|
"节次类别", "学员队全名称含年级",
|
|
"外部文件存储根路径", "本站文件访问路径"
|
|
)
|
|
SELECT
|
|
(
|
|
SELECT NVL(MAX(historyVersion."ID"), 0) + 1
|
|
FROM "DBVersion" historyVersion
|
|
),
|
|
#{versionDate},
|
|
#{dto.versionValue},
|
|
#{dto.universityName},
|
|
#{dto.universityCode},
|
|
#{dto.defaultSystemName},
|
|
#{dto.systemMode},
|
|
#{dto.semesterNameStyle},
|
|
#{dto.periodCategory},
|
|
#{dto.studentTeamFullNameIncludesGrade},
|
|
#{dto.externalFileStorageRootPath},
|
|
#{dto.localFileAccessPath}
|
|
FROM DUAL
|
|
WHERE NOT EXISTS (
|
|
SELECT 1
|
|
FROM "DBVersion"
|
|
)
|
|
</insert>
|
|
|
|
<!--
|
|
第一步:只复制页面读取时对应的当前版本,完成原子化乐观锁校验。
|
|
第二步:页面可编辑字段使用本次参数覆盖。
|
|
第三步:其余历史字段完整复制,避免保存基础参数时丢失其他模块配置。
|
|
-->
|
|
<insert id="insertNextConfigurationVersion">
|
|
INSERT INTO "DBVersion" (
|
|
"ID", "VersionDate", "VersionValue", "UniversityName",
|
|
"学员队全名称含年级", "学期名称样式", "节次类别",
|
|
"外部文件存储根路径", "本站文件访问路径",
|
|
"登录失败弹窗", "允许密码尝试次数", "用户锁定分钟数",
|
|
"允许教研室管理教材",
|
|
"使用虚拟教学场地设置班次专用教室",
|
|
"使用虚拟教员设置课程责任教员",
|
|
"允许多主讲分组教学", "跟查课录入锁定天数",
|
|
"UniversityCode", "UniversityValidCode",
|
|
"显示78节", "显示晚上", "显示夜间", "教学要点名称",
|
|
"教材导出包含图片",
|
|
"建立班次学期信息时自动生成教学计划",
|
|
"成绩报表显示结论成绩", "缺省系统名称",
|
|
"Excel课表按开课日期排序", "Excel课表显示实施教员数",
|
|
"系统模式", "课程表标题样式", "课程表副标题样式",
|
|
"大屏显示教学内容", "大屏显示前景标题颜色",
|
|
"大屏显示前景内容颜色", "大屏显示背景颜色",
|
|
"实践课标记", "三实课标记", "增加学时标记",
|
|
"减少学时标记", "JSONZD", "学员正课请假模板文件编号"
|
|
)
|
|
SELECT
|
|
currentVersion."ID" + 1,
|
|
#{versionDate},
|
|
#{dto.versionValue},
|
|
#{dto.universityName},
|
|
#{dto.studentTeamFullNameIncludesGrade},
|
|
#{dto.semesterNameStyle},
|
|
#{dto.periodCategory},
|
|
#{dto.externalFileStorageRootPath},
|
|
#{dto.localFileAccessPath},
|
|
currentVersion."登录失败弹窗",
|
|
currentVersion."允许密码尝试次数",
|
|
currentVersion."用户锁定分钟数",
|
|
currentVersion."允许教研室管理教材",
|
|
currentVersion."使用虚拟教学场地设置班次专用教室",
|
|
currentVersion."使用虚拟教员设置课程责任教员",
|
|
currentVersion."允许多主讲分组教学",
|
|
currentVersion."跟查课录入锁定天数",
|
|
#{dto.universityCode},
|
|
currentVersion."UniversityValidCode",
|
|
currentVersion."显示78节",
|
|
currentVersion."显示晚上",
|
|
currentVersion."显示夜间",
|
|
currentVersion."教学要点名称",
|
|
currentVersion."教材导出包含图片",
|
|
currentVersion."建立班次学期信息时自动生成教学计划",
|
|
currentVersion."成绩报表显示结论成绩",
|
|
#{dto.defaultSystemName},
|
|
currentVersion."Excel课表按开课日期排序",
|
|
currentVersion."Excel课表显示实施教员数",
|
|
#{dto.systemMode},
|
|
currentVersion."课程表标题样式",
|
|
currentVersion."课程表副标题样式",
|
|
currentVersion."大屏显示教学内容",
|
|
currentVersion."大屏显示前景标题颜色",
|
|
currentVersion."大屏显示前景内容颜色",
|
|
currentVersion."大屏显示背景颜色",
|
|
currentVersion."实践课标记",
|
|
currentVersion."三实课标记",
|
|
currentVersion."增加学时标记",
|
|
currentVersion."减少学时标记",
|
|
currentVersion."JSONZD",
|
|
currentVersion."学员正课请假模板文件编号"
|
|
FROM "DBVersion" currentVersion
|
|
WHERE currentVersion."ID" = #{dto.expectedVersionId}
|
|
AND currentVersion."ID" = (
|
|
SELECT MAX(historyVersion."ID")
|
|
FROM "DBVersion" historyVersion
|
|
)
|
|
</insert>
|
|
|
|
<!-- 查询当前学期;历史脏数据存在多个当前标志时稳定取年度和序号最大的记录。 -->
|
|
<select id="selectCurrentSemester"
|
|
resultMap="SemesterInitializationResultMap">
|
|
SELECT *
|
|
FROM (
|
|
SELECT
|
|
<include refid="SemesterColumns"/>
|
|
FROM "学期" semester
|
|
WHERE COALESCE(semester."当前学期", 0) = 1
|
|
ORDER BY semester."年度" DESC, semester."序号" DESC
|
|
) currentSemester
|
|
WHERE ROWNUM = 1
|
|
</select>
|
|
|
|
<!-- 按照年度和序号组成的业务键查询一条学期记录。 -->
|
|
<select id="selectSemesterByKey"
|
|
resultMap="SemesterInitializationResultMap">
|
|
SELECT
|
|
<include refid="SemesterColumns"/>
|
|
FROM "学期" semester
|
|
WHERE semester."年度" = #{year}
|
|
AND semester."序号" = #{sequenceNumber}
|
|
</select>
|
|
|
|
<!--
|
|
检查其他学期是否与待保存学期发生时间重叠。
|
|
起止边界相接允许保存,不把上一学期结束时间等于下一学期开学时间视为冲突。
|
|
-->
|
|
<select id="countOverlappingSemesters" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM "学期" semester
|
|
WHERE NOT (
|
|
semester."年度" = #{dto.year}
|
|
AND semester."序号" = #{dto.sequenceNumber}
|
|
)
|
|
AND semester."开学日期" < #{dto.endAt}
|
|
AND semester."结束日期" > #{dto.startAt}
|
|
</select>
|
|
|
|
<!-- 设置新当前学期前清除其他记录的当前标志。 -->
|
|
<update id="clearOtherCurrentSemesters">
|
|
UPDATE "学期"
|
|
SET "当前学期" = 0
|
|
WHERE COALESCE("当前学期", 0) != 0
|
|
AND NOT (
|
|
"年度" = #{year}
|
|
AND "序号" = #{sequenceNumber}
|
|
)
|
|
</update>
|
|
|
|
<!-- 写入一条新的学期参数记录。 -->
|
|
<insert id="insertSemester">
|
|
INSERT INTO "学期" (
|
|
"年度", "当前学期", "开学日期", "结束日期",
|
|
"调课不审批", "课时系数方案编号", "禁止调课",
|
|
"终结成绩定及格", "教务领导审核调课",
|
|
"调课不审批_教员", "调课不审批_时间",
|
|
"调课不审批_保障", "锁定周数", "调课不审批_场地",
|
|
"序号", "锁定计量单位", "课时统计时间"
|
|
) VALUES (
|
|
#{dto.year}, #{dto.currentSemester},
|
|
#{dto.startAt}, #{dto.endAt},
|
|
#{dto.adjustmentWithoutApproval},
|
|
#{dto.hourCoefficientSchemeId},
|
|
#{dto.adjustmentForbidden},
|
|
#{dto.finalGradeAsPass},
|
|
#{dto.leadershipReviewRequired},
|
|
#{dto.teacherAdjustmentWithoutApproval},
|
|
#{dto.timeAdjustmentWithoutApproval},
|
|
#{dto.supportAdjustmentWithoutApproval},
|
|
#{dto.lockedWeeks},
|
|
#{dto.venueAdjustmentWithoutApproval},
|
|
#{dto.sequenceNumber},
|
|
#{dto.lockMeasurementUnit},
|
|
#{dto.teachingHourStatisticsAt}
|
|
)
|
|
</insert>
|
|
|
|
<!-- 修改已有学期业务参数,保留不属于初始化页面维护的 json 字典。 -->
|
|
<update id="updateSemester">
|
|
UPDATE "学期"
|
|
SET "当前学期" = #{dto.currentSemester},
|
|
"开学日期" = #{dto.startAt},
|
|
"结束日期" = #{dto.endAt},
|
|
"调课不审批" = #{dto.adjustmentWithoutApproval},
|
|
"课时系数方案编号" = #{dto.hourCoefficientSchemeId},
|
|
"禁止调课" = #{dto.adjustmentForbidden},
|
|
"终结成绩定及格" = #{dto.finalGradeAsPass},
|
|
"教务领导审核调课" = #{dto.leadershipReviewRequired},
|
|
"调课不审批_教员" =
|
|
#{dto.teacherAdjustmentWithoutApproval},
|
|
"调课不审批_时间" =
|
|
#{dto.timeAdjustmentWithoutApproval},
|
|
"调课不审批_保障" =
|
|
#{dto.supportAdjustmentWithoutApproval},
|
|
"锁定周数" = #{dto.lockedWeeks},
|
|
"调课不审批_场地" =
|
|
#{dto.venueAdjustmentWithoutApproval},
|
|
"锁定计量单位" = #{dto.lockMeasurementUnit},
|
|
"课时统计时间" = #{dto.teachingHourStatisticsAt}
|
|
WHERE "年度" = #{dto.year}
|
|
AND "序号" = #{dto.sequenceNumber}
|
|
</update>
|
|
|
|
<!-- 查询数据库已有部别编号,用于整份历史文件的冲突和引用预校验。 -->
|
|
<select id="selectDepartmentIds" resultType="string">
|
|
SELECT "编号"
|
|
FROM "实施_机关"
|
|
</select>
|
|
|
|
<!-- 查询数据库已有教研室编号,用于防止历史导入覆盖正式数据。 -->
|
|
<select id="selectResearchOfficeIds" resultType="string">
|
|
SELECT "教研室代号"
|
|
FROM "教研室表"
|
|
</select>
|
|
|
|
<!-- 查询数据库已有部别人员编号,用于防止历史导入重复写入。 -->
|
|
<select id="selectPersonnelIds" resultType="string">
|
|
SELECT "编号"
|
|
FROM "实施_机关参谋"
|
|
</select>
|
|
|
|
<!-- 按工具类排好的父节点优先顺序批量写入历史部别。 -->
|
|
<insert id="insertHistoricalDepartments">
|
|
INSERT INTO "实施_机关" (
|
|
"编号", "机关名称", "机关类别", "分类号", "分级号",
|
|
"上级机关编号", "停用", "停用时间", "简称"
|
|
)
|
|
<foreach collection="rows" item="row"
|
|
separator=" UNION ALL ">
|
|
SELECT
|
|
#{row.id}, #{row.name}, #{row.category},
|
|
#{row.classificationCode}, #{row.levelNumber},
|
|
#{row.parentId}, #{row.disabled},
|
|
<choose>
|
|
<when test="row.disabled != null and row.disabled">
|
|
#{importedAt}
|
|
</when>
|
|
<otherwise>NULL</otherwise>
|
|
</choose>,
|
|
#{row.abbreviation}
|
|
FROM DUAL
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 批量写入历史教研室基础信息。 -->
|
|
<insert id="insertHistoricalResearchOffices">
|
|
INSERT INTO "教研室表" (
|
|
"教研室代号", "教研室名称", "备注", "停用", "停用时间",
|
|
"序号", "部系", "虚实类型", "简称", "机关性质"
|
|
)
|
|
<foreach collection="rows" item="row"
|
|
separator=" UNION ALL ">
|
|
SELECT
|
|
#{row.id}, #{row.name}, #{row.remark}, #{row.disabled},
|
|
<choose>
|
|
<when test="row.disabled != null and row.disabled">
|
|
#{importedAt}
|
|
</when>
|
|
<otherwise>NULL</otherwise>
|
|
</choose>,
|
|
#{row.sequenceNumber}, #{row.departmentText},
|
|
#{row.virtual}, #{row.abbreviation}, #{row.organNature}
|
|
FROM DUAL
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 批量建立历史教研室和部别的唯一隶属关系。 -->
|
|
<insert id="insertHistoricalResearchOfficeRelations">
|
|
INSERT INTO "实施_机关_教研室" (
|
|
"编号", "实施_机关编号", "教研室编号"
|
|
)
|
|
<foreach collection="rows" item="row"
|
|
separator=" UNION ALL ">
|
|
SELECT
|
|
#{row.relationId}, #{row.departmentId}, #{row.id}
|
|
FROM DUAL
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 批量写入历史部别人员,并把布尔值转换为原表使用的 0/1 状态。 -->
|
|
<insert id="insertHistoricalPersonnel">
|
|
INSERT INTO "实施_机关参谋" (
|
|
"编号", "实施_机关编号", "用户姓名", "序号", "离职状态",
|
|
"职务", "卡号", "拼音", "主官"
|
|
)
|
|
<foreach collection="rows" item="row"
|
|
separator=" UNION ALL ">
|
|
SELECT
|
|
#{row.id}, #{row.departmentId}, #{row.name},
|
|
#{row.sequenceNumber},
|
|
<choose>
|
|
<when test="row.departed != null and row.departed">
|
|
1
|
|
</when>
|
|
<otherwise>0</otherwise>
|
|
</choose>,
|
|
#{row.position}, #{row.cardNumber}, #{row.pinyin},
|
|
<choose>
|
|
<when test="row.principal != null and row.principal">
|
|
1
|
|
</when>
|
|
<otherwise>0</otherwise>
|
|
</choose>
|
|
FROM DUAL
|
|
</foreach>
|
|
</insert>
|
|
|
|
<!-- 使用最小查询验证数据库连接和 SQL 执行能力。 -->
|
|
<select id="selectDatabaseHealth" resultType="int">
|
|
SELECT 1
|
|
FROM DUAL
|
|
</select>
|
|
|
|
<!-- 统计当前部别总数。 -->
|
|
<select id="countDepartments" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM "实施_机关"
|
|
</select>
|
|
|
|
<!-- 统计当前教研室总数。 -->
|
|
<select id="countResearchOffices" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM "教研室表"
|
|
</select>
|
|
|
|
<!-- 统计当前部别人员总数。 -->
|
|
<select id="countPersonnel" resultType="int">
|
|
SELECT COUNT(1)
|
|
FROM "实施_机关参谋"
|
|
</select>
|
|
|
|
<!--
|
|
汇总部别上级、教研室隶属关系和部别人员所属部别中的失效引用。
|
|
任意失效引用都会阻止系统初始化最终确认。
|
|
-->
|
|
<select id="countBrokenBaseReferences" resultType="int">
|
|
SELECT NVL(SUM(referenceCheck."brokenCount"), 0)
|
|
FROM (
|
|
SELECT COUNT(1) AS "brokenCount"
|
|
FROM "实施_机关" department
|
|
LEFT JOIN "实施_机关" parentDepartment
|
|
ON parentDepartment."编号" = department."上级机关编号"
|
|
WHERE department."上级机关编号" IS NOT NULL
|
|
AND parentDepartment."编号" IS NULL
|
|
|
|
UNION ALL
|
|
|
|
SELECT COUNT(1) AS "brokenCount"
|
|
FROM "实施_机关_教研室" relation
|
|
LEFT JOIN "实施_机关" department
|
|
ON department."编号" = relation."实施_机关编号"
|
|
LEFT JOIN "教研室表" researchOffice
|
|
ON researchOffice."教研室代号" = relation."教研室编号"
|
|
WHERE department."编号" IS NULL
|
|
OR researchOffice."教研室代号" IS NULL
|
|
|
|
UNION ALL
|
|
|
|
SELECT COUNT(1) AS "brokenCount"
|
|
FROM "实施_机关参谋" personnel
|
|
LEFT JOIN "实施_机关" department
|
|
ON department."编号" = personnel."实施_机关编号"
|
|
WHERE department."编号" IS NULL
|
|
) referenceCheck
|
|
</select>
|
|
|
|
</mapper>
|