|
|
<?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.xujie.sys.modules.pms.mapper.EamKnowledgeBaseMapper">
<!-- 查询设备知识库列表 --> <select id="getKnowledgeBaseList" parameterType="EamKnowledgeBaseData" resultType="EamKnowledgeBaseData"> SELECT ekb.site, ekb.num, ekb.object_id, eo.ObjectDesc as objectName, ekb.file_type, ekb.defect_id, ed.DefectDesc, ekb.defect_describe, ekb.disposal_measures, ekb.file_id, ekb.file_name, ekb.remark, ekb.create_date, ekb.update_date, ekb.create_by, ekb.order_no, ekb.update_by FROM eam_knowledge_base as ekb LEFT JOIN eam_object as eo on ekb.site = eo.site and ekb.object_id = eo.ObjectID LEFT JOIN eam_defect as ed on ekb.defect_id = ed.DefectID <where> ekb.site = #{query.site} <if test = "query.objectId != null and query.objectId != ''"> and ekb.object_id LIKE '%' + #{query.objectId}+'%' </if> <if test = "query.defectId != null and query.defectId != ''"> AND ekb.defect_id LIKE '%' + #{query.defectId}+'%' </if> <if test = "query.defectDesc != null and query.defectDesc != ''"> AND ed.DefectDesc LIKE '%' + #{query.defectDesc}+'%' </if> <if test = "query.defectDescribe != null and query.defectDescribe != ''"> AND ekb.defect_describe = #{query.defectDescribe} </if> <if test = "query.fileType != null and query.fileType != ''"> AND ekb.file_type = #{query.fileType} </if> <if test="query.startDate != null"> AND ekb.create_date >= #{query.startDate} </if> <if test="query.endDate != null"> AND #{query.endDate} >= ekb.create_date </if> </where> </select>
<!-- 查询故障列表 --> <select id="getDefectList" parameterType="EamKnowledgeBaseData" resultType="EamKnowledgeBaseData"> SELECT eod.ObjectID as objectId, eod.DefectID as defectId, ed.DefectDesc as defectDesc FROM eam_object_defect as eod LEFT JOIN eam_defect as ed ON eod.DefectID = ed.DefectID WHERE eod.ObjectID = #{objectId} and eod.Active = 'Y' </select>
<!-- 新增知识库文件 --> <insert id="saveKnowledgeBase" parameterType="EamKnowledgeBaseData"> INSERT INTO eam_knowledge_base (num, file_type, defect_describe, disposal_measures, file_id, file_name, remark, create_date, create_by, object_id, defect_id, site) VALUES ((select 'ZS'+ Right('0000000000' + convert(VARCHAR(10), isnull(max(convert(INT, SUBSTRING(num, 3, 10))), 0) + 1), 8) from eam_knowledge_base where site = #{site}), #{fileType}, #{defectDescribe}, #{disposalMeasures}, #{fileId}, #{fileName}, #{remark}, getDate(), #{createBy}, #{objectId}, #{defectId}, #{site}) </insert>
<!-- 修改知识库文件 --> <update id="knowledgeBaseUpdate" parameterType="EamKnowledgeBaseData"> UPDATE eam_knowledge_base SET object_id = #{objectId}, defect_id = #{defectId}, file_type = #{fileType}, defect_describe = #{defectDescribe}, disposal_measures = #{disposalMeasures}, remark = #{remark}, update_date = getDate(), update_by = #{updateBy} WHERE num = #{num} and site = #{site} </update>
<!-- 删除知识库文件 --> <delete id="knowledgeBaseDelete" parameterType="EamKnowledgeBaseData"> DELETE FROM eam_knowledge_base WHERE num = #{num} and site = #{site} </delete>
<!-- 批量删除知识库文件 --> <delete id="knowledgeBaseDeleteSome"> DELETE FROM eam_knowledge_base WHERE <foreach collection="list" item="item" separator=" or " index="index"> (num = #{item.num} and site = #{item.site}) </foreach> </delete>
<!-- 删除文件 --> <delete id="deleteKnowledgeBaseFile" parameterType="EamKnowledgeBaseData"> DELETE FROM sys_oss WHERE order_ref2 = #{num} </delete></mapper>
|