feat: 迁移标准属性自定义 修改相关问题

This commit is contained in:
super_liu
2021-06-15 18:45:21 +08:00
parent e737cc225d
commit 9d704f4d1e
25 changed files with 1017 additions and 189 deletions
@@ -54,10 +54,164 @@
</trim>
</sql>
<!-- 插入记录 -->
<insert id="insert" parameterType="com.adc.da.slrs.sarLawsAttrInfo.entity.SarLawsAttrInfo" >
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_SAR_LAWS_ATTR_INFO.NEXTVAL FROM DUAL
</selectKey> -->
insert into SAR_LAWS_ATTR_INFO(<include refid="Base_Column_List" />)
values (#{id, jdbcType=VARCHAR}, #{lawsId, jdbcType=VARCHAR}, #{creationUser, jdbcType=VARCHAR}, #{validFlag, jdbcType=VARCHAR}, #{creationTime, jdbcType=TIMESTAMP}, #{modifyTime, jdbcType=TIMESTAMP})
</insert>
<!-- 动态插入记录 主键是序列 -->
<insert id="insertSelective" parameterType="com.adc.da.slrs.sarLawsAttrInfo.entity.SarLawsAttrInfo" >
<!-- <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_SAR_LAWS_ATTR_INFO.NEXTVAL FROM DUAL
</selectKey> -->
insert into SAR_LAWS_ATTR_INFO
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >id,</if>
<if test="lawsId != null" >laws_id,</if>
<if test="creationUser != null" >creation_user,</if>
<if test="validFlag != null" >valid_flag,</if>
<if test="creationTime != null" >creation_time,</if>
<if test="modifyTime != null" >modify_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >#{id, jdbcType=VARCHAR},</if>
<if test="lawsId != null" >#{lawsId, jdbcType=VARCHAR},</if>
<if test="creationUser != null" >#{creationUser, jdbcType=VARCHAR},</if>
<if test="validFlag != null" >#{validFlag, jdbcType=VARCHAR},</if>
<if test="creationTime != null" >#{creationTime, jdbcType=TIMESTAMP},</if>
<if test="modifyTime != null" >#{modifyTime, jdbcType=TIMESTAMP},</if>
</trim>
</insert>
<!-- 根据pk,修改记录-->
<update id="updateByPrimaryKey" parameterType="com.adc.da.slrs.sarLawsAttrInfo.entity.SarLawsAttrInfo" >
update SAR_LAWS_ATTR_INFO
set laws_id = #{lawsId},
creation_user = #{creationUser},
valid_flag = #{validFlag},
creation_time = #{creationTime},
modify_time = #{modifyTime}
where id = #{id}
</update>
<!-- 修改记录,只修改只不为空的字段 -->
<update id="updateByPrimaryKeySelective" parameterType="com.adc.da.slrs.sarLawsAttrInfo.entity.SarLawsAttrInfo" >
update SAR_LAWS_ATTR_INFO
<set >
<if test="lawsId != null" >
laws_id = #{lawsId},
</if>
<if test="creationUser != null" >
creation_user = #{creationUser},
</if>
<if test="validFlag != null" >
valid_flag = #{validFlag},
</if>
<if test="creationTime != null" >
creation_time = #{creationTime},
</if>
<if test="modifyTime != null" >
modify_time = #{modifyTime},
</if>
</set>
where id = #{id}
</update>
<!-- 根据id查询 SAR_LAWS_ATTR_INFO -->
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select <include refid="Base_Column_List" />
from SAR_LAWS_ATTR_INFO
where id = #{value}
</select>
<!-- 删除记录 -->
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from SAR_LAWS_ATTR_INFO
where id = #{value}
</delete>
<!-- SAR_LAWS_ATTR_INFO 列表总数-->
<select id="queryByCount" resultType="java.lang.Integer" parameterType="com.adc.da.base.page.BasePage">
select count(1) from SAR_LAWS_ATTR_INFO
<include refid="Base_Where_Clause"/>
</select>
<!-- 查询SAR_LAWS_ATTR_INFO列表 -->
<select id="queryByPage" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Base_Column_List" /> from
(select tmp_tb.* from
(select <include refid="Base_Column_List" /> from SAR_LAWS_ATTR_INFO
<include refid="Base_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''" >
${pager.orderCondition}
</if>
) tmp_tb limit ${pager.startIndex-1},${pageSize}) a
</select>
<select id="queryByList" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Base_Column_List"/> from SAR_LAWS_ATTR_INFO
<include refid="Base_Where_Clause"/>
<if test="pager.orderCondition != null and pager.orderCondition != ''" >
${pager.orderCondition}
</if>
</select>
<insert id="alterLawsAttr" parameterType="java.lang.String" >
alter table SAR_LAWS_ATTR_INFO
add ${fieldInfo}
</insert>
<!-- 删除字段-->
<insert id="deleteLawsAttr" parameterType="java.lang.String" >
alter table SAR_LAWS_ATTR_INFO
drop COLUMN ${fieldInfo}
</insert>
<!-- 查询表中已存在字段-->
<select id="selectLawsAttrColumn" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(*)
FROM information_schema.columns
WHERE TABLE_NAME = 'SAR_LAWS_ATTR_INFO' AND COLUMN_NAME = #{columnName}
</select>
<!-- 修改字段长度-->
<update id="updateAttrLen" parameterType="java.lang.String" >
ALTER table SAR_LAWS_ATTR_INFO
MODIFY ${fieldInfo}
</update>
<!-- 查询字段及对应数据-->
<select id="selectLawsFieldAndData" resultType="Map">
SELECT ${fieldInfo}
FROM SAR_LAWS_ATTR_INFO
WHERE valid_flag=0 and laws_id = #{standId}
</select>
<insert id="insertLawsAttr" parameterType="java.lang.String" >
insert into SAR_LAWS_ATTR_INFO(${fieldInfo})
values (${fieldValue})
</insert>
<update id="deleteLawsAttrByStandId" parameterType="java.lang.String" >
delete from SAR_LAWS_ATTR_INFO
where laws_id = #{standId}
</update>
<update id="updateLawsInfo" parameterType="java.lang.String" >
update SAR_LAWS_ATTR_INFO set ${field}=#{value}
where laws_id = #{lawsId}
</update>
<select id="selectFieldValByLawsId" resultType="java.lang.String" parameterType="java.lang.String">
SELECT ${field}
FROM SAR_LAWS_ATTR_INFO
WHERE laws_id = #{lawsId} and valid_flag=0
</select>
</mapper>
@@ -284,4 +284,11 @@
<include refid="Laws_Where_Clause"/>
GROUP BY SAR_LAWS_INFO.ID) a
</select>
<select id="selectLawsColumn" resultType="java.lang.Integer" parameterType="java.lang.String">
SELECT COUNT(*)
FROM information_schema.columns
WHERE table_name = 'SAR_LAWS_INFO' AND column_name = #{columnName}
</select>
</mapper>
@@ -107,20 +107,57 @@
</trim>
</sql>
<select id="selectNameByField" resultType="java.lang.String" parameterType="java.lang.String">
SELECT attr_name
<!-- 根据id查询 SAR_STAND_ATTR_DETAILS -->
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select <include refid="Base_Column_List" />
from SAR_STAND_ATTR_DETAILS
where attr_field = #{attrField} and valid_flag=0
<if test='sarType != null and sarType == "INLAND_STAND"'>
and (sar_type=#{sarType} or sar_type='STAND')
</if>
<if test='sarType != null and sarType == "FOREIGN_STAND"'>
and (sar_type=#{sarType} or sar_type='STAND')
</if>
<if test='sarType != null and sarType != "FOREIGN_STAND" and sarType != "INLAND_STAND"'>
and sar_type=#{sarType}
</if>
limit 0,1
where id = #{value} and valid_flag=0
</select>
<!-- 删除记录 -->
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from SAR_STAND_ATTR_DETAILS
where id = #{value} and valid_flag=0
</delete>
<!-- SAR_STAND_ATTR_DETAILS 列表总数-->
<select id="queryByCount" resultType="java.lang.Integer" parameterType="com.adc.da.base.page.BasePage">
select count(1) from SAR_STAND_ATTR_DETAILS
<include refid="Base_Where_Clause"/>
</select>
<!-- 查询SAR_STAND_ATTR_DETAILS列表 -->
<select id="queryByPage" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Base_Column_List" />,areaName from
(select tmp_tb.* from
(select <include refid="Base_Column_List_Show" />,UT_AREA.area_name as areaName from SAR_STAND_ATTR_DETAILS
left join UT_AREA on SAR_STAND_ATTR_DETAILS.show_region_id = UT_AREA.id
<include refid="Base_Where_Clause"/>
order by SAR_STAND_ATTR_DETAILS.order_num,SAR_STAND_ATTR_DETAILS.id
) tmp_tb limit ${pager.startIndex-1},${pageSize}) a
</select>
<select id="queryByList" resultMap="BaseResultMap" parameterType="com.adc.da.base.page.BasePage">
select <include refid="Base_Column_List"/> from SAR_STAND_ATTR_DETAILS
<include refid="Base_Where_Clause"/>
order by order_num,id
</select>
<update id="deleteByIds" parameterType="java.lang.String" >
delete from SAR_STAND_ATTR_DETAILS
where id in
<foreach collection="idList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="selectAllFieldToStr" resultType="java.lang.String" parameterType="com.adc.da.base.page.BasePage">
SELECT listagg ( attr_field, ',' ) within GROUP ( ORDER BY attr_field )
from SAR_STAND_ATTR_DETAILS
<include refid="Base_Where_Clause"/>
order by order_num,id
</select>
<select id="selectFieldByName" resultMap="BaseResultMap" parameterType="java.lang.String">
@@ -139,4 +176,45 @@
limit 0,1
</select>
<select id="selectFileFieldForSel" resultType="com.adc.da.sys.common.SelectionResult" parameterType="java.lang.String">
SELECT attr_field as value, attr_name as label
from SAR_STAND_ATTR_DETAILS
where valid_flag=0 and attr_type='FILE' and
(sar_type='STAND' or sar_type='INLAND_STAND' or sar_type='FOREIGN_STAND')
<if test="attrField != null">
and attr_field=#{attrField}
</if>
group by attr_field,attr_name
</select>
<!-- 标准拆分在用-->
<select id="selectFileFieldForSel1" resultType="com.adc.da.sys.common.SelectionResult"
parameterType="java.lang.String">
SELECT attr_field as value, attr_name as label
from SAR_STAND_ATTR_DETAILS
where valid_flag=0 and attr_type='FILE' and
(sar_type='STAND' or sar_type='INLAND_STAND' or sar_type='FOREIGN_STAND' or SAR_TYPE = 'FOREIGN_LAWS')
<if test="attrField != null">
and attr_field=#{attrField}
</if>
group by attr_field,attr_name
</select>
<select id="selectNameByField" resultType="java.lang.String" parameterType="java.lang.String">
SELECT attr_name
from SAR_STAND_ATTR_DETAILS
where attr_field = #{attrField} and valid_flag=0
<if test='sarType != null and sarType == "INLAND_STAND"'>
and (sar_type=#{sarType} or sar_type='STAND')
</if>
<if test='sarType != null and sarType == "FOREIGN_STAND"'>
and (sar_type=#{sarType} or sar_type='STAND')
</if>
<if test='sarType != null and sarType != "FOREIGN_STAND" and sarType != "INLAND_STAND"'>
and sar_type=#{sarType}
</if>
limit 0,1
</select>
</mapper>
@@ -28,6 +28,8 @@
<result column="cite_stand" property="citeStand" />
<result column="cited_stand" property="citedStand" />
<result column="allPutTime" property="allPutTime" />
<result column="text_status" property="textStatus" />
<result column="stand_system" property="standSystem" />
</resultMap>
<resultMap id="BaseResultMapExcel" type="com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo">
@@ -50,7 +52,7 @@
SAR_STANDARDS_INFO.stand_number, SAR_STANDARDS_INFO.stand_year, SAR_STANDARDS_INFO.stand_name, SAR_STANDARDS_INFO.stand_en_name,
SAR_STANDARDS_INFO.stand_state, SAR_STANDARDS_INFO.stand_nature, SAR_STANDARDS_INFO.issue_time, SAR_STANDARDS_INFO.put_time,
SAR_STANDARDS_INFO.synopsis, SAR_STANDARDS_INFO.creation_user, SAR_STANDARDS_INFO.valid_flag,
SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,SAR_STANDARDS_INFO.is_relate_access,SAR_STANDARDS_INFO.cite_stand,SAR_STANDARDS_INFO.cited_stand
SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,SAR_STANDARDS_INFO.is_relate_access,SAR_STANDARDS_INFO.cite_stand,SAR_STANDARDS_INFO.cited_stand,SAR_STANDARDS_INFO.text_status
</sql>
<sql id="Base_Column_List_Show" >
@@ -59,7 +61,7 @@
SAR_STANDARDS_INFO.stand_state, SAR_STANDARDS_INFO.stand_nature, SAR_STANDARDS_INFO.issue_time, SAR_STANDARDS_INFO.put_time,
concat(SAR_STANDARDS_INFO.synopsis, '') as synopsis, concat(replace_stand_num, '') as replace_stand_num, replaced_stand_num, SAR_STANDARDS_INFO.creation_user, SAR_STANDARDS_INFO.valid_flag,
SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,dicountry.DIC_TYPE_NAME as countryShow, dicstandSort.DIC_TYPE_NAME as standSortShow,
dicstandState.DIC_TYPE_NAME as standStateShow,dicstandNature.DIC_TYPE_NAME as standNatureShow,is_relate_access,cite_stand,cited_stand
dicstandState.DIC_TYPE_NAME as standStateShow,dicstandNature.DIC_TYPE_NAME as standNatureShow,is_relate_access,cite_stand,cited_stand,SAR_STANDARDS_INFO.text_status
</sql>
<sql id="Group_Column_List_Show">
@@ -68,7 +70,7 @@
SAR_STANDARDS_INFO.stand_state, SAR_STANDARDS_INFO.stand_nature, SAR_STANDARDS_INFO.issue_time, SAR_STANDARDS_INFO.put_time,
concat(SAR_STANDARDS_INFO.synopsis, ''), concat(replace_stand_num, ''), replaced_stand_num, SAR_STANDARDS_INFO.creation_user, SAR_STANDARDS_INFO.valid_flag,
SAR_STANDARDS_INFO.creation_time, SAR_STANDARDS_INFO.modify_time,dicountry.DIC_TYPE_NAME, dicstandSort.DIC_TYPE_NAME,
dicstandState.DIC_TYPE_NAME,dicstandNature.DIC_TYPE_NAME,is_relate_access,cite_stand,cited_stand
dicstandState.DIC_TYPE_NAME,dicstandNature.DIC_TYPE_NAME,is_relate_access,cite_stand,cited_stand,SAR_STANDARDS_INFO.text_status
</sql>
<!-- 查询条件 -->
@@ -159,6 +161,12 @@
<if test="isRelateAccess != null" >
and is_relate_access = #{isRelateAccess}
</if>
<if test="textStatus != null" >
and text_status = #{textStatus}
</if>
<if test="standSystem != null" >
and stand_system = #{standSystem}
</if>
</trim>
</sql>
@@ -188,6 +196,8 @@
<if test="isRelateAccess != null" >is_relate_access,</if>
<if test="citeStand != null" >cite_stand,</if>
<if test="citedStand != null" >cited_stand,</if>
<if test="textStatus != null" >text_status,</if>
<if test="standSystem != null" >stand_system,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >#{id, jdbcType=VARCHAR},</if>
@@ -212,6 +222,8 @@
<if test="isRelateAccess != null" >#{isRelateAccess, jdbcType=VARCHAR},</if>
<if test="citeStand != null" >#{citeStand, jdbcType=VARCHAR},</if>
<if test="citedStand != null" >#{citedStand, jdbcType=VARCHAR},</if>
<if test="textStatus != null" >#{textStatus, jdbcType=VARCHAR},</if>
<if test="standSystem != null" >#{standSystem, jdbcType=VARCHAR},</if>
</trim>
</insert>
@@ -235,7 +247,9 @@
creation_user = #{creationUser},
valid_flag = #{validFlag},
creation_time = #{creationTime},
modify_time = #{modifyTime}
modify_time = #{modifyTime},
text_status = #{textStatus},
stand_system = #{standSystem}
where id = #{id}
</update>
@@ -306,6 +320,12 @@
<if test="citedStand != null" >
cited_stand = #{citedStand},
</if>
<if test="textStatus != null" >
text_status = #{textStatus},
</if>
<if test="standSystem != null" >
stand_system = #{standSystem},
</if>
</set>
where id = #{id}
</update>