工业级运维app手机api
fengxiang
2017-11-09 cdcc163408a45578880c91ca79d865e0e5e86b65
src/main/resources/mapper/JobDao.xml
@@ -6,17 +6,53 @@
<mapper namespace="com.moral.monitor.dao.JobDao">
    <resultMap type="HashMap" id="adjustResultMap">
        <result column="mac_key"   property="key" javaType="java.lang.String" />
        <result column="value"   property="value" javaType="java.lang.Float" />
        <result column="owner_id"   property="orgId" javaType="java.lang.String" />
        <result column="areacode"   property="areaCode" javaType="java.lang.String" />
        <result column="monitorpoint"   property="monitorpointId" javaType="java.lang.String" />
        <collection property="adjusts" column="id" javaType="java.util.List"  ofType="java.util.Map">
              <result column="mac_key" property="key" javaType="java.lang.String"/>
              <result column="value" property="value" javaType="java.lang.Float"/>
        </collection>
    </resultMap>
    <select id="findAdjustByMac" resultMap="adjustResultMap">
        select c.mac_key, d.`value`
    <select id="findEquWithAdjustsByMac" resultMap="adjustResultMap">
        select a.id,a.owner_id,a.monitorpoint,e.areacode,c.mac_key,d.`value`
        from equipment a
        inner join mac b on a.id = b.equipment_id
        inner join mac b on a.id = b.equipment_id
        inner join sensor c on b.sensor = c.id
        left join sensoradjust d on b.id = d.sen_dev_id
      left join monitorpoint e on e.id = a.monitorpoint
        where a.mac = #{0}
    </select>
    <update id="updateStateByMac">
        UPDATE equipment SET state=#{1} WHERE mac=#{0}
    </update>
    <insert id="batchInsertHistory" parameterType="java.util.List" >
        <selectKey resultType ="java.lang.Integer" keyProperty="id" order="AFTER">
            SELECT LAST_INSERT_ID()
        </selectKey >
        insert into history
            (mac, sensor, mac_key, mac_value, time)
        values
            <foreach collection="list" item="item" index="index" separator=",">
                (
                    #{item.mac},
                    #{item.sensor},
                    #{item.mac_key},
                    #{item.mac_value},
                    #{item.time}
                )
            </foreach>
    </insert>
    <select id="getAllEquipment" resultType="com.moral.monitor.entity.Equipment">
        select mac from equipment
    </select>
    <select id="getLoggerByMac" resultType="com.moral.monitor.entity.Logger">
        select time from history where mac=#{0} order by time DESC limit 1
    </select>
</mapper>