|
|
<?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.EamMapper">
<select id="eamAdminSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminData" resultType="com.xujie.sys.modules.pms.data.EamAdminData"> SELECT distinct ea.Site, ea.AdminID, ea.AdminName, ea.Phone, ea.Email, ea.Tel, ea.LevelID, eal.AdminLevelDesc, ea.MesUser, ea.Active, ea.CreatedDate, ea.created_by, ea.update_date, ea.update_by FROM eam_admin as ea LEFT JOIN eam_adminLevel as eal ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site left join eam_admin_dept as ead on ea.site = ead.site and ea.AdminID = ead.admin_id LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id <where> <if test="query.site != null and query.site != ''"> AND ea.site = #{query.site} </if> <if test="query.adminID != null and query.adminID != ''"> AND ea.adminID like '%' + #{query.adminID} +'%' </if> <if test="query.adminName != null and query.adminName != ''"> AND ea.adminName like '%' + #{query.adminName}+'%' </if> <if test="query.departmentName != null and query.departmentName != ''"> AND ved.department_name like '%' + #{query.departmentName}+'%' </if> <if test="query.active != null and query.active != ''"> AND ea.active = #{query.active} </if> </where> </select>
<select id="eamAdminSearch2" parameterType="com.xujie.sys.modules.pms.data.EamAdminData" resultType="com.xujie.sys.modules.pms.data.EamAdminData"> SELECT distinct ea.Site, ea.AdminID, ea.AdminName, ea.Phone, ea.Email, ea.Tel, ea.LevelID, eal.AdminLevelDesc, ea.MesUser, ea.Active, ea.CreatedDate, ea.created_by, ea.update_date, ea.update_by FROM eam_admin as ea LEFT JOIN eam_adminLevel as eal ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site left join eam_admin_dept as ead on ea.site = ead.site and ea.AdminID = ead.admin_id LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id <where> <if test="site != null and site != ''"> AND ea.site = #{site} </if> <if test="adminID != null and adminID != ''"> AND ea.adminID like '%' + #{adminID} +'%' </if> <if test="adminName != null and adminName != ''"> AND ea.adminName like '%' + #{adminName}+'%' </if> <if test="departmentName != null and departmentName != ''"> AND ved.department_name like '%' + #{departmentName}+'%' </if> <if test="active != null and active != ''"> AND ea.active = #{active} </if> </where> </select>
<select id="eamFamilySearch" parameterType="com.xujie.sys.modules.pms.data.EamFamilyData" resultType="com.xujie.sys.modules.pms.data.EamFamilyData"> SELECT Site, FamilyID, FamilyDesc, Active, create_date, create_by, update_date, update_by FROM eam_family <where> <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.familyID != null and query.familyID != ''"> AND familyID like '%' + #{query.familyID} +'%' </if> <if test="query.familyDesc != null and query.familyDesc != ''"> AND familyDesc like '%' + #{query.familyDesc} +'%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where></select>
<select id="eamGroupSearch" parameterType="com.xujie.sys.modules.pms.data.EamGroupData" resultType="com.xujie.sys.modules.pms.data.EamGroupData"> SELECT Site, GroupID, GroupDesc, Active, create_date, create_by, update_date, update_by FROM eam_group <where> <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.groupID != null and query.groupID != ''"> AND groupID like '%' + #{query.groupID} </if> <if test="query.groupDesc != null and query.groupDesc != ''"> AND groupDesc like '%' + #{query.groupDesc} </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where></select>
<select id="eamLocationSearch" parameterType="com.xujie.sys.modules.pms.data.EamLocationData" resultType="com.xujie.sys.modules.pms.data.EamLocationData"> SELECT Site, LocationID, LocationName, Active, create_date, create_by, update_date, update_by FROM eam_location <where> <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.locationID != null and query.locationID != ''"> AND locationID like '%' + #{query.locationID} +'%' </if> <if test="query.locationName != null and query.locationName != ''"> AND locationName like '%' + #{query.locationName} +'%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where></select>
<select id="eamManufacturerSearch" parameterType="com.xujie.sys.modules.pms.data.EamManufacturerData" resultType="com.xujie.sys.modules.pms.data.EamManufacturerData"> SELECT Site, ManufacturerID, ManufacturerName, Active, Contact, Phone, Address, Email, Remark, create_date, create_by, update_date, update_by FROM eam_manufacturer <where> <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.manufacturerID != null and query.manufacturerID != ''"> AND manufacturerID like '%' + #{query.manufacturerID} +'%' </if> <if test="query.manufacturerName != null and query.manufacturerName != ''"> AND manufacturerName like '%' + #{query.manufacturerName} +'%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where></select>
<select id="eamAdminLevelSearch" parameterType="com.xujie.sys.modules.pms.data.EamAdminLevelData" resultType="com.xujie.sys.modules.pms.data.EamAdminLevelData"> SELECT Site, AdminLevelID, AdminLevelDesc, Active, create_date, create_by, update_date, update_by FROM eam_adminLevel <where> <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.adminLevelID != null and query.adminLevelID != ''"> AND adminLevelID like '%' + #{query.adminLevelID} +'%' </if> <if test="query.adminLevelDesc != null and query.adminLevelDesc != ''"> AND adminLevelDesc like '%' + #{query.adminLevelDesc}+'%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where></select><select id="eamSupplierSearch" parameterType="com.xujie.sys.modules.pms.data.EamSupplierData" resultType="com.xujie.sys.modules.pms.data.EamSupplierData"> SELECT Site, SupplierID, SupplierName, [Group], Active, Contact, Phone, Address, Email, Remark, create_date, create_by, update_date, update_by FROM eam_supplier <where> <if test="query.site != null and query.site != ''"> AND site = #{query.site} </if> <if test="query.supplierID != null and query.supplierID != ''"> AND supplierID like '%' + #{query.supplierID} +'%' </if> <if test="query.supplierName != null and query.supplierName != ''"> AND supplierName like '%' + #{query.supplierName} +'%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where></select>
<select id="searchItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemAvailableData"> SELECT site, ItemNo, ValueNo, AvailableValue, CreatedDate, CreatedBy, ItemType from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site}</select>
<select id="getItemValueNo" resultType="Double"> SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and site = #{site}</select><select id="getItemValueNoForPlan" resultType="Double"> SELECT isnull( max(valueNo),0)+1 from eam_workPlan_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and PlanID=#{planID}</select><insert id="saveItemAvailable"> insert into eam_properties_item_available (ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType,site) values(#{itemNo},#{valueNo},#{availableValue},GetDate(),#{createdBy},#{itemType},#{site})</insert>
<update id="updateItemAvailable"> update eam_properties_item_available set AvailableValue = #{availableValue} where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site}</update>
<delete id="deleteItemAvailable"> delete from eam_properties_item_available where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} and site = #{site}</delete>
<select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData"> SELECT site, function_type, code_no, code_desc, active, created_date, created_by, update_date, update_by, delflag, version FROM eam_properties_model_header <where> site = #{query.site} <if test="query.codeNo != null and query.codeNo != ''"> AND code_no like '%' + #{query.codeNo} +'%' </if> <if test="query.codeDesc != null and query.codeDesc != ''"> AND code_desc like '%' + #{query.codeDesc} +'%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> and function_type = #{query.functionType} </where></select>
<insert id="eamPropertiesModelSave" > insert into eam_properties_model_header (function_type, code_no, code_desc, active, created_date, created_by, delflag, version, update_date, update_by,site) values(#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy},#{site})</insert>
<update id="eamPropertiesModelEdit"> update eam_properties_model_header set version = version + 1, code_desc = #{codeDesc}, active = #{active}, update_by = #{updateBy}, update_date = GetDate() where function_type = #{functionType} and code_no = #{codeNo} and site = #{site}</update>
<select id="checkPropertiesModel" resultType="EamPropertiesModelHeaderData"> SELECT function_type, code_no, code_desc, active, created_date, created_by, update_date, update_by, delflag, version FROM eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site}</select>
<delete id="eamPropertiesModelDelete" > delete from eam_properties_model_header where function_type = #{functionType} and code_no = #{codeNo} and site = #{site}</delete>
<select id="searchModalDetails" resultType="EamPropertiesModelDetailData"> SELECT a.site, a.function_type, a.code_no, a.properties_item_no itemNo, a.seq_no, b.ItemDesc, b.DefaultValue, b.ValueType, b.ValueType_DB, b.ValueChooseFlag, b.MaxValue, b.MinValue, b.ItemRemark, b.ItemType FROM eam_properties_model_detail a left join eam_properties_item b on a.function_type = b.itemType and a.properties_item_no = b.itemNo and a.site = b.site where a.function_type = #{functionType} and a.code_no = #{codeNo} and a.site = #{site}</select>
<select id="checkItem" resultType="EamPropertiesModelDetailData"> SELECT ItemDesc FROM eam_properties_item where itemType = #{functionType} and itemNo = #{itemNo} and site = #{site}</select>
<select id="checkModalDetails" resultType="EamPropertiesModelDetailData"> SELECT function_type, code_no, properties_item_no itemNo, seq_no FROM eam_properties_model_detail where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site}</select>
<select id="getModalDetailSeqNo" resultType="Integer"> SELECT isnull(max(seq_no),0) + 1 from eam_properties_model_detail where function_type = #{functionType} and code_no = #{codeNo} and site = #{site}</select>
<insert id="saveModalDetails" > insert into eam_properties_model_detail (function_type, code_no, properties_item_no, seq_no, created_date, created_by, delflag, version, site) values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0, #{site})</insert>
<delete id="deleteModalDetails" > delete from eam_properties_model_detail where function_type = #{functionType} and code_no = #{codeNo} and properties_item_no = #{itemNo} and site = #{site}</delete>
<select id="eamWorkPlanOverviewSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData"> SELECT a.site, a.plan_id, a.plan_desc, a.status, a.plan_start_date, a.plan_end_date, a.created_date, a.created_by, a.update_date, a.update_by, a.remark, a.next_work_date, a.delete_flag, a.operator, a.operator_name, a.checker, a.checker_name, a.function_type, a.properties_code, a.plan_period, d.code_desc, a.work_order_rule, a.plan_cycle, a.task_start_date FROM eam_workPlan_overview as a LEFT JOIN eam_properties_model_header as d ON a.site = d.site and a.function_type = d.function_type and a.properties_code = d.code_no <where> a.site = #{query.site} and a.delete_flag = 'N' AND a.function_type = #{query.functionType} <if test="query.planID != null and query.planID != ''"> AND a.plan_id like '%' + #{query.planID} +'%' </if> <if test="query.planDesc != null and query.planDesc != ''"> AND a.plan_desc like '%' + #{query.planDesc}+'%' </if> <if test="query.status != null and query.status != ''"> AND a.status = #{query.status} </if> <if test="query.startDate != null "> AND a.plan_start_date >= #{query.startDate} </if> <if test="query.endDate != null "> AND #{query.endDate} >= a.plan_start_date </if> </where> ORDER BY a.created_date DESC </select>
<select id="eamWorkPlanSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkPlanInData" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData"> SELECT a.Site, a.PlanID, a.PlanDesc, a.ObjectID, a.FunctionType, a.PropertiesCode, a.Operator, a.checker, a.PlanPeriod, a.Status, a.PlanStartDate, a.PlanEndDate, a.CreatedDate, a.CreatedBy, a.UpdateDate, a.UpdateBy, a.Version, a.Remark, a.NextWorkDate, b.ObjectDesc, d.code_desc FROM eam_workPlan a left join eam_object b on a.Site = b.Site and a.ObjectID = b.ObjectID left join eam_properties_model_header d on a.FunctionType = d.function_type and a.PropertiesCode = d.code_no <where> AND a.DeleteFlag = 'N' AND a.FunctionType = #{query.functionType} <if test="query.planID != null and query.planID != ''"> AND a.PlanID like '%' + #{query.planID} +'%' </if> <if test="query.planDesc != null and query.planDesc != ''"> AND a.PlanDesc like '%' + #{query.planDesc}+'%' </if> <if test="query.status != null and query.status != ''"> AND a.status = #{query.status} </if> <if test="query.startDate != null "> AND a.PlanStartDate >= #{query.startDate} </if> <if test="query.endDate != null "> AND #{query.endDate} >= a.PlanStartDate </if> </where></select>
<select id="selectNameById" resultType="string" parameterType="string"> SELECT AdminName FROM eam_admin WHERE AdminID = #{s} </select>
<select id="searchPlanItems" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemData"> SELECT a.Site, a.PlanID, a.ItemNo, a.ItemDesc, a.DefaultValue, a.ValueType, a.ValueType_DB, a.ValueChooseFlag, a.UpdateDate, a.UpdateBy, a.MaxValue, a.MinValue, a.ItemRemark, a.ItemType, a.CreatedDate, a.CreatedBy, a.ObjectID FROM eam_workPlan_item a <where> and a.PlanID = #{planID} and a.Site = #{site} and a.ItemType = #{functionType} <if test = "objectID != null and objectID != ''"> AND a.ObjectID = #{objectID} </if> </where></select>
<select id="searchPlanItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanItemAvailableData"> SELECT Site, PlanID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy, UpdateDate, UpdateBy, ObjectID from eam_workPlan_item_available where PlanID = #{planID} and itemNo = #{itemNo} and site = #{site} and ItemType = #{itemType} and ObjectID = #{objectID} </select>
<update id="updatePlanItems"> update eam_workPlan_item set DefaultValue = #{defaultValue}, ValueType = #{valueType}, ValueType_DB = #{valueTypeDb}, ValueChooseFlag = #{valueChooseFlag}, UpdateDate = GetDate(), UpdateBy = #{createdBy}, MaxValue = #{maxValue,jdbcType=FLOAT}, MinValue = #{minValue,jdbcType=FLOAT}, ItemRemark = #{itemRemark} where site = #{site} and planID = #{planID} and ItemType = #{itemType} and ItemNo = #{itemNo} and ObjectID = #{objectID}</update><update id="updatePlanItemsForNull"> update eam_workPlan_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb} ,ValueChooseFlag=#{valueChooseFlag},UpdateDate=GetDate(),UpdateBy=#{createdBy},MaxValue=null,MinValue=null, ItemRemark=#{itemRemark} where site=#{site} and planID=#{planID} and ItemType=#{itemType} and ItemNo=#{itemNo}</update>
<insert id="saveItemAvailableForPlan"> insert into eam_workPlan_item_available (Site,PlanID,ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType,ObjectID) values(#{site},#{planID},#{itemNo},#{valueNo},#{availableValue},GetDate(),#{createdBy},#{itemType},#{objectID})</insert>
<update id="updateItemAvailableForPlan"> update eam_workPlan_item_available set AvailableValue = #{availableValue}, updateBy = #{createdBy}, updateDate = GetDate() where itemNo = #{itemNo} and ItemType = #{itemType} and ValueNo = #{valueNo} AND site = #{site} and planID = #{planID} and ObjectID = #{objectID}</update>
<delete id="deletePlanItemAvailable"> delete from eam_workPlan_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and ValueNo=#{valueNo} AND site=#{site} and planID=#{planID} and ObjectID = #{objectID} </delete>
<select id="objectIDBlur" resultType="com.xujie.sys.modules.pms.data.EamObjectData"> select objectID,ObjectDesc from eam_object where active='Y' and Site=#{site} and ObjectID=#{objectID} </select> <select id="modalCodeBlur" resultType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData"> select code_no,code_desc from eam_properties_model_header where active='Y' and function_type=#{functionType} and code_no=#{codeNo} </select>
<select id="eamWorkOrderSearch" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData"> SELECT a.Site, a.OrderNo, a.PlanID, a.PlanDesc, a.PropertiesCode, a.ObjectID, a.Status, a.PlanOperator, a.checker, a.ActualOperator, a.PlanDate, a.ActualDate, a.FunctionType, a.CreateDate, d.operator_name as createBy, a.Remark, a.StartTime, a.EndTime, a.WorkTime, a.PlanOperatorName, a.checkerName, dbo.eam_Get_eamAdminName(a.Site,a.ActualOperator) ActualOperatorName, dbo.eam_Get_eamObjectDesc(a.Site,a.ObjectID) objectDesc, dbo.eam_Get_eam_properties_CodeDesc(a.FunctionType,a.PropertiesCode) codeDesc, a.result, b.urgency, a.checkResult, b.DefectID, c.DefectDesc, a.disposal_measures, a.check_work_plan_id, a.check_item_no, a.reach_date, a.reach_operator, a.reach_operator_name, b.FeedBackDesc, dbo.joint_id(a.Site,a.OrderNo,a.FunctionType) as adminID, dbo.joint_name(a.Site,a.OrderNo,a.FunctionType) as operator, check_remark FROM eam_workOrder a LEFT JOIN eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID LEFT JOIN eam_defect c on b.DefectID = c.DefectID LEFT JOIN operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y' left join eam_object as eo on eo.site = a.site and eo.ObjectID = a.ObjectID left join sys_department as sd ON eo.site = sd.site and eo.dept_id = sd.department_id left join eam_admin_dept as ead ON ead.site = sd.site and ead.dept_id = sd.department_id left join eam_admin as ea on ead.site = ea.site and ead.admin_id = ea.AdminID left join eam_workPlan_overview as ewo on a.site = ewo.site and a.PlanID = ewo.plan_id <where> and a.Site = #{query.site} and ea.MesUser = #{query.username} <if test="query.orderNo != null and query.orderNo != ''"> AND a.OrderNo like '%' + #{query.orderNo} +'%' </if> <if test="query.planID != null and query.planID != ''"> AND a.PlanID like '%' + #{query.planID} +'%' </if> <if test="query.planDesc != null and query.planDesc != ''"> AND a.PlanDesc like '%' + #{query.planDesc} +'%' </if> <if test="query.objectID != null and query.objectID != ''"> AND a.ObjectID like '%' + #{query.objectID} +'%' </if> <if test="query.planOperatorName != null and query.planOperatorName != ''"> AND a.PlanOperatorName like '%' + #{query.planOperatorName} +'%' </if> <if test='(query.status == null || query.status == "") and query.functionType == "A" and query.searchType == "checkOrder" '> AND a.status != '已取消' </if> <if test='query.status != null and query.status != "" and query.functionType == "A" and query.searchType == "checkOrder" '> AND a.status = #{query.status} </if> <if test='query.functionType == "A" and query.searchType == "reportCheck" '> AND a.status = '未开工' </if> <if test='(query.status == null || query.status == "") and query.functionType == "B" and query.searchType == "maintenanceOrder" '> AND a.status != '已取消' </if> <if test='query.status != null and query.status != "" and query.functionType == "B" and query.searchType == "maintenanceOrder" '> AND a.status = #{query.status} </if> <if test='query.functionType == "B" and query.searchType == "reportMaintenance" '> AND (a.status = '未开工' or a.status = '已到达') </if> <if test='query.functionType == "C" and query.searchType == "reportDefect" '> AND (a.status = '未开工' or a.status = '已到达') </if> <if test="query.planDate != null"> AND a.PlanDate = #{query.planDate} </if> <if test="query.startDate != null "> AND a.PlanDate >= #{query.startDate} </if> <if test="query.endDate != null "> AND #{query.endDate} >= a.PlanDate </if> <if test="query.endDate == null "> AND getDate() >= a.PlanDate </if> <if test='query.functionType == "A"'> and getDate() >= dbo.compare_date(ewo.task_start_date) </if> AND a.FunctionType = #{query.functionType} </where> ORDER BY a.CreateDate, CASE WHEN b.urgency = '事故' THEN 1 WHEN b.urgency = '紧急' THEN 2 WHEN b.urgency = '正常' THEN 3 END</select>
<select id="eamWorkOrderSearchForDefect" parameterType="com.xujie.sys.modules.pms.data.EamWorkOrderInData" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData"> SELECT a.Site, a.OrderNo, a.PlanID, a.ObjectID, a.Status, a.PlanOperator, a.ActualOperator, a.PlanDate, a.ActualDate, a.FunctionType, a.CreateDate, d.operator_name as createBy, a.Remark, a.StartTime, a.EndTime, a.WorkTime, dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) as planOperatorName, b.DefectID, c.DefectDesc, dbo.eam_Get_eamObjectDesc(a.Site,a.ObjectID) as objectDesc, dbo.eam_Get_eam_properties_CodeDesc(a.FunctionType,a.PropertiesCode) as codeDesc, a.result, b.urgency, a.disposal_measures, a.difficulty_level, a.difficulty_remark, f.department_name, a.reach_date, b.CreatedDate, a.handling_method, dbo.eam_Get_eamResourceDesc(a.Site, a.ObjectID) as resourceDesc, CASE WHEN (DATEDIFF(SECOND, b.CreatedDate, a.reach_date) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, b.CreatedDate, a.reach_date) / 60.0 ELSE DATEDIFF(MINUTE, b.CreatedDate, a.reach_date) END AS responseTime, b.FeedBackDesc, dbo.joint_name(a.Site,a.OrderNo,a.FunctionType) as actualOperatorName FROM eam_workOrder a left join eam_defect_feedBack b on a.site = b.site and a.PlanID = b.feedBackID left join eam_defect c on b.DefectID = c.DefectID left join operator as d on a.site = d.site and a.CreateBy = d.operator_id and d.active = 'Y' left join eam_object as e on a.site = e.site and a.ObjectID = e.ObjectID and e.Active = 'Y' left join sys_department as f on e.site = f.site and e.dept_id = f.department_id <where> and a.Site = #{query.site} <if test="query.deptArr != null"> AND <foreach collection="query.deptArr" item="item" open="(" separator="or" close=")"> f.department_name like '%' + #{item} + '%' </foreach> </if> <if test="query.orderNo != null and query.orderNo != ''"> AND a.OrderNo like '%' + #{query.orderNo} +'%' </if> <if test="query.planID != null and query.planID != ''"> AND a.PlanID like '%' + #{query.planID} +'%' </if> <if test="query.objectID != null and query.objectID != ''"> AND a.ObjectID like '%' + #{query.objectID} +'%' </if> <if test="query.planOperator != null and query.planOperator != ''"> AND a.PlanOperator like '%' + #{query.planOperator} +'%' </if> <if test="query.status != null and query.status != ''"> AND a.status=#{query.status} </if> <if test="query.startDate != null "> AND a.PlanDate >= #{query.startDate} </if> <if test="query.endDate != null "> AND #{query.endDate} >= a.PlanDate </if> and a.FunctionType =#{query.functionType} </where> ORDER BY a.PlanDate, CASE WHEN b.urgency = '事故' THEN 1 WHEN b.urgency = '紧急' THEN 2 WHEN b.urgency = '正常' THEN 3 END</select>
<select id="eamDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamDefectData" resultType="com.xujie.sys.modules.pms.data.EamDefectData"> SELECT DefectID, DefectDesc, Active, create_date, create_by, update_date, update_by, fault_type FROM eam_defect <where> <if test="query.defectID != null and query.defectID != ''"> AND defectID like '%' + #{query.defectID} + '%' </if> <if test="query.defectDesc != null and query.defectDesc != ''"> AND defectDesc like '%' + #{query.defectDesc} + '%' </if> <if test="query.active != null and query.active != ''"> AND active = #{query.active} </if> </where> order by id</select>
<select id="eamObjectDefectSearch" parameterType="com.xujie.sys.modules.pms.data.EamObjectDefectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData"> SELECT a.site, a.ObjectID, a.DefectID, a.Active, a.id, b.ObjectDesc, c.DefectDesc, a.create_date, a.create_by, a.update_date, a.update_by FROM eam_object_defect a left join eam_object b on a.site=b.site and a.ObjectID=b.ObjectID left join eam_defect c on a.DefectID=c.DefectID <where> <if test="query.objectID != null and query.objectID != ''"> AND a.ObjectID like '%' + #{query.objectID} + '%' </if> <if test="query.objectDesc != null and query.objectDesc != ''"> AND b.ObjectDesc like '%' + #{query.objectDesc} + '%' </if> <if test="query.defectID != null and query.defectID != ''"> AND a.defectID like '%' + #{query.defectID} + '%' </if> <if test="query.defectDesc != null and query.defectDesc != ''"> AND c.defectDesc like '%' + #{query.defectDesc} + '%' </if> <if test="query.active != null and query.active != ''"> AND a.active = #{query.active} </if> </where> order by a.id</select> <select id="getObjectList" parameterType="com.xujie.sys.modules.pms.data.EamObjectInData" resultType="com.xujie.sys.modules.pms.data.EamObjectInData"> SELECT a.Site, a.ObjectID, a.ObjectDesc, a.LocationID, a.FamilyID, a.GroupID, b.FamilyDesc, c.LocationName FROM eam_object a LEFT JOIN eam_family b ON a.site = b.site and a.FamilyID = b.FamilyID LEFT JOIN eam_location as c ON a.LocationID = c.LocationID and a.site = c.site <where> <if test="objectID != null and objectID != ''"> AND a.ObjectID like '%' + #{objectID} + '%' </if> <if test="objectDesc != null and objectDesc != ''"> AND a.ObjectDesc like '%' + #{objectDesc} + '%' </if> AND a.site = #{site} AND a.active = 'Y' </where> </select>
<select id="checkEamFamilyDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData"> SELECT a.site, a.objectID from eam_object as a left join eam_family as b on a.site = b.site and a.FamilyID = b.FamilyID where a.site = '2' and (b.son_id like #{sonId} + '%' or a.FamilyID = #{familyID}) </select>
<select id="checkEamGroupDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData"> SELECT site ,objectID from eam_object where site=#{site} and GroupID=#{groupID} </select>
<select id="checkEamLocationDelete" resultType="com.xujie.sys.modules.pms.data.EamObjectData"> SELECT site ,objectID from eam_object where site=#{site} and LocationID=#{locationID} </select>
<select id="eamWorkPlanItemSearchForReport" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData"> SELECT a.Site, c.OrderNo, a.ItemNo, a.ItemDesc, a.DefaultValue, a.ValueType, a.ValueType_DB, a.ValueChooseFlag, a.MaxValue, a.MinValue, a.ItemRemark, a.ItemType, a.image_flag, a.produce_control_flag, CASE WHEN b.id is null THEN 'N' ELSE 'Y' END as uploadFlag, a.item_notes from eam_workPlan_item as a left join eam_workOrder as c on a.site = c.site and a.PlanID = c.PlanID left join (SELECT MAX (id) as id, order_ref1, order_ref2, order_ref3 FROM sys_oss GROUP BY order_ref1, order_ref2, order_ref3) as b on b.order_ref1 = a.site and b.order_ref2 = c.OrderNo and b.order_ref3 = a.ItemNo where a.site = #{site} and c.orderNo = #{orderNo} and a.ObjectID = #{objectID} </select>
<select id="checkEamOrderStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderInData"> SELECT Site, status, OrderNo from eam_workOrder where site = #{site} and orderNo = #{orderNo} </select>
<select id="getAdminIDWithMesUser" resultType="com.xujie.sys.modules.pms.data.EamAdminData"> SELECT adminID from eam_admin where site = #{site} and mesUser = #{mesUser} and active = 'Y' </select>
<update id="updateDefectResult" > update eam_defect_feedBack set Status = #{result}, FinishDate = GetDate(), DefectID = #{defectID} where Site = #{site} and FeedBackID = #{planID} </update>
<update id="reportWorkOrder" parameterType="EamWorkOrderInData"> update eam_workOrder set Status = '待审核', ActualOperator = #{actualOperator}, ActualDate = #{actualDate}, Remark = #{remark}, disposal_measures = #{disposalMeasures}, WorkTime = CASE WHEN (DATEDIFF(SECOND, reach_date, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, reach_date, #{actualDate}) / 60.0 ELSE DATEDIFF(MINUTE, reach_date, #{actualDate}) END, result = #{result,jdbcType=VARCHAR}, checkResult = #{checkResult}, handling_method = #{handlingMethod} where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} </update>
<update id="reportWorkOrder2" parameterType="EamWorkOrderInData"> update eam_workOrder set Status = '待审核', ActualOperator = #{actualOperator}, ActualDate = #{actualDate}, Remark = #{remark}, disposal_measures = #{disposalMeasures}, WorkTime = #{workTime}, result = #{result,jdbcType=VARCHAR}, checkResult = #{checkResult}, handling_method = #{handlingMethod}, check_remark = #{checkRemark} where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} </update>
<update id="defectReportWorkOrder" > update eam_workOrder set Status = '已完工', ActualOperator = #{actualOperator}, ActualDate = GetDate(), Remark = #{remark}, disposal_measures = #{disposalMeasures}, WorkTime = #{workTime}, result = #{result,jdbcType=VARCHAR}, checkResult = #{checkResult} where site = #{site} and orderNo = #{orderNo} </update> <insert id="saveWorkOrderItem"> INSERT into eam_workOrder_item (Site, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult, item_notes) values (#{site}, #{orderNo}, #{itemNo}, #{itemDesc}, #{defaultValue}, #{valueType}, #{valueTypeDb}, #{valueChooseFlag}, #{maxValue,jdbcType=DOUBLE}, #{minValue,jdbcType=DOUBLE}, #{itemRemark,jdbcType=VARCHAR}, #{itemType}, #{textValue,jdbcType=VARCHAR}, #{numberValue,jdbcType=DOUBLE}, GetDate(), #{createdBy}, #{finishFlag}, #{itemResult}, #{itemNotes}) </insert> <!-- 修改 eam_workPlan 状态为已结束 --> <update id="closePlanWithCheck"> update eam_workPlan set status = '已结束' where site = #{site} and PlanID = #{planID} and ObjectID = #{objectID} and GetDate() > PlanEndDate </update>
<!-- 报工后更新下一个工作日期 --> <update id="updatePlanNextDate"> update eam_workPlan_overview set next_work_date = (select top 1 PlanDate from eam_workOrder where site = #{site} and PlanID = #{planID} and PlanDate > GetDate() and status = '未开工' order by PlanDate) where site = #{site} and plan_id = #{planID} </update>
<select id="eamWorkOrderReportSearch" resultType="com.xujie.sys.modules.pms.data.EamWorkOrderItemInData"> SELECT Site, OrderNo, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB, ValueChooseFlag, MaxValue, MinValue, ItemRemark, ItemType, TextValue, NumberValue, CreatedDate, CreatedBy, FinishFlag, itemResult from eam_workOrder_item where site = #{site} and orderNo = #{orderNo} </select>
<update id="cancelOrder" parameterType="EamWorkOrderInData"> update eam_workOrder set Status = '已取消' where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} </update>
<update id="cancelOrderAll" parameterType="EamWorkOrderInData"> update eam_workOrder set Status = '已取消' where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} and Status = #{status} </update>
<select id="checkPlanStatus" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData"> SELECT site, status from eam_workPlan_overview where site = #{site} and plan_id = #{planID} and delete_flag = 'N' </select>
<update id="planOrder"> update eam_workPlan set Status = '已计划', NextWorkDate = null where site = #{site} and PlanID = #{planID} and deleteFlag = 'N' </update>
<update id="cancelPlan"> update eam_workPlan_overview set status = '已取消', next_work_date = null where site = #{site} and plan_id = #{planID} and delete_flag = 'N' </update>
<update id="updateWorkPlanStatus"> update eam_workPlan set Status = '已取消', NextWorkDate = null where Site = #{site} and PlanID = #{planID} and deleteFlag = 'N' </update>
<update id="cancelOrderWithPlanID"> update eam_workOrder set Status = '已取消' where site = #{site} and PlanID = #{planID} and status = '未开工' </update>
<update id="deleteOrderDetailWithPlanID"> delete from eam_workOrder_item where site = #{site} and OrderNo in (select OrderNo from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 ) </update>
<update id="deleteOrderWithPlanID"> delete from eam_workOrder where site = #{site} and PlanID = #{planID} and status = '未开工' and PlanDate > GetDate() - 1 </update>
<update id="updateOrderPlanOperator"> update eam_workOrder set PlanOperator = #{planOperator} where site = #{site} and orderNo = #{orderNo} </update>
<select id="getSpareSelectList" resultType="com.xujie.sys.modules.pms.data.PartSpareInData"> select a.site ,a.part_no,a.part_description,a.spec,b.resource_id objectID from part_spare a left join resource_spare b on a.site = b.site and a.part_no = b.part_no and resource_id = #{objectID} <where> <if test="partNo != null and partNo != ''"> AND a.part_no like '%' + #{partNo} + '%' </if> <if test="partDescription != null and partDescription != ''"> AND a.part_description like '%' + #{partDescription} + '%' </if> and a.site=#{site} and a.active='Y' </where> </select>
<select id="checkPartSpare" resultType="com.xujie.sys.modules.pms.data.PartSpareInData"> select part_no from resource_spare where site = #{site} and resource_id = #{objectID} and part_no = #{partNo} </select>
<insert id="savePartSpare" > INSERT Into resource_spare (resource_id,part_no,delflag,version,site) values(#{objectID},#{partNo},'',0,#{site}) </insert>
<delete id="deletePartSpare"> delete from resource_spare where resource_id = #{objectID} and site = #{site} </delete>
<insert id="copyPartSpare" > INSERT Into resource_spare (resource_id,part_no,delflag,version,site) select #{objectID},part_no,delflag,0,site from resource_spare where resource_id=#{oldObjectID} and site=#{site} </insert>
<select id="getWorkPlanDataWithObjectID" resultType="com.xujie.sys.modules.pms.data.EamWorkPlanInData"> SELECT a.Site,a.PlanID,a.PlanDesc,a.ObjectID,a.FunctionType,a.PropertiesCode,a.Operator,a.PlanPeriod,a.Status, a.PlanStartDate,a.PlanEndDate,a.CreatedDate,a.CreatedBy,a.UpdateDate,a.UpdateBy,a.Version,a.Remark ,a.NextWorkDate,b.ObjectDesc,c.adminName,d.code_desc
FROM eam_workPlan a left join eam_object b on a.Site=b.Site and a.ObjectID=b.ObjectID left join eam_admin c on a.Site=c.Site and a.operator=c.AdminID left join eam_properties_model_header d on a.FunctionType=d.function_type and a.PropertiesCode=d.code_no where a.site=#{site} and a.ObjectID=#{objectID} and a.FunctionType=#{functionType} and a.DeleteFlag='N' and status in ('已计划','进行中')</select>
<select id="getObjectItemList" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData"> SELECT a.site,a.objectID,a.ItemNo,a.DefaultValue,a.ValueType,a.ValueType_DB,a.ValueChooseFlag,a.CreatedDate,a.CreatedBy, a.MaxValue,a.MinValue,a.ItemType,b.ItemDesc,b.ItemRemark from eam_object_item a left join eam_properties_item b on a.ItemNo=b.ItemNo and a.ItemType=b.ItemType where a.site=#{site} and a.ObjectID=#{objectID} and a.ItemType=#{itemType}</select>
<select id="getDefectWithObject" resultType="com.xujie.sys.modules.pms.data.EamObjectDefectInData"> SELECT a.site,a.ObjectID,a.DefectID,a.Active,a.id,b.DefectDesc from eam_object_defect a left join eam_defect b on a.DefectID=b.DefectID where a.site=#{site} and a.ObjectID=#{objectID}
</select>
<select id="checkEamObjectItemData" resultType="com.xujie.sys.modules.pms.data.EamObjectItemInData"> select site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue, ItemType from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}</select>
<insert id="saveNewEamObjectItem" > insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue, ItemType) values(#{site},#{objectID},#{itemNo},#{defaultValue},#{valueType},#{valueTypeDb},#{valueChooseFlag},GetDate(),#{userId},#{maxValue,jdbcType=DOUBLE},#{minValue,jdbcType=DOUBLE},#{itemType})</insert>
<update id="editEamObjectItem"> update eam_object_item set DefaultValue=#{defaultValue},ValueType=#{valueType},ValueType_DB=#{valueTypeDb} ,ValueChooseFlag=#{valueChooseFlag},MaxValue=#{maxValue,jdbcType=FLOAT},MinValue=#{minValue,jdbcType=FLOAT}
where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}</update>
<delete id="deleteObjectItem"> delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}</delete>
<insert id="saveNewEamObjectItemAvailable"> insert into eam_object_item_available (Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy) select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate() ,#{userId} from eam_properties_item_available where ItemNo=#{itemNo} and ItemType=#{itemType}</insert>
<delete id="deleteEamObjectItemAvailable"> delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}</delete><select id="searchObjectItemAvailable" resultType="com.xujie.sys.modules.pms.data.EamObjectItemAvailableData"> select Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo}</select><select id="getItemValueNoForObject" resultType="Double"> SELECT isnull( max(valueNo),0)+1 from eam_object_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and site=#{site} and objectID=#{objectID}</select>
<insert id="saveObjectItemAvailable"> insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy) values(#{site},#{objectID},#{itemNo},#{itemType},#{valueNo},#{availableValue},GetDate(),#{createdBy})</insert><update id="updateObjectItemAvailable"> update eam_object_item_available set AvailableValue=#{availableValue},updateDate=GetDate(),updateBy=#{createdBy} where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}</update>
<delete id="deleteObjectItemAvailable"> delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType} and ItemNo=#{itemNo} and ValueNo=#{valueNo}</delete>
<delete id="deleteObjectItemForCopy"> delete from eam_object_item where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}</delete><delete id="deleteObjectItemAvailableForCopy"> delete from eam_object_item_available where site=#{site} and objectID=#{objectID} and ItemType=#{itemType}</delete><insert id="copyObjectItem" > insert into eam_object_item (site,objectID,ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,CreatedDate,CreatedBy,MaxValue,MinValue, ItemType) select #{site},#{objectID},ItemNo,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,GetDate(),#{createBy},MaxValue,MinValue,ItemType from eam_object_item where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}</insert><insert id="copyObjectItemAvailable"> insert into eam_object_item_available(Site,ObjectID,ItemNo,ItemType,ValueNo,AvailableValue,CreatedDate,CreatedBy) select #{site},#{objectID},ItemNo,ItemType,ValueNo,AvailableValue,GetDate(),#{createBy} from eam_object_item_available where site=#{site} and objectID=#{oldObjectID} and ItemType=#{itemType}</insert><delete id="deleteObjectDefectForCopy"> delete from eam_object_defect where site=#{site} and objectID=#{objectID}</delete>
<insert id="copyObjectDefect"> insert into eam_object_defect(site,ObjectID,DefectID,Active) select #{site},#{objectID},DefectID,Active from eam_object_defect where site=#{site} and objectID=#{oldObjectID}</insert>
<select id="eamFeedBackSearch" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData"> select a.Site, a.FeedBackID, a.FeedBackDesc, a.ObjectID, a.DefectID, a.FunctionType, a.PlanOperator, a.ActualOperator, a.Status, a.PlanDate, a.Remark, a.urgency, a.deleteFlag, a.CreatedDate, a.CreatedBy, c.operator_name as feedbackBy, a.UpdateDate, a.UpdateBy, a.Version, a.DefectDate, dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName, b.defectDesc, dbo.eam_Get_eamObjectDesc(a.Site,a.ObjectID) ObjectDesc, FinishDate, dbo.joint_name(a.Site,(select OrderNo from eam_workOrder where PlanID = a.FeedBackID and site = a.site and Result = '维修完成'),a.FunctionType) as actualOperatorName from eam_defect_feedBack a left join eam_defect b on a.DefectID = b.DefectID left join operator as c on a.site = c.site and a.CreatedBy = c.operator_id <where> and a.Site = #{query.site} <if test="query.feedBackID != null and query.feedBackID != ''"> AND a.feedBackID like '%' + #{query.feedBackID} +'%' </if> <if test="query.defectDesc != null and query.defectDesc != ''"> AND b.defectDesc like '%' + #{query.defectDesc} +'%' </if> <if test="query.objectID != null and query.objectID != ''"> AND a.ObjectID like '%' + #{query.objectID} +'%' </if> <if test="query.planOperator != null and query.planOperator != ''"> AND a.PlanOperator like '%' + #{query.planOperator} +'%' </if> <if test="query.status != null and query.status != ''"> AND a.status = #{query.status} </if> <if test="query.startDate != null "> AND a.defectDate >= #{query.startDate} </if> <if test="query.endDate != null "> AND #{query.endDate} >= a.defectDate </if> and a.FunctionType = #{query.functionType} </where> ORDER BY a.DefectDate, CASE WHEN a.urgency = '事故' THEN 1 WHEN a.urgency = '紧急' THEN 2 WHEN a.urgency = '正常' THEN 3 END </select>
<select id="eamFeedBackCheck" resultType="com.xujie.sys.modules.pms.data.EamDefectFeedBackInData"> select Site,FeedBackID,FeedBackDesc,ObjectID,DefectID,Status from eam_defect_feedBack where FeedBackID=#{feedBackID} and site=#{site}</select>
<update id="cancelFeedBack" > update eam_defect_feedBack set status = '已取消' where FeedBackID = #{feedBackID} and site = #{site}</update>
<update id="updateFeedBack"> update eam_defect_feedBack set status = '已下达', PlanOperator = #{planOperator}, UpdateDate = GetDate(), UpdateBy = #{updateBy} where FeedBackID = #{feedBackID} and site = #{site} </update>
<insert id="saveDefectOrder"> INSERT INTO eam_workOrder (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy) values(#{site}, (select 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site=#{site} and FunctionType='C' ), #{feedBackID}, '', #{objectID}, '未开工', #{planOperator}, #{planDate}, 'C', GetDate(), #{userId}) </insert>
<select id="getItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData"> SELECT a.itemNo, a.ItemDesc, a.ItemRemark FROM eam_properties_item a LEFT JOIN eam_properties_model_detail b on b.function_type = #{functionType} and b.code_no = #{codeNo} and b.properties_item_no = a.ItemNo and a.site = b.site <where> a.ItemType = #{functionType} and a.site = #{site} AND b.code_no is null <if test = "itemNo != null and itemNo != ''"> AND a.ItemNo LIKE '%' + #{itemNo} + '%' </if> <if test = "itemDesc != null and itemDesc != ''"> AND a.ItemDesc LIKE '%' + #{itemDesc} + '%' </if> </where> </select>
<select id="getModelItemLists" resultType="com.xujie.sys.modules.pms.data.EamPropertiesItemData"> select a.properties_item_no itemNo, b.ItemDesc, b.ItemRemark from eam_properties_model_detail a left join eam_properties_item b on a.properties_item_no = b.ItemNo and a.function_type = b.ItemType where a.code_no = #{codeNo} and a.function_type = #{functionType} </select>
<delete id="deleteObjectFile"> delete from sys_oss where id = #{id} </delete>
<select id="checkSparPartImage" resultType="SysOssEntity" parameterType="EamWorkOrderInData"> SELECT id, url, create_date, file_name, new_file_name, created_by, order_ref1, order_ref2, order_ref3, file_type, file_suffix, file_type_code FROM sys_oss WHERE order_ref2 = #{orderNo} AND order_ref1 = #{site} AND order_ref3 = 'reportSparPart' </select>
<!-- 获取机修人员列表 --> <select id="getOperatorList" resultType="EamAdminData" parameterType="EamAdminData"> SELECT ea.AdminID, ea.AdminName, ea.Phone, dbo.get_eam_dept_str(ea.site,ea.AdminID) as departmentName, ea.Email, ea.Tel, ea.LevelID, eal.AdminLevelDesc, ea.MesUser, ea.Active, ea.CreatedDate FROM eam_admin as ea LEFT JOIN eam_adminLevel as eaL ON ea.LevelID = eal.AdminLevelID and ea.site = eal.site <where> ea.Active = 'Y' AND ea.Site = #{site} <if test = "adminID != null and adminID != ''"> AND ea.AdminID LIKE '%' + #{adminID}+'%' </if> <if test = "adminName != null and adminName != ''"> AND ea.AdminName LIKE '%' + #{adminName}+'%' </if> </where> </select>
<!-- 获取审核人员列表 --> <select id="getCheckerList" resultType="EamAdminData" parameterType="EamAdminData"> SELECT site, user_id, username as adminID, email, mobile as phone, user_display as adminName FROM sys_user <where> AND site = #{site} <if test = "adminID != null and adminID != ''"> AND username LIKE '%' + #{adminID}+'%' </if> <if test = "adminName != null and adminName != ''"> AND user_display LIKE '%' + #{adminName}+'%' </if> </where> </select>
<!-- 点检工单审核 --> <update id="checkWorkOrder" parameterType="EamWorkOrderInData"> UPDATE eam_workOrder SET Status = '已完工' WHERE Site = #{site} AND OrderNo = #{orderNo} </update>
<update id="cancelCheckWorkOrder" parameterType="EamWorkOrderInData"> UPDATE eam_workOrder SET Status = '待审核' WHERE Site = #{site} AND OrderNo = #{orderNo} </update>
<!-- 查看点检工单状态 --> <select id="checkWorkOrderStatus" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData"> SELECT OrderNo FROM eam_workOrder WHERE site = #{site} AND PlanID = #{planID} AND Status != '已完工' </select>
<!-- 点检工单审核 --> <update id="updateWorkPlanOverviewStatus" parameterType="EamWorkOrderInData"> UPDATE eam_workPlan_overview SET status = '已结束' WHERE site = #{site} AND plan_id = #{planID} </update>
<!-- 新增点检计划 --> <insert id="saveWorkPlan" parameterType="EamWorkPlanInData"> INSERT INTO eam_workPlan_overview (site, plan_id, plan_desc, status, plan_start_date, plan_end_date, created_date, created_by, update_date, update_by, remark, delete_flag, operator, operator_name, checker, checker_name, function_type, properties_code, plan_period, work_order_rule, plan_cycle, task_start_date) VALUES (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy}, #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod}, #{workOrderRule}, #{planCycle}, #{taskStartDate}) </insert>
<!-- 生成工单ID --> <select id="selectOrderId" resultType="string" parameterType="EamWorkPlanInData"> SELECT Right('0000000000'+ convert(VARCHAR(10), isnull(max(convert(INT,SUBSTRING(PlanID,3,10))),0)+1),8) FROM eam_workPlan WHERE site = #{site} AND FunctionType = #{functionType} </select>
<!-- 查询计划中的设备列表 --> <select id="getPlanDetailList" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData"> SELECT ewp.PlanID, ewp.PlanDesc, ewp.ObjectID, eo.ObjectDesc, eo.FamilyID, ef.FamilyDesc, eo.LocationID, el.LocationName FROM eam_workPlan as ewP LEFT JOIN eam_object as eo ON ewP.ObjectID = eo.ObjectID and ewP.Site = eo.Site LEFT JOIN eam_family as ef ON eo.FamilyID = ef.FamilyID and ewP.Site = ef.Site LEFT JOIN eam_location as el ON eo.LocationID = el.LocationID and ewP.Site = el.Site <where> ewP.site = #{site} AND ewp.PlanID = #{planID} <if test = "objectID != null and objectID != ''"> AND eo.ObjectID LIKE '%' + #{objectID}+'%' </if> <if test = "objectDesc != null and objectDesc != ''"> AND eo.ObjectDesc LIKE '%' + #{objectDesc}+'%' </if> </where> </select>
<!-- 删除计划中的设备 --> <delete id="delPlanDetail" parameterType="WorkPlanDetailData"> DELETE FROM eam_workPlan WHERE Site = #{site} AND PlanID = #{planID} AND ObjectID = #{objectID} </delete>
<!-- 获取当前计划不包含的设备 --> <select id="getObjList1" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData"> SELECT a.ObjectID, a.ObjectDesc, a.FamilyID, ef.FamilyDesc, a.LocationID, el.LocationName FROM eam_object a LEFT JOIN eam_workPlan b ON b.PlanID = #{planID} and b.ObjectID = a.ObjectID and a.site = b.site LEFT JOIN eam_family as ef ON a.FamilyID = ef.FamilyID and a.site = ef.site LEFT JOIN eam_location as el ON a.LocationID = el.LocationID and a.site = el.site WHERE a.site = #{site} and b.PlanID is null </select>
<!-- 获取当前计划包含的设备 --> <select id="getObjList2" resultType="WorkPlanDetailData" parameterType="WorkPlanDetailData"> SELECT a.ObjectID, b.ObjectDesc, b.FamilyID, ef.FamilyDesc, b.LocationID, el.LocationName FROM eam_workPlan a LEFT JOIN eam_object b ON a.ObjectID = b.ObjectID and a.site = b.site LEFT JOIN eam_family as ef ON b.FamilyID = ef.FamilyID and a.site = ef.site LEFT JOIN eam_location as el ON b.LocationID = el.LocationID and a.site = el.site WHERE a.PlanID = #{planID} and a.site = #{site} </select>
<!-- 添加计划设备 --> <insert id="addObject" parameterType="EamWorkPlanInData"> INSERT INTO eam_workPlan (Site,PlanID,PlanDesc,ObjectID,FunctionType,PropertiesCode,Operator,OperatorName,checker,checkerName,PlanPeriod,Status,PlanStartDate,PlanEndDate,CreatedDate,CreatedBy,Version,Remark,DeleteFlag) values (#{site},#{planID},#{planDesc},#{objectID},#{functionType},#{propertiesCode},#{operator},#{operatorName},#{checker},#{checkerName},#{planPeriod},#{status},#{planStartDate},#{planEndDate},GetDate(),#{createdBy},0,#{remark},'N') </insert>
<!-- 修改工单计划 --> <update id="updateWorkPlan" parameterType="EamWorkPlanInData"> UPDATE eam_workPlan_overview SET plan_desc = #{planDesc}, properties_code = #{propertiesCode}, plan_start_date = #{planStartDate}, plan_end_date = #{planEndDate}, plan_period = #{planPeriod}, remark = #{remark}, operator = #{operator}, operator_name = #{operatorName}, checker = #{checker}, checker_name = #{checkerName}, work_order_rule = #{workOrderRule}, task_start_date = #{taskStartDate}, plan_cycle = #{planCycle} WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} </update>
<!-- 删除该计划的旧设备 --> <delete id="delWorkPlanObject" parameterType="EamWorkPlanInData"> DELETE FROM eam_workPlan WHERE Site = #{site} AND PlanID = #{planID} </delete>
<!-- 删除该计划的旧设备item --> <delete id="delWorkPlanItem" parameterType="EamWorkPlanInData"> DELETE FROM eam_workPlan_item WHERE Site = #{site} AND PlanID = #{planID} </delete>
<!-- 删除该计划的旧设备itemAvailable--> <delete id="delWorkPlanItemAvailable"> DELETE FROM eam_workPlan_item_available WHERE Site = #{site} AND PlanID = #{planID} AND ObjectID = #{objectID} </delete>
<!-- 查询该计划的设备 --> <select id="planObjectSearch" resultType="EamWorkPlanItemData" parameterType="EamWorkPlanItemData"> SELECT DISTINCT a.ObjectID, b.ObjectDesc FROM eam_workPlan_item as a LEFT JOIN eam_object as b ON a.ObjectID = b.ObjectID WHERE a.Site = #{site} AND a.PlanID = #{planID} </select>
<!-- 修改该计划状态 --> <update id="updateOverviewStatus" parameterType="EamWorkPlanInData"> UPDATE eam_workPlan_overview SET status = '进行中', next_work_date = plan_start_date WHERE site = #{site} AND plan_id = #{planID} </update>
<!-- 查询文件路径 --> <select id="searchFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderInData"> SELECT id, url, file_name FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{folder} </select>
<!-- 新增子明细信息 --> <insert id="saveOperator" parameterType="EamWorkOrderInData"> INSERT INTO eam_actual_operator (site, order_no, function_type, operator) VALUES (#{site}, #{orderNo}, #{functionType}, #{operator}) </insert>
<!-- AND Status = '已完工' AND PlanOperator is not null-->
<!-- 查询实际维修人员 --> <select id="getActualOperatorList2" resultType="EamAdminData"> SELECT ea.AdminID, ea.AdminName FROM eam_actual_operator as eao LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site LEFT JOIN eam_workOrder as ew ON eao.site = ew.Site and eao.function_type = ew.FunctionType and eao.order_no = ew.OrderNo WHERE eao.site = #{site} AND eao.function_type = #{functionType} AND ew.PlanID = #{planID} </select>
<!-- 查询实际维修人员 --> <select id="getActualOperatorList" resultType="EamAdminData"> SELECT ea.AdminID, ea.AdminName FROM eam_actual_operator as eao LEFT JOIN eam_admin as ea ON eao.operator = ea.AdminID and eao.site = ea.Site WHERE eao.site = #{site} AND eao.order_no = #{orderNo} AND eao.function_type = #{functionType} </select>
<!-- 查询设备所属部门 --> <select id="selectDeptByObjectID" resultType="string" parameterType="string"> SELECT ved.department_name FROM eam_object as eo LEFT JOIN sys_department as ved ON eo.site = ved.site and eo.dept_id = ved.department_id WHERE eo.site = #{site} AND eo.ObjectID = #{objectID} </select>
<!-- 查询用户所属部门 --> <select id="selectAdminIdByUserName" resultType="string" parameterType="string"> SELECT AdminID FROM eam_admin WHERE site = #{site} AND MesUser = #{username} </select>
<!-- 查询部门列表 --> <select id="getDeptList" resultType="string" parameterType="string">
SELECT ved.department_name FROM eam_admin_dept as ead LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id LEFT JOIN eam_admin as ea ON ead.site = ea.site and ead.admin_id = ea.AdminID WHERE ead.site = #{site} AND ea.MesUser = #{username} </select>
<!-- 生成新的维修工单 --> <insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData"> INSERT INTO eam_workOrder (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no) VALUES (#{site}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}) </insert>
<!-- 创建count表 --> <insert id="saveDefectRecordCount2" parameterType="EamWorkOrderInData"> INSERT INTO eam_workOrder_count (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, check_work_plan_id, check_item_no) VALUES (#{site}, #{orderNo}, #{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy}, #{checkWorkPlanId}, #{checkItemNo}) </insert>
<!-- 获取旧工单的基础信息 --> <select id="queryOldWorkOrderMessage" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData"> select PlanOperator, PlanOperatorName, checker, checkerName from eam_workOrder where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} </select>
<!-- 生成新的维保工单 --> <insert id="saveMaintenanceWorkOrder" parameterType="EamWorkOrderInData"> INSERT INTO eam_workOrder (Site, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType, CreateDate, CreateBy, checker, PlanOperatorName, checkerName) VALUES (#{site}, (select 'W' + Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site = #{site} and FunctionType = 'B'), #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{planOperator}, Dateadd(dd, Datediff(dd,0,Getdate()), 0), #{functionType}, getDate(), #{createBy}, #{checker}, #{planOperatorName}, #{checkerName}) </insert>
<!-- 检查系统操作人和审核人员是否一致 --> <select id="selectNameByMes" resultType="EamAdminData" parameterType="EamAdminData"> SELECT AdminName FROM eam_admin WHERE site = #{site} AND MesUser = #{mesUser} </select>
<!-- 维修审核确认 --> <update id="submitDefect" parameterType="EamWorkOrderInData"> UPDATE eam_workOrder SET Status = #{status}, difficulty_level = #{difficultyLevel}, difficulty_remark = #{difficultyRemark} WHERE Site = #{site} AND OrderNo = #{orderNo} </update>
<!-- 查询设备的点检和维保历史记录 --> <select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData"> SELECT top 10 ewo.OrderNo, ewo.PlanID, ewo.PlanDesc, ewo.ActualDate, ewo.ObjectID, eo.ObjectDesc, ewo.Remark, dbo.eam_Get_eamAdminName(ewo.site,ewo.ActualOperator) ActualOperatorName, ewo.checkResult FROM eam_workOrder as ewo LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' ORDER BY ewo.ActualDate desc </select>
<!-- 查询设备的维修历史记录 --> <select id="queryDefectHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData"> SELECT top 10 ewo.OrderNo, ewo.PlanID, ewo.PlanDesc, ewo.ActualDate, ewo.Remark, ewo.Result, ewo.disposal_measures, ed.DefectDesc, ewo.WorkTime FROM eam_workOrder as ewo LEFT JOIN eam_object as eo ON ewo.site = eo.site and ewo.ObjectID = eo.ObjectID LEFT JOIN eam_defect_feedBack as edf ON ewo.site = edf.site and ewo.PlanID = edf.FeedBackID LEFT JOIN eam_defect as ed ON ed.DefectID = edf.DefectID WHERE ewo.site = #{site} AND ewo.ObjectID = #{objectID} AND ewo.FunctionType = #{functionType} AND ewo.Status = '已完工' ORDER BY ewo.ActualDate desc </select>
<!-- AND datediff(week, ewo.ActualDate, getdate()) = 0-->
<!-- 查询部门列表 --> <select id="getEmpyDeptList" resultType="EmpyDept" parameterType="EmpyDept"> SELECT site, department_id as deptId, department_name as deptName FROM sys_department <where> site = #{site} <if test = "deptId != null and deptId != ''"> AND department_id LIKE '%' + #{deptId}+'%' </if> <if test = "deptName != null and deptName != ''"> AND department_name LIKE '%' + #{deptName}+'%' </if> </where> </select>
<!-- 生成新的维修工单 --> <insert id="saveAdminDepartment"> INSERT INTO eam_admin_dept (Site, admin_id, dept_id) VALUES (#{site}, #{adminID}, #{deptId}) </insert>
<!-- 查询部门详情 --> <select id="getDeptDetail" resultType="EamAdminData" parameterType="string"> SELECT ved.department_id as department, ved.department_name as departmentName FROM eam_admin_dept as ead LEFT JOIN sys_department as ved ON ead.site = ved.site and ead.dept_id = ved.department_id WHERE ead.site = #{site} AND ead.admin_id = #{adminID} </select>
<!-- 删除旧数据--> <delete id="deleteAdminDepartment"> DELETE FROM eam_admin_dept WHERE site = #{site} AND admin_id = #{adminID} </delete>
<!-- 获取可用的MES账号 --> <select id="getMesList" resultType="SysUserEntity" parameterType="SysUserEntity"> SELECT a.username, a.user_display FROM sys_user a LEFT JOIN eam_admin b ON b.MesUser = a.username and a.site = b.site WHERE a.site = #{site} AND b.MesUser is null </select>
<!-- 查询点检项目 --> <select id="eamPropertiesItemSearch" parameterType="EamPropertiesItemData" resultType="EamPropertiesItemData"> SELECT site, ItemNo, ItemDesc, DefaultValue, ValueType, ValueType_DB as valueTypeDb, ValueChooseFlag, CreatedDate, CreatedBy, update_date, update_by, MaxValue, MinValue, ItemRemark, ItemType, image_flag, produce_control_flag FROM eam_properties_item <where> site = #{query.site} and ItemType = #{query.itemType} <if test="query.itemNo != null and query.itemNo != ''"> AND ItemNo LIKE '%' + #{query.itemNo}+'%' </if> <if test="query.itemDesc != null and query.itemDesc != ''"> AND ItemDesc LIKE '%' + #{query.itemDesc}+'%' </if> </where> </select>
<!-- 删除图片--> <delete id="imageDelete" parameterType="SysOssEntity"> DELETE FROM sys_oss WHERE id = #{id} </delete>
<!-- 检查该日期内是否已有该设备的计划 --> <select id="checkObjectPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData"> SELECT a.PlanID, a.ObjectID FROM eam_workPlan a LEFT JOIN eam_workOrder b ON a.site = b.site AND a.PlanID = b.PlanID and a.FunctionType = b.FunctionType and a.ObjectID = b.ObjectID WHERE a.site = #{site} AND a.ObjectID = #{objectID} AND a.FunctionType = #{functionType} AND a.Status in ('已计划','进行中') AND a.deleteFlag = 'N' AND (convert(varchar(10), a.PlanStartDate, 120) between #{planStartDate} and #{planEndDate} or convert(varchar(10), a.PlanEndDate, 120) between #{planStartDate} and #{planEndDate} or (DATEDIFF(day, a.PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, a.PlanEndDate) >= 0) ) and a.PropertiesCode = #{propertiesCode} and a.plan_cycle = #{planCycle} and a.PlanPeriod = #{planPeriod} and b.Status not in ('已取消','已完成','待审核') </select>
<!-- 获取可用的MES账号 --> <select id="queryWorkPlan" resultType="EamWorkPlanInData" parameterType="EamWorkPlanInData"> SELECT site, plan_id, plan_desc, properties_code, #{objectID} as objectID, status, operator, delete_flag, plan_start_date, plan_end_date, plan_period, function_type, checker, checker_name, operator_name, work_order_rule, plan_cycle FROM eam_workPlan_overview WHERE site = #{site} AND plan_id = #{planID} AND function_type = #{functionType} </select>
<!-- 获得工单号 --> <select id="queryPlanOrderNo" resultType="string" parameterType="EamWorkPlanInData"> SELECT Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) FROM eam_workOrder WHERE site = #{site} AND FunctionType = #{functionType} </select>
<!-- 新增工单 --> <insert id="insertWorkOrder" parameterType="EamWorkPlanInData"> INSERT INTO eam_workOrder (Site, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName) VALUES (#{site}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{planStartDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}) </insert>
<!-- 循环新增工单 --> <insert id="forInsertWorkOrder" parameterType="EamWorkPlanInData"> INSERT INTO eam_workOrder (Site, OrderNo, PlanID, PlanDesc, PropertiesCode, ObjectID, Status, PlanOperator, PlanDate, FunctionType,CreateDate, CreateBy, checker, PlanOperatorName, checkerName) VALUES (#{site}, #{orderNo}, #{planID}, #{planDesc}, #{propertiesCode}, #{objectID}, '未开工', #{operator}, #{orderDate}, #{functionType}, getDate(), #{userId}, #{checker}, #{operatorName}, #{checkerName}) </insert>
<!-- 更改plan表的状态为进行中 --> <update id="updatePlanStatus" parameterType="EamWorkPlanInData"> update eam_workPlan set status = '进行中', NextWorkDate = PlanStartDate where site = #{site} and PlanID = #{planID} and FunctionType = #{functionType} and ObjectID = #{objectID} </update>
<!-- 获得工单号 --> <select id="queryFileByOrderNoAndItemNo" resultType="SysOssEntity" parameterType="EamWorkOrderItemInData"> SELECT id, file_name FROM sys_oss WHERE order_ref1 = #{site} AND order_ref2 = #{orderNo} AND order_ref3 = #{itemNo} </select>
<!-- 删除原来工单项目--> <delete id="deleteWorkPlanItem" parameterType="EamWorkOrderItemInData"> DELETE FROM eam_workPlan_item WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} </delete>
<!-- 删除原来的可选值--> <delete id="deleteWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData"> DELETE FROM eam_workPlan_item_available WHERE site = #{site} and PlanID = #{planID} and ItemType = #{itemType} and ObjectID = #{objectID} </delete>
<!-- 添加新项目 --> <insert id="saveWorkPlanItem" parameterType="EamWorkOrderItemInData"> INSERT INTO eam_workPlan_item (Site,PlanID,ObjectID,ItemNo,ItemDesc,DefaultValue,ValueType,ValueType_DB,ValueChooseFlag,MaxValue,MinValue,ItemRemark,ItemType,CreatedDate,CreatedBy,image_flag,produce_control_flag) select #{site}, #{planID}, #{objectID}, a.ItemNo, a.ItemDesc, case when c.site is not null then c.DefaultValue else a.DefaultValue end, case when c.site is not null then c.ValueType else a.ValueType end, case when c.site is not null then c.ValueType_DB else a.ValueType_DB end, case when c.site is not null then c.ValueChooseFlag else a.ValueChooseFlag end, case when c.site is not null then c.MaxValue else a.MaxValue end, case when c.site is not null then c.MinValue else a.MinValue end, a.ItemRemark, a.ItemType, GetDate(), #{userId}, a.image_flag, a.produce_control_flag from eam_properties_item a left join eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no left join eam_object_item c on a.ItemType = c.ItemType and a.ItemNo = c.ItemNo and c.objectID = #{objectID} where a.ItemType = #{itemType} and b.code_no = #{propertiesCode} </insert>
<!-- 添加新项目可选值 --> <insert id="saveWorkPlanItemAvailable" parameterType="EamWorkOrderItemInData"> INSERT INTO eam_workPlan_item_available (Site, PlanID, ObjectID, ItemNo, ItemType, ValueNo, AvailableValue, CreatedDate, CreatedBy) SELECT DISTINCT #{site}, #{planID}, #{objectID}, a.ItemNo, a.ItemType, case when c.ValueNo is not null then c.ValueNo else a.ValueNo end, case when c.ValueNo is not null then c.AvailableValue else a.AvailableValue end, GetDate(), #{userId} FROM eam_properties_item_available a LEFT JOIN eam_properties_model_detail b on a.ItemType = b.function_type and a.ItemNo = b.properties_item_no LEFT JOIN eam_object_item_available c on a.ItemNo = c.ItemNo and a.ItemType = c.ItemType and c.ObjectID = #{objectID} WHERE a.ItemType = #{itemType} and b.code_no = #{propertiesCode} </insert>
<!-- 检查维修任务号是否已存在 --> <select id="getEamGzData" resultType="EamDefectFeedBackData" parameterType="EamDefectFeedBackData"> select a.Site, a.FeedBackID, a.FeedBackDesc, a.ObjectID from eam_defect_feedBack a left join eam_defect b on a.DefectID = b.DefectID <where> a.site = #{site} and a.deleteFlag = 'N' <if test="feedBackID != null and feedBackID != ''"> AND a.FeedBackID LIKE '%' + #{feedBackID}+'%' </if> </where> </select>
<!-- 保存故障信息 --> <insert id="saveEamGzBbData" parameterType="EamDefectFeedBackData"> INSERT INTO eam_defect_feedBack (Site, FeedBackID, FeedBackDesc, ObjectID, DefectID, FunctionType, PlanOperator, Status, PlanDate, Remark, deleteFlag, CreatedDate, CreatedBy, Version, DefectDate, urgency) VALUES (#{site}, #{feedBackID}, #{feedBackDesc}, #{objectID}, #{defectID}, #{functionType}, #{planOperator}, #{status}, #{planDate}, #{remark}, #{deleteFlag}, getDate(), #{createdBy}, #{version}, #{defectDate}, #{urgency}) </insert>
<!-- 查看现场动控是否开启 --> <select id="selectControlBaseData" resultType="SysSceneDynamicControlModelEntity" parameterType="string"> SELECT type, base_data, base_desc, status, remark, third_type, second_type, page_control, control_style FROM sys_scene_dynamic_control_model where site = #{site} and control_no = #{controlNo} </select>
<!-- 修改反馈状态为已下达 --> <update id="updateDefectFeedBackStatus" parameterType="EamDefectFeedBackData"> UPDATE eam_defect_feedBack SET Status = '已下达' WHERE Site = #{site} AND FeedBackID = #{feedBackID} </update>
<!-- 查询工单号 --> <select id="getOrderNo" resultType="string" parameterType="EamWorkOrderInData"> select 'X'+ Right( '0000000000'+ convert(VARCHAR(10),isnull(max(convert(INT,SUBSTRING(OrderNo,3,10))),0)+1),8) from eam_workOrder where site = #{site} and FunctionType = 'C' </select>
<!-- 创建维修工单 --> <insert id="saveWorkOrder" parameterType="EamDefectFeedBackData"> INSERT INTO eam_workOrder (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc) VALUES (#{site}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}) </insert>
<!-- 创建维修count表数据 --> <insert id="saveDefectRecordCount" parameterType="EamDefectFeedBackData"> INSERT INTO eam_workOrder_count (Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, PlanDate, FunctionType, CreateDate, CreateBy, PlanDesc) VALUES (#{site}, #{orderNo}, #{feedBackID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createdBy}, #{feedBackDesc}) </insert>
<!-- 修改工单 --> <update id="updateWorkOrder" parameterType="EamWorkOrderInData"> update eam_workOrder set update_by = #{mesUser}, update_date = GetDate(), Remark = #{remark}, WorkTime = #{workTime}, <if test='functionType == "B" and checkResult == "合格"'> disposal_measures = '', </if> <if test='functionType == "B" and checkResult == "异常"'> disposal_measures = #{disposalMeasures}, </if> checkResult = #{checkResult}, check_remark = #{checkRemark} where site = #{site} and orderNo = #{orderNo} </update>
<!-- 修改工单项目 --> <update id="updateWorkOrderItem" parameterType="EamWorkOrderItemInData"> update eam_workOrder_item set update_by = #{updateBy}, update_date = GetDate(), <if test='valueTypeDb == "T"'> TextValue = #{textValue}, </if> <if test='valueTypeDb == "N"'> NumberValue = #{numberValue}, </if> itemResult = #{itemResult} where site = #{site} and OrderNo = #{orderNo} and ItemNo = #{itemNo} </update>
<!-- 删除之前的协同人员--> <delete id="delOperator" parameterType="EamWorkOrderInData"> DELETE FROM eam_actual_operator WHERE site = #{site} and order_no = #{orderNo} and function_type = #{functionType} </delete>
<!-- 到达 --> <update id="reach" parameterType="EamWorkOrderInData"> update eam_workOrder set Status = #{status}, reach_date = GetDate(), reach_operator = #{reachOperator}, reach_operator_name = #{reachOperatorName} where site = #{site} and OrderNo = #{orderNo} and FunctionType = #{functionType} </update>
<!-- 查询是否已经上传图片 --> <select id="checkUploadAlready" resultType="SysOssEntity" parameterType="EamWorkOrderItemData"> SELECT id FROM sys_oss where order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} </select>
<!-- 查询文件路径 --> <select id="searchItemFileUrl" resultType="SysOssEntity" parameterType="EamWorkOrderItemData"> SELECT id, url, file_name FROM sys_oss WHERE order_ref1 = #{site} and order_ref2 = #{orderNo} and order_ref3 = #{itemNo} </select>
<!-- 根据工单号查询知识库记录 --> <select id="selectKnowledgeRecordByOrderNo" resultType="EamKnowledgeBaseData" parameterType="EamWorkOrderInData"> SELECT site, num FROM eam_knowledge_base WHERE site = #{site} and order_no = #{orderNo} </select>
<!-- 根据工单号修改知识库记录 --> <update id="updateKnowledgeRecordByOrderNo" parameterType="EamWorkOrderInData"> update eam_knowledge_base set update_date = getDate(), update_by = #{updateBy} where site = #{site} and order_no = #{orderNo} </update>
<!-- 新增设备知识库记录 --> <insert id="saveKnowledgeRecord" parameterType="EamWorkOrderInData"> INSERT INTO eam_knowledge_base (site, num, file_type, defect_describe, disposal_measures, create_date, create_by, object_id, defect_id, order_no) VALUES (#{site}, (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}), '维修', #{planDesc}, #{disposalMeasures}, getDate(), #{createBy}, #{objectID}, #{defectID}, #{orderNo}) </insert>
<!-- 修改反馈状态为已取消 --> <update id="updateFeedBackStatus" parameterType="EamWorkOrderInData"> UPDATE eam_defect_feedBack SET Status = '已取消' WHERE Site = #{site} AND FeedBackID = #{planID} </update>
<!-- 获取所有分类 --> <select id="getFamilyTree" resultType="EamFamilyData" parameterType="EamFamilyData"> SELECT site, FamilyID, FamilyDesc, parent_id, son_id, Active FROM eam_family WHERE site = #{site} and Active = 'Y' </select>
<!-- 获得familyId --> <select id="getFamilyId" resultType="string" parameterType="EamFamilyData"> SELECT Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(FamilyID,4))),0)+1),4) FROM eam_family WHERE site = #{site} </select>
<!-- 获得sonId --> <select id="getSonId" resultType="string" parameterType="EamFamilyData"> SELECT Right('0000' + convert(varchar(10),isnull(max(convert(INT,Right(son_id,2))),0)+1),2) FROM eam_family WHERE site = #{site} and son_id like #{parentId} + '%' </select>
<!-- 删除该分类以及其子类--> <delete id="eamFamilyDelete" parameterType="EamFamilyData"> DELETE FROM eam_family WHERE site = #{site} and FamilyID = #{familyID} and son_id like #{sonId} + '%' </delete>
<select id="getEamWorkOrder" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData"> EXEC EAM_WORK_ORDER #{site}, #{username}, #{orderNo}, #{planID}, #{objectID}, #{status}, #{startDate}, #{endDate}, #{functionType}, '*' </select>
<!-- 修改执行结果 --> <update id="updateReportResult" parameterType="EamWorkOrderInData"> update eam_workOrder set ActualDate = #{actualDate}, reach_date = #{reachDate}, WorkTime = CASE WHEN (DATEDIFF(SECOND, #{reachDate}, #{actualDate}) <![CDATA[<]]> 60) THEN DATEDIFF(SECOND, #{reachDate}, #{actualDate}) / 60.0 ELSE DATEDIFF(MINUTE, #{reachDate}, #{actualDate}) END where site = #{site} and orderNo = #{orderNo} and FunctionType = #{functionType} </update></mapper>
|