`
yansuihehe
  • 浏览: 1429 次
  • 性别: Icon_minigender_1
  • 来自: 济南
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

most.map.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.inspur.pmv5.dao.api.momgt.MOSTDao">
<resultMap type="com.inspur.pmv5.pojo.momgt.Othersys" id="Othersys">
<result column="MAPPINGID" property="mappingId" jdbcType="VARCHAR"/>
<result column="OTHERSYSID" property="othersyId" jdbcType="VARCHAR"/>
<result column="OTHERSYSNAME" property="othersysName" jdbcType="VARCHAR"></result>
<result column="ENABLE" property="enable" jdbcType="VARCHAR"/>
<result column="OTHERMOTYPEID" property="otherMotypeId" jdbcType="VARCHAR"/>
<result column="MODELID" property="modelId" jdbcType="VARCHAR"/>
<result column="MODELNAME" property="modelName" jdbcType="VARCHAR"/>
<result column="OTHERMOTYPECODE" property="otherMotypeCode" jdbcType="VARCHAR"/>
<result column="ISRELATION" property="isRelation" jdbcType="VARCHAR"/>
<result column="ATTRIBUTEID" property="keyAttributeId" jdbcType="VARCHAR"/>
<result column="OBJECTCODERULES" property="objectCodeRules" jdbcType="VARCHAR"/>
<result column="ISMASTER" property="isMaster" jdbcType="VARCHAR"/>
<result column="OTHERSYS_ATTRIBUTEID" property="othersysKeyAttributeId" jdbcType="VARCHAR"/>
<result column="OTHERMODELID" property="otherModelId" jdbcType="VARCHAR"/>
<result column="OTHERSYS_SWTCH" property="othersysSwitchExp" jdbcType="VARCHAR"/>
<result column="SYNCHRONOUSDATE" property="synchronousDate" jdbcType="DATE"/>
<result column="OTHERSYS_SWTCHATTRIBUTEID" property="switchOthersysAttributeId" jdbcType="VARCHAR"/>
<result column="OTHERSYS_SWTCHVALUE" property="switchOthersysAttributeValue" jdbcType="VARCHAR"/>
<result column="ISPMRELATION" property="isPMRelation" jdbcType="VARCHAR"/>
<result column="ENABLESTR" property="enableStr" jdbcType="VARCHAR"/>
<result column="ATTRIBUTEID" property="attributeId" jdbcType="VARCHAR"/>
<result column="ATTRIBUTENAME" property="attributeName" jdbcType="VARCHAR"/>
<result column="OTHERATTRIBUTEID" property="othersAttributeId" jdbcType="VARCHAR"/>
<result column="OTHERSYS_ATTRIBUTENAME" property="othersAttributeName" jdbcType="VARCHAR"/>
<result column="CURSYNCHRONOUSDATE" property="curSynchronousDate" jdbcType="VARCHAR"/>
<result column="CURSYNCHRONOUSPAGETOTAL" property="curSynchronousPageTotal" jdbcType="VARCHAR"/>
<result column="CURSYNCHRONOUSPAGE" property="curSynchronousPage" jdbcType="VARCHAR"/>
</resultMap>
<resultMap type="com.inspur.pmv5.pojo.momgt.OthersysAttribute" id="OthersysAttribute">
<result column="MAPPINGID" property="mappingId" jdbcType="VARCHAR"/>
<result column="OTHERSYSID" property="othersysId" jdbcType="VARCHAR"/>
<result column="OTHERMOTYPEID" property="otherMotypeId" jdbcType="VARCHAR"/>
<result column="ATTRIBUTEID" property="attributeId" jdbcType="VARCHAR"/>
<result column="ATTRIBUTENAME" property="attributeName" jdbcType="VARCHAR"/>
<result column="OTHERATTRIBUTEID" property="othersysAttributeId" jdbcType="VARCHAR"/>
<result column="OTHERSYS_ATTRIBUTECODE" property="othersysAttributeCode" jdbcType="VARCHAR"/>
<result column="ENABLE" property="enable" jdbcType="VARCHAR"/>
<result column="OTHERSYS_ATTRIBUTENAME" property="othersysAttributeName" jdbcType="VARCHAR"/>
<result column="OTHERSYS_ATTRIBUTETYPE" property="othersysAttributeType" jdbcType="VARCHAR"/>
<result column="OTHERSYS_LABELNAME" property="othersysLabelName" jdbcType="VARCHAR"/>
<result column="OTHERSYS_PRIMARYKEY" property="othersysPrimaryKey" jdbcType="VARCHAR"/>
<result column="OTHERSYS_ATTRIBUTEIDCHANGE" property="othersysAttributeIDChange" jdbcType="VARCHAR"/>
<result column="ISRELATIONFIELD" property="isRelationField" jdbcType="VARCHAR"/>
<result column="ENABLESTR" property="enableStr" jdbcType="VARCHAR"/>
<result column="ISRELATIONFIELDSTR" property="isRelationFieldStr" jdbcType="VARCHAR"/>
<result column="PARAMETERGROUPNAME" property="parameterGroupName" jdbcType="VARCHAR"/>
<result column="PARAMETERTYPE" property="parameterType" jdbcType="VARCHAR"/>
<result column="DISPLAYORDER" property="displayOrder" jdbcType="VARCHAR"/>
</resultMap>
<select id="getEnableOthersys" resultMap="Othersys" parameterType="string">
select * from mdl_othersys where ENABLE=1 and OTHERSYSID=#{othersysId}
</select>

<select id="getOthersysModel" resultMap="Othersys" parameterType="string">
select t.othermodelid,
   t.othersysid,
          t.othermotypeid,
          t.othermotypecode,
               t.ismaster,
          t.enable,
          t.isrelation
    from MDL_OTHERSYSMODEL t
where t.OTHERSYSID = #{othersysId}
   and t.ISRELATION!=3
</select>

<select id="getPMAttribute" parameterType="hashmap" resultMap="OthersysAttribute">
<choose>
<when test="isPMRelation != 'relation'">
select t.mappingid,
       a.attributeid,
       a.attributename,
       o.othersysid,
       o.othersys_motypeid,
       o.otherattributeid,
       o.othersys_attributecode,
       o.othersys_attributename,
       o.othersys_attributetype,
       o.othersys_labelname,
       o.othersys_primarykey,
       o.enable,
       decode(o.enable,1,'mapped','not mapped') enableStr,
       'common attribute' isRelationFieldStr,
       t.othersys_attributeidchange,
       '0' as isRelationField
  from mdl_resattribute a
  left join mdl_othersysattrmapping t
    on a.attributeid = t.attributeid
  left join mdl_othersysattr o
    on o.otherattributeid = t.otherattributeid
where a.modelid = #{moTypeId}
   and a.enable = 1
   and a.attributename not in
              ('VEREndtime', 'VERID', 'VERStarttime', 'OBJID')
          and (a.equipmentpara = -1 or a.equipmentpara = 0)
       union all
       select t1.mappingid,
       m.relationid attributeid,
       r.modelname attributename,
       o1.othersysid,
       o1.othersys_motypeid,
       o1.otherattributeid,
       o1.othersys_attributecode,
       o1.othersys_attributename,
       o1.othersys_attributetype,
       o1.othersys_labelname,
       o1.othersys_primarykey,
       o1.enable,
       decode(o1.enable,1,'mapped','not mapped') enableStr,
       'relation attribute' isRelationFieldStr,
       t1.othersys_attributeidchange,
       '1' as isRelationField
  from mdl_relation m
  left join mdl_resmodel r
    on m.modelb = r.modelid
  left join mdl_othersysattrmapping t1
    on m.relationid = t1.attributeid
  left join mdl_othersysattr o1
    on o1.otherattributeid = t1.otherattributeid
where m.enable = 1
   and m.modela = #{moTypeId}
</when>
<otherwise>
select t1.mappingid,
       m.modelb attributeid,
       r.modelname attributename,
       o1.othersysid,
       o1.othersys_motypeid,
       o1.otherattributeid,
       o1.othersys_attributecode,
       o1.othersys_attributename,
       o1.othersys_attributetype,
       o1.othersys_labelname,
       o1.othersys_primarykey,
       o1.enable,
       decode(o1.enable,1,'mapped','not mapped') enableStr,
       'relation attribute' isRelationFieldStr,
       t1.othersys_attributeidchange,
       '1' as isRelationField
  from mdl_relation m
  left join mdl_resmodel r
    on m.modelb = r.modelid
  left join mdl_othersysattrmapping t1
    on m.modelb = t1.attributeid
  left join mdl_othersysattr o1
    on o1.otherattributeid = t1.otherattributeid
where m.enable = 1
   and m.relationid = #{moTypeId}
</otherwise>
</choose>
<!-- <if test="isPMRelation != 'relation'">
select t.mappingid,
       a.attributeid,
       a.attributename,
       o.othersysid,
       o.othersys_motypeid,
       o.otherattributeid,
       o.othersys_attributecode,
       o.othersys_attributename,
       o.othersys_attributetype,
       o.othersys_labelname,
       o.othersys_primarykey,
       o.enable,
       decode(o.enable,1,'mapped','not mapped') enableStr,
       'common attribute' isRelationFieldStr,
       t.othersys_attributeidchange,
       '0' as isRelationField
  from mdl_resattribute a
  left join mdl_othersysattrmapping t
    on a.attributeid = t.attributeid
  left join mdl_othersysattr o
    on o.otherattributeid = t.otherattributeid
where a.modelid = #{moTypeId}
   and a.enable = 1
   and a.attributename not in
              ('VEREndtime', 'VERID', 'VERStarttime', 'OBJID')
union all
</if>
select t1.mappingid,
       m.modelb attributeid,
       r.modelname attributename,
       o1.othersysid,
       o1.othersys_motypeid,
       o1.otherattributeid,
       o1.othersys_attributecode,
       o1.othersys_attributename,
       o1.othersys_attributetype,
       o1.othersys_labelname,
       o1.othersys_primarykey,
       o1.enable,
       decode(o1.enable,1,'mapped','not mapped') enableStr,
       'relation attribute' isRelationFieldStr,
       t1.othersys_attributeidchange,
       '1' as isRelationField
  from mdl_relation m
  left join mdl_resmodel r
    on m.modelb = r.modelid
  left join mdl_othersysattrmapping t1
    on m.modelb = t1.attributeid
  left join mdl_othersysattr o1
    on o1.otherattributeid = t1.otherattributeid
where m.enable = 1
   and m.relationid = #{moTypeId} -->
</select>

<select id="getMostAttributeByModelId" parameterType="hashmap" resultMap="OthersysAttribute">
select * from mdl_othersysattr t where t.othersys_motypeid=#{mostModelId}
</select>

<select id="checkOthersysExist" parameterType="hashmap" resultMap="Othersys">
select OTHERMOTYPEID, ENABLE
  from MDL_OTHERSYSMODEL t
where 1=1
<if test="othersysId != null">
and t.othersysid=#{othersysId}
</if>
<if test="otherMotypeCode != null">
and t.OTHERMOTYPEID=#{otherMotypeCode}
</if>
<if test="isRelation != null">
and t.ISRELATION=#{isRelation}
</if>
</select>
<select id="getOthersysByCode" parameterType="hashmap" resultMap="Othersys">
select * from mdl_othersysmodelmapping t
where 1=1
<if test="othersysId != null and othersysId != ''">
and t.othersysid=#{othersysId}
</if>
<if test="otherMotypeCode != null and otherMotypeCode != ''">
and t.othermotypecode like '%'||#{otherMotypeCode}||'%'
</if>
</select>
<update id="updateOthersysMapping" parameterType="com.inspur.pmv5.pojo.momgt.Othersys">
update MDL_OTHERSYSMODELMAPPING set OTHERMODELID=#{otherModelId}
,MODELID=#{modelId}
<if test="keyAttributeId != null">,ATTRIBUTEID=#{keyAttributeId}</if>
<if test="othersysKeyAttributeId != null">,OTHERSYS_ATTRIBUTEID=#{othersysKeyAttributeId}</if>
<if test="switchOthersysAttributeId != null">,OTHERSYS_SWTCHATTRIBUTEID=#{switchOthersysAttributeId}</if>
<if test="switchOthersysAttributeValue != null">,OTHERSYS_SWTCHVALUE=#{switchOthersysAttributeValue}</if>
<if test="othersysSwitchExp != null">,OTHERSYS_SWTCH=#{othersysSwitchExp}</if>
<if test="objectCodeRules != null">,OBJECTCODERULES=#{objectCodeRules}</if>
where MAPPINGID=#{mappingId}
</update>
<update id="updateOthersys" parameterType="com.inspur.pmv5.pojo.momgt.Othersys">
update MDL_OTHERSYSMODEL set ISRELATION=#{isRelation}
<if test="enable != null">,ENABLE=#{enable}</if>
<if test="otherMotypeCode != null">,OTHERMOTYPECODE=#{otherMotypeCode}</if>
<if test="isMaster != null">,ISMASTER=#{isMaster}</if>
where OTHERSYSID=#{othersyId} and OTHERMOTYPEID=#{otherMotypeId}
</update>
<update id="updateOthersysAttr" parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute">
update MDL_OTHERSYSATTR set OTHERSYSID=#{othersysId}
<!-- <if test="isMaster != null and isMaster != ''">
,OTHERMOTYPEID=#{otherMotypeId}
</if> -->
<if test="enable != null and enable != ''">
,ENABLE=#{enable}
</if>
<if test="othersysAttributeName != null and othersysAttributeName != ''">
,OTHERSYS_ATTRIBUTENAME=#{othersysAttributeName}
</if>
<if test="othersysAttributeType != null and othersysAttributeType != ''">
,OTHERSYS_ATTRIBUTETYPE=#{othersysAttributeType}
</if>
<if test="othersysLabelName != null and othersysLabelName != ''">
,OTHERSYS_LABELNAME=#{othersysLabelName}
</if>
<if test="othersysPrimaryKey != null and othersysPrimaryKey != ''">
,OTHERSYS_PRIMARYKEY=#{othersysPrimaryKey}
</if>
where OTHERSYSID=#{othersysId}
  and OTHERSYS_MOTYPEID=#{otherMotypeId}
  and OTHERSYS_ATTRIBUTECODE=#{othersysAttributeCode}
</update>
<update id="updateOthersysKeyAttributeId" parameterType="com.inspur.pmv5.pojo.momgt.Othersys">
update MDL_OTHERSYSMODELMAPPING set OTHERSYS_ATTRIBUTEID=#{othersysKeyAttributeId}
where OTHERMOTYPECODE=#{otherMotypeCode}
   and ISRELATION=#{isRelation}
   and OTHERSYSID=#{othersyId}
</update>
<insert id="addOthersys" parameterType="com.inspur.pmv5.pojo.momgt.Othersys">
insert into MDL_OTHERSYSMODEL
  (OTHERSYSID
<if test="otherModelId!=null">,OTHERMODELID</if>
<if test="otherMotypeId!=null">,OTHERMOTYPEID</if>
<if test="otherMotypeCode!=null">,OTHERMOTYPECODE</if>
<if test="isRelation!=null">,ISRELATION</if>
<if test="isMaster!=null">,ISMASTER</if>
<if test="enable!=null">,ENABLE</if>
)
values
  (#{othersyId}
  <if test="otherModelId!=null">,#{otherModelId,jdbcType=VARCHAR}</if>
  <if test="otherMotypeId!=null">,#{otherMotypeId,jdbcType=VARCHAR}</if>
  <if test="otherMotypeCode!=null">,#{otherMotypeCode,jdbcType=VARCHAR}</if>
  <if test="isRelation!=null">,#{isRelation,jdbcType=VARCHAR}</if>
  <if test="isMaster!=null">,#{isMaster,jdbcType=VARCHAR}</if>
  <if test="enable!=null">,#{enable,jdbcType=VARCHAR}</if>
  )
</insert>
<select id="checkOthersysAttributeExist" parameterType="hashmap" resultType="OthersysAttribute">
select OTHERSYS_ATTRIBUTECODE, ENABLE from MDL_OTHERSYSATTR
where OTHERSYSID=#{othersysId}
   and OTHERSYS_MOTYPEID=#{otherMotypeId}
   and OTHERSYS_ATTRIBUTECode=#{othersysAttributeId}
   and OTHERSYS_ATTRIBUTETYPE!='Relation'
</select>
<select id="checkOthersysAttrRelationExist" resultType="OthersysAttribute" parameterType="hashmap">
select OTHERSYS_ATTRIBUTECODE,to_char(ENABLE) as ENABLE
  from MDL_OTHERSYSATTR
where OTHERSYSID=#{othersysId,jdbcType=VARCHAR}
   and OTHERSYS_MOTYPEID=#{otherMotypeId,jdbcType=VARCHAR}
   and OTHERSYS_ATTRIBUTECODE=#{othersysAttributeId,jdbcType=VARCHAR}
   and OTHERSYS_LABELNAME=#{othersysLabelName,jdbcType=VARCHAR}
   and OTHERSYS_ATTRIBUTETYPE='Relation'
</select>
<update id="updateOthersysAttrRelation" parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute">
update MDL_OTHERSYSATTR set OTHERSYSID=#{othersysId}
<!-- <if test="isMaster != null and isMaster != ''">
,OTHERMOTYPEID=#{otherMotypeId}
</if> -->
<if test="enable != null and enable != ''">
,ENABLE=#{enable}
</if>
where OTHERSYS_ATTRIBUTECODE=#{othersysAttributeCode}
  and OTHERSYS_MOTYPEID=#{otherMotypeId}
  and OTHERSYS_LABELNAME=#{othersysLabelName}
  and OTHERSYS_ATTRIBUTETYPE='Relation'
</update>
<insert id="addRelation" parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute">
insert into MDL_OTHERSYSATTR (OTHERSYSID
<if test="attributeId != null">,OTHERATTRIBUTEID</if>
<if test="otherMotypeId!=null">,OTHERSYS_MOTYPEID</if>
<if test="othersysAttributeCode!=null">,OTHERSYS_ATTRIBUTECODE</if>
<if test="othersysAttributeName!=null">,OTHERSYS_ATTRIBUTENAME</if>
,OTHERSYS_ATTRIBUTETYPE
<if test="othersysLabelName!=null">,OTHERSYS_LABELNAME</if>
<if test="othersysPrimaryKey!=null">,OTHERSYS_PRIMARYKEY</if>
<if test="enable!=null">,ENABLE</if>) values
(#{othersysId}
<if test="attributeId != null">,#{attributeId}</if>
<if test="otherMotypeId!=null">,#{otherMotypeId}</if>
<if test="othersysAttributeCode!=null">,#{othersysAttributeCode}</if>
<if test="othersysAttributeName!=null">,#{othersysAttributeName}</if>
,'Relation'
<if test="othersysLabelName!=null">,#{othersysLabelName}</if>
<if test="othersysPrimaryKey!=null">,#{othersysPrimaryKey}</if>
<if test="enable!=null">,#{enable}</if>
)
</insert>
<insert id="addOthersysAttr" parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute">
insert into MDL_OTHERSYSATTR (OTHERSYSID
<if test="attributeId != null">,OTHERATTRIBUTEID</if>
<if test="otherMotypeId != null">,OTHERSYS_MOTYPEID</if>
<if test="othersysAttributeCode != null">,OTHERSYS_ATTRIBUTECODE</if>
<if test="othersysAttributeName != null">,OTHERSYS_ATTRIBUTENAME</if>
<if test="othersysAttributeType != null">,OTHERSYS_ATTRIBUTETYPE</if>
<if test="othersysLabelName != null">,OTHERSYS_LABELNAME</if>
<if test="othersysPrimaryKey != null">,OTHERSYS_PRIMARYKEY</if>
<if test="enable != null">,ENABLE</if>) values
(#{othersysId}
<if test="attributeId != null">,#{attributeId}</if>
<if test="otherMotypeId != null">,#{otherMotypeId}</if>
<if test="othersysAttributeCode != null">,#{othersysAttributeCode}</if>
<if test="othersysAttributeName != null">,#{othersysAttributeName}</if>
<if test="othersysAttributeType != null">,#{othersysAttributeType}</if>
<if test="othersysLabelName != null">,#{othersysLabelName}</if>
<if test="othersysPrimaryKey != null">,#{othersysPrimaryKey}</if>
<if test="enable != null">,#{enable}</if>
)
</insert>
<select id="getOthersysByDomainIdFuzzy" parameterType="hashmap" resultMap="Othersys">
select m.mappingid,
       r.modelid,
       r.modelname,
       o.othersysid,
       o.othersysname,
       s.enable,
       s.othermodelid,
       s.othermotypeid,
       s.othermotypecode,
       s.isrelation,
       m.attributeid,
       m.othersys_attributeid,
       m.objectcoderules,
       s.ismaster,
       m.othersys_swtch
  from mdl_resmodel r
  left join mdl_othersysmodelmapping m
    on r.modelid = m.modelid
  left join mdl_othersysmodel s
    on m.othermodelid = s.othermodelid
  left join mdl_othersys o
    on o.othersysid = s.othersysid
where r.enable=1 and r.belongparmodelid is null
<if test="domainId != 'root'">
and r.domainid = #{domainId}
</if>
<if test="name != null and name != ''">
and upper(r.MODELNAME) like '%'||upper(#{name})||'%'
</if>
</select>
<select id="getOthersysByDomainId" parameterType="hashmap" resultMap="Othersys">

select m.mappingid,
       r.modelid,
       r.modelname,
       o.othersysid,
       o.othersysname,
       s.enable,
       decode(s.enable,1,'mapped','not mapped') enablestr,
       s.othermodelid,
       s.othermotypeid,
       s.othermotypecode,
       s.isrelation,
       m.attributeid,
       m.othersys_attributeid,
       m.objectcoderules,
       s.ismaster,
       m.othersys_swtchattributeid,
       m.othersys_swtchvalue,
       m.othersys_swtch,
       'model' isPMRelation
  from mdl_resmodel r
  left join mdl_othersysmodelmapping m
    on r.modelid = m.modelid
  left join mdl_othersysmodel s
    on m.othermodelid = s.othermodelid
  left join mdl_othersys o
    on o.othersysid = s.othersysid
where r.enable = 1 and r.belongparmodelid is null and (s.isrelation is null or s.isrelation != 3)
<if test="domainId != 'root'">
and r.domainid = #{domainId}
</if>

union all

select m.mappingid,
       a.relationid "modelid",
       ra.modelname || '.' || ra.modelname || '_' || rb.modelname "modelname",
       o.othersysid,
       o.othersysname,
       s.enable,
       decode(s.enable,1,'mapped','not mapped') enablestr,
       s.othermodelid,
       s.othermotypeid,
       s.othermotypecode,
       s.isrelation,
       m.attributeid,
       m.othersys_attributeid,
       m.objectcoderules,
       s.ismaster,
       m.othersys_swtchattributeid,
       m.othersys_swtchvalue,
       m.othersys_swtch,
       'relation' isPMRelation
  from mdl_relation a
  left join mdl_resmodel ra
    on a.modela = ra.modelid
  left join mdl_resmodel rb
    on a.modelb = rb.modelid
  left join mdl_othersysmodelmapping m
    on a.relationid = m.modelid
  left join mdl_othersysmodel s
    on m.othermodelid = s.othermodelid
  left join mdl_othersys o
    on o.othersysid = s.othersysid
where a.modela in (select b.modelid
                      from mdl_resmodel b
                     where b.enable = 1
                     <if test="domainId != 'root'">
   and ra.domainid = #{domainId}
                     </if>)
   and a.enable = 1 and ra.belongparmodelid is null and (s.isrelation is null or s.isrelation != 3)
</select>
<update id="setAttributeEnableToZero" parameterType="hashmap">
update MDL_OTHERSYSATTR set ENABLE=0
where OTHERSYSID=#{othersysId}
  and OTHERSYS_MOTYPEID=#{otherMotypeId}
  <if test="attrIds != null and attrIds.size() != 0">
  and OTHERSYS_ATTRIBUTECODE not in
  <foreach collection="attrIds" item="attrId" open="(" close=")" separator=",">
  #{attrId}
  </foreach>
  </if>
  and OTHERSYS_ATTRIBUTETYPE!='BasicProperties'
  and OTHERSYS_ATTRIBUTETYPE!='Relation'
  and PARAMETERTYPE=0
</update>
<update id="setRelationEnableToZero" parameterType="hashmap">
update MDL_OTHERSYSATTR set ENABLE=0
where OTHERSYSID=#{othersysId}
  and OTHERSYS_MOTYPEID=#{moTypeId}
  <if test="pathList != null and pathList.size() != 0">
  and OTHERSYS_ATTRIBUTECODE||OTHERSYS_LABELNAME not in
  <foreach collection="pathList" item="listItem" open="(" close=")" separator=",">
  #{listItem}
  </foreach>
  </if>
  and OTHERSYS_ATTRIBUTETYPE='Relation'
  and OTHERSYS_ATTRIBUTETYPE!='BasicProperties'
  and PARAMETERTYPE=0
</update>
<update id="setOthersysEnableToZero" parameterType="hashmap">
update MDL_OTHERSYSMODEL set ENABLE=0
where OTHERSYSID=#{othersysId}
  <if test="othersysIds != null and othersysIds.size() != 0">
  and OTHERMOTYPEID not in
  <foreach collection="othersysIds" item="listItem" open="(" close=")" separator=",">
  #{listItem}
  </foreach>
  </if>
  and ISRELATION!=3
</update>
<update id="setOthersysEnableToZeroByMoTypeId" parameterType="hashmap">
update MDL_OTHERSYSATTR set ENABLE=0
where OTHERSYSID=#{othersysId}
  <if test="othersysIds != null and othersysIds.size() != 0">
  and OTHERSYS_MOTYPEID not in
  <foreach collection="othersysIds" item="listItem" open="(" close=")" separator=",">
  #{listItem}
  </foreach>
  </if>
  and PARAMETERTYPE=0
</update>
<delete id="deleteOthersysModelMapping" parameterType="hashmap">
delete MDL_OTHERSYSMODELMAPPING where MAPPINGID=#{mappingId}
</delete>
<insert id="addOthersysModelMapping" parameterType="com.inspur.pmv5.pojo.momgt.Othersys">
insert into MDL_OTHERSYSMODELMAPPING (MAPPINGID,OTHERMODELID,MODELID
<if test="keyAttributeId != null">,ATTRIBUTEID</if>
<if test="othersysKeyAttributeId != null">,OTHERSYS_ATTRIBUTEID</if>
<if test="switchOthersysAttributeId != null">,OTHERSYS_SWTCHATTRIBUTEID</if>
<if test="switchOthersysAttributeValue != null">,OTHERSYS_SWTCHVALUE</if>
<if test="othersysSwitchExp != null">,OTHERSYS_SWTCH</if>
<if test="objectCodeRules != null">,OBJECTCODERULES</if>)
values (#{mappingId},#{otherModelId},#{modelId}
<if test="keyAttributeId != null">,#{keyAttributeId}</if>
<if test="othersysKeyAttributeId != null">,#{othersysKeyAttributeId}</if>
<if test="switchOthersysAttributeId != null">,#{switchOthersysAttributeId}</if>
<if test="switchOthersysAttributeValue != null">,#{switchOthersysAttributeValue}</if>
<if test="othersysSwitchExp != null">,#{othersysSwitchExp}</if>
<if test="objectCodeRules != null">,#{objectCodeRules}</if>)
</insert>
<insert id="addOthersysAttrMapping"  parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute">
insert into MDL_OTHERSYSATTRMAPPING (MAPPINGID, OTHERATTRIBUTEID, ATTRIBUTEID
<if test="othersysAttributeIDChange != null">,OTHERSYS_ATTRIBUTEIDCHANGE</if>)
values (#{mappingId},#{othersysAttributeId},#{attributeId}
<if test="othersysAttributeIDChange != null">,#{othersysAttributeIDChange}</if>)
</insert>
<delete id="deleteOthersysAttrMapping" parameterType="java.lang.String">
delete MDL_OTHERSYSATTRMAPPING where MAPPINGID=#{mappingId}
</delete>
<update id="updateAttrMapping" parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute">
update MDL_OTHERSYSATTRMAPPING
   set OTHERATTRIBUTEID=#{othersysAttributeId}
   ,ATTRIBUTEID=#{attributeId}
   <if test="othersysAttributeIDChange != null">
   OTHERSYS_ATTRIBUTEIDCHANGE=#{othersysAttributeIDChange}
   </if>
where MAPPINGID=#{mappingId}
</update>
<update id="changeDeleteModelEnable">
    update MDL_OTHERSYSMODEL set ENABLE=-1 where
    OTHERMODELID not in (select OTHERMODELID from MDL_OTHERSYSMODELMAPPING)
    and ENABLE != 0
</update>
<update id="changeModelEnable">
    update MDL_OTHERSYSMODEL set ENABLE=1 where
    OTHERMODELID in (select OTHERMODELID from MDL_OTHERSYSMODELMAPPING)
    and ENABLE != 0
</update>
<update id="updateDeleteAttrEnable" parameterType="hashmap">
    update MDL_OTHERSYSATTR set ENABLE=-1 where
    OTHERATTRIBUTEID not in (select OTHERATTRIBUTEID from MDL_OTHERSYSATTRMAPPING)
    and ENABLE != 0
</update>
<update id="updateAttrEnable" parameterType="hashmap">
    update MDL_OTHERSYSATTR set ENABLE=1 where
    OTHERATTRIBUTEID in
    (select OTHERATTRIBUTEID from MDL_OTHERSYSATTRMAPPING)
    and ENABLE != 0
</update>

<select id="getMOSTMOTypeByCIName" parameterType="hashmap" resultMap="Othersys">
select t.othermodelid,
       t.othersysid,
       t.othermotypeid,
       t.othermotypecode,
       t.isrelation,
       t.ismaster,
       t.enable,
       t.synchronousdate,
       t.cursynchronousdate,
           t.cursynchronouspagetotal,
           t.cursynchronouspage,
       m.mappingid,
       m.modelid,
       m.attributeid,
       m.othersys_attributeid,
       m.othersys_swtchattributeid,
       m.othersys_swtchvalue,
       m.othersys_swtch,
       m.objectcoderules
  from mdl_othersysmodel t
  left join mdl_othersysmodelmapping m
    on t.othermodelid = m.othermodelid
where
<choose>
<when test="CIName.indexOf('Parameters') != -1">
t.othermotypeid like '%' || #{CIName} || '%'
</when>
<otherwise>
t.othermotypeid = #{CIName}
</otherwise>
</choose>
</select>

<select id="getMOSTAttributeByMostMOTypeId" parameterType="hashmap" resultMap="OthersysAttribute">
select t.otherattributeid,
       t.othersysid,
       t.othersys_motypeid,
       t.othersys_attributecode,
       t.othersys_attributename,
       t.othersys_attributetype,
       t.othersys_labelname,
       t.othersys_primarykey,
       t.enable,
       m.mappingid,
       m.attributeid,
       m.othersys_attributeidchange
  from mdl_othersysattr t
  left join mdl_othersysattrmapping m
    on t.otherattributeid = m.otherattributeid
where t.othersys_motypeid = #{othersysMOTypeId}
</select>

<select id="getAllEnableModel" parameterType="java.lang.String" resultMap="Othersys">
select *
  from mdl_othersysmodelmapping m
  left join mdl_othersysmodel t
    on m.othermodelid = t.othermodelid
where t.enable = 1
<!--  select * from mdl_othersysmodel t where t.isrelation=1 -->
</select>
<select id="getOthersysModelMappings" parameterType="java.lang.String" resultMap="Othersys">
select * from MDL_OTHERSYSMODELMAPPING t where t.OTHERMODELID=#{otherModelId}
</select>
<select id="getAttrMapping" parameterType="hashmap" resultMap="OthersysAttribute">
select t1.OTHERATTRIBUTEID, t1.ATTRIBUTEID, t2.OTHERSYS_ATTRIBUTENAME from MDL_OTHERSYSATTRMAPPING t1,MDL_OTHERSYSATTR t2
where t1.OTHERATTRIBUTEID=t2.OTHERATTRIBUTEID 
<if test="attrIds != null and attrIds.size() != 0">
and t1.ATTRIBUTEID in
<foreach collection="attrIds" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
<if test="otherAttrIds != null and otherAttrIds.size() != 0">
and t1.OTHERATTRIBUTEID in
<foreach collection="otherAttrIds" open="(" close=")" separator="," item="otheritem">
#{otheritem}
</foreach>
</if>
</select>
<select id="getAttrByModelId" parameterType="hashmap" resultType="java.lang.String">
select t.OTHERATTRIBUTEID
    from mdl_othersysattr t, mdl_othersysmodel mo
     where t.othersysid = mo.othersysid
           and t.othersys_motypeid = mo.othermotypeid
           and mo.othermodelid = #{otherModelId}
           and t.OTHERSYSID=#{othersysId}
</select>
<select id="getMOCount" parameterType="hashmap" resultType="java.lang.Integer">
select count(${columnName}) from ${tableName} where ${columnName}=#{value}
</select>
<select id="getMOAttrName" parameterType="java.lang.String" resultType="java.lang.String">
select t.attributename from mdl_resattribute t where t.attributeid=#{attrID}
</select>
<select id="getMOSTAttrName" parameterType="java.lang.String" resultType="java.lang.String">
select t.OTHERSYS_ATTRIBUTENAME from MDL_OTHERSYSATTR t where t.OTHERATTRIBUTEID=#{mostAttrID}
</select>
<update id="updateEntity" parameterType="hashmap">
${sql}
</update>
<insert id="addEntity" parameterType="hashmap">
${sql}
</insert>
<select id="checkBasicAttributeExist" parameterType="hashmap" resultMap="OthersysAttribute">
select t.OTHERSYS_ATTRIBUTENAME,t.OTHERSYS_ATTRIBUTECODE
  from MDL_OTHERSYSATTR t where OTHERSYSID=#{othersysId}
   and OTHERSYS_MOTYPEID=#{otherModelId}
   and OTHERSYS_ATTRIBUTENAME=#{basicAttrName}
   and OTHERSYS_ATTRIBUTETYPE='BasicProperties'
</select>
<update id="changeOthersysUpdateDate" parameterType="Othersys">
update MDL_OTHERSYSMODEL t set SYNCHRONOUSDATE=sysdate
where OTHERSYSID=#{othersyId}
   and OTHERMOTYPEID=#{otherMotypeId}
</update>
<select id="getAllEnableRelation" parameterType="java.lang.String" resultMap="Othersys">
select t.othermodelid,
       t.othersysid,
       t.othermotypeid,
       t.othermotypecode,
       t.isrelation,
       t.ismaster,
       t.enable,
       t.synchronousdate,
       m.mappingid,
       m.modelid
  from MDL_OTHERSYSMODEL t
  left join mdl_othersysmodelmapping m
    on t.othermodelid = m.othermodelid
where OTHERSYSID = #{othersyId}
   and ISRELATION = 2
   and ENABLE = 1
</select>
<update id="updateMOSTSynDate" parameterType="java.lang.String">
update MDL_OTHERSYSMODEL t set SYNCHRONOUSDATE=sysdate
where OTHERMODELID=#{otherModelId}
</update>

<update id="updateMOSTSynDateByCiName" parameterType="java.lang.String">
update MDL_OTHERSYSMODEL t set SYNCHRONOUSDATE=sysdate
where OTHERMOTYPEID like #{ciName} ||'%'
</update>

<select id="getRelationMappings" parameterType="java.lang.String" resultMap="Othersys">
select * from MDL_OTHERSYSMODELMAPPING t where t.OTHERMODELID=#{otherModelId}
</select>
<insert id="addOrUpdateMOSTEntity" parameterType="MOEntity">
insert into ${tableName}
(
OBJID
,OBJNAME
,OBJCODE
,EQUIPMENTMODELID
,ISONSITE
,EMSENTITYID
,VERID
,VERSTARTTIME
,EQUIPMENTENTITYID
,EMSID
,VERSION
,TIMEZONE
<if test="attrList != null">
<foreach collection="attrList" index="index" item="attr"
separator="," open=",">
${attr.columnName}
</foreach>
</if>
<if test="refList != null">
<foreach collection="refList" index="index" item="ref"
separator="," open=",">
${ref.columnName}
</foreach>
</if>
)
values
(
<choose>
<when test="objId != null">#{objId},</when>
<otherwise>SEQ_MO.Nextval,</otherwise>
</choose>
<choose>
<when test="objName == null and objId != null">
(select OBJNAME from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="objName == null and objId == null">
<!-- '', -->
SEQ_MO.CURRVAL,
</when>
<otherwise>
#{objName},
</otherwise>
</choose>
<choose>
<when test="objCode == null and objId != null">
(select OBJCODE from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="objCode == null and objId == null">
<!-- '', -->
SEQ_MO.CURRVAL,
</when>
<otherwise>
#{objCode},
</otherwise>
</choose>
<choose>
<when test="equipmentMOId == null and objId != null">
(select EQUIPMENTMODELID from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="equipmentMOId == null and objId == null">
'',
</when>
<otherwise>
#{equipmentMOId},
</otherwise>
</choose>
<choose>
<when test="isOnSite == null and objId != null">
(select ISONSITE from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="isOnSite == null and objId == null">
'',
</when>
<otherwise>
#{isOnSite},
</otherwise>
</choose>
<choose>
<when test="emsEntryId == null and objId != null">
(select EMSENTITYID from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="emsEntryId == null and objId == null">
'',
</when>
<otherwise>
#{emsEntryId},
</otherwise>
</choose>
SEQ_VER.Nextval,
sysdate,
<choose>
<when test="equipmentId == null and objId != null">
(select EQUIPMENTENTITYID from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="equipmentId == null and objId == null">
'',
</when>
<otherwise>
#{equipmentId},
</otherwise>
</choose>
<choose>
<when test="emsId == null and objId != null">
(select EMSID from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="emsId == null and objId == null">
'',
</when>
<otherwise>
#{emsId},
</otherwise>
</choose>
<choose>
<when test="version == null and objId != null">
(select VERSION from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId})),
</when>
<when test="version == null and objId == null">
'',
</when>
<otherwise>
#{version},
</otherwise>
</choose>
<choose>
<when test="timeZone == null and objId != null">
(select TIMEZONE from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId}))
</when>
<when test="timeZone == null and objId == null">
''
</when>
<otherwise>
#{timeZone}
</otherwise>
</choose>
<if test="attrList != null">
<foreach collection="attrList" index="index" item="attr"
separator="," open=",">
<choose>
<when test="attr.attributeValue == null and objId != null">
(select ${attr.columnName} from ${tableName}
where OBJID=#{objId} and VERID=(select max(VERID) from ${tableName}
where OBJID=#{objId}))
</when>
<when test="attr.attributeValue == null and objId == null">
''
</when>
<otherwise>
#{attr.attributeValue}
</otherwise>
</choose>
</foreach>
</if>
<if test="refList != null">
<foreach collection="refList" index="index" item="ref"
separator="," open=",">
<choose>
<when test="ref.attributeValue == null and objId != null">
(select ${ref.columnName} from ${tableName} where
OBJID=#{objId} and VERID=(select max(VERID) from ${tableName} where
OBJID=#{objId}))
</when>
<when test="ref.attributeValue == null and objId == null">
''
</when>
<otherwise>
#{ref.attributeValue}
</otherwise>
</choose>
</foreach>
</if>
)
</insert>
<select id="checkEntityExist" parameterType="hashmap" resultType="string">
select 1 from ${tableName} where ${columnName}=#{objId} and VERENDTIME is null
</select>
<update id="updateEntityRelation" parameterType="hashmap">
update ${tableName} set
<choose>
<when test="columnValue != null">
${columnName}=#{columnValue}
</when>
<otherwise>
${columnName}=null
</otherwise>
</choose>
${columnName}=#{columnValue}
where ObjId = #{objId} and VERID=(select max(VERID) from ${tableName} where
OBJID=#{objId})
</update>

<select id="checkMappingExist" parameterType="hashmap" resultType="string">
select 1
  from mdl_othersysmodelmapping m
where m.othermodelid = (select t.othermodelid
                           from mdl_othersysmodel t
                          where t.othermotypecode = #{mostCIName})
   and m.modelid = #{pmModelId}
</select>

<select id="getIDColumnNameByMOSTMOType" parameterType="hashmap" resultType="string">
select c.columnname
  from mdl_resattributecol c
where c.attributeid =
       (select t.attributeid
          from MDL_OTHERSYSATTRMAPPING t
          left join mdl_othersysattr b
            on t.otherattributeid = b.otherattributeid
         where b.othersys_attributename = 'ID'
           and b.othersys_motypeid =
               (select m.othermotypeid
                  from mdl_othersysmodel m
                 where m.othermotypecode = #{mostCIName})
           and t.attributeid in (select r.attributeid
                                   from mdl_resattribute r
                                  where r.modelid = #{pmModelId}
                                    and r.enable = 1))
</select>

<select id="getObjIdByCIID" parameterType="hashmap" resultType="string">
<!-- select objid from ${tableName} where ${columnName}=#{CIID} and VERENDTIME is null -->
select objid
  from ${tableName} b
where b.verendtime is null
   and b.${columnName} = #{CIID}
   and b.verid = (select max(verid)
                    from ${tableName} b
                   where b.verendtime is null
                     and b.${columnName} = #{CIID})
</select>

<select id="getMOEntityByMOSTId" parameterType="hashmap" resultType="MOEntity">
select to_char(t.objid) "objId",
to_char(t.verid) "verId",
t.verstarttime "verStartTime",
t.verendtime "verEndTime",
t.objname
"objName",
t.objcode "objCode",
t.EquipmentMODELID "equipmentId",
t.emsentityid "emsEntryId",
t.emsid "emsId",
to_char(t.isonsite)
"isOnSite"
from ${tableName} t
where
t.${columnName}=#{primaryValue}
</select>
<select id="getBasicAttributeId" resultType="java.lang.String" parameterType="java.lang.String">
select ATTRIBUTEID from MDL_RESATTRIBUTE where MODELID=#{motypeId} and EQUIPMENTPARA=-1
</select>
<select id="getSimpleMOAttrName" resultType="java.lang.String" parameterType="java.lang.String">
select COLUMNNAME from MDL_RESATTRIBUTECOL where ATTRIBUTEID=#{attributeId}
</select>
<select id="getMetaModelAttribute" parameterType="hashmap" resultType="MOAttribute">
select r.attributeid "attributeID",
       'obj_' || t.tablename "tableName",
       r.modelid "moTypeID",
       r.attributename "attributeName",
       r.attributetype "attributeType",
       r.equipmentpara "equipmentPara",
       upper(t.columnname) "columnName"
  from MDL_RESATTRIBUTECOL t
  left join mdl_resattribute r
    on t.attributeid = r.attributeid
where r.equipmentpara = -1
   and r.modelid = #{moTypeId}
</select>
<select id="getOthersysByCIName" parameterType="hashmap" resultMap="Othersys">
select * from mdl_othersysmodel t where t.othermotypecode=#{CIName}
</select>
<select id="getPMParamModel" parameterType="hashmap" resultType="MOType">
select t.modelid           "moTypeID",
       t.parentmodelid     "parentMOTypeID",
       t.modelname         "moTypeName",
       t.modelcode         "moTypeCode",
       t.domainid          "domainID",
       t.iscommon          "isCommon",
       t.equipmentMODELID  "equipmentID",
       t.equipmentdomainid "equipmentDomainID",
       t.ismeta            "isMeta",
       t.displayorder      "displayOrder",
       t.ismanual          "isManual",
       t.enable            "status",
       t.modifytime        "modifyTime",
       t.remark            "remark"
  from mdl_resmodel t
where
<choose>
<when test="modelId != 'root'">
t.modelid = #{modelId}
or t.belongparmodelid = #{modelId}
</when>
<otherwise>
t.isparmodelid = 1
   or t.belongparmodelid is not null
</otherwise>
</choose>
</select>
<select id="checkOthersysAttrHasOne" parameterType="com.inspur.pmv5.pojo.momgt.OthersysAttribute"
resultType="java.lang.Integer">
select count(*) from MDL_OTHERSYSATTRMAPPING where ATTRIBUTEID=#{attributeId}
</select>
<select id="getModelAttrMappings" resultMap="Othersys" parameterType="string">
select t3.attributeid,
       t3.attributename,
       t4.modelid,
       t4.modelname,
       t1.otherattributeid,
       t1.othersys_attributename,
       t2.othermotypeid,
       t2.othermotypecode
  from mdl_othersysattrmapping t
  left join mdl_othersysattr t1 on t1.otherattributeid = t.otherattributeid
  left join mdl_othersysmodel t2 on t2.othermotypeid = t1.othersys_motypeid
  left join mdl_resattribute t3 on t3.attributeid = t.attributeid
  left join mdl_resmodel t4 on t3.modelid = t4.modelid
  where t4.modelid= #{modelId}
</select>
<delete id="deleteModelAttrMappings" parameterType="string">
delete mdl_othersysattrmapping t
where t.attributeid in
       (select t1.attributeid
          from mdl_resattribute t1
         where t1.modelid = #{modelId})
</delete>
<delete id="deleteModelMappings" parameterType="string">
delete mdl_othersysmodelmapping t where t.modelid=#{modelId}
</delete>
<insert id="addModelAttrMappings" parameterType="Othersys">
insert into mdl_othersysattrmapping(mappingid,otherattributeid,
attributeid,othersys_attributeidchange) values (SEQ_MO.Nextval,#{othersAttributeId},#{attributeId},null)
</insert>
<delete id="deleteModelAttrMappingByOtherAttrId" parameterType="string">
delete mdl_othersysattrmapping t where t.otherattributeid=#{othersAttributeId}
</delete>
<delete id="deleteModelAttrMappingByAttrMappingId" parameterType="string">
delete mdl_othersysattrmapping t where t.mappingid=#{mappingId}
</delete>
<!-- 需要根据mapping id 删除原有的映射属性 -->
<delete id="deleteModelAttrMappingById" parameterType="string">
delete mdl_othersysattrmapping t2
where t2.otherattributeid in
       (select t1.otherattributeid
          from mdl_othersysattr t1
         where t1.othersys_motypeid in
               (select t.othermodelid
                  from mdl_othersysmodelmapping t
                 where t.mappingid = #{mappingId}))
</delete>
<update id="updateModelMappingById" parameterType="Othersys">
update mdl_othersysmodelmapping t set t.modelid=#{modelId},t.othermodelid=#{otherModelId} where t.mappingid=#{mappingId}
</update>
<insert id="addModelMappings" parameterType="string">
insert into mdl_othersysmodelmapping
  (mappingid, modelid, othermodelid)
  select seq_mo.nextval as mappingId,
         m.modelId,
         m.othersys_motypeid as othermodelid
    from (select distinct (t2.modelid), t1.othersys_motypeid
            from mdl_othersysattrmapping t
            left join mdl_othersysattr t1 on t.otherattributeid =
                                             t1.otherattributeid
            left join mdl_resattribute t2 on t.attributeid = t2.attributeid
           where t2.modelid = #{modelId}) m
</insert>
<insert id="addModelMappingByModelIdAndOtherModelId" parameterType="Othersys">
insert into mdl_othersysmodelmapping(mappingid,modelid,othermodelid) values(seq_mo.nextval,#{modelId},#{otherModelId})
</insert>
<update id="updateOtherModelEnable" parameterType="hashmap">
update mdl_othersysmodel o
   set o.enable = #{enable}
where o.othermotypeid =
       (select m.othersys_motypeid as othermodelid
          from (select distinct (t2.modelid), t1.othersys_motypeid
                  from mdl_othersysattrmapping t
                  left join mdl_othersysattr t1 on t.otherattributeid =
                                                   t1.otherattributeid
                  left join mdl_resattribute t2 on t.attributeid =
                                                   t2.attributeid
                 where t2.modelid = #{modelId}) m)
</update>
<update id="updateOtherModelAttrEnable1" parameterType="hashmap">
update mdl_othersysattr t set t.enable=#{enable} where t.otherattributeid=#{othersAttributeId}
</update>
<update id="updateOtherModelAttrEnable" parameterType="hashmap">
update mdl_othersysattr o
   set o.enable = #{enable}
where o.otherattributeid in
       (select t.otherattributeid
          from mdl_othersysattrmapping t
         where t.attributeid in
               (select t1.attributeid
                  from mdl_resattribute t1
                 where t1.modelid = #{modelId}))
</update>
<select id="getMOSTParamModel" resultMap="Othersys">
select * from MDL_OTHERSYSMODEL t where t.isrelation=3
</select>

<select id="getParamAttrByMOTypeId" parameterType="hashmap" resultMap="OthersysAttribute">
select t.attributeid,
       t.attributename,
       o.otherattributeid,
       o.othersys_attributename,
       m.mappingid,
       decode(o.enable, 1, 'mapped', 'not mapped') enableStr
  from mdl_resattribute t
  left join mdl_othersysattrmapping m
    on m.attributeid = t.attributeid
  left join mdl_othersysattr o
    on o.otherattributeid = m.otherattributeid
where t.equipmentpara = 1
   and t.modelid = #{modelId}
   and t.enable = 1
</select>
<update id="updateOtherModelAttrMapping" parameterType="OthersysAttribute">
update mdl_othersysattrmapping t set t.attributeid=#{attributeId},t.otherattributeid=#{othersysAttributeName} where t.mappingid=#{mappingId}
</update>
<select id="validateAttrMappingByOtherAttrId" parameterType="string" resultType="java.util.HashMap">
select * from mdl_othersysattrmapping t where t.otherattributeid=#{otherAttributeId}
</select>
<insert id="addOtherModelAttrMapping" parameterType="OthersysAttribute">
insert into mdl_othersysattrmapping(mappingid,otherattributeid,attributeid) values(seq_mo.nextval,#{othersysAttributeName},#{attributeId})
</insert>
<select id="getMappedModel" parameterType="hashmap" resultMap="Othersys">
select m.modelid, m.othermodelid,m.mappingid
  from mdl_othersysmodelmapping m
  left join mdl_resmodel t
    on t.modelid = m.modelid
  left join mdl_othersysmodel o
    on o.othermodelid = m.othermodelid
where
<if test="modelId != 'root'">
   t.belongparmodelid = #{modelId}
    or t.modelid = #{modelId}
   and
</if>
       o.isrelation = 3
   and o.enable = 1
</select>

<select id="getMOSTParamAttribute" parameterType="hashmap" resultMap="OthersysAttribute">
select *
  from mdl_othersysattr t
  left join mdl_othersysmodel m
    on t.othersys_motypeid = m.othermotypeid
where m.othermodelid = #{otherModelId}
</select>
<select id="getModelAndAttributeByMOST" parameterType="Othersys" resultMap="Othersys">
select t.othermotypeid,t4.modelid,t4.modelname,t3.attributeid,t3.attributename,
t.othermotypecode as otherMotypeCode,t1.othersys_attributecode as othersAttributeName
  from mdl_othersysmodel t
  left join mdl_othersysattr t1 on t1.othersys_motypeid = t.othermotypeid
  left join mdl_othersysattrmapping t2 on t1.otherattributeid=t2.otherattributeid
  left join mdl_resattribute t3 on t2.attributeid=t3.attributeid
  left join mdl_resmodel t4 on t3.modelid=t4.modelid
  where
  <if test="otherMotypeCode != null">
t.othermotypecode=#{otherMotypeCode}
<if test="othersAttributeId != null">
and t1.othersys_attributecode=#{othersAttributeId}
</if>
</if>
<if test="modelId != null">
t4.modelid=#{modelId} and t3.attributeid=#{attributeId}
</if>
 
</select>
<select id="getIndexKeyAttributeIdByMOSTMotypeId" parameterType="string" resultMap="Othersys">
select t.othersys_attributecode as othersAttributeId from mdl_othersysattr t
left join mdl_othersysmodel t1 on t.othersys_motypeid=t1.othermotypeid
      where t1.othermotypecode=#{otherMotypeCode}  and t.parametertype=1
</select>
<select id="getTableNameAndColumnNameByMOST" parameterType="string" resultType="java.util.HashMap">
select t1.modelid, t1.tablename, t4.columnname
      FROM mdl_resmodeltable t1
      left join (select t2.modelid, t3.columnname
                   from mdl_resattribute t2
                   left join mdl_resattributecol t3 on t3.attributeid =
                                                       t2.attributeid
                  where t2.isemsid = 1) t4 on t4.modelid = t1.modelid
                  where t1.modelid=#{othersysMotypeId}
</select>
<select id="getMoentity" parameterType="hashmap" resultType="java.util.HashMap">
select t.objid,t.equipmententityid,t.objname from obj_${tableName} t where t.${columnName}=#{moId}
</select>
<select id="getMo" parameterType="hashmap" resultType="java.util.HashMap">
select t.${columnName} from obj_${tableName} t where t.objid=#{objId}
</select>
<select id="getUpperNEModelIdByLowerNEModelId" parameterType="string" resultType="java.util.HashMap">
select modelid
  from mdl_resmodel t2
where t2.modelid in
       (select t1.motypeid
          from pm4h_ad.cm_equipmentmodel t1
         where t1.equipmentmodelid in
               (select t.equipmentmodelid
                  from mdl_resmodel t
                 where t.modelid = #{lowerModelId}))
</select>

<select id="getMappedInstanceSelectAttribute" parameterType="hashmap" resultMap="OthersysAttribute">
select *
  from mdl_othersysattr t
  left join mdl_othersysattrmapping m
    on t.otherattributeid = m.otherattributeid
  left join mdl_othersysmodel o
    on t.othersys_motypeid = o.othermotypeid
where o.othermotypecode = #{ciName}
   and t.othersys_attributetype = 'instanceselect'
   and t.enable = 1
</select>

<select id="getMappingOthersysByCIName" parameterType="hashmap" resultMap="Othersys">
select *
  from mdl_othersysmodelmapping m
  left join mdl_othersysmodel t
    on m.othermodelid = t.othermodelid
where t.othermotypecode = #{ciName}
</select>

<select id="getColumnNameByOthersysAttributeId" parameterType="hashmap" resultType="String">
select c.columnname
  from mdl_othersysattrmapping m
  left join mdl_othersysattr t
    on m.otherattributeid = t.otherattributeid
  left join mdl_resattributecol c
    on c.attributeid = m.attributeid
where t.othersys_attributename = #{attrId}
   and t.othersys_motypeid = #{ciName}
</select>

<select id="getDistinctedValue" parameterType="hashmap" resultType="String">
select distinct substr(t.${columnName},6)
  from ${tableName} t
where t.verendtime is null
   and t.${columnName} like '%'||'most:'||'%'
</select>

<update id="updateToObjId" parameterType="hashmap">
update ${tableName} t
   set t.${columnName} = #{objId}
where t.verendtime is null
   and t.${columnName} = 'most:'||#{oldValue}
</update>

<select id="getPrimaryKeyAttributeMapping" parameterType="hashmap" resultType="hashmap">
select t.othersys_attributename, c.columnname
  from mdl_othersysattrmapping m
  left join mdl_othersysattr t
    on t.otherattributeid = m.otherattributeid
  left join mdl_resattributecol c
    on m.attributeid = c.attributeid
where t.othersys_primarykey = 1
   and t.othersys_motypeid = #{otherMOTypeId}
   and t.othersys_attributename != 'ID'
   and t.enable = 1
</select>

<select id="getMOEntityByPrimaryKey" parameterType="hashmap" resultType="MOEntity">
select to_char(t.objid) "objId",
       to_char(t.verid) "verId",
       t.verstarttime "verStartTime",
       t.verendtime "verEndTime",
       t.objname "objName",
       t.objcode "objCode",
       t.EquipmentMODELID "equipmentId",
       t.emsentityid "emsEntryId",
       t.emsid "emsId",
       to_char(t.isonsite) "isOnSite"
  from ${tableName} t
where t.verendtime is null
<if test="keyValueList != null and keyValueList.size() != 0">
<foreach collection="keyValueList" item="item" index="index" open=" and " separator=" and ">
t.${item.key} = #{item.value}
</foreach>
</if>
</select>

<select id="getRelationColumnByOthersysAttributeName" parameterType="hashmap" resultType="String">
select t.columnname
  from mdl_relationcol t
where t.relationid =
       (select r.relationid
          from mdl_relation r
         where r.modela =
               (select m.modelid
                  from mdl_othersysmodelmapping m
                 where m.othermodelid =
                       (select b.othermodelid
                          from mdl_othersysmodel b
                         where b.othermotypecode = #{otherMOTypeCode}))
           and r.modelb =
               (select m.modelid
                  from mdl_othersysmodelmapping m
                 where m.othermodelid =
                       (select b.othermodelid
                          from mdl_othersysmodel b
                         where b.othermotypecode =
                               (select o.othersys_labelname
                                  from mdl_othersysattr o
                                 where o.othersys_attributename =
                                       #{otherAttributeCode}
                                   and o.othersys_motypeid = #{otherMOTypeCode}))))
</select>

<select id="getLabelNameRelatedTabelName" parameterType="hashmap" resultType="String">
select 'obj_' || t.tablename
  from mdl_resmodeltable t
where t.modelid =
       (select m.modelid
          from mdl_othersysmodelmapping m
          left join mdl_othersysmodel o
            on m.othermodelid = o.othermodelid
         where o.othermotypeid =
               (select t.othersys_labelname
                  from mdl_othersysattr t
                 where t.othersys_motypeid = #{otherMOTypeCode}
                   and t.othersys_attributename = #{otherAttributeCode}))
</select>

<select id="getLabelName" parameterType="hashmap" resultType="String">
select t.othersys_labelname
  from mdl_othersysattr t
where t.othersys_motypeid = #{otherMOTypeCode}
   and t.othersys_attributename = #{otherAttributeCode}
</select>

<select id="isExistN2NRelation" parameterType="hashmap" resultType="String">
select 1
  from ${tableName} t
where t.OBJAID = #{objAId}
   and t.OBJBID = #{objBId}
</select>

<insert id="insertN2NRelation" parameterType="hashmap">
insert into ${tableName}
  (OBJAID, OBJBID, VERID, VERSTARTTIME)
values
  (#{objAId}, #{objBId}, SEQ_VER.Nextval, sysdate)
</insert>

<update id="updateCurSyncDate" parameterType="hashmap">
update mdl_othersysmodel t set t.cursynchronousdate=#{systemTime} where t.othermotypecode=#{ciName}
</update>

<update id="updateCurTotalPage" parameterType="hashmap">
update mdl_othersysmodel t set t.cursynchronouspagetotal=#{totalPage} where t.othermotypecode=#{ciName}
</update>

<update id="updateCurPage" parameterType="hashmap">
update mdl_othersysmodel t set t.cursynchronouspage=#{currentPage} where t.othermotypecode=#{ciName}
</update>

<update id="updateTwoDate" parameterType="hashmap">
update mdl_othersysmodel t set t.synchronousdate=#{totalMaxDate}, t.cursynchronousdate=#{totalMaxDate} where t.othermotypecode=#{ciName}
</update>

<update id="updateCurPageAndTotalPageToNull" parameterType="hashmap">
update mdl_othersysmodel t set t.cursynchronouspagetotal=null, t.cursynchronouspage=null where t.othermotypecode=#{ciName}
</update>

<select id="getOthersysMappingByPMModelId" parameterType="hashmap" resultMap="Othersys">
select *
  from mdl_othersysmodelmapping t
  left join mdl_othersysmodel b
    on t.othermodelid = b.othermodelid
where t.modelid = #{modelId}
   and b.isrelation = 1
</select>

<select id="getAllOthersysParamMappingFor12n" parameterType="hashmap" resultMap="Othersys">
select *
  from mdl_othersysmodelmapping m
  left join mdl_othersysmodel t
    on m.othermodelid = t.othermodelid
where t.isrelation = 3
   and substr(t.othermotypeid, 0, instr(t.othermotypeid, ':') - 1) =
       #{ciName}
   and m.modelid in (select m.modelid
                       from mdl_othersysmodelmapping m
                       left join mdl_othersysmodel t
                         on m.othermodelid = t.othermodelid
                      where t.isrelation = 3
                      group by modelid
                     having count(*) > 1)
</select>

<select id="getAllOthersysAttrParamMappingFor12n" parameterType="hashmap" resultMap="OthersysAttribute">
select *
  from mdl_othersysattrmapping a
  left join mdl_othersysattr b
    on a.otherattributeid = b.otherattributeid
where b.othersys_motypeid in
       (select t.othermotypeid
          from mdl_othersysmodelmapping m
          left join mdl_othersysmodel t
            on m.othermodelid = t.othermodelid
         where t.isrelation = 3
           and substr(t.othermotypeid, 0, instr(t.othermotypeid, ':') - 1) =
               #{ciName}
           and m.modelid in (select m.modelid
                               from mdl_othersysmodelmapping m
                               left join mdl_othersysmodel t
                                 on m.othermodelid = t.othermodelid
                              where t.isrelation = 3
                              group by modelid
                             having count(*) > 1))
</select>

</mapper>
分享到:
评论

相关推荐

    Faster-RCNN+ZF制作自己的数据集和训练模型完整文件及教程(Matlab版本)(most.zip

    1. 数据预处理:包括标注图像中的目标边界框,将这些信息转换为VOC格式的XML文件,以及将图像和标注文件组织成MATLAB可以读取的格式。 2. 构建网络结构:根据ZF网的架构,在MATLAB的Deep Learning Toolbox中定义...

    基于文本和多模态数据的风险识别题目名称Emoji复杂文本识别python源码+项目说明.zip

    根据训练集的数据,保留出现频率大于等于2的emoji-&gt;text映射关系,构建基本规则字典data/map_v5.json和其子集data/map_mostCommon.json、data/map_multi.json;对于测试集中oov的emoji,通过cldr公开的unicode-org....

    EurekaLog_7.5.0.0_Enterprise

    Later is supported when map2dbg.exe tool is placed in \Bin folder of EurekaLog installation (separate download is required) 5)....Added: Exception2HRESULT in EAppDLL to simplify developing DLLs with ...

    Hibernate Reference Documentation3.1

    8.3. Components as Map indices 8.4. Components as composite identifiers 8.5. Dynamic components 9. Inheritance Mapping 9.1. The Three Strategies 9.1.1. Table per class hierarchy 9.1.2. Table per ...

    Android代码-konf

    Support sources from JSON, XML, YAML, HOCON, TOML, properties, map, command line and system environment out of box. Cascading. Config can fork from another config by adding a new layer on it. Each ...

    PHP Web 2.0 Mashup Projects.pdf

    we create an extensible object-oriented parser for XML. The mashup covered in this chapter integrates information taken from Amazon's E-commerce Service (ECS) with the Internet UPC database. In ...

    外文翻译 stus MVC

    You would map some input event to a pointer to a function. If you where slick, you would place the configuration information into a file and load the file at run time. Function pointer arrays were ...

    MyBatisCodeHelper-Pro.zip

    Generate mybatis sql based on mybatis interface method name like spring data jpa, with this, you don't have to write most sql for non join query support generate statement with if test Database ...

    Manning-AspectJInAction

    It is difficult to map requirements to the implementation and then trace the implementation back to the requirements. Although many approaches—such as object-oriented programming, component-oriented...

    VB编程资源大全(英文源码 网络)

    TreeViewXML.zip Great example program for programmers learning XML. This program shows you how to use the msxml.dll control, as well as the treeview control. Users must have msxml.dll version 2.0 ...

    jQuery完全实例.rar

    $("div", xml.responseXML); jQuery(html)jQuery(html) 根据提供的原始 HTML 标记字符串,动态创建由 jQuery 对象包装的 DOM 元素。 你可以传递一个手写的 HTML 字符串,或者由某些模板引擎或插件创建的字符串,也...

    Proxy Pattern Informatization Research Based On SaaS

    After the user logs on, access to resources and business functions in a SaaS application is managed by using roles that map to specific job functions within an organization. Each role is given one or ...

Global site tag (gtag.js) - Google Analytics