|
|
<?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.jtem.modules.pda.dao.ToolDetailMapper"> <resultMap id="BaseResultMap" type="com.jtem.modules.pda.entity.ToolDetail"> <id column="ToolID" jdbcType="VARCHAR" property="toolId" /> <id column="Site" jdbcType="VARCHAR" property="site" /> <id column="ToolInstanceID" jdbcType="VARCHAR" property="toolInstanceId" /> <result column="LocationID" jdbcType="VARCHAR" property="locationId" /> <result column="Status" jdbcType="VARCHAR" property="status" /> <result column="Remark" jdbcType="VARCHAR" property="remark" /> <result column="CreateDate" jdbcType="TIMESTAMP" property="createDate" /> <result column="CreatedBy" jdbcType="VARCHAR" property="createdBy" /> <result column="SupplierID" jdbcType="VARCHAR" property="supplierId" /> <result column="PurchaseDate" jdbcType="TIMESTAMP" property="purchaseDate" /> <result column="PhaseInDate" jdbcType="TIMESTAMP" property="phaseInDate" /> <result column="PhaseOutDate" jdbcType="TIMESTAMP" property="phaseOutDate" /> <result column="InspectDuration" jdbcType="FLOAT" property="inspectDuration" /> <result column="LatestInspectDate" jdbcType="TIMESTAMP" property="latestInspectDate" /> <result column="LatestUseDate" jdbcType="TIMESTAMP" property="latestUseDate" /> <result column="EstUseQty" jdbcType="FLOAT" property="estUseQty" /> <result column="ActualUseQty" jdbcType="FLOAT" property="actualUseQty" /> <result column="WorkCenterNo" jdbcType="VARCHAR" property="workCenterNo" /> <result column="LastUpdateBy" jdbcType="VARCHAR" property="lastupdateby" /> <result column="SupplierName" jdbcType="VARCHAR" property="supplierName" /> </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> ToolID, Site, ToolInstanceID, LocationID, Status, Remark, CreateDate, CreatedBy, SupplierID, PurchaseDate, PhaseInDate, PhaseOutDate, InspectDuration, LatestInspectDate, LatestUseDate, EstUseQty, ActualUseQty, WorkCenterNo, LastUpdateBy </sql> <select id="checkToolDetailInspect" resultType="com.jtem.modules.pda.entity.ToolDetail"> Select site from ToolInspectHist Where Site=#{site} and ToolID=#{toolId} and ToolInstanceID=#{toolInstanceId} </select>
<select id="checkToolUsageHist" resultType="com.jtem.modules.pda.entity.ToolDetail"> Select site from ToolUsageHist Where Site=#{site} and ToolID=#{toolId} and ToolInstanceID=#{toolInstanceId} </select>
<delete id="deleteToolDetailNew" > delete from ToolDetail where ToolID=#{toolId} and site=#{site} and ToolInstanceID =#{toolInstanceId} </delete>
<!-- 获取工具实例信息 --> <select id="getToolDetailList" resultMap="BaseResultMap"> select A.ToolID, A.Site, A.ToolInstanceID, A.LocationID, A.Status, A.Remark, A.CreateDate, A.CreatedBy, A.SupplierID, A.PurchaseDate, A.PhaseInDate, A.PhaseOutDate, A.InspectDuration, A.LatestInspectDate, A.LatestUseDate, A.EstUseQty, A.ActualUseQty, A.WorkCenterNo, A.LastUpdateBy, A.TorNumacc, A.statusRef, A.steelSeal, CONVERT(varchar(100), A.CreateDate, 23) as strCreateDate, CONVERT(varchar(100), A.PurchaseDate, 23) as strPurchaseDate, CONVERT(varchar(100), A.PhaseOutDate, 23) as strPhaseOutDate, CONVERT(varchar(100), A.PhaseInDate, 23) as strPhaseInDate, CONVERT(varchar(100), A.LatestInspectDate, 23) as strLatestInspectDate, CONVERT(varchar(100), A.LatestUseDate, 23) as strLatestUseDate, B.SupplierName, A.lifespan from ToolDetail A left join Supplier B on A.Site = B.Site and A.SupplierID = B.SupplierID <where> <if test="site != null"> and A.Site = #{site,jdbcType=VARCHAR} </if> <if test="toolId != null and toolId != ''"> and A.ToolID = #{toolId,jdbcType=VARCHAR} </if> <if test="toolInstanceId != null and toolInstanceId != ''"> and A.ToolInstanceID = #{toolInstanceId,jdbcType=VARCHAR} </if> <if test="locationId != null and locationId != ''"> and A.LocationID = #{locationId,jdbcType=VARCHAR} </if> </where> </select>
<!-- <!– 新增工具实例 –>--><!-- <insert id="insertSelective">--><!-- INSERT INTO ToolDetail--><!-- <trim prefix="(" suffix=")" suffixOverrides=",">--><!-- <if test="statusRef != null">statusRef,</if>--><!-- <if test="toolId != null and toolId != ''">ToolID,</if>--><!-- <if test="site!=null">Site,</if>--><!-- <if test="toolInstanceId != null and toolInstanceId != ''">ToolInstanceID,</if>--><!-- <if test="locationId != null and locationId != ''">LocationID,</if>--><!-- <if test="status!=null">Status,</if>--><!-- <if test="remark!=null">Remark,</if>--><!-- <if test="createDate != null">CreateDate,</if>--><!-- <if test="createdBy != null and createdBy != ''">CreatedBy,</if>--><!-- <if test="supplierId != null and supplierId != ''">SupplierID,</if>--><!-- <if test="purchaseDate != null">PurchaseDate,</if>--><!-- <if test="phaseInDate != null">PhaseInDate,</if>--><!-- <if test="phaseOutDate != null">PhaseOutDate,</if>--><!-- <if test="inspectDuration != null">InspectDuration,</if>--><!-- <if test="latestInspectDate != null">LatestInspectDate,</if>--><!-- <if test="latestUseDate != null">LatestUseDate,</if>--><!-- <if test="estUseQty != null">EstUseQty,</if>--><!-- <if test="actualUseQty != null">ActualUseQty,</if>--><!-- <if test="workCenterNo != null and workCenterNo != ''">WorkCenterNo,</if>--><!-- <if test="lastupdateby != null and lastupdateby != ''">LastUpdateBy,</if>--><!-- <if test="price != null ">Price</if>--><!-- </trim>--><!-- VALUES--><!-- <trim prefix="(" suffix=")" suffixOverrides=",">--><!-- <if test="statusRef != null">#{statusRef,jdbcType=VARCHAR}</if>--><!-- <if test="toolId != null and toolId != ''">#{toolId,jdbcType=VARCHAR},</if>--><!-- <if test="site!=null">#{site,jdbcType=VARCHAR},</if>--><!-- <if test="toolInstanceId != null and toolInstanceId != ''">#{toolInstanceId,jdbcType=VARCHAR},</if>--><!-- <if test="locationId != null and locationId != ''">#{locationId,jdbcType=VARCHAR},</if>--><!-- <if test="status!=null">#{status,jdbcType=VARCHAR},</if>--><!-- <if test="remark!=null">#{remark,jdbcType=VARCHAR},</if>--><!-- <if test="createDate != null">#{createDate,jdbcType=TIMESTAMP},</if>--><!-- <if test="createdBy != null and createdBy != ''">#{createdBy,jdbcType=VARCHAR},</if>--><!-- <if test="supplierId != null and supplierId != ''">#{supplierId,jdbcType=VARCHAR},</if>--><!-- <if test="purchaseDate != null">#{purchaseDate,jdbcType=TIMESTAMP},</if>--><!-- <if test="phaseInDate != null">#{phaseInDate,jdbcType=TIMESTAMP},</if>--><!-- <if test="phaseOutDate != null">#{phaseOutDate,jdbcType=TIMESTAMP},</if>--><!-- <if test="inspectDuration != null">#{inspectDuration,jdbcType=DOUBLE},</if>--><!-- <if test="latestInspectDate != null">#{latestInspectDate,jdbcType=TIMESTAMP},</if>--><!-- <if test="latestUseDate != null">#{latestUseDate,jdbcType=TIMESTAMP},</if>--><!-- <if test="estUseQty != null">#{estUseQty,jdbcType=DOUBLE},</if>--><!-- <if test="actualUseQty != null">#{actualUseQty,jdbcType=DOUBLE},</if>--><!-- <if test="workCenterNo != null and workCenterNo != ''">#{workCenterNo,jdbcType=VARCHAR},</if>--><!-- <if test="lastupdateby!=null">#{lastupdateby,jdbcType=VARCHAR}</if>--><!-- <if test="price!=null">#{price}</if>--><!-- </trim>--><!-- </insert>-->
<!-- 新增工具实例 --> <insert id="insertSelective" parameterType="ToolDetail"> INSERT INTO ToolDetail (ToolID, Site, ToolInstanceID, LocationID, Status, Remark, CreateDate, CreatedBy, SupplierID, PurchaseDate, PhaseInDate, PhaseOutDate, InspectDuration, LatestInspectDate, LatestUseDate, EstUseQty, ActualUseQty, WorkCenterNo, LastUpdateBy, statusRef, Price) VALUES (#{toolId}, #{site}, #{toolInstanceId}, #{locationId}, #{status}, #{remark}, #{createDate}, #{createdBy}, #{supplierId}, #{purchaseDate}, #{phaseInDate}, #{phaseOutDate}, #{inspectDuration,jdbcType=DOUBLE}, #{latestInspectDate}, #{latestUseDate}, #{estUseQty,jdbcType=DOUBLE}, #{actualUseQty,jdbcType=DOUBLE}, #{workCenterNo}, #{lastUpdateBy}, #{statusRef}, #{price}) </insert>
<insert id="insertList"> <!--@mbg.generated--> INSERT INTO ToolDetail( ToolID, Site, ToolInstanceID, LocationID, Status, Remark, CreateDate, CreatedBy, SupplierID, PurchaseDate, PhaseInDate, PhaseOutDate, InspectDuration, LatestInspectDate, LatestUseDate, EstUseQty, ActualUseQty, WorkCenterNo, LastUpdateBy )VALUES <foreach collection="list" item="element" index="index" separator=","> ( #{element.toolId,jdbcType=VARCHAR}, #{element.site,jdbcType=VARCHAR}, #{element.toolInstanceId,jdbcType=VARCHAR}, #{element.locationId,jdbcType=VARCHAR}, #{element.status,jdbcType=VARCHAR}, #{element.remark,jdbcType=VARCHAR}, #{element.createDate,jdbcType=TIMESTAMP}, #{element.createdBy,jdbcType=VARCHAR}, #{element.supplierId,jdbcType=VARCHAR}, #{element.purchaseDate,jdbcType=TIMESTAMP}, #{element.phaseInDate,jdbcType=TIMESTAMP}, #{element.phaseOutDate,jdbcType=TIMESTAMP}, #{element.inspectDuration,jdbcType=DOUBLE}, #{element.latestInspectDate,jdbcType=TIMESTAMP}, #{element.latestUseDate,jdbcType=TIMESTAMP}, #{element.estUseQty,jdbcType=DOUBLE}, #{element.actualUseQty,jdbcType=DOUBLE}, #{element.workCenterNo,jdbcType=VARCHAR}, #{element.lastupdateby,jdbcType=VARCHAR} ) </foreach> </insert> <!-- 根据条件更新工具实例信息 --> <update id="updateToolDetailSelective"> update ToolDetail <set> <if test="statusRef != null"> statusRef = #{statusRef,jdbcType=VARCHAR}, </if> <if test="locationId != null and locationId != ''"> LocationID = #{locationId,jdbcType=VARCHAR}, </if> <if test="status != null and status != ''"> Status = #{status,jdbcType=VARCHAR}, </if> <if test="remark != null and remark != ''"> Remark = #{remark,jdbcType=VARCHAR}, </if> <if test="createDate != null"> CreateDate = #{createDate,jdbcType=TIMESTAMP}, </if> <if test="createdBy != null and createdBy != ''"> CreatedBy = #{createdBy,jdbcType=VARCHAR}, </if> <if test="supplierId != null and supplierId != ''"> SupplierID = #{supplierId,jdbcType=VARCHAR}, </if> <if test="purchaseDate != null"> PurchaseDate = #{purchaseDate,jdbcType=TIMESTAMP}, </if> <if test="phaseInDate != null"> PhaseInDate = #{phaseInDate,jdbcType=TIMESTAMP}, </if> <if test="phaseOutDate != null"> PhaseOutDate = #{phaseOutDate,jdbcType=TIMESTAMP}, </if> <if test="inspectDuration != null"> InspectDuration = #{inspectDuration,jdbcType=DOUBLE}, </if> <if test="latestInspectDate != null"> LatestInspectDate = #{latestInspectDate,jdbcType=TIMESTAMP}, </if> <if test="latestUseDate != null"> LatestUseDate = #{latestUseDate,jdbcType=TIMESTAMP}, </if> <if test="estUseQty != null"> EstUseQty = #{estUseQty,jdbcType=DOUBLE}, </if> <if test="actualUseQty != null"> ActualUseQty = #{actualUseQty,jdbcType=DOUBLE}, </if> <if test="workCenterNo != null and workCenterNo != ''"> WorkCenterNo = #{workCenterNo,jdbcType=VARCHAR}, </if> <if test="lastupdateby != null and lastupdateby != ''"> LastUpdateBy = #{lastupdateby,jdbcType=VARCHAR}, </if> <if test="steelSeal != null and steelSeal != ''"> steelSeal = #{steelSeal,jdbcType=VARCHAR}, </if> <if test="newToolInstanceId != null and newToolInstanceId != ''"> ToolInstanceID = #{newToolInstanceId}, </if> <if test="lifespan != null and lifespan != ''"> lifespan = #{lifespan} </if> </set> <where> Site=#{site,jdbcType=VARCHAR} AND ToolInstanceID=#{toolInstanceId,jdbcType=VARCHAR} <if test="toolId!= '' and toolId != null"> AND ToolID=#{toolId,jdbcType=VARCHAR} </if>
</where> </update> <update id="updateToolDetailInfo"> update ToolDetail <set> <if test="statusRef != null"> statusRef = #{statusRef,jdbcType=VARCHAR}, </if> LocationID = #{locationId,jdbcType=VARCHAR}, Status = #{status,jdbcType=VARCHAR}, Remark = #{remark,jdbcType=VARCHAR}, SupplierID = #{supplierId,jdbcType=VARCHAR}, PurchaseDate = #{purchaseDate,jdbcType=TIMESTAMP}, PhaseInDate = #{phaseInDate,jdbcType=TIMESTAMP}, PhaseOutDate = #{phaseOutDate,jdbcType=TIMESTAMP}, lifespan = #{lifespan} </set> <where> Site=#{site,jdbcType=VARCHAR} AND ToolInstanceID=#{toolInstanceId,jdbcType=VARCHAR} <if test="toolId!= '' and toolId != null"> AND ToolID=#{toolId,jdbcType=VARCHAR} </if>
</where> </update> <delete id="deleteToolDetail"> <!--@mbg.generated--> delete from ToolDetail <where> <if test="site != null"> and Site=#{site,jdbcType=VARCHAR} </if> <if test="toolInstanceId != null and toolInstanceId != ''"> and ToolInstanceID=#{toolInstanceId,jdbcType=VARCHAR} </if> </where> </delete> <select id="getIndex" resultType="integer"> <!--@mbg.generated--> select isnull(max(convert(INT,SUBSTRING(ToolInstanceID, #{toolIdLen,jdbcType=INTEGER},4))) ,0)
from ToolDetail <where> <if test="site != null and site != ''"> and Site=#{site,jdbcType=VARCHAR} </if> <if test="toolId != null and toolId != ''"> and ToolID = #{toolId,jdbcType=VARCHAR} </if> </where> </select> <select id="getToolDetailCount" resultType="integer"> select isnull(count(ToolID) ,0) from ToolDetail <where> <if test="site != null and site != ''"> and site = #{site,jdbcType=VARCHAR} </if> <if test="toolInstanceId != null and toolInstanceId != ''"> and ToolInstanceID = #{toolInstanceId,jdbcType=VARCHAR} </if> <if test="toolId != null and toolId != ''"> and ToolID = #{toolId} </if> </where> </select>
<!-- 获取工具实例信息 --> <select id="getToolDetail" resultType="com.jtem.modules.pda.entity.ToolDetail"> SELECT A.ToolID, A.Site, A.ToolInstanceID, A.Status, A.Remark, A.CreateDate, A.CreatedBy, A.SupplierID, A.PurchaseDate, A.PhaseInDate, A.PhaseOutDate, A.InspectDuration, A.LatestInspectDate, A.LatestUseDate, A.EstUseQty, A.ActualUseQty, A.WorkCenterNo, A.LastUpdateBy, A.TorNumacc, A.statusRef, isnull(A.LocationID ,'') as locationId, B.ToolDescription, B.FamilyID FROM ToolDetail A LEFT JOIN ToolHeader B on A.ToolID = B.ToolID and A.Site = B.Site <where> <if test="site != null and site != ''"> and A.Site = #{site} </if> <if test="toolInstanceId != null and toolInstanceId != ''"> and A.ToolInstanceID = #{toolInstanceId} </if> </where> </select>
<select id="printToolData" resultType="java.util.Map" parameterType="com.jtem.modules.pda.query.ToolDetailQuery"> SELECT A.ToolID as toolId, A.Site as site, A.ToolInstanceID as toolInstanceId, A.LocationID as locationId, A.Status as status, A.CreateDate as createDate, A.CreatedBy as createdBy, A.SupplierID as supplierId, A.EstUseQty as estUseQty, A.PhaseInDate as phaseInDate, B.ToolDescription as toolDescription, B.Spec as spec, C.SupplierName FROM ToolDetail A left join ToolHeader B on A.Site = B.Site and A.ToolID = B.ToolID left join Supplier C on A.Site = C.site and A.SupplierID = C.SupplierID WHERE A.ToolInstanceID = #{toolInstanceId} and A.site = #{site} </select>
<select id="getToolInfoList" resultType="com.jtem.modules.pda.query.ToolDetailQuery"> SELECT td.ToolID, ToolInstanceID, Status, EstUseQty as estUseQty, isnull(actualUseQty,0) as actualUseQty, td.CreateDate create_date, td.CreatedBy, s.SupplierName, td.SupplierID, th.ToolDescription, cast((CASE WHEN EstUseQty IS NULL OR EstUseQty = 0 THEN 999 WHEN actualUseQty IS NULL OR actualUseQty = 0 THEN 0 ELSE Round((actualUseQty/EstUseQty)*100,2) END)as varchar(10) )+'%' prop, td.LocationID as locationId, l.LocationName as locationName FROM ToolDetail td LEFT JOIN Supplier s ON td.SupplierID = s.SupplierID AND td.Site = s.Site LEFT JOIN ToolHeader th ON th.ToolID = td.ToolID AND td.Site = th.Site LEFT JOIN Location l ON l.LocationID =td.LocationID AND td.Site = l.Site <where> <if test="toolDetailQuery.supplierId != '' and toolDetailQuery.supplierId != null"> td.SupplierID = #{toolDetailQuery.supplierId} </if> <if test="toolDetailQuery.toolId != '' and toolDetailQuery.toolId != null"> AND td.ToolID like '%' + #{toolDetailQuery.toolId} + '%' </if> <if test="toolDetailQuery.toolDescription != '' and toolDetailQuery.toolDescription != null"> AND th.ToolDescription like '%' + #{toolDetailQuery.toolDescription} + '%' </if> <if test="toolDetailQuery.toolInstanceId != '' and toolDetailQuery.toolInstanceId != null"> AND ToolInstanceID like '%' + #{toolDetailQuery.toolInstanceId} + '%' </if> <if test="toolDetailQuery.startDate != null"> AND td.CreateDate <![CDATA[ >= ]]> #{toolDetailQuery.startDate} </if> <if test="toolDetailQuery.endDate != null"> AND td.CreateDate <![CDATA[ <= ]]> #{toolDetailQuery.endDate} </if> <if test="toolDetailQuery.startProp != null"> AND (CASE WHEN EstUseQty IS NULL OR EstUseQty = 0 THEN 999 WHEN actualUseQty IS NULL OR actualUseQty = 0 THEN 0 ELSE Round((actualUseQty/EstUseQty)*100,2) END) <![CDATA[ >= ]]> #{toolDetailQuery.startProp} </if> <if test=" toolDetailQuery.endProp != null"> AND (CASE WHEN EstUseQty IS NULL OR EstUseQty = 0 THEN 999 WHEN actualUseQty IS NULL OR actualUseQty = 0 THEN 0 ELSE Round((actualUseQty/EstUseQty)*100,2) END) <![CDATA[ <= ]]> #{toolDetailQuery.endProp} </if> </where> order by td.CreateDate desc </select>
<select id="getToolTransInfoList" resultType="com.jtem.modules.pda.query.ToolTransDetailQuery"> SELECT td.id, th.trans_no, th.user_id, td.tool_instance_id, th.trans_type, th.trans_date, td.trans_qty, td.direction, td.supplier_id, s.SupplierName Supplier_Name, d.ToolID tool_id, h.ToolDescription tool_description, td.remark, d.price, td.trans_price FROM tool_trans_detail td LEFT JOIN tool_trans_header th ON td.trans_no = th.trans_no LEFT JOIN Supplier s ON s.SupplierID = td.supplier_id LEFT JOIN ToolDetail d ON d.ToolInstanceID = td.tool_instance_id LEFT JOIN ToolHeader h ON d.ToolID = h.ToolID <where> <if test="query.transNo != '' and query.transNo != null"> th.trans_no like '%' + #{query.transNo} + '%' </if> <if test="query.toolId != '' and query.toolId != null"> AND d.ToolID like '%' + #{query.toolId} + '%' </if> <if test="query.toolDescription != '' and query.toolDescription != null"> AND h.ToolDescription like '%' + #{query.toolDescription} + '%' </if> <if test=" query.transTypes != null"> <foreach collection="query.transTypes" item="transType"> OR th.trans_type = #{transType} </foreach> </if> <if test="query.supplierId != '' and query.supplierId != null"> and td.supplier_id = #{query.supplierId} </if> <if test="query.toolInstanceId != '' and query.toolInstanceId != null"> AND td.tool_instance_id like '%' + #{query.toolInstanceId} + '%' </if> <if test=" query.startDate != null"> AND th.trans_date <![CDATA[ >= ]]> #{query.startDate} </if> <if test=" query.endDate != null"> AND th.trans_date <![CDATA[ <= ]]> #{query.endDate} </if> </where> ORDER BY td.id DESC </select>
<select id="getLocationCount" resultType="java.lang.Integer"> select count(1) from ToolDetail where LocationID = #{locationId} </select>
<!-- 新增寿命评估记录 --> <insert id="saveToolUseQtyAssess" parameterType="ToolUseQtyAssessData"> INSERT INTO tool_use_qty_assess (tool_id, tool_instance_id, tool_desc_ription, est_use_qty, actual_use_qty, add_use_qty, prop, create_by, create_date, status) VALUES (#{toolId}, #{toolInstanceId}, #{toolDescription}, #{estUseQty,jdbcType=DOUBLE}, #{actualUseQty,jdbcType=DOUBLE}, #{addUseQty,jdbcType=DOUBLE}, #{prop}, #{createBy}, getDate(), #{status}) </insert>
<!-- 查询寿命评估记录 --> <select id="getToolUseQtyAssessList" resultType="ToolUseQtyAssessData" parameterType="ToolUseQtyAssessData"> select id, tool_id, tool_instance_id, est_use_qty, actual_use_qty, add_use_qty, prop, create_by, create_date, status, actual_add_use_qty, checker, check_date, tool_desc_ription from tool_use_qty_assess <where> <if test="query.toolId != '' and query.toolId != null"> AND tool_id like '%' + #{query.toolId} + '%' </if> <if test="query.toolInstanceId != '' and query.toolInstanceId != null"> AND tool_instance_id like '%' + #{query.toolInstanceId} + '%' </if> <if test="query.startDate != null"> AND create_date <![CDATA[ >= ]]> #{query.startDate} </if> <if test="query.endDate != null"> AND create_date <![CDATA[ <= ]]> #{query.endDate} </if> </where> ORDER BY CASE WHEN status = '待审核' THEN 1 WHEN status = '已完成' THEN 2 END,create_date </select>
<!-- 审核 --> <update id="checkToolUseQtyAssess" parameterType="ToolUseQtyAssessData"> update tool_use_qty_assess set actual_add_use_qty = #{addUseQty}, status = #{status}, checker = #{createBy}, check_date = getDate() where id = #{id} </update>
<!-- 更新工具实例寿命 --> <update id="updateToolDetailUseQty" parameterType="ToolUseQtyAssessData"> update ToolDetail set EstUseQty = #{estUseQty} where ToolID = #{toolId} and Site = #{site} and ToolInstanceID = #{toolInstanceId} </update>
<select id="getItemModal" resultType="com.jtem.modules.toolMan.entity.PartSubPropertiesValueData"> SELECT a.PartNo,a.Site,a.CodeNo,a.SubCodeSeqNo,a.SubCodeDesc,a.ItemNo,a.PropertiesItemNo,a.TextValue,a.NumValue,a.RecordType ,b.ItemDesc ItemDesc,b.ValueType,b.ValueType_DB,b.ValueChooseFlag
FROM PartSubPropertiesValue a left join PropertiesItem b on a.PropertiesItemNo=b.ItemNo <where>
AND a.site =#{site}
AND a.PartNo =#{toolID}
</where>
</select>
<select id="checkItemNo" resultType="ToolSubPropertiesValueData"> select ValueType_DB from PropertiesItem where itemNo=#{propertiesItemNo} </select>
<select id="checkToolItemNo" resultType="ToolSubPropertiesValueData"> select itemNo from ToolSubPropertiesValue where ToolItemNo=#{propertiesItemNo} and site=#{site} and ToolID=#{toolID} </select>
<insert id="itemSaveData"> insert into ToolSubPropertiesValue(ToolID,Site,CodeNo,SubCodeSeqNo,SubCodeDesc, ItemNo,PropertiesItemNo,TextValue,NumValue,RecordType,ToolItemNo) values (#{toolID},#{site},'*',1.0,'*',#{itemNo},#{propertiesItemNo},#{textValue},#{numValue,jdbcType=DOUBLE},'T',#{propertiesItemNo}) </insert>
<select id="getToolItemNo" resultType="Double"> select isnull(max(ItemNo),0.0) +1 from ToolSubPropertiesValue where site=#{site} and ToolID=#{toolID} </select>
<update id="updateToolItem" > update PartSubPropertiesValue set TextValue=#{textValue} , NumValue=#{numValue,jdbcType=DOUBLE} where PropertiesItemNo=#{propertiesItemNo} and site=#{site} and PartNo=#{partNo} and RecordType='T' </update>
<delete id="deleteItemModal"> delete from ToolSubPropertiesValue where ToolItemNo=#{propertiesItemNo} and site=#{site} and ToolID=#{toolID} </delete>
<!-- 根据实例编码获取寿命评估记录 --> <select id="checkAssessRecord" resultType="ToolUseQtyAssessData" parameterType="ToolUseQtyAssessData"> select id, tool_id, tool_instance_id, est_use_qty from tool_use_qty_assess where tool_id = #{toolId} and tool_instance_id = #{toolInstanceId} and status = '待审核' </select>
<insert id="refreshItemModal"> insert into PartSubPropertiesValue(PartNo,Site,CodeNo,SubCodeSeqNo,SubCodeDesc, ItemNo,PropertiesItemNo,TextValue,NumValue,RecordType) select #{toolId},#{site},a.CodeNo,1,a.SubCodeDesc,b.ItemNo,b.PropertiesItemNo,case when e.ValueType_DB='T' then e.DefaultValue else null end ,case when e.ValueType_DB='N' and e.DefaultValue!='' then e.DefaultValue else null end ,'T' from PartSubPropertiesValueHeader a left join PropertiesModelDetail b on a.CodeNo=b.CodeNo left join PartSubPropertiesValue c on c.Site=#{site} and c.PartNo=#{toolId} and c.RecordType='T' and b.ItemNo=c.ItemNo left join PropertiesItem e on b.PropertiesItemNo=e.ItemNo where c.ItemNo is null and a.RecordType='T' </insert></mapper>
|