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.

649 lines
29 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
3 years ago
2 years ago
2 years ago
3 years ago
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.jtem.modules.pda.dao.ToolDetailMapper">
  4. <resultMap id="BaseResultMap" type="com.jtem.modules.pda.entity.ToolDetail">
  5. <id column="ToolID" jdbcType="VARCHAR" property="toolId" />
  6. <id column="Site" jdbcType="VARCHAR" property="site" />
  7. <id column="ToolInstanceID" jdbcType="VARCHAR" property="toolInstanceId" />
  8. <result column="LocationID" jdbcType="VARCHAR" property="locationId" />
  9. <result column="Status" jdbcType="VARCHAR" property="status" />
  10. <result column="Remark" jdbcType="VARCHAR" property="remark" />
  11. <result column="CreateDate" jdbcType="TIMESTAMP" property="createDate" />
  12. <result column="CreatedBy" jdbcType="VARCHAR" property="createdBy" />
  13. <result column="SupplierID" jdbcType="VARCHAR" property="supplierId" />
  14. <result column="PurchaseDate" jdbcType="TIMESTAMP" property="purchaseDate" />
  15. <result column="PhaseInDate" jdbcType="TIMESTAMP" property="phaseInDate" />
  16. <result column="PhaseOutDate" jdbcType="TIMESTAMP" property="phaseOutDate" />
  17. <result column="InspectDuration" jdbcType="FLOAT" property="inspectDuration" />
  18. <result column="LatestInspectDate" jdbcType="TIMESTAMP" property="latestInspectDate" />
  19. <result column="LatestUseDate" jdbcType="TIMESTAMP" property="latestUseDate" />
  20. <result column="EstUseQty" jdbcType="FLOAT" property="estUseQty" />
  21. <result column="ActualUseQty" jdbcType="FLOAT" property="actualUseQty" />
  22. <result column="WorkCenterNo" jdbcType="VARCHAR" property="workCenterNo" />
  23. <result column="LastUpdateBy" jdbcType="VARCHAR" property="lastupdateby" />
  24. <result column="SupplierName" jdbcType="VARCHAR" property="supplierName" />
  25. </resultMap>
  26. <sql id="Base_Column_List">
  27. <!--@mbg.generated-->
  28. ToolID, Site, ToolInstanceID, LocationID, Status, Remark, CreateDate, CreatedBy,
  29. SupplierID, PurchaseDate, PhaseInDate, PhaseOutDate, InspectDuration, LatestInspectDate,
  30. LatestUseDate, EstUseQty, ActualUseQty, WorkCenterNo, LastUpdateBy
  31. </sql>
  32. <select id="checkToolDetailInspect" resultType="com.jtem.modules.pda.entity.ToolDetail">
  33. Select site from ToolInspectHist Where Site=#{site} and ToolID=#{toolId} and ToolInstanceID=#{toolInstanceId}
  34. </select>
  35. <select id="checkToolUsageHist" resultType="com.jtem.modules.pda.entity.ToolDetail">
  36. Select site from ToolUsageHist Where Site=#{site} and ToolID=#{toolId} and ToolInstanceID=#{toolInstanceId}
  37. </select>
  38. <delete id="deleteToolDetailNew" >
  39. delete from ToolDetail where ToolID=#{toolId} and site=#{site} and ToolInstanceID =#{toolInstanceId}
  40. </delete>
  41. <!-- 获取工具实例信息 -->
  42. <select id="getToolDetailList" resultMap="BaseResultMap">
  43. select
  44. A.ToolID,
  45. A.Site,
  46. A.ToolInstanceID,
  47. A.LocationID,
  48. A.Status,
  49. A.Remark,
  50. A.CreateDate,
  51. A.CreatedBy,
  52. A.SupplierID,
  53. A.PurchaseDate,
  54. A.PhaseInDate,
  55. A.PhaseOutDate,
  56. A.InspectDuration,
  57. A.LatestInspectDate,
  58. A.LatestUseDate,
  59. A.EstUseQty,
  60. A.ActualUseQty,
  61. A.WorkCenterNo,
  62. A.LastUpdateBy,
  63. A.TorNumacc,
  64. A.statusRef,
  65. A.steelSeal,
  66. CONVERT(varchar(100), A.CreateDate, 23) as strCreateDate,
  67. CONVERT(varchar(100), A.PurchaseDate, 23) as strPurchaseDate,
  68. CONVERT(varchar(100), A.PhaseOutDate, 23) as strPhaseOutDate,
  69. CONVERT(varchar(100), A.PhaseInDate, 23) as strPhaseInDate,
  70. CONVERT(varchar(100), A.LatestInspectDate, 23) as strLatestInspectDate,
  71. CONVERT(varchar(100), A.LatestUseDate, 23) as strLatestUseDate,
  72. B.SupplierName,
  73. A.lifespan
  74. from ToolDetail A
  75. left join Supplier B on A.Site = B.Site and A.SupplierID = B.SupplierID
  76. <where>
  77. <if test="site != null">
  78. and A.Site = #{site,jdbcType=VARCHAR}
  79. </if>
  80. <if test="toolId != null and toolId != ''">
  81. and A.ToolID = #{toolId,jdbcType=VARCHAR}
  82. </if>
  83. <if test="toolInstanceId != null and toolInstanceId != ''">
  84. and A.ToolInstanceID = #{toolInstanceId,jdbcType=VARCHAR}
  85. </if>
  86. <if test="locationId != null and locationId != ''">
  87. and A.LocationID = #{locationId,jdbcType=VARCHAR}
  88. </if>
  89. </where>
  90. </select>
  91. <!-- &lt;!&ndash; 新增工具实例 &ndash;&gt;-->
  92. <!-- <insert id="insertSelective">-->
  93. <!-- INSERT INTO ToolDetail-->
  94. <!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
  95. <!-- <if test="statusRef != null">statusRef,</if>-->
  96. <!-- <if test="toolId != null and toolId != ''">ToolID,</if>-->
  97. <!-- <if test="site!=null">Site,</if>-->
  98. <!-- <if test="toolInstanceId != null and toolInstanceId != ''">ToolInstanceID,</if>-->
  99. <!-- <if test="locationId != null and locationId != ''">LocationID,</if>-->
  100. <!-- <if test="status!=null">Status,</if>-->
  101. <!-- <if test="remark!=null">Remark,</if>-->
  102. <!-- <if test="createDate != null">CreateDate,</if>-->
  103. <!-- <if test="createdBy != null and createdBy != ''">CreatedBy,</if>-->
  104. <!-- <if test="supplierId != null and supplierId != ''">SupplierID,</if>-->
  105. <!-- <if test="purchaseDate != null">PurchaseDate,</if>-->
  106. <!-- <if test="phaseInDate != null">PhaseInDate,</if>-->
  107. <!-- <if test="phaseOutDate != null">PhaseOutDate,</if>-->
  108. <!-- <if test="inspectDuration != null">InspectDuration,</if>-->
  109. <!-- <if test="latestInspectDate != null">LatestInspectDate,</if>-->
  110. <!-- <if test="latestUseDate != null">LatestUseDate,</if>-->
  111. <!-- <if test="estUseQty != null">EstUseQty,</if>-->
  112. <!-- <if test="actualUseQty != null">ActualUseQty,</if>-->
  113. <!-- <if test="workCenterNo != null and workCenterNo != ''">WorkCenterNo,</if>-->
  114. <!-- <if test="lastupdateby != null and lastupdateby != ''">LastUpdateBy,</if>-->
  115. <!-- <if test="price != null ">Price</if>-->
  116. <!-- </trim>-->
  117. <!-- VALUES-->
  118. <!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
  119. <!-- <if test="statusRef != null">#{statusRef,jdbcType=VARCHAR}</if>-->
  120. <!-- <if test="toolId != null and toolId != ''">#{toolId,jdbcType=VARCHAR},</if>-->
  121. <!-- <if test="site!=null">#{site,jdbcType=VARCHAR},</if>-->
  122. <!-- <if test="toolInstanceId != null and toolInstanceId != ''">#{toolInstanceId,jdbcType=VARCHAR},</if>-->
  123. <!-- <if test="locationId != null and locationId != ''">#{locationId,jdbcType=VARCHAR},</if>-->
  124. <!-- <if test="status!=null">#{status,jdbcType=VARCHAR},</if>-->
  125. <!-- <if test="remark!=null">#{remark,jdbcType=VARCHAR},</if>-->
  126. <!-- <if test="createDate != null">#{createDate,jdbcType=TIMESTAMP},</if>-->
  127. <!-- <if test="createdBy != null and createdBy != ''">#{createdBy,jdbcType=VARCHAR},</if>-->
  128. <!-- <if test="supplierId != null and supplierId != ''">#{supplierId,jdbcType=VARCHAR},</if>-->
  129. <!-- <if test="purchaseDate != null">#{purchaseDate,jdbcType=TIMESTAMP},</if>-->
  130. <!-- <if test="phaseInDate != null">#{phaseInDate,jdbcType=TIMESTAMP},</if>-->
  131. <!-- <if test="phaseOutDate != null">#{phaseOutDate,jdbcType=TIMESTAMP},</if>-->
  132. <!-- <if test="inspectDuration != null">#{inspectDuration,jdbcType=DOUBLE},</if>-->
  133. <!-- <if test="latestInspectDate != null">#{latestInspectDate,jdbcType=TIMESTAMP},</if>-->
  134. <!-- <if test="latestUseDate != null">#{latestUseDate,jdbcType=TIMESTAMP},</if>-->
  135. <!-- <if test="estUseQty != null">#{estUseQty,jdbcType=DOUBLE},</if>-->
  136. <!-- <if test="actualUseQty != null">#{actualUseQty,jdbcType=DOUBLE},</if>-->
  137. <!-- <if test="workCenterNo != null and workCenterNo != ''">#{workCenterNo,jdbcType=VARCHAR},</if>-->
  138. <!-- <if test="lastupdateby!=null">#{lastupdateby,jdbcType=VARCHAR}</if>-->
  139. <!-- <if test="price!=null">#{price}</if>-->
  140. <!-- </trim>-->
  141. <!-- </insert>-->
  142. <!-- 新增工具实例 -->
  143. <insert id="insertSelective" parameterType="ToolDetail">
  144. INSERT INTO ToolDetail
  145. (ToolID, Site, ToolInstanceID, LocationID, Status, Remark, CreateDate, CreatedBy, SupplierID, PurchaseDate, PhaseInDate,
  146. PhaseOutDate, InspectDuration, LatestInspectDate, LatestUseDate, EstUseQty, ActualUseQty, WorkCenterNo, LastUpdateBy, statusRef, Price)
  147. VALUES
  148. (#{toolId}, #{site}, #{toolInstanceId}, #{locationId}, #{status}, #{remark}, #{createDate}, #{createdBy}, #{supplierId}, #{purchaseDate}, #{phaseInDate},
  149. #{phaseOutDate}, #{inspectDuration,jdbcType=DOUBLE}, #{latestInspectDate}, #{latestUseDate}, #{estUseQty,jdbcType=DOUBLE}, #{actualUseQty,jdbcType=DOUBLE}, #{workCenterNo}, #{lastUpdateBy}, #{statusRef}, #{price})
  150. </insert>
  151. <insert id="insertList">
  152. <!--@mbg.generated-->
  153. INSERT INTO ToolDetail(
  154. ToolID,
  155. Site,
  156. ToolInstanceID,
  157. LocationID,
  158. Status,
  159. Remark,
  160. CreateDate,
  161. CreatedBy,
  162. SupplierID,
  163. PurchaseDate,
  164. PhaseInDate,
  165. PhaseOutDate,
  166. InspectDuration,
  167. LatestInspectDate,
  168. LatestUseDate,
  169. EstUseQty,
  170. ActualUseQty,
  171. WorkCenterNo,
  172. LastUpdateBy
  173. )VALUES
  174. <foreach collection="list" item="element" index="index" separator=",">
  175. (
  176. #{element.toolId,jdbcType=VARCHAR},
  177. #{element.site,jdbcType=VARCHAR},
  178. #{element.toolInstanceId,jdbcType=VARCHAR},
  179. #{element.locationId,jdbcType=VARCHAR},
  180. #{element.status,jdbcType=VARCHAR},
  181. #{element.remark,jdbcType=VARCHAR},
  182. #{element.createDate,jdbcType=TIMESTAMP},
  183. #{element.createdBy,jdbcType=VARCHAR},
  184. #{element.supplierId,jdbcType=VARCHAR},
  185. #{element.purchaseDate,jdbcType=TIMESTAMP},
  186. #{element.phaseInDate,jdbcType=TIMESTAMP},
  187. #{element.phaseOutDate,jdbcType=TIMESTAMP},
  188. #{element.inspectDuration,jdbcType=DOUBLE},
  189. #{element.latestInspectDate,jdbcType=TIMESTAMP},
  190. #{element.latestUseDate,jdbcType=TIMESTAMP},
  191. #{element.estUseQty,jdbcType=DOUBLE},
  192. #{element.actualUseQty,jdbcType=DOUBLE},
  193. #{element.workCenterNo,jdbcType=VARCHAR},
  194. #{element.lastupdateby,jdbcType=VARCHAR}
  195. )
  196. </foreach>
  197. </insert>
  198. <!-- 根据条件更新工具实例信息 -->
  199. <update id="updateToolDetailSelective">
  200. update ToolDetail
  201. <set>
  202. <if test="statusRef != null">
  203. statusRef = #{statusRef,jdbcType=VARCHAR},
  204. </if>
  205. <if test="locationId != null and locationId != ''">
  206. LocationID = #{locationId,jdbcType=VARCHAR},
  207. </if>
  208. <if test="status != null and status != ''">
  209. Status = #{status,jdbcType=VARCHAR},
  210. </if>
  211. <if test="remark != null and remark != ''">
  212. Remark = #{remark,jdbcType=VARCHAR},
  213. </if>
  214. <if test="createDate != null">
  215. CreateDate = #{createDate,jdbcType=TIMESTAMP},
  216. </if>
  217. <if test="createdBy != null and createdBy != ''">
  218. CreatedBy = #{createdBy,jdbcType=VARCHAR},
  219. </if>
  220. <if test="supplierId != null and supplierId != ''">
  221. SupplierID = #{supplierId,jdbcType=VARCHAR},
  222. </if>
  223. <if test="purchaseDate != null">
  224. PurchaseDate = #{purchaseDate,jdbcType=TIMESTAMP},
  225. </if>
  226. <if test="phaseInDate != null">
  227. PhaseInDate = #{phaseInDate,jdbcType=TIMESTAMP},
  228. </if>
  229. <if test="phaseOutDate != null">
  230. PhaseOutDate = #{phaseOutDate,jdbcType=TIMESTAMP},
  231. </if>
  232. <if test="inspectDuration != null">
  233. InspectDuration = #{inspectDuration,jdbcType=DOUBLE},
  234. </if>
  235. <if test="latestInspectDate != null">
  236. LatestInspectDate = #{latestInspectDate,jdbcType=TIMESTAMP},
  237. </if>
  238. <if test="latestUseDate != null">
  239. LatestUseDate = #{latestUseDate,jdbcType=TIMESTAMP},
  240. </if>
  241. <if test="estUseQty != null">
  242. EstUseQty = #{estUseQty,jdbcType=DOUBLE},
  243. </if>
  244. <if test="actualUseQty != null">
  245. ActualUseQty = #{actualUseQty,jdbcType=DOUBLE},
  246. </if>
  247. <if test="workCenterNo != null and workCenterNo != ''">
  248. WorkCenterNo = #{workCenterNo,jdbcType=VARCHAR},
  249. </if>
  250. <if test="lastupdateby != null and lastupdateby != ''">
  251. LastUpdateBy = #{lastupdateby,jdbcType=VARCHAR},
  252. </if>
  253. <if test="steelSeal != null and steelSeal != ''">
  254. steelSeal = #{steelSeal,jdbcType=VARCHAR},
  255. </if>
  256. <if test="newToolInstanceId != null and newToolInstanceId != ''">
  257. ToolInstanceID = #{newToolInstanceId},
  258. </if>
  259. <if test="lifespan != null and lifespan != ''">
  260. lifespan = #{lifespan}
  261. </if>
  262. </set>
  263. <where>
  264. Site=#{site,jdbcType=VARCHAR} AND ToolInstanceID=#{toolInstanceId,jdbcType=VARCHAR}
  265. <if test="toolId!= '' and toolId != null">
  266. AND ToolID=#{toolId,jdbcType=VARCHAR}
  267. </if>
  268. </where>
  269. </update>
  270. <update id="updateToolDetailInfo">
  271. update ToolDetail
  272. <set>
  273. <if test="statusRef != null">
  274. statusRef = #{statusRef,jdbcType=VARCHAR},
  275. </if>
  276. LocationID = #{locationId,jdbcType=VARCHAR},
  277. Status = #{status,jdbcType=VARCHAR},
  278. Remark = #{remark,jdbcType=VARCHAR},
  279. SupplierID = #{supplierId,jdbcType=VARCHAR},
  280. PurchaseDate = #{purchaseDate,jdbcType=TIMESTAMP},
  281. PhaseInDate = #{phaseInDate,jdbcType=TIMESTAMP},
  282. PhaseOutDate = #{phaseOutDate,jdbcType=TIMESTAMP},
  283. lifespan = #{lifespan}
  284. </set>
  285. <where>
  286. Site=#{site,jdbcType=VARCHAR} AND ToolInstanceID=#{toolInstanceId,jdbcType=VARCHAR}
  287. <if test="toolId!= '' and toolId != null">
  288. AND ToolID=#{toolId,jdbcType=VARCHAR}
  289. </if>
  290. </where>
  291. </update>
  292. <delete id="deleteToolDetail">
  293. <!--@mbg.generated-->
  294. delete from ToolDetail
  295. <where>
  296. <if test="site != null">
  297. and Site=#{site,jdbcType=VARCHAR}
  298. </if>
  299. <if test="toolInstanceId != null and toolInstanceId != ''">
  300. and ToolInstanceID=#{toolInstanceId,jdbcType=VARCHAR}
  301. </if>
  302. </where>
  303. </delete>
  304. <select id="getIndex" resultType="integer">
  305. <!--@mbg.generated-->
  306. select isnull(max(convert(INT,SUBSTRING(ToolInstanceID, #{toolIdLen,jdbcType=INTEGER},4))) ,0)
  307. from ToolDetail
  308. <where>
  309. <if test="site != null and site != ''">
  310. and Site=#{site,jdbcType=VARCHAR}
  311. </if>
  312. <if test="toolId != null and toolId != ''">
  313. and ToolID = #{toolId,jdbcType=VARCHAR}
  314. </if>
  315. </where>
  316. </select>
  317. <select id="getToolDetailCount" resultType="integer">
  318. select isnull(count(ToolID) ,0) from ToolDetail
  319. <where>
  320. <if test="site != null and site != ''">
  321. and site = #{site,jdbcType=VARCHAR}
  322. </if>
  323. <if test="toolInstanceId != null and toolInstanceId != ''">
  324. and ToolInstanceID = #{toolInstanceId,jdbcType=VARCHAR}
  325. </if>
  326. <if test="toolId != null and toolId != ''">
  327. and ToolID = #{toolId}
  328. </if>
  329. </where>
  330. </select>
  331. <!-- 获取工具实例信息 -->
  332. <select id="getToolDetail" resultType="com.jtem.modules.pda.entity.ToolDetail">
  333. SELECT
  334. A.ToolID,
  335. A.Site,
  336. A.ToolInstanceID,
  337. A.Status,
  338. A.Remark,
  339. A.CreateDate,
  340. A.CreatedBy,
  341. A.SupplierID,
  342. A.PurchaseDate,
  343. A.PhaseInDate,
  344. A.PhaseOutDate,
  345. A.InspectDuration,
  346. A.LatestInspectDate,
  347. A.LatestUseDate,
  348. A.EstUseQty,
  349. A.ActualUseQty,
  350. A.WorkCenterNo,
  351. A.LastUpdateBy,
  352. A.TorNumacc,
  353. A.statusRef,
  354. isnull(A.LocationID ,'') as locationId,
  355. B.ToolDescription,
  356. B.FamilyID
  357. FROM ToolDetail A
  358. LEFT JOIN ToolHeader B on A.ToolID = B.ToolID and A.Site = B.Site
  359. <where>
  360. <if test="site != null and site != ''">
  361. and A.Site = #{site}
  362. </if>
  363. <if test="toolInstanceId != null and toolInstanceId != ''">
  364. and A.ToolInstanceID = #{toolInstanceId}
  365. </if>
  366. </where>
  367. </select>
  368. <select id="printToolData" resultType="java.util.Map" parameterType="com.jtem.modules.pda.query.ToolDetailQuery">
  369. SELECT
  370. A.ToolID as toolId,
  371. A.Site as site,
  372. A.ToolInstanceID as toolInstanceId,
  373. A.LocationID as locationId,
  374. A.Status as status,
  375. A.CreateDate as createDate,
  376. A.CreatedBy as createdBy,
  377. A.SupplierID as supplierId,
  378. A.EstUseQty as estUseQty,
  379. A.PhaseInDate as phaseInDate,
  380. B.ToolDescription as toolDescription,
  381. B.Spec as spec,
  382. C.SupplierName
  383. FROM ToolDetail A
  384. left join ToolHeader B on A.Site = B.Site and A.ToolID = B.ToolID
  385. left join Supplier C on A.Site = C.site and A.SupplierID = C.SupplierID
  386. WHERE A.ToolInstanceID = #{toolInstanceId} and A.site = #{site}
  387. </select>
  388. <select id="getToolInfoList" resultType="com.jtem.modules.pda.query.ToolDetailQuery">
  389. SELECT
  390. td.ToolID,
  391. ToolInstanceID,
  392. Status,
  393. EstUseQty as estUseQty,
  394. isnull(actualUseQty,0) as actualUseQty,
  395. td.CreateDate create_date,
  396. td.CreatedBy,
  397. s.SupplierName,
  398. td.SupplierID,
  399. th.ToolDescription,
  400. cast((CASE
  401. WHEN EstUseQty IS NULL OR EstUseQty = 0 THEN 999
  402. WHEN actualUseQty IS NULL OR actualUseQty = 0 THEN 0
  403. ELSE Round((actualUseQty/EstUseQty)*100,2)
  404. END)as varchar(10)
  405. )+'%' prop,
  406. td.LocationID as locationId,
  407. l.LocationName as locationName
  408. FROM ToolDetail td
  409. LEFT JOIN Supplier s ON td.SupplierID = s.SupplierID AND td.Site = s.Site
  410. LEFT JOIN ToolHeader th ON th.ToolID = td.ToolID AND td.Site = th.Site
  411. LEFT JOIN Location l ON l.LocationID =td.LocationID AND td.Site = l.Site
  412. <where>
  413. <if test="toolDetailQuery.supplierId != '' and toolDetailQuery.supplierId != null">
  414. td.SupplierID = #{toolDetailQuery.supplierId}
  415. </if>
  416. <if test="toolDetailQuery.toolId != '' and toolDetailQuery.toolId != null">
  417. AND td.ToolID like '%' + #{toolDetailQuery.toolId} + '%'
  418. </if>
  419. <if test="toolDetailQuery.toolDescription != '' and toolDetailQuery.toolDescription != null">
  420. AND th.ToolDescription like '%' + #{toolDetailQuery.toolDescription} + '%'
  421. </if>
  422. <if test="toolDetailQuery.toolInstanceId != '' and toolDetailQuery.toolInstanceId != null">
  423. AND ToolInstanceID like '%' + #{toolDetailQuery.toolInstanceId} + '%'
  424. </if>
  425. <if test="toolDetailQuery.startDate != null">
  426. AND td.CreateDate <![CDATA[ >= ]]> #{toolDetailQuery.startDate}
  427. </if>
  428. <if test="toolDetailQuery.endDate != null">
  429. AND td.CreateDate <![CDATA[ <= ]]> #{toolDetailQuery.endDate}
  430. </if>
  431. <if test="toolDetailQuery.startProp != null">
  432. AND (CASE
  433. WHEN EstUseQty IS NULL OR EstUseQty = 0 THEN 999
  434. WHEN actualUseQty IS NULL OR actualUseQty = 0 THEN 0
  435. ELSE Round((actualUseQty/EstUseQty)*100,2)
  436. END) <![CDATA[ >= ]]> #{toolDetailQuery.startProp}
  437. </if>
  438. <if test=" toolDetailQuery.endProp != null">
  439. AND (CASE
  440. WHEN EstUseQty IS NULL OR EstUseQty = 0 THEN 999
  441. WHEN actualUseQty IS NULL OR actualUseQty = 0 THEN 0
  442. ELSE Round((actualUseQty/EstUseQty)*100,2)
  443. END) <![CDATA[ <= ]]> #{toolDetailQuery.endProp}
  444. </if>
  445. </where>
  446. order by td.CreateDate desc
  447. </select>
  448. <select id="getToolTransInfoList" resultType="com.jtem.modules.pda.query.ToolTransDetailQuery">
  449. SELECT
  450. td.id,
  451. th.trans_no,
  452. th.user_id,
  453. td.tool_instance_id,
  454. th.trans_type,
  455. th.trans_date,
  456. td.trans_qty,
  457. td.direction,
  458. td.supplier_id,
  459. s.SupplierName Supplier_Name,
  460. d.ToolID tool_id,
  461. h.ToolDescription tool_description,
  462. td.remark,
  463. d.price,
  464. td.trans_price
  465. FROM
  466. tool_trans_detail td
  467. LEFT JOIN tool_trans_header th ON td.trans_no = th.trans_no
  468. LEFT JOIN Supplier s ON s.SupplierID = td.supplier_id
  469. LEFT JOIN ToolDetail d ON d.ToolInstanceID = td.tool_instance_id
  470. LEFT JOIN ToolHeader h ON d.ToolID = h.ToolID
  471. <where>
  472. <if test="query.transNo != '' and query.transNo != null">
  473. th.trans_no like '%' + #{query.transNo} + '%'
  474. </if>
  475. <if test="query.toolId != '' and query.toolId != null">
  476. AND d.ToolID like '%' + #{query.toolId} + '%'
  477. </if>
  478. <if test="query.toolDescription != '' and query.toolDescription != null">
  479. AND h.ToolDescription like '%' + #{query.toolDescription} + '%'
  480. </if>
  481. <if test=" query.transTypes != null">
  482. <foreach collection="query.transTypes" item="transType">
  483. OR th.trans_type = #{transType}
  484. </foreach>
  485. </if>
  486. <if test="query.supplierId != '' and query.supplierId != null">
  487. and td.supplier_id = #{query.supplierId}
  488. </if>
  489. <if test="query.toolInstanceId != '' and query.toolInstanceId != null">
  490. AND td.tool_instance_id like '%' + #{query.toolInstanceId} + '%'
  491. </if>
  492. <if test=" query.startDate != null">
  493. AND th.trans_date <![CDATA[ >= ]]> #{query.startDate}
  494. </if>
  495. <if test=" query.endDate != null">
  496. AND th.trans_date <![CDATA[ <= ]]> #{query.endDate}
  497. </if>
  498. </where>
  499. ORDER BY td.id DESC
  500. </select>
  501. <select id="getLocationCount" resultType="java.lang.Integer">
  502. select count(1)
  503. from ToolDetail
  504. where LocationID = #{locationId}
  505. </select>
  506. <!-- 新增寿命评估记录 -->
  507. <insert id="saveToolUseQtyAssess" parameterType="ToolUseQtyAssessData">
  508. INSERT INTO tool_use_qty_assess
  509. (tool_id, tool_instance_id, tool_desc_ription, est_use_qty, actual_use_qty, add_use_qty, prop, create_by, create_date, status)
  510. VALUES
  511. (#{toolId}, #{toolInstanceId}, #{toolDescription}, #{estUseQty,jdbcType=DOUBLE}, #{actualUseQty,jdbcType=DOUBLE}, #{addUseQty,jdbcType=DOUBLE}, #{prop}, #{createBy}, getDate(), #{status})
  512. </insert>
  513. <!-- 查询寿命评估记录 -->
  514. <select id="getToolUseQtyAssessList" resultType="ToolUseQtyAssessData" parameterType="ToolUseQtyAssessData">
  515. select
  516. id,
  517. tool_id,
  518. tool_instance_id,
  519. est_use_qty,
  520. actual_use_qty,
  521. add_use_qty,
  522. prop,
  523. create_by,
  524. create_date,
  525. status,
  526. actual_add_use_qty,
  527. checker,
  528. check_date,
  529. tool_desc_ription
  530. from tool_use_qty_assess
  531. <where>
  532. <if test="query.toolId != '' and query.toolId != null">
  533. AND tool_id like '%' + #{query.toolId} + '%'
  534. </if>
  535. <if test="query.toolInstanceId != '' and query.toolInstanceId != null">
  536. AND tool_instance_id like '%' + #{query.toolInstanceId} + '%'
  537. </if>
  538. <if test="query.startDate != null">
  539. AND create_date <![CDATA[ >= ]]> #{query.startDate}
  540. </if>
  541. <if test="query.endDate != null">
  542. AND create_date <![CDATA[ <= ]]> #{query.endDate}
  543. </if>
  544. </where>
  545. ORDER BY
  546. CASE WHEN status = '待审核' THEN 1
  547. WHEN status = '已完成' THEN 2
  548. END,create_date
  549. </select>
  550. <!-- 审核 -->
  551. <update id="checkToolUseQtyAssess" parameterType="ToolUseQtyAssessData">
  552. update tool_use_qty_assess
  553. set actual_add_use_qty = #{addUseQty},
  554. status = #{status},
  555. checker = #{createBy},
  556. check_date = getDate()
  557. where id = #{id}
  558. </update>
  559. <!-- 更新工具实例寿命 -->
  560. <update id="updateToolDetailUseQty" parameterType="ToolUseQtyAssessData">
  561. update ToolDetail
  562. set EstUseQty = #{estUseQty}
  563. where ToolID = #{toolId} and Site = #{site} and ToolInstanceID = #{toolInstanceId}
  564. </update>
  565. <select id="getItemModal" resultType="com.jtem.modules.toolMan.entity.PartSubPropertiesValueData">
  566. SELECT a.PartNo,a.Site,a.CodeNo,a.SubCodeSeqNo,a.SubCodeDesc,a.ItemNo,a.PropertiesItemNo,a.TextValue,a.NumValue,a.RecordType
  567. ,b.ItemDesc ItemDesc,b.ValueType,b.ValueType_DB,b.ValueChooseFlag
  568. FROM PartSubPropertiesValue a left join PropertiesItem b on a.PropertiesItemNo=b.ItemNo
  569. <where>
  570. AND a.site =#{site}
  571. AND a.PartNo =#{toolID}
  572. </where>
  573. </select>
  574. <select id="checkItemNo" resultType="ToolSubPropertiesValueData">
  575. select ValueType_DB from PropertiesItem where itemNo=#{propertiesItemNo}
  576. </select>
  577. <select id="checkToolItemNo" resultType="ToolSubPropertiesValueData">
  578. select itemNo from ToolSubPropertiesValue where ToolItemNo=#{propertiesItemNo} and site=#{site} and ToolID=#{toolID}
  579. </select>
  580. <insert id="itemSaveData">
  581. insert into ToolSubPropertiesValue(ToolID,Site,CodeNo,SubCodeSeqNo,SubCodeDesc,
  582. ItemNo,PropertiesItemNo,TextValue,NumValue,RecordType,ToolItemNo) values
  583. (#{toolID},#{site},'*',1.0,'*',#{itemNo},#{propertiesItemNo},#{textValue},#{numValue,jdbcType=DOUBLE},'T',#{propertiesItemNo})
  584. </insert>
  585. <select id="getToolItemNo" resultType="Double">
  586. select isnull(max(ItemNo),0.0) +1 from ToolSubPropertiesValue where site=#{site} and ToolID=#{toolID}
  587. </select>
  588. <update id="updateToolItem" >
  589. update PartSubPropertiesValue set TextValue=#{textValue} , NumValue=#{numValue,jdbcType=DOUBLE} where PropertiesItemNo=#{propertiesItemNo} and site=#{site} and PartNo=#{partNo} and RecordType='T'
  590. </update>
  591. <delete id="deleteItemModal">
  592. delete from ToolSubPropertiesValue where ToolItemNo=#{propertiesItemNo} and site=#{site} and ToolID=#{toolID}
  593. </delete>
  594. <!-- 根据实例编码获取寿命评估记录 -->
  595. <select id="checkAssessRecord" resultType="ToolUseQtyAssessData" parameterType="ToolUseQtyAssessData">
  596. select
  597. id,
  598. tool_id,
  599. tool_instance_id,
  600. est_use_qty
  601. from tool_use_qty_assess
  602. where tool_id = #{toolId} and tool_instance_id = #{toolInstanceId} and status = '待审核'
  603. </select>
  604. <insert id="refreshItemModal">
  605. insert into PartSubPropertiesValue(PartNo,Site,CodeNo,SubCodeSeqNo,SubCodeDesc,
  606. ItemNo,PropertiesItemNo,TextValue,NumValue,RecordType)
  607. select #{toolId},#{site},a.CodeNo,1,a.SubCodeDesc,b.ItemNo,b.PropertiesItemNo,case when e.ValueType_DB='T' then e.DefaultValue
  608. else null end ,case when e.ValueType_DB='N' and e.DefaultValue!='' then e.DefaultValue else null end ,'T'
  609. from PartSubPropertiesValueHeader a left join PropertiesModelDetail b on a.CodeNo=b.CodeNo
  610. left join PartSubPropertiesValue c on c.Site=#{site} and c.PartNo=#{toolId} and c.RecordType='T' and b.ItemNo=c.ItemNo
  611. left join PropertiesItem e on b.PropertiesItemNo=e.ItemNo
  612. where c.ItemNo is null and a.RecordType='T'
  613. </insert>
  614. </mapper>