You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1787 lines
67 KiB
1787 lines
67 KiB
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
|
<mapper namespace="com.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
|
|
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
|
|
<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.active != null and query.active != ''">
|
|
AND ea.active = #{query.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 ItemNo,ValueNo,AvailableValue,CreatedDate,CreatedBy,ItemType
|
|
from eam_properties_item_available where itemNo=#{itemNo} and ItemType=#{itemType}
|
|
</select>
|
|
|
|
|
|
<select id="getItemValueNo" resultType="Double">
|
|
SELECT isnull( max(valueNo),0)+1 from eam_properties_item_available where itemNo=#{itemNo} and ItemType=#{itemType}
|
|
</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)
|
|
values(#{itemNo},#{valueNo},#{availableValue},GetDate(),#{createdBy},#{itemType})
|
|
</insert>
|
|
|
|
<update id="updateItemAvailable">
|
|
update eam_properties_item_available set AvailableValue=#{availableValue} where itemNo=#{itemNo} and ItemType=#{itemType} and ValueNo=#{valueNo}
|
|
</update>
|
|
|
|
<delete id="deleteItemAvailable">
|
|
delete from eam_properties_item_available where itemNo=#{itemNo} and ItemType=#{itemType} and ValueNo=#{valueNo}
|
|
</delete>
|
|
|
|
<select id="eamPropertiesModelSearch" parameterType="com.xujie.sys.modules.pms.data.EamPropertiesModelHeaderData" resultType="com.xujie.sys.modules.pms.data.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>
|
|
<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)
|
|
values(#{functionType}, #{codeNo}, #{codeDesc}, #{active}, GetDate(), #{userId}, 'N', 0, getDate(), #{updateBy})
|
|
</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}
|
|
</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}
|
|
</select>
|
|
|
|
<delete id="eamPropertiesModelDelete" >
|
|
delete from eam_properties_model_header where function_type=#{functionType} and code_no=#{codeNo}
|
|
</delete>
|
|
|
|
<select id="searchModalDetails" resultType="EamPropertiesModelDetailData">
|
|
SELECT 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
|
|
where a.function_type=#{functionType} and a.code_no=#{codeNo}
|
|
</select>
|
|
|
|
<select id="checkItem" resultType="EamPropertiesModelDetailData">
|
|
SELECT
|
|
ItemDesc
|
|
FROM eam_properties_item
|
|
where itemType = #{functionType}
|
|
and itemNo = #{itemNo}
|
|
</select>
|
|
|
|
<select id="checkModalDetails" resultType="EamPropertiesModelDetailData">
|
|
SELECT
|
|
a.function_type,
|
|
a.code_no,
|
|
a.properties_item_no itemNo,
|
|
a.seq_no
|
|
FROM eam_properties_model_detail a
|
|
where a.function_type = #{functionType}
|
|
and a.code_no = #{codeNo}
|
|
and properties_item_no = #{itemNo}
|
|
</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}
|
|
</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)
|
|
values (#{functionType}, #{codeNo}, #{itemNo}, #{seqNo}, GetDate(), #{userId}, 'N', 0)
|
|
</insert>
|
|
|
|
|
|
<delete id="deleteModalDetails" >
|
|
delete from eam_properties_model_detail
|
|
where function_type = #{functionType}
|
|
and code_no = #{codeNo}
|
|
and properties_item_no = #{itemNo}
|
|
</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
|
|
FROM eam_workPlan_overview a
|
|
LEFT JOIN eam_properties_model_header d
|
|
ON a.function_type = d.function_type and a.properties_code = d.code_no
|
|
<where>
|
|
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,
|
|
a.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
|
|
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
|
|
<where>
|
|
and a.Site = #{query.site}
|
|
<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 and query.status != ''">
|
|
AND a.status = #{query.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>
|
|
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,
|
|
a.CreateBy,
|
|
a.Remark,
|
|
a.StartTime,
|
|
a.EndTime,
|
|
a.WorkTime,
|
|
dbo.eam_Get_eamAdminName(a.Site,a.PlanOperator) PlanOperatorName,
|
|
b.DefectID,
|
|
c.DefectDesc,
|
|
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.disposal_measures,
|
|
a.difficulty_level,
|
|
a.difficulty_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
|
|
<where>
|
|
and a.Site = #{query.site}
|
|
<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
|
|
<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 site ,objectID from eam_object where site=#{site} and 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
|
|
Site,
|
|
#{orderNo} as orderNo,
|
|
ItemNo,
|
|
ItemDesc,
|
|
DefaultValue,
|
|
ValueType,
|
|
ValueType_DB,
|
|
ValueChooseFlag,
|
|
MaxValue,
|
|
MinValue,
|
|
ItemRemark,
|
|
ItemType
|
|
from eam_workPlan_item
|
|
where site = #{site}
|
|
and planID = #{planID}
|
|
AND 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" >
|
|
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>
|
|
|
|
<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)
|
|
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})
|
|
</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">
|
|
update eam_workOrder
|
|
set Status = '已取消'
|
|
where site = #{site}
|
|
and orderNo = #{orderNo}
|
|
</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,
|
|
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
|
|
from eam_defect_feedBack a
|
|
left join eam_defect b
|
|
on a.DefectID = b.DefectID
|
|
<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
|
|
<where>
|
|
a.ItemType = #{functionType}
|
|
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,
|
|
ea.Department,
|
|
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
|
|
<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>
|
|
|
|
<!-- 点检工单审核 -->
|
|
<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)
|
|
VALUES (#{site}, #{planID}, #{planDesc}, '已计划', #{planStartDate}, #{planEndDate}, getDate(), #{createdBy}, getDate(), #{updateBy}, #{remark}, 'N', #{operator}, #{operatorName}, #{checker}, #{checkerName}, #{functionType}, #{propertiesCode}, #{planPeriod}, #{workOrderRule}, #{planCycle})
|
|
</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
|
|
LEFT JOIN eam_family as ef
|
|
ON eo.FamilyID = ef.FamilyID
|
|
LEFT JOIN eam_location as el
|
|
ON eo.LocationID = el.LocationID
|
|
<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
|
|
LEFT JOIN eam_family as ef
|
|
ON a.FamilyID = ef.FamilyID
|
|
LEFT JOIN eam_location as el
|
|
ON a.LocationID = el.LocationID
|
|
WHERE 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
|
|
LEFT JOIN eam_family as ef
|
|
ON b.FamilyID = ef.FamilyID
|
|
LEFT JOIN eam_location as el
|
|
ON b.LocationID = el.LocationID
|
|
WHERE a.PlanID = #{planID}
|
|
</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}
|
|
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 = #{planStartDate}
|
|
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>
|
|
|
|
<!-- 查询工单号 -->
|
|
<select id="getOrderNo" resultType="string">
|
|
SELECT OrderNo
|
|
FROM eam_workOrder
|
|
WHERE site = #{site}
|
|
AND PlanID = #{planID}
|
|
AND FunctionType = #{functionType}
|
|
AND Status = '已完工'
|
|
AND PlanOperator is not null
|
|
</select>
|
|
|
|
<!-- 查询实际维修人员 -->
|
|
<select id="getActualOperatorList" resultType="string">
|
|
SELECT 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.dept_name
|
|
FROM eam_object as eo
|
|
LEFT JOIN view_eam_department as ved ON eo.site = ved.site and eo.dept_id = ved.dept_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>
|
|
|
|
<!-- 生成新的维修工单 -->
|
|
<insert id="saveDefectWorkOrder" parameterType="EamWorkOrderInData">
|
|
INSERT INTO eam_workOrder
|
|
(Site, OrderNo, PlanID, PropertiesCode, ObjectID, Status, 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'),
|
|
#{planID}, '', #{objectID}, '未开工', getDate(), 'C', getDate(), #{createBy})
|
|
</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 = '已完工',
|
|
difficulty_level = #{difficultyLevel},
|
|
difficulty_remark = #{difficultyRemark}
|
|
WHERE Site = #{site}
|
|
AND OrderNo = #{orderNo}
|
|
</update>
|
|
|
|
<!-- 查询设备的历史记录 -->
|
|
<select id="queryHistoryRecord" resultType="EamWorkOrderInData" parameterType="EamWorkOrderInData">
|
|
SELECT
|
|
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 = '已完工'
|
|
AND datediff(week, ewo.ActualDate, getdate()) = 0
|
|
</select>
|
|
|
|
<!-- 查询部门列表 -->
|
|
<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.dept_id as department,
|
|
ved.dept_name as departmentName
|
|
FROM eam_admin_dept as ead
|
|
LEFT JOIN view_eam_department as ved
|
|
ON ead.site = ved.site and ead.dept_id = ved.dept_id
|
|
WHERE ead.site = #{site}
|
|
AND ead.admin_id = #{adminID}
|
|
</select>
|
|
|
|
<!-- 查询部门列表 -->
|
|
<select id="getDeptList" resultType="string" parameterType="string">
|
|
SELECT
|
|
ved.dept_name
|
|
FROM eam_admin_dept as ead
|
|
LEFT JOIN view_eam_department as ved
|
|
ON ead.site = ved.site and ead.dept_id = ved.dept_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
|
|
ItemNo,
|
|
ItemDesc,
|
|
DefaultValue,
|
|
ValueType,
|
|
ValueType_DB as valueTypeDb,
|
|
ValueChooseFlag,
|
|
CreatedDate,
|
|
CreatedBy,
|
|
update_date,
|
|
update_by,
|
|
MaxValue,
|
|
MinValue,
|
|
ItemRemark,
|
|
ItemType
|
|
FROM eam_properties_item
|
|
<where>
|
|
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
|
|
PlanID,
|
|
ObjectID
|
|
FROM eam_workPlan
|
|
WHERE site = #{site}
|
|
AND ObjectID = #{objectID}
|
|
AND FunctionType = #{functionType}
|
|
AND Status in ('已计划','进行中')
|
|
AND deleteFlag = 'N'
|
|
AND (convert(varchar(10), PlanStartDate, 120) between #{planStartDate} and #{planEndDate}
|
|
or convert(varchar(10), PlanEndDate, 120) between #{planStartDate} and #{planEndDate}
|
|
or (DATEDIFF(day, PlanStartDate, #{planStartDate}) >= 0 and DATEDIFF(day, #{planEndDate}, PlanEndDate) >= 0)
|
|
)
|
|
</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>
|
|
</mapper>
|