You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

242 lines
9.5 KiB

<?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.epmet.dao.IcFormDao">
<!-- 查询表单 -->
<select id="selectByCode" parameterType="map" resultType="com.epmet.dto.result.CustomerFormResultDTO">
SELECT
f.id AS formId,
f.FORM_NAME AS formName
FROM
ic_form f
WHERE
f.DEL_FLAG = '0'
AND f.CUSTOMER_ID = #{customerId}
AND f.FORM_CODE = #{formCode}
</select>
<resultMap id="FormItemMap1" type="com.epmet.dto.result.FormItem">
<id property="itemId" column="item_id" ></id>
<result property="tableName" column="table_name"/>
<result property="parentItemId" column="PARENT_ITEM_ID"/>
<result property="label" column="LABEL"/>
<result property="itemType" column="ITEM_TYPE"/>
<result property="itemGroupId" column="ITEM_GROUP_ID"/>
<result property="required" column="REQUIRED"/>
<result property="validType" column="VALID_TYPE"/>
<result property="defaultValue" column="DEFAULT_VALUE"/>
<result property="optionSourceType" column="OPTION_SOURCE_TYPE"/>
<result property="optionSourceValue" column="OPTION_SOURCE_VALUE"/>
<result property="sort" column="SORT"/>
<result property="placeholder" column="PLACEHOLDER"/>
<result property="searchDisplay" column="SEARCH_DISPLAY"/>
<result property="listDisplay" column="LIST_DISPLAY"/>
<result property="dataAnalyse" column="DATA_ANALYSE"/>
<result property="columnName" column="COLUMN_NAME"/>
<result property="columnNum" column="COLUMN_NUM"/>
<result property="multiSelect" column="MULTI_SELECT"/>
<collection property="options" ofType="com.epmet.dto.result.OptionDTO"
column="item_id" select="com.epmet.dao.IcFormDao.selectListOption">
<result property="label" column=""/>
<result property="value" column="url"/>
</collection>
<collection property="childGroup" ofType="com.epmet.dto.result.FormGroupDTO"
column="item_id" select="com.epmet.dao.IcFormDao.selectChildGroup">
</collection>
</resultMap>
<select id="selectListOption" parameterType="java.lang.String" resultType="com.epmet.dto.result.OptionDTO">
SELECT
i.OPTION_LABEL as label,
i.OPTION_VALUE as value
FROM
ic_form_item_options i
WHERE
i.DEL_FLAG = '0'
AND i.ITEM_ID = #{itemId}
ORDER BY
i.SORT ASC
</select>
<select id="selectChildGroup" parameterType="java.lang.String" resultMap="FormGroupDTOMap">
SELECT
g.id AS group_id,
g.LABEL,
g.sort,
g.SUPPORT_ADD,
g.TABLE_NAME AS TABLE_NAME
FROM
ic_form_item_group g
WHERE
g.DEL_FLAG = '0'
AND g.id =(
SELECT DISTINCT
i.ITEM_GROUP_ID
FROM
ic_form_item i
WHERE
i.DEL_FLAG = '0'
AND i.PARENT_ITEM_ID = #{itemId}
)
</select>
<select id="selectItemList" parameterType="java.lang.String" resultMap="FormItemMap1">
SELECT
fi.ID AS item_id,
'ic_resi_user' AS table_name,
fi.PARENT_ITEM_ID,
fi.LABEL,
fi.ITEM_TYPE,
fi.ITEM_GROUP_ID,
fi.REQUIRED,
IFNULL(fi.VALID_TYPE,'') as VALID_TYPE,
IFNULL(fi.DEFAULT_VALUE,'') as DEFAULT_VALUE,
IFNULL(fi.OPTION_SOURCE_TYPE,'') as OPTION_SOURCE_TYPE,
IFNULL(fi.OPTION_SOURCE_VALUE,'') as OPTION_SOURCE_VALUE,
fi.SORT,
IFNULL(fi.PLACEHOLDER,'') as PLACEHOLDER,
fi.SEARCH_DISPLAY,
fi.LIST_DISPLAY,
fi.DATA_ANALYSE,
fi.COLUMN_NAME,
fi.COLUMN_NUM,
fi.MULTI_SELECT
FROM
ic_form_item fi
WHERE
fi.DEL_FLAG = '0'
AND fi.FORM_ID = #{formId}
<if test="dynamic != null">
AND fi.DYNAMIC = #{dynamic}
</if>
AND fi.ITEM_GROUP_ID = '0'
ORDER BY
fi.SORT ASC
</select>
<resultMap id="FormGroupDTOMap" type="com.epmet.dto.result.FormGroupDTO">
<id property="groupId" column="group_id" ></id>
<result property="label" column="LABEL"/>
<result property="sort" column="sort"/>
<result property="supportAdd" column="SUPPORT_ADD"/>
<result property="tableName" column="TABLE_NAME"/>
<collection property="itemList" ofType="com.epmet.dto.result.FormItem2"
column="group_id" select="com.epmet.dao.IcFormDao.selectItemListByGroupId">
</collection>
</resultMap>
<resultMap id="FormItemMap2" type="com.epmet.dto.result.FormItem2">
<id property="itemId" column="item_id" ></id>
<result property="tableName" column="table_name"/>
<result property="parentItemId" column="PARENT_ITEM_ID"/>
<result property="label" column="LABEL"/>
<result property="itemType" column="ITEM_TYPE"/>
<result property="itemGroupId" column="ITEM_GROUP_ID"/>
<result property="required" column="REQUIRED"/>
<result property="validType" column="VALID_TYPE"/>
<result property="defaultValue" column="DEFAULT_VALUE"/>
<result property="optionSourceType" column="OPTION_SOURCE_TYPE"/>
<result property="optionSourceValue" column="OPTION_SOURCE_VALUE"/>
<result property="sort" column="SORT"/>
<result property="placeholder" column="PLACEHOLDER"/>
<result property="searchDisplay" column="SEARCH_DISPLAY"/>
<result property="listDisplay" column="LIST_DISPLAY"/>
<result property="dataAnalyse" column="DATA_ANALYSE"/>
<result property="columnName" column="COLUMN_NAME"/>
<result property="columnNum" column="COLUMN_NUM"/>
<result property="multiSelect" column="MULTI_SELECT"/>
<collection property="options" ofType="com.epmet.dto.result.OptionDTO"
column="item_id" select="com.epmet.dao.IcFormDao.selectListOption">
<result property="label" column=""/>
<result property="value" column="url"/>
</collection>
</resultMap>
<select id="selectItemListByGroupId" parameterType="java.lang.String" resultMap="FormItemMap2">
SELECT
fi.ID AS item_id,
g.table_name AS table_name,
fi.PARENT_ITEM_ID,
fi.LABEL,
fi.ITEM_TYPE,
fi.ITEM_GROUP_ID,
fi.REQUIRED,
IFNULL(fi.VALID_TYPE,'') as VALID_TYPE,
IFNULL(fi.DEFAULT_VALUE,'') as DEFAULT_VALUE,
IFNULL(fi.OPTION_SOURCE_TYPE,'') as OPTION_SOURCE_TYPE,
IFNULL(fi.OPTION_SOURCE_VALUE,'') as OPTION_SOURCE_VALUE,
fi.SORT,
IFNULL(fi.PLACEHOLDER,'') as PLACEHOLDER,
fi.SEARCH_DISPLAY,
fi.LIST_DISPLAY,
fi.DATA_ANALYSE,
fi.COLUMN_NAME,
fi.COLUMN_NUM,
fi.MULTI_SELECT
FROM
ic_form_item fi
left join ic_form_item_group g
on(fi.ITEM_GROUP_ID=g.id)
WHERE
fi.DEL_FLAG = '0'
AND fi.ITEM_GROUP_ID = #{groupId}
AND fi.DYNAMIC = '1'
ORDER BY
fi.SORT ASC
</select>
<select id="selectListGroup" parameterType="java.lang.String" resultMap="FormGroupDTOMap">
SELECT
g.id AS group_id,
g.LABEL,
g.sort,
g.SUPPORT_ADD,
(
case when g.table_name is null or g.table_name ='' then 'ic_resi_user'
else g.TABLE_NAME
end
) AS TABLE_NAME
FROM
ic_form_item_group g
WHERE
g.DEL_FLAG = '0'
AND g.FORM_ID = #{formId}
AND g.DISPLAY = '1'
ORDER BY
g.SORT ASC
</select>
<select id="listItems" resultType="com.epmet.dto.result.FormItem">
SELECT fi.ID AS item_id,
case
when g.TABLE_NAME is null or g.TABLE_NAME = '' then 'ic_resi_user'
else g.TABLE_NAME end as table_name,
fi.PARENT_ITEM_ID,
pitem.LABEL PARENT_ITEM_LABEL,
fi.LABEL,
fi.ITEM_TYPE,
fi.ITEM_GROUP_ID,
g.LABEL as GROUP_LABEL,
fi.REQUIRED,
IFNULL(fi.VALID_TYPE, '') as VALID_TYPE,
IFNULL(fi.DEFAULT_VALUE, '') as DEFAULT_VALUE,
IFNULL(fi.OPTION_SOURCE_TYPE, '') as OPTION_SOURCE_TYPE,
IFNULL(fi.OPTION_SOURCE_VALUE, '') as OPTION_SOURCE_VALUE,
fi.SORT,
IFNULL(fi.PLACEHOLDER, '') as PLACEHOLDER,
fi.SEARCH_DISPLAY,
fi.LIST_DISPLAY,
fi.DATA_ANALYSE,
fi.COLUMN_NAME,
fi.COLUMN_NUM
FROM ic_form_item fi
left join ic_form_item_group g on (fi.ITEM_GROUP_ID = g.ID and fi.DEL_FLAG = 0 and g.DEL_FLAG = 0)
left join ic_form_item pitem on (pitem.DEL_FLAG = 0 and fi.PARENT_ITEM_ID = pitem.ID)
WHERE fi.FORM_ID = #{formId}
ORDER BY fi.SORT ASC
</select>
</mapper>